コード例 #1
0
ファイル: Program.cs プロジェクト: runelippert/TestGame
        static void Main(string[] args)
        {
            Match newMatch = new Match();

            Match thisMatch = newMatch.SetupMatch();

            Board gameBoard = new Board();

            Player players = new Player();

            var homeTeamHand = thisMatch.HomeTeam.Hand();
            var awayTeamHand = thisMatch.AwayTeam.Hand();

            gameBoard.DrawBoard(thisMatch);

            //Turn loop
            for (int turn = 1; turn <= 9; turn++)
            {
                Console.WriteLine();
                Console.WriteLine("Start of turn {0}", turn);

                //Assign orders to all players in the Home match
                players.GiveOrders(thisMatch.HomeTeam, homeTeamHand);

                //Assign orders to all players in the away team
                players.GiveOrders(thisMatch.AwayTeam, awayTeamHand);

                //Execute Orders
                players.ExecuteOrders(thisMatch);

                //Find encounters - doesn't seem to work
                List<Coordinate> engagements = thisMatch.CompairePlayersCoordinates(thisMatch);
                Rolls roll = new Rolls();

                //Roll for all engagements
                foreach (Coordinate coordinate in engagements)
                {
                    Console.WriteLine("Engagement at {0},{1}", coordinate.X, coordinate.Y);
                    roll.RollForEngagement(coordinate, thisMatch);
                }

                Console.WriteLine("!-----New Turn------!");

                gameBoard.DrawBoard(thisMatch);
            }
        }
コード例 #2
0
ファイル: UnitTests.cs プロジェクト: runelippert/TestGame
        public void rollForEngagementTest()
        {
            //Arrange
            Team firsteTeam = new Team() { TeamName = "The greeks" };
            Team secondTeam = new Team() { TeamName = "Olsen banden" };
            Ball ball = new Ball();

            Match thisMatch = new Match()
            {
                HomeTeam = firsteTeam,
                AwayTeam = secondTeam,
                MatchBall = ball
            };

            firsteTeam.PlayersOnTeam.Add(new Player() { ShirtNumber = 1, Name = "Alpha", Position = new Coordinate(2, 1), Team = firsteTeam });
            firsteTeam.PlayersOnTeam.Add(new Player() { ShirtNumber = 2, Name = "Beta", Position = new Coordinate(1, 1), Team = firsteTeam });
            secondTeam.PlayersOnTeam.Add(new Player() { ShirtNumber = 10, Name = "Egon", Position = new Coordinate(1, 1), Team = secondTeam });
            secondTeam.PlayersOnTeam.Add(new Player() { ShirtNumber = 11, Name = "Benny", Position = new Coordinate(1, 1), Team = secondTeam });

            //Act
            Rolls roll = new Rolls();
            roll.RollForEngagement(new Coordinate(1, 1), thisMatch);

            //Assert
        }
コード例 #3
0
ファイル: UnitTests.cs プロジェクト: runelippert/TestGame
        public void findWinnerTest(int a, int b, Rolls.ResultOfEngagement expectedResult)
        {
            Rolls roll = new Rolls();
            Match match = new Match
            {
                HomeTeam = new Team() { TeamName = "The greeks" },
                AwayTeam = new Team() { TeamName = "Olsen banden" }
            };

               //ACT
            var result = roll.FindWinner(match, a, b);

            //ASSERT
            Assert.Equal(expectedResult, result);
        }
コード例 #4
0
ファイル: UnitTests.cs プロジェクト: runelippert/TestGame
        public void effectOfEngagementTest(Rolls.ResultOfEngagement engagementResult, string loserTeam)
        {
            //Arrange
            Team firsteTeam = new Team() { TeamName = "The greeks" };
            Team secondTeam = new Team() { TeamName = "Olsen banden" };

            //Setup players at an engagement
            Rolls roll = new Rolls();
            List<Player> homeTeamPlayersAtCoordinate = new List<Player>();
            List<Player> awayTeamPlayersAtCoordinate = new List<Player>();

            homeTeamPlayersAtCoordinate.Add(new Player() { Name="Aplha", State = Player.PlayerState.Up, Team = firsteTeam});
            homeTeamPlayersAtCoordinate.Add(new Player() { Name="Beta", State = Player.PlayerState.Up, Team = firsteTeam});
            awayTeamPlayersAtCoordinate.Add(new Player() { Name = "Ringo", State = Player.PlayerState.Up, Team = secondTeam});
            awayTeamPlayersAtCoordinate.Add(new Player() { Name = "John", State = Player.PlayerState.Up, Team = secondTeam});

            //Act
            var result = roll.EffectOfEngangement(engagementResult, homeTeamPlayersAtCoordinate, awayTeamPlayersAtCoordinate);

            //Assert
            Assert.Equal(Player.PlayerState.Down, result.State);
            Assert.Equal(loserTeam, result.Team.TeamName);
        }