[Command("start")] // Start the game public override async Task StartGameCmd() { if (Game != null) { await ReplyAsync("Another game already in progress.").ConfigureAwait(false); } else if (!OpenToJoin) { await ReplyAsync("No game has been opened at this time.").ConfigureAwait(false); } else if (JoinedUsers.Count < 2) // Example value if a game has a minimum player requirement { await ReplyAsync("Not enough players have joined.").ConfigureAwait(false); } else { if (GameService.TryUpdateOpenToJoin(Context.Channel, newValue: false)) { // Tip: Shuffle the players before projecting them var players = JoinedUsers.Select(u => new ExamplePlayer(u, Context.Channel)); // The Player class can also be extended for additional properties var game = new ExampleGame(Context.Channel, players); if (await GameService.TryAddNewGameAsync(Context.Channel, game).ConfigureAwait(false)) { await game.SetupGame().ConfigureAwait(false); await game.StartGame().ConfigureAwait(false); } } } }
private void WinnerFound(object sender, Aiva.Models.Giveaway.Users e) { Winners.Add(e); JoinedUsers.Remove(e); if (!string.IsNullOrEmpty(WinnersSeperated)) { WinnersSeperated += $" | {e.Username}"; } else { WinnersSeperated += e.Username; } }
public void Leave(User user) { if (JoinedUsers.Contains(user)) { Logger.DebugPrint(user.Username + " Left multiroom @ " + x.ToString() + "," + y.ToString()); joinedUsers.Remove(user); foreach (User joinedUser in JoinedUsers) { if (!TwoPlayer.IsPlayerInGame(joinedUser)) { if (!joinedUser.MajorPriority) { GameServer.UpdateArea(joinedUser.LoggedinClient); } } } } }
private void UserJoined(object sender, Aiva.Models.Giveaway.Users e) { Application.Current.Dispatcher.Invoke(() => JoinedUsers.Add(e)); }
public bool IsJoinedById(string userId) { return(JoinedUsers.Any(p => p.Id == userId)); }
public bool AlreadyJoinedByEmail(string email) { return(JoinedUsers.Any(p => p.Email == email)); }