private void PlayGame() { while (_runNewGame) { decimal stake = _playerInputRequester.RequestStake(); SlotMachineSpinResultDto result = _gameController.SpinMachine(stake); if (!result.IsSuccess) { _writer.WriteLine(result.ResultMessage); continue; } DrawSymbols(result.Symbols); _writer.WriteLine($"You have won: {result.WinAmount:f2}"); _writer.WriteLine($"Current balance is: {result.PlayerBalance:f2}"); if (!_gameController.PlayerCanPlay()) { _runNewGame = _playerInputRequester.AskForNewGame(); if (_runNewGame) { decimal deposit = _playerInputRequester.RequestPlayerDeposit(); _gameController.CreateNewGame(deposit); } } } }
public SlotMachineSpinResultDto SpinMachine(decimal stakeAmount) { if (_player == null || _player.Balance <= 0 || _player.Balance < stakeAmount) { return(new SlotMachineSpinResultDto() { IsSuccess = false, ResultMessage = string.Format(InsufficientBalanceMessage, _player?.Balance) }); } _player.Balance -= stakeAmount; SlotMachineSpinResultDto spinResult = _slotMachine.Spin(stakeAmount); return(spinResult); }