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"); } }
protected override async Task ClickProcessAsync(SKPoint thisPoint) { if (_gameContainer.Command.IsExecuting) { return; } if (_gameContainer.GameStatus == EnumWhatStatus.NeedChooseFirstOption) { var firstOption = GetCareerRectangle(); var secondOption = GetCollegeRectangle(); if (MiscHelpers.DidClickRectangle(firstOption, thisPoint)) { _gameContainer.Command.StartExecuting(); await _options.OpeningOptionAsync(EnumStart.Career); return; } if (MiscHelpers.DidClickRectangle(secondOption, thisPoint)) { _gameContainer.Command.StartExecuting(); await _options.OpeningOptionAsync(EnumStart.College); return; } return; } if (_gameContainer.GameStatus == EnumWhatStatus.NeedChooseRetirement) { var country = GetCountrySideRect(); var million = GetMillionRect(); if (MiscHelpers.DidClickRectangle(country, thisPoint)) { _gameContainer.Command.StartExecuting(); await _options.RetirementAsync(EnumFinal.CountrySideAcres); return; } if (MiscHelpers.DidClickRectangle(million, thisPoint)) { _gameContainer.Command.StartExecuting(); await _options.RetirementAsync(EnumFinal.MillionaireEstates); return; } return; } if (_gameContainer.GameStatus == EnumWhatStatus.NeedToChooseSpace) { int firstOption = _spacePos.FirstPossiblePosition; int secondOption = _spacePos.SecondPossiblePosition; if (firstOption == 0 || secondOption == 0) { throw new BasicBlankException("Must truly have 2 options. Otherwise, can't do it."); } var firstRect = GetSpaceRect(firstOption); var secondRect = GetSpaceRect(secondOption); if (MiscHelpers.DidClickRectangle(firstRect, thisPoint)) { _options.SpaceDescription(firstOption); return; } if (MiscHelpers.DidClickRectangle(secondRect, thisPoint)) { _options.SpaceDescription(secondOption); return; } } foreach (var thisPiece in _gameContainer !.ExtraSpace !.PieceList) { ButtonCP?thisBut = thisPiece as ButtonCP; if (thisBut !.DidClickButton(thisPoint)) { if (thisBut.ExecuteAsync == null) { throw new BasicBlankException($"No execute async was done for button with text of {thisBut.Text}. Rethink."); } _gameContainer.Command.StartExecuting(); await thisBut.ExecuteAsync(); return; } } }