コード例 #1
0
        public BoolResponseBox standardRentCard(int playedCard, Guid setOfPropertiesToRentOn, bool usingDoubleTheRent, int doubleTheRentCard, Guid playerGuid, Guid gameLobbyGuid, Guid playfieldModelInstanceGuid)
        {
            PlayFieldModel lastState    = getPreviousState();
            PlayFieldModel currentState = getCurrentState();
            PlayFieldModel nextState    = null;
            PlayerModel    playerModelAtCurrentState = move.getPlayerModel(playerGuid, currentState);
            ActionCard     playedActionCard          = monopolyDeal.deck.getCardByID(playedCard) as ActionCard;

            if (playedActionCard != null && checkIfCardInHand(playedActionCard, playerModelAtCurrentState) != null)
            {
                MoveInfo playStandardRent = new MoveInfo();
                playStandardRent.playerWhoseTurnItIs = currentState.guidOfPlayerWhosTurnItIs;
                playStandardRent.playerMakingMove    = playerGuid;
                playStandardRent.moveBeingMade       = TurnActionTypes.PlayActionCard;
                playStandardRent.idOfCardBeingUsed   = playedCard;

                playStandardRent.actionCardActionType = ActionCardAction.RentStandard;

                playStandardRent.guidOfSetToCollectRentOn = setOfPropertiesToRentOn;

                playStandardRent.idOfDoubleTheRentCardBeingUsed = doubleTheRentCard;
                playStandardRent.isDoubleTheRentCardBeingUsed   = usingDoubleTheRent;

                BoolResponseBox result = move.evaluateMove(lastState, currentState, nextState, playerModelAtCurrentState, playStandardRent.moveBeingMade, playStandardRent);
                return(result);
            }
            return(new BoolResponseBox(false, "Selected Card is not in players hand or is not a Action card"));
        }
コード例 #2
0
        public bool playPropertyCardToExistingSet(Card playedCard, PropertyCardSet setToPlayPropertyTo, Guid gameLobbyGuid, Guid playerGuid, Guid playfieldModelInstanceGuid)
        {
            PlayFieldModel lastState    = getPreviousState();
            PlayFieldModel currentState = getCurrentState();
            PlayFieldModel nextState    = null;
            PlayerModel    playerModelAtCurrentState = move.getPlayerModel(playerGuid, currentState);
            PropertyCard   playedPropertycard        = monopolyDeal.deck.getCardByID(playedCard.cardID) as PropertyCard;

            if (playedPropertycard != null && checkIfCardInHand(playedPropertycard, playerModelAtCurrentState) != null)
            {
                MoveInfo playPropertyCardFromHand = new MoveInfo();
                playPropertyCardFromHand.playerMakingMove  = playerGuid;
                playPropertyCardFromHand.moveBeingMade     = TurnActionTypes.PlayPropertyCardFromHand;
                playPropertyCardFromHand.idOfCardBeingUsed = playedCard.cardID;

                bool isOrientedUp = (playedCard as PropertyCard).isCardUp;
                playPropertyCardFromHand.isPropertyToPlayOrientedUp        = isOrientedUp;
                playPropertyCardFromHand.addPropertyToPlayToExistingSet    = true;//Add to existing set
                playPropertyCardFromHand.guidOfExistingSetToPlayPropertyTo = setToPlayPropertyTo.guid;

                BoolResponseBox result = move.evaluateMove(lastState, currentState, nextState, playerModelAtCurrentState, playPropertyCardFromHand.moveBeingMade, playPropertyCardFromHand);
                return(result.success);
            }
            return(new BoolResponseBox(false, "Selected Card is not in players hand or is not a property card").success);
        }
コード例 #3
0
        public BoolResponseBox movePropertyCard(int propertyCardToMoveID, bool isCardUp, bool moveToExistingSet,
                                                Guid oldSetGuid, Guid setToPlayPropertyToGuid, Guid playerGuid, Guid gameLobbyGuid, Guid playfieldModelInstanceGuid)
        {
            //Gets the last,current and a reference for the next state
            PlayFieldModel lastState    = getPreviousState();
            PlayFieldModel currentState = getCurrentState();
            PlayFieldModel nextState    = null;
            //Gets the PlayerModel of the Player making the move.
            PlayerModel playerModelAtCurrentState = move.getPlayerModel(playerGuid, currentState);
            //The property card to move between sets
            PropertyCard propertyCardToMove = monopolyDeal.deck.getCardByID(propertyCardToMoveID) as PropertyCard;

            if (propertyCardToMove != null)
            {
                //Initialize MoveInfo for moving a property card between sets
                MoveInfo movePropertyCardToNewSet = new MoveInfo();
                movePropertyCardToNewSet.playerMakingMove                  = playerGuid;
                movePropertyCardToNewSet.moveBeingMade                     = TurnActionTypes.MovePropertyCard;
                movePropertyCardToNewSet.guidOfSetPropertyToMoveIsIn       = oldSetGuid;
                movePropertyCardToNewSet.guidOfPropertyToMove              = propertyCardToMove.cardGuid;
                movePropertyCardToNewSet.isPropertyToMoveOrientedUp        = isCardUp;
                movePropertyCardToNewSet.addPropertyToMoveToExistingSet    = moveToExistingSet;
                movePropertyCardToNewSet.guidOfExistingSetToMovePropertyTo = setToPlayPropertyToGuid;
                movePropertyCardToNewSet.idOfCardBeingUsed                 = propertyCardToMoveID;
                BoolResponseBox result = move.evaluateMove(lastState, currentState, nextState, playerModelAtCurrentState, movePropertyCardToNewSet.moveBeingMade, movePropertyCardToNewSet);
                return(result);
            }
            return(new BoolResponseBox(false, "Selected Card is not in players property card sets or is not a property card"));
        }
コード例 #4
0
        public BoolResponseBox hotelCard(int playedCardID, Guid setOfPropertiesToAddHotelTo, Guid playerGuid, Guid gameLobbyGuid, Guid playfieldModelInstanceGuid)
        {
            PlayFieldModel lastState    = getPreviousState();
            PlayFieldModel currentState = getCurrentState();
            PlayFieldModel nextState    = null;
            PlayerModel    playerModelAtCurrentState = move.getPlayerModel(playerGuid, currentState);
            ActionCard     playedActionCard          = monopolyDeal.deck.getCardByID(playedCardID) as ActionCard;

            if (playedActionCard != null && checkIfCardInHand(playedActionCard, playerModelAtCurrentState) != null)
            {
                MoveInfo playHotel = new MoveInfo();
                playHotel.playerWhoseTurnItIs = currentState.guidOfPlayerWhosTurnItIs;
                playHotel.playerMakingMove    = playerGuid;
                playHotel.moveBeingMade       = TurnActionTypes.PlayActionCard;
                playHotel.idOfCardBeingUsed   = playedCardID;

                playHotel.actionCardActionType = ActionCardAction.Hotel;

                playHotel.guidFullSetWithHouseToAddHotelTo = setOfPropertiesToAddHotelTo;

                BoolResponseBox result = move.evaluateMove(lastState, currentState, nextState, playerModelAtCurrentState, playHotel.moveBeingMade, playHotel);
                return(result);
            }
            return(new BoolResponseBox(false, "Selected Card is not in players hand or is not a Action card"));
        }
コード例 #5
0
        public BoolResponseBox forcedDealCard(int forcedDealCardID, int playersCardToSwapWith, Guid setPlayersCardIsIn, Guid targetedPlayerGuid, int targetedCard, Guid setTargetCardIn, Guid playerGuid, Guid gameLobbyGuid, Guid playfieldModelInstanceGuid)
        {
            PlayFieldModel lastState    = getPreviousState();
            PlayFieldModel currentState = getCurrentState();
            PlayFieldModel nextState    = null;
            PlayerModel    playerModelAtCurrentState = move.getPlayerModel(playerGuid, currentState);
            ActionCard     playedActionCard          = monopolyDeal.deck.getCardByID(forcedDealCardID) as ActionCard;
            PropertyCard   cardToForcedDealFor       = monopolyDeal.deck.getCardByID(targetedCard) as PropertyCard;
            PropertyCard   cardToLoseInForcedDeal    = monopolyDeal.deck.getCardByID(playersCardToSwapWith) as PropertyCard;

            if (playedActionCard != null && checkIfCardInHand(playedActionCard, playerModelAtCurrentState) != null && cardToForcedDealFor != null && cardToLoseInForcedDeal != null)
            {
                MoveInfo playForcedDeal = new MoveInfo();
                playForcedDeal.playerWhoseTurnItIs = currentState.guidOfPlayerWhosTurnItIs;
                playForcedDeal.playerMakingMove    = playerGuid;
                playForcedDeal.moveBeingMade       = TurnActionTypes.PlayActionCard;
                playForcedDeal.idOfCardBeingUsed   = forcedDealCardID;

                playForcedDeal.actionCardActionType = ActionCardAction.ForcedDeal;

                playForcedDeal.guidOfCardToBeForcedDealed         = cardToForcedDealFor.cardGuid;
                playForcedDeal.guidOfSetCardToBeForcedDealedIsIn  = setTargetCardIn;
                playForcedDeal.guidOfPlayerWhoIsBeingForcedDealed = targetedPlayerGuid;

                playForcedDeal.idOfCardToBeForcedDealed             = cardToForcedDealFor.cardID;
                playForcedDeal.idOfCardToBeGivenUpInForcedDeal      = cardToLoseInForcedDeal.cardID;
                playForcedDeal.guidOfCardToBeGivenUpInForcedDeal    = cardToLoseInForcedDeal.cardGuid;
                playForcedDeal.guidOfSetCardGivenUpInForcedDealIsIn = setPlayersCardIsIn;

                BoolResponseBox result = move.evaluateMove(lastState, currentState, nextState, playerModelAtCurrentState, playForcedDeal.moveBeingMade, playForcedDeal);
                return(result);
            }
            return(new BoolResponseBox(false, "Selected Card is not in players hand or is not a Action card"));
        }
コード例 #6
0
        public BoolResponseBox dealBreakerCard(int dealBreakerCardID, Guid targetedPlayerGuid, Guid setTargeted, Guid playerGuid, Guid gameLobbyGuid, Guid playfieldModelInstanceGuid)
        {
            PlayFieldModel lastState    = getPreviousState();
            PlayFieldModel currentState = getCurrentState();
            PlayFieldModel nextState    = null;
            PlayerModel    playerModelAtCurrentState = move.getPlayerModel(playerGuid, currentState);
            ActionCard     playedActionCard          = monopolyDeal.deck.getCardByID(dealBreakerCardID) as ActionCard;

            if (playedActionCard != null && checkIfCardInHand(playedActionCard, playerModelAtCurrentState) != null)
            {
                MoveInfo playdealBreaker = new MoveInfo();
                playdealBreaker.playerWhoseTurnItIs = currentState.guidOfPlayerWhosTurnItIs;
                playdealBreaker.playerMakingMove    = playerGuid;
                playdealBreaker.moveBeingMade       = TurnActionTypes.PlayActionCard;
                playdealBreaker.idOfCardBeingUsed   = dealBreakerCardID;

                playdealBreaker.actionCardActionType = ActionCardAction.DealBreaker;

                playdealBreaker.guidOfFullSetToBeDealBreakered      = setTargeted;
                playdealBreaker.guidOfPlayerWhoIsBeingDealBreakered = targetedPlayerGuid;

                BoolResponseBox result = move.evaluateMove(lastState, currentState, nextState, playerModelAtCurrentState, playdealBreaker.moveBeingMade, playdealBreaker);
                return(result);
            }
            return(new BoolResponseBox(false, "Selected Card is not in players hand or is not a Action card"));
        }
コード例 #7
0
        public bool bankCard(int playedCardID, Guid playerGuid, Guid serverGuid, Guid playfieldModelInstanceGuid)
        {
            PlayFieldModel lastState    = getPreviousState();
            PlayFieldModel currentState = getCurrentState();
            PlayFieldModel nextState    = null;
            PlayerModel    playerModelAtCurrentState = move.getPlayerModel(playerGuid, currentState);
            Card           playedcard = monopolyDeal.deck.getCardByID(playedCardID);

            if (checkIfCardInHand(playedcard, playerModelAtCurrentState) != null)
            {
                if (playedcard is PropertyCard)
                {
                    return(new BoolResponseBox(false, "Property Cards can not be Banked").success);
                }
                else
                {
                    MoveInfo bankCardInfo = new MoveInfo();
                    bankCardInfo.playerWhoseTurnItIs = playerGuid;
                    bankCardInfo.playerMakingMove    = playerGuid;
                    bankCardInfo.moveBeingMade       = TurnActionTypes.BankMoneyCard;
                    bankCardInfo.idOfCardBeingUsed   = playedCardID;

                    BoolResponseBox result = move.evaluateMove(lastState, currentState, nextState, playerModelAtCurrentState, bankCardInfo.moveBeingMade, bankCardInfo);
                    return(result.success);
                }
            }
            return(new BoolResponseBox(false, "Selected Card is not in players hand.").success);
        }
コード例 #8
0
        //[DataMember]
        //TurnActionModel actionsToTake;
        public TakeActionOnTurnMessage(Guid playerGuid, Guid guidOfMessageThisMessageIsRespondingTo, Guid guidOfThisMessage, Guid serverGuid, PlayFieldModel playFieldModelP, Guid playFieldModelGuidP, TurnActionModel turnActionModel)
            : base(guidOfThisMessage, guidOfMessageThisMessageIsRespondingTo, MessageType.actionTaken, null, false, playerGuid, serverGuid, null)
        {
            //Message used for notifying all players that the field has been updated
            fieldModel = playFieldModelP;
            referenceThisGuidToRespond = guidOfThisMessage;

            //Clients of players whose turn it is not should adknowledge they recieved this message and request again for an update of the playing field
            //Client of player whose turn it is should reply with an action
        }
コード例 #9
0
        //[DataMember]
        //TurnActionModel actionsToTake;

        public TakeActionOnTurnMessage(Guid playerGuid, Guid guidOfMessageThisMessageIsRespondingTo, Guid guidOfThisMessage, Guid serverGuid, PlayFieldModel playFieldModelP, Guid playFieldModelGuidP, TurnActionModel turnActionModel)
            : base(guidOfThisMessage, guidOfMessageThisMessageIsRespondingTo, MessageType.actionTaken, null, false, playerGuid, serverGuid, null)
        {
            //Message used for notifying all players that the field has been updated
            fieldModel = playFieldModelP;
            referenceThisGuidToRespond = guidOfThisMessage;

            //Clients of players whose turn it is not should adknowledge they recieved this message and request again for an update of the playing field
            //Client of player whose turn it is should reply with an action
        }
コード例 #10
0
        public FieldUpdateMessage(Guid guidOfMessageThisMessageIsRespondingTo, Guid guidOfThisMessage, Guid serverGuid, Guid[] playersRecieving, PlayFieldModel playFieldModelP)
            : base(guidOfThisMessage, guidOfMessageThisMessageIsRespondingTo, MessageType.fieldupdate, null, true, serverGuid, serverGuid, playersRecieving)
        {
            //Message used for notifying all players that the field has been updated
            fieldModel = playFieldModelP;
            referenceThisGuidToRespond = guidOfThisMessage;

            //Clients of players whose turn it is not should adknowledge they recieved this message and request again for an update of the playing field
            //Client of player whose turn it is should reply with an action
        }
コード例 #11
0
ファイル: Move.cs プロジェクト: Nitzahon/Monopoly-Deal-WCF
 private BoolResponseBox setGameOver(PlayFieldModel state, Guid guidOfWinner)
 {
     PlayFieldModel newState = state.clone(generateGuidForNextState());
     newState.currentPhase = Statephase.Game_Over;
     newState.playerWhoWon = guidOfWinner;
     addNextState(newState);
     monopolyDeal.gameOver = true;
     monopolyDeal.lobby.setGameLobbyStatus(this.monopolyDeal.MONOPOLY_DEAL_GAME_GUID, GameLobbyStatus.Game_Ended);
     return new BoolResponseBox(true, "Game over");
 }
コード例 #12
0
        public FieldUpdateMessage(Guid guidOfMessageThisMessageIsRespondingTo, Guid guidOfThisMessage, Guid serverGuid, Guid[] playersRecieving, PlayFieldModel playFieldModelP)
            : base(guidOfThisMessage, guidOfMessageThisMessageIsRespondingTo, MessageType.fieldupdate, null, true, serverGuid, serverGuid, playersRecieving)
        {
            //Message used for notifying all players that the field has been updated
            fieldModel = playFieldModelP;
            referenceThisGuidToRespond = guidOfThisMessage;

            //Clients of players whose turn it is not should adknowledge they recieved this message and request again for an update of the playing field
            //Client of player whose turn it is should reply with an action
        }
