コード例 #1
0
        public override IEnumerable <Union <Player, Character, Location, Obstacle, Path> > ApplyAndGetModifiedResources(Game game)
        {
            var playerToRemove = game.Players.Single(player => player.Id == PlayerId);

            game.Players.Remove(playerToRemove);

            // Reassign actions to existing players
            if (game.Players.Any())
            {
                var actionSets = ActionSetsFactory.GetActionSets(game.Players.Count);
                ActionSetAssigner.Assign(actionSets, game.Players, game.RandomSeed);
            }

            yield return(playerToRemove);
        }
コード例 #2
0
ファイル: PlayerJoined.cs プロジェクト: kits-ab/MAZE
        public override IEnumerable <Union <Player, Character, Location, Obstacle, Path> > ApplyAndGetModifiedResources(Game game)
        {
            var takenPlayerIds = game.Players.Select(player => player.Id).ToHashSet();
            var newPlayerId    = 0;

            while (takenPlayerIds.Contains(newPlayerId))
            {
                newPlayerId++;
            }

            var newPlayer = new Player(newPlayerId, NewPlayerName);

            game.Players.Add(newPlayer);
            var actionSets = ActionSetsFactory.GetActionSets(game.Players.Count);

            ActionSetAssigner.Assign(actionSets, game.Players, game.RandomSeed);
            yield return(newPlayer);
        }