示例#1
0
        /// <summary>
        ///
        ///     the controller will fill out the RollModel which has the complete set of state impacted by this roll.
        ///
        ///     1. push the roll
        ///     2. Update roll stats
        ///     3. Update resource counts
        ///     4. do Baron tracking
        ///     5. set state to WaitingForNext (always comes after Roll)
        /// </summary>
        /// <returns></returns>
        public static RolledModel Do(MainPage page, int roll)
        {
            var         currentPlayer = page.CurrentPlayer;
            RolledModel rolledModel   = new RolledModel()
            {
                Page        = page,
                Rolled      = roll,
                Player      = currentPlayer,
                PlayerIndex = currentPlayer.AllPlayerIndex,
                PlayerName  = currentPlayer.PlayerName,
                OldState    = page.NewGameState,
                Action      = (roll == 7) ? CatanAction.RolledSeven : CatanAction.Rolled
            };

            page.Rolls.Push(rolledModel.Rolled); // all the rolls...
            page.LastRoll = rolledModel.Rolled;
            page.UpdateGlobalRollStats();        // just math


            rolledModel.PlayerToResources = RolledController.GetResourceModelForRoll(page, rolledModel.Rolled);

            if (rolledModel.Rolled != 7)
            {
                currentPlayer.GameData.MovedBaronAfterRollingSeven = null;
                rolledModel.NewState = GameState.WaitingForNext;
            }
            else
            {
                currentPlayer.GameData.MovedBaronAfterRollingSeven = false;
                rolledModel.NewState = GameState.MustMoveBaron;
            }


            return(rolledModel);
        }
示例#2
0
        internal static void Redo(MainPage page, RolledModel model)
        {
            var newModel = RolledController.Do(page, model.Rolled);

            if (newModel.Equals(model) == false)
            {
                throw new Exception("new and old Roll models must match on Redo!");
            }
        }
示例#3
0
文件: newLog.cs 项目: joelong01/Catan
        public async Task Redo()
        {
            var logEntry = UndoStack.Last();

            UndoStack.RemoveAt(UndoStack.Count - 1);
            //
            //  now get the controller for this particular Action
            switch (logEntry.Action)
            {
            case CatanAction.Rolled:
                RolledController.Redo(Page, (RolledModel)logEntry);
                break;

            case CatanAction.ChangedState:
                break;

            case CatanAction.ChangedPlayer:
                await ChangedPlayerController.Redo(Page, logEntry as ChangedPlayerModel);

                break;

            case CatanAction.Dealt:
                break;

            case CatanAction.CardsLost:
                break;

            case CatanAction.CardsLostToSeven:
                break;

            case CatanAction.MissedOpportunity:
                break;

            case CatanAction.DoneSupplemental:
                break;

            case CatanAction.DoneResourceAllocation:
                break;

            case CatanAction.PlayedKnight:
                break;

            case CatanAction.RolledSeven:
                break;

            case CatanAction.AssignedBaron:
                break;

            case CatanAction.UpdatedRoadState:
                break;

            case CatanAction.UpdateBuildingState:
                break;

            case CatanAction.AssignedPirateShip:
                break;

            case CatanAction.AddPlayer:
                break;

            case CatanAction.RandomizeTiles:
                break;

            case CatanAction.AssignHarbors:
                break;

            case CatanAction.SelectGame:
                break;

            case CatanAction.AssignRandomTiles:
                break;

            case CatanAction.InitialAssignBaron:
                break;

            case CatanAction.None:
                break;

            case CatanAction.SetFirstPlayer:
                break;

            case CatanAction.RoadTrackingChanged:
                break;

            case CatanAction.AddResourceCount:
                break;

            case CatanAction.ChangedPlayerProperty:
                break;

            case CatanAction.SetRandomTileToGold:
                break;

            case CatanAction.ChangePlayerAndSetState:
                break;

            default:
                break;
            }
        }