public void ValidateDiceString_ShouldNotValidateBadStrings() { Assert.IsFalse(RollDice.ValidateDiceString("0d8")); Assert.IsFalse(RollDice.ValidateDiceString("1a8")); Assert.IsFalse(RollDice.ValidateDiceString("2d10a3")); Assert.IsFalse(RollDice.ValidateDiceString("")); }
// Use this for initialization void Start() { rollDice = GameObject.Find("DiceRoller").GetComponent <RollDice>(); IssueText.text = "=10*n->d10\n" + ">=12->d6_456\n" + ">=50->d6_x(+n)\n"; }
internal DiceRollResult onRollDice() { DiceRollResult diceRoll = new DiceRollResult(GameBoard); RollDice?.Invoke(this, diceRoll); return(diceRoll); }
void Awake() { RollTheDice = GameObject.Find("Dice").GetComponent<RollDice>(); TheBaseStar = this.gameObject.GetComponent<BaseStar>(); TheBaseStellarType = this.gameObject.GetComponent<BaseStellarType>(); PlentifulResources = new List<string>(); ScarceResources = new List<string>(); }
//Two player game ----------------------------------------------------------------------------------------- public static void TwoPlayerBattleCountry(ref List <Commander> players, string directory, GameDice dice, ref string diceImageOne, ref List <Country> countries, ref bool loop, ref int winner) { do { //Determine who won the roll----------------------------------------------------------------------------- int num = 0; //string win = "Win" int playerNumIdentifier = 1; for (int i = 0; i < players.Count; i++) { Console.WriteLine($"Player{playerNumIdentifier}: Press enter to roll your dice."); Console.ReadLine(); RollDice.RollOneGameDice(ref dice); players[i].DiceNumber = dice.DiceOne; Console.WriteLine("Player" + playerNumIdentifier + "'s roll:"); DisplayDiceImage.ShowDiceImageOne(ref dice, ref diceImageOne); Console.WriteLine(); playerNumIdentifier++; } if (players[0].DiceNumber > players[1].DiceNumber) { Console.WriteLine("Player one wins first pick! "); Console.ReadLine(); winner = 0; PickBattleCountry(ref players, directory, dice, ref diceImageOne, ref countries, ref loop, ref winner); winner = 1; PickBattleCountry(ref players, directory, dice, ref diceImageOne, ref countries, ref loop, ref winner); loop = true; } else if (players[1].DiceNumber > players[0].DiceNumber) { Console.WriteLine("Player two wins first pick!"); Console.ReadLine(); winner = 1; PickBattleCountry(ref players, directory, dice, ref diceImageOne, ref countries, ref loop, ref winner); winner = 0; PickBattleCountry(ref players, directory, dice, ref diceImageOne, ref countries, ref loop, ref winner); loop = true; } else if (players[1].DiceNumber == players[0].DiceNumber || players[0].DiceNumber == players[1].DiceNumber) { } else { Console.WriteLine("Invalid! Error!"); } Console.ReadLine(); } while (loop == false); //PickBattleCountry(ref players, directory, dice, ref diceImageOne, ref countries, ref loop, ref winner); Console.WriteLine($"{players[0].CommanderCountry}\n{players[1].CommanderCountry}"); Console.ReadLine(); }
private void OnRollDice(RollDice rollDice, Receiver receiver) { try { _player.RollDice(); } catch (Exception exception) { _receiver.SendMessage(new GameActionException(exception.Message)); } }
void Awake() { if (instance != null && instance != this) { Destroy(transform.root.gameObject); return; } else { instance = this; } DontDestroyOnLoad(transform.root.gameObject); }
public void RollManyTimesAndVerifyRange() { List <int> rolls = new List <int>(); for (int i = 0; i < 40; i++) { rolls.Add(RollDice.Roll("1d4")); } foreach (int i in rolls) { Assert.IsTrue(i >= 1 && i <= 4); } }
public ActionResult Index(RollDice roll) { if (ModelState.IsValid) { string[] rolls = new string[2]; rolls = roll.rollDice(); ViewBag.Die1 = rolls[0]; ViewBag.Die2 = rolls[1]; } else { ViewBag.Total = 0; } return(View()); }
public void EndTurn() { // dont end turn if there is still something to place in setup phase if (setupRoad > 0 || setupSettlement > 0) { return; } isPlacingRoad = false; isPlacingCity = false; isPlacingSettlement = false; int d1 = RollDice.Roll(); int d2 = RollDice.Roll(); GameState.instance.photonView.RPC("NextPlayer", RpcTarget.All, d1, d2); turnsButtons.SetActive(false); }
public void EditDie(RollDice die) { editMenuPoint.Look(editTransitionTime); die.GetComponent<Rigidbody>().useGravity = false; die.GetComponent<Collider>().enabled = false; die.Deactivate(); dieBeingEdited = die; diePreEditProperties = new DieProperties(); diePreEditProperties.material = die.GetComponent<Renderer>().material; diePreEditProperties.label = die.label; diePreEditProperties.modifier = die.modifier; InitEditDieFields(); dieFloatPoint.FlyTo(die.gameObject, editTransitionTime, delegate(GameObject obj) { inEditMode = true; }); }
public void RollAnInvalidDiceString() { Assert.Throws <InvalidRollException>(() => RollDice.Roll("")); }
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); } }
private void btnRoll_Click(object sender, EventArgs e) { int lvSuccess = RollDice.Roll(3, 2, 0, 8); }
public void RollAnInvalidNumberOfDice() { Assert.Throws <InvalidRollException>(() => RollDice.Roll("xd12+1")); }
private void btnRoll_Click(object sender, EventArgs e) { int lvSuccess = RollDice.Roll(3, 1, 1, 8, 10); ChatBox($"Outcome ({RollDice.GetOutcomeList()}) > {lvSuccess.ToString()} Success(es)", "Roll:", (int)RtfHelper.FontColorEnum.White, (int)RtfHelper.FontColorEnum.White); }
void Awake() { Aspects = new List<string>(); RollTheDice = GameObject.Find("Dice").GetComponent<RollDice>(); TheBaseStar = GetComponentInParent<BaseStar>(); TheBasePlanetarySystem = this.gameObject.GetComponent<BasePlanetarySystem>(); TheSliderSetting = Mathf.FloorToInt(GameObject.Find("Slider").GetComponent<SliderController>().TheValue); }
public void ValidateDiceString_ShouldValidateGoodStrings() { Assert.IsTrue(RollDice.ValidateDiceString("1d6")); Assert.IsTrue(RollDice.ValidateDiceString("10d12+25")); Assert.IsTrue(RollDice.ValidateDiceString("2d8-6")); }
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); } }
void Awake() { Aspects = new List<string>(); SatelliteTypes = new List<string>(); RollTheDice = GameObject.Find("Dice").GetComponent<RollDice>(); TheBaseStar = GetComponentInParent<BaseStar>(); BiosphereModifier = TheBaseStar.BiosphereModifier; TheSliderSetting = Mathf.FloorToInt(GameObject.Find("Slider").GetComponent<SliderController>().TheValue); }
public void RollAnInvalidDiceType() { Assert.Throws <InvalidRollException>(() => RollDice.Roll("5da1+3")); }
public void RollAnInvalidModifier() { Assert.Throws <InvalidRollException>(() => RollDice.Roll("2d10+x")); }
public void RollAValidDiceString() { var rollValue = RollDice.Roll("1d6+10"); Assert.IsTrue(rollValue >= 11 && rollValue <= 16); }
void Awake() { RollTheDice = GameObject.Find("Dice").GetComponent<RollDice>(); TheBaseStar = GetComponentInParent<BaseStar>(); TheBasePlanetarySystem = this.gameObject.GetComponent<BasePlanetarySystem>(); TheBaseCivilization = this.gameObject.GetComponent<BaseCivilization>(); }
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 RollAValidDiceStringWithoutModifier() { var rollValue = RollDice.Roll("1d20"); Assert.IsTrue(rollValue >= 1 && rollValue <= 20); }