コード例 #13
0
ファイル: Move.cs プロジェクト: Nitzahon/Monopoly-Deal-WCF
 /// <summary>
 /// Gets the PlayerModel from a state given the PlayerModels Guid
 /// </summary>
 /// <param name="playerGuid"></param>
 /// <param name="pfm"></param>
 /// <returns></returns>
 public PlayerModel getPlayerModel(Guid playerGuid, PlayFieldModel pfm)
 {
     foreach (PlayerModel pm in pfm.playerModels)
     {
         if (pm.guid.CompareTo(playerGuid) == 0)
         {
             return pm;
         }
     }
     return null;
 }
コード例 #14
0
ファイル: Move.cs プロジェクト: Nitzahon/Monopoly-Deal-WCF
 private BoolResponseBox checkAndSetIfGameIsOver(PlayFieldModel state, Guid playerToCheck)
 {
     if (checkIfPlayerHasEnoughFullUniquelyColoredSetsToWin(state, playerToCheck).success)
     {
         return setGameOver(state, playerToCheck);
     }
     else
     {
         return new BoolResponseBox(false, "Player checked has not won");
     }
 }
コード例 #15
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);
        }
コード例 #16
0
 //Clone Constructors
 public PlayerModel(PlayerModel player, PlayFieldModel state)
 {
     this.hand = new PlayerHand(player.hand, state);
     this.bank = new PlayerBank(player.bank, state);
     this.propertySets = new PlayerPropertySets(player.propertySets, state);
     this.guid = player.guid;
     this.id = player.id;
     this.isThisPlayersTurn = player.isThisPlayersTurn;
     this.name = player.name;
     this.actionsCurrentlyAllowed = player.actionsCurrentlyAllowed.cloneListTurnActionTypes();
     this.isReadyToStartGame = player.isReadyToStartGame;
     this.owesAnotherPlayer = player.owesAnotherPlayer;
     this.amountOwedToAnotherPlayer = player.amountOwedToAnotherPlayer;
 }
コード例 #17
0
 //Clone Constructors
 public PlayerModel(PlayerModel player, PlayFieldModel state)
 {
     this.hand                      = new PlayerHand(player.hand, state);
     this.bank                      = new PlayerBank(player.bank, state);
     this.propertySets              = new PlayerPropertySets(player.propertySets, state);
     this.guid                      = player.guid;
     this.id                        = player.id;
     this.isThisPlayersTurn         = player.isThisPlayersTurn;
     this.name                      = player.name;
     this.actionsCurrentlyAllowed   = player.actionsCurrentlyAllowed.cloneListTurnActionTypes();
     this.isReadyToStartGame        = player.isReadyToStartGame;
     this.owesAnotherPlayer         = player.owesAnotherPlayer;
     this.amountOwedToAnotherPlayer = player.amountOwedToAnotherPlayer;
 }
コード例 #18
0
        public BoolResponseBox doNotJustSayNo(Guid playerGuid, Guid gameLobbyGuid, Guid playfieldModelInstanceGuid)
        {
            PlayFieldModel lastState    = getPreviousState();
            PlayFieldModel currentState = getCurrentState();
            PlayFieldModel nextState    = null;
            PlayerModel    playerModelAtCurrentState = move.getPlayerModel(playerGuid, currentState);
            MoveInfo       doNotPlayJustSayNo        = new MoveInfo();

            doNotPlayJustSayNo.playerMakingMove = playerGuid;
            doNotPlayJustSayNo.moveBeingMade    = TurnActionTypes.Dont_Play_Just_Say_No;
            BoolResponseBox result = move.evaluateMove(lastState, currentState, nextState, playerModelAtCurrentState, doNotPlayJustSayNo.moveBeingMade, doNotPlayJustSayNo);

            return(result);
        }
コード例 #19
0
        public bool playActionCardJustSayNo(int playedCard, Guid playerGuid, Guid gameLobbyGuid, Guid playfieldModelInstanceGuid)
        {
            PlayFieldModel lastState    = getPreviousState();
            PlayFieldModel currentState = getCurrentState();
            PlayFieldModel nextState    = null;
            PlayerModel    playerModelAtCurrentState = move.getPlayerModel(playerGuid, currentState);
            MoveInfo       playJustSayNo             = new MoveInfo();

            playJustSayNo.playerMakingMove  = playerGuid;
            playJustSayNo.moveBeingMade     = TurnActionTypes.PlayJustSayNo;
            playJustSayNo.idOfCardBeingUsed = playedCard;
            BoolResponseBox result = move.evaluateMove(lastState, currentState, nextState, playerModelAtCurrentState, playJustSayNo.moveBeingMade, playJustSayNo);

            return(result.success);
        }
コード例 #20
0
 public GameModel(List<PlayerModel> playersP, Guid guidS)
 {
     //give this a guid
     gameModelGuid = guidS;
     //Assign Players to the game
     players = playersP;
     //Create idLookup
     foreach (PlayerModel pm in players)
     {
         playerIdLookup.Add(pm.guid);
     }
     initialState = createInitialState(players);
     gameStates.Add(initialState);
     //State added to gameStates list, notify all players, wait for responses
 }
コード例 #21
0
 public GameModel(List <PlayerModel> playersP, Guid guidS)
 {
     //give this a guid
     gameModelGuid = guidS;
     //Assign Players to the game
     players = playersP;
     //Create idLookup
     foreach (PlayerModel pm in players)
     {
         playerIdLookup.Add(pm.guid);
     }
     initialState = createInitialState(players);
     gameStates.Add(initialState);
     //State added to gameStates list, notify all players, wait for responses
 }
コード例 #22
0
        /// <summary>
        /// Creates a new MonopolyDeal Game
        /// </summary>
        /// <param name="playersP">List of PlayerModels</param>
        public MonopolyDeal(List<PlayerModel> playersP, Guid thisGameGuidP, ILobby lobby)
        {
            this.lobby = lobby;
            //Assign Guid to this game of Monopoly Deal
            MONOPOLY_DEAL_GAME_GUID = thisGameGuidP;
            gameModelGuid = thisGameGuidP;
            //Assign Players to this game of Monopoly Deal
            players = playersP;

            gameStateManager = new GameStateManagerToMoveAdapter(this);

            addPlayersToIDLookup(playersP);
            initialState = createInitialState(players);
            gameStates.Add(initialState);
            currentState = initialState;
            //State added to gameStates list, notify all players, wait for responses
        }
コード例 #23
0
        public BoolResponseBox endTurn(Guid playerGuid, Guid stateGuid)
        {
            PlayFieldModel lastState    = getPreviousState();
            PlayFieldModel currentState = getCurrentState();
            PlayFieldModel nextState    = null;
            PlayerModel    playerModelAtCurrentState = move.getPlayerModel(playerGuid, currentState);

            MoveInfo endTurnInfo = new MoveInfo();

            endTurnInfo.playerWhoseTurnItIs = playerGuid;
            endTurnInfo.playerMakingMove    = playerGuid;
            endTurnInfo.moveBeingMade       = TurnActionTypes.EndTurn;

            BoolResponseBox result = move.evaluateMove(lastState, currentState, nextState, playerModelAtCurrentState, endTurnInfo.moveBeingMade, endTurnInfo);

            return(result);
        }
コード例 #24
0
        public bool payDebt(List <int> idOfCardsToPayWith, Guid playerGuid, Guid gameLobbyGuid, Guid playfieldModelInstanceGuid)
        {
            PlayFieldModel lastState    = getPreviousState();
            PlayFieldModel currentState = getCurrentState();
            PlayFieldModel nextState    = null;
            PlayerModel    playerModelAtCurrentState = move.getPlayerModel(playerGuid, currentState);
            MoveInfo       payDebt = new MoveInfo();

            payDebt.playerMakingMove = playerGuid;
            payDebt.moveBeingMade    = TurnActionTypes.PayDebt;
            payDebt.listOfIDsOfCardsBeingUsedToPayDebt = idOfCardsToPayWith;
            payDebt.guidOfPlayerToPayDebtTo            = currentState.guidOfPlayerWhosTurnItIs;
            payDebt.amountOwed = playerModelAtCurrentState.amountOwedToAnotherPlayer;
            BoolResponseBox result = move.evaluateMove(lastState, currentState, nextState, playerModelAtCurrentState, payDebt.moveBeingMade, payDebt);

            return(result.success);
        }
コード例 #25
0
        public BoolResponseBox drawFiveCards(Guid player, Guid state)
        {
            PlayFieldModel lastState    = getPreviousState();
            PlayFieldModel currentState = getCurrentState();
            PlayFieldModel nextState    = null;
            PlayerModel    playerModelAtCurrentState = move.getPlayerModel(player, currentState);

            MoveInfo draw5CardsInfo = new MoveInfo();

            draw5CardsInfo.playerWhoseTurnItIs = player;
            draw5CardsInfo.playerMakingMove    = player;
            draw5CardsInfo.moveBeingMade       = TurnActionTypes.drawFiveCardsAtStartOfTurn;

            BoolResponseBox result = move.evaluateMove(lastState, currentState, nextState, playerModelAtCurrentState, draw5CardsInfo.moveBeingMade, draw5CardsInfo);

            return(result);
        }
コード例 #26
0
 //Clone Constructor
 public PropertyCardSet(PropertyCardSet pcs, PlayFieldModel state)
 {
     id = pcs.id;
     guid = pcs.guid;
     hasHouse = pcs.hasHouse;
     hasHotel = pcs.hasHotel;
     if (pcs.hotel != null)
     {
         this.hotel = state.deck.getCardByID(pcs.hotel.cardID);
     }
     if (pcs.house != null)
     {
         this.house = state.deck.getCardByID(pcs.house.cardID);
     }
     properties = pcs.properties.cloneLinkedListPropertyCard(state.deck);
     propertySetColor = pcs.propertySetColor;
 }
コード例 #27
0
        /// <summary>
        /// Creates a new MonopolyDeal Game
        /// </summary>
        /// <param name="playersP">List of PlayerModels</param>
        public MonopolyDeal(List <PlayerModel> playersP, Guid thisGameGuidP, ILobby lobby)
        {
            this.lobby = lobby;
            //Assign Guid to this game of Monopoly Deal
            MONOPOLY_DEAL_GAME_GUID = thisGameGuidP;
            gameModelGuid           = thisGameGuidP;
            //Assign Players to this game of Monopoly Deal
            players = playersP;

            gameStateManager = new GameStateManagerToMoveAdapter(this);

            addPlayersToIDLookup(playersP);
            initialState = createInitialState(players);
            gameStates.Add(initialState);
            currentState = initialState;
            //State added to gameStates list, notify all players, wait for responses
        }
コード例 #28
0
 public PropertyCardSet(PropertyCardSet pcs, PlayFieldModel state)//Clone Constructor
 {
     id       = pcs.id;
     guid     = pcs.guid;
     hasHouse = pcs.hasHouse;
     hasHotel = pcs.hasHotel;
     if (pcs.hotel != null)
     {
         this.hotel = state.deck.getCardByID(pcs.hotel.cardID);
     }
     if (pcs.house != null)
     {
         this.house = state.deck.getCardByID(pcs.house.cardID);
     }
     properties       = pcs.properties.cloneLinkedListPropertyCard(state.deck);
     propertySetColor = pcs.propertySetColor;
 }
コード例 #29
0
        /// <summary>
        /// Returns a copy of an instance of PlayFieldModel
        /// </summary>
        /// <returns></returns>
        public PlayFieldModel clone(Guid guidOfClone)
        {
            Guid oldInstanceGuid = thisPlayFieldModelInstanceGuid.cloneGuid();
            //TODO Clone Deck

            List <PlayerModel> playersCloned          = cloneListPlayerModels(this.playerModels, this);
            List <Card>        topCardsPlayPileCloned = cloneListCards(topCardsOnPlaypile);
            Guid oldPlayerWhoseTurnItIsGuid           = guidOfPlayerWhosTurnItIs.cloneGuid();
            int  numberOfTurnsForPlayerRemaining      = this.numberOfTurnsRemainingForPlayerWhosTurnItIs;
            bool startOfATurnClone = startOfATurn.cloneBool();

            if (lastActionPlayed == null)
            {
                lastActionPlayed = new TurnActionModel(null, new Guid(), new Guid(), new Guid(), null, TurnActionTypes.gameStarted, false);
            }
            PlayFieldModel pfmC = new PlayFieldModel(oldInstanceGuid, guidOfClone, playersCloned, topCardsPlayPileCloned, oldPlayerWhoseTurnItIsGuid, playersAffectedByActionCardGuids.cloneListGuids(), lastActionPlayed.clone(), currentTurnActionModel.clone(), drawPile.clone(deck), playpile.clone(deck), numberOfTurnsForPlayerRemaining, startOfATurnClone, currentPhase, deck.cloneDeck());

            return(pfmC);
        }
コード例 #30
0
        public bool discard(int cardsToDiscardID, Guid playerGuid, Guid serverGuid, Guid playfieldModelInstanceGuid)
        {
            PlayFieldModel lastState    = getPreviousState();
            PlayFieldModel currentState = getCurrentState();
            PlayFieldModel nextState    = null;
            PlayerModel    playerModelAtCurrentState = move.getPlayerModel(playerGuid, currentState);
            Card           playedcard = currentState.deck.getCardByID(cardsToDiscardID);

            if (playedcard != null && checkIfCardInHand(playedcard, playerModelAtCurrentState) != null)
            {
                MoveInfo discard1Card = new MoveInfo();
                discard1Card.moveBeingMade     = TurnActionTypes.Discard_1_Card;
                discard1Card.idOfCardBeingUsed = cardsToDiscardID;

                BoolResponseBox result = move.evaluateMove(lastState, currentState, nextState, playerModelAtCurrentState, discard1Card.moveBeingMade, discard1Card);
                return(result.success);
            }
            return(new BoolResponseBox(false, "Selected Card is not in players hand").success);
        }
コード例 #31
0
        public PollForFieldUpdateMessage(Guid playerSendingGuidP, Guid guidOfMessageThisMessageIsRespondingTo, Guid guidOfThisMessage,
            Guid serverGameGuidP, PlayFieldModel playFieldModelP, Guid playFieldModelGuidP, TurnActionModel turnActionModel)
            : base(guidOfThisMessage, guidOfMessageThisMessageIsRespondingTo, MessageType.pollForFieldUpdate, null, false,
            playerSendingGuidP, serverGameGuidP, null)
        {
            //Message used for requesting updates to the games state represented by PlayFieldModel
            fieldModel = playFieldModelP;

            //Guid to reference in response to this message
            referenceThisGuidToRespond = guidOfThisMessage;

            //Guid of the turn the action was taken on
            fieldModelGuid = playFieldModelGuidP;
            //Actions taken by client sending this message
            actionsToTake = turnActionModel;

            //Clients of players whose turn it is not should adknowledge they recieved this message and request again for an update of the playing field
            //Client of player whose turn it is should reply with an action
        }
コード例 #32
0
        public PollForFieldUpdateMessage(Guid playerSendingGuidP, Guid guidOfMessageThisMessageIsRespondingTo, Guid guidOfThisMessage,
                                         Guid serverGameGuidP, PlayFieldModel playFieldModelP, Guid playFieldModelGuidP, TurnActionModel turnActionModel)
            : base(guidOfThisMessage, guidOfMessageThisMessageIsRespondingTo, MessageType.pollForFieldUpdate, null, false,
                   playerSendingGuidP, serverGameGuidP, null)
        {
            //Message used for requesting updates to the games state represented by PlayFieldModel
            fieldModel = playFieldModelP;

            //Guid to reference in response to this message
            referenceThisGuidToRespond = guidOfThisMessage;

            //Guid of the turn the action was taken on
            fieldModelGuid = playFieldModelGuidP;
            //Actions taken by client sending this message
            actionsToTake = turnActionModel;

            //Clients of players whose turn it is not should adknowledge they recieved this message and request again for an update of the playing field
            //Client of player whose turn it is should reply with an action
        }
コード例 #33
0
        public bool playActionCardPassGo(int passGoCardID, Guid serverGuid, Guid playerGuid, Guid playfieldModelInstanceGuid, TurnActionTypes turnActionTypes)
        {
            PlayFieldModel lastState    = getPreviousState();
            PlayFieldModel currentState = getCurrentState();
            PlayFieldModel nextState    = null;
            PlayerModel    playerModelAtCurrentState = move.getPlayerModel(playerGuid, currentState);
            ActionCard     playedPassGo = monopolyDeal.deck.getCardByID(passGoCardID) as ActionCard;

            if (playedPassGo != null && checkIfCardInHand(playedPassGo, playerModelAtCurrentState) != null)
            {
                MoveInfo playPassGo = new MoveInfo();
                playPassGo.playerWhoseTurnItIs  = playerGuid;
                playPassGo.playerMakingMove     = playerGuid;
                playPassGo.moveBeingMade        = TurnActionTypes.PlayActionCard;
                playPassGo.idOfCardBeingUsed    = passGoCardID;
                playPassGo.actionCardActionType = ActionCardAction.PassGo;

                BoolResponseBox result = move.evaluateMove(lastState, currentState, nextState, playerModelAtCurrentState, playPassGo.moveBeingMade, playPassGo);
                return(result.success);
            }
            return(new BoolResponseBox(false, "Selected Card is not in players hand or is not a Action Card").success);
        }
