Exemple #1
0
        /// <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());
            }
        }
Exemple #2
0
 /// <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
 }