コード例 #1
0
        public CalculatedTurnResult generateTurnTaskEvent(string actualEventDescription, string playerName, int basePoint, int extraPoint, int numberOfDice, string diceType, TaskType taskName)
        {
            rolledDicesInTurn.Clear();
            RealPlayerStep playerStep    = CreateRealPlayer(playerName, basePoint, extraPoint, numberOfDice, diceType);
            string         generatedText = turnTextBuilder.GeneratePlayerVSTaskText(actualEventDescription, playerStep, taskName);

            return(new CalculatedTurnResult(generatedText, rolledDicesInTurn.ToArray()));
        }
コード例 #2
0
        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()));
        }
コード例 #3
0
        private RealPlayerStep CreateRealPlayer(string playerName, int basePoint, int extraPoint, int numberOfDice, string diceType)
        {
            RealPlayerStep playerStep = new RealPlayerStep();

            playerStep.playerName = playerName.Equals("") ? DEFAULT_PLAYER_NAME : playerName;
            playerStep.basePoint  = basePoint;
            playerStep.extraPoint = extraPoint;

            if (numberOfDice > 0)
            {
                playerStep.throwDice = true;
                playerStep.dicePoint = genereateSumOfThrowDice(diceType, numberOfDice);
            }
            return(playerStep);
        }
コード例 #4
0
        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);
        }