mirror of
https://github.com/AndrioCelos/TableturfBattleApp.git
synced 2026-03-24 19:04:08 -05:00
This allows any number of games to be played in a room. Each player bar will show the number of games that player has won. If a goal win count is selected in More Options, the set will end when someone reaches that many wins. Otherwise, players can start a new game after the game ends.
45 lines
1.3 KiB
C#
45 lines
1.3 KiB
C#
using Newtonsoft.Json;
|
|
|
|
namespace TableturfBattleServer.DTO;
|
|
|
|
internal class WebSocketPayload<T> {
|
|
[JsonProperty("event")]
|
|
public string EventName;
|
|
[JsonProperty("data")]
|
|
public T Payload;
|
|
|
|
public WebSocketPayload(string eventName, T payload) {
|
|
this.EventName = eventName ?? throw new ArgumentNullException(nameof(eventName));
|
|
this.Payload = payload;
|
|
}
|
|
}
|
|
internal class WebSocketPayloadWithPlayerData<T> : WebSocketPayload<T> {
|
|
[JsonProperty("playerData")]
|
|
public PlayerData? PlayerData;
|
|
|
|
public WebSocketPayloadWithPlayerData(string eventName, T payload, PlayerData? playerData) : base(eventName, payload)
|
|
=> this.PlayerData = playerData;
|
|
}
|
|
|
|
public class PlayerData {
|
|
[JsonProperty("playerIndex")]
|
|
public int PlayerIndex;
|
|
[JsonProperty("hand")]
|
|
public Card[]? Hand;
|
|
[JsonProperty("deck")]
|
|
public Card[]? Deck;
|
|
[JsonProperty("move")]
|
|
public Move? Move;
|
|
[JsonProperty("cardsUsed")]
|
|
public List<int>? CardsUsed;
|
|
|
|
public PlayerData(int playerIndex, Card[]? hand, Card[]? deck, Move? move, List<int>? cardsUsed) {
|
|
this.PlayerIndex = playerIndex;
|
|
this.Hand = hand;
|
|
this.Deck = deck;
|
|
this.Move = move;
|
|
this.CardsUsed = cardsUsed;
|
|
}
|
|
public PlayerData(int playerIndex, Player player) : this(playerIndex, player.Hand, player.CurrentGameData.Deck, player.Move, player.CardsUsed) { }
|
|
}
|