Skip to content

Commit

Permalink
Added double damage item packet
Browse files Browse the repository at this point in the history
  • Loading branch information
DoubleF3lix committed Aug 16, 2024
1 parent 4d0dc75 commit 02b76ca
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Server.cs
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,24 @@ public async Task packetReceived(Client sender, ClientPacket packet) {
await this.postActionTransition(isTurnEndingMove);
}
break;
case UseDoubleDamageItemPacket useDoubleDamageItemPacket:
if (sender.player == this.gameData.getCurrentPlayerForTurn()) {
if (this.gameData.damageForShot != 1) {
await sender.sendMessage(new ActionFailedPacket { reason = "You've already used a double damage item for this shot!" });
} else {
// Try to remove the item
if (sender.player.items.Remove(Item.DoubleDamage)) {
await broadcast(new DoubleDamageItemUsedPacket());
await this.sendGameLogMessage($"{sender.player.username} has used a double damage item");
this.gameData.damageForShot = 2;
await this.syncGameData(); // Sync because the item is gone now
// If it fails and they don't have it
} else {
await sender.sendMessage(new ActionFailedPacket { reason = "You don't have a double damage item! Are you trying to cheat?" });
}
}
}
break;
default:
throw new Exception("Invalid packet type (with player instance) of \"{packet.packetType}\". Did you forget to implement this?");
}
Expand Down

0 comments on commit 02b76ca

Please sign in to comment.