mchess-client/lib/api/register.dart

44 lines
1.1 KiB
Dart
Raw Normal View History

2023-06-02 21:28:40 +00:00
import 'package:uuid/uuid.dart';
2023-06-29 23:49:18 +00:00
class PlayerInfo {
final UuidValue? playerID;
final UuidValue? lobbyID;
final String? passphrase;
2023-06-02 21:28:40 +00:00
2023-06-29 23:49:18 +00:00
const PlayerInfo({
2023-06-02 21:28:40 +00:00
required this.playerID,
required this.lobbyID,
2023-06-29 23:49:18 +00:00
required this.passphrase,
2023-06-02 21:28:40 +00:00
});
2023-06-29 23:49:18 +00:00
factory PlayerInfo.fromJson(Map<String, dynamic> json) {
final playerid = UuidValue.fromString(json['playerID']);
final lobbyid = UuidValue.fromString(json['lobbyID']);
2023-06-29 23:49:18 +00:00
final passphrase = json['passphrase'];
2023-06-02 21:28:40 +00:00
2023-06-29 23:49:18 +00:00
return PlayerInfo(
playerID: playerid, lobbyID: lobbyid, passphrase: passphrase);
2023-06-02 21:28:40 +00:00
}
2023-06-29 23:49:18 +00:00
Map<String, dynamic> toJson() => {
'playerID': playerID,
'lobbyID': lobbyID,
'passphrase': passphrase,
};
2023-06-02 21:28:40 +00:00
}
class WebsocketMessageIdentifyPlayer {
final String playerID;
final String lobbyID;
2023-06-29 23:49:18 +00:00
final String? passphrase;
2023-06-02 21:28:40 +00:00
const WebsocketMessageIdentifyPlayer({
required this.playerID,
required this.lobbyID,
2023-06-29 23:49:18 +00:00
required this.passphrase,
2023-06-02 21:28:40 +00:00
});
2023-06-29 23:49:18 +00:00
Map<String, dynamic> toJson() =>
{'lobbyID': lobbyID, 'playerID': playerID, 'passphrase': passphrase};
2023-06-02 21:28:40 +00:00
}