コード例 #34
0
ファイル: Move.cs プロジェクト: Nitzahon/Monopoly-Deal-WCF
        /// <summary>
        /// Checks if Game is over
        /// </summary>
        /// <param name="state"></param>
        /// <param name="playerToCheck"></param>
        /// <returns></returns>
        private BoolResponseBox checkIfPlayerHasEnoughFullUniquelyColoredSetsToWin(PlayFieldModel state, Guid playerToCheck)
        {
            //Check for each possible set colour if a player has a full set, if at least NUMBER_OF_FULL_SETS_REQUIRED_TO_WIN different coloured sets are full a player has won and the game is over

            HashSet<PropertyColor> uniquelyColouredFullSets = new HashSet<PropertyColor>();
            PlayerModel player = getPlayerModel(playerToCheck, state);
            foreach (PropertyCardSet propertySet in player.propertySets.playersPropertySets)
            {
                if (propertySet.isFullSet())
                {
                    uniquelyColouredFullSets.Add(propertySet.getPropertySetColor());
                }
            }
            if (uniquelyColouredFullSets.Count >= MonopolyDeal.NUMBER_OF_FULL_SETS_REQUIRED_TO_WIN)
            {
                return new BoolResponseBox(true, "The player to check has enough uniquely coloured full sets to win");
            }
            else
            {
                return new BoolResponseBox(false, "The player to check does not have enough uniquely coloured full sets to win");
            }
        }
コード例 #35
0
        public bool playPropertyCardToNewSet(Guid gameGuid, bool isOrientedUp, Guid playerGuid, Guid gameStateActionShouldBeAppliedOnGuid, TurnActionTypes actionType, int propertyCardID)
        {
            PlayFieldModel lastState    = getPreviousState();
            PlayFieldModel currentState = getCurrentState();
            PlayFieldModel nextState    = null;
            PlayerModel    playerModelAtCurrentState = move.getPlayerModel(playerGuid, currentState);
            PropertyCard   playedcard = monopolyDeal.deck.getCardByID(propertyCardID) as PropertyCard;

            if (playedcard != null && checkIfCardInHand(playedcard, playerModelAtCurrentState) != null)
            {
                MoveInfo playPropertyCardFromHand = new MoveInfo();
                playPropertyCardFromHand.playerWhoseTurnItIs            = playerGuid;
                playPropertyCardFromHand.playerMakingMove               = playerGuid;
                playPropertyCardFromHand.moveBeingMade                  = TurnActionTypes.PlayPropertyCardFromHand;
                playPropertyCardFromHand.idOfCardBeingUsed              = propertyCardID;
                playPropertyCardFromHand.isPropertyToPlayOrientedUp     = isOrientedUp;
                playPropertyCardFromHand.addPropertyToPlayToExistingSet = false;//Add to new set

                BoolResponseBox result = move.evaluateMove(lastState, currentState, nextState, playerModelAtCurrentState, playPropertyCardFromHand.moveBeingMade, playPropertyCardFromHand);
                return(result.success);
            }
            return(new BoolResponseBox(false, "Selected Card is not in players hand or is not a property card").success);
        }
コード例 #36
0
        public bool playActionCardItsMyBirthday(int myBirthdayCardID, Guid playerGuid, Guid gameLobbyGuid, Guid stateGuid)
        {
            PlayFieldModel lastState    = getPreviousState();
            PlayFieldModel currentState = getCurrentState();
            PlayFieldModel nextState    = null;
            PlayerModel    playerModelAtCurrentState = move.getPlayerModel(playerGuid, currentState);
            ActionCard     playedActionCard          = monopolyDeal.deck.getCardByID(myBirthdayCardID) as ActionCard;

            if (playedActionCard != null && checkIfCardInHand(playedActionCard, playerModelAtCurrentState) != null)
            {
                MoveInfo playBirthday = new MoveInfo();
                playBirthday.playerWhoseTurnItIs = currentState.guidOfPlayerWhosTurnItIs;
                playBirthday.playerMakingMove    = playerGuid;
                playBirthday.moveBeingMade       = TurnActionTypes.PlayActionCard;
                playBirthday.idOfCardBeingUsed   = myBirthdayCardID;

                playBirthday.actionCardActionType = ActionCardAction.ItsMyBirthday;

                BoolResponseBox result = move.evaluateMove(lastState, currentState, nextState, playerModelAtCurrentState, playBirthday.moveBeingMade, playBirthday);
                return(result.success);
            }
            return(new BoolResponseBox(false, "Selected Card is not in players hand or is not a Action card").success);
        }
コード例 #37
0
 /// <summary>
 /// Gets the current state of a Monopoly Deal Game on service hiding cards of other players
 /// </summary>
 /// <param name="playerGuid">Guid of player</param>
 /// <param name="gameGuid">Guid of MonopolyDeal game instance</param>
 /// <returns>PlayFieldModel of current state</returns>
 public PlayFieldModel pollStateMonopolyDealPerPlayer(GuidBox playerGuid, GuidBox gameGuid)
 {
     try
     {
         //Find MonopolyDealGame
         MonopolyDeal md = getMonopolyDeal(gameGuid.guid);
         if (md != null)
         {
             //Ask GameStateManager for currentState
             PlayFieldModel currentState = md.getMonopolyDealGameStateManager().getCurrentState();
             //TODO:Current state should be filtered here so players cant see other players hands
             //TODO:Could send Acknowledgement at this point but currently will have client send Acknowledgement
             return(currentState);
         }
         else
         {
             return(null);
         }
     }
     catch (System.ServiceModel.CommunicationException ex)
     {
         throw new FaultException(ex.Message);
     }
 }
コード例 #38
0
ファイル: Move.cs プロジェクト: Nitzahon/Monopoly-Deal-WCF
        private BoolResponseBox endTurn(PlayFieldModel currentState, PlayFieldModel nextState, PlayerModel playerPerformingAction)
        {
            //Allowed to end turn
            //Clone the current state to create next state then draws two cards in the next state
            nextState = currentState.clone(generateGuidForNextState());
            PlayerModel playerModelForPlayer = getPlayerModel(playerPerformingAction.guid, nextState);

            //action is valid for player at this time
            List<TurnActionTypes> notOnTurn = new List<TurnActionTypes>();
            List<TurnActionTypes> onTurn = new List<TurnActionTypes>();
            //Could perform the action here instead, for now just change the phase of the state
            //Not an action so cant be just say no'd

            //Check if Game is over
            if (checkAndSetIfGameIsOver(nextState, playerPerformingAction.guid).success)
            {
                //Game is now over as player has enough unique full sets
                return new BoolResponseBox(true, "Player:" + playerPerformingAction.name + " Ended their turn and won the game!");
            }
            //Change phase
            switch (playerModelForPlayer.hand.cardsInHand.Count)
            {
                case 8:
                    {
                        nextState.currentPhase = Statephase.Turn_Ended_8_Cards_In_Hand_Discard_1_Card;
                        onTurn.Add(TurnActionTypes.Discard_1_Card);
                        //Update the moves for players
                        updateAllowableStates(nextState, notOnTurn, onTurn, nextState.guidOfPlayerWhosTurnItIs, nextState.guidOfPlayerWhosTurnItIs);
                        //change the current state to the next state
                        addNextState(nextState);
                        return new BoolResponseBox(true, "Player:" + playerPerformingAction.name + " Ended their turn with 8 cards and must discard 1 card");
                    }
                case 9:
                    {
                        nextState.currentPhase = Statephase.Turn_Ended_9_Cards_In_Hand_Discard_2_Cards;
                        onTurn.Add(TurnActionTypes.Discard_1_Card);
                        //Update the moves for players
                        updateAllowableStates(nextState, notOnTurn, onTurn, nextState.guidOfPlayerWhosTurnItIs, nextState.guidOfPlayerWhosTurnItIs);
                        //change the current state to the next state
                        addNextState(nextState);
                        return new BoolResponseBox(true, "Player:" + playerPerformingAction.name + " Ended their turn with 9 cards and must discard 2 cards");
                    }
                case 10:
                    {
                        nextState.currentPhase = Statephase.Turn_Ended_10_Cards_In_Hand_Discard_3_Cards;
                        onTurn.Add(TurnActionTypes.Discard_1_Card);
                        //Update the moves for players
                        updateAllowableStates(nextState, notOnTurn, onTurn, nextState.guidOfPlayerWhosTurnItIs, nextState.guidOfPlayerWhosTurnItIs);
                        //change the current state to the next state
                        addNextState(nextState);
                        return new BoolResponseBox(true, "Player:" + playerPerformingAction.name + " Ended their turn with 10 cards and must discard 3 cards");
                    }
                case 11:
                    {
                        nextState.currentPhase = Statephase.Turn_Ended_11_Cards_In_Hand_Discard_4_Cards;
                        onTurn.Add(TurnActionTypes.Discard_1_Card);
                        //Update the moves for players
                        updateAllowableStates(nextState, notOnTurn, onTurn, nextState.guidOfPlayerWhosTurnItIs, nextState.guidOfPlayerWhosTurnItIs);
                        //change the current state to the next state
                        addNextState(nextState);
                        return new BoolResponseBox(true, "Player:" + playerPerformingAction.name + " Ended their turn with 11 cards and must discard 4 cards");
                    }
                case 12:
                    {
                        nextState.currentPhase = Statephase.Turn_Ended_12_Cards_In_Hand_Discard_5_Cards;
                        onTurn.Add(TurnActionTypes.Discard_1_Card);
                        //Update the moves for players
                        updateAllowableStates(nextState, notOnTurn, onTurn, nextState.guidOfPlayerWhosTurnItIs, nextState.guidOfPlayerWhosTurnItIs);
                        //change the current state to the next state
                        addNextState(nextState);
                        return new BoolResponseBox(true, "Player:" + playerPerformingAction.name + " Ended their turn with 12 cards and must discard 5 cards");
                    }
                default:
                    {
                        nextState.currentPhase = Statephase.Turn_Ended_7_Or_Less_Cards_In_Hand_Setup_NextPlayer;
                        setNextPlayerOnTurn(nextState);
                        if (getPlayerModel(nextState.guidOfPlayerWhosTurnItIs, nextState).hand.cardsInHand.Count == 0)
                        {
                            //Player has 0 cards draws 5 on turn start instead of 2
                            nextState.currentPhase = Statephase.Turn_Started_Draw_5_Cards;
                            onTurn.Add(TurnActionTypes.drawFiveCardsAtStartOfTurn);
                            //Update the moves for players
                            updateAllowableStates(nextState, notOnTurn, onTurn, nextState.guidOfPlayerWhosTurnItIs, nextState.guidOfPlayerWhosTurnItIs);
                            //change the current state to the next state
                            addNextState(nextState);
                            return new BoolResponseBox(true, "Player:" + playerPerformingAction.name + " Ended their turn." + "Player:" + getPlayerModel(nextState.guidOfPlayerWhosTurnItIs, nextState).name + "\'s Turn. Draw 5 Cards.");
                        }
                        else
                        {
                            //Player has at least one and at most seven cards, draws 2
                            nextState.currentPhase = Statephase.Turn_Started_Draw_2_Cards;
                            onTurn.Add(TurnActionTypes.drawTwoCardsAtStartOfTurn);
                            //Update the moves for players
                            updateAllowableStates(nextState, notOnTurn, onTurn, nextState.guidOfPlayerWhosTurnItIs, nextState.guidOfPlayerWhosTurnItIs);
                            //change the current state to the next state
                            addNextState(nextState);
                            return new BoolResponseBox(true, "Player:" + playerPerformingAction.name + " Ended their turn." + "Player:" + getPlayerModel(nextState.guidOfPlayerWhosTurnItIs, nextState).name + "\'s Turn. Draw 2 Cards.");
                        }
                    }
            }
        }
コード例 #39
0
ファイル: Move.cs プロジェクト: Nitzahon/Monopoly-Deal-WCF
        /// <summary>
        /// Sets the next player to have their turn.
        /// </summary>
        /// <param name="pfm"></param>
        private void setNextPlayerOnTurn(PlayFieldModel pfm)
        {
            playerTurnCounter++;
            if (playerTurnCounter >= pfm.playerModels.Count)
            {
                playerTurnCounter = 0;
            }

            int nextPlayerID = playerTurnCounter;

            pfm.guidOfPlayerWhosTurnItIs = pfm.playerModels[nextPlayerID].guid;

            foreach (PlayerModel p in pfm.playerModels)
            {
                if (p.guid.CompareTo(pfm.guidOfPlayerWhosTurnItIs) == 0)
                {
                    if (p.isThisPlayersTurn)
                    {
                        throw new Exception("player allready on turn");
                    }

                    p.isThisPlayersTurn = true;
                }
                else
                {
                    p.isThisPlayersTurn = false;
                }
            }
            pfm.guidOfPlayerWhosTurnItIs = pfm.playerModels.ElementAt(nextPlayerID).guid;
        }
コード例 #40
0
ファイル: Move.cs プロジェクト: Nitzahon/Monopoly-Deal-WCF
        /// <summary>
        /// Allows a player to Draw 5 Cards at the start of their turn
        /// </summary>
        /// <param name="currentState"></param>
        /// <param name="nextState"></param>
        /// <param name="playerPerformingAction"></param>
        /// <param name="nextStatePhaseIfSuccessful"></param>
        /// <returns></returns>
        private BoolResponseBox draw5CardsAtStartOfTurn(PlayFieldModel currentState, PlayFieldModel nextState, PlayerModel playerPerformingAction, Statephase nextStatePhaseIfSuccessful)
        {
            //Check
            //Perform action in next state
            //Clone the current state to create next state then draws 5 cards in the next state
            nextState = currentState.clone(generateGuidForNextState());
            PlayerModel playerModelForPlayer = getPlayerModel(playerPerformingAction.guid, nextState);

            //Perform action
            playerModelForPlayer.hand.addCardToHand(nextState.drawPile.drawcard());
            playerModelForPlayer.hand.addCardToHand(nextState.drawPile.drawcard());
            playerModelForPlayer.hand.addCardToHand(nextState.drawPile.drawcard());
            playerModelForPlayer.hand.addCardToHand(nextState.drawPile.drawcard());
            playerModelForPlayer.hand.addCardToHand(nextState.drawPile.drawcard());

            //drawtwocards has been performed, advance the phase of the game
            nextState.currentPhase = nextStatePhaseIfSuccessful;
            //Respond that the move has been performed

            //player has drawn their 5 cards, Now can play up to three cards on their turn
            //Set the allowable moves for all players for the next state
            List<TurnActionTypes> notOnTurn = new List<TurnActionTypes>();
            List<TurnActionTypes> onTurn = new List<TurnActionTypes>();
            onTurn = setAllowableActionsOnTurn(onTurn, nextState);
            updateAllowableStates(nextState, notOnTurn, onTurn, nextState.guidOfPlayerWhosTurnItIs, nextState.guidOfPlayerWhosTurnItIs);

            //change the current state to the next state
            addNextState(nextState);
            return new BoolResponseBox(true, "Player:" + playerPerformingAction.name + " Has drawn 5 cards");
        }
