public void MenuButton_Click(object sender, EventArgs e) { ErrorMessagePanel.Visible = false; var TheButton = (Button)sender; int viewIndex = Int32.Parse(TheButton.CommandArgument); MenuMultiView.ActiveViewIndex = viewIndex; //Change button style foreach (Button b in MenuButtonPlaceHolder.Controls) { b.CssClass = ""; } TheButton.CssClass = "ViewSelected"; if (viewIndex == 3) { //enable betting currentWindow.Text = "3"; InvestmentsGridView.DataBind(); } else if (viewIndex == 2) { //Disable betting currentWindow.Text = "2"; DiceGameHash CurrentDiceGameHash = DiceGameHash.Get(user); CurrentDiceGameHash.ArchiveServerSeedAndHash(); string serverSeedPrevious = CurrentDiceGameHash.ServerSeedPrevious; string serverHashPrevious = CurrentDiceGameHash.ServerHashPrevious; string clientSeedPrevious = CurrentDiceGameHash.ClientSeedCurrent; string numberOfBets = DiceGameHashLogic.GetNumberOfBets(user.Id).ToString(); CurrentDiceGameHash.GenerateServerSeedAndHash(); CurrentDiceGameHash.Save(); string serverHashCurrent = CurrentDiceGameHash.ServerHashCurrent; LastServerSeedLabel.Text = serverSeedPrevious; LastServerSeedHashLabel.Text = serverHashPrevious; LastClientSeedLabel.Text = clientSeedPrevious; NumberOfRollsLabel.Text = numberOfBets; NewServerSeedHashLabel.Text = serverHashCurrent; NewClientSeedTextBox.Text = DiceGameHashLogic.GenerateClientSeed(); } else if (viewIndex == 1) { //enable betting currentWindow.Text = "1"; } else if (viewIndex == 0) { //enable betting currentWindow.Text = "0"; } else if (viewIndex == 4) { //disable betting currentWindow.Text = "4"; } }
/// <summary> /// Gets Seeds and Hashes from the DB or creates new if not present /// </summary> /// <param name="user"></param> /// <returns></returns> public static DiceGameHash Get(Member user) { var diceGameHashes = TableHelper.SelectRows <DiceGameHash>(TableHelper.MakeDictionary("UserId", user.Id)); if (diceGameHashes.Count == 0) { DiceGameHash hash = new DiceGameHash(); hash.UserId = user.Id; hash.GenerateFirstHashes(); hash.Save(); return(hash); } return(diceGameHashes[0]); }
public void btnRandomize_Click(object sender, EventArgs e) { try { string digitsOnly = NewClientSeedTextBox.Text; if (digitsOnly.Length != 24) { throw new MsgException(U4200.CLIENTSEEDNOTVALID1); } foreach (char c in digitsOnly) { if (!char.IsDigit(c)) { throw new MsgException(U4200.CLIENTSEEDNOTVALID2); } } DiceGameHash CurrentDiceGameHash = DiceGameHash.Get(user); CurrentDiceGameHash.UpdateClientSeed(NewClientSeedTextBox.Text); CurrentDiceGameHash.Save(); Response.Redirect("dicegame.aspx"); } catch (MsgException ex) { ErrorMessagePanel.Visible = true; ErrorMessage.Text = ex.Message; } catch (Exception ex) { ErrorLogger.Log(ex); throw ex; } }