Example #1
0
        protected override void HandleStart(Player p, RoundsGame game_, string[] args)
        {
            if (game_.Running)
            {
                p.Message("{0} is already running", game_.GameName); return;
            }

            CountdownGame game  = (CountdownGame)game_;
            string        speed = args.Length > 1 ? args[1] : "";
            string        mode  = args.Length > 2 ? args[2] : "";

            switch (speed)
            {
            case "slow":     game.Interval = 800; break;

            case "normal":   game.Interval = 650; break;

            case "fast":     game.Interval = 500; break;

            case "extreme":  game.Interval = 300; break;

            case "ultimate": game.Interval = 150; break;

            default:
                p.Message("No speed specified, playing at 'normal' speed.");
                game.Interval = 650; speed = "normal"; break;
            }

            game.FreezeMode = mode == "freeze" || mode == "frozen";
            game.SpeedType  = speed;
            game.Start(p, "countdown", int.MaxValue);
        }
 public static void Call(RoundsGame game)
 {
     if (handlers.Count == 0)
     {
         return;
     }
     CallCommon(pl => pl(game));
 }
Example #3
0
        void HandleMapsChanged(RoundsGame game)
        {
            GamesHelper helper = GetGameHelper(game);

            if (helper == null)
            {
                return;
            }
            RunOnUI_Async(() => helper.UpdateMaps());
        }
        protected void SaveMapConfig(Player p, RoundsGameMapConfig cfg)
        {
            RoundsGame game = Game;

            cfg.Save(p.level.name);
            if (p.level == game.Map)
            {
                game.UpdateMapConfig();
            }
        }
 protected void HandleEnd(Player p, RoundsGame game)
 {
     if (game.RoundInProgress)
     {
         game.EndRound();
     }
     else
     {
         p.Message("No round is currently in progress");
     }
 }
        protected virtual void HandleStart(Player p, RoundsGame game, string[] args)
        {
            if (game.Running)
            {
                p.Message("{0} is already running", game.GameName); return;
            }

            string map = args.Length > 1 ? args[1] : "";

            game.Start(p, map, int.MaxValue);
        }
 protected void HandleGo(Player p, RoundsGame game)
 {
     if (!game.Running)
     {
         p.Message("{0} is not running", game.GameName);
     }
     else
     {
         PlayerActions.ChangeMap(p, game.Map);
     }
 }
 protected void HandleStatus(Player p, RoundsGame game)
 {
     if (!game.Running)
     {
         p.Message("{0} is not running", game.GameName);
     }
     else
     {
         p.Message("Running on map: " + game.Map.ColoredName);
         game.OutputStatus(p);
     }
 }
 protected void HandleStop(Player p, RoundsGame game)
 {
     if (!game.Running)
     {
         p.Message("{0} is not running", game.GameName);
     }
     else
     {
         game.End();
         Chat.MessageGlobal(game.GameName + " has ended! We hope you had fun!");
     }
 }
        public override void Use(Player p, string message, CommandData data)
        {
            RoundsGame game = Game;

            if (message.CaselessEq("go"))
            {
                HandleGo(p, game); return;
            }
            else if (IsInfoCommand(message))
            {
                HandleStatus(p, game); return;
            }
            if (!CheckExtraPerm(p, data, 1))
            {
                return;
            }

            if (message.CaselessEq("start") || message.CaselessStarts("start "))
            {
                HandleStart(p, game, message.SplitSpaces());
            }
            else if (message.CaselessEq("end"))
            {
                HandleEnd(p, game);
            }
            else if (message.CaselessEq("stop"))
            {
                HandleStop(p, game);
            }
            else if (message.CaselessEq("add"))
            {
                RoundsGameConfig.AddMap(p, p.level.name, p.level.Config, game);
            }
            else if (IsDeleteCommand(message))
            {
                RoundsGameConfig.RemoveMap(p, p.level.name, p.level.Config, game);
            }
            else if (message.CaselessStarts("set ") || message.CaselessStarts("setup "))
            {
                HandleSet(p, game, message.SplitSpaces());
            }
            else
            {
                Help(p);
            }
        }
        public GamesHelper(RoundsGame game,
                           CheckBox start_, CheckBox map, CheckBox main,
                           Button start, Button stop, Button end,
                           Button add, Button del, ListBox used, ListBox notUsed)
        {
            this.game = game;
            cbStart   = start_; cbMap = map; cbMain = main;
            btnStart  = start; btnStop = stop; btnEnd = end;
            btnAdd    = add; btnDel = del; lbUsed = used; lbNotUsed = notUsed;

            start.Click += StartGame_Click;
            stop.Click  += StopGame_Click;
            end.Click   += EndRound_Click;

            add.Click += AddMap_Click;
            del.Click += DelMap_Click;
        }
