void placebetthread(object bet) { try { PlaceBetObj tmp5 = bet as PlaceBetObj; decimal amount = tmp5.Amount; decimal chance = tmp5.Chance; bool High = tmp5.High; /*if (amount < 10000 && (DateTime.Now - Lastbet).TotalMilliseconds < 500) * { * Thread.Sleep((int)(500.0 - (DateTime.Now - Lastbet).TotalMilliseconds)); * }*/ decimal tmpchance = High ? 99.99m - chance : chance; GraphQLResponse betresult = GQLClient.PostAsync(new GraphQLRequest { Query = "mutation{rollDice(amount:" + amount.ToString("0.00000000", System.Globalization.NumberFormatInfo.InvariantInfo) + ", target:" + tmpchance.ToString("0.00", System.Globalization.NumberFormatInfo.InvariantInfo) + ",condition:" + (High ? "above" : "below") + ",currency:btc) { id iid nonce currency amount value payout result target condition createdAt seed{serverSeedHash serverSeed clientSeed nonce} user{balances{available{amount currency}} statistic{bets wins losses amount profit currency}}}}" }).Result; RollDice tmp = betresult.GetDataFieldAs <RollDice>("rollDice"); Lastbet = DateTime.Now; try { lastupdate = DateTime.Now; foreach (Statistic x in tmp.user.statistic) { if (x.currency.ToLower() == Currency.ToLower()) { this.bets = (int)x.bets; this.wins = (int)x.wins; this.losses = (int)x.losses; this.profit = (decimal)x.profit; this.wagered = (decimal)x.amount; break; } } foreach (Balance x in tmp.user.balances) { if (x.available.currency.ToLower() == Currency.ToLower()) { balance = (decimal)x.available.amount; break; } } Bet tmpbet = tmp.ToBet(); tmpbet.Guid = tmp5.Guid; FinishedBet(tmpbet); retrycount = 0; } catch { Parent.updateStatus("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 (AggregateException e) { if (retrycount++ < 3) { Thread.Sleep(500); placebetthread(new PlaceBetObj(High, amount, chance, (bet as PlaceBetObj).Guid)); return; } if (e.InnerException.Message.Contains("429") || e.InnerException.Message.Contains("502")) { Thread.Sleep(500); placebetthread(new PlaceBetObj(High, amount, chance, (bet as PlaceBetObj).Guid)); } } catch (Exception e2) { Parent.updateStatus("Error occured while trying to bet, retrying in 30 seconds. Probably."); Parent.DumpLog(e2.ToString(), -1); } }
void placebetthread(object bet) { try { PlaceBetObj tmp5 = bet as PlaceBetObj; decimal amount = tmp5.Amount; decimal chance = tmp5.Chance; bool High = tmp5.High; decimal tmpchance = High ? maxRoll - chance : chance; GraphQLResponse betresult = GQLClient.PostAsync(new GraphQLRequest { 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:" + Currency.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}}}}" }).Result; if (betresult.Errors != null) { if (betresult.Errors.Length > 0) { Parent.updateStatus(betresult.Errors[0].Message); } } if (betresult.Data != null) { RollDice tmp = betresult.GetDataFieldAs <RollDice>(RolName); Lastbet = DateTime.Now; try { lastupdate = DateTime.Now; foreach (Statistic x in tmp.user.statistic) { if (x.currency.ToLower() == Currency.ToLower() && x.game == StatGameName) { this.bets = (int)x.bets; this.wins = (int)x.wins; this.losses = (int)x.losses; this.profit = (decimal)x.profit; this.wagered = (decimal)x.betAmount; break; } } foreach (Balance x in tmp.user.balances) { if (x.available.currency.ToLower() == Currency.ToLower()) { balance = (decimal)x.available.amount; break; } } Bet tmpbet = tmp.ToBet(maxRoll); if (getid) { GraphQLResponse betresult2 = GQLClient.PostAsync(new GraphQLRequest { Query = " query{bet(betId:\"" + tmpbet.Id + "\"){iid}}" }).Result; if (betresult2.Data != null) { //RollDice tmp2 = betresult2.GetDataFieldAs<RollDice>(RolName); //tmpbet.Id = tmp2.iid; tmpbet.Id = betresult2.Data.bet.iid; if (tmpbet.Id.Contains("house:")) { tmpbet.Id = tmpbet.Id.Substring("house:".Length); } } } tmpbet.Guid = tmp5.Guid; FinishedBet(tmpbet); retrycount = 0; } catch (Exception e) { Parent.DumpLog(e.ToString(), -1); Parent.updateStatus("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 (AggregateException e) { if (retrycount++ < 3) { Thread.Sleep(500); placebetthread(new PlaceBetObj(High, amount, chance, (bet as PlaceBetObj).Guid)); return; } if (e.InnerException.Message.Contains("429") || e.InnerException.Message.Contains("502")) { Thread.Sleep(500); placebetthread(new PlaceBetObj(High, amount, chance, (bet as PlaceBetObj).Guid)); } } catch (Exception e2) { Parent.updateStatus("Error occured while trying to bet, retrying in 30 seconds. Probably."); Parent.DumpLog(e2.ToString(), -1); } }
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); } }