コード例 #41
0
ファイル: Move.cs プロジェクト: Nitzahon/Monopoly-Deal-WCF
        /// <summary>
        /// Allows a player on their turn to play a Pass Go card
        /// </summary>
        /// <param name="currentState"></param>
        /// <param name="nextState"></param>
        /// <param name="playerPerformingAction"></param>
        /// <param name="nextStatePhaseIfSuccessful"></param>
        /// <param name="passGoInfo"></param>
        /// <returns></returns>
        public BoolResponseBox playActionCardPassGo(PlayFieldModel currentState, PlayFieldModel nextState, PlayerModel playerPerformingAction, Statephase nextStatePhaseIfSuccessful, MoveInfo passGoInfo)
        {
            //Check
            //Perform action in next state
            //Clone the current state to create next state then draws 5 cards in the next state
            nextState = currentState.clone(generateGuidForNextState());
            PlayerModel playerModelForPlayer = getPlayerModel(playerPerformingAction.guid, nextState);

            Card cardInHandToBePlayed = nextState.deck.getCardByID(passGoInfo.idOfCardBeingUsed);
            //Get the reference to the players playerModel in the current PlayFieldModel

            PlayerModel player = getPlayerModel(passGoInfo.playerMakingMove, nextState);
            //Get the reference to the Card in the current PlayFieldModel
            if (cardInHandToBePlayed != null && cardInHandToBePlayed is ActionCard && ((ActionCard)cardInHandToBePlayed).actionType.CompareTo(ActionCardAction.PassGo) == 0)
            {
                Card card = removeCardFromHand(cardInHandToBePlayed, player);
                if (card != null)
                {
                    ActionCard actionCard = card as ActionCard;
                    player.hand.addCardToHand(nextState.drawPile.drawcard());
                    player.hand.addCardToHand(nextState.drawPile.drawcard());
                    //Change state on success
                    //has been performed, advance the phase of the game
                    nextState.currentPhase = nextStatePhaseIfSuccessful;
                    //Put card in discard pile
                    nextState.playpile.playCardOnPile(card);
                    List<TurnActionTypes> notOnTurn = new List<TurnActionTypes>();
                    List<TurnActionTypes> onTurn = new List<TurnActionTypes>();
                    onTurn = setAllowableActionsOnTurn(onTurn, nextState);

                    updateAllowableStates(nextState, notOnTurn, onTurn, nextState.guidOfPlayerWhosTurnItIs, nextState.guidOfPlayerWhosTurnItIs);
                    //change the current state to the next state
                    addNextState(nextState);
                    return new BoolResponseBox(true, "Player:" + playerPerformingAction.name + " Has passed go and drawn 2 cards");
                }
                return new BoolResponseBox(false, "Card is not in hand.");
            }
            return new BoolResponseBox(false, "Card is not in hand or is not a pass go card");
        }
コード例 #42
0
ファイル: Move.cs プロジェクト: Nitzahon/Monopoly-Deal-WCF
        private BoolResponseBox playActionCardForcedDeal(PlayFieldModel currentState, PlayFieldModel nextState, PlayerModel playerPerformingAction, Statephase nextStatePhase, MoveInfo moveInformation)
        {
            //Check
            //Perform action in next state
            //Clone the current state to create next state then draws 5 cards in the next state
            nextState = currentState.clone(generateGuidForNextState());
            PlayerModel playerModelForPlayer = getPlayerModel(playerPerformingAction.guid, nextState);
            PlayerModel playerModelForPlayerToForcedDeal = getPlayerModel(moveInformation.guidOfPlayerWhoIsBeingForcedDealed, nextState);
            Card cardInHandToBePlayed = nextState.deck.getCardByID(moveInformation.idOfCardBeingUsed);
            //Get the reference to the players playerModel in the current PlayFieldModel

            //Get the reference to the Card in the current PlayFieldModel
            if (cardInHandToBePlayed != null && cardInHandToBePlayed is ActionCard && ((ActionCard)cardInHandToBePlayed).actionType.CompareTo(ActionCardAction.ForcedDeal) == 0)
            {
                Card card = removeCardFromHand(cardInHandToBePlayed, playerModelForPlayer);
                if (card != null)
                {
                    ActionCard actionCard = card as ActionCard;
                    //Do action
                    PropertyCardSet setToForcedDealFrom = getPropertyCardSet(playerModelForPlayerToForcedDeal.propertySets, moveInformation.guidOfSetCardToBeForcedDealedIsIn);
                    PropertyCard cardToForcedDealFor = nextState.deck.getCardByID(moveInformation.idOfCardToBeForcedDealed) as PropertyCard;

                    PropertyCardSet setToGiveUpCardFrom = getPropertyCardSet(playerModelForPlayer.propertySets, moveInformation.guidOfSetCardGivenUpInForcedDealIsIn);
                    PropertyCard cardToGiveUp = nextState.deck.getCardByID(moveInformation.idOfCardToBeGivenUpInForcedDeal) as PropertyCard;
                    if (setToForcedDealFrom != null && cardToForcedDealFor != null && setToGiveUpCardFrom != null && cardToGiveUp != null)
                    {
                        if (playerModelForPlayerToForcedDeal.removePropertyCardFromPlayersPropertySet(cardToForcedDealFor, moveInformation.guidOfSetCardToBeForcedDealedIsIn) != null)
                        {
                            //Card Removed from set
                            //Create new set with card Forced Dealed in it
                            PropertyCardSet newSetForcedDealCard = new PropertyCardSet(cardToForcedDealFor);
                            playerModelForPlayer.propertySets.addSet(newSetForcedDealCard);
                            if (playerModelForPlayer.removePropertyCardFromPlayersPropertySet(cardToGiveUp, moveInformation.guidOfSetCardGivenUpInForcedDealIsIn) != null)
                            {
                                //Forced dealed player recieves card given up in forced deal
                                PropertyCardSet newSetGivenUpCard = new PropertyCardSet(cardToGiveUp);
                                playerModelForPlayerToForcedDeal.propertySets.addSet(newSetGivenUpCard);
                                playerModelForPlayerToForcedDeal.hasHadCardsTaken = true;
                                //Change state on success
                                //has been performed, advance the phase of the game
                                nextState.currentPhase = nextStatePhase;
                                //Put card in discard pile
                                nextState.playpile.playCardOnPile(actionCard);
                                List<TurnActionTypes> notOnTurn = new List<TurnActionTypes>();
                                List<TurnActionTypes> onTurn = new List<TurnActionTypes>();
                                onTurn = setAllowableActionsOnTurn(onTurn, nextState);

                                nextState.actionCardEvent = new ActionCardEvent();
                                nextState.actionCardEvent.playerAffectedByAction = moveInformation.guidOfPlayerWhoIsBeingForcedDealed;
                                nextState.actionCardEvent.playerWhoPerformedActionOffTurn = moveInformation.playerMakingMove;
                                nextState.actionCardEvent.playerOnTurnPerformingAction = true;
                                nextState.actionCardEvent.actionTypeTaken = TurnActionTypes.PlayActionCard;

                                nextState.actionCardEvent.actionCardTypeUsed = ActionCardAction.ForcedDeal;
                                List<CardIDSetGuid> listOfCardsForcedDealed = new List<CardIDSetGuid>();
                                listOfCardsForcedDealed.Add(new CardIDSetGuid(moveInformation.idOfCardToBeForcedDealed, moveInformation.guidOfSetCardToBeForcedDealedIsIn));
                                nextState.actionCardEvent.propertyCardsTakenFromPlayerAndSetTheCardWasIn = listOfCardsForcedDealed;
                                nextState.actionCardEvent.propertyCardGivenUpInForcedDeal = new CardIDSetGuid(moveInformation.idOfCardToBeGivenUpInForcedDeal, moveInformation.guidOfSetCardGivenUpInForcedDealIsIn);
                                //change the current state to the next state

                                updateAllowableStatesPerPlayerCardsTaken(nextState, notOnTurn, onTurn, nextState.guidOfPlayerWhosTurnItIs, setAllowableActionsNotOnTurnCardsTaken(new List<TurnActionTypes>(), nextState));
                                addNextState(nextState);
                                return new BoolResponseBox(true, "Player:" + playerPerformingAction.name + " Has used a Forced Deal Card");
                            }
                            else
                            {
                                return new BoolResponseBox(false, "Unable to remove card to be given up");
                            }
                        }
                        else
                        {
                            return new BoolResponseBox(false, "Unable to remove card from player being forced dealed set");
                        }
                    }
                    else
                    {
                        return new BoolResponseBox(false, "Card to Forced Deal or set the card is in does not exist");
                    }
                }

                return new BoolResponseBox(false, "Card is not in hand.");
            }
            return new BoolResponseBox(false, "Card is not in hand or is not a Forced Deal Card");
        }
コード例 #43
0
ファイル: Move.cs プロジェクト: Nitzahon/Monopoly-Deal-WCF
 private void updateAllowableStatesPerPlayerCardsTaken(PlayFieldModel state, List<TurnActionTypes> allowedForPlayersWhoDontHaveCardsTaken, List<TurnActionTypes> allowedForPlayerOnTurn, Guid playerOnTurnGuid, List<TurnActionTypes> allowedForPlayersWhoDoHaveCardsTaken)
 {
     foreach (PlayerModel p in state.playerModels)
     {
         if (p.guid.CompareTo(playerOnTurnGuid) == 0)
         {
             //its p's turn
             p.actionsCurrentlyAllowed = allowedForPlayerOnTurn;
         }
         else if (p.hasHadCardsTaken)
         {
             p.actionsCurrentlyAllowed = allowedForPlayersWhoDoHaveCardsTaken;
         }
         else
         {
             p.actionsCurrentlyAllowed = allowedForPlayersWhoDontHaveCardsTaken;
         }
     }
 }
