// Fill the form and Play private void btnPlay_Click(object sender, EventArgs e) { try { string Age, PlayerName; Age = tbAge.Text.Trim(); PlayerName = tbName.Text.Trim(); if (PlayerName.Equals("")) { MessageBox.Show("Please enter player name"); } else if (Age.Equals("")) { MessageBox.Show("Please enter your age"); } else { PlayerData obj = new PlayerData(); obj.PlayerName = PlayerName; obj.Age = int.Parse(Age); obj.Win = 0; obj.Loss = 0; if (obj.Age >= 18) { int PlayerID = new PlayerTask().InsertData(obj); if (PlayerID != 0) { this.Hide(); Game g = new Game(PlayerName, PlayerID); g.Show(); } } else { MessageBox.Show("Be mature enough to play this game"); } } } catch (Exception ex) { if (ex is FormatException) { MessageBox.Show("Please enter numeric values only"); } else if (ex.Message.Contains("Duplicate")) { MessageBox.Show("Player name already exists, please user another name"); } else { MessageBox.Show(ex.Message); } } }
public override bool Equals(object obj) { if (obj == null || GetType() != obj.GetType()) { return(false); } var other = (ScoreViewModel)obj; return(PlayerName.Equals(other.PlayerName) && Seconds == other.Seconds && Points == other.Points && Date == other.Date); }
private static bool ProceedTheGame(PlayerName name) { bool result; Random rn = new Random(); if (name.Equals(PlayerName.Computer)) { Console.WriteLine($"\r\n >>Computer will decide whether to continue the game or not: "); result = rn.Next(0, 2) == 1; Console.Write($">>Computer has chosen to {(result ? "continue" : "stop")} playing\r\n"); return(result); } Console.WriteLine("\r\n>>Would you like yo get one more card?"); return(RecieveYesOrNoAnswer()); }
private void TryLogInPlayer() { if (string.IsNullOrWhiteSpace(PlayerName)) { if (string.IsNullOrEmpty(PlayerName)) { SetErrorMessageDesign(); ErrorMessage = "Du måste skriva något"; } else { SetErrorMessageDesign(); ErrorMessage = "Du får inte använda mellanslag"; } return; } if (PlayerName.Equals("Admin", StringComparison.OrdinalIgnoreCase)) { SetActivePlayer("Admin"); GoToPage(ApplicationPage.Admin); } else if (!_module.TryLogInPlayer(PlayerName)) { SetErrorMessageDesign(); ErrorMessage = "Din användare finns inte!"; } else { SetActivePlayer(PlayerName); GoToPage(ApplicationPage.GamePage); } }
public bool Equals(Stats other) { return(PlayerName.Equals(other.PlayerName) && Score.Equals(other.Score) && date.Equals(other.date)); }
private void OnEventReceived(SeerEvent seerEvent) { try { // make sure it's valid to begin with and from a backend. if (!seerEvent.IsValid() || 10 > (int)seerEvent.EventSource) { return; } seerEvent.Game = this; // pass exceptions up immediately if (seerEvent is BackendExceptionEvent backendExceptionEvent) { BmpSeer.Instance.PublishEvent(backendExceptionEvent); return; } // deduplicate if needed if (seerEvent.DedupeThreshold > 0) { if (_eventDedupeHistory.ContainsKey(seerEvent.EventType) && _eventDedupeHistory[seerEvent.EventType] + seerEvent.DedupeThreshold >= seerEvent.TimeStamp) { return; } _eventDedupeHistory[seerEvent.EventType] = seerEvent.TimeStamp; } switch (seerEvent) { case ActorIdChanged actorId: if (ActorId != actorId.ActorId) { ActorId = actorId.ActorId; BmpSeer.Instance.PublishEvent(actorId); } break; case ChatLog chatLogEvent: // Currently unused. break; case ChatStatusChanged chatStatus: if (ChatStatus != chatStatus.ChatStatus) { ChatStatus = chatStatus.ChatStatus; BmpSeer.Instance.PublishEvent(chatStatus); } break; case ConfigIdChanged configId: if (!ConfigId.Equals(configId.ConfigId)) { ConfigId = configId.ConfigId; BmpSeer.Instance.PublishEvent(configId); } break; case EnsembleRejected ensembleRejected: BmpSeer.Instance.PublishEvent(ensembleRejected); break; case EnsembleRequested ensembleRequested: BmpSeer.Instance.PublishEvent(ensembleRequested); break; case EnsembleStarted ensembleStarted: BmpSeer.Instance.PublishEvent(ensembleStarted); break; // Currently unused. Currently unavailable from Machina backend. // case EnsembleStopped ensembleStopped: // Seer.Instance.PublishEvent(ensembleStopped); // break; case InstrumentHeldChanged instrumentHeld: if (!InstrumentHeld.Equals(instrumentHeld.InstrumentHeld)) { InstrumentHeld = instrumentHeld.InstrumentHeld; BmpSeer.Instance.PublishEvent(instrumentHeld); } break; case IsBardChanged isBard: if (IsBard != isBard.IsBard) { IsBard = isBard.IsBard; BmpSeer.Instance.PublishEvent(isBard); } break; case KeyMapChanged keyMap: if (!NavigationMenuKeys.Equals(keyMap.NavigationMenuKeys) || !InstrumentToneMenuKeys.Equals(keyMap.InstrumentToneMenuKeys) || !InstrumentKeys.Equals(keyMap.InstrumentKeys) || !InstrumentToneKeys.Equals(keyMap.InstrumentToneKeys) || !NoteKeys.Equals(keyMap.NoteKeys)) { NavigationMenuKeys = keyMap.NavigationMenuKeys; InstrumentToneMenuKeys = keyMap.InstrumentToneMenuKeys; InstrumentKeys = keyMap.InstrumentKeys; InstrumentToneKeys = keyMap.InstrumentToneKeys; NoteKeys = keyMap.NoteKeys; BmpSeer.Instance.PublishEvent(keyMap); } break; case PartyMembersChanged partyMembers: if (!PartyMembers.KeysEquals(partyMembers.PartyMembers)) { PartyMembers = partyMembers.PartyMembers; BmpSeer.Instance.PublishEvent(partyMembers); } break; case PlayerNameChanged playerName: if (!PlayerName.Equals(playerName.PlayerName)) { PlayerName = playerName.PlayerName; BmpSeer.Instance.PublishEvent(playerName); } break; case HomeWorldChanged homeWorld: if (!HomeWorld.Equals(homeWorld.HomeWorld)) { HomeWorld = homeWorld.HomeWorld; BmpSeer.Instance.PublishEvent(homeWorld); } break; } } catch (Exception ex) { BmpSeer.Instance.PublishEvent(new GameExceptionEvent(this, Pid, ex)); } }