public CalculatedTurnResult generateTurnOpponentEvent(string actualEventDescription, string playerName, int basePoint, int extraPoint, int numberOfDice, string diceType, int opponentPoint, bool isOpponentThrowToo) { rolledDicesInTurn.Clear(); RealPlayerStep playerStep = CreateRealPlayer(playerName, basePoint, extraPoint, numberOfDice, diceType); PlayerStep opponentStep = CreateOpponentPlayer(numberOfDice, diceType, opponentPoint, isOpponentThrowToo); TurnResult tr = calculateTurnResult(opponentStep, playerStep); string generatedText = turnTextBuilder.GeneratePlayerVSOpponentText(actualEventDescription, playerStep, opponentStep, tr); return(new CalculatedTurnResult(generatedText, rolledDicesInTurn.ToArray())); }
private PlayerStep CreateOpponentPlayer(int numberOfDice, string diceType, int opponentPoint, bool isOpponentThrowToo) { PlayerStep opponentStep = new PlayerStep(); opponentStep.basePoint = opponentPoint; if (isOpponentThrowToo) { opponentStep.throwDice = true; opponentStep.dicePoint = genereateSumOfThrowDice(diceType, numberOfDice); } return(opponentStep); }
private static TurnResult calculateTurnResult(PlayerStep opponentStep, RealPlayerStep playerStep) { TurnResult turnResult = TurnResult.win; int playerScore = playerStep.basePoint + playerStep.extraPoint + playerStep.dicePoint; int opponentScore = opponentStep.basePoint + opponentStep.dicePoint; if (playerScore == opponentScore) { turnResult = TurnResult.draw; } if (playerScore < opponentScore) { turnResult = TurnResult.lose; } if (playerScore > opponentScore) { turnResult = TurnResult.win; } return(turnResult); }