Fix CPE messages not being reset for zombie survival, fixes #124.

This commit is contained in:
UnknownShadow200 2016-04-07 12:13:50 +10:00
parent 16a3341282
commit dfd65bbd77
4 changed files with 34 additions and 21 deletions

View File

@ -56,7 +56,7 @@ namespace MCGalaxy {
if (i >= red && i <= white) if (i >= red && i <= white)
Properties[i].KilledByLava = true; Properties[i].KilledByLava = true;
if (i == air || i == shrub || (i >= yellowflower && i <= redmushroom) { if (i == air || i == shrub || (i >= yellowflower && i <= redmushroom)) {
Properties[i].KilledByLava = true; Properties[i].KilledByLava = true;
Properties[i].KilledByWater = true; Properties[i].KilledByWater = true;
} }

View File

@ -23,7 +23,7 @@ namespace MCGalaxy
{ {
public static bool Walkthrough(byte type) { public static bool Walkthrough(byte type) {
return type == air || type == shrub || (type >= water && type <= lavastill) return type == air || type == shrub || (type >= water && type <= lavastill)
&& (type >= yelllowflower && type <= redmushroom); && (type >= yellowflower && type <= redmushroom);
} }
public static bool AllowBreak(byte type) public static bool AllowBreak(byte type)
@ -85,7 +85,7 @@ namespace MCGalaxy
} }
public static bool Placable(byte type) { public static bool Placable(byte type) {
return !(type == blackrock || (type >= water && type <= lavstill) return !(type == blackrock || (type >= water && type <= lavastill))
&& type < Block.CpeCount; && type < Block.CpeCount;
} }

View File

@ -87,7 +87,7 @@ namespace MCGalaxy.Games {
Player[] players = p.Game.Infected ? Infected.Items : Alive.Items; Player[] players = p.Game.Infected ? Infected.Items : Alive.Items;
string type = p.Game.Infected ? " &cto zombies%S: " : " &ato humans%S: "; string type = p.Game.Infected ? " &cto zombies%S: " : " &ato humans%S: ";
foreach (Player pl in players) foreach (Player pl in players)
pl.SendMessage(p.color + p.DisplayName + type + message.Substring(1)); pl.SendMessage(p.color + p.DisplayName + type + message.Substring(1));
return true; return true;
} else if (message[0] == '`' && message.Length > 1) { } else if (message[0] == '`' && message.Length > 1) {
if (p.Game.Team == null) { if (p.Game.Team == null) {
@ -122,7 +122,7 @@ namespace MCGalaxy.Games {
} }
public override void PlayerJoinedLevel(Player p, Level lvl, Level oldLvl) { public override void PlayerJoinedLevel(Player p, Level lvl, Level oldLvl) {
p.SendCpeMessage(CpeMessageType.BottomRight2, ""); p.SendCpeMessage(CpeMessageType.BottomRight2, "");
p.SendCpeMessage(CpeMessageType.BottomRight1, ""); p.SendCpeMessage(CpeMessageType.BottomRight1, "");
if (RoundInProgress && lvl.name.CaselessEq(CurLevelName)) { if (RoundInProgress && lvl.name.CaselessEq(CurLevelName)) {
if (Running && p != null) { if (Running && p != null) {
@ -152,30 +152,36 @@ namespace MCGalaxy.Games {
return; return;
} }
p.SendCpeMessage(CpeMessageType.Status1, ""); ResetCpeMessages(p);
p.SendCpeMessage(CpeMessageType.Status2, "");
p.SendCpeMessage(CpeMessageType.Status3, "");
Alive.Remove(p); Alive.Remove(p);
Infected.Remove(p); Infected.Remove(p);
if (oldLvl != null && oldLvl.name.CaselessEq(CurLevelName)) if (oldLvl != null && oldLvl.name.CaselessEq(CurLevelName))
UpdateAllPlayerStatus(); UpdateAllPlayerStatus();
} }
void ResetCpeMessages(Player p) {
p.SendCpeMessage(CpeMessageType.Status1, "");
p.SendCpeMessage(CpeMessageType.Status2, "");
p.SendCpeMessage(CpeMessageType.Status3, "");
p.SendCpeMessage(CpeMessageType.BottomRight1, "");
p.SendCpeMessage(CpeMessageType.BottomRight2, "");
}
public override bool PlayerCanJoinLevel(Player p, Level lvl, Level oldLvl) { public override bool PlayerCanJoinLevel(Player p, Level lvl, Level oldLvl) {
if (!oldLvl.name.CaselessEq(CurLevelName)) return true; if (!oldLvl.name.CaselessEq(CurLevelName)) return true;
if (lvl.name.CaselessEq(CurLevelName)) return true; if (lvl.name.CaselessEq(CurLevelName)) return true;
if (RoundInProgress && !p.Game.Referee) { if (RoundInProgress && !p.Game.Referee) {
p.SendMessage("Sorry, you cannot leave a zombie survival map until the current round has ended."); p.SendMessage("Sorry, you cannot leave a zombie survival map until the current round has ended.");
return false; return false;
} }
return true; return true;
} }
public override void PlayerMoneyChanged(Player p) { public override void PlayerMoneyChanged(Player p) {
if (!Running || !p.level.name.CaselessEq(CurLevelName)) return; if (!Running || !p.level.name.CaselessEq(CurLevelName)) return;
string moneyMsg = "&a" + p.money + " %S" + Server.moneys; string moneyMsg = "&a" + p.money + " %S" + Server.moneys;
string stateMsg = " and you are " + (p.Game.Infected ? "&cdead" : "&aalive"); string stateMsg = " and you are " + (p.Game.Infected ? "&cdead" : "&aalive");
p.SendCpeMessage(CpeMessageType.Status3, moneyMsg + stateMsg); p.SendCpeMessage(CpeMessageType.Status3, moneyMsg + stateMsg);
} }
} }

View File

@ -203,11 +203,18 @@ namespace MCGalaxy.Games {
RoundInProgress = false; RoundInProgress = false;
RoundStart = DateTime.MinValue; RoundStart = DateTime.MinValue;
RoundEnd = DateTime.MinValue; RoundEnd = DateTime.MinValue;
Player[] online = PlayerInfo.Online.Items;
foreach (Player pl in online) {
pl.Game.RatedMap = false;
pl.Game.PledgeSurvive = false;
if (pl.level == null || !pl.level.name.CaselessEq(CurLevelName))
continue;
ResetCpeMessages(pl);
}
LastLevelName = ""; LastLevelName = "";
CurLevelName = ""; CurLevelName = "";
CurLevel = null; CurLevel = null;
Player[] online = PlayerInfo.Online.Items;
foreach (Player pl in online) { foreach (Player pl in online) {
pl.Game.RatedMap = false; pl.Game.RatedMap = false;
pl.Game.PledgeSurvive = false; pl.Game.PledgeSurvive = false;