Пример #1
0
        protected internal void OnBankrupt()
        {
            IsPlayering = false;
            NextAction.Clear();

            // Transfer cash back to BANK (when manually raised)
            if (Cash > 0)
            {
                TransferMoney(GameBoard.BANK, System.Convert.ToUInt32(Cash));
            }

            // Give all Fields back to BANK
            foreach (var f in OwnFields.Values)
            {
                f.ChangeOwner(GameBoard.BANK);
            }

            Bankrupt?.Invoke(this);

            GameBoard.CheckGameOver();
        }
Пример #2
0
        internal void OnMove()
        {
            var diceRoll = onRollDice();

            if (diceRoll.IsDoubles)
            {
                DoublesCount += 1;
            }

            // Doubles Limit?
            if (DoublesCount >= GameBoard.Settings.MAX_DOUBLES)
            {
                NextAction.Clear();
                NextAction.Enqueue(eActionType.JumpToJail);
                RaiseDoublesLimit();
            }
            else
            {
                // Move over every field in path, an move on the last

                // TODO: Should call MoveTo with overload
                for (var i = 1; i < diceRoll.DiceSum; i++)
                {
                    Position = (ushort)((Position + 1) % (GameBoard.FieldCount));
                    GameBoard.GetField(Position).onMoveOver(this);
                }
                Position = (ushort)((Position + 1) % GameBoard.FieldCount);
                PositionField.onMoveOn(this);

                if (IsPlayering && (diceRoll.IsDoubles) && this.Position != GameBoard.JailField.Index)
                {
                    // Doubles Limit no reached, so add another move
                    NextAction.Enqueue(eActionType.Move);
                    // TODO: AddMove needs own event
                    RaiseChance(eActionType.AddMove, new object[] { diceRoll });
                }
            }
        }
Пример #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="e"></param>
        /// <returns>BUGGY: true if redo last action</returns>
        protected bool invokeAction(DelegateEventArgs e)
        {
            GameBoard.Statistics.ActionChoosen[e.ChoosenAction] = System.Convert.ToInt32(GameBoard.Statistics.ActionChoosen[e.ChoosenAction]) + 1;

            switch (e.ChoosenAction)
            {
            case eActionType.Move:
            {
                OnMove();
                break;
            }

            case eActionType.BuyHouse:
            {
                ((HouseField)e.Fields[0]).Buy(this);
                break;
            }

            case eActionType.PayRent:
            {
                ((HouseField)e.Fields[0]).PayRent(this);
                break;
            }

            case eActionType.GiveUp:
            {
                OnBankrupt();
                break;
            }

            case eActionType.UpgradeHouse:
            {
                ((HouseField)e.Fields[0]).Upgrade();
                break;
            }

            case eActionType.LoseTurn:
            {
                RaiseJail(eActionType.LoseTurn);
                break;
            }

            case eActionType.GoToField:
            {
                MoveTo(e.Fields[0], false);
                break;
            }

            case eActionType.JumpToField:
            case eActionType.JumpToRelativField:
            {
                MoveTo(e.Fields[0], true);
                break;
            }

            case eActionType.JumpToJail:
            {
                GameBoard.JailField.GoToJail(this);
                RaiseJail(eActionType.JumpToJail);
                break;
            }

            case eActionType.PayToStack:
            {
                TransferMoney(GameBoard.Wundertuete, e.Cash);
                break;
            }

            case eActionType.CollectStack:
            {
                GameBoard.Wundertuete.TransferMoney(this, e.Cash);
                break;
            }

            case eActionType.CashToBank:
            {
                TransferMoney(GameBoard.BANK, e.Cash);
                break;
            }

            case eActionType.CashFromBank:
            {
                GameBoard.BANK.TransferMoney(this, e.Cash);
                break;
            }

            case eActionType.CashToPlayer:
            {
                TransferMoney(e.Players[0], e.Cash);
                break;
            }

            case eActionType.CashFromPlayer:
            {
                e.Players[0].TransferMoney(this, e.Cash);
                break;
            }

            case eActionType.CashFromAll:
            {
                foreach (var p in GameBoard.PlayerRank)
                {
                    if (p.IsPlayering)
                    {
                        p.TransferMoney(this, e.Cash);
                    }
                }

                break;
            }

            case eActionType.PayPerHouse:
            {
                foreach (var house in OwnFields)
                {
                    TransferMoney(GameBoard.BANK, e.Cash);
                }
                break;
            }

            case eActionType.AddMove:
            {
                //BUGGY!
                NextAction.Clear();
                NextAction.Enqueue(eActionType.Move);
                break;
            }

            case eActionType.Card_UseFreeParking:
            {
                RaiseChance(eActionType.Card_UseFreeParking, new object[] { e.Fields[0] });
                if (!CheatAlwaysRentFree)
                {
                    GameBoard.FreeParkingOwner = GameBoard.BANK;
                }
                break;
            }

            case eActionType.Card_GetFreeParking:
            {
                GameBoard.FreeParkingOwner = this;
                break;
            }

            case eActionType.Card_UseFreeJail:
            {
                RaiseChance(eActionType.Card_UseFreeJail, new object[] { GameBoard.JailField });
                if (!CheatAlwaysJailFree)
                {
                    GameBoard.FreeParkingOwner = GameBoard.BANK;
                }
                break;
            }

            case eActionType.Card_GetFreeJail:
            {
                GameBoard.FreeJailOwner = this;
                break;
            }

            case eActionType.Pass:
            case eActionType.None:
            {
                break;
            }

            case eActionType.CreditForHouse:
            {
                var h = (HouseField)e.Fields[0];
                if (h.Owner.Equals(this))
                {
                    h.TakeForCredit();
                }

                // Redo Last Action!
                return(true);
            }

            case eActionType.CreditReleaseHouse:
            {
                var h = (HouseField)e.Fields[0];
                if (h.Owner.Equals(this))
                {
                    h.RemoveCredit();
                }

                // Redo Last Action!
                return(true);
            }

            case eActionType.IncreaseFixedDeposite:
            {
                RaiseIncreaseFixedDeposite(e.Cash);
                return(true);
            }

            case eActionType.TerminateFixedDeposite:
            {
                RaiseTerminateFixedDeposite();
                return(true);
            }

            default:
            {
                throw new System.NotImplementedException(e.ChoosenAction.ToString());
            }
            }
            return(false);
        }