コード例 #44
0
ファイル: Move.cs プロジェクト: Nitzahon/Monopoly-Deal-WCF
        /// <summary>
        /// Determines what state the game is currently in and sets the appropriate possible next states for the move being played and calls doAppropriateAction to play the move
        /// </summary>
        /// <param name="lastState"></param>
        /// <param name="currentState"></param>
        /// <param name="nextState"></param>
        /// <param name="playerPerformingAction"></param>
        /// <param name="typeOfActionToPerform"></param>
        /// <param name="cardsAndPlayersInvolved"></param>
        /// <returns></returns>
        public BoolResponseBox evaluateMove(PlayFieldModel lastState, PlayFieldModel currentState, PlayFieldModel nextState, PlayerModel playerPerformingAction, TurnActionTypes typeOfActionToPerform, MoveInfo cardsAndPlayersInvolved)
        {
            BoolResponseBox result;

            #region Draw2State

            if (currentState.currentPhase.CompareTo(Statephase.Turn_Started_Draw_2_Cards) == 0)
            {
                //Action card that can be just say no carded next state
                Statephase justSayNoAble = Statephase.Turn_Started_Cards_Drawn_0_Cards_Played;//Action cards not playable at this phase
                //Any move that plays a card excluding justSayNo move next state
                Statephase notJustSayNoAble = Statephase.Turn_Started_Cards_Drawn_0_Cards_Played;//No cards playable at this phase
                //Just Say No card played by off turn player
                Statephase JustSayNoUsedByOpposition = Statephase.Turn_Started_Cards_Drawn_0_Cards_Played;
                //Property card rearranging next state
                Statephase rearrangeProperties = Statephase.Turn_Started_Cards_Drawn_0_Cards_Played;//No cards can be rearranged at this phase
                //Draw
                Statephase drawCardsAtTurnStart = Statephase.Turn_Started_Cards_Drawn_0_Cards_Played;//Only action allowable at this phase
                Statephase discard = Statephase.Turn_Started_Draw_2_Cards;
                BoolResponseBox isMoveTypeAllowableAtCurrentPhase = checkIfMoveAllowedAtThisState(typeOfActionToPerform, playerPerformingAction, currentState);
                if (isMoveTypeAllowableAtCurrentPhase.success)
                {
                    //type of move is allowable at this point for this player. Check if move is doable ex is a set stealable
                    result = doAppropriateAction(lastState, currentState, nextState, playerPerformingAction, typeOfActionToPerform, justSayNoAble, notJustSayNoAble, rearrangeProperties, drawCardsAtTurnStart, JustSayNoUsedByOpposition, cardsAndPlayersInvolved, discard);

                    return result;//True if action performed, False if not
                }
                else
                {
                    //No other actionTypes are allowable in this state
                    return new BoolResponseBox(false, "Player:" + playerPerformingAction.name + " is not able to perform " + typeOfActionToPerform + " at this state:" + currentState.currentPhase.ToString());
                }
            }

            #endregion Draw2State

            #region Draw5State

            else if (currentState.currentPhase.CompareTo(Statephase.Turn_Started_Draw_5_Cards) == 0)
            {
                //Action card that can be just say no carded next state
                Statephase justSayNoAble = Statephase.Turn_Started_Cards_Drawn_0_Cards_Played;//Action cards not playable at this phase
                //Any move that plays a card excluding justSayNo move next state
                Statephase notJustSayNoAble = Statephase.Turn_Started_Cards_Drawn_0_Cards_Played;//No cards playable at this phase
                //Just Say No card played by off turn player
                Statephase JustSayNoUsedByOpposition = Statephase.Turn_Started_Cards_Drawn_0_Cards_Played;
                //Property card rearranging next state
                Statephase rearrangeProperties = Statephase.Turn_Started_Cards_Drawn_0_Cards_Played;//No cards can be rearranged at this phase
                //Draw
                Statephase drawCardsAtTurnStart = Statephase.Turn_Started_Cards_Drawn_0_Cards_Played;//Only action allowable at this phase
                Statephase discard = Statephase.Turn_Started_Draw_5_Cards;
                BoolResponseBox isMoveTypeAllowableAtCurrentPhase = checkIfMoveAllowedAtThisState(typeOfActionToPerform, playerPerformingAction, currentState);
                if (isMoveTypeAllowableAtCurrentPhase.success)
                {
                    //type of move is allowable at this point for this player. Check if move is doable ex is a set stealable
                    result = doAppropriateAction(lastState, currentState, nextState, playerPerformingAction, typeOfActionToPerform, justSayNoAble, notJustSayNoAble, rearrangeProperties, drawCardsAtTurnStart, JustSayNoUsedByOpposition, cardsAndPlayersInvolved, discard);

                    return result;//True if action performed, False if not
                }
                else
                {
                    //No other actionTypes are allowable in this state
                    return new BoolResponseBox(false, "Player:" + playerPerformingAction.name + " is not able to perform " + typeOfActionToPerform + " at this state:" + currentState.currentPhase.ToString());
                }
            }

            #endregion Draw5State

            #region Turn Started Cards Drawn 0 Cards Played

            else if (currentState.currentPhase.CompareTo(Statephase.Turn_Started_Cards_Drawn_0_Cards_Played) == 0)
            {
                //Action card that can be just say no carded next state
                Statephase justSayNoAble = Statephase.Turn_Started_Cards_Drawn_0_Cards_Played_Ask_Just_Say_No;//Action cards not playable at this phase
                //Any move that plays a card excluding justSayNo move next state
                Statephase notJustSayNoAble = Statephase.Turn_Started_Cards_Drawn_1_Cards_Played;//No cards playable at this phase
                //Just Say No card played by off turn player
                Statephase JustSayNoUsedByOpposition = Statephase.Turn_Started_Cards_Drawn_0_Cards_Played_Just_Say_No_Used_By_Oppostion_Ask_Player_On_Turn_Just_Say_No;
                //Property card rearranging next state
                Statephase rearrangeProperties = Statephase.Turn_Started_Cards_Drawn_0_Cards_Played;//No cards can be rearranged at this phase
                //Draw
                Statephase discard = Statephase.Turn_Started_Cards_Drawn_0_Cards_Played;
                Statephase drawCardsAtTurnStart = Statephase.Turn_Started_Cards_Drawn_0_Cards_Played;//Only action allowable at this phase
                BoolResponseBox isMoveTypeAllowableAtCurrentPhase = checkIfMoveAllowedAtThisState(typeOfActionToPerform, playerPerformingAction, currentState);
                if (isMoveTypeAllowableAtCurrentPhase.success)
                {
                    //type of move is allowable at this point for this player. Check if move is doable ex is a set stealable
                    result = doAppropriateAction(lastState, currentState, nextState, playerPerformingAction, typeOfActionToPerform, justSayNoAble, notJustSayNoAble, rearrangeProperties, drawCardsAtTurnStart, JustSayNoUsedByOpposition, cardsAndPlayersInvolved, discard);

                    return result;//True if action performed, False if not
                }
                else
                {
                    //No other actionTypes are allowable in this state
                    return new BoolResponseBox(false, "Player:" + playerPerformingAction.name + " is not able to perform " + typeOfActionToPerform + " at this state:" + currentState.currentPhase.ToString());
                }
            }

            #endregion Turn Started Cards Drawn 0 Cards Played

            #region 0 Cards Played Just Say Noable Card Played

            else if (currentState.currentPhase.CompareTo(Statephase.Turn_Started_Cards_Drawn_0_Cards_Played_Ask_Just_Say_No) == 0)
            {
                Statephase discard = Statephase.Invalid_Action_For_Turn;

                //Player used Just Say No
                Statephase JustSayNoUsedByOpposition = Statephase.Turn_Started_Cards_Drawn_0_Cards_Played_Just_Say_No_Used_By_Oppostion_Ask_Player_On_Turn_Just_Say_No;
                /*
                //Player did not play just say no and is dealbreakered or sly dealed or forced dealed
                Statephase JustSayNoNotUsed = Statephase.Turn_Started_Cards_Drawn_1_Cards_Played;

                //Player has to pay rent or Birthday or Debt Collector
                Statephase PayDebt = Statephase.Turn_Started_Cards_Drawn_1_Cards_Play
                */
                //Action card that can be just say no carded next state
                Statephase justSayNoAble = Statephase.Turn_Started_Cards_Drawn_0_Cards_Played_Ask_Just_Say_No;//Action cards not playable at this phase
                //Any move that plays a card excluding justSayNo move next state
                Statephase notJustSayNoAble = Statephase.Turn_Started_Cards_Drawn_1_Cards_Played;//cards playable at this phase

                //Property card rearranging next state
                Statephase rearrangeProperties = Statephase.Invalid_Action_For_Turn;//cards can be rearranged at this phase
                //Draw
                Statephase drawCardsAtTurnStart = Statephase.Invalid_Action_For_Turn;//not allowable at this phase
                BoolResponseBox isMoveTypeAllowableAtCurrentPhase = checkIfMoveAllowedAtThisState(typeOfActionToPerform, playerPerformingAction, currentState);
                //In this state players may be required to pay rent, birthday or debt collector money or use a just say no
                if (isMoveTypeAllowableAtCurrentPhase.success)
                {
                    //type of move is allowable at this point for this player. Check if move is doable ex is a set stealable
                    result = doAppropriateAction(lastState, currentState, nextState, playerPerformingAction, typeOfActionToPerform, justSayNoAble, notJustSayNoAble, rearrangeProperties, drawCardsAtTurnStart, JustSayNoUsedByOpposition, cardsAndPlayersInvolved, discard);

                    return result;//True if action performed, False if not
                }
                else
                {
                    //No other actionTypes are allowable in this state
                    return new BoolResponseBox(false, "Player:" + playerPerformingAction.name + " is not able to perform " + typeOfActionToPerform + " at this state:" + currentState.currentPhase.ToString());
                }
            }

            #endregion 0 Cards Played Just Say Noable Card Played

            #region 0 Cards Played Just Say Noable Card Just Say No'd

            else if (currentState.currentPhase.CompareTo(Statephase.Turn_Started_Cards_Drawn_0_Cards_Played_Just_Say_No_Used_By_Oppostion_Ask_Player_On_Turn_Just_Say_No) == 0)
            {
                Statephase discard = Statephase.Invalid_Action_For_Turn;

                //Player used Just Say No
                Statephase JustSayNoUsedByOpposition = Statephase.Invalid_Action_For_Turn;
                /*
                //Player did not play just say no and is dealbreakered or sly dealed or forced dealed
                Statephase JustSayNoNotUsed = Statephase.Turn_Started_Cards_Drawn_1_Cards_Played;

                //Player has to pay rent or Birthday or Debt Collector
                Statephase PayDebt = Statephase.Turn_Started_Cards_Drawn_1_Cards_Play
                */
                //Action card that can be just say no carded next state
                Statephase justSayNoAble = Statephase.Turn_Started_Cards_Drawn_0_Cards_Played_Ask_Just_Say_No;//Action cards not playable at this phase except just say no
                //Any move that plays a card excluding justSayNo move next state
                Statephase notJustSayNoAble = Statephase.Turn_Started_Cards_Drawn_1_Cards_Played;//cards playable at this phase

                //Property card rearranging next state
                Statephase rearrangeProperties = Statephase.Invalid_Action_For_Turn;//cards can be rearranged at this phase
                //Draw
                Statephase drawCardsAtTurnStart = Statephase.Invalid_Action_For_Turn;//not allowable at this phase
                BoolResponseBox isMoveTypeAllowableAtCurrentPhase = checkIfMoveAllowedAtThisState(typeOfActionToPerform, playerPerformingAction, currentState);
                //In this state players may be required to pay rent, birthday or debt collector money or use a just say no
                if (isMoveTypeAllowableAtCurrentPhase.success)
                {
                    //type of move is allowable at this point for this player. Check if move is doable ex is a set stealable
                    result = doAppropriateAction(lastState, currentState, nextState, playerPerformingAction, typeOfActionToPerform, justSayNoAble, notJustSayNoAble, rearrangeProperties, drawCardsAtTurnStart, JustSayNoUsedByOpposition, cardsAndPlayersInvolved, discard);

                    return result;//True if action performed, False if not
                }
                else
                {
                    //No other actionTypes are allowable in this state
                    return new BoolResponseBox(false, "Player:" + playerPerformingAction.name + " is not able to perform " + typeOfActionToPerform + " at this state:" + currentState.currentPhase.ToString());
                }
            }

            #endregion 0 Cards Played Just Say Noable Card Just Say No'd

            #region 1 Card Played State

            else if (currentState.currentPhase.CompareTo(Statephase.Turn_Started_Cards_Drawn_1_Cards_Played) == 0)
            {
                //Action card that can be just say no carded next state
                Statephase justSayNoAble = Statephase.Turn_Started_Cards_Drawn_1_Cards_Played_Ask_Just_Say_No;//Action cards not playable at this phase
                //Any move that plays a card excluding justSayNo move next state
                Statephase notJustSayNoAble = Statephase.Turn_Started_Cards_Drawn_2_Cards_Played;//cards playable at this phase
                //Just Say No card played by off turn player
                Statephase JustSayNoUsedByOpposition = Statephase.Turn_Started_Cards_Drawn_1_Cards_Played_Just_Say_No_Used_By_Oppostion_Ask_Player_On_Turn_Just_Say_No;
                //Property card rearranging next state
                Statephase rearrangeProperties = Statephase.Turn_Started_Cards_Drawn_1_Cards_Played;//cards can be rearranged at this phase
                //Draw
                Statephase drawCardsAtTurnStart = Statephase.Turn_Started_Cards_Drawn_1_Cards_Played;//not allowable at this phase
                BoolResponseBox isMoveTypeAllowableAtCurrentPhase = checkIfMoveAllowedAtThisState(typeOfActionToPerform, playerPerformingAction, currentState);
                Statephase discard = Statephase.Turn_Started_Cards_Drawn_1_Cards_Played;
                if (isMoveTypeAllowableAtCurrentPhase.success)
                {
                    //type of move is allowable at this point for this player. Check if move is doable ex is a set stealable
                    result = doAppropriateAction(lastState, currentState, nextState, playerPerformingAction, typeOfActionToPerform, justSayNoAble, notJustSayNoAble, rearrangeProperties, drawCardsAtTurnStart, JustSayNoUsedByOpposition, cardsAndPlayersInvolved, discard);

                    return result;//True if action performed, False if not
                }
                else
                {
                    //No other actionTypes are allowable in this state
                    return new BoolResponseBox(false, "Player:" + playerPerformingAction.name + " is not able to perform " + typeOfActionToPerform + " at this state:" + currentState.currentPhase.ToString());
                }
            }

            #endregion 1 Card Played State

            #region 1 Card Played Just Say Noable Card Played

            else if (currentState.currentPhase.CompareTo(Statephase.Turn_Started_Cards_Drawn_1_Cards_Played_Ask_Just_Say_No) == 0)
            {
                Statephase discard = Statephase.Invalid_Action_For_Turn;

                //Player used Just Say No
                Statephase JustSayNoUsedByOpposition = Statephase.Turn_Started_Cards_Drawn_1_Cards_Played_Just_Say_No_Used_By_Oppostion_Ask_Player_On_Turn_Just_Say_No;
                /*
                //Player did not play just say no and is dealbreakered or sly dealed or forced dealed
                Statephase JustSayNoNotUsed = Statephase.Turn_Started_Cards_Drawn_1_Cards_Played;

                //Player has to pay rent or Birthday or Debt Collector
                Statephase PayDebt = Statephase.Turn_Started_Cards_Drawn_1_Cards_Play
                */
                //Action card that can be just say no carded next state
                Statephase justSayNoAble = Statephase.Turn_Started_Cards_Drawn_1_Cards_Played_Ask_Just_Say_No;//Action cards not playable at this phase
                //Any move that plays a card excluding justSayNo move next state
                Statephase notJustSayNoAble = Statephase.Turn_Started_Cards_Drawn_2_Cards_Played;//cards playable at this phase

                //Property card rearranging next state
                Statephase rearrangeProperties = Statephase.Invalid_Action_For_Turn;//cards can be rearranged at this phase
                //Draw
                Statephase drawCardsAtTurnStart = Statephase.Invalid_Action_For_Turn;//not allowable at this phase
                BoolResponseBox isMoveTypeAllowableAtCurrentPhase = checkIfMoveAllowedAtThisState(typeOfActionToPerform, playerPerformingAction, currentState);
                //In this state players may be required to pay rent, birthday or debt collector money or use a just say no
                if (isMoveTypeAllowableAtCurrentPhase.success)
                {
                    //type of move is allowable at this point for this player. Check if move is doable ex is a set stealable
                    result = doAppropriateAction(lastState, currentState, nextState, playerPerformingAction, typeOfActionToPerform, justSayNoAble, notJustSayNoAble, rearrangeProperties, drawCardsAtTurnStart, JustSayNoUsedByOpposition, cardsAndPlayersInvolved, discard);

                    return result;//True if action performed, False if not
                }
                else
                {
                    //No other actionTypes are allowable in this state
                    return new BoolResponseBox(false, "Player:" + playerPerformingAction.name + " is not able to perform " + typeOfActionToPerform + " at this state:" + currentState.currentPhase.ToString());
                }
            }

            #endregion 1 Card Played Just Say Noable Card Played

            #region 1 Card Played Just Say Noable Card Just Say No'd

            else if (currentState.currentPhase.CompareTo(Statephase.Turn_Started_Cards_Drawn_1_Cards_Played_Just_Say_No_Used_By_Oppostion_Ask_Player_On_Turn_Just_Say_No) == 0)
            {
                Statephase discard = Statephase.Invalid_Action_For_Turn;

                //Player used Just Say No
                Statephase JustSayNoUsedByOpposition = Statephase.Invalid_Action_For_Turn;
                /*
                //Player did not play just say no and is dealbreakered or sly dealed or forced dealed
                Statephase JustSayNoNotUsed = Statephase.Turn_Started_Cards_Drawn_1_Cards_Played;

                //Player has to pay rent or Birthday or Debt Collector
                Statephase PayDebt = Statephase.Turn_Started_Cards_Drawn_1_Cards_Play
                */
                //Action card that can be just say no carded next state
                Statephase justSayNoAble = Statephase.Turn_Started_Cards_Drawn_1_Cards_Played_Ask_Just_Say_No;//Action cards not playable at this phase
                //Any move that plays a card excluding justSayNo move next state
                Statephase notJustSayNoAble = Statephase.Turn_Started_Cards_Drawn_2_Cards_Played;//cards playable at this phase

                //Property card rearranging next state
                Statephase rearrangeProperties = Statephase.Invalid_Action_For_Turn;//cards can be rearranged at this phase
                //Draw
                Statephase drawCardsAtTurnStart = Statephase.Invalid_Action_For_Turn;//not allowable at this phase
                BoolResponseBox isMoveTypeAllowableAtCurrentPhase = checkIfMoveAllowedAtThisState(typeOfActionToPerform, playerPerformingAction, currentState);
                //In this state players may be required to pay rent, birthday or debt collector money or use a just say no
                if (isMoveTypeAllowableAtCurrentPhase.success)
                {
                    //type of move is allowable at this point for this player. Check if move is doable ex is a set stealable
                    result = doAppropriateAction(lastState, currentState, nextState, playerPerformingAction, typeOfActionToPerform, justSayNoAble, notJustSayNoAble, rearrangeProperties, drawCardsAtTurnStart, JustSayNoUsedByOpposition, cardsAndPlayersInvolved, discard);

                    return result;//True if action performed, False if not
                }
                else
                {
                    //No other actionTypes are allowable in this state
                    return new BoolResponseBox(false, "Player:" + playerPerformingAction.name + " is not able to perform " + typeOfActionToPerform + " at this state:" + currentState.currentPhase.ToString());
                }
            }

            #endregion 1 Card Played Just Say Noable Card Just Say No'd

            #region 2 Cards Played State

            else if (currentState.currentPhase.CompareTo(Statephase.Turn_Started_Cards_Drawn_2_Cards_Played) == 0)
            {
                //Action card that can be just say no carded next state
                Statephase justSayNoAble = Statephase.Turn_Started_Cards_Drawn_2_Cards_Played_Ask_Just_Say_No;//Action cards playable at this phase
                //Any move that plays a card excluding justSayNo move next state
                Statephase notJustSayNoAble = Statephase.Turn_Started_Cards_Drawn_3_Cards_Played_Swap_Properties_Or_End_Turn_Only;//cards playable at this phase
                //Just Say No card played by off turn player
                Statephase JustSayNoUsedByOpposition = Statephase.Turn_Started_Cards_Drawn_2_Cards_Played_Just_Say_No_Used_By_Oppostion_Ask_Player_On_Turn_Just_Say_No;
                //Property card rearranging next state
                Statephase rearrangeProperties = Statephase.Turn_Started_Cards_Drawn_2_Cards_Played;//cards can be rearranged at this phase
                //Draw
                Statephase drawCardsAtTurnStart = Statephase.Turn_Started_Cards_Drawn_2_Cards_Played;//not allowable at this phase
                BoolResponseBox isMoveTypeAllowableAtCurrentPhase = checkIfMoveAllowedAtThisState(typeOfActionToPerform, playerPerformingAction, currentState);

                Statephase discard = Statephase.Turn_Started_Cards_Drawn_2_Cards_Played;
                if (isMoveTypeAllowableAtCurrentPhase.success)
                {
                    //type of move is allowable at this point for this player. Check if move is doable ex is a set stealable
                    result = doAppropriateAction(lastState, currentState, nextState, playerPerformingAction, typeOfActionToPerform, justSayNoAble, notJustSayNoAble, rearrangeProperties, drawCardsAtTurnStart, JustSayNoUsedByOpposition, cardsAndPlayersInvolved, discard);

                    return result;//True if action performed, False if not
                }
                else
                {
                    //No other actionTypes are allowable in this state
                    return new BoolResponseBox(false, "Player:" + playerPerformingAction.name + " is not able to perform " + typeOfActionToPerform + " at this state:" + currentState.currentPhase.ToString());
                }
            }

            #endregion 2 Cards Played State

            #region 2 Cards Played State Just Say Noable Card Played

            else if (currentState.currentPhase.CompareTo(Statephase.Turn_Started_Cards_Drawn_2_Cards_Played_Ask_Just_Say_No) == 0)
            {
                Statephase discard = Statephase.Invalid_Action_For_Turn;

                //Player used Just Say No
                Statephase JustSayNoUsedByOpposition = Statephase.Turn_Started_Cards_Drawn_2_Cards_Played_Just_Say_No_Used_By_Oppostion_Ask_Player_On_Turn_Just_Say_No;
                /*
                //Player did not play just say no and is dealbreakered or sly dealed or forced dealed
                Statephase JustSayNoNotUsed = Statephase.Turn_Started_Cards_Drawn_1_Cards_Played;

                //Player has to pay rent or Birthday or Debt Collector
                Statephase PayDebt = Statephase.Turn_Started_Cards_Drawn_1_Cards_Play
                */
                //Action card that can be just say no carded next state
                Statephase justSayNoAble = Statephase.Turn_Started_Cards_Drawn_2_Cards_Played_Ask_Just_Say_No;//Action cards not playable at this phase
                //Any move that plays a card excluding justSayNo move next state
                Statephase notJustSayNoAble = Statephase.Turn_Started_Cards_Drawn_3_Cards_Played_Swap_Properties_Or_End_Turn_Only;//cards playable at this phase

                //Property card rearranging next state
                Statephase rearrangeProperties = Statephase.Invalid_Action_For_Turn;//cards can be rearranged at this phase
                //Draw
                Statephase drawCardsAtTurnStart = Statephase.Invalid_Action_For_Turn;//not allowable at this phase
                BoolResponseBox isMoveTypeAllowableAtCurrentPhase = checkIfMoveAllowedAtThisState(typeOfActionToPerform, playerPerformingAction, currentState);
                //In this state players may be required to pay rent, birthday or debt collector money or use a just say no
                if (isMoveTypeAllowableAtCurrentPhase.success)
                {
                    //type of move is allowable at this point for this player. Check if move is doable ex is a set stealable
                    result = doAppropriateAction(lastState, currentState, nextState, playerPerformingAction, typeOfActionToPerform, justSayNoAble, notJustSayNoAble, rearrangeProperties, drawCardsAtTurnStart, JustSayNoUsedByOpposition, cardsAndPlayersInvolved, discard);

                    return result;//True if action performed, False if not
                }
                else
                {
                    //No other actionTypes are allowable in this state
                    return new BoolResponseBox(false, "Player:" + playerPerformingAction.name + " is not able to perform " + typeOfActionToPerform + " at this state:" + currentState.currentPhase.ToString());
                }
            }

            #endregion 2 Cards Played State Just Say Noable Card Played

            #region 2 Cards Played State Just Say Noable Card just Say No'd

            else if (currentState.currentPhase.CompareTo(Statephase.Turn_Started_Cards_Drawn_2_Cards_Played_Just_Say_No_Used_By_Oppostion_Ask_Player_On_Turn_Just_Say_No) == 0)
            {
                Statephase discard = Statephase.Invalid_Action_For_Turn;

                //Player used Just Say No
                Statephase JustSayNoUsedByOpposition = Statephase.Invalid_Action_For_Turn;
                /*
                //Player did not play just say no and is dealbreakered or sly dealed or forced dealed
                Statephase JustSayNoNotUsed = Statephase.Turn_Started_Cards_Drawn_1_Cards_Played;

                //Player has to pay rent or Birthday or Debt Collector
                Statephase PayDebt = Statephase.Turn_Started_Cards_Drawn_1_Cards_Play
                */
                //Action card that can be just say no carded next state
                Statephase justSayNoAble = Statephase.Turn_Started_Cards_Drawn_2_Cards_Played_Ask_Just_Say_No;//Action cards not playable at this phase except just say no
                //Any move that plays a card excluding justSayNo move next state
                Statephase notJustSayNoAble = Statephase.Turn_Started_Cards_Drawn_3_Cards_Played_Swap_Properties_Or_End_Turn_Only;//cards playable at this phase

                //Property card rearranging next state
                Statephase rearrangeProperties = Statephase.Invalid_Action_For_Turn;//cards can be rearranged at this phase
                //Draw
                Statephase drawCardsAtTurnStart = Statephase.Invalid_Action_For_Turn;//not allowable at this phase
                BoolResponseBox isMoveTypeAllowableAtCurrentPhase = checkIfMoveAllowedAtThisState(typeOfActionToPerform, playerPerformingAction, currentState);
                //In this state players may be required to pay rent, birthday or debt collector money or use a just say no
                if (isMoveTypeAllowableAtCurrentPhase.success)
                {
                    //type of move is allowable at this point for this player. Check if move is doable ex is a set stealable
                    result = doAppropriateAction(lastState, currentState, nextState, playerPerformingAction, typeOfActionToPerform, justSayNoAble, notJustSayNoAble, rearrangeProperties, drawCardsAtTurnStart, JustSayNoUsedByOpposition, cardsAndPlayersInvolved, discard);

                    return result;//True if action performed, False if not
                }
                else
                {
                    //No other actionTypes are allowable in this state
                    return new BoolResponseBox(false, "Player:" + playerPerformingAction.name + " is not able to perform " + typeOfActionToPerform + " at this state:" + currentState.currentPhase.ToString());
                }
            }

            #endregion 2 Cards Played State Just Say Noable Card just Say No'd

            #region 3 Cards Played State

            else if (currentState.currentPhase.CompareTo(Statephase.Turn_Started_Cards_Drawn_3_Cards_Played_Swap_Properties_Or_End_Turn_Only) == 0)
            {
                //Action card that can be just say no carded next state
                Statephase justSayNoAble = Statephase.Invalid_Action_For_Turn;//Action cards not playable at this phase
                //Any move that plays a card excluding justSayNo move next state
                Statephase notJustSayNoAble = Statephase.Invalid_Action_For_Turn;//cards not playable at this phase
                //Just Say No card played by off turn player
                Statephase JustSayNoUsedByOpposition = Statephase.Invalid_Action_For_Turn;
                //Property card rearranging next state
                Statephase rearrangeProperties = Statephase.Turn_Started_Cards_Drawn_3_Cards_Played_Swap_Properties_Or_End_Turn_Only;//cards can be rearranged at this phase
                //Draw
                Statephase drawCardsAtTurnStart = Statephase.Invalid_Action_For_Turn;//not allowable at this phase

                Statephase discard = Statephase.Turn_Started_Cards_Drawn_3_Cards_Played_Swap_Properties_Or_End_Turn_Only;
                BoolResponseBox isMoveTypeAllowableAtCurrentPhase = checkIfMoveAllowedAtThisState(typeOfActionToPerform, playerPerformingAction, currentState);
                if (isMoveTypeAllowableAtCurrentPhase.success)
                {
                    //type of move is allowable at this point for this player. Check if move is doable ex is a set stealable
                    result = doAppropriateAction(lastState, currentState, nextState, playerPerformingAction, typeOfActionToPerform, justSayNoAble, notJustSayNoAble, rearrangeProperties, drawCardsAtTurnStart, JustSayNoUsedByOpposition, cardsAndPlayersInvolved, discard);

                    return result;//True if action performed, False if not
                }
                else
                {
                    //No other actionTypes are allowable in this state
                    return new BoolResponseBox(false, "Player:" + playerPerformingAction.name + " is not able to perform " + typeOfActionToPerform + " at this state:" + currentState.currentPhase.ToString());
                }
            }

            #endregion 3 Cards Played State

            #region Too many cards in hand at end of turn states

            else if (currentState.currentPhase.CompareTo(Statephase.Turn_Ended_12_Cards_In_Hand_Discard_5_Cards) == 0)
            {
                //Action card that can be just say no carded next state
                Statephase justSayNoAble = Statephase.Turn_Ended_12_Cards_In_Hand_Discard_5_Cards;
                //Any move that plays a card excluding justSayNo move next state
                Statephase notJustSayNoAble = Statephase.Turn_Ended_12_Cards_In_Hand_Discard_5_Cards;
                //Just Say No card played by off turn player
                Statephase JustSayNoUsedByOpposition = Statephase.Turn_Ended_12_Cards_In_Hand_Discard_5_Cards;
                //Property card rearranging next state
                Statephase rearrangeProperties = Statephase.Turn_Ended_12_Cards_In_Hand_Discard_5_Cards;
                //Draw
                Statephase drawCardsAtTurnStart = Statephase.Turn_Ended_12_Cards_In_Hand_Discard_5_Cards;//not allowable at this phase
                //Discard
                Statephase discard = Statephase.Turn_Ended_11_Cards_In_Hand_Discard_4_Cards;

                BoolResponseBox isMoveTypeAllowableAtCurrentPhase = checkIfMoveAllowedAtThisState(typeOfActionToPerform, playerPerformingAction, currentState);
                if (isMoveTypeAllowableAtCurrentPhase.success)
                {
                    //type of move is allowable at this point for this player. Check if move is doable ex is a set stealable
                    result = doAppropriateAction(lastState, currentState, nextState, playerPerformingAction, typeOfActionToPerform, justSayNoAble, notJustSayNoAble, rearrangeProperties, drawCardsAtTurnStart, JustSayNoUsedByOpposition, cardsAndPlayersInvolved, discard);

                    return result;//True if action performed, False if not
                }
                else
                {
                    //No other actionTypes are allowable in this state
                    return new BoolResponseBox(false, "Player:" + playerPerformingAction.name + " is not able to perform " + typeOfActionToPerform + " at this state:" + currentState.currentPhase.ToString());
                }
            }
            else if (currentState.currentPhase.CompareTo(Statephase.Turn_Ended_11_Cards_In_Hand_Discard_4_Cards) == 0)
            {
                //Action card that can be just say no carded next state
                Statephase justSayNoAble = Statephase.Turn_Ended_11_Cards_In_Hand_Discard_4_Cards;
                //Any move that plays a card excluding justSayNo move next state
                Statephase notJustSayNoAble = Statephase.Turn_Ended_11_Cards_In_Hand_Discard_4_Cards;
                //Just Say No card played by off turn player
                Statephase JustSayNoUsedByOpposition = Statephase.Turn_Ended_11_Cards_In_Hand_Discard_4_Cards;
                //Property card rearranging next state
                Statephase rearrangeProperties = Statephase.Turn_Ended_11_Cards_In_Hand_Discard_4_Cards;
                //Draw
                Statephase drawCardsAtTurnStart = Statephase.Turn_Ended_11_Cards_In_Hand_Discard_4_Cards;//not allowable at this phase
                //Discard
                Statephase discard = Statephase.Turn_Ended_10_Cards_In_Hand_Discard_3_Cards;

                BoolResponseBox isMoveTypeAllowableAtCurrentPhase = checkIfMoveAllowedAtThisState(typeOfActionToPerform, playerPerformingAction, currentState);
                if (isMoveTypeAllowableAtCurrentPhase.success)
                {
                    //type of move is allowable at this point for this player. Check if move is doable ex is a set stealable
                    result = doAppropriateAction(lastState, currentState, nextState, playerPerformingAction, typeOfActionToPerform, justSayNoAble, notJustSayNoAble, rearrangeProperties, drawCardsAtTurnStart, JustSayNoUsedByOpposition, cardsAndPlayersInvolved, discard);

                    return result;//True if action performed, False if not
                }
                else
                {
                    //No other actionTypes are allowable in this state
                    return new BoolResponseBox(false, "Player:" + playerPerformingAction.name + " is not able to perform " + typeOfActionToPerform + " at this state:" + currentState.currentPhase.ToString());
                }
            }
            else if (currentState.currentPhase.CompareTo(Statephase.Turn_Ended_10_Cards_In_Hand_Discard_3_Cards) == 0)
            {
                //Action card that can be just say no carded next state
                Statephase justSayNoAble = Statephase.Turn_Ended_10_Cards_In_Hand_Discard_3_Cards;
                //Any move that plays a card excluding justSayNo move next state
                Statephase notJustSayNoAble = Statephase.Turn_Ended_10_Cards_In_Hand_Discard_3_Cards;
                //Just Say No card played by off turn player
                Statephase JustSayNoUsedByOpposition = Statephase.Turn_Ended_10_Cards_In_Hand_Discard_3_Cards;
                //Property card rearranging next state
                Statephase rearrangeProperties = Statephase.Turn_Ended_10_Cards_In_Hand_Discard_3_Cards;
                //Draw
                Statephase drawCardsAtTurnStart = Statephase.Turn_Ended_10_Cards_In_Hand_Discard_3_Cards;//not allowable at this phase
                //Discard
                Statephase discard = Statephase.Turn_Ended_9_Cards_In_Hand_Discard_2_Cards;

                BoolResponseBox isMoveTypeAllowableAtCurrentPhase = checkIfMoveAllowedAtThisState(typeOfActionToPerform, playerPerformingAction, currentState);
                if (isMoveTypeAllowableAtCurrentPhase.success)
                {
                    //type of move is allowable at this point for this player. Check if move is doable ex is a set stealable
                    result = doAppropriateAction(lastState, currentState, nextState, playerPerformingAction, typeOfActionToPerform, justSayNoAble, notJustSayNoAble, rearrangeProperties, drawCardsAtTurnStart, JustSayNoUsedByOpposition, cardsAndPlayersInvolved, discard);

                    return result;//True if action performed, False if not
                }
                else
                {
                    //No other actionTypes are allowable in this state
                    return new BoolResponseBox(false, "Player:" + playerPerformingAction.name + " is not able to perform " + typeOfActionToPerform + " at this state:" + currentState.currentPhase.ToString());
                }
            }
            else if (currentState.currentPhase.CompareTo(Statephase.Turn_Ended_9_Cards_In_Hand_Discard_2_Cards) == 0)
            {
                //Action card that can be just say no carded next state
                Statephase justSayNoAble = Statephase.Turn_Ended_9_Cards_In_Hand_Discard_2_Cards;
                //Any move that plays a card excluding justSayNo move next state
                Statephase notJustSayNoAble = Statephase.Turn_Ended_9_Cards_In_Hand_Discard_2_Cards;
                //Just Say No card played by off turn player
                Statephase JustSayNoUsedByOpposition = Statephase.Turn_Ended_9_Cards_In_Hand_Discard_2_Cards;
                //Property card rearranging next state
                Statephase rearrangeProperties = Statephase.Turn_Ended_9_Cards_In_Hand_Discard_2_Cards;
                //Draw
                Statephase drawCardsAtTurnStart = Statephase.Turn_Ended_9_Cards_In_Hand_Discard_2_Cards;//not allowable at this phase
                //Discard
                Statephase discard = Statephase.Turn_Ended_8_Cards_In_Hand_Discard_1_Card;

                BoolResponseBox isMoveTypeAllowableAtCurrentPhase = checkIfMoveAllowedAtThisState(typeOfActionToPerform, playerPerformingAction, currentState);
                if (isMoveTypeAllowableAtCurrentPhase.success)
                {
                    //type of move is allowable at this point for this player. Check if move is doable ex is a set stealable
                    result = doAppropriateAction(lastState, currentState, nextState, playerPerformingAction, typeOfActionToPerform, justSayNoAble, notJustSayNoAble, rearrangeProperties, drawCardsAtTurnStart, JustSayNoUsedByOpposition, cardsAndPlayersInvolved, discard);

                    return result;//True if action performed, False if not
                }
                else
                {
                    //No other actionTypes are allowable in this state
                    return new BoolResponseBox(false, "Player:" + playerPerformingAction.name + " is not able to perform " + typeOfActionToPerform + " at this state:" + currentState.currentPhase.ToString());
                }
            }
            else if (currentState.currentPhase.CompareTo(Statephase.Turn_Ended_8_Cards_In_Hand_Discard_1_Card) == 0)
            {
                //Action card that can be just say no carded next state
                Statephase justSayNoAble = Statephase.Turn_Ended_9_Cards_In_Hand_Discard_2_Cards;
                //Any move that plays a card excluding justSayNo move next state
                Statephase notJustSayNoAble = Statephase.Turn_Ended_9_Cards_In_Hand_Discard_2_Cards;
                //Just Say No card played by off turn player
                Statephase JustSayNoUsedByOpposition = Statephase.Turn_Ended_9_Cards_In_Hand_Discard_2_Cards;
                //Property card rearranging next state
                Statephase rearrangeProperties = Statephase.Turn_Ended_9_Cards_In_Hand_Discard_2_Cards;
                //Draw
                Statephase drawCardsAtTurnStart = Statephase.Turn_Ended_9_Cards_In_Hand_Discard_2_Cards;//not allowable at this phase
                //Discard
                Statephase discard = Statephase.Turn_Ended_7_Or_Less_Cards_In_Hand_Setup_NextPlayer;

                BoolResponseBox isMoveTypeAllowableAtCurrentPhase = checkIfMoveAllowedAtThisState(typeOfActionToPerform, playerPerformingAction, currentState);
                if (isMoveTypeAllowableAtCurrentPhase.success)
                {
                    //type of move is allowable at this point for this player. Check if move is doable ex is a set stealable
                    result = doAppropriateAction(lastState, currentState, nextState, playerPerformingAction, typeOfActionToPerform, justSayNoAble, notJustSayNoAble, rearrangeProperties, drawCardsAtTurnStart, JustSayNoUsedByOpposition, cardsAndPlayersInvolved, discard);

                    return result;//True if action performed, False if not
                }
                else
                {
                    //No other actionTypes are allowable in this state
                    return new BoolResponseBox(false, "Player:" + playerPerformingAction.name + " is not able to perform " + typeOfActionToPerform + " at this state:" + currentState.currentPhase.ToString());
                }
            }

            #endregion Too many cards in hand at end of turn states

            else if (currentState.currentPhase.CompareTo(Statephase.Game_Over) == 0)
            {
                return new BoolResponseBox(false, "Game is over, move not possible");
            }
            else
            {
                return new BoolResponseBox(false, "Game is in an invalid state");
            }
        }
