public PlayFieldModel(Guid previousPlayFieldModelGuidP, Guid thisInstanceGuid, List <PlayerModel> playerModelsP, List <Card> topCardsPlayPileP, Guid guidOfPlayerWhosTurnItIsP,
                       List <Guid> playersAffectedByActionCardGuidsP, TurnActionModel lastActionP, TurnActionModel nextActionP, DrawPile currentDrawPileState, PlayPile currentPlayPileState, int numberOfTurnsRemainingForPlayerP, bool startOfATurnP, Statephase phaseP, Deck deckP)
 {
     //The guid of this instance of PlayFieldModel
     thisPlayFieldModelInstanceGuid = thisInstanceGuid;
     //The Players
     playerModels = playerModelsP;
     //The last 4 played cards
     topCardsOnPlaypile = topCardsPlayPileP;
     //The guid of the player whos turn it currently is
     guidOfPlayerWhosTurnItIs = guidOfPlayerWhosTurnItIsP;
     //A list of players who are affected by an action card that have just been played
     playersAffectedByActionCardGuids = playersAffectedByActionCardGuidsP;
     //The TurnActionModel of the last action
     lastActionPlayed = lastActionP;
     //The current State of the deck
     drawPile = currentDrawPileState;
     //The current State of the playpile
     playpile = currentPlayPileState;
     //The maximun number of cards that the player whos turn it is can play before their turn is over
     numberOfTurnsRemainingForPlayerWhosTurnItIs = numberOfTurnsRemainingForPlayerP;
     //This is the first move of a turn so the player whose turn it is should draw two cards
     startOfATurn           = startOfATurnP;
     currentTurnActionModel = nextActionP;
     lastActionPlayed       = lastActionP;
     //Current Phase
     currentPhase = phaseP;
     //Previous PlayFieldModelGuid
     previousPlayFieldModelGuid = previousPlayFieldModelGuidP;
     //Deck
     deck = deckP;
 }
Exemple #2
0
        private DrawPile generateInitialDrawPile(PlayPile pp)
        {
            //ShuffleDeck
            deck = new Deck(NUMBER_OF_DECKS);
            DrawPile dp = new DrawPile(deck.getDeck(), pp);

            return(dp);
        }
Exemple #3
0
        private PlayFieldModel createInitialState(List <PlayerModel> players)
        {
            //guid for initial state
            Guid playFieldModelGuid = PlayFieldModel.generateplayFieldModelGuid();
            //no cards to be shown as played in playpile
            List <Card> emptyTopPlayPile = new List <Card>();
            //setFirstPlayerToHaveTurn(players);
            //set player 0 to be first to play
            //Guid firstPlayerGuid = players.ElementAt(FIRST_PLAYER).guid;
            //currentPlayerTurn = FIRST_PLAYER;
            Guid firstPlayerGuid = setFirstPlayerToHaveTurn(players);
            //no players can be affected by actioncards as none have been played
            List <Guid> noPlayersAffectedByActionCard = new List <Guid>();
            //No actions have been taken
            List <TurnActionTypes> actionsAllowable = new List <TurnActionTypes>();

            actionsAllowable.Add(TurnActionTypes.drawTwoCardsAtStartOfTurn);

            //Set players Allowable actions
            foreach (PlayerModel p in players)
            {
                p.actionsCurrentlyAllowed = new List <TurnActionTypes>();
                if (p.guid.CompareTo(firstPlayerGuid) == 0)
                {
                    //Player whos turn it is must draw TwoCards
                    p.actionsCurrentlyAllowed.Add(TurnActionTypes.drawTwoCardsAtStartOfTurn);
                }
            }

            //
            TurnActionModel noActionsPlayedFirstPlayerToDraw = new TurnActionModel(this.playerIdLookup, this.gameModelGuid, playFieldModelGuid, generateTurnActionGuid(), actionsAllowable, TurnActionTypes.gameStarted, false);

            //create empty playpile
            initialPlayPile = new PlayPile();
            //fill  new drawpile
            DrawPile initialDrawPile = generateInitialDrawPile(initialPlayPile);

            //Deal players thier first five cards
            dealPlayersInitialFiveCards(players, initialDrawPile);
            //It is the start of a players turn
            bool turnStart = true;

            //put it all into the intial state
            PlayFieldModel state = new PlayFieldModel(playFieldModelGuid, players, emptyTopPlayPile, firstPlayerGuid, noPlayersAffectedByActionCard,
                                                      null, noActionsPlayedFirstPlayerToDraw, initialDrawPile, initialPlayPile, NEW_TURN_NUMBER_OF_CARDS_PLAYABLE, turnStart, Statephase.Turn_Started_Draw_2_Cards, deck);

            //stateCreated
            currentState = state;
            return(state);
        }