Example #12
0
        protected override void HandleStart(Player p, RoundsGame game_, string[] args)
        {
            if (game_.Running)
            {
                p.Message("{0} is already running", game_.GameName); return;
            }

            CountdownGame game  = (CountdownGame)game_;
            string        speed = args.Length > 1 ? args[1] : "";
            string        mode  = args.Length > 2 ? args[2] : "";

            if (!game.SetSpeed(speed))
            {
                p.Message("No speed specified, playing at 'normal' speed.");
                game.SetSpeed("normal");
            }

            game.FreezeMode = mode == "freeze" || mode == "frozen";
            game.Start(p, "countdown", int.MaxValue);
        }
Example #13
0
        protected override void HandleSet(Player p, RoundsGame game, string[] args)
        {
            string prop = args[1];

            if (prop.CaselessEq("spawn"))
            {
                HandleSetSpawn(p, args);
            }
            else if (prop.CaselessEq("block"))
            {
                HandleSetBlock(p, args);
            }
            else if (prop.CaselessEq("other"))
            {
                HandleSetOther(p, args);
            }
            else
            {
                Help(p, "set");
            }
        }
Example #14
0
        protected override void HandleSet(Player p, RoundsGame game, string[] args)
        {
            string       prop = args[1];
            CTFMapConfig cfg  = new CTFMapConfig();

            LoadMapConfig(p, cfg);

            if (prop.CaselessEq("bluespawn"))
            {
                cfg.BlueSpawn = (Vec3U16)p.Pos.FeetBlockCoords;
                p.Message("Set spawn of blue team to &b" + cfg.BlueSpawn);
                SaveMapConfig(p, cfg);
            }
            else if (prop.CaselessEq("redspawn"))
            {
                cfg.RedSpawn = (Vec3U16)p.Pos.FeetBlockCoords;
                p.Message("Set spawn of red team to &b" + cfg.RedSpawn);
                SaveMapConfig(p, cfg);
            }
            else if (prop.CaselessEq("blueflag"))
            {
                p.Message("Place or delete a block to set blue team's flag.");
                p.MakeSelection(1, cfg, BlueFlagCallback);
            }
            else if (prop.CaselessEq("redflag"))
            {
                p.Message("Place or delete a block to set red team's flag.");
                p.MakeSelection(1, cfg, RedFlagCallback);
            }
            else if (prop.CaselessEq("divider"))
            {
                cfg.ZDivider = p.Pos.BlockZ;
                p.Message("Set Z line divider to {0}.", cfg.ZDivider);
                SaveMapConfig(p, cfg);
            }
            else
            {
                Help(p, "set");
            }
        }
Example #15
0
        protected override void HandleSet(Player p, RoundsGame game_, string[] args)
        {
            if (args.Length < 4)
            {
                Help(p); return;
            }
            if (game_.Running)
            {
                p.Message("You must stop Countdown before replacing the map."); return;
            }

            ushort x = 0, y = 0, z = 0;

            if (!MapGen.GetDimensions(p, args, 1, ref x, ref y, ref z))
            {
                return;
            }

            CountdownGame game = (CountdownGame)game_;

            game.GenerateMap(p, x, y, z);
        }
Example #16
0
        protected override void HandleSet(Player p, RoundsGame game, string[] args)
        {
            ZSConfig    cfg  = ZSGame.Config;
            string      prop = args[1];
            LevelConfig lCfg = p.level.Config;

            if (prop.CaselessEq("map"))
            {
                p.Message("Pillaring allowed: &b" + lCfg.Pillaring);
                p.Message("Build type: &b" + lCfg.BuildType);
                p.Message("Round time: &b{0}" + lCfg.RoundTime.Shorten(true, true));
                return;
            }
            if (args.Length < 3)
            {
                Help(p, "set"); return;
            }

            if (prop.CaselessEq("hitbox"))
            {
                if (!CommandParser.GetReal(p, args[2], "Hitbox detection", ref cfg.HitboxDist, 0, 4))
                {
                    return;
                }
                p.Message("Set hitbox detection to &a" + cfg.HitboxDist + " %Sblocks apart");

                cfg.Save(); return;
            }
            else if (prop.CaselessEq("maxmove"))
            {
                if (!CommandParser.GetReal(p, args[2], "Max move distance", ref cfg.MaxMoveDist, 0, 4))
                {
                    return;
                }
                p.Message("Set max move distance to &a" + cfg.MaxMoveDist + " %Sblocks apart");

                cfg.Save(); return;
            }
            else if (prop.CaselessEq("pillaring"))
            {
                if (!CommandParser.GetBool(p, args[2], ref lCfg.Pillaring))
                {
                    return;
                }

                p.Message("Set pillaring allowed to &b" + lCfg.Pillaring);
                game.UpdateAllStatus2();
            }
            else if (prop.CaselessEq("build"))
            {
                if (!CommandParser.GetEnum(p, args[2], "Build type", ref lCfg.BuildType))
                {
                    return;
                }
                p.level.UpdateBlockPermissions();

                p.Message("Set build type to &b" + lCfg.BuildType);
                game.UpdateAllStatus2();
            }
            else if (prop.CaselessEq("roundtime"))
            {
                if (!ParseTimespan(p, "round time", args, ref lCfg.RoundTime))
                {
                    return;
                }
            }
            else
            {
                Help(p, "set"); return;
            }
            Level.SaveSettings(p.level);
        }
