From c598df000655329e6ab75b671c7a5fb607eb7493 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Sun, 13 Mar 2016 21:38:33 +1100 Subject: [PATCH] Modularise /zg. --- Commands/Fun/CmdBounty.cs | 2 +- Commands/Fun/CmdZombieGame.cs | 151 ++++++++++++++++++---------------- 2 files changed, 81 insertions(+), 72 deletions(-) diff --git a/Commands/Fun/CmdBounty.cs b/Commands/Fun/CmdBounty.cs index 4a2d111dd..950f1a408 100644 --- a/Commands/Fun/CmdBounty.cs +++ b/Commands/Fun/CmdBounty.cs @@ -46,7 +46,7 @@ namespace MCGalaxy.Commands { 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 wants the brain of ! An bounty for x was placed on them. + // "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. } diff --git a/Commands/Fun/CmdZombieGame.cs b/Commands/Fun/CmdZombieGame.cs index fa658569e..153bbcfa8 100644 --- a/Commands/Fun/CmdZombieGame.cs +++ b/Commands/Fun/CmdZombieGame.cs @@ -1,21 +1,21 @@ /* - Copyright 2010 MCLawl Team - + Copyright 2010 MCLawl Team - Created by Snowl (David D.) and Cazzar (Cayde D.) - Dual-licensed under the Educational Community License, Version 2.0 and - the GNU General Public License, Version 3 (the "Licenses"); you may - not use this file except in compliance with the Licenses. You may - obtain a copy of the Licenses at - - http://www.osedu.org/licenses/ECL-2.0 - http://www.gnu.org/licenses/gpl-3.0.html - - Unless required by applicable law or agreed to in writing, - software distributed under the Licenses are distributed on an "AS IS" - 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. -*/ + Dual-licensed under the Educational Community License, Version 2.0 and + the GNU General Public License, Version 3 (the "Licenses"); you may + not use this file except in compliance with the Licenses. You may + obtain a copy of the Licenses at + + http://www.osedu.org/licenses/ECL-2.0 + http://www.gnu.org/licenses/gpl-3.0.html + + Unless required by applicable law or agreed to in writing, + software distributed under the Licenses are distributed on an "AS IS" + 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. + */ using System; namespace MCGalaxy.Commands { @@ -27,64 +27,73 @@ namespace MCGalaxy.Commands public override bool museumUsable { get { return false; } } public override LevelPermission defaultRank { get { return LevelPermission.Operator; } } public CmdZombieGame() { } - public override void Use(Player p, string message) - { - if (String.IsNullOrEmpty(message)) { Help(p); return; } - string[] s = message.ToLower().Split(' '); - if (s[0] == "status") - { - switch (Server.zombie.Status) { - case ZombieGameStatus.NotStarted: - Player.SendMessage(p, "Zombie Survival is not ccurrently running."); return; - case ZombieGameStatus.InfiniteRounds: - Player.SendMessage(p, "Zombie Survival is currently in progress with infinite rounds."); return; - case ZombieGameStatus.SingleRound: - Player.SendMessage(p, "Zombie Survival game currently in progress."); return; - case ZombieGameStatus.VariableRounds: - Player.SendMessage(p, "Zombie Survival game currently in progress with " + Server.zombie.MaxRounds + " rounds."); return; - case ZombieGameStatus.LastRound: - Player.SendMessage(p, "Zombie Survival game currently in progress, with this round being the final round."); return; - } - return; - } - else if (s[0] == "start") - { - if (Server.zombie.Status != ZombieGameStatus.NotStarted) { - Player.SendMessage(p, "There is already a Zombie Survival game currently in progress."); return; - } - if (s.Length == 2) { - int rounds = 1; - if (!int.TryParse(s[1], out rounds)) { - Player.SendMessage(p, "You need to specify a valid option!"); return; - } - ZombieGameStatus status = rounds == 0 ? - ZombieGameStatus.InfiniteRounds : ZombieGameStatus.VariableRounds; - Server.zombie.Start(status, rounds); - } else { - Server.zombie.Start(ZombieGameStatus.SingleRound, 0); - } - } - else if (s[0] == "stop") - { - if (Server.zombie.Status == ZombieGameStatus.NotStarted) { - Player.SendMessage(p, "There is no Zombie Survival game currently in progress."); return; - } - Player.GlobalMessage("The current game of Zombie Survival will end this round!"); - Server.zombie.Status = ZombieGameStatus.LastRound; - } - else if (s[0] == "force") - { - if (Server.zombie.Status == ZombieGameStatus.NotStarted) { - Player.SendMessage(p, "There is no Zombie Survival game currently in progress."); return; - } - Server.s.Log("Zombie Survival ended forcefully by " + p.name); - Server.zombie.aliveCount = 0; - Server.zombie.ResetState(); + + public override void Use(Player p, string message) { + if (message == "") { Help(p); return; } + string[] args = message.ToLower().Split(' '); + switch (args[0]) { + case "status": HandleStatus(p, message, args); break; + case "start": HandleStart(p, message, args); break; + case "stop": HandleStop(p, message, args); break; + case "force": HandleForceStop(p, message, args); break; + case "hitbox": HandleHitbox(p, message, args); break; } } - public override void Help(Player p) - { - Player.SendMessage(p, "/zombiegame - Shows this help menu."); + + static void HandleStatus(Player p, string message, string[] args) { + switch (Server.zombie.Status) { + case ZombieGameStatus.NotStarted: + Player.SendMessage(p, "Zombie Survival is not ccurrently running."); return; + case ZombieGameStatus.InfiniteRounds: + Player.SendMessage(p, "Zombie Survival is currently in progress with infinite rounds."); return; + case ZombieGameStatus.SingleRound: + Player.SendMessage(p, "Zombie Survival game currently in progress."); return; + case ZombieGameStatus.VariableRounds: + Player.SendMessage(p, "Zombie Survival game currently in progress with " + Server.zombie.MaxRounds + " rounds."); return; + case ZombieGameStatus.LastRound: + Player.SendMessage(p, "Zombie Survival game currently in progress, with this round being the final round."); return; + } + } + + static void HandleStart(Player p, string message, string[] args) { + if (Server.zombie.Status != ZombieGameStatus.NotStarted) { + Player.SendMessage(p, "There is already a Zombie Survival game currently in progress."); return; + } + if (args.Length == 2) { + int rounds = 1; + if (!int.TryParse(args[1], out rounds)) { + Player.SendMessage(p, "You need to specify a valid option!"); return; + } + ZombieGameStatus status = rounds == 0 ? + ZombieGameStatus.InfiniteRounds : ZombieGameStatus.VariableRounds; + Server.zombie.Start(status, rounds); + } else { + Server.zombie.Start(ZombieGameStatus.SingleRound, 0); + } + } + + static void HandleStop(Player p, string message, string[] args) { + if (Server.zombie.Status == ZombieGameStatus.NotStarted) { + Player.SendMessage(p, "There is no Zombie Survival game currently in progress."); return; + } + Player.GlobalMessage("The current game of Zombie Survival will end this round!"); + Server.zombie.Status = ZombieGameStatus.LastRound; + } + + static void HandleForceStop(Player p, string message, string[] args) { + if (Server.zombie.Status == ZombieGameStatus.NotStarted) { + Player.SendMessage(p, "There is no Zombie Survival game currently in progress."); return; + } + Server.s.Log("Zombie Survival ended forcefully by " + p.name); + Server.zombie.aliveCount = 0; + Server.zombie.ResetState(); + } + + static void HandleHitbox(Player p, string message, string[] args) { + + } + + public override void Help(Player p) { Player.SendMessage(p, "/zombiegame start - Starts a Zombie Survival game for one round."); Player.SendMessage(p, "/zombiegame start 0 - Starts a Zombie Survival game for an unlimited amount of rounds."); Player.SendMessage(p, "/zombiegame start [x] - Starts a Zombie Survival game for [x] amount of rounds.");