コード例 #1
0
 public LockingGameHost(Game game)
 {
     _game = game;
     _players = new Dictionary<IGameClient, Player>();      
     _lock = new ReaderWriterLockSlim();
     _chatSubject = new Subject<string>();        
 }
コード例 #2
0
 public void GivenANewGameWithPlayersAndBank(int playerCount, string bankCardNames)
 {
     var cardNameList = bankCardNames.Split(new char[]{',', ' '}, StringSplitOptions.RemoveEmptyEntries);
     var startingConfig = new ChosenStartingConfiguration(playerCount, cardNameList, false);
     var names = playerCount.Items(i => "Player" + i);
     _game = startingConfig.CreateGame(names);
 }
コード例 #3
0
ファイル: GameViewModel.cs プロジェクト: trentkerin/Dominion
        public GameViewModel(Game game, Player player)
        {
            Log = game.Log.Contents;

            Version = game.Version;
            
            PopulateActivityRelated(game, player);

            Bank = game.Bank.Piles
                .Select(p => new CardPileViewModel(p, game.CurrentTurn, player)).ToArray();

            Hand = player.Hand
                .Select(c => new CardViewModel(c, game.CurrentTurn, player)).ToArray();

            if (game.IsComplete)
            {
                InPlay = player.PlayArea
                    .Select(c => new CardViewModel(c)).ToArray();
            }
            else
            {
                InPlay = game.ActivePlayer.PlayArea
                    .Select(c => new CardViewModel(c)).ToArray();
            }

            Status = new TurnContextViewModel(game.CurrentTurn, player);

            Deck = new DeckViewModel(player.Deck);

            Discards = new DiscardPileViewModel(player.Discards);
        }
コード例 #4
0
ファイル: ScoringBindings.cs プロジェクト: razzielx/Dominion
 public void WhenTheGameIsScored()
 {
     var gameBinding = Binding<GameStateBindings>();
     _game = gameBinding.Game;
     _game.Score();
     _scores = _game.Scores;
 }
コード例 #5
0
ファイル: ChoiceMessage.cs プロジェクト: razzielx/Dominion
        public void UpdateGameState(Game game)
        {
            var player = game.Players.Single(p => p.Id == PlayerId);
            var activity = game.GetPendingActivity(player) as ChoiceActivity;

            if (activity == null)
                throw new InvalidOperationException("There must be a corresponding activity");

            activity.MakeChoice(Choice);
        }
コード例 #6
0
        public void UpdateGameState(Game game)
        {
            var player = game.Players.Single(p => p.Id == PlayerId);
            var pile = game.Bank.Piles.SingleOrDefault(p => p.Id == PileId);
            var activity = game.GetPendingActivity(player) as ISelectPileActivity;

            if (activity == null)
                throw new InvalidOperationException("There must be a corresponding activity");

            activity.SelectPile(pile);
        }
コード例 #7
0
ファイル: TurnContext.cs プロジェクト: trentkerin/Dominion
        public TurnContext(Player player, Game game)
        {
            ActivePlayer = player;
            Game = game;
            AvailableSpend = 0;
            RemainingActions = 1;
            Buys = 1;

            foreach (var longLivedEffect in player.LongLivedEffects)
                longLivedEffect.OnTurnStarting(this);
        }
コード例 #8
0
ファイル: GameViewModel.cs プロジェクト: trentkerin/Dominion
        private void PopulateActivityRelated(Game game, Player player)
        {
            var activity = game.GetPendingActivity(player);
            if(activity != null)
                PendingActivity = new ActivityModel(activity);

            if (activity is IRevealedCardsActivity)
            {
                this.Revealed = ((IRevealedCardsActivity)activity).RevealedCards
                    .Select(c => new CardViewModel(c)).ToArray();
            }
        }
コード例 #9
0
        public void UpdateGameState(Game game)
        {
            var player = game.Players.Single(p => p.Id == PlayerId);
            var activity = game.GetPendingActivity(player) as ISelectCardsActivity;

            if (activity == null)
                throw new InvalidOperationException("There must be a corresponding activity");

            IEnumerable<ICard> cardSource;

            if(activity is ISelectFromRevealedCardsActivity)
            {
                cardSource = ((ISelectFromRevealedCardsActivity) activity).RevealedCards;
            }
            else
            {
                cardSource = player.Hand;
            }

            var cards = cardSource.Where(c => CardIds.Contains(c.Id)).ToList();                   
            activity.SelectCards(cards);            
        }
コード例 #10
0
ファイル: TextGameLog.cs プロジェクト: trentkerin/Dominion
        public void LogGameEnd(Game game)
        {
            GameScores scores = game.Score();

            _builder
                .AppendLine("The game has ended!")
                .AppendLine()
                .AppendLine("----- SCORES -----");

            foreach (var item in scores)
                _builder
                    .AppendFormat("{0}: {1}", item.Key.Name, item.Value)
                    .AppendLine();

            _builder.AppendLine();            

            var winner = scores.Winner;                                

            _builder.AppendLine();
            _builder.AppendLine(winner.Name + " is the winner!");


        }
コード例 #11
0
 public void UpdateGameState(Game game)
 {
     game.CurrentTurn.MoveToBuyStep();            
 }
コード例 #12
0
 public void GivenANewGameWithPlayers(int playerCount)
 {            
     var startingConfig = new SimpleStartingConfiguration(playerCount);
     var names = playerCount.Items(i => "Player" + i);
     _game = startingConfig.CreateGame(names);
 }
コード例 #13
0
 public void Validate(Game game)
 {
     
 }
コード例 #14
0
ファイル: Player.cs プロジェクト: razzielx/Dominion
 public TurnContext BeginTurn(Game game)
 {            
     var context = new TurnContext(this, game);
     return context;
 }
コード例 #15
0
ファイル: EndTurnMessage.cs プロジェクト: razzielx/Dominion
 public void UpdateGameState(Game game)
 {
     game.EndTurn();            
 }
コード例 #16
0
ファイル: BuyCardMessage.cs プロジェクト: razzielx/Dominion
 public void UpdateGameState(Game game)
 {            
     CardPile pile = game.Bank.Piles.Single(p => p.Id == PileId);
     game.CurrentTurn.Buy(pile);            
 }
コード例 #17
0
ファイル: BeginGameMessage.cs プロジェクト: razzielx/Dominion
 public void UpdateGameState(Game game)
 {
     TurnContext tempQualifier = game.CurrentTurn;
     if (tempQualifier.ActivePlayer.Hand.OfType<IActionCard>().Any() == false || tempQualifier.RemainingActions == 0)
         tempQualifier.MoveToBuyStep();
 }
コード例 #18
0
ファイル: EndTurnMessage.cs プロジェクト: razzielx/Dominion
 public void Validate(Game game)
 {
     if (game.ActivePlayer.Id != PlayerId)
         throw new InvalidOperationException(string.Format("Player '{0}' is not active.", PlayerId));
 }
コード例 #19
0
ファイル: PlayCardMessage.cs プロジェクト: razzielx/Dominion
 public void UpdateGameState(Game game)
 {
     ICard card = game.CurrentTurn.ActivePlayer.Hand.Single(c => c.Id == CardId);
     game.CurrentTurn.Play((IActionCard) card);            
 }