Ejemplo n.º 1
0
        public string Roll(string rawStat, int bonus)
        {
            string            resultMsg = string.Empty;
            AnimaRollableStat rollableStat;

            try
            {
                rollableStat = this.AllStats.FindByRawStat(rawStat);
            }
            catch (Exception)
            {
                return("Error 404: Stat not found (" + rawStat + ")");
            }

            DiceResult resultDice = rollableStat.Roll(bonus, this.DestinFuneste);

            this.AddRollStatistics(rollableStat, resultDice);

            if (rollableStat is Roll100Stat)
            {
                string bonusSymbol = bonus > 0 ? "+" : "";
                resultMsg = $"rolled : {resultDice.ResultText} {rollableStat.Name}{(bonus != 0 ? bonusSymbol + bonus: "" )}";

                // test si le jet et une maladress
                int failValue = AnimaDiceHelper.CheckFailValue(this.IsLucky, this.IsUnlucky, rollableStat.Value);
                if (resultDice.DiceResults.Last() <= failValue)
                {
                    // si oui lance le jet de maladress
                    int tempFail = resultDice.DiceResults.Last();
                    resultDice = rollableStat.FailRoll(tempFail);

                    // et affiche le resultat de maladress
                    resultMsg += Environment.NewLine;
                    resultMsg += string.Format("maladress : {0} {1}",
                                               resultDice.ResultText,
                                               (!string.IsNullOrEmpty(rollableStat.Name) ? rollableStat.Name : ""));
                }
            }
            else if (rollableStat is ResistanceStat)
            {
                string bonusSymbol = bonus > 0 ? "+" : "";
                resultMsg = $"rolled : {resultDice.ResultText} {rollableStat.Name}{(bonus != 0 ? bonusSymbol + bonus : "")}";
            }
            else
            {
                string rollOutcome = null;
                if (resultDice.DiceResults.First() - (rollableStat.Value + bonus) < 0)
                {
                    rollOutcome = "won";
                }
                else
                {
                    rollOutcome = "failed";
                }

                resultMsg = string.Format("rolled : {0} against {1} {2}, {3} by {4}",
                                          resultDice.DiceResults.First(),
                                          rollableStat.Value + bonus,
                                          (!string.IsNullOrEmpty(rollableStat.Name) ? rollableStat.Name : ""),
                                          rollOutcome,
                                          resultDice.DiceResults.First() - (rollableStat.Value + bonus));
            }

            return(resultMsg);
        }
Ejemplo n.º 2
0
 public override DiceResult Roll(int temporaryBonus, Boolean destinFuneste)
 {
     return(AnimaDiceHelper.BaseStatRoll(Value, temporaryBonus));
 }