private void undoButton_Click(object sender, EventArgs e) { RoundModel round = new RoundModel(); int index = AllRounds.Count - 2; if (index > 0) { round = AllRounds[index]; } if (AllRounds.Count > 0) { NumberLogic.UndoNumberProperties(AllRounds.Last().WinningNumber, this); } DisplayCurrentRound(round); ReverseTextboxes(); if (AllRounds.Count > 0) { AllRounds.RemoveAt(AllRounds.Count - 1); } }
private void NumberButton_Click(object sender, EventArgs e) { Button button = (Button)sender; byte digit = byte.Parse(button.Text); RoundModel round = new RoundModel(); round.Spin = AllRounds.Count() + 1; round = UserInputHelper.EnterNumber(digit, round, this, sessionStartForm); AllRounds.Add(round); NumberLogic.UpdateNumberProperties(digit, this); UserInputHelper.CheckIfUserHasWon(round, CurrentUser, this, userWonForm); CascadeTextboxes(); DisplayCurrentRound(round); tickSound.Play(); }
private void inputTextBox_KeyDown(object sender, KeyEventArgs e) { RoundModel round = new RoundModel(); round.Spin = AllRounds.Count() + 1; if (e.KeyCode == Keys.Enter) { if (InputValueAllowed()) { byte currentNumber = byte.Parse(inputTextBox.Text); foreach (NumberModel number in AllRouletteNumbers) { if (currentNumber == number.Digit) { round = UserInputHelper.EnterNumber(currentNumber, round, this, sessionStartForm); } } AllRounds.Add(round); NumberLogic.UpdateNumberProperties(currentNumber, this); UserInputHelper.CheckIfUserHasWon(round, CurrentUser, this, userWonForm); } inputTextBox.Clear(); CascadeTextboxes(); DisplayCurrentRound(round); tickSound.Play(); } }
private void NumberButton_Click(object sender, EventArgs e) { Button button = (Button)sender; int digit = int.Parse(button.Content.ToString()); Round round = new Round(); round.Spin = AllRounds.Count() + 1; round = UserInputHandler.EnterNumber(digit, round, this); AllRounds.Add(round); NumberLogic.UpdateNumberProperties(digit, this); UserInputHandler.CheckIfUserHasWon(round, this); CascadeTextboxes(); DisplayCurrentRound(round); tickSound.Play(); }
private void ReverseTextboxes() { textBox1.Text = textBox2.Text; textBox2.Text = textBox3.Text; textBox3.Text = textBox4.Text; textBox4.Text = textBox5.Text; textBox5.Text = textBox6.Text; textBox6.Text = textBox7.Text; textBox7.Text = textBox8.Text; textBox8.Text = textBox9.Text; textBox9.Text = textBox10.Text; textBox10.Text = textBox11.Text; textBox11.Text = textBox12.Text; if (AllRounds.Count > 0) { int index = AllRounds.Count() - 13; if (AllRounds.Count > 12) { RoundModel round = AllRounds[index]; textBox12.Text = round.WinningNumber.ToString(); } else { textBox12.Clear(); } } }
private void InputTextBox_KeyDown(object sender, KeyEventArgs e) { Round round = new Round(); round.Spin = AllRounds.Count() + 1; if (e.Key == Key.Enter) { if (InputValueAllowed()) { byte currentNumber = byte.Parse(InputTextBox.Text); foreach (Number number in AllRouletteNumbers) { if (currentNumber == number.Digit) { round = UserInputHandler.EnterNumber(currentNumber, round, this); } } AllRounds.Add(round); NumberLogic.UpdateNumberProperties(currentNumber, this); UserInputHandler.CheckIfUserHasWon(round, this); } InputTextBox.Clear(); CascadeTextboxes(); DisplayCurrentRound(round); tickSound.Play(); } }
private void resetRoot(XElement newRoot) { Console.WriteLine("Reset Root called newroot is CHDB? {0}", newRoot.Equals(CHDBElement)); Console.WriteLine("AllRounds.Count(): {0}", AllRounds.Count()); Console.WriteLine("AllVideos.Count(): {0}", AllVideos.Count()); PlayerHelper.Stop(); wasPlaying = false; Root = newRoot; SelectedRound = AllRounds.First(); RaisePropertyChanged("AllVideos"); RaisePropertyChanged("AllRounds"); }
/// <summary> /// Plays given round, calculating everything, moving this instance of /// the game into position after the round was played. /// </summary> public virtual void PlayRound() { var linearizedRound = LastRound.Linearize(); roundHandler.PlayRound(linearizedRound); Game.Refresh(); AllRounds.Add(linearizedRound); // if I played a round it means that next round will surelly wont be GameBeginningRound LastRound = new GameRound(); OnRoundPlayed?.Invoke(); }
public JsonValue ToJson(IJsonContext ctx) { return(new JsonDictionary() .Set("items", ctx.ToJson(items)) .Set("nextItems", ctx.ToJson(nextItems)) .Set("failed", new JsonBool(failed)) .Set("currentItem", ctx.ToJson(CurrentItem)) .Set("currentIndex", new JsonNumber(CurrentIndex)) .Set("itemCount", new JsonNumber(ItemCount)) .Set("score", new JsonNumber(Score)) .Set("round", new JsonNumber(Round)) .Set("lastRoundInfo", ctx.ToJson(LastRoundInfo)) .Set("allRounds", ctx.ToJson(AllRounds.ToList())) .Set("title", new JsonString(Title)) .Set("maxItemCount", new JsonNumber(maxItemCount))); }
public CHDB(string applicationPath) { pathToCHDB = Path.Combine(applicationPath, CHDBFilename); pathToInWork = Path.Combine(applicationPath, InWorkFilename); pathToTagDB = Path.Combine(applicationPath, TagDBFilename); CHDBElement = loadOrCreateXElement(pathToCHDB, XName.Get("CH")); InWorkElement = loadOrCreateXElement(pathToInWork, XName.Get("CH")); TagDBElement = loadOrCreateXElement(pathToTagDB, XName.Get("Tags")); CurrentFile = pathToCHDB; Root = CHDBElement ?? new XElement("CH"); CHDBElement.Changed += CHDB_Changed; InWorkElement.Changed += InWorkElement_Changed; TagDBElement.Changed += TagDBElement_Changed; _roundModeProperty = NotifyProperty.CreateNotifyProperty(this, () => RoundMode); _selectedRoundProperty = NotifyProperty.CreateNotifyProperty(this, () => SelectedRound); _selectedVideoProperty = DerivedNotifyProperty.CreateDerivedNotifyProperty <XElement, XElement>(this, () => SelectedVideo, _selectedRoundProperty, GetVideoFromRound); _currentPlayerPos = NotifyProperty.CreateNotifyProperty(this, () => CurrentPlayerPosition); _breakModeProperty = NotifyProperty.CreateNotifyProperty(this, () => CurrentBreakMode); _onBreakProperty = NotifyProperty.CreateNotifyProperty(this, () => OnBreak); _breakProgressProperty = NotifyProperty.CreateNotifyProperty(this, () => BreakProgress); _breakMinimumProperty = NotifyProperty.CreateNotifyProperty(this, () => BreakMinimum); _breakMaximumProperty = NotifyProperty.CreateNotifyProperty(this, () => BreakMaximum); _breakBetweenMinLengthProperty = NotifyProperty.CreateNotifyProperty(this, () => MinBetweenBreakLength); _breakBetweenMaxLengthProperty = NotifyProperty.CreateNotifyProperty(this, () => MaxBetweenBreakLength); _breakSetMaxLengthProperty = NotifyProperty.CreateNotifyProperty(this, () => MaxSetBreakLength); _bothFilesExist = NotifyProperty.CreateNotifyProperty(this, () => BothFilesExist); _tagTreeViewSyncedToSelectedRound = NotifyProperty.CreateNotifyProperty(this, () => TagTreeViewSyncedToSelectedRound); _treeViewSelectedItemProperty = NotifyProperty.CreateNotifyProperty(this, () => TreeViewSelectedItem); _treeViewSelectedItemTagsDerivedProperty = DerivedNotifyProperty.CreateDerivedNotifyProperty <XElement, List <TokenizedTagItem> >(this, () => TreeViewSelectedTags, _treeViewSelectedItemProperty, GetTagsFromSelectedItem); BothFilesExist = File.Exists(pathToCHDB) && File.Exists(pathToInWork); TagTreeViewSyncedToSelectedRound = false; CurrentBreakMode = BreakMode.Set; OnBreak = false; BreakMinimum = 0; BreakMaximum = 100; BreakProgress = 0; RoundMode = true; timer.Tick += Timer_Tick; timer.Interval = new TimeSpan(0, 0, 0, 0, 100); // 100 milliseconds MinBetweenBreakLength = 1; MaxBetweenBreakLength = 8; MaxSetBreakLength = 60; doStartupCheck(); if (AllVideos.Count() == 0) // if at this point we have no videos... die horrific death? { MessageBox.Show(String.Format("Could not find any videos! Exiting... check your XML files. path used: {0}", applicationPath)); Environment.Exit(1); } // cannot access anything that needs "Exists" or "Buried" until after startup check SelectedRound = AllRounds.First(); }