private DiceBet SimulatedBet(PlaceDiceBet NewBet) { //get RNG result from site decimal Lucky = 0; if (!Site.NonceBased) { GenerateSeeds(); } Lucky = Site.GetLucky(serverseedhash, serverseed, clientseed, (int)BetsWithSeed); DiceBet betresult = new DiceBet { TotalAmount = NewBet.Amount, Chance = NewBet.Chance, ClientSeed = clientseed, Currency = "simulation", DateValue = DateTime.Now, Guid = null, High = NewBet.High, Nonce = BetsWithSeed, Roll = Lucky, ServerHash = serverseedhash, ServerSeed = serverseed }; betresult.Profit = betresult.GetWin(Site) ? ((((100.0m - Site.Edge) / NewBet.Chance) * NewBet.Amount) - NewBet.Amount): -NewBet.Amount; OnBetSimulated?.Invoke(this, new BetFinisedEventArgs(betresult)); return(betresult); }
public void PlaceDiceBet(PlaceDiceBet BetDetails) { try { bool High = BetDetails.High; decimal amount = BetDetails.Amount; decimal chance = BetDetails.Chance; string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZqwertyuiopasdfghjklzxcvbnm1234567890"; while (clientseed.Length < 16) { clientseed += chars[R.Next(0, chars.Length)]; } string Params = string.Format(System.Globalization.NumberFormatInfo.InvariantInfo, "m={0}&client_seed={1}&jackpot=0&stake={2}&multiplier={3}&rand={5}&csrf_token={4}", High ? "hi" : "lo", clientseed, amount, (100m - Edge) / chance, csrf, R.Next(0, 9999999) / 10000000); var betresult = Client.GetAsync("https://freebitco.in/cgi-bin/bet.pl?" + Params).Result; if (betresult.IsSuccessStatusCode) { string Result = betresult.Content.ReadAsStringAsync().Result; string[] msgs = Result.Split(':'); if (msgs.Length > 2) { /* * 1. Success code (s1) * 2. Result (w/l) * 3. Rolled number * 4. User balance * 5. Amount won or lost (always positive). If 2. is l, then amount is subtracted from balance else if w it is added. * 6. Redundant (can ignore) * 7. Server seed hash for next roll * 8. Client seed of previous roll * 9. Nonce for next roll * 10. Server seed for previous roll * 11. Server seed hash for previous roll * 12. Client seed again (can ignore) * 13. Previous nonce * 14. Jackpot result (1 if won 0 if not won) * 15. Redundant (can ignore) * 16. Jackpot amount won (0 if lost) * 17. Bonus account balance after bet * 18. Bonus account wager remaining * 19. Max. amount of bonus eligible * 20. Max bet * 21. Account balance before bet * 22. Account balance after bet * 23. Bonus account balance before bet * 24. Bonus account balance after bet */ DiceBet tmp = new DiceBet { Guid = BetDetails.GUID, TotalAmount = amount, DateValue = DateTime.Now, Chance = chance, ClientSeed = msgs[7], High = High, BetID = Stats.Bets.ToString(), Profit = msgs[1] == "w" ? decimal.Parse(msgs[4]) : -decimal.Parse(msgs[4], System.Globalization.NumberFormatInfo.InvariantInfo), Nonce = long.Parse(msgs[12], System.Globalization.NumberFormatInfo.InvariantInfo), ServerHash = msgs[10], ServerSeed = msgs[9], Roll = decimal.Parse(msgs[2], System.Globalization.NumberFormatInfo.InvariantInfo) / 100.0m }; tmp.IsWin = tmp.GetWin(this); Stats.Balance = decimal.Parse(msgs[3], System.Globalization.NumberFormatInfo.InvariantInfo); if (msgs[1] == "w") { Stats.Wins++; } else { Stats.Losses++; } Stats.Bets++; Stats.Wagered += amount; Stats.Profit += tmp.Profit; callBetFinished(tmp); } else if (msgs.Length > 0) { //20 - too low balance if (msgs.Length > 1) { if (msgs[1] == "20") { callError("Balance too low.", true, ErrorType.BalanceTooLow); } } else { callError("Site returned unknown error. Retrying in 30 seconds.", true, ErrorType.Unknown); } } else { callError("Site returned unknown error. Retrying in 30 seconds.", true, ErrorType.Unknown); } } } catch (Exception e) { Logger.DumpLog(e); callError("An internal error occured. Retrying in 30 seconds.", true, ErrorType.Unknown); } }
private void SimulationThread() { try { DiceBet NewBet = SimulatedBet(DiceStrategy.RunReset()); this.Balance += (decimal)NewBet.Profit; Profit += (decimal)NewBet.Profit; while (TotalBetsPlaced < Bets && !Stop && Running) { if (log) { bets.Add(string.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8}" , TotalBetsPlaced, NewBet.Roll, NewBet.Chance, (NewBet.High ? ">" : "<"), NewBet.GetWin(Site) ? "win" : "lose", NewBet.TotalAmount, NewBet.Profit, this.Balance, Profit)); } if (TotalBetsPlaced % 10000 == 0) { OnSimulationWriting?.Invoke(this, new EventArgs()); if (log) { using (StreamWriter sw = File.AppendText(TmpFileName)) { foreach (string tmpbet in bets) { sw.WriteLine(tmpbet); } } bets.Clear(); } } TotalBetsPlaced++; BetsWithSeed++; bool Reset = false; PlaceDiceBet NewBetObject = null; bool win = NewBet.GetWin(Site); string Response = ""; if (BetSettings.CheckResetPreStats(NewBet, NewBet.GetWin(Site), Stats, SiteStats)) { Reset = true; NewBetObject = DiceStrategy.RunReset(); } if (BetSettings.CheckStopPreStats(NewBet, NewBet.GetWin(Site), Stats, out Response, SiteStats)) { this.Stop = (true); } Stats.UpdateStats(NewBet, win); if (DiceStrategy is ProgrammerMode) { (DiceStrategy as ProgrammerMode).UpdateSessionStats(CopyHelper.CreateCopy <SessionStats>(Stats)); (DiceStrategy as ProgrammerMode).UpdateSiteStats(CopyHelper.CreateCopy <SiteStats>(SiteStats)); (DiceStrategy as ProgrammerMode).UpdateSite(CopyHelper.CreateCopy <SiteDetails>(Site.SiteDetails)); } if (BetSettings.CheckResetPostStats(NewBet, NewBet.GetWin(Site), Stats, SiteStats)) { Reset = true; NewBetObject = DiceStrategy.RunReset(); } if (BetSettings.CheckStopPOstStats(NewBet, NewBet.GetWin(Site), Stats, out Response, SiteStats)) { Stop = true; } decimal withdrawamount = 0; if (BetSettings.CheckWithdraw(NewBet, NewBet.GetWin(Site), Stats, out withdrawamount, SiteStats)) { this.Balance -= withdrawamount; } if (BetSettings.CheckBank(NewBet, NewBet.GetWin(Site), Stats, out withdrawamount, SiteStats)) { this.Balance -= withdrawamount; } if (BetSettings.CheckTips(NewBet, NewBet.GetWin(Site), Stats, out withdrawamount, SiteStats)) { this.Balance -= withdrawamount; } bool NewHigh = false; if (BetSettings.CheckResetSeed(NewBet, NewBet.GetWin(Site), Stats, SiteStats)) { GenerateSeeds(); } if (BetSettings.CheckHighLow(NewBet, NewBet.GetWin(Site), Stats, out NewHigh, SiteStats)) { (DiceStrategy as iDiceStrategy).High = NewHigh; } if (!Reset) { NewBetObject = (DiceStrategy as iDiceStrategy).CalculateNextDiceBet(NewBet, win); } if (Running && !Stop && TotalBetsPlaced <= Bets) { if (this.Balance < (decimal)NewBetObject.Amount) { break; } NewBet = SimulatedBet(NewBetObject); this.Balance += (decimal)NewBet.Profit; Profit += (decimal)NewBet.Profit; //save to file } } using (StreamWriter sw = File.AppendText(TmpFileName)) { foreach (string tmpbet in bets) { sw.WriteLine(tmpbet); } } bets.Clear(); OnSimulationComplete?.Invoke(this, new EventArgs()); } catch (Exception e) { Logger.DumpLog(e); } }
public void PlaceDiceBet(PlaceDiceBet BetDetails) { try { decimal amount = BetDetails.Amount; decimal chance = BetDetails.Chance; bool High = BetDetails.High; /*if (amount < 10000 && (DateTime.Now - Lastbet).TotalMilliseconds < 500) * { * Thread.Sleep((int)(500.0 - (DateTime.Now - Lastbet).TotalMilliseconds)); * }*/ decimal tmpchance = High ? MaxRoll - chance : chance; string query = "mutation{" + RolName + "(amount:" + amount.ToString("0.00000000", System.Globalization.NumberFormatInfo.InvariantInfo) + ", target:" + tmpchance.ToString("0.00", System.Globalization.NumberFormatInfo.InvariantInfo) + ",condition:" + (High ? "above" : "below") + ",currency:" + CurrentCurrency.ToLower() + ") { id nonce currency amount payout state { ... on " + GameName + " { result target condition } } createdAt serverSeed{seedHash seed nonce} clientSeed{seed} user{balances{available{amount currency}} statistic{game bets wins losses betAmount profit currency}}}}"; //string query = "mutation {" + RolName + "(amount:" + amount.ToString("0.00000000", System.Globalization.NumberFormatInfo.InvariantInfo) + ", target:" + tmpchance.ToString("0.00", System.Globalization.NumberFormatInfo.InvariantInfo) + ",condition:" + (High ? "above" : "below") + ",currency:" + Currencies[Currency].ToLower() + ") { id iid nonce currency amount payout state { ... on " + GameName + " { result target condition } } createdAt serverSeed{seedHash seed nonce} clientSeed{seed} user{balances{available{amount currency}} statistic{game bets wins losses amount profit currency}}}}"; //var primediceRoll = GQLClient.SendMutationAsync<dynamic>(new GraphQLRequest { Query = query }).Result; GraphQLResponse <RollDice> betresult = GQLClient.SendMutationAsync <RollDice>(new GraphQLRequest { Query = query }).Result; RollDice tmp = betresult.Data.primediceRoll; Lastbet = DateTime.Now; try { lastupdate = DateTime.Now; foreach (Statistic x in tmp.user.statistic) { if (x.currency.ToLower() == Currencies[Currency].ToLower() && x.game == StatGameName) { this.Stats.Bets = (int)x.bets; this.Stats.Wins = (int)x.wins; this.Stats.Losses = (int)x.losses; this.Stats.Profit = x.profit; this.Stats.Wagered = x.amount; break; } } foreach (Balance x in tmp.user.balances) { if (x.available.currency.ToLower() == Currencies[Currency].ToLower()) { this.Stats.Balance = x.available.amount; break; } } DiceBet tmpbet = tmp.ToBet(); tmpbet.IsWin = tmpbet.GetWin(this); tmpbet.Guid = BetDetails.GUID; callBetFinished(tmpbet); retrycount = 0; } catch (Exception e) { Logger.DumpLog(e); callNotify("Some kind of error happened. I don't really know graphql, so your guess as to what went wrong is as good as mine."); } } catch (Exception e2) { callNotify("Error occured while trying to bet, retrying in 30 seconds. Probably."); Logger.DumpLog(e2); } }