コード例 #45
0
ファイル: Move.cs プロジェクト: Nitzahon/Monopoly-Deal-WCF
 /// <summary>
 /// Sets the allowable actions for each player
 /// </summary>
 /// <param name="state"></param>
 /// <param name="allowedForPlayersNotOnTurn"></param>
 /// <param name="allowedForPlayerOnTurn"></param>
 /// <param name="playerOnTurnGuid"></param>
 /// <param name="playerWhoPerformedActionGuid"></param>
 private void updateAllowableStates(PlayFieldModel state, List<TurnActionTypes> allowedForPlayersNotOnTurn, List<TurnActionTypes> allowedForPlayerOnTurn, Guid playerOnTurnGuid, Guid playerWhoPerformedActionGuid)
 {
     foreach (PlayerModel p in state.playerModels)
     {
         if (p.guid.CompareTo(playerOnTurnGuid) == 0)
         //if (p.isThisPlayersTurn)
         {
             //its p's turn
             p.actionsCurrentlyAllowed = allowedForPlayerOnTurn;
         }
         else
         {
             p.actionsCurrentlyAllowed = allowedForPlayersNotOnTurn;
         }
     }
 }
コード例 #46
0
 public bool isActionAllowedForPlayer(TurnActionTypes turnActionToDo, Guid playerGuid, PlayFieldModel currentState)
 {
     throw new NotImplementedException();
 }
