Пример #1
0
        private static TeamPosition InitTeamPosition(Team team)
        {
            IDictionary<Player, PlayerPosition> playerPositions = new Dictionary<Player, PlayerPosition>(team.Players.Count);
            foreach (Player player in team.Players)
                playerPositions[player] = new PlayerPosition();

            return new TeamPosition(playerPositions);
        }
Пример #2
0
        private static TeamAction BuildTeamAction(Team team, IGameState gameState)
        {
            IDictionary<Player, PlayerAction> playerActions = new Dictionary<Player, PlayerAction>(team.Players.Count);
            foreach (Player player in team.Players)
                playerActions.Add(player, team.Strategy.GetPlayerStrategy(player).GetAction(gameState));

            return new TeamAction(playerActions);
        }
        public void TestPlayersCount()
        {
            var players = new Player[10];

            var team = new Team(players, null);
            var validator = new StandardTeamValidator();

            Assert.IsFalse(validator.Validate(team));
        }
        public void TestNullPlayers()
        {
            var players = new Player[11];
            for (int i = 0; i < 11; i++)
                players[i] = new Player("Player" + i);

            var team = new Team(players, null);
            var validator = new StandardTeamValidator();

            Assert.IsTrue(validator.Validate(team));
        }
Пример #5
0
        public Game(IGameRunner runner, IGameRunnerStateBuilder gameStateBuilder, Field field, Team firstTeam, Team secondTeam, Ball ball)
        {
            Contract.Requires<ArgumentNullException>(runner != null);
            Contract.Requires<ArgumentNullException>(gameStateBuilder != null);

            Contract.Requires<ArgumentNullException>(firstTeam != null);
            Contract.Requires<ArgumentNullException>(secondTeam != null);
            Contract.Requires<ArgumentNullException>(ball != null);

            _runner = runner;
            _gameStateBuilder = gameStateBuilder;
            _field = field;
            _firstTeam = firstTeam;
            _secondTeam = secondTeam;
            _ball = ball;
        }