public string AttemptToLeave(ChatUser chatUser) { if (!IsRunning) { return("You can't leave a game that isn't being played."); // TODO: this needs to be a whisper } if (_questionAskingStarted) { return("The questions have started, you can't leave."); // TODO: this needs to be a whisper } if (CurrentPlayers.ContainsKey(chatUser.DisplayName)) { CurrentPlayers.Remove(chatUser.DisplayName); return($"{chatUser.DisplayName} has quit the game."); } return($"You aren't in this game, {chatUser.DisplayName}"); // TODO: this needs to be a whisper }
private void ResolveAttack(int cardNumber) { //Dictionary<string, Tuple<int, List<Tuple<int,int>>>> playersAttacks = new Dictionary<string, Tuple<int, List<Tuple<int,int>>>>(); //dmg, kernel Dictionary <string, Tuple <int, int> > playersPositions = new Dictionary <string, Tuple <int, int> >(); foreach (var player in CurrentPlayers) { playersPositions[player.PlayerId] = new Tuple <int, int>(player.X, player.Y); } foreach (var player in CurrentPlayers) { List <Tuple <int, int> > affectedPositions = new List <Tuple <int, int> >(); var card = CardsList[player.ActionList[cardNumber]]; if (card.Dmg != 0) { player.Animation = AnimationStatus.Attack; int sizePerSide = card.DmgKernel.GetLength(0) / 2; for (int y = 0; y < card.DmgKernel.GetLength(0); y++) { for (int x = 0; x < card.DmgKernel.GetLength(0); x++) { if (card.DmgKernel[y, x]) { affectedPositions.Add(new Tuple <int, int>(player.X + x - sizePerSide, player.Y + y - sizePerSide)); } } } //playersAttacks[player.PlayerId] = new Tuple<int, bool[,]>(card.Dmg, card.DmgKernel); //player.Animation = AnimationStatus.Attack; } foreach (var position in playersPositions) { foreach (var pos in affectedPositions) { if (pos.Item1 >= 0 && pos.Item1 < MaxX && pos.Item2 >= 0 && pos.Item2 < MaxY && Grid[pos.Item1, pos.Item2] == -1) { Grid[pos.Item1, pos.Item2] = -2; } } if (affectedPositions.Contains(position.Value)) { Player currentPlayer = CurrentPlayers.First(d => d.PlayerId == position.Key); currentPlayer.HP -= card.Dmg; switch (currentPlayer.Animation) { case AnimationStatus.Idle: currentPlayer.Animation = AnimationStatus.IdleHurt; break; case AnimationStatus.Move: currentPlayer.Animation = AnimationStatus.MoveHurt; break; case AnimationStatus.Attack: currentPlayer.Animation = AnimationStatus.AttackHurt; break; case AnimationStatus.Colide: currentPlayer.Animation = AnimationStatus.ColideHurt; break; } if (currentPlayer.HP <= 0) { int pN = currentPlayer.PlayerNumber; //currentPlayer.Animation = AnimationStatus.Death; for (int i = 0; i < MaxX; i++) { for (int j = 0; j < MaxY; j++) { if (Grid[i, j] == pN) { Grid[i, j] = -2; } } } CurrentPlayers.Remove(currentPlayer); //Status = 0; //game ended (specjalna wiadomość?) } } } } }