コード例 #47
0
ファイル: Move.cs プロジェクト: Nitzahon/Monopoly-Deal-WCF
 /// <summary>
 /// Adds a state to the list of states in the game and sets it as the current state.
 /// Can be modified to set the state to be the current state only once all players have recieved the current state.
 /// </summary>
 /// <param name="nextPlayfieldModel"></param>
 /// <returns></returns>
 public BoolResponseBox addNextState(PlayFieldModel nextPlayfieldModel)
 {
     //Add the next state to the list of states
     monopolyDeal.gameStates.Add(nextPlayfieldModel);
     //TODO If all players have adknowledged the current state then set the nextPlayfieldModel as the current state
     //For now set it straight away
     bool allAdknowleged = true;
     if (allAdknowleged)
     {
         monopolyDeal.currentState = nextPlayfieldModel;
         return new BoolResponseBox(true, "State added and set as current state");
     }
     else
     {
         return new BoolResponseBox(false, "Not all players have adknowledged recieving the current state, state added but not switched to");
     }
 }
コード例 #48
0
ファイル: Move.cs プロジェクト: Nitzahon/Monopoly-Deal-WCF
        private BoolResponseBox doNotPlayJustSayNo(PlayFieldModel currentState, PlayFieldModel nextState, PlayerModel playerPerformingAction, MoveInfo moveInformation, Statephase justSayNoAble, Statephase notJustSayNoAble)
        {
            //Check
            //Perform action in next state
            //Clone the current state to create next state then draws 5 cards in the next state
            nextState = currentState.clone(generateGuidForNextState());

            //Player Not using Just Say No
            PlayerModel playerModelForNotUsingJustSayNo = getPlayerModel(moveInformation.playerMakingMove, nextState);

            //Player no longer can Just Say no
            playerModelForNotUsingJustSayNo.hasHadCardsTaken = false;

            //Change state on success
            //has been performed, advance the phase of the game
            Statephase nextStatePhaseIfSuccessful;
            nextStatePhaseIfSuccessful = notJustSayNoAble;
            nextState.currentPhase = nextStatePhaseIfSuccessful;

            List<TurnActionTypes> notOnTurn = new List<TurnActionTypes>();
            List<TurnActionTypes> onTurn = new List<TurnActionTypes>();
            onTurn = setAllowableActionsOnTurn(onTurn, nextState);

            updateAllowableStates(nextState, notOnTurn, onTurn, nextState.guidOfPlayerWhosTurnItIs, nextState.guidOfPlayerWhosTurnItIs);

            //change the current state to the next state
            addNextState(nextState);
            return new BoolResponseBox(true, "Player:" + playerPerformingAction.name + " Has chosen to not use a Just Say No!");
        }
コード例 #49
0
ファイル: Move.cs プロジェクト: Nitzahon/Monopoly-Deal-WCF
        /// <summary>
        /// Moves a property card that has been played to a set to a new set
        /// </summary>
        /// <param name="currentState"></param>
        /// <param name="nextState"></param>
        /// <param name="playerPerformingAction"></param>
        /// <param name="moveInformation"></param>
        /// <param name="rearrangeProperties"></param>
        /// <returns></returns>
        private BoolResponseBox movePropertyCard(PlayFieldModel currentState, PlayFieldModel nextState, PlayerModel playerPerformingAction, MoveInfo moveInformation, Statephase rearrangeProperties)
        {
            //Clone the current state to create next state
            nextState = currentState.clone(generateGuidForNextState());

            PropertyColor oldColour = ((PropertyCard)currentState.deck.getCardByID(moveInformation.idOfCardBeingUsed)).getPropertyColor();
            bool oldOrientation = ((PropertyCard)currentState.deck.getCardByID(moveInformation.idOfCardBeingUsed)).isCardUp;
            ((PropertyCard)nextState.deck.getCardByID(moveInformation.idOfCardBeingUsed)).setPropertyColor(moveInformation.isPropertyToMoveOrientedUp);

            if (moveInformation.addPropertyToMoveToExistingSet == false || getPropertyCardSet(getPlayerModel(playerPerformingAction.guid, nextState).propertySets, moveInformation.guidOfExistingSetToMovePropertyTo).isPropertyCompatible((PropertyCard)nextState.deck.getCardByID(moveInformation.idOfCardBeingUsed)))
            {
                //Get CurrentPlayFieldModelState
                PropertyCard propertyCardToMove = nextState.deck.getCardByID(moveInformation.idOfCardBeingUsed) as PropertyCard;
                PlayerModel player = getPlayerModel(playerPerformingAction.guid, nextState);
                //Remove Property Card from it's current set.
                PropertyCard property = player.removePropertyCardFromPlayersPropertySet(propertyCardToMove, moveInformation.guidOfSetPropertyToMoveIsIn);
                if (property != null)
                {
                    PropertyCard cP = propertyCardToMove;
                    bool propertyAdded = false;
                    cP.setPropertyColor(moveInformation.isPropertyToPlayOrientedUp);
                    PropertyCardSet ps = getPropertyCardSet(player.propertySets, moveInformation.guidOfExistingSetToMovePropertyTo);
                    if (moveInformation.addPropertyToMoveToExistingSet == false)
                    {
                        player.propertySets.addSet(new PropertyCardSet(cP));
                    }
                    else if (ps == null)
                    {
                        //card was intended to be played to an existing set
                        return new BoolResponseBox(false, "Property not moved. Selected set does not exist");
                    }
                    else if (ps != null)
                    {
                        propertyAdded = ps.addProperty(cP);
                    }
                    if (propertyAdded == false)
                    {
                        return new BoolResponseBox(false, "Property Card not played. Set full or card incompatible.");
                    }
                    //Change state on success
                    //has been performed, advance the phase of the game
                    nextState.currentPhase = rearrangeProperties;
                    List<TurnActionTypes> notOnTurn = new List<TurnActionTypes>();
                    List<TurnActionTypes> onTurn = new List<TurnActionTypes>();
                    onTurn = setAllowableActionsOnTurn(onTurn, nextState);

                    updateAllowableStates(nextState, notOnTurn, onTurn, nextState.guidOfPlayerWhosTurnItIs, nextState.guidOfPlayerWhosTurnItIs);
                    //change the current state to the next state
                    addNextState(nextState);
                    return new BoolResponseBox(true, "Player:" + playerPerformingAction.name + " Has moved a Property to a existing set " + propertyCardToMove.cardName);
                }
                return new BoolResponseBox(false, "Card is not in set.");
            }
            else
            {
                nextState = null;
                ((PropertyCard)currentState.deck.getCardByID(moveInformation.idOfCardBeingUsed)).setPropertyColor(oldOrientation);//change back the orientation of the property
                return new BoolResponseBox(false, "Property Card is not the correct colour to be added to this set");
            }
        }
コード例 #50
0
 public PlayFieldModel copyPlayFieldModel(PlayFieldModel currentPlayFieldModel)
 {
     throw new NotImplementedException();
 }
コード例 #51
0
ファイル: Move.cs プロジェクト: Nitzahon/Monopoly-Deal-WCF
        /// <summary>
        /// Determines the type of action to perform and calls the correct method to perform it
        /// </summary>
        /// <param name="lastState">The state previous to the current state.</param>
        /// <param name="currentState">The current state.</param>
        /// <param name="nextState">A reference for the next state</param>
        /// <param name="playerPerformingAction">The Guid of the player who is performing the action.</param>
        /// <param name="typeOfActionToPerform">The type of action the player is performing.</param>
        /// <param name="justSayNoAble">The StatePhase the state should be if the action is performed and is able to be Just Say No'd</param>
        /// <param name="notJustSayNoAble">The StatePhase the state should be if the action is performed and is not able to be Just Say No'd</param>
        /// <param name="rearrangeProperties">The StatePhase the state should be if the action is performed is to move properties between sets</param>
        /// <param name="drawCardsAtTurnStart">The StatePhase the state should be if the action is performed is to draw cards at the start of a turn</param>
        /// <param name="JustSayNoUsedByOpposition">The StatePhase the state should be if the action is performed and is a player using a Just Say No card against an Action Card affecting them played by the player who is on their turn</param>
        /// <param name="moveInformation">The MoveInfo containing the information required to perform the action.</param>
        /// <param name="discard">The StatePhase the state should be if the action is performed is to end a turn and the player has to discard cards</param>
        /// <returns></returns>
        private BoolResponseBox doAppropriateAction(PlayFieldModel lastState, PlayFieldModel currentState, PlayFieldModel nextState, PlayerModel playerPerformingAction, TurnActionTypes typeOfActionToPerform, Statephase justSayNoAble, Statephase notJustSayNoAble, Statephase rearrangeProperties, Statephase drawCardsAtTurnStart, Statephase JustSayNoUsedByOpposition, MoveInfo moveInformation, Statephase discard)
        {
            if (typeOfActionToPerform.CompareTo(TurnActionTypes.drawTwoCardsAtStartOfTurn) == 0)
            {
                return draw2CardsAtStartOfTurn(currentState, nextState, playerPerformingAction, drawCardsAtTurnStart);
            }
            else if (typeOfActionToPerform.CompareTo(TurnActionTypes.drawFiveCardsAtStartOfTurn) == 0)
            {
                return draw5CardsAtStartOfTurn(currentState, nextState, playerPerformingAction, drawCardsAtTurnStart);
            }
            else if (typeOfActionToPerform.CompareTo(TurnActionTypes.EndTurn) == 0)
            {
                return endTurn(currentState, nextState, playerPerformingAction);
            }
            else if (typeOfActionToPerform.CompareTo(TurnActionTypes.MovePropertyCard) == 0)
            {
                return movePropertyCard(currentState, nextState, playerPerformingAction, moveInformation, rearrangeProperties);
            }
            else if (typeOfActionToPerform.CompareTo(TurnActionTypes.PlayPropertyCardFromHand) == 0)
            {
                return playPropertyCardFromHand(currentState, nextState, playerPerformingAction, moveInformation, notJustSayNoAble);
            }
            else if (typeOfActionToPerform.CompareTo(TurnActionTypes.PlayPropertyCard_New_Set) == 0)
            {
                return playPropertyCardFromHandToNewSet(currentState, nextState, playerPerformingAction, moveInformation, notJustSayNoAble);
            }
            else if (typeOfActionToPerform.CompareTo(TurnActionTypes.BankActionCard) == 0)
            {
                return playCardFromHandToBank(currentState, nextState, playerPerformingAction, moveInformation, notJustSayNoAble);
            }
            else if (typeOfActionToPerform.CompareTo(TurnActionTypes.BankMoneyCard) == 0)
            {
                return playCardFromHandToBank(currentState, nextState, playerPerformingAction, moveInformation, notJustSayNoAble);
            }
            else if (typeOfActionToPerform.CompareTo(TurnActionTypes.Discard_1_Card) == 0)
            {
                return discard1Card(currentState, nextState, playerPerformingAction, moveInformation, discard);
            }
            else if (typeOfActionToPerform.CompareTo(TurnActionTypes.PayDebt) == 0)
            {
                return payDebt(currentState, nextState, playerPerformingAction, moveInformation, justSayNoAble, notJustSayNoAble);
            }
            else if (typeOfActionToPerform.CompareTo(TurnActionTypes.Dont_Play_Just_Say_No) == 0)
            {
                return doNotPlayJustSayNo(currentState, nextState, playerPerformingAction, moveInformation, justSayNoAble, notJustSayNoAble);
            }

            //ActionCards
            else if (typeOfActionToPerform.CompareTo(TurnActionTypes.PlayActionCard) == 0 || typeOfActionToPerform.CompareTo(TurnActionTypes.PlayCard) == 0)
            {
                if (moveInformation.actionCardActionType.CompareTo(ActionCardAction.PassGo) == 0)
                {
                    Statephase nextStatePhase = notJustSayNoAble;
                    return playActionCardPassGo(currentState, nextState, playerPerformingAction, nextStatePhase, moveInformation);
                }
                else if (moveInformation.actionCardActionType.CompareTo(ActionCardAction.DebtCollector) == 0)
                {
                    Statephase nextStatePhase = justSayNoAble;
                    return playActionCardDebtCollector(currentState, nextState, playerPerformingAction, nextStatePhase, moveInformation);
                }
                else if (moveInformation.actionCardActionType.CompareTo(ActionCardAction.ItsMyBirthday) == 0)
                {
                    Statephase nextStatePhase = justSayNoAble;
                    return playActionCardItsMyBirthday(currentState, nextState, playerPerformingAction, nextStatePhase, moveInformation);
                }
                else if (moveInformation.actionCardActionType.CompareTo(ActionCardAction.JustSayNo) == 0)
                {
                    Statephase nextStatePhase = notJustSayNoAble;//TODO switch to justsaynoable
                    return playActionCardJustSayNo(currentState, nextState, playerPerformingAction, nextStatePhase, justSayNoAble, JustSayNoUsedByOpposition, moveInformation);
                }
                else if (moveInformation.actionCardActionType.CompareTo(ActionCardAction.RentMultiColor) == 0)
                {
                    Statephase nextStatePhase = justSayNoAble;
                    return playActionCardRentMultiColor(currentState, nextState, playerPerformingAction, nextStatePhase, moveInformation);
                }
                else if (moveInformation.actionCardActionType.CompareTo(ActionCardAction.RentStandard) == 0)
                {
                    Statephase nextStatePhase = justSayNoAble;
                    return playActionCardRentStandard(currentState, nextState, playerPerformingAction, nextStatePhase, moveInformation);
                }
                else if (moveInformation.actionCardActionType.CompareTo(ActionCardAction.SlyDeal) == 0)
                {
                    Statephase nextStatePhase = justSayNoAble;
                    return playActionCardSlyDeal(currentState, nextState, playerPerformingAction, nextStatePhase, moveInformation);
                }
                else if (moveInformation.actionCardActionType.CompareTo(ActionCardAction.ForcedDeal) == 0)
                {
                    Statephase nextStatePhase = justSayNoAble;
                    return playActionCardForcedDeal(currentState, nextState, playerPerformingAction, nextStatePhase, moveInformation);
                }
                else if (moveInformation.actionCardActionType.CompareTo(ActionCardAction.DealBreaker) == 0)
                {
                    Statephase nextStatePhase = justSayNoAble;
                    return playActionCardDealBreaker(currentState, nextState, playerPerformingAction, nextStatePhase, moveInformation);
                }
                else if (moveInformation.actionCardActionType.CompareTo(ActionCardAction.House) == 0)
                {
                    Statephase nextStatePhase = notJustSayNoAble;
                    return playActionCardHouse(currentState, nextState, playerPerformingAction, nextStatePhase, moveInformation);
                }
                else if (moveInformation.actionCardActionType.CompareTo(ActionCardAction.Hotel) == 0)
                {
                    Statephase nextStatePhase = notJustSayNoAble;
                    return playActionCardHotel(currentState, nextState, playerPerformingAction, nextStatePhase, moveInformation);
                }
                throw new NotImplementedException();
            }
            else if (typeOfActionToPerform.CompareTo(TurnActionTypes.PlayJustSayNo) == 0)
            {
                Statephase nextStatePhase = notJustSayNoAble;//should be just say noable
                return playActionCardJustSayNo(currentState, nextState, playerPerformingAction, nextStatePhase, justSayNoAble, JustSayNoUsedByOpposition, moveInformation);
            }
            else
            {
                return new BoolResponseBox(false, "Unsupported action:" + typeOfActionToPerform.ToString());
            }
        }
コード例 #52
0
ファイル: Move.cs プロジェクト: Nitzahon/Monopoly-Deal-WCF
 /// <summary>
 /// Sets the actions each player can take after a debt has been played by a player in the given state
 /// </summary>
 /// <param name="state">The state to update the allowable action for each player in.</param>
 /// <param name="allowedForPlayersWhoDontHaveToPay">A list of Actions a player who does not have to pay a debt can take.</param>
 /// <param name="allowedForPlayerOnTurn">A list of Actions the player whoes turn it is can take.</param>
 /// <param name="playerOnTurnGuid">The Guid of the player whoes turn it is.</param>
 /// <param name="allowedForPlayersWhoDoHaveToPay">The list of Actions allowed for players who are in debt.</param>
 private void updateAllowableStatesDebtPaid(PlayFieldModel state, List<TurnActionTypes> allowedForPlayersWhoDontHaveToPay, List<TurnActionTypes> allowedForPlayerOnTurn, Guid playerOnTurnGuid, List<TurnActionTypes> allowedForPlayersWhoDoHaveToPay)
 {
     foreach (PlayerModel p in state.playerModels)
     {
         if (p.guid.CompareTo(playerOnTurnGuid) == 0)
         {
             //its p's turn
             p.actionsCurrentlyAllowed = allowedForPlayerOnTurn;
         }
         else if (p.owesAnotherPlayer)
         {
             p.actionsCurrentlyAllowed = allowedForPlayersWhoDoHaveToPay;
         }
         else
         {
             p.actionsCurrentlyAllowed = allowedForPlayersWhoDontHaveToPay;
         }
     }
 }
