From c9ae84d5f6d1c02d9a1e7f4baa8b52ec0c4af5ed Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Sun, 13 Mar 2016 23:18:22 +1100 Subject: [PATCH] Fix bounties for zombie survival. --- Commands/Fun/CmdBounty.cs | 20 ++++++++----- Games/ZombieSurvival/ZombieGame.Core.cs | 38 ++++++++++++++++--------- Games/ZombieSurvival/ZombieGame.cs | 8 ++---- Player/Player.cs | 7 +---- 4 files changed, 40 insertions(+), 33 deletions(-) diff --git a/Commands/Fun/CmdBounty.cs b/Commands/Fun/CmdBounty.cs index 950f1a408..8b1e6c2e9 100644 --- a/Commands/Fun/CmdBounty.cs +++ b/Commands/Fun/CmdBounty.cs @@ -14,7 +14,7 @@ BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the Licenses for the specific language governing permissions and limitations under the Licenses. -*/ + */ namespace MCGalaxy.Commands { public sealed class CmdBounty : Command { @@ -24,7 +24,7 @@ namespace MCGalaxy.Commands { public override string type { get { return CommandTypes.Games; } } public override bool museumUsable { get { return true; } } public override LevelPermission defaultRank { get { return LevelPermission.Banned; } } - public override bool Enabled { get { return Server.ZombieModeOn; } } + public override bool Enabled { get { return Server.ZombieModeOn; } } public CmdBounty() { } public override void Use(Player p, string message) { @@ -41,13 +41,19 @@ namespace MCGalaxy.Commands { Player.SendMessage(p, "You do not have enough " + Server.moneys + " to place such a large bountry."); return; } - BountyData data; - if (Server.zombie.Bounties.TryGetValue(who.name, out data) && data.Amount >= amount) { + BountyData old; + if (Server.zombie.Bounties.TryGetValue(who.name, out old) && old.Amount >= amount) { Player.SendMessage(p, "There is already a larger active bounty for " + who.name + "."); return; } - // TODO here - actually announce the bounty and place it - // "Looks like someone really wants the brains of ! An bounty for x was placed on them. - // " is popular! The bounty on them was increased from to money. + + if (old == null) { + Player.GlobalMessage("Looks like someone really wants the brains of " + who.FullName + + "%S! A bounty of &a" + amount + " %S" + Server.moneys + " was placed on them."); + } else { + Player.GlobalMessage(who.FullName + " %Sis popular! The bounty on them was increased from &a" + old.Amount + + " %Sto &a" + amount + " %S" + Server.moneys + "."); + } + Server.zombie.Bounties[who.name] = new BountyData(p, amount); } public override void Help(Player p) { diff --git a/Games/ZombieSurvival/ZombieGame.Core.cs b/Games/ZombieSurvival/ZombieGame.Core.cs index 5bc3d01f8..4d99f4a56 100644 --- a/Games/ZombieSurvival/ZombieGame.Core.cs +++ b/Games/ZombieSurvival/ZombieGame.Core.cs @@ -75,7 +75,7 @@ namespace MCGalaxy { Player.GlobalMessage(player.color + player.name + " %Sstarted the infection!"); player.infected = true; - CheckPlayerColor(player, Colors.red); + UpdatePlayerColor(player, Colors.red); RoundInProgress = true; int roundMins = random.Next(5, 8); @@ -149,11 +149,11 @@ namespace MCGalaxy { infectd.ForEach( delegate(Player pKiller) { - CheckPlayerColor(pKiller, Colors.red); + UpdatePlayerColor(pKiller, Colors.red); alive.ForEach( delegate(Player pAlive) { - CheckPlayerColor(pAlive, pAlive.group.color); + UpdatePlayerColor(pAlive, pAlive.group.color); if (Math.Abs(pAlive.pos[0] - pKiller.pos[0]) > HitboxPrecision || Math.Abs(pAlive.pos[1] - pKiller.pos[1]) > HitboxPrecision || Math.Abs(pAlive.pos[2] - pKiller.pos[2]) > HitboxPrecision) @@ -178,13 +178,22 @@ namespace MCGalaxy { infectCombo = 0; } lastPlayerToInfect = pKiller.name; - pKiller.infectThisRound++; pKiller.playersInfected++; Player.GlobalMessage(String.Format( messages[random.Next(messages.Length)], Colors.red + pKiller.DisplayName + Colors.yellow, Colors.red + pAlive.DisplayName + Colors.yellow)); - CheckPlayerColor(pAlive, Colors.red); + + BountyData bounty; + if (Bounties.TryGetValue(pAlive.name, out bounty)) + Bounties.Remove(pAlive.name); + if (bounty != null) { + Player.GlobalMessage(pKiller.FullName + " %Scollected the bounty of &a" + + bounty.Amount + " %S" + Server.moneys + " on " + pAlive.FullName + "%S."); + bounty.Origin.money = Math.Max(0, bounty.Origin.money - bounty.Amount); + pKiller.money += bounty.Amount; + } + UpdatePlayerColor(pAlive, Colors.red); } }); }); @@ -192,7 +201,7 @@ namespace MCGalaxy { } } - static void CheckPlayerColor(Player p, string color) { + static void UpdatePlayerColor(Player p, string color) { if (p.color == color) return; p.color = color; Player.GlobalDespawn(p, false); @@ -211,12 +220,13 @@ namespace MCGalaxy { public void HandOutRewards() { RoundInProgress = false; + Bounties.Clear(); if (Status == ZombieGameStatus.NotStarted) return; Player.GlobalMessage(Colors.lime + "The game has ended!"); - if(aliveCount == 0) - Player.GlobalMessage(Colors.maroon + "Zombies have won this round."); - else - Player.GlobalMessage(Colors.green + "Congratulations to our survivor(s)"); + if (aliveCount == 0) Player.GlobalMessage(Colors.maroon + "Zombies have won this round."); + else if (aliveCount == 1) Player.GlobalMessage(Colors.green + "Congratulations to the sole survivor:"); + else Player.GlobalMessage(Colors.green + "Congratulations to the survivors:"); + timer.Enabled = false; string playersString = ""; Player[] online = null; @@ -248,14 +258,14 @@ namespace MCGalaxy { Player.GlobalDespawn(pl, false); Player.GlobalSpawn(pl, pl.pos[0], pl.pos[1], pl.pos[2], pl.rot[0], pl.rot[1], false); if (money == -1) { - pl.SendMessage("You may not hide inside a block! No " + Server.moneys + " for you!"); money = 0; + pl.SendMessage("You may not hide inside a block! No " + Server.moneys + " for you."); money = 0; } else if (money > 0) { pl.SendMessage( Colors.gold + "You gained " + money + " " + Server.moneys); } + pl.blockCount = 50; pl.playersInfected = 0; - pl.money += money; - + pl.money += money; pl.infected = false; pl.color = pl.group.color; if (pl.referee) { @@ -269,7 +279,7 @@ namespace MCGalaxy { void ResetPlayer(Player p, ref string playersString) { p.blockCount = 50; p.infected = false; - p.infectThisRound = 0; + p.playersInfected = 0; if (p.level.name == currentLevelName) { p.color = p.group.color; diff --git a/Games/ZombieSurvival/ZombieGame.cs b/Games/ZombieSurvival/ZombieGame.cs index 7c8f5cfd6..2a0dc901d 100644 --- a/Games/ZombieSurvival/ZombieGame.cs +++ b/Games/ZombieSurvival/ZombieGame.cs @@ -134,9 +134,7 @@ namespace MCGalaxy { infectd.Add(p); alive.Remove(p); p.infected = true; - p.color = Colors.red; - Player.GlobalDespawn(p, false); - Player.GlobalSpawn(p, p.pos[0], p.pos[1], p.pos[2], p.rot[0], p.rot[1], false); + UpdatePlayerColor(p, Colors.red); aliveCount = alive.Count; } @@ -146,9 +144,7 @@ namespace MCGalaxy { infectd.Remove(p); alive.Add(p); p.infected = false; - p.color = p.group.color; - Player.GlobalDespawn(p, false); - Player.GlobalSpawn(p, p.pos[0], p.pos[1], p.pos[2], p.rot[0], p.rot[1], false); + UpdatePlayerColor(p, p.group.color); aliveCount = alive.Count; } diff --git a/Player/Player.cs b/Player/Player.cs index 402585ae4..309d885d1 100644 --- a/Player/Player.cs +++ b/Player/Player.cs @@ -190,16 +190,11 @@ namespace MCGalaxy { public int blockCount = 50; public bool voted = false; public int blocksStacked = 0; - public int infectThisRound = 0; - public int lastYblock = 0; - public int lastXblock = 0; - public int lastZblock = 0; + public int lastYblock = 0, lastXblock = 0, lastZblock = 0; public bool infected = false; public bool aka = false; public bool flipHead = true; public int playersInfected = 0; - public int NoClipcount = 0; - //Tnt Wars public bool PlayingTntWars = false;