Example #17
0
        protected override void HandleSet(Player p, RoundsGame game_, string[] args)
        {
            TWGame      game    = (TWGame)game_;
            TWMapConfig cfg     = new TWMapConfig();
            TWConfig    gameCfg = TWGame.Config;

            LoadMapConfig(p, cfg);
            if (args.Length == 1)
            {
                Help(p, "set"); return;
            }
            if (args.Length == 2)
            {
                OutputStatus(p, gameCfg, cfg); return;
            }

            string prop = args[1], value = args[2];

            if (prop.CaselessEq("spawn"))
            {
                if (gameCfg.Mode == TWGameMode.FFA)
                {
                    p.Message("&WCannot set spawns in Free For All mode"); return;
                }

                if (value.CaselessEq("red"))
                {
                    cfg.RedSpawn = (Vec3U16)p.Pos.FeetBlockCoords;
                    p.Message("Set &cRed &Sspawn");
                }
                else if (value.CaselessEq("blue"))
                {
                    cfg.BlueSpawn = (Vec3U16)p.Pos.FeetBlockCoords;
                    p.Message("Set &9Blue &Sspawn");
                }
                else
                {
                    Help(p, "team"); return;
                }
            }
            else if (prop.CaselessEq("tnt"))
            {
                int amount = 1;
                if (!CommandParser.GetInt(p, value, "TNT at a time", ref amount, 0))
                {
                    return;
                }
                cfg.MaxActiveTnt = amount;

                p.Message("Number of TNTs placeable by a player at a time is now {0}",
                          amount == 0 ? "unlimited" : value);
            }
            else if (prop.CaselessEq("graceperiod"))
            {
                SetBool(p, ref cfg.GracePeriod, value, "Grace period");
            }
            else if (prop.CaselessEq("gracetime"))
            {
                TimeSpan time = default(TimeSpan);
                if (!CommandParser.GetTimespan(p, value, ref time, "set grace time to", "s"))
                {
                    return;
                }
                cfg.GracePeriodTime = time;

                p.Message("Grace period is now {0}", time.Shorten(true, true));
            }
            else if (prop.CaselessEq("gamemode"))
            {
                if (value.CaselessEq("tdm"))
                {
                    if (gameCfg.Mode == TWGameMode.FFA)
                    {
                        if (p.level != game.Map)
                        {
                            p.Message("Changed gamemode to Team Deathmatch");
                        }
                        game.ModeTDM();
                    }
                    else
                    {
                        p.Message("&cGamemode is already Team Deathmatch"); return;
                    }
                }
                else if (value.CaselessEq("ffa"))
                {
                    if (gameCfg.Mode == TWGameMode.TDM)
                    {
                        if (p.level != game.Map)
                        {
                            p.Message("Changed gamemode to Free For All");
                        }
                        game.ModeFFA();
                    }
                    else
                    {
                        p.Message("&cGamemode is already Free For All"); return;
                    }
                }
                else
                {
                    Help(p, "other"); return;
                }
            }
            else if (prop.CaselessEq("difficulty"))
            {
                TWDifficulty diff = TWDifficulty.Easy;
                if (!CommandParser.GetEnum(p, value, "Difficulty", ref diff))
                {
                    return;
                }
                SetDifficulty(game, diff, p);
            }
            else if (prop.CaselessEq("score"))
            {
                if (args.Length < 4)
                {
                    Help(p, "score"); return;
                }
                if (!HandleSetScore(p, cfg, args))
                {
                    return;
                }
            }
            else if (prop.CaselessEq("balanceteams"))
            {
                SetBool(p, ref cfg.BalanceTeams, value, "Team balancing");
            }
            else if (prop.CaselessEq("teamkill"))
            {
                SetBool(p, ref cfg.TeamKills, value, "Team killing");
            }
            else if (prop.CaselessEq("zone"))
            {
                if (args.Length < 4)
                {
                    Help(p, "zone"); return;
                }

                if (value.CaselessEq("notnt"))
                {
                    if (!HandleZone(p, game, true, args))
                    {
                        return;
                    }
                }
                else if (value.CaselessEq("nodestroy"))
                {
                    if (!HandleZone(p, game, false, args))
                    {
                        return;
                    }
                }
                else
                {
                    Help(p, "zone"); return;
                }
            }
            else
            {
                OutputStatus(p, gameCfg, cfg); return;
            }
            SaveMapConfig(p, cfg);
        }
 protected abstract void HandleSet(Player p, RoundsGame game, string[] args);