Exemplo n.º 1
0
 public override Task SubmitAsync()
 {
     if (_model.HandList !.AutoSelect == HandObservable <LifeBaseCard> .EnumAutoType.SelectAsMany)
     {
         AdditionalCareerInstructions();
         return(Task.CompletedTask);
     }
     if (_gameContainer.GameStatus == EnumWhatStatus.NeedNewCareer || _gameContainer.GameStatus == EnumWhatStatus.NeedChooseFirstCareer)
     {
         return(_processes.ChoseCareerAsync(_model.HandList.ObjectSelected()));
     }
     throw new BasicBlankException("Unable to submit based on the status of the game.  Rethink");
 }
        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");
            }
        }