예제 #1
0
        // Remember that actions that were not made from a certain game state cannot be used in any way with it.
        public override void TakeTurn(TurnInfo turnInfo, CardGameState gameState, CardGameManager manager)
        {
            if (turnInfo.IsMulligan)
            {
                // Pass in the mulligan for now
                manager.Continue();
            }
            else
            {
                bool shouldContinue = false;
                bool hasTakenAction = false;
                List <Actions.ActionOrder> availableActions = GetAvailableActions(turnInfo, gameState);

                while (!shouldContinue && availableActions.Count > 0)
                {
                    ActionsAndGameStateSet actionSet;
                    Utility.Serialiser.CreateActionsAndGameStateSet(gameState, availableActions, out actionSet);
                    float continueScore   = EvaluateMatchWinChance(getIndex(), gameState, manager.GetRoundVictoryLimit(), !hasTakenAction);
                    float maxScore        = 0;
                    int   bestActionIndex = -1;
                    for (int actionIndex = 0; actionIndex < actionSet.mAvailableActions.Count; actionIndex++)
                    {
                        float actionScore = EvaluateAction(getIndex(), actionSet.mAvailableActions[actionIndex],
                                                           actionSet.mCardGameStates[actionIndex], manager.GetRoundVictoryLimit());

                        if (actionScore > maxScore)
                        {
                            maxScore        = actionScore;
                            bestActionIndex = actionIndex;
                        }
                    }
                    if (maxScore > continueScore)
                    {
                        UnityEngine.Debug.Assert(bestActionIndex > -1);
                        // Update real game state with action.
                        manager.PassAction(availableActions[bestActionIndex]);
                        availableActions = GetAvailableActions(turnInfo, gameState);
                        hasTakenAction   = HasSpentCP() || WasCardPlaced();
                    }
                    else
                    {
                        shouldContinue = true;
                    }
                }

                // Continue at the end of the turn
                manager.Continue();
            }
        }
예제 #2
0
 public TurnManager(CardGameState GS, CardGameManager GM)
 {
     TurnInformation    = GS.mTurnInfo;
     TheCardGameState   = GS;
     TheCardGameManager = GM;
 }
예제 #3
0
 public virtual void TakeTurn(TurnInfo turnInfo, CardGameState gameState, CardGameManager manager)
 {
 }