Esempio n. 1
0
        // Tests for board size 12
        public void Run()
        {
            Coord stc1 = Constants.StringToCoord("A1");
            Coord stc2 = Constants.StringToCoord("E10");

            bool tc1 = Constants.ValidCoord("A1");
            bool tc2 = Constants.ValidCoord("E10");
            bool tc3 = !Constants.ValidCoord("M1");
            bool tc4 = !Constants.ValidCoord("F13");
            bool tc5 = !Constants.ValidCoord("2A");

            Constants.Teams got1 = Constants.GetOppositeTeam(Constants.Teams.Red);
            Constants.Teams got2 = Constants.GetOppositeTeam(Constants.Teams.Blue);

            Tile t1 = new Tile(new Coord("A", 1));
            Tile t2 = new Tile(new Coord("L", 12));

            Settlement s1      = new Settlement(Constants.Teams.Red, t1);
            bool       s1Enemy = !s1.InEnemyTerritory;
            Settlement s2      = new Settlement(Constants.Teams.Blue, t1);
            bool       s2Enemy = s2.InEnemyTerritory;
            Settlement s3      = new Settlement(Constants.Teams.Red, t2);
            bool       s3Enemy = s3.InEnemyTerritory;
            Settlement s4      = new Settlement(Constants.Teams.Blue, t2);
            bool       s4Enemy = !s4.InEnemyTerritory;

            Board board = new Board();

            Tile bgt1 = board.GetTile("A", 1);
            Tile bgt2 = board.GetTile("E", 10);

            Tile bgt3 = board.GetTile(bgt1.Coord);
            Tile bgt4 = board.GetTile(bgt2.Coord);

            Tile tgt1  = board.TryGetTile(0, 0);
            bool tgtc1 = tgt1.Coord == new Coord("A", 1);
            Tile tgt2  = board.TryGetTile(4, 9);
            bool tgtc2 = tgt2.Coord == new Coord("E", 10);
            bool tgt3  = board.TryGetTile(12, 12) == null;
            bool tgt4  = board.TryGetTile(-1, -1) == null;

            var  bgg1  = board.GetGrid(stc1, Constants.MissileExplosionSize);
            bool bgg1s = bgg1.Count == 4;
            var  bgg2  = board.GetGrid(stc2, Constants.MissileExplosionSize);
            bool bgg2s = bgg2.Count == 9;

            Game game = new Game(string.Empty, string.Empty);

            game.TeamTurn = Constants.Teams.Red;
            bool cy1    = game.Year == 1;
            var  aps1   = game.AttemptPlaySettlements("A1");
            bool aps1c  = aps1.Count == 0;
            bool aps1cp = game.board.GetTile("A", 1).HasSettlement;
            var  pm1    = game.PlayMissiles("L12");
            bool pm1c   = pm1.Count == 0;

            game.SwitchTeamTurn();
            bool ctt1   = game.TeamTurn == Constants.Teams.Blue;
            var  aps2   = game.AttemptPlaySettlements("L12", "A1");
            bool aps2c  = aps2.Count == 1;
            bool aps2cc = aps2[0] == "A1";
            bool aps2cp = game.board.GetTile("L", 12).HasSettlement;
            var  pm2    = game.PlayMissiles("A1");
            bool pm2c   = pm2.Count == 1;
            bool sc1    = pm2[0].Tile.Coord == new Coord("A", 1);
            bool st1    = pm2[0].OwningTeam == Constants.Teams.Red;
            //game.RemoveDestroyedSettlements(pm2);
            var  at1  = game.board.GetTile("A", 1);
            bool ats1 = at1.HasSettlement == false;
            bool kp1  = !game.KillPopulation;

            game.Advance();
            bool cy2 = game.Year == 2;
            bool cp1 = game.RedTeam.Population == 1000;
            bool cp2 = game.BlueTeam.Population == 1000;

            game.RemoveDestroyedSettlements(game.PlayMissiles("A1"));
            game.SwitchTeamTurn();
            bool ctt2 = game.TeamTurn == Constants.Teams.Red;
            var  f1   = game.AttemptPlaySettlements("C8");
            bool f1c  = f1.Count == 0;

            game.Advance();
            bool cy3 = game.Year == 3;
            bool cp3 = game.RedTeam.Population == 4000;
            bool cp4 = game.BlueTeam.Population == 3000;

            game.KillPopulation = true;
            game.Advance();
            bool cy4 = game.Year == 4;
            bool cp5 = game.RedTeam.Population == 12000;
            bool cp6 = game.BlueTeam.Population == 7000;
            var  pm3 = game.PlayMissiles("D9");

            game.RemoveDestroyedSettlements(pm3);
            game.Advance();
            bool cy5 = game.Year == 5;
            bool cp7 = game.RedTeam.Population == 4000;
            bool cp8 = game.BlueTeam.Population == 5000;

            Debug.WriteLine("");
        }