Exemple #4
0
        private void dealPlayersInitialFiveCards(List <PlayerModel> players, DrawPile drawPile)
        {
            //PreCondition drawPile is Full and each player.hand contains no Cards
            //PostCondition each player.hand contains 5 Cards
            int numberOfCardsDrawn = 0;
            int forloop            = 0;

            for (int i = 0; i < 5; i++)
            {
                foreach (PlayerModel player in players)
                {
                    Card drawnCard = drawPile.drawcard();
                    player.hand.addCardToHand(drawnCard);
                    numberOfCardsDrawn++;
                }
                forloop++;
            }
        }
Exemple #5
0
 private DrawPile setUpDrawPile(Deck deck, PlayPile playPile)
 {
     drawPile = new DrawPile(deck.getDeck(), playPile);
     return(drawPile);
 }
 private DrawPile generateInitialDrawPile(PlayPile pp)
 {
     //ShuffleDeck
     deck = new Deck(NUMBER_OF_DECKS);
     DrawPile dp = new DrawPile(deck.getDeck(), pp);
     return dp;
 }
 private void dealPlayersInitialFiveCards(List<PlayerModel> players, DrawPile drawPile)
 {
     //PreCondition drawPile is Full and each player.hand contains no Cards
     //PostCondition each player.hand contains 5 Cards
     int numberOfCardsDrawn = 0;
     int forloop = 0;
     for (int i = 0; i < 5; i++)
     {
         foreach (PlayerModel player in players)
         {
             Card drawnCard = drawPile.drawcard();
             player.hand.addCardToHand(drawnCard);
             numberOfCardsDrawn++;
         }
         forloop++;
     }
 }
 public PlayFieldModel(Guid previousPlayFieldModelGuidP, Guid thisInstanceGuid, List<PlayerModel> playerModelsP, List<Card> topCardsPlayPileP, Guid guidOfPlayerWhosTurnItIsP,
     List<Guid> playersAffectedByActionCardGuidsP, TurnActionModel lastActionP, TurnActionModel nextActionP, DrawPile currentDrawPileState, PlayPile currentPlayPileState, int numberOfTurnsRemainingForPlayerP, bool startOfATurnP, Statephase phaseP, Deck deckP)
 {
     //The guid of this instance of PlayFieldModel
     thisPlayFieldModelInstanceGuid = thisInstanceGuid;
     //The Players
     playerModels = playerModelsP;
     //The last 4 played cards
     topCardsOnPlaypile = topCardsPlayPileP;
     //The guid of the player whos turn it currently is
     guidOfPlayerWhosTurnItIs = guidOfPlayerWhosTurnItIsP;
     //A list of players who are affected by an action card that have just been played
     playersAffectedByActionCardGuids = playersAffectedByActionCardGuidsP;
     //The TurnActionModel of the last action
     lastActionPlayed = lastActionP;
     //The current State of the deck
     drawPile = currentDrawPileState;
     //The current State of the playpile
     playpile = currentPlayPileState;
     //The maximun number of cards that the player whos turn it is can play before their turn is over
     numberOfTurnsRemainingForPlayerWhosTurnItIs = numberOfTurnsRemainingForPlayerP;
     //This is the first move of a turn so the player whose turn it is should draw two cards
     startOfATurn = startOfATurnP;
     currentTurnActionModel = nextActionP;
     lastActionPlayed = lastActionP;
     //Current Phase
     currentPhase = phaseP;
     //Previous PlayFieldModelGuid
     previousPlayFieldModelGuid = previousPlayFieldModelGuidP;
     //Deck
     deck = deckP;
 }
Exemple #9
0
 private DrawPile setUpDrawPile(Deck deck, PlayPile playPile)
 {
     drawPile = new DrawPile(deck.getDeck(), playPile);
     return drawPile;
 }