public TickResult Next(long wager, long lossStreak = 0) { var ticks = 0; var alive = true; int chance = BaseChance; if (lossStreak > 0) { int chanceBonus = (int)Math.Floor(lossStreak / (double)3); chance += chanceBonus; if (chance > 70) { chance = 70; } } while (alive) { if (RandomProvider.Instance.Next(LowerBound, UpperBound) <= chance) { ticks++; chance--; if (chance <= 0) { break; } continue; } alive = false; } Chance = chance; bool won = Method switch { TickWinMethod.Exact => ticks == ExpectedTick, _ => ticks >= ExpectedTick }; TickResultFlag flag = won ? TickResultFlag.Win : TickResultFlag.Lose; if (won && Method == TickWinMethod.Exact) { flag = TickResultFlag.Exact; } float multiplier = GetMultiplier(ExpectedTick, Method); var reward = (long)Math.Floor(wager * multiplier); Logger.Debug($"Tick died at {ticks} ({chance}%) [{flag} - {wager} => {reward} (x{multiplier})]"); return(new TickResult(wager, reward, flag, ExpectedTick, ticks, multiplier)); } }
public TickResult(long wager, long reward, TickResultFlag flag, int expectedTick, int actualTick, float multiplier) { Wager = wager; Reward = reward; Flag = flag; ExpectedTick = expectedTick; ActualTick = actualTick; Multiplier = multiplier; }
public static string GetReply(TickResultFlag flag, ArcadeUser user = null, TickResult result = null) { IEnumerable <CasinoReply> replies = GetReplies(flag); if (user != null && result != null) { replies = replies.Where(x => MeetsCriteria(x, user, result)); } if (Check.NotNullOrEmpty(replies)) { return(Randomizer.Choose(replies).ToString(user, result)); } return(GetGeneric(flag)); }