Exemple #1
0
        private async Task ResumeSpinnerCompletedAsync()
        {
            _gameContainer.SaveRoot !.SpinList.Add(_gameBoard.NumberRolled);
            EarnProcessFromRoll(_gameBoard.NumberRolled);
            if (_gameContainer.Test !.NoAnimations == false)
            {
                await _gameContainer.Delay !.DelaySeconds(1);
            }
            if (_gameContainer.GameStatus == EnumWhatStatus.NeedToSpin)
            {
                _gameContainer.GameStatus = EnumWhatStatus.LastSpin;
            }
            if (_gameBoard.NumberRolled == 0)
            {
                BetweenNumbers();
                if (_gameContainer.SingleInfo !.PlayerCategory == EnumPlayerCategory.Self)
                {
                    await UIPlatform.ShowMessageAsync("Spin again because it landed between two numbers");
                }
                if (_gameContainer.GameStatus == EnumWhatStatus.LastSpin)
                {
                    _gameContainer.GameStatus = EnumWhatStatus.NeedToSpin;
                }
                await _gameContainer.ContinueTurnAsync !.Invoke();
                return;
            }
            await FinishSpinProcessAsync();

            if (_gameContainer.CanTradeForBig(false))
            {
                await UIPlatform.ShowMessageAsync("Current Player Is Getting The $100,000 for 2 8s, 9s or 10s spinned in a row for a lucky break for being entertainer");

                await _gameContainer.TradeForBigAsync();

                return;
            }
            IMoveProcesses move = _gameContainer.Resolver.Resolve <IMoveProcesses>();
            await move.PossibleAutomateMoveAsync();
        }
        protected override async Task ComputerTurnAsync()
        {
            if (Test !.NoAnimations == false)
            {
                await Delay !.DelayMilli(500);
            }
            if (PlayerList.DidChooseColors() == false)
            {
                await base.ComputerTurnAsync(); //because this handles the choosing of colors.

                return;
            }
            if (SaveRoot.GameStatus == EnumWhatStatus.NeedChooseGender)
            {
                //choose gender computer choose.
                if (_gameContainer.ComputerChooseGenderAsync == null)
                {
                    //throw new BasicBlankException("No processes handling computer choosing gender");
                    return; //hopefully goes back again (?)
                }
                await _gameContainer.ComputerChooseGenderAsync.Invoke();

                return;
            }
            if (Test !.NoAnimations == false)
            {
                await Delay !.DelayMilli(500);
            }
            switch (SaveRoot.GameStatus)
            {
            case EnumWhatStatus.NeedChooseFirstOption:
                await _boardProcesses.OpeningOptionAsync(EnumStart.Career);     //the computer will always choose career.

                break;

            case EnumWhatStatus.NeedChooseFirstCareer:
            case EnumWhatStatus.NeedNewCareer:
                await _careerProcesses.ChoseCareerAsync(_model.GetRandomCard);

                break;

            case EnumWhatStatus.NeedChooseStock:
                await _chooseStockProcesses.ChoseStockAsync(_model.GetRandomCard);

                break;

            case EnumWhatStatus.NeedChooseSalary:
                await _basicSalaryProcesses.ChoseSalaryAsync(_model.GetRandomCard);

                break;

            case EnumWhatStatus.NeedToSpin:
                if (SingleInfo !.CarIsInsured == false)
                {
                    await _boardProcesses.PurchaseCarInsuranceAsync();

                    return;
                }
                if (SingleInfo.FirstStock == 0 && SingleInfo.SecondStock == 0)
                {
                    await _boardProcesses.PurchaseStockAsync();

                    return;
                }
                if (SingleInfo.Salary < 80000 && _gameContainer.CanTradeForBig(true))
                {
                    await _boardProcesses.Trade4TilesAsync();

                    return;
                }
                await _spinnerProcesses.StartSpinningAsync();     //hopefully this simple.

                break;

            case EnumWhatStatus.NeedReturnStock:
                if (_model.HandList.HandList.Count != 2)
                {
                    throw new BasicBlankException("Must have 2 choices to return.  Otherwise; should have returned automatically");
                }
                await _returnStockProcesses.StockReturnedAsync(_model.GetRandomCard);

                break;

            case EnumWhatStatus.NeedToChooseSpace:
                int firstNumber  = _gameBoard.FirstPossiblePosition;
                int secondNumber = _gameBoard.SecondPossiblePosition;
                if (firstNumber == 0)
                {
                    throw new BasicBlankException("The first possible position cannot be 0. Check this out");
                }
                if (secondNumber == 0)
                {
                    throw new BasicBlankException("The second possible position cannot be 0.  Otherwise, should have made move automatically");
                }
                CustomBasicList <int> posList = new CustomBasicList <int> {
                    firstNumber, secondNumber
                };
                int numberChosen;
                if (Test.DoubleCheck)
                {
                    numberChosen = secondNumber;     //the problem only happens with second.
                }
                else
                {
                    numberChosen = posList.GetRandomItem();
                }
                await MakeMoveAsync(numberChosen);

                //await _boardProcesses.ComputerChoseSpaceAsync(posList.GetRandomItem());
                break;

            case EnumWhatStatus.NeedNight:
            case EnumWhatStatus.NeedToEndTurn:
                if (BasicData.MultiPlayer)
                {
                    await Network !.SendEndTurnAsync();
                }
                await EndTurnAsync();

                break;

            case EnumWhatStatus.NeedStealTile:
                await _stolenTileProcesses.ComputerStealTileAsync();

                break;

            case EnumWhatStatus.NeedChooseRetirement:
                await _boardProcesses.RetirementAsync(EnumFinal.MillionaireEstates);     //always choose millionaire for computer;

                break;

            case EnumWhatStatus.NeedChooseHouse:
            case EnumWhatStatus.NeedSellBuyHouse:
                await _spinnerProcesses.StartSpinningAsync();     //computer will never choose to sell or buy house.

                break;

            case EnumWhatStatus.NeedTradeSalary:
                await _tradeSalaryProcesses.ComputerTradeAsync();

                break;

            default:
                throw new BasicBlankException("Rethink for computer turn");
            }
        }