コード例 #53
0
 public PlayerModel getPlayerByGuid(Guid player, PlayFieldModel pfm)
 {
     throw new NotImplementedException();
 }
コード例 #54
0
ファイル: Move.cs プロジェクト: Nitzahon/Monopoly-Deal-WCF
        private BoolResponseBox playActionCardHouse(PlayFieldModel currentState, PlayFieldModel nextState, PlayerModel playerPerformingAction, Statephase nextStatePhase, MoveInfo moveInformation)
        {
            //Check
            //Perform action in next state
            //Clone the current state to create next state then draws 5 cards in the next state
            nextState = currentState.clone(generateGuidForNextState());
            PlayerModel playerModelForPlayer = getPlayerModel(playerPerformingAction.guid, nextState);
            Card cardInHandToBePlayed = nextState.deck.getCardByID(moveInformation.idOfCardBeingUsed);
            //Get the reference to the players playerModel in the current PlayFieldModel

            //Get the reference to the Card in the current PlayFieldModel
            if (cardInHandToBePlayed != null && cardInHandToBePlayed is ActionCard && ((ActionCard)cardInHandToBePlayed).actionType.CompareTo(ActionCardAction.House) == 0)
            {
                Card card = removeCardFromHand(cardInHandToBePlayed, playerModelForPlayer);
                if (card != null)
                {
                    ActionCard actionCard = card as ActionCard;
                    PropertyCardSet ps = getPropertyCardSet(playerModelForPlayer.propertySets, moveInformation.guidFullSetToAddHouseTo);
                    if (ps != null)
                    {
                        if (ps.addHouse(actionCard))
                        {
                            //Change state on success
                            //has been performed, advance the phase of the game
                            nextState.currentPhase = nextStatePhase;
                            //Put card in discard pile
                            nextState.playpile.playCardOnPile(actionCard);
                            List<TurnActionTypes> notOnTurn = new List<TurnActionTypes>();
                            List<TurnActionTypes> onTurn = new List<TurnActionTypes>();
                            onTurn = setAllowableActionsOnTurn(onTurn, nextState);
                            updateAllowableStates(nextState, notOnTurn, onTurn, nextState.guidOfPlayerWhosTurnItIs, nextState.guidOfPlayerWhosTurnItIs);
                            //change the current state to the next state
                            addNextState(nextState);
                            return new BoolResponseBox(true, "Player:" + playerPerformingAction.name + " Has added a house to a set");
                        }
                        else
                        {
                            return new BoolResponseBox(false, "House can not be added to this set");
                        }
                    }
                    return new BoolResponseBox(false, "Set does not exist");
                }
                return new BoolResponseBox(false, "Card is not in hand.");
            }
            return new BoolResponseBox(false, "Card is not in hand or is not a House card");
        }
コード例 #55
0
ファイル: Move.cs プロジェクト: Nitzahon/Monopoly-Deal-WCF
        /// <summary>
        /// Plays a Property Card from a Players Hand on their turn to a new Property Set
        /// </summary>
        /// <param name="currentState"></param>
        /// <param name="nextState"></param>
        /// <param name="playerPerformingAction"></param>
        /// <param name="moveInformation"></param>
        /// <param name="notJustSayNoAble"></param>
        /// <returns></returns>
        private BoolResponseBox playPropertyCardFromHandToNewSet(PlayFieldModel currentState, PlayFieldModel nextState, PlayerModel playerPerformingAction, MoveInfo moveInformation, Statephase notJustSayNoAble)
        {
            //Clone the current state to create next state
            nextState = currentState.clone(generateGuidForNextState());
            //Get CurrentPlayFieldModelState
            Card cardInHandToBePlayed = nextState.deck.getCardByID(moveInformation.idOfCardBeingUsed);
            PlayerModel player = getPlayerModel(playerPerformingAction.guid, nextState);
            Card card = removeCardFromHand(cardInHandToBePlayed, player);
            if (card != null)
            {
                PropertyCard cP = cardInHandToBePlayed as PropertyCard;
                cP.setPropertyColor(moveInformation.isPropertyToPlayOrientedUp);
                PropertyCardSet ps = new PropertyCardSet(cP);

                player.propertySets.addSet(ps);
                //Change state on success
                //has been performed, advance the phase of the game
                nextState.currentPhase = notJustSayNoAble;
                List<TurnActionTypes> notOnTurn = new List<TurnActionTypes>();
                List<TurnActionTypes> onTurn = new List<TurnActionTypes>();
                onTurn = setAllowableActionsOnTurn(onTurn, nextState);

                updateAllowableStates(nextState, notOnTurn, onTurn, nextState.guidOfPlayerWhosTurnItIs, nextState.guidOfPlayerWhosTurnItIs);
                //change the current state to the next state
                addNextState(nextState);
                return new BoolResponseBox(true, "Player:" + playerPerformingAction.name + " Has played to a new set " + card.cardName);
            }
            return new BoolResponseBox(false, "Card is not in hand.");
        }
コード例 #56
0
ファイル: Move.cs プロジェクト: Nitzahon/Monopoly-Deal-WCF
 /// <summary>
 /// Determines if a move is valid for the current player and state
 /// </summary>
 /// <param name="turnActionToDo"></param>
 /// <param name="player"></param>
 /// <param name="currentState"></param>
 /// <returns></returns>
 private BoolResponseBox checkIfMoveAllowedAtThisState(TurnActionTypes turnActionToDo, PlayerModel player, PlayFieldModel currentState)
 {
     TurnActionTypes tAT = turnActionToDo;
     PlayerModel playerAttemptingAction = player;
     if (monopolyDeal.gameOver)
     {
         return new BoolResponseBox(false, "Can not perform action as game is over");
     }
     if (playerAttemptingAction != null)
     {
         foreach (TurnActionTypes t in playerAttemptingAction.actionsCurrentlyAllowed)
         {
             if (t.CompareTo(tAT) == 0)
             {
                 //Action is in allowable list for player
                 return new BoolResponseBox(true, player.name + " is allowed to :" + turnActionToDo.ToString() + " at current phase");
             }
         }
     }
     return new BoolResponseBox(false, player.name + " is not allowed to :" + turnActionToDo.ToString() + " at current phase"); ; //Action not allowable
 }
コード例 #57
0
ファイル: Move.cs プロジェクト: Nitzahon/Monopoly-Deal-WCF
        private BoolResponseBox playActionCardDealBreaker(PlayFieldModel currentState, PlayFieldModel nextState, PlayerModel playerPerformingAction, Statephase nextStatePhase, MoveInfo moveInformation)
        {
            //Check
            //Perform action in next state
            //Clone the current state to create next state then draws 5 cards in the next state
            nextState = currentState.clone(generateGuidForNextState());
            PlayerModel playerModelForPlayer = getPlayerModel(playerPerformingAction.guid, nextState);
            PlayerModel playerModelForPlayerToDealBreaker = getPlayerModel(moveInformation.guidOfPlayerWhoIsBeingDealBreakered, nextState);
            Card cardInHandToBePlayed = nextState.deck.getCardByID(moveInformation.idOfCardBeingUsed);
            //Get the reference to the players playerModel in the current PlayFieldModel

            //Get the reference to the Card in the current PlayFieldModel
            if (cardInHandToBePlayed != null && cardInHandToBePlayed is ActionCard && ((ActionCard)cardInHandToBePlayed).actionType.CompareTo(ActionCardAction.DealBreaker) == 0)
            {
                Card card = removeCardFromHand(cardInHandToBePlayed, playerModelForPlayer);
                if (card != null)
                {
                    ActionCard actionCard = card as ActionCard;
                    //Do action
                    PropertyCardSet setToDealBreaker = getPropertyCardSet(playerModelForPlayerToDealBreaker.propertySets, moveInformation.guidOfFullSetToBeDealBreakered);
                    if (setToDealBreaker != null && setToDealBreaker.isFullSet() == true)
                    {
                        if (playerModelForPlayerToDealBreaker.propertySets.playersPropertySets.Remove(setToDealBreaker) == true)
                        {
                            //Set taken from player
                            //give to player using dealbreaker card
                            playerModelForPlayer.propertySets.addSet(setToDealBreaker);

                            //Change state on success
                            //has been performed, advance the phase of the game
                            nextState.currentPhase = nextStatePhase;
                            //Used to set the allowable actions for player
                            playerModelForPlayerToDealBreaker.hasHadCardsTaken = true;
                            //Put card in discard pile
                            nextState.playpile.playCardOnPile(actionCard);
                            //Create event information for rollback and display
                            nextState.actionCardEvent = new ActionCardEvent();
                            nextState.actionCardEvent.playerAffectedByAction = moveInformation.guidOfPlayerWhoIsBeingDealBreakered;
                            nextState.actionCardEvent.playerWhoPerformedActionOffTurn = moveInformation.playerMakingMove;
                            nextState.actionCardEvent.playerOnTurnPerformingAction = true;
                            nextState.actionCardEvent.actionTypeTaken = TurnActionTypes.PlayActionCard;
                            nextState.actionCardEvent.propertySetTakenFromPlayer = setToDealBreaker.guid;
                            nextState.actionCardEvent.actionCardTypeUsed = ActionCardAction.DealBreaker;
                            List<CardIDSetGuid> listOfCardDealbreakered = new List<CardIDSetGuid>();
                            foreach (Card property in setToDealBreaker.properties)
                            {
                                listOfCardDealbreakered.Add(new CardIDSetGuid(property.cardID, setToDealBreaker.guid));
                            }
                            if (setToDealBreaker.hasHouse)
                            {
                                listOfCardDealbreakered.Add(new CardIDSetGuid(setToDealBreaker.house.cardID, setToDealBreaker.guid));
                            }
                            if (setToDealBreaker.hasHotel)
                            {
                                listOfCardDealbreakered.Add(new CardIDSetGuid(setToDealBreaker.hotel.cardID, setToDealBreaker.guid));
                            }
                            nextState.actionCardEvent.propertyCardsTakenFromPlayerAndSetTheCardWasIn = listOfCardDealbreakered;
                            //change the current state to the next state

                            List<TurnActionTypes> notOnTurn = new List<TurnActionTypes>();
                            List<TurnActionTypes> onTurn = new List<TurnActionTypes>();
                            onTurn = setAllowableActionsOnTurn(onTurn, nextState);

                            updateAllowableStatesPerPlayerCardsTaken(nextState, notOnTurn, onTurn, nextState.guidOfPlayerWhosTurnItIs, setAllowableActionsNotOnTurnCardsTaken(new List<TurnActionTypes>(), nextState));

                            addNextState(nextState);
                            return new BoolResponseBox(true, "Player:" + playerPerformingAction.name + " Has used a Deal Breaker Card");
                        }
                        else
                        {
                            return new BoolResponseBox(false, "Unable to take set from player");
                        }
                    }
                    else
                    {
                        return new BoolResponseBox(false, "Set to Deal Breaker is not a full set or does not exist");
                    }
                }

                return new BoolResponseBox(false, "Card is not in hand.");
            }
            return new BoolResponseBox(false, "Card id does not exist or is not a Deal Breaker Card");
        }
コード例 #58
0
ファイル: Move.cs プロジェクト: Nitzahon/Monopoly-Deal-WCF
        /// <summary>
        /// Plays a Property Card from a Players Hand on their turn to an existing Property Set
        /// </summary>
        /// <param name="currentState"></param>
        /// <param name="nextState"></param>
        /// <param name="playerPerformingAction"></param>
        /// <param name="moveInformation"></param>
        /// <param name="notJustSayNoAble"></param>
        /// <returns></returns>
        private BoolResponseBox playPropertyCardFromHand(PlayFieldModel currentState, PlayFieldModel nextState, PlayerModel playerPerformingAction, MoveInfo moveInformation, Statephase notJustSayNoAble)
        {
            if (moveInformation.guidOfExistingSetToPlayPropertyTo.CompareTo(new Guid()) != 0)
            {
                //Clone the current state to create next state
                nextState = currentState.clone(generateGuidForNextState());
                PropertyColor oldColour = ((PropertyCard)currentState.deck.getCardByID(moveInformation.idOfCardBeingUsed)).getPropertyColor();
                bool oldOrientation = ((PropertyCard)currentState.deck.getCardByID(moveInformation.idOfCardBeingUsed)).isCardUp;
                ((PropertyCard)nextState.deck.getCardByID(moveInformation.idOfCardBeingUsed)).setPropertyColor(moveInformation.isPropertyToPlayOrientedUp);

                /*
                if ((getPropertyCardSet(getPlayerModel(playerPerformingAction.guid, nextState).propertySets, moveInformation.guidOfExistingSetToPlayPropertyTo)).propertySetColor.CompareTo(
                    ((PropertyCard)nextState.deck.getCardByID(moveInformation.idOfCardBeingUsed)).currentPropertyColor) == 0)
                {
                 */
                if (getPropertyCardSet(getPlayerModel(playerPerformingAction.guid, nextState).propertySets, moveInformation.guidOfExistingSetToPlayPropertyTo).isPropertyCompatible((PropertyCard)nextState.deck.getCardByID(moveInformation.idOfCardBeingUsed)))
                {
                    //Get CurrentPlayFieldModelState
                    Card cardInHandToBePlayed = nextState.deck.getCardByID(moveInformation.idOfCardBeingUsed);
                    PlayerModel player = getPlayerModel(playerPerformingAction.guid, nextState);
                    Card card = removeCardFromHand(cardInHandToBePlayed, player);
                    if (card != null)
                    {
                        PropertyCard cP = cardInHandToBePlayed as PropertyCard;
                        cP.setPropertyColor(moveInformation.isPropertyToPlayOrientedUp);
                        PropertyCardSet ps = getPropertyCardSet(player.propertySets, moveInformation.guidOfExistingSetToPlayPropertyTo);
                        if (ps.addProperty(cP) == false)
                        {
                            return new BoolResponseBox(false, "Property Card not played. Set full or card incompatible.");
                        }
                        else
                        {
                            //Change state on success
                            //has been performed, advance the phase of the game
                            nextState.currentPhase = notJustSayNoAble;
                            List<TurnActionTypes> notOnTurn = new List<TurnActionTypes>();
                            List<TurnActionTypes> onTurn = new List<TurnActionTypes>();
                            onTurn = setAllowableActionsOnTurn(onTurn, nextState);

                            updateAllowableStates(nextState, notOnTurn, onTurn, nextState.guidOfPlayerWhosTurnItIs, nextState.guidOfPlayerWhosTurnItIs);
                            //change the current state to the next state
                            addNextState(nextState);
                            return new BoolResponseBox(true, "Player:" + playerPerformingAction.name + " Has played to a existing set " + card.cardName);
                        }
                    }
                    return new BoolResponseBox(false, "Card is not in hand.");
                }
                else
                {
                    nextState = null;
                    ((PropertyCard)currentState.deck.getCardByID(moveInformation.idOfCardBeingUsed)).setPropertyColor(oldOrientation);//change back the orientation of the property
                    return new BoolResponseBox(false, "Property Card is not the correct colour to be added to this set");
                }
            }
            else
            {
                return playPropertyCardFromHandToNewSet(currentState, nextState, playerPerformingAction, moveInformation, notJustSayNoAble);
            }
        }
コード例 #59
0
ファイル: Move.cs プロジェクト: Nitzahon/Monopoly-Deal-WCF
 /// <summary>
 /// Returns a list of the actions a player not on their turn can take when they are affected by an ActionCard
 /// </summary>
 /// <param name="listToSet"></param>
 /// <param name="newState"></param>
 /// <returns></returns>
 private List<TurnActionTypes> setAllowableActionsNotOnTurnAffectedByActionCard(List<TurnActionTypes> listToSet, PlayFieldModel newState)
 {
     if (newState.currentPhase.CompareTo(Statephase.Turn_Started_Cards_Drawn_0_Cards_Played_Ask_Just_Say_No) == 0 || newState.currentPhase.CompareTo(Statephase.Turn_Started_Cards_Drawn_1_Cards_Played_Ask_Just_Say_No) == 0 || newState.currentPhase.CompareTo(Statephase.Turn_Started_Cards_Drawn_2_Cards_Played_Ask_Just_Say_No) == 0)
     {
         listToSet.Add(TurnActionTypes.PlayJustSayNo);
         return listToSet;
     }
     else
     {
         throw new NotImplementedException();
     }
 }
コード例 #60
0
 public DrawOnTurnStart(TurnActionModel ta, PlayFieldModel pfm)
     : base(ta)
 {
 }