Esempio n. 2
0
        public List <GameInstruction> OutputEndOfRound()
        {
            List <GameInstruction> instructions = new List <GameInstruction>();

            game.CurrentPlayingTeam.Moves = 0;
            game.Advance();
            var pointAnnoucment = new GameInstruction($"Red: {game.GetTeamPopulationTotalString(Constants.Teams.Red)} ({game.GetTeamPopulationDifferenceString(Constants.Teams.Red)}). Blue: {game.GetTeamPopulationTotalString(Constants.Teams.Blue)} ({game.GetTeamPopulationDifferenceString(Constants.Teams.Blue)}).", BothChannels);

            instructions.Add(pointAnnoucment);
            if (game.RedTeam.Population >= Constants.WinningScore &&
                game.BlueTeam.Population >= Constants.WinningScore)
            {
                if (game.RedTeam.Population > game.BlueTeam.Population)
                {
                    var i = new GameInstruction("The Red side has won the game.", BothChannels);
                    instructions.Add(i);
                }
                else if (game.RedTeam.Population < game.BlueTeam.Population)
                {
                    var i = new GameInstruction("The Blue side has won the game.", BothChannels);
                    instructions.Add(i);
                }
                else
                {
                    var i = new GameInstruction("The game has ended in a draw.", BothChannels);
                    instructions.Add(i);
                }
                GameIsOver = true;
                return(instructions);
            }
            else if (game.RedTeam.Population >= Constants.WinningScore)
            {
                var i = new GameInstruction("The Red side has won the game.", BothChannels);
                instructions.Add(i);
                GameIsOver = true;
                return(instructions);
            }
            else if (game.BlueTeam.Population >= Constants.WinningScore)
            {
                var i = new GameInstruction("The Blue side has won the game.", BothChannels);
                instructions.Add(i);
                GameIsOver = true;
                return(instructions);
            }
            if (game.ResolveSwap)
            {
                var swapAnnoucement = new GameInstruction("PLEASE SWITCH SIDES. YOU ARE NOW ON THE OTHER TEAM. MOVE POSITIONS. REMEMBER, G.O.D. IS ON YOUR SIDE.", BothChannels);
                instructions.Add(swapAnnoucement);
                if (!game.AlreadySwapped)
                {
                    var gameChangeAnnouncement = new GameInstruction("Points are now people. When you bomb a tile you kill all people living the affected settlements.", BothChannels);
                    instructions.Add(gameChangeAnnouncement);
                    var newScoreAnnouncement = new GameInstruction($"You are now trying to reach a population of {Constants.WinningScore}.", BothChannels);
                    instructions.Add(newScoreAnnouncement);
                    var drawI = new GameInstruction($"You can now initiate a draw by sending draw. Both sides must agree to draw on the same turn. You can propose a draw every turn.", BothChannels);
                    instructions.Add(drawI);
                }
                game.ResolveSwap    = false;
                game.AlreadySwapped = true;
                game.StartKilingPopulation();
            }
            instructions.AddRange(ResetDraw());
            partOfRound    = HalfOfRound.FirstHalf;
            sectionOfRound = SectionOfRound.Settlements;
            instructions.AddRange(StartYear());
            return(instructions);
        }