void Update() { if (lives == 0 && gameIsStarted) { LoseGame(); } if (CountOfDealedCards == 0 && gameIsStarted) { CountOfDealedCards = GameRules.CardForDealing; cardDealer.DealCards(); } if (cardDealer.cardFirst != null && cardDealer.cardSecond != null) { if (cardDealer.cardFirst.CardId == cardDealer.cardSecond.CardId) { bonusAnswers++; if (bonusAnswers == 1) { AddBonuseLive(); } scoreDirector.AddScore(1); cardDealer.PutChoosenCardsBackToDeck(); CountOfDealedCards -= 2; } else { bonusAnswers = 0; // сброс бонусной серии lives--; DeleteStar(); cardDealer.HideChoosenCards(); } } }
public async Task Start() { if (variables[Context.Guild].GameInProgress) // check if the game is in progress { if (variables[Context.Guild].RedScore + variables[Context.Guild].BlueScore == 9) { await ReplyAsync( ":checkered_flag: The game has ended! Use the `.reset` command to play again! :checkered_flag:"); return; } await ReplyAsync(":trophy: Game is already in progess! :trophy:"); return; } if (variables[Context.Guild].Players.Count == 0) { await ReplyAsync(":x: There are not enough players!! :x:"); return; } //if (variables[Context.Guild].RedTeam.Count != variables[Context.Guild].BlueTeam.Count) // make sure the teams are even //{ // await ReplyAsync($"Teams are not even! Check teams using the `.team list` command"); // return; //} foreach (string player in variables[Context.Guild].Players) // make sure that each username is attached to a IUser { if (variables[Context.Guild].AuthorUsers.ContainsKey(player)) { continue; } await ReplyAsync($":x: <@{player}> is not attached to a SocketUser! :x:"); return; } variables[Context.Guild].GameInProgress = true; variables[Context.Guild].CalledHalfSuits.Clear(); //Create AFN header variables[Context.Guild].AlgebraicNotation += variables[Context.Guild].Players.Count + ";"; variables[Context.Guild].AlgebraicNotation += variables[Context.Guild].RedTeam.Count + ";"; variables[Context.Guild].AlgebraicNotation += variables[Context.Guild].BlueTeam.Count + ";"; foreach (string redPlayer in variables[Context.Guild].RedTeam) { variables[Context.Guild].AlgebraicNotation += redPlayer + ":" + variables[Context.Guild].AuthorUsers[redPlayer] + ";"; } foreach (string bluePlayer in variables[Context.Guild].BlueTeam) { variables[Context.Guild].AlgebraicNotation += bluePlayer + ":" + variables[Context.Guild].AuthorUsers[bluePlayer] + ";"; } // Starting game await ReplyAsync(":trophy: `Starting Game...` :weary:"); variables[Context.Guild].PlayerTurn = variables[Context.Guild] .Players[new Random().Next(variables[Context.Guild].Players.Count)]; // get random player to start variables[Context.Guild].AlgebraicNotation += variables[Context.Guild].PlayerTurn + ";"; // add first player to afn variables[Context.Guild].GameStart = true; await CardDealer.DealCards(Context.Guild); await ReplyAsync($":game_die: It's <@{variables[Context.Guild].PlayerTurn}>'s turn!"); }