mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-11 08:34:52 -07:00
remove type aliases
This commit is contained in:
parent
141f0e59f5
commit
cea9ae62d8
58 changed files with 412 additions and 455 deletions
|
|
@ -1,6 +1,6 @@
|
|||
import { StatusEnum, User, WebSocketConnectReason, WebSocketConnectOptions } from 'types';
|
||||
import { StatusEnum, WebSocketConnectReason, WebSocketConnectOptions } from 'types';
|
||||
import { SessionCommands } from 'websocket';
|
||||
import { ServerInfo_User_UserLevelFlag } from 'generated/proto/serverinfo_user_pb';
|
||||
import { ServerInfo_User, ServerInfo_User_UserLevelFlag } from 'generated/proto/serverinfo_user_pb';
|
||||
|
||||
export class AuthenticationService {
|
||||
static login(options: WebSocketConnectOptions): void {
|
||||
|
|
@ -39,7 +39,7 @@ export class AuthenticationService {
|
|||
return state === StatusEnum.LOGGED_IN;
|
||||
}
|
||||
|
||||
static isModerator(user: User): boolean {
|
||||
static isModerator(user: ServerInfo_User): boolean {
|
||||
const moderatorLevel = ServerInfo_User_UserLevelFlag.IsModerator;
|
||||
// @TODO tell cockatrice not to do this so shittily
|
||||
return (user.userLevel & moderatorLevel) === moderatorLevel;
|
||||
|
|
|
|||
|
|
@ -8,7 +8,8 @@ import MenuItem from '@mui/material/MenuItem';
|
|||
import { Images } from 'images/Images';
|
||||
import { SessionService } from 'api';
|
||||
import { ServerSelectors } from 'store';
|
||||
import { RouteEnum, User } from 'types';
|
||||
import { RouteEnum } from 'types';
|
||||
import type { ServerInfo_User } from 'generated/proto/serverinfo_user_pb';
|
||||
import { useAppSelector } from 'store/store';
|
||||
|
||||
import './UserDisplay.css';
|
||||
|
|
@ -87,7 +88,7 @@ const UserDisplay = ({ user }: UserDisplayProps) => {
|
|||
};
|
||||
|
||||
interface UserDisplayProps {
|
||||
user: User;
|
||||
user: ServerInfo_User;
|
||||
}
|
||||
|
||||
export default UserDisplay;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import { SortBy, SortDirection, User } from 'types';
|
||||
import { SortBy, SortDirection } from 'types';
|
||||
import type { ServerInfo_User } from 'generated/proto/serverinfo_user_pb';
|
||||
|
||||
export default class SortUtil {
|
||||
static sortByField<T extends object>(arr: T[], sortBy: SortBy): void {
|
||||
|
|
@ -51,7 +52,7 @@ export default class SortUtil {
|
|||
}
|
||||
}
|
||||
|
||||
static sortUsersByField(users: User[], sortBy: SortBy) {
|
||||
static sortUsersByField(users: ServerInfo_User[], sortBy: SortBy) {
|
||||
if (users.length) {
|
||||
users.sort((a, b) => SortUtil.userComparator(a, b, sortBy))
|
||||
}
|
||||
|
|
@ -75,7 +76,7 @@ export default class SortUtil {
|
|||
arr.sort((a, b) => SortUtil.stringComparator(a, b, sortBy));
|
||||
}
|
||||
|
||||
private static userComparator(a: User, b: User, sortBy: SortBy, sortByUserLevel = true) {
|
||||
private static userComparator(a: ServerInfo_User, b: ServerInfo_User, sortBy: SortBy, sortByUserLevel = true) {
|
||||
if (sortByUserLevel) {
|
||||
const adminSortBy = {
|
||||
field: 'userLevel',
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
import type { ServerInfo_Room } from 'generated/proto/serverinfo_room_pb';
|
||||
import type { ServerInfo_Game } from 'generated/proto/serverinfo_game_pb';
|
||||
import type { ServerInfo_GameType } from 'generated/proto/serverinfo_gametype_pb';
|
||||
import { Game, GametypeMap, LogItem, LogGroups, Message, Room } from 'types';
|
||||
import type { ServerInfo_ChatMessage } from 'generated/proto/serverinfo_chat_message_pb';
|
||||
import { Game, GametypeMap, LogGroups, Message, Room } from 'types';
|
||||
|
||||
/** Flatten a gametype list into a lookup map of { gameTypeId → description }. */
|
||||
export function normalizeGametypeMap(gametypeList: ServerInfo_GameType[]): GametypeMap {
|
||||
|
|
@ -40,7 +41,7 @@ export function normalizeGameObject(game: ServerInfo_Game, gametypeMap: Gametype
|
|||
}
|
||||
|
||||
/** Group a flat LogItem[] into { room, game, chat } buckets for the server store. */
|
||||
export function normalizeLogs(logs: LogItem[]): LogGroups {
|
||||
export function normalizeLogs(logs: ServerInfo_ChatMessage[]): LogGroups {
|
||||
return logs.reduce((obj, log) => {
|
||||
const type = log.targetType as keyof LogGroups;
|
||||
obj[type] = obj[type] || [];
|
||||
|
|
|
|||
|
|
@ -1,4 +1,8 @@
|
|||
import { ArrowInfo, CardInfo, CounterInfo, PlayerProperties, ProtoInit } from 'types';
|
||||
import { ProtoInit } from 'types';
|
||||
import type { ServerInfo_Card } from 'generated/proto/serverinfo_card_pb';
|
||||
import type { ServerInfo_Counter } from 'generated/proto/serverinfo_counter_pb';
|
||||
import type { ServerInfo_Arrow } from 'generated/proto/serverinfo_arrow_pb';
|
||||
import type { ServerInfo_PlayerProperties } from 'generated/proto/serverinfo_playerproperties_pb';
|
||||
import { create } from '@bufbuild/protobuf';
|
||||
import { ServerInfo_CardSchema } from 'generated/proto/serverinfo_card_pb';
|
||||
import { ServerInfo_CounterSchema } from 'generated/proto/serverinfo_counter_pb';
|
||||
|
|
@ -7,7 +11,7 @@ import { ServerInfo_ArrowSchema } from 'generated/proto/serverinfo_arrow_pb';
|
|||
import { ServerInfo_PlayerPropertiesSchema } from 'generated/proto/serverinfo_playerproperties_pb';
|
||||
import { GameEntry, GamesState, PlayerEntry, ZoneEntry } from '../game.interfaces';
|
||||
|
||||
export function makeCard(overrides: ProtoInit<CardInfo> = {}): CardInfo {
|
||||
export function makeCard(overrides: ProtoInit<ServerInfo_Card> = {}): ServerInfo_Card {
|
||||
return create(ServerInfo_CardSchema, {
|
||||
id: 1,
|
||||
name: 'Test Card',
|
||||
|
|
@ -30,7 +34,7 @@ export function makeCard(overrides: ProtoInit<CardInfo> = {}): CardInfo {
|
|||
});
|
||||
}
|
||||
|
||||
export function makeCounter(overrides: ProtoInit<CounterInfo> = {}): CounterInfo {
|
||||
export function makeCounter(overrides: ProtoInit<ServerInfo_Counter> = {}): ServerInfo_Counter {
|
||||
return create(ServerInfo_CounterSchema, {
|
||||
id: 1,
|
||||
name: 'Life',
|
||||
|
|
@ -41,7 +45,7 @@ export function makeCounter(overrides: ProtoInit<CounterInfo> = {}): CounterInfo
|
|||
});
|
||||
}
|
||||
|
||||
export function makeArrow(overrides: ProtoInit<ArrowInfo> = {}): ArrowInfo {
|
||||
export function makeArrow(overrides: ProtoInit<ServerInfo_Arrow> = {}): ServerInfo_Arrow {
|
||||
return create(ServerInfo_ArrowSchema, {
|
||||
id: 1,
|
||||
startPlayerId: 1,
|
||||
|
|
@ -68,7 +72,7 @@ export function makeZoneEntry(overrides: Partial<ZoneEntry> = {}): ZoneEntry {
|
|||
};
|
||||
}
|
||||
|
||||
export function makePlayerProperties(overrides: ProtoInit<PlayerProperties> = {}): PlayerProperties {
|
||||
export function makePlayerProperties(overrides: ProtoInit<ServerInfo_PlayerProperties> = {}): ServerInfo_PlayerProperties {
|
||||
return create(ServerInfo_PlayerPropertiesSchema, {
|
||||
playerId: 1,
|
||||
spectator: false,
|
||||
|
|
|
|||
|
|
@ -1,25 +1,23 @@
|
|||
import {
|
||||
AttachCardData,
|
||||
ChangeZonePropertiesData,
|
||||
CreateArrowData,
|
||||
CreateCounterData,
|
||||
CreateTokenData,
|
||||
DelCounterData,
|
||||
DeleteArrowData,
|
||||
DestroyCardData,
|
||||
DrawCardsData,
|
||||
DumpZoneData,
|
||||
FlipCardData,
|
||||
GameStateChangedData,
|
||||
MoveCardData,
|
||||
PlayerProperties,
|
||||
RevealCardsData,
|
||||
RollDieData,
|
||||
SetCardAttrData,
|
||||
SetCardCounterData,
|
||||
SetCounterData,
|
||||
ShuffleData,
|
||||
} from 'types';
|
||||
import type { Event_AttachCard } from 'generated/proto/event_attach_card_pb';
|
||||
import type { Event_ChangeZoneProperties } from 'generated/proto/event_change_zone_properties_pb';
|
||||
import type { Event_CreateArrow } from 'generated/proto/event_create_arrow_pb';
|
||||
import type { Event_CreateCounter } from 'generated/proto/event_create_counter_pb';
|
||||
import type { Event_CreateToken } from 'generated/proto/event_create_token_pb';
|
||||
import type { Event_DelCounter } from 'generated/proto/event_del_counter_pb';
|
||||
import type { Event_DeleteArrow } from 'generated/proto/event_delete_arrow_pb';
|
||||
import type { Event_DestroyCard } from 'generated/proto/event_destroy_card_pb';
|
||||
import type { Event_DrawCards } from 'generated/proto/event_draw_cards_pb';
|
||||
import type { Event_DumpZone } from 'generated/proto/event_dump_zone_pb';
|
||||
import type { Event_FlipCard } from 'generated/proto/event_flip_card_pb';
|
||||
import type { Event_GameStateChanged } from 'generated/proto/event_game_state_changed_pb';
|
||||
import type { Event_MoveCard } from 'generated/proto/event_move_card_pb';
|
||||
import type { ServerInfo_PlayerProperties } from 'generated/proto/serverinfo_playerproperties_pb';
|
||||
import type { Event_RevealCards } from 'generated/proto/event_reveal_cards_pb';
|
||||
import type { Event_RollDie } from 'generated/proto/event_roll_die_pb';
|
||||
import type { Event_SetCardAttr } from 'generated/proto/event_set_card_attr_pb';
|
||||
import type { Event_SetCardCounter } from 'generated/proto/event_set_card_counter_pb';
|
||||
import type { Event_SetCounter } from 'generated/proto/event_set_counter_pb';
|
||||
import type { Event_Shuffle } from 'generated/proto/event_shuffle_pb';
|
||||
import { GameEntry } from './game.interfaces';
|
||||
import { Types } from './game.types';
|
||||
|
||||
|
|
@ -50,13 +48,13 @@ export const Actions = {
|
|||
hostId,
|
||||
}),
|
||||
|
||||
gameStateChanged: (gameId: number, data: GameStateChangedData) => ({
|
||||
gameStateChanged: (gameId: number, data: Event_GameStateChanged) => ({
|
||||
type: Types.GAME_STATE_CHANGED,
|
||||
gameId,
|
||||
data,
|
||||
}),
|
||||
|
||||
playerJoined: (gameId: number, playerProperties: PlayerProperties) => ({
|
||||
playerJoined: (gameId: number, playerProperties: ServerInfo_PlayerProperties) => ({
|
||||
type: Types.PLAYER_JOINED,
|
||||
gameId,
|
||||
playerProperties,
|
||||
|
|
@ -69,7 +67,7 @@ export const Actions = {
|
|||
reason,
|
||||
}),
|
||||
|
||||
playerPropertiesChanged: (gameId: number, playerId: number, properties: PlayerProperties) => ({
|
||||
playerPropertiesChanged: (gameId: number, playerId: number, properties: ServerInfo_PlayerProperties) => ({
|
||||
type: Types.PLAYER_PROPERTIES_CHANGED,
|
||||
gameId,
|
||||
playerId,
|
||||
|
|
@ -81,112 +79,112 @@ export const Actions = {
|
|||
gameId,
|
||||
}),
|
||||
|
||||
cardMoved: (gameId: number, playerId: number, data: MoveCardData) => ({
|
||||
cardMoved: (gameId: number, playerId: number, data: Event_MoveCard) => ({
|
||||
type: Types.CARD_MOVED,
|
||||
gameId,
|
||||
playerId,
|
||||
data,
|
||||
}),
|
||||
|
||||
cardFlipped: (gameId: number, playerId: number, data: FlipCardData) => ({
|
||||
cardFlipped: (gameId: number, playerId: number, data: Event_FlipCard) => ({
|
||||
type: Types.CARD_FLIPPED,
|
||||
gameId,
|
||||
playerId,
|
||||
data,
|
||||
}),
|
||||
|
||||
cardDestroyed: (gameId: number, playerId: number, data: DestroyCardData) => ({
|
||||
cardDestroyed: (gameId: number, playerId: number, data: Event_DestroyCard) => ({
|
||||
type: Types.CARD_DESTROYED,
|
||||
gameId,
|
||||
playerId,
|
||||
data,
|
||||
}),
|
||||
|
||||
cardAttached: (gameId: number, playerId: number, data: AttachCardData) => ({
|
||||
cardAttached: (gameId: number, playerId: number, data: Event_AttachCard) => ({
|
||||
type: Types.CARD_ATTACHED,
|
||||
gameId,
|
||||
playerId,
|
||||
data,
|
||||
}),
|
||||
|
||||
tokenCreated: (gameId: number, playerId: number, data: CreateTokenData) => ({
|
||||
tokenCreated: (gameId: number, playerId: number, data: Event_CreateToken) => ({
|
||||
type: Types.TOKEN_CREATED,
|
||||
gameId,
|
||||
playerId,
|
||||
data,
|
||||
}),
|
||||
|
||||
cardAttrChanged: (gameId: number, playerId: number, data: SetCardAttrData) => ({
|
||||
cardAttrChanged: (gameId: number, playerId: number, data: Event_SetCardAttr) => ({
|
||||
type: Types.CARD_ATTR_CHANGED,
|
||||
gameId,
|
||||
playerId,
|
||||
data,
|
||||
}),
|
||||
|
||||
cardCounterChanged: (gameId: number, playerId: number, data: SetCardCounterData) => ({
|
||||
cardCounterChanged: (gameId: number, playerId: number, data: Event_SetCardCounter) => ({
|
||||
type: Types.CARD_COUNTER_CHANGED,
|
||||
gameId,
|
||||
playerId,
|
||||
data,
|
||||
}),
|
||||
|
||||
arrowCreated: (gameId: number, playerId: number, data: CreateArrowData) => ({
|
||||
arrowCreated: (gameId: number, playerId: number, data: Event_CreateArrow) => ({
|
||||
type: Types.ARROW_CREATED,
|
||||
gameId,
|
||||
playerId,
|
||||
data,
|
||||
}),
|
||||
|
||||
arrowDeleted: (gameId: number, playerId: number, data: DeleteArrowData) => ({
|
||||
arrowDeleted: (gameId: number, playerId: number, data: Event_DeleteArrow) => ({
|
||||
type: Types.ARROW_DELETED,
|
||||
gameId,
|
||||
playerId,
|
||||
data,
|
||||
}),
|
||||
|
||||
counterCreated: (gameId: number, playerId: number, data: CreateCounterData) => ({
|
||||
counterCreated: (gameId: number, playerId: number, data: Event_CreateCounter) => ({
|
||||
type: Types.COUNTER_CREATED,
|
||||
gameId,
|
||||
playerId,
|
||||
data,
|
||||
}),
|
||||
|
||||
counterSet: (gameId: number, playerId: number, data: SetCounterData) => ({
|
||||
counterSet: (gameId: number, playerId: number, data: Event_SetCounter) => ({
|
||||
type: Types.COUNTER_SET,
|
||||
gameId,
|
||||
playerId,
|
||||
data,
|
||||
}),
|
||||
|
||||
counterDeleted: (gameId: number, playerId: number, data: DelCounterData) => ({
|
||||
counterDeleted: (gameId: number, playerId: number, data: Event_DelCounter) => ({
|
||||
type: Types.COUNTER_DELETED,
|
||||
gameId,
|
||||
playerId,
|
||||
data,
|
||||
}),
|
||||
|
||||
cardsDrawn: (gameId: number, playerId: number, data: DrawCardsData) => ({
|
||||
cardsDrawn: (gameId: number, playerId: number, data: Event_DrawCards) => ({
|
||||
type: Types.CARDS_DRAWN,
|
||||
gameId,
|
||||
playerId,
|
||||
data,
|
||||
}),
|
||||
|
||||
cardsRevealed: (gameId: number, playerId: number, data: RevealCardsData) => ({
|
||||
cardsRevealed: (gameId: number, playerId: number, data: Event_RevealCards) => ({
|
||||
type: Types.CARDS_REVEALED,
|
||||
gameId,
|
||||
playerId,
|
||||
data,
|
||||
}),
|
||||
|
||||
zoneShuffled: (gameId: number, playerId: number, data: ShuffleData) => ({
|
||||
zoneShuffled: (gameId: number, playerId: number, data: Event_Shuffle) => ({
|
||||
type: Types.ZONE_SHUFFLED,
|
||||
gameId,
|
||||
playerId,
|
||||
data,
|
||||
}),
|
||||
|
||||
dieRolled: (gameId: number, playerId: number, data: RollDieData) => ({
|
||||
dieRolled: (gameId: number, playerId: number, data: Event_RollDie) => ({
|
||||
type: Types.DIE_ROLLED,
|
||||
gameId,
|
||||
playerId,
|
||||
|
|
@ -211,14 +209,14 @@ export const Actions = {
|
|||
reversed,
|
||||
}),
|
||||
|
||||
zoneDumped: (gameId: number, playerId: number, data: DumpZoneData) => ({
|
||||
zoneDumped: (gameId: number, playerId: number, data: Event_DumpZone) => ({
|
||||
type: Types.ZONE_DUMPED,
|
||||
gameId,
|
||||
playerId,
|
||||
data,
|
||||
}),
|
||||
|
||||
zonePropertiesChanged: (gameId: number, playerId: number, data: ChangeZonePropertiesData) => ({
|
||||
zonePropertiesChanged: (gameId: number, playerId: number, data: Event_ChangeZoneProperties) => ({
|
||||
type: Types.ZONE_PROPERTIES_CHANGED,
|
||||
gameId,
|
||||
playerId,
|
||||
|
|
|
|||
|
|
@ -1,25 +1,23 @@
|
|||
import {
|
||||
AttachCardData,
|
||||
ChangeZonePropertiesData,
|
||||
CreateArrowData,
|
||||
CreateCounterData,
|
||||
CreateTokenData,
|
||||
DelCounterData,
|
||||
DeleteArrowData,
|
||||
DestroyCardData,
|
||||
DrawCardsData,
|
||||
DumpZoneData,
|
||||
FlipCardData,
|
||||
GameStateChangedData,
|
||||
MoveCardData,
|
||||
PlayerProperties,
|
||||
RevealCardsData,
|
||||
RollDieData,
|
||||
SetCardAttrData,
|
||||
SetCardCounterData,
|
||||
SetCounterData,
|
||||
ShuffleData,
|
||||
} from 'types';
|
||||
import type { Event_AttachCard } from 'generated/proto/event_attach_card_pb';
|
||||
import type { Event_ChangeZoneProperties } from 'generated/proto/event_change_zone_properties_pb';
|
||||
import type { Event_CreateArrow } from 'generated/proto/event_create_arrow_pb';
|
||||
import type { Event_CreateCounter } from 'generated/proto/event_create_counter_pb';
|
||||
import type { Event_CreateToken } from 'generated/proto/event_create_token_pb';
|
||||
import type { Event_DelCounter } from 'generated/proto/event_del_counter_pb';
|
||||
import type { Event_DeleteArrow } from 'generated/proto/event_delete_arrow_pb';
|
||||
import type { Event_DestroyCard } from 'generated/proto/event_destroy_card_pb';
|
||||
import type { Event_DrawCards } from 'generated/proto/event_draw_cards_pb';
|
||||
import type { Event_DumpZone } from 'generated/proto/event_dump_zone_pb';
|
||||
import type { Event_FlipCard } from 'generated/proto/event_flip_card_pb';
|
||||
import type { Event_GameStateChanged } from 'generated/proto/event_game_state_changed_pb';
|
||||
import type { Event_MoveCard } from 'generated/proto/event_move_card_pb';
|
||||
import type { ServerInfo_PlayerProperties } from 'generated/proto/serverinfo_playerproperties_pb';
|
||||
import type { Event_RevealCards } from 'generated/proto/event_reveal_cards_pb';
|
||||
import type { Event_RollDie } from 'generated/proto/event_roll_die_pb';
|
||||
import type { Event_SetCardAttr } from 'generated/proto/event_set_card_attr_pb';
|
||||
import type { Event_SetCardCounter } from 'generated/proto/event_set_card_counter_pb';
|
||||
import type { Event_SetCounter } from 'generated/proto/event_set_counter_pb';
|
||||
import type { Event_Shuffle } from 'generated/proto/event_shuffle_pb';
|
||||
import { store } from 'store/store';
|
||||
import { Actions } from './game.actions';
|
||||
import { GameEntry } from './game.interfaces';
|
||||
|
|
@ -45,11 +43,11 @@ export const Dispatch = {
|
|||
store.dispatch(Actions.gameHostChanged(gameId, hostId));
|
||||
},
|
||||
|
||||
gameStateChanged: (gameId: number, data: GameStateChangedData) => {
|
||||
gameStateChanged: (gameId: number, data: Event_GameStateChanged) => {
|
||||
store.dispatch(Actions.gameStateChanged(gameId, data));
|
||||
},
|
||||
|
||||
playerJoined: (gameId: number, playerProperties: PlayerProperties) => {
|
||||
playerJoined: (gameId: number, playerProperties: ServerInfo_PlayerProperties) => {
|
||||
store.dispatch(Actions.playerJoined(gameId, playerProperties));
|
||||
},
|
||||
|
||||
|
|
@ -57,7 +55,7 @@ export const Dispatch = {
|
|||
store.dispatch(Actions.playerLeft(gameId, playerId, reason));
|
||||
},
|
||||
|
||||
playerPropertiesChanged: (gameId: number, playerId: number, properties: PlayerProperties) => {
|
||||
playerPropertiesChanged: (gameId: number, playerId: number, properties: ServerInfo_PlayerProperties) => {
|
||||
store.dispatch(Actions.playerPropertiesChanged(gameId, playerId, properties));
|
||||
},
|
||||
|
||||
|
|
@ -65,67 +63,67 @@ export const Dispatch = {
|
|||
store.dispatch(Actions.kicked(gameId));
|
||||
},
|
||||
|
||||
cardMoved: (gameId: number, playerId: number, data: MoveCardData) => {
|
||||
cardMoved: (gameId: number, playerId: number, data: Event_MoveCard) => {
|
||||
store.dispatch(Actions.cardMoved(gameId, playerId, data));
|
||||
},
|
||||
|
||||
cardFlipped: (gameId: number, playerId: number, data: FlipCardData) => {
|
||||
cardFlipped: (gameId: number, playerId: number, data: Event_FlipCard) => {
|
||||
store.dispatch(Actions.cardFlipped(gameId, playerId, data));
|
||||
},
|
||||
|
||||
cardDestroyed: (gameId: number, playerId: number, data: DestroyCardData) => {
|
||||
cardDestroyed: (gameId: number, playerId: number, data: Event_DestroyCard) => {
|
||||
store.dispatch(Actions.cardDestroyed(gameId, playerId, data));
|
||||
},
|
||||
|
||||
cardAttached: (gameId: number, playerId: number, data: AttachCardData) => {
|
||||
cardAttached: (gameId: number, playerId: number, data: Event_AttachCard) => {
|
||||
store.dispatch(Actions.cardAttached(gameId, playerId, data));
|
||||
},
|
||||
|
||||
tokenCreated: (gameId: number, playerId: number, data: CreateTokenData) => {
|
||||
tokenCreated: (gameId: number, playerId: number, data: Event_CreateToken) => {
|
||||
store.dispatch(Actions.tokenCreated(gameId, playerId, data));
|
||||
},
|
||||
|
||||
cardAttrChanged: (gameId: number, playerId: number, data: SetCardAttrData) => {
|
||||
cardAttrChanged: (gameId: number, playerId: number, data: Event_SetCardAttr) => {
|
||||
store.dispatch(Actions.cardAttrChanged(gameId, playerId, data));
|
||||
},
|
||||
|
||||
cardCounterChanged: (gameId: number, playerId: number, data: SetCardCounterData) => {
|
||||
cardCounterChanged: (gameId: number, playerId: number, data: Event_SetCardCounter) => {
|
||||
store.dispatch(Actions.cardCounterChanged(gameId, playerId, data));
|
||||
},
|
||||
|
||||
arrowCreated: (gameId: number, playerId: number, data: CreateArrowData) => {
|
||||
arrowCreated: (gameId: number, playerId: number, data: Event_CreateArrow) => {
|
||||
store.dispatch(Actions.arrowCreated(gameId, playerId, data));
|
||||
},
|
||||
|
||||
arrowDeleted: (gameId: number, playerId: number, data: DeleteArrowData) => {
|
||||
arrowDeleted: (gameId: number, playerId: number, data: Event_DeleteArrow) => {
|
||||
store.dispatch(Actions.arrowDeleted(gameId, playerId, data));
|
||||
},
|
||||
|
||||
counterCreated: (gameId: number, playerId: number, data: CreateCounterData) => {
|
||||
counterCreated: (gameId: number, playerId: number, data: Event_CreateCounter) => {
|
||||
store.dispatch(Actions.counterCreated(gameId, playerId, data));
|
||||
},
|
||||
|
||||
counterSet: (gameId: number, playerId: number, data: SetCounterData) => {
|
||||
counterSet: (gameId: number, playerId: number, data: Event_SetCounter) => {
|
||||
store.dispatch(Actions.counterSet(gameId, playerId, data));
|
||||
},
|
||||
|
||||
counterDeleted: (gameId: number, playerId: number, data: DelCounterData) => {
|
||||
counterDeleted: (gameId: number, playerId: number, data: Event_DelCounter) => {
|
||||
store.dispatch(Actions.counterDeleted(gameId, playerId, data));
|
||||
},
|
||||
|
||||
cardsDrawn: (gameId: number, playerId: number, data: DrawCardsData) => {
|
||||
cardsDrawn: (gameId: number, playerId: number, data: Event_DrawCards) => {
|
||||
store.dispatch(Actions.cardsDrawn(gameId, playerId, data));
|
||||
},
|
||||
|
||||
cardsRevealed: (gameId: number, playerId: number, data: RevealCardsData) => {
|
||||
cardsRevealed: (gameId: number, playerId: number, data: Event_RevealCards) => {
|
||||
store.dispatch(Actions.cardsRevealed(gameId, playerId, data));
|
||||
},
|
||||
|
||||
zoneShuffled: (gameId: number, playerId: number, data: ShuffleData) => {
|
||||
zoneShuffled: (gameId: number, playerId: number, data: Event_Shuffle) => {
|
||||
store.dispatch(Actions.zoneShuffled(gameId, playerId, data));
|
||||
},
|
||||
|
||||
dieRolled: (gameId: number, playerId: number, data: RollDieData) => {
|
||||
dieRolled: (gameId: number, playerId: number, data: Event_RollDie) => {
|
||||
store.dispatch(Actions.dieRolled(gameId, playerId, data));
|
||||
},
|
||||
|
||||
|
|
@ -141,11 +139,11 @@ export const Dispatch = {
|
|||
store.dispatch(Actions.turnReversed(gameId, reversed));
|
||||
},
|
||||
|
||||
zoneDumped: (gameId: number, playerId: number, data: DumpZoneData) => {
|
||||
zoneDumped: (gameId: number, playerId: number, data: Event_DumpZone) => {
|
||||
store.dispatch(Actions.zoneDumped(gameId, playerId, data));
|
||||
},
|
||||
|
||||
zonePropertiesChanged: (gameId: number, playerId: number, data: ChangeZonePropertiesData) => {
|
||||
zonePropertiesChanged: (gameId: number, playerId: number, data: Event_ChangeZoneProperties) => {
|
||||
store.dispatch(Actions.zonePropertiesChanged(gameId, playerId, data));
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,7 @@
|
|||
import { ArrowInfo, CardInfo, CounterInfo, PlayerProperties } from 'types';
|
||||
import type { ServerInfo_Card } from 'generated/proto/serverinfo_card_pb';
|
||||
import type { ServerInfo_Counter } from 'generated/proto/serverinfo_counter_pb';
|
||||
import type { ServerInfo_Arrow } from 'generated/proto/serverinfo_arrow_pb';
|
||||
import type { ServerInfo_PlayerProperties } from 'generated/proto/serverinfo_playerproperties_pb';
|
||||
|
||||
export interface GamesState {
|
||||
games: { [gameId: number]: GameEntry };
|
||||
|
|
@ -29,14 +32,14 @@ export interface GameEntry {
|
|||
|
||||
/** Normalized from ServerInfo_Player — keyed collections for O(1) lookup. */
|
||||
export interface PlayerEntry {
|
||||
properties: PlayerProperties;
|
||||
properties: ServerInfo_PlayerProperties;
|
||||
deckList: string;
|
||||
/** Zones keyed by zone name (e.g. "hand", "deck", "table"). */
|
||||
zones: { [zoneName: string]: ZoneEntry };
|
||||
/** Player-level counters (e.g. life) keyed by counter id. */
|
||||
counters: { [counterId: number]: CounterInfo };
|
||||
counters: { [counterId: number]: ServerInfo_Counter };
|
||||
/** Arrows keyed by arrow id. */
|
||||
arrows: { [arrowId: number]: ArrowInfo };
|
||||
arrows: { [arrowId: number]: ServerInfo_Arrow };
|
||||
}
|
||||
|
||||
/** Normalized from ServerInfo_Zone — card list is an ordered array matching proto. */
|
||||
|
|
@ -48,7 +51,7 @@ export interface ZoneEntry {
|
|||
/** Authoritative card count (used for hidden zones where cardList may be empty). */
|
||||
cardCount: number;
|
||||
/** Ordered card list; may be empty for hidden zones with no dump active. */
|
||||
cards: CardInfo[];
|
||||
cards: ServerInfo_Card[];
|
||||
alwaysRevealTopCard: boolean;
|
||||
alwaysLookAtTopCard: boolean;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import { create } from '@bufbuild/protobuf';
|
||||
import { CardAttribute, PlayerInfo } from 'types';
|
||||
import { CardAttribute } from 'generated/proto/card_attributes_pb';
|
||||
import type { ServerInfo_Player } from 'generated/proto/serverinfo_player_pb';
|
||||
import { gamesReducer } from './game.reducer';
|
||||
import { Types } from './game.types';
|
||||
import {
|
||||
|
|
@ -68,7 +69,7 @@ describe('2B: Game state & player management', () => {
|
|||
const card = makeCard({ id: 5 });
|
||||
const counter = makeCounter({ id: 2 });
|
||||
const arrow = makeArrow({ id: 3 });
|
||||
const playerList: PlayerInfo[] = [
|
||||
const playerList: ServerInfo_Player[] = [
|
||||
create(ServerInfo_PlayerSchema, {
|
||||
properties: makePlayerProperties({ playerId: 7 }),
|
||||
deckList: 'some deck',
|
||||
|
|
|
|||
|
|
@ -1,12 +1,9 @@
|
|||
import {
|
||||
ArrowInfo,
|
||||
CardAttribute,
|
||||
CardCounterInfo,
|
||||
CardInfo,
|
||||
CounterInfo,
|
||||
PlayerInfo,
|
||||
PlayerProperties,
|
||||
} from 'types';
|
||||
import { CardAttribute } from 'generated/proto/card_attributes_pb';
|
||||
import type { ServerInfo_CardCounter } from 'generated/proto/serverinfo_cardcounter_pb';
|
||||
import type { ServerInfo_Card } from 'generated/proto/serverinfo_card_pb';
|
||||
import type { ServerInfo_Counter } from 'generated/proto/serverinfo_counter_pb';
|
||||
import type { ServerInfo_Arrow } from 'generated/proto/serverinfo_arrow_pb';
|
||||
import type { ServerInfo_Player } from 'generated/proto/serverinfo_player_pb';
|
||||
import { create } from '@bufbuild/protobuf';
|
||||
import { ServerInfo_CardSchema } from 'generated/proto/serverinfo_card_pb';
|
||||
import { ServerInfo_CardCounterSchema } from 'generated/proto/serverinfo_cardcounter_pb';
|
||||
|
|
@ -77,7 +74,7 @@ function removeGame(state: GamesState, gameId: number): GamesState {
|
|||
}
|
||||
|
||||
/** Converts the proto PlayerInfo[] array into the keyed PlayerEntry map used in the store. */
|
||||
function normalizePlayers(playerList: PlayerInfo[]): { [playerId: number]: PlayerEntry } {
|
||||
function normalizePlayers(playerList: ServerInfo_Player[]): { [playerId: number]: PlayerEntry } {
|
||||
const players: { [playerId: number]: PlayerEntry } = {};
|
||||
for (const player of playerList) {
|
||||
const playerId = player.properties.playerId;
|
||||
|
|
@ -95,12 +92,12 @@ function normalizePlayers(playerList: PlayerInfo[]): { [playerId: number]: Playe
|
|||
};
|
||||
}
|
||||
|
||||
const counters: { [counterId: number]: CounterInfo } = {};
|
||||
const counters: { [counterId: number]: ServerInfo_Counter } = {};
|
||||
for (const counter of player.counterList) {
|
||||
counters[counter.id] = counter;
|
||||
}
|
||||
|
||||
const arrows: { [arrowId: number]: ArrowInfo } = {};
|
||||
const arrows: { [arrowId: number]: ServerInfo_Arrow } = {};
|
||||
for (const arrow of player.arrowList) {
|
||||
arrows[arrow.id] = arrow;
|
||||
}
|
||||
|
|
@ -123,7 +120,7 @@ function buildEmptyCard(
|
|||
y: number,
|
||||
faceDown: boolean,
|
||||
providerId: string
|
||||
): CardInfo {
|
||||
): ServerInfo_Card {
|
||||
return create(ServerInfo_CardSchema, {
|
||||
id,
|
||||
name,
|
||||
|
|
@ -209,7 +206,7 @@ export const gamesReducer = (state: GamesState = initialState, action: GameActio
|
|||
return state;
|
||||
}
|
||||
const newPlayer: PlayerEntry = {
|
||||
properties: playerProperties as PlayerProperties,
|
||||
properties: playerProperties,
|
||||
deckList: '',
|
||||
zones: {},
|
||||
counters: {},
|
||||
|
|
@ -269,8 +266,8 @@ export const gamesReducer = (state: GamesState = initialState, action: GameActio
|
|||
}
|
||||
|
||||
// Locate card in source zone (by id for visible zones, by position for hidden)
|
||||
let removedCard: CardInfo | undefined;
|
||||
let newSourceCards: CardInfo[];
|
||||
let removedCard: ServerInfo_Card | undefined;
|
||||
let newSourceCards: ServerInfo_Card[];
|
||||
if (cardId >= 0) {
|
||||
removedCard = sourceZoneEntry.cards.find(c => c.id === cardId);
|
||||
newSourceCards = sourceZoneEntry.cards.filter(c => c.id !== cardId);
|
||||
|
|
@ -283,7 +280,7 @@ export const gamesReducer = (state: GamesState = initialState, action: GameActio
|
|||
}
|
||||
|
||||
const effectiveNewId = newCardId >= 0 ? newCardId : (removedCard?.id ?? -1);
|
||||
const movedCard: CardInfo = removedCard
|
||||
const movedCard: ServerInfo_Card = removedCard
|
||||
? {
|
||||
...removedCard,
|
||||
id: effectiveNewId,
|
||||
|
|
@ -426,7 +423,7 @@ export const gamesReducer = (state: GamesState = initialState, action: GameActio
|
|||
return state;
|
||||
}
|
||||
|
||||
const newCard: CardInfo = create(ServerInfo_CardSchema, {
|
||||
const newCard: ServerInfo_Card = create(ServerInfo_CardSchema, {
|
||||
id: cardId,
|
||||
name: cardName,
|
||||
x,
|
||||
|
|
@ -472,7 +469,7 @@ export const gamesReducer = (state: GamesState = initialState, action: GameActio
|
|||
return state;
|
||||
}
|
||||
|
||||
const attrPatch: Partial<CardInfo> = {};
|
||||
const attrPatch: Partial<ServerInfo_Card> = {};
|
||||
switch (attribute as CardAttribute) {
|
||||
case CardAttribute.AttrTapped: attrPatch.tapped = attrValue === '1'; break;
|
||||
case CardAttribute.AttrAttacking: attrPatch.attacking = attrValue === '1'; break;
|
||||
|
|
@ -510,7 +507,7 @@ export const gamesReducer = (state: GamesState = initialState, action: GameActio
|
|||
}
|
||||
|
||||
const card = zone.cards[cardIdx];
|
||||
let newCounterList: CardCounterInfo[];
|
||||
let newCounterList: ServerInfo_CardCounter[];
|
||||
if (counterValue <= 0) {
|
||||
newCounterList = card.counterList.filter(c => c.id !== counterId);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
import { createSelector } from '@reduxjs/toolkit';
|
||||
import { CardInfo } from 'types';
|
||||
import type { ServerInfo_Card } from 'generated/proto/serverinfo_card_pb';
|
||||
import { GamesState, GameEntry, PlayerEntry, ZoneEntry } from './game.interfaces';
|
||||
|
||||
interface State {
|
||||
games: GamesState;
|
||||
}
|
||||
|
||||
const EMPTY_ARRAY: CardInfo[] = [];
|
||||
const EMPTY_ARRAY: ServerInfo_Card[] = [];
|
||||
const EMPTY_OBJECT = {} as Record<string, never>;
|
||||
|
||||
export const Selectors = {
|
||||
|
|
|
|||
|
|
@ -5,16 +5,16 @@ import {
|
|||
ProtoInit,
|
||||
Room,
|
||||
SortDirection,
|
||||
User,
|
||||
UserSortField,
|
||||
} from 'types';
|
||||
import type { ServerInfo_User } from 'generated/proto/serverinfo_user_pb';
|
||||
import { create } from '@bufbuild/protobuf';
|
||||
import { ServerInfo_UserSchema } from 'generated/proto/serverinfo_user_pb';
|
||||
import { ServerInfo_GameSchema } from 'generated/proto/serverinfo_game_pb';
|
||||
import { ServerInfo_RoomSchema } from 'generated/proto/serverinfo_room_pb';
|
||||
import { RoomsState } from '../rooms.interfaces';
|
||||
|
||||
export function makeUser(overrides: ProtoInit<User> = {}): User {
|
||||
export function makeUser(overrides: ProtoInit<ServerInfo_User> = {}): ServerInfo_User {
|
||||
return create(ServerInfo_UserSchema, {
|
||||
name: 'TestUser',
|
||||
accountageSecs: 0n,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import { GameSortField, Message, SortDirection, User } from 'types';
|
||||
import { GameSortField, Message, SortDirection } from 'types';
|
||||
import type { ServerInfo_User } from 'generated/proto/serverinfo_user_pb';
|
||||
import type { ServerInfo_Room } from 'generated/proto/serverinfo_room_pb';
|
||||
import type { ServerInfo_Game } from 'generated/proto/serverinfo_game_pb';
|
||||
|
||||
|
|
@ -36,7 +37,7 @@ export const Actions = {
|
|||
games,
|
||||
}),
|
||||
|
||||
userJoined: (roomId: number, user: User) => ({
|
||||
userJoined: (roomId: number, user: ServerInfo_User) => ({
|
||||
type: Types.USER_JOINED,
|
||||
roomId,
|
||||
user,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import { GameSortField, Message, SortDirection, User } from 'types';
|
||||
import { GameSortField, Message, SortDirection } from 'types';
|
||||
import type { ServerInfo_User } from 'generated/proto/serverinfo_user_pb';
|
||||
import type { ServerInfo_Room } from 'generated/proto/serverinfo_room_pb';
|
||||
import type { ServerInfo_Game } from 'generated/proto/serverinfo_game_pb';
|
||||
|
||||
|
|
@ -31,7 +32,7 @@ export const Dispatch = {
|
|||
store.dispatch(Actions.updateGames(roomId, games));
|
||||
},
|
||||
|
||||
userJoined: (roomId: number, user: User) => {
|
||||
userJoined: (roomId: number, user: ServerInfo_User) => {
|
||||
store.dispatch(Actions.userJoined(roomId, user));
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -1,19 +1,19 @@
|
|||
import {
|
||||
BanHistoryItem,
|
||||
DeckList,
|
||||
DeckStorageTreeItem,
|
||||
Game,
|
||||
LogItem,
|
||||
ProtoInit,
|
||||
ReplayMatch,
|
||||
SortDirection,
|
||||
StatusEnum,
|
||||
User,
|
||||
UserSortField,
|
||||
WebSocketConnectOptions,
|
||||
WarnHistoryItem,
|
||||
WarnListItem,
|
||||
} from 'types';
|
||||
import type { ServerInfo_User } from 'generated/proto/serverinfo_user_pb';
|
||||
import type { ServerInfo_Ban } from 'generated/proto/serverinfo_ban_pb';
|
||||
import type { ServerInfo_Warning } from 'generated/proto/serverinfo_warning_pb';
|
||||
import type { Response_WarnList } from 'generated/proto/response_warn_list_pb';
|
||||
import type { ServerInfo_ReplayMatch } from 'generated/proto/serverinfo_replay_match_pb';
|
||||
import type { ServerInfo_ChatMessage } from 'generated/proto/serverinfo_chat_message_pb';
|
||||
import type { Response_DeckList } from 'generated/proto/response_deck_list_pb';
|
||||
import type { ServerInfo_DeckStorage_TreeItem } from 'generated/proto/serverinfo_deckstorage_pb';
|
||||
import { create } from '@bufbuild/protobuf';
|
||||
import { ServerInfo_GameSchema } from 'generated/proto/serverinfo_game_pb';
|
||||
import { ServerInfo_UserSchema } from 'generated/proto/serverinfo_user_pb';
|
||||
|
|
@ -26,7 +26,7 @@ import { ServerInfo_DeckStorage_TreeItemSchema, ServerInfo_DeckStorage_FolderSch
|
|||
import { Response_DeckListSchema } from 'generated/proto/response_deck_list_pb';
|
||||
import { ServerState } from '../server.interfaces';
|
||||
|
||||
export function makeUser(overrides: ProtoInit<User> = {}): User {
|
||||
export function makeUser(overrides: ProtoInit<ServerInfo_User> = {}): ServerInfo_User {
|
||||
return create(ServerInfo_UserSchema, {
|
||||
name: 'TestUser',
|
||||
accountageSecs: 0n,
|
||||
|
|
@ -36,7 +36,7 @@ export function makeUser(overrides: ProtoInit<User> = {}): User {
|
|||
});
|
||||
}
|
||||
|
||||
export function makeLogItem(overrides: ProtoInit<LogItem> = {}): LogItem {
|
||||
export function makeLogItem(overrides: ProtoInit<ServerInfo_ChatMessage> = {}): ServerInfo_ChatMessage {
|
||||
return create(ServerInfo_ChatMessageSchema, {
|
||||
message: '',
|
||||
senderId: '',
|
||||
|
|
@ -50,7 +50,7 @@ export function makeLogItem(overrides: ProtoInit<LogItem> = {}): LogItem {
|
|||
});
|
||||
}
|
||||
|
||||
export function makeBanHistoryItem(overrides: ProtoInit<BanHistoryItem> = {}): BanHistoryItem {
|
||||
export function makeBanHistoryItem(overrides: ProtoInit<ServerInfo_Ban> = {}): ServerInfo_Ban {
|
||||
return create(ServerInfo_BanSchema, {
|
||||
adminId: '',
|
||||
adminName: '',
|
||||
|
|
@ -62,7 +62,7 @@ export function makeBanHistoryItem(overrides: ProtoInit<BanHistoryItem> = {}): B
|
|||
});
|
||||
}
|
||||
|
||||
export function makeWarnHistoryItem(overrides: ProtoInit<WarnHistoryItem> = {}): WarnHistoryItem {
|
||||
export function makeWarnHistoryItem(overrides: ProtoInit<ServerInfo_Warning> = {}): ServerInfo_Warning {
|
||||
return create(ServerInfo_WarningSchema, {
|
||||
userName: '',
|
||||
adminName: '',
|
||||
|
|
@ -72,7 +72,7 @@ export function makeWarnHistoryItem(overrides: ProtoInit<WarnHistoryItem> = {}):
|
|||
});
|
||||
}
|
||||
|
||||
export function makeWarnListItem(overrides: ProtoInit<WarnListItem> = {}): WarnListItem {
|
||||
export function makeWarnListItem(overrides: ProtoInit<Response_WarnList> = {}): Response_WarnList {
|
||||
return create(Response_WarnListSchema, {
|
||||
warning: [],
|
||||
userName: '',
|
||||
|
|
@ -81,7 +81,7 @@ export function makeWarnListItem(overrides: ProtoInit<WarnListItem> = {}): WarnL
|
|||
});
|
||||
}
|
||||
|
||||
export function makeDeckTreeItem(overrides: ProtoInit<DeckStorageTreeItem> = {}): DeckStorageTreeItem {
|
||||
export function makeDeckTreeItem(overrides: ProtoInit<ServerInfo_DeckStorage_TreeItem> = {}): ServerInfo_DeckStorage_TreeItem {
|
||||
return create(ServerInfo_DeckStorage_TreeItemSchema, {
|
||||
id: 1,
|
||||
name: 'item',
|
||||
|
|
@ -89,14 +89,14 @@ export function makeDeckTreeItem(overrides: ProtoInit<DeckStorageTreeItem> = {})
|
|||
});
|
||||
}
|
||||
|
||||
export function makeDeckList(overrides: ProtoInit<DeckList> = {}): DeckList {
|
||||
export function makeDeckList(overrides: ProtoInit<Response_DeckList> = {}): Response_DeckList {
|
||||
return create(Response_DeckListSchema, {
|
||||
root: create(ServerInfo_DeckStorage_FolderSchema, { items: [] }),
|
||||
...overrides,
|
||||
});
|
||||
}
|
||||
|
||||
export function makeReplayMatch(overrides: ProtoInit<ReplayMatch> = {}): ReplayMatch {
|
||||
export function makeReplayMatch(overrides: ProtoInit<ServerInfo_ReplayMatch> = {}): ServerInfo_ReplayMatch {
|
||||
return create(ServerInfo_ReplayMatchSchema, {
|
||||
gameId: 1,
|
||||
roomName: 'Test Room',
|
||||
|
|
|
|||
|
|
@ -1,7 +1,14 @@
|
|||
import {
|
||||
BanHistoryItem, DeckList, DeckStorageTreeItem, GametypeMap, LogItem, ReplayMatch,
|
||||
User, WebSocketConnectOptions, WarnHistoryItem, WarnListItem
|
||||
GametypeMap, WebSocketConnectOptions
|
||||
} from 'types';
|
||||
import type { ServerInfo_User } from 'generated/proto/serverinfo_user_pb';
|
||||
import type { ServerInfo_Ban } from 'generated/proto/serverinfo_ban_pb';
|
||||
import type { ServerInfo_Warning } from 'generated/proto/serverinfo_warning_pb';
|
||||
import type { Response_WarnList } from 'generated/proto/response_warn_list_pb';
|
||||
import type { ServerInfo_ReplayMatch } from 'generated/proto/serverinfo_replay_match_pb';
|
||||
import type { Response_DeckList } from 'generated/proto/response_deck_list_pb';
|
||||
import type { ServerInfo_DeckStorage_TreeItem } from 'generated/proto/serverinfo_deckstorage_pb';
|
||||
import type { ServerInfo_ChatMessage } from 'generated/proto/serverinfo_chat_message_pb';
|
||||
import type { ServerInfo_Game } from 'generated/proto/serverinfo_game_pb';
|
||||
import { NotifyUserData, ServerShutdownData, UserMessageData } from 'websocket/events/session/interfaces';
|
||||
import { ServerStateStatus } from './server.interfaces';
|
||||
|
|
@ -41,11 +48,11 @@ export const Actions = {
|
|||
type: Types.SERVER_MESSAGE,
|
||||
message
|
||||
}),
|
||||
updateBuddyList: (buddyList: User[]) => ({
|
||||
updateBuddyList: (buddyList: ServerInfo_User[]) => ({
|
||||
type: Types.UPDATE_BUDDY_LIST,
|
||||
buddyList
|
||||
}),
|
||||
addToBuddyList: (user: User) => ({
|
||||
addToBuddyList: (user: ServerInfo_User) => ({
|
||||
type: Types.ADD_TO_BUDDY_LIST,
|
||||
user
|
||||
}),
|
||||
|
|
@ -53,11 +60,11 @@ export const Actions = {
|
|||
type: Types.REMOVE_FROM_BUDDY_LIST,
|
||||
userName
|
||||
}),
|
||||
updateIgnoreList: (ignoreList: User[]) => ({
|
||||
updateIgnoreList: (ignoreList: ServerInfo_User[]) => ({
|
||||
type: Types.UPDATE_IGNORE_LIST,
|
||||
ignoreList
|
||||
}),
|
||||
addToIgnoreList: (user: User) => ({
|
||||
addToIgnoreList: (user: ServerInfo_User) => ({
|
||||
type: Types.ADD_TO_IGNORE_LIST,
|
||||
user
|
||||
}),
|
||||
|
|
@ -73,15 +80,15 @@ export const Actions = {
|
|||
type: Types.UPDATE_STATUS,
|
||||
status
|
||||
}),
|
||||
updateUser: (user: User) => ({
|
||||
updateUser: (user: ServerInfo_User) => ({
|
||||
type: Types.UPDATE_USER,
|
||||
user
|
||||
}),
|
||||
updateUsers: (users: User[]) => ({
|
||||
updateUsers: (users: ServerInfo_User[]) => ({
|
||||
type: Types.UPDATE_USERS,
|
||||
users
|
||||
}),
|
||||
userJoined: (user: User) => ({
|
||||
userJoined: (user: ServerInfo_User) => ({
|
||||
type: Types.USER_JOINED,
|
||||
user
|
||||
}),
|
||||
|
|
@ -89,7 +96,7 @@ export const Actions = {
|
|||
type: Types.USER_LEFT,
|
||||
name
|
||||
}),
|
||||
viewLogs: (logs: LogItem[]) => ({
|
||||
viewLogs: (logs: ServerInfo_ChatMessage[]) => ({
|
||||
type: Types.VIEW_LOGS,
|
||||
logs
|
||||
}),
|
||||
|
|
@ -162,15 +169,15 @@ export const Actions = {
|
|||
accountPasswordChange: () => ({
|
||||
type: Types.ACCOUNT_PASSWORD_CHANGE,
|
||||
}),
|
||||
accountEditChanged: (user: Partial<User>) => ({
|
||||
accountEditChanged: (user: Partial<ServerInfo_User>) => ({
|
||||
type: Types.ACCOUNT_EDIT_CHANGED,
|
||||
user,
|
||||
}),
|
||||
accountImageChanged: (user: Partial<User>) => ({
|
||||
accountImageChanged: (user: Partial<ServerInfo_User>) => ({
|
||||
type: Types.ACCOUNT_IMAGE_CHANGED,
|
||||
user,
|
||||
}),
|
||||
getUserInfo: (userInfo: User) => ({
|
||||
getUserInfo: (userInfo: ServerInfo_User) => ({
|
||||
type: Types.GET_USER_INFO,
|
||||
userInfo,
|
||||
}),
|
||||
|
|
@ -200,17 +207,17 @@ export const Actions = {
|
|||
type: Types.BAN_FROM_SERVER,
|
||||
userName,
|
||||
}),
|
||||
banHistory: (userName: string, banHistory: BanHistoryItem[]) => ({
|
||||
banHistory: (userName: string, banHistory: ServerInfo_Ban[]) => ({
|
||||
type: Types.BAN_HISTORY,
|
||||
userName,
|
||||
banHistory,
|
||||
}),
|
||||
warnHistory: (userName: string, warnHistory: WarnHistoryItem[]) => ({
|
||||
warnHistory: (userName: string, warnHistory: ServerInfo_Warning[]) => ({
|
||||
type: Types.WARN_HISTORY,
|
||||
userName,
|
||||
warnHistory,
|
||||
}),
|
||||
warnListOptions: (warnList: WarnListItem[]) => ({
|
||||
warnListOptions: (warnList: Response_WarnList[]) => ({
|
||||
type: Types.WARN_LIST_OPTIONS,
|
||||
warnList,
|
||||
}),
|
||||
|
|
@ -238,14 +245,14 @@ export const Actions = {
|
|||
userName,
|
||||
notes,
|
||||
}),
|
||||
replayList: (matchList: ReplayMatch[]) => ({ type: Types.REPLAY_LIST, matchList }),
|
||||
replayAdded: (matchInfo: ReplayMatch) => ({ type: Types.REPLAY_ADDED, matchInfo }),
|
||||
replayList: (matchList: ServerInfo_ReplayMatch[]) => ({ type: Types.REPLAY_LIST, matchList }),
|
||||
replayAdded: (matchInfo: ServerInfo_ReplayMatch) => ({ type: Types.REPLAY_ADDED, matchInfo }),
|
||||
replayModifyMatch: (gameId: number, doNotHide: boolean) => ({ type: Types.REPLAY_MODIFY_MATCH, gameId, doNotHide }),
|
||||
replayDeleteMatch: (gameId: number) => ({ type: Types.REPLAY_DELETE_MATCH, gameId }),
|
||||
backendDecks: (deckList: DeckList) => ({ type: Types.BACKEND_DECKS, deckList }),
|
||||
backendDecks: (deckList: Response_DeckList) => ({ type: Types.BACKEND_DECKS, deckList }),
|
||||
deckNewDir: (path: string, dirName: string) => ({ type: Types.DECK_NEW_DIR, path, dirName }),
|
||||
deckDelDir: (path: string) => ({ type: Types.DECK_DEL_DIR, path }),
|
||||
deckUpload: (path: string, treeItem: DeckStorageTreeItem) => ({ type: Types.DECK_UPLOAD, path, treeItem }),
|
||||
deckUpload: (path: string, treeItem: ServerInfo_DeckStorage_TreeItem) => ({ type: Types.DECK_UPLOAD, path, treeItem }),
|
||||
deckDelete: (deckId: number) => ({ type: Types.DECK_DELETE, deckId }),
|
||||
gamesOfUser: (userName: string, games: ServerInfo_Game[], gametypeMap: GametypeMap) =>
|
||||
({ type: Types.GAMES_OF_USER, userName, games, gametypeMap }),
|
||||
|
|
|
|||
|
|
@ -1,9 +1,16 @@
|
|||
import { Actions } from './server.actions';
|
||||
import { store } from 'store';
|
||||
import {
|
||||
BanHistoryItem, DeckList, DeckStorageTreeItem, GametypeMap, LogItem, ReplayMatch,
|
||||
User, WarnHistoryItem, WarnListItem, WebSocketConnectOptions
|
||||
GametypeMap, WebSocketConnectOptions
|
||||
} from 'types';
|
||||
import type { ServerInfo_User } from 'generated/proto/serverinfo_user_pb';
|
||||
import type { ServerInfo_Ban } from 'generated/proto/serverinfo_ban_pb';
|
||||
import type { ServerInfo_Warning } from 'generated/proto/serverinfo_warning_pb';
|
||||
import type { Response_WarnList } from 'generated/proto/response_warn_list_pb';
|
||||
import type { ServerInfo_ReplayMatch } from 'generated/proto/serverinfo_replay_match_pb';
|
||||
import type { Response_DeckList } from 'generated/proto/response_deck_list_pb';
|
||||
import type { ServerInfo_DeckStorage_TreeItem } from 'generated/proto/serverinfo_deckstorage_pb';
|
||||
import type { ServerInfo_ChatMessage } from 'generated/proto/serverinfo_chat_message_pb';
|
||||
import type { ServerInfo_Game } from 'generated/proto/serverinfo_game_pb';
|
||||
import { NotifyUserData, ServerShutdownData, UserMessageData } from 'websocket/events/session/interfaces';
|
||||
|
||||
|
|
@ -35,19 +42,19 @@ export const Dispatch = {
|
|||
testConnectionFailed: () => {
|
||||
store.dispatch(Actions.testConnectionFailed());
|
||||
},
|
||||
updateBuddyList: (buddyList: User[]) => {
|
||||
updateBuddyList: (buddyList: ServerInfo_User[]) => {
|
||||
store.dispatch(Actions.updateBuddyList(buddyList));
|
||||
},
|
||||
addToBuddyList: (user: User) => {
|
||||
addToBuddyList: (user: ServerInfo_User) => {
|
||||
store.dispatch(Actions.addToBuddyList(user));
|
||||
},
|
||||
removeFromBuddyList: (userName: string) => {
|
||||
store.dispatch(Actions.removeFromBuddyList(userName));
|
||||
},
|
||||
updateIgnoreList: (ignoreList: User[]) => {
|
||||
updateIgnoreList: (ignoreList: ServerInfo_User[]) => {
|
||||
store.dispatch(Actions.updateIgnoreList(ignoreList));
|
||||
},
|
||||
addToIgnoreList: (user: User) => {
|
||||
addToIgnoreList: (user: ServerInfo_User) => {
|
||||
store.dispatch(Actions.addToIgnoreList(user));
|
||||
},
|
||||
removeFromIgnoreList: (userName: string) => {
|
||||
|
|
@ -65,19 +72,19 @@ export const Dispatch = {
|
|||
description
|
||||
}));
|
||||
},
|
||||
updateUser: (user: User) => {
|
||||
updateUser: (user: ServerInfo_User) => {
|
||||
store.dispatch(Actions.updateUser(user));
|
||||
},
|
||||
updateUsers: (users: User[]) => {
|
||||
updateUsers: (users: ServerInfo_User[]) => {
|
||||
store.dispatch(Actions.updateUsers(users));
|
||||
},
|
||||
userJoined: (user: User) => {
|
||||
userJoined: (user: ServerInfo_User) => {
|
||||
store.dispatch(Actions.userJoined(user));
|
||||
},
|
||||
userLeft: (name: string) => {
|
||||
store.dispatch(Actions.userLeft(name));
|
||||
},
|
||||
viewLogs: (logs: LogItem[]) => {
|
||||
viewLogs: (logs: ServerInfo_ChatMessage[]) => {
|
||||
store.dispatch(Actions.viewLogs(logs));
|
||||
},
|
||||
clearLogs: () => {
|
||||
|
|
@ -143,13 +150,13 @@ export const Dispatch = {
|
|||
accountPasswordChange: () => {
|
||||
store.dispatch(Actions.accountPasswordChange());
|
||||
},
|
||||
accountEditChanged: (user: Partial<User>) => {
|
||||
accountEditChanged: (user: Partial<ServerInfo_User>) => {
|
||||
store.dispatch(Actions.accountEditChanged(user));
|
||||
},
|
||||
accountImageChanged: (user: Partial<User>) => {
|
||||
accountImageChanged: (user: Partial<ServerInfo_User>) => {
|
||||
store.dispatch(Actions.accountImageChanged(user));
|
||||
},
|
||||
getUserInfo: (userInfo: User) => {
|
||||
getUserInfo: (userInfo: ServerInfo_User) => {
|
||||
store.dispatch(Actions.getUserInfo(userInfo));
|
||||
},
|
||||
notifyUser: (notification: NotifyUserData) => {
|
||||
|
|
@ -170,13 +177,13 @@ export const Dispatch = {
|
|||
banFromServer: (userName: string) => {
|
||||
store.dispatch(Actions.banFromServer(userName));
|
||||
},
|
||||
banHistory: (userName: string, banHistory: BanHistoryItem[]) => {
|
||||
banHistory: (userName: string, banHistory: ServerInfo_Ban[]) => {
|
||||
store.dispatch(Actions.banHistory(userName, banHistory))
|
||||
},
|
||||
warnHistory: (userName: string, warnHistory: WarnHistoryItem[]) => {
|
||||
warnHistory: (userName: string, warnHistory: ServerInfo_Warning[]) => {
|
||||
store.dispatch(Actions.warnHistory(userName, warnHistory))
|
||||
},
|
||||
warnListOptions: (warnList: WarnListItem[]) => {
|
||||
warnListOptions: (warnList: Response_WarnList[]) => {
|
||||
store.dispatch(Actions.warnListOptions(warnList))
|
||||
},
|
||||
warnUser: (userName: string) => {
|
||||
|
|
@ -194,10 +201,10 @@ export const Dispatch = {
|
|||
updateAdminNotes: (userName: string, notes: string) => {
|
||||
store.dispatch(Actions.updateAdminNotes(userName, notes));
|
||||
},
|
||||
replayList: (matchList: ReplayMatch[]) => {
|
||||
replayList: (matchList: ServerInfo_ReplayMatch[]) => {
|
||||
store.dispatch(Actions.replayList(matchList));
|
||||
},
|
||||
replayAdded: (matchInfo: ReplayMatch) => {
|
||||
replayAdded: (matchInfo: ServerInfo_ReplayMatch) => {
|
||||
store.dispatch(Actions.replayAdded(matchInfo));
|
||||
},
|
||||
replayModifyMatch: (gameId: number, doNotHide: boolean) => {
|
||||
|
|
@ -206,7 +213,7 @@ export const Dispatch = {
|
|||
replayDeleteMatch: (gameId: number) => {
|
||||
store.dispatch(Actions.replayDeleteMatch(gameId));
|
||||
},
|
||||
backendDecks: (deckList: DeckList) => {
|
||||
backendDecks: (deckList: Response_DeckList) => {
|
||||
store.dispatch(Actions.backendDecks(deckList));
|
||||
},
|
||||
deckNewDir: (path: string, dirName: string) => {
|
||||
|
|
@ -215,7 +222,7 @@ export const Dispatch = {
|
|||
deckDelDir: (path: string) => {
|
||||
store.dispatch(Actions.deckDelDir(path));
|
||||
},
|
||||
deckUpload: (path: string, treeItem: DeckStorageTreeItem) => {
|
||||
deckUpload: (path: string, treeItem: ServerInfo_DeckStorage_TreeItem) => {
|
||||
store.dispatch(Actions.deckUpload(path, treeItem));
|
||||
},
|
||||
deckDelete: (deckId: number) => {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,13 @@
|
|||
import {
|
||||
WarnHistoryItem, BanHistoryItem, DeckList, Game, LogItem, ReplayMatch, SortBy, User, UserSortField, WarnListItem
|
||||
Game, SortBy, UserSortField
|
||||
} from 'types';
|
||||
import type { ServerInfo_User } from 'generated/proto/serverinfo_user_pb';
|
||||
import type { ServerInfo_Ban } from 'generated/proto/serverinfo_ban_pb';
|
||||
import type { ServerInfo_Warning } from 'generated/proto/serverinfo_warning_pb';
|
||||
import type { Response_WarnList } from 'generated/proto/response_warn_list_pb';
|
||||
import type { ServerInfo_ReplayMatch } from 'generated/proto/serverinfo_replay_match_pb';
|
||||
import type { Response_DeckList } from 'generated/proto/response_deck_list_pb';
|
||||
import type { ServerInfo_ChatMessage } from 'generated/proto/serverinfo_chat_message_pb';
|
||||
import { NotifyUserData, ServerShutdownData, UserMessageData } from 'websocket/events/session/interfaces';
|
||||
|
||||
export interface ServerConnectParams {
|
||||
|
|
@ -43,34 +50,34 @@ export interface AccountActivationParams extends ServerRegisterParams {
|
|||
|
||||
export interface ServerState {
|
||||
initialized: boolean;
|
||||
buddyList: User[];
|
||||
ignoreList: User[];
|
||||
buddyList: ServerInfo_User[];
|
||||
ignoreList: ServerInfo_User[];
|
||||
info: ServerStateInfo;
|
||||
status: ServerStateStatus;
|
||||
logs: ServerStateLogs;
|
||||
user: User;
|
||||
users: User[];
|
||||
user: ServerInfo_User;
|
||||
users: ServerInfo_User[];
|
||||
sortUsersBy: ServerStateSortUsersBy;
|
||||
messages: {
|
||||
[userName: string]: UserMessageData[];
|
||||
}
|
||||
userInfo: {
|
||||
[userName: string]: User;
|
||||
[userName: string]: ServerInfo_User;
|
||||
}
|
||||
notifications: NotifyUserData[];
|
||||
serverShutdown: ServerShutdownData;
|
||||
banUser: string;
|
||||
banHistory: {
|
||||
[userName: string]: BanHistoryItem[];
|
||||
[userName: string]: ServerInfo_Ban[];
|
||||
};
|
||||
warnHistory: {
|
||||
[userName: string]: WarnHistoryItem[];
|
||||
[userName: string]: ServerInfo_Warning[];
|
||||
};
|
||||
warnListOptions: WarnListItem[];
|
||||
warnListOptions: Response_WarnList[];
|
||||
warnUser: string;
|
||||
adminNotes: { [userName: string]: string };
|
||||
replays: ReplayMatch[];
|
||||
backendDecks: DeckList | null;
|
||||
replays: ServerInfo_ReplayMatch[];
|
||||
backendDecks: Response_DeckList | null;
|
||||
gamesOfUser: { [userName: string]: Game[] };
|
||||
registrationError: string | null;
|
||||
}
|
||||
|
|
@ -88,9 +95,9 @@ export interface ServerStateInfo {
|
|||
}
|
||||
|
||||
export interface ServerStateLogs {
|
||||
room: LogItem[];
|
||||
game: LogItem[];
|
||||
chat: LogItem[];
|
||||
room: ServerInfo_ChatMessage[];
|
||||
game: ServerInfo_ChatMessage[];
|
||||
chat: ServerInfo_ChatMessage[];
|
||||
}
|
||||
|
||||
export interface ServerStateSortUsersBy extends SortBy {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import { StatusEnum, UserLevelFlag } from 'types';
|
||||
import { StatusEnum } from 'types';
|
||||
import { ServerInfo_User_UserLevelFlag as UserLevelFlag } from 'generated/proto/serverinfo_user_pb';
|
||||
import { create } from '@bufbuild/protobuf';
|
||||
import { Event_UserMessageSchema } from 'generated/proto/event_user_message_pb';
|
||||
import { ServerInfo_DeckStorage_FolderSchema, ServerInfo_DeckStorage_TreeItemSchema } from 'generated/proto/serverinfo_deckstorage_pb';
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
import { DeckStorageFolder, DeckStorageTreeItem, SortDirection, StatusEnum, UserLevelFlag, UserSortField } from 'types';
|
||||
import { SortDirection, StatusEnum, UserSortField } from 'types';
|
||||
import { ServerInfo_User_UserLevelFlag } from 'generated/proto/serverinfo_user_pb';
|
||||
import type { ServerInfo_DeckStorage_Folder, ServerInfo_DeckStorage_TreeItem } from 'generated/proto/serverinfo_deckstorage_pb';
|
||||
import { create } from '@bufbuild/protobuf';
|
||||
import { Response_DeckListSchema } from 'generated/proto/response_deck_list_pb';
|
||||
import { ServerInfo_DeckStorage_FolderSchema, ServerInfo_DeckStorage_TreeItemSchema } from 'generated/proto/serverinfo_deckstorage_pb';
|
||||
|
|
@ -13,7 +15,11 @@ function splitPath(path: string): string[] {
|
|||
return path ? path.split('/') : [];
|
||||
}
|
||||
|
||||
function insertAtPath(folder: DeckStorageFolder, pathSegments: string[], item: DeckStorageTreeItem): DeckStorageFolder {
|
||||
function insertAtPath(
|
||||
folder: ServerInfo_DeckStorage_Folder,
|
||||
pathSegments: string[],
|
||||
item: ServerInfo_DeckStorage_TreeItem,
|
||||
): ServerInfo_DeckStorage_Folder {
|
||||
if (pathSegments.length === 0 || (pathSegments.length === 1 && pathSegments[0] === '')) {
|
||||
return create(ServerInfo_DeckStorage_FolderSchema, { items: [...folder.items, item] });
|
||||
}
|
||||
|
|
@ -28,13 +34,13 @@ function insertAtPath(folder: DeckStorageFolder, pathSegments: string[], item: D
|
|||
),
|
||||
});
|
||||
}
|
||||
const created: DeckStorageTreeItem = create(ServerInfo_DeckStorage_TreeItemSchema, {
|
||||
const created: ServerInfo_DeckStorage_TreeItem = create(ServerInfo_DeckStorage_TreeItemSchema, {
|
||||
id: 0, name: head, folder: insertAtPath(create(ServerInfo_DeckStorage_FolderSchema, { items: [] }), tail, item)
|
||||
});
|
||||
return create(ServerInfo_DeckStorage_FolderSchema, { items: [...folder.items, created] });
|
||||
}
|
||||
|
||||
function removeById(folder: DeckStorageFolder, id: number): DeckStorageFolder {
|
||||
function removeById(folder: ServerInfo_DeckStorage_Folder, id: number): ServerInfo_DeckStorage_Folder {
|
||||
return create(ServerInfo_DeckStorage_FolderSchema, {
|
||||
items: folder.items
|
||||
.filter(item => item.id !== id)
|
||||
|
|
@ -44,7 +50,7 @@ function removeById(folder: DeckStorageFolder, id: number): DeckStorageFolder {
|
|||
});
|
||||
}
|
||||
|
||||
function removeByPath(folder: DeckStorageFolder, pathSegments: string[]): DeckStorageFolder {
|
||||
function removeByPath(folder: ServerInfo_DeckStorage_Folder, pathSegments: string[]): ServerInfo_DeckStorage_Folder {
|
||||
if (pathSegments.length === 0 || (pathSegments.length === 1 && pathSegments[0] === '')) {
|
||||
return folder;
|
||||
}
|
||||
|
|
@ -410,8 +416,12 @@ export const serverReducer = (state = initialState, action: ServerAction) => {
|
|||
return user;
|
||||
}
|
||||
let newLevel = user.userLevel;
|
||||
newLevel = shouldBeMod ? (newLevel | UserLevelFlag.IsModerator) : (newLevel & ~UserLevelFlag.IsModerator);
|
||||
newLevel = shouldBeJudge ? (newLevel | UserLevelFlag.IsJudge) : (newLevel & ~UserLevelFlag.IsJudge);
|
||||
newLevel = shouldBeMod
|
||||
? (newLevel | ServerInfo_User_UserLevelFlag.IsModerator)
|
||||
: (newLevel & ~ServerInfo_User_UserLevelFlag.IsModerator);
|
||||
newLevel = shouldBeJudge
|
||||
? (newLevel | ServerInfo_User_UserLevelFlag.IsJudge)
|
||||
: (newLevel & ~ServerInfo_User_UserLevelFlag.IsJudge);
|
||||
return {
|
||||
...user,
|
||||
userLevel: newLevel,
|
||||
|
|
@ -465,7 +475,7 @@ export const serverReducer = (state = initialState, action: ServerAction) => {
|
|||
if (!state.backendDecks?.root) {
|
||||
return state;
|
||||
}
|
||||
const newFolder: DeckStorageTreeItem = create(ServerInfo_DeckStorage_TreeItemSchema, {
|
||||
const newFolder: ServerInfo_DeckStorage_TreeItem = create(ServerInfo_DeckStorage_TreeItemSchema, {
|
||||
id: 0, name: action.dirName, folder: create(ServerInfo_DeckStorage_FolderSchema, { items: [] })
|
||||
});
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -1,9 +0,0 @@
|
|||
import type {
|
||||
ServerInfo_DeckStorage_File, ServerInfo_DeckStorage_Folder, ServerInfo_DeckStorage_TreeItem
|
||||
} from 'generated/proto/serverinfo_deckstorage_pb';
|
||||
import type { Response_DeckList } from 'generated/proto/response_deck_list_pb';
|
||||
|
||||
export type DeckList = Response_DeckList;
|
||||
export type DeckStorageFolder = ServerInfo_DeckStorage_Folder;
|
||||
export type DeckStorageFile = ServerInfo_DeckStorage_File;
|
||||
export type DeckStorageTreeItem = ServerInfo_DeckStorage_TreeItem;
|
||||
|
|
@ -1,7 +1,8 @@
|
|||
// ── Imports from generated proto files ───────────────────────────────────────
|
||||
|
||||
import type { ProtoInit } from './utilities';
|
||||
import type { GameEventContext } from 'generated/proto/game_event_context_pb';
|
||||
import type { CardToMove, Command_MoveCard } from 'generated/proto/command_move_card_pb';
|
||||
import type { Command_MoveCard } from 'generated/proto/command_move_card_pb';
|
||||
import type { Command_DrawCards } from 'generated/proto/command_draw_cards_pb';
|
||||
import type { Command_RollDie } from 'generated/proto/command_roll_die_pb';
|
||||
import type { Command_Shuffle } from 'generated/proto/command_shuffle_pb';
|
||||
|
|
@ -24,59 +25,11 @@ import type { Command_KickFromGame } from 'generated/proto/command_kick_from_gam
|
|||
import type { Command_ReadyStart } from 'generated/proto/command_ready_start_pb';
|
||||
import type { Command_Mulligan } from 'generated/proto/command_mulligan_pb';
|
||||
import type { Command_DeckSelect } from 'generated/proto/command_deck_select_pb';
|
||||
import type { MoveCard_ToZone } from 'generated/proto/move_card_to_zone_pb';
|
||||
import type { Command_SetSideboardPlan } from 'generated/proto/command_set_sideboard_plan_pb';
|
||||
import type { Command_SetSideboardLock } from 'generated/proto/command_set_sideboard_lock_pb';
|
||||
import type { Command_SetActivePhase } from 'generated/proto/command_set_active_phase_pb';
|
||||
import type { Command_GameSay } from 'generated/proto/command_game_say_pb';
|
||||
import type { Event_GameStateChanged } from 'generated/proto/event_game_state_changed_pb';
|
||||
import type { Event_GameSay } from 'generated/proto/event_game_say_pb';
|
||||
import type { Event_MoveCard } from 'generated/proto/event_move_card_pb';
|
||||
import type { Event_FlipCard } from 'generated/proto/event_flip_card_pb';
|
||||
import type { Event_DestroyCard } from 'generated/proto/event_destroy_card_pb';
|
||||
import type { Event_AttachCard } from 'generated/proto/event_attach_card_pb';
|
||||
import type { Event_CreateToken } from 'generated/proto/event_create_token_pb';
|
||||
import type { Event_SetCardAttr } from 'generated/proto/event_set_card_attr_pb';
|
||||
import type { Event_SetCardCounter } from 'generated/proto/event_set_card_counter_pb';
|
||||
import type { Event_CreateArrow } from 'generated/proto/event_create_arrow_pb';
|
||||
import type { Event_DeleteArrow } from 'generated/proto/event_delete_arrow_pb';
|
||||
import type { Event_CreateCounter } from 'generated/proto/event_create_counter_pb';
|
||||
import type { Event_SetCounter } from 'generated/proto/event_set_counter_pb';
|
||||
import type { Event_DelCounter } from 'generated/proto/event_del_counter_pb';
|
||||
import type { Event_DrawCards } from 'generated/proto/event_draw_cards_pb';
|
||||
import type { Event_RevealCards } from 'generated/proto/event_reveal_cards_pb';
|
||||
import type { Event_Shuffle } from 'generated/proto/event_shuffle_pb';
|
||||
import type { Event_RollDie } from 'generated/proto/event_roll_die_pb';
|
||||
import type { Event_DumpZone } from 'generated/proto/event_dump_zone_pb';
|
||||
import type { Event_ChangeZoneProperties } from 'generated/proto/event_change_zone_properties_pb';
|
||||
import type { Event_SetActivePlayer } from 'generated/proto/event_set_active_player_pb';
|
||||
import type { Event_SetActivePhase } from 'generated/proto/event_set_active_phase_pb';
|
||||
import type { Event_ReverseTurn } from 'generated/proto/event_reverse_turn_pb';
|
||||
import type { ServerInfo_Game } from 'generated/proto/serverinfo_game_pb';
|
||||
import type { color } from 'generated/proto/color_pb';
|
||||
import type { ServerInfo_CardCounter } from 'generated/proto/serverinfo_cardcounter_pb';
|
||||
import type { ServerInfo_Card } from 'generated/proto/serverinfo_card_pb';
|
||||
import type { ServerInfo_Zone } from 'generated/proto/serverinfo_zone_pb';
|
||||
import type { ServerInfo_Counter } from 'generated/proto/serverinfo_counter_pb';
|
||||
import type { ServerInfo_Arrow } from 'generated/proto/serverinfo_arrow_pb';
|
||||
import type { ServerInfo_PlayerProperties } from 'generated/proto/serverinfo_playerproperties_pb';
|
||||
import type { ServerInfo_Player } from 'generated/proto/serverinfo_player_pb';
|
||||
|
||||
// ── Enum re-exports from generated proto files ────────────────────────────────
|
||||
|
||||
export { CardAttribute } from 'generated/proto/card_attributes_pb';
|
||||
export { ServerInfo_Zone_ZoneType as ZoneType } from 'generated/proto/serverinfo_zone_pb';
|
||||
|
||||
// ── Proto utility types ───────────────────────────────────────────────────────
|
||||
|
||||
/**
|
||||
* Init shape for constructing protobuf messages via create().
|
||||
* Strips $typeName and $unknown branding, making all fields optional.
|
||||
* Use for function parameters that feed into create().
|
||||
*/
|
||||
export type ProtoInit<T> = {
|
||||
[K in keyof T as K extends '$typeName' | '$unknown' ? never : K]?: T[K];
|
||||
};
|
||||
|
||||
// ── UI types (not proto mirrors) ──────────────────────────────────────────────
|
||||
|
||||
|
|
@ -120,46 +73,7 @@ export enum LeaveGameReason {
|
|||
USER_DISCONNECTED = 4
|
||||
}
|
||||
|
||||
// ── Type aliases for generated state mirror types ─────────────────────────────
|
||||
|
||||
export type Color = color;
|
||||
export type CardCounterInfo = ServerInfo_CardCounter;
|
||||
export type CardInfo = ServerInfo_Card;
|
||||
export type ZoneInfo = ServerInfo_Zone;
|
||||
export type CounterInfo = ServerInfo_Counter;
|
||||
export type ArrowInfo = ServerInfo_Arrow;
|
||||
export type PlayerProperties = ServerInfo_PlayerProperties;
|
||||
export type PlayerInfo = ServerInfo_Player;
|
||||
|
||||
// ── Type aliases for generated event data types ───────────────────────────────
|
||||
|
||||
export type GameStateChangedData = Event_GameStateChanged;
|
||||
export type GameSayData = Event_GameSay;
|
||||
export type MoveCardData = Event_MoveCard;
|
||||
export type FlipCardData = Event_FlipCard;
|
||||
export type DestroyCardData = Event_DestroyCard;
|
||||
export type AttachCardData = Event_AttachCard;
|
||||
export type CreateTokenData = Event_CreateToken;
|
||||
export type SetCardAttrData = Event_SetCardAttr;
|
||||
export type SetCardCounterData = Event_SetCardCounter;
|
||||
export type CreateArrowData = Event_CreateArrow;
|
||||
export type DeleteArrowData = Event_DeleteArrow;
|
||||
export type CreateCounterData = Event_CreateCounter;
|
||||
export type SetCounterData = Event_SetCounter;
|
||||
export type DelCounterData = Event_DelCounter;
|
||||
export type DrawCardsData = Event_DrawCards;
|
||||
export type RevealCardsData = Event_RevealCards;
|
||||
export type ShuffleData = Event_Shuffle;
|
||||
export type RollDieData = Event_RollDie;
|
||||
export type DumpZoneData = Event_DumpZone;
|
||||
export type ChangeZonePropertiesData = Event_ChangeZoneProperties;
|
||||
export type SetActivePlayerData = Event_SetActivePlayer;
|
||||
export type SetActivePhaseData = Event_SetActivePhase;
|
||||
export type ReverseTurnData = Event_ReverseTurn;
|
||||
|
||||
// ── GameEventContext (re-export of generated type) ────────────────────────────
|
||||
|
||||
export type { GameEventContext };
|
||||
// ── GameEventContext (imported for use in GameEventMeta below) ───────────────
|
||||
|
||||
/**
|
||||
* Passed to every game event handler alongside the event payload.
|
||||
|
|
@ -180,7 +94,6 @@ export interface GameEventMeta {
|
|||
// These use ProtoInit<> because callers construct plain objects;
|
||||
// the command functions internally call create(Schema, params).
|
||||
|
||||
export type { CardToMove };
|
||||
export type MoveCardParams = ProtoInit<Command_MoveCard>;
|
||||
export type DrawCardsParams = ProtoInit<Command_DrawCards>;
|
||||
export type RollDieParams = ProtoInit<Command_RollDie>;
|
||||
|
|
@ -204,7 +117,6 @@ export type KickFromGameParams = ProtoInit<Command_KickFromGame>;
|
|||
export type ReadyStartParams = ProtoInit<Command_ReadyStart>;
|
||||
export type MulliganParams = ProtoInit<Command_Mulligan>;
|
||||
export type DeckSelectParams = ProtoInit<Command_DeckSelect>;
|
||||
export type MoveCardToZone = MoveCard_ToZone;
|
||||
export type SetSideboardPlanParams = ProtoInit<Command_SetSideboardPlan>;
|
||||
export type SetSideboardLockParams = ProtoInit<Command_SetSideboardLock>;
|
||||
export type SetActivePhaseParams = ProtoInit<Command_SetActivePhase>;
|
||||
|
|
|
|||
|
|
@ -11,7 +11,4 @@ export * from './message';
|
|||
export * from './settings';
|
||||
export * from './languages';
|
||||
export * from './logs';
|
||||
export * from './session';
|
||||
export * from './deckList';
|
||||
export * from './moderator';
|
||||
export * from './replay';
|
||||
export * from './utilities';
|
||||
|
|
|
|||
|
|
@ -1,7 +0,0 @@
|
|||
import type { ServerInfo_Ban } from 'generated/proto/serverinfo_ban_pb';
|
||||
import type { ServerInfo_Warning } from 'generated/proto/serverinfo_warning_pb';
|
||||
import type { Response_WarnList } from 'generated/proto/response_warn_list_pb';
|
||||
|
||||
export type BanHistoryItem = ServerInfo_Ban;
|
||||
export type WarnHistoryItem = ServerInfo_Warning;
|
||||
export type WarnListItem = Response_WarnList;
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
import type { ServerInfo_Replay } from 'generated/proto/serverinfo_replay_pb';
|
||||
import type { ServerInfo_ReplayMatch } from 'generated/proto/serverinfo_replay_match_pb';
|
||||
|
||||
export type Replay = ServerInfo_Replay;
|
||||
export type ReplayMatch = ServerInfo_ReplayMatch;
|
||||
|
|
@ -111,10 +111,8 @@ export const KnownHosts = {
|
|||
[KnownHost.TETRARCH]: { port: 443, host: 'mtg.tetrarch.co/servatrice' },
|
||||
}
|
||||
|
||||
export type LogItem = ServerInfo_ChatMessage;
|
||||
|
||||
export interface LogGroups {
|
||||
room: LogItem[];
|
||||
game: LogItem[];
|
||||
chat: LogItem[];
|
||||
room: ServerInfo_ChatMessage[];
|
||||
game: ServerInfo_ChatMessage[];
|
||||
chat: ServerInfo_ChatMessage[];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
export { Event_NotifyUser_NotificationType as NotificationType } from 'generated/proto/event_notify_user_pb';
|
||||
|
|
@ -1,8 +1,3 @@
|
|||
import type { ServerInfo_User } from 'generated/proto/serverinfo_user_pb';
|
||||
|
||||
export type User = ServerInfo_User;
|
||||
export { ServerInfo_User_UserLevelFlag as UserLevelFlag } from 'generated/proto/serverinfo_user_pb';
|
||||
|
||||
export enum UserSortField {
|
||||
NAME = 'name'
|
||||
}
|
||||
|
|
|
|||
8
webclient/src/types/utilities.ts
Normal file
8
webclient/src/types/utilities.ts
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
/**
|
||||
* Init shape for constructing protobuf messages via create().
|
||||
* Strips $typeName and $unknown branding, making all fields optional.
|
||||
* Use for function parameters that feed into create().
|
||||
*/
|
||||
export type ProtoInit<T> = {
|
||||
[K in keyof T as K extends '$typeName' | '$unknown' ? never : K]?: T[K];
|
||||
};
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
import { AttachCardData, GameEventMeta } from 'types';
|
||||
import type { Event_AttachCard } from 'generated/proto/event_attach_card_pb';
|
||||
import type { GameEventMeta } from 'types';
|
||||
import { GamePersistence } from '../../persistence';
|
||||
|
||||
export function attachCard(data: AttachCardData, meta: GameEventMeta): void {
|
||||
export function attachCard(data: Event_AttachCard, meta: GameEventMeta): void {
|
||||
GamePersistence.cardAttached(meta.gameId, meta.playerId, data);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { ChangeZonePropertiesData, GameEventMeta } from 'types';
|
||||
import type { Event_ChangeZoneProperties } from 'generated/proto/event_change_zone_properties_pb';
|
||||
import type { GameEventMeta } from 'types';
|
||||
import { GamePersistence } from '../../persistence';
|
||||
|
||||
export function changeZoneProperties(data: ChangeZonePropertiesData, meta: GameEventMeta): void {
|
||||
export function changeZoneProperties(data: Event_ChangeZoneProperties, meta: GameEventMeta): void {
|
||||
GamePersistence.zonePropertiesChanged(meta.gameId, meta.playerId, data);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { CreateArrowData, GameEventMeta } from 'types';
|
||||
import type { Event_CreateArrow } from 'generated/proto/event_create_arrow_pb';
|
||||
import type { GameEventMeta } from 'types';
|
||||
import { GamePersistence } from '../../persistence';
|
||||
|
||||
export function createArrow(data: CreateArrowData, meta: GameEventMeta): void {
|
||||
export function createArrow(data: Event_CreateArrow, meta: GameEventMeta): void {
|
||||
GamePersistence.arrowCreated(meta.gameId, meta.playerId, data);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { CreateCounterData, GameEventMeta } from 'types';
|
||||
import type { Event_CreateCounter } from 'generated/proto/event_create_counter_pb';
|
||||
import type { GameEventMeta } from 'types';
|
||||
import { GamePersistence } from '../../persistence';
|
||||
|
||||
export function createCounter(data: CreateCounterData, meta: GameEventMeta): void {
|
||||
export function createCounter(data: Event_CreateCounter, meta: GameEventMeta): void {
|
||||
GamePersistence.counterCreated(meta.gameId, meta.playerId, data);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { CreateTokenData, GameEventMeta } from 'types';
|
||||
import type { Event_CreateToken } from 'generated/proto/event_create_token_pb';
|
||||
import type { GameEventMeta } from 'types';
|
||||
import { GamePersistence } from '../../persistence';
|
||||
|
||||
export function createToken(data: CreateTokenData, meta: GameEventMeta): void {
|
||||
export function createToken(data: Event_CreateToken, meta: GameEventMeta): void {
|
||||
GamePersistence.tokenCreated(meta.gameId, meta.playerId, data);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { DelCounterData, GameEventMeta } from 'types';
|
||||
import type { Event_DelCounter } from 'generated/proto/event_del_counter_pb';
|
||||
import type { GameEventMeta } from 'types';
|
||||
import { GamePersistence } from '../../persistence';
|
||||
|
||||
export function delCounter(data: DelCounterData, meta: GameEventMeta): void {
|
||||
export function delCounter(data: Event_DelCounter, meta: GameEventMeta): void {
|
||||
GamePersistence.counterDeleted(meta.gameId, meta.playerId, data);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { DeleteArrowData, GameEventMeta } from 'types';
|
||||
import type { Event_DeleteArrow } from 'generated/proto/event_delete_arrow_pb';
|
||||
import type { GameEventMeta } from 'types';
|
||||
import { GamePersistence } from '../../persistence';
|
||||
|
||||
export function deleteArrow(data: DeleteArrowData, meta: GameEventMeta): void {
|
||||
export function deleteArrow(data: Event_DeleteArrow, meta: GameEventMeta): void {
|
||||
GamePersistence.arrowDeleted(meta.gameId, meta.playerId, data);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { DestroyCardData, GameEventMeta } from 'types';
|
||||
import type { Event_DestroyCard } from 'generated/proto/event_destroy_card_pb';
|
||||
import type { GameEventMeta } from 'types';
|
||||
import { GamePersistence } from '../../persistence';
|
||||
|
||||
export function destroyCard(data: DestroyCardData, meta: GameEventMeta): void {
|
||||
export function destroyCard(data: Event_DestroyCard, meta: GameEventMeta): void {
|
||||
GamePersistence.cardDestroyed(meta.gameId, meta.playerId, data);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { DrawCardsData, GameEventMeta } from 'types';
|
||||
import type { Event_DrawCards } from 'generated/proto/event_draw_cards_pb';
|
||||
import type { GameEventMeta } from 'types';
|
||||
import { GamePersistence } from '../../persistence';
|
||||
|
||||
export function drawCards(data: DrawCardsData, meta: GameEventMeta): void {
|
||||
export function drawCards(data: Event_DrawCards, meta: GameEventMeta): void {
|
||||
GamePersistence.cardsDrawn(meta.gameId, meta.playerId, data);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { DumpZoneData, GameEventMeta } from 'types';
|
||||
import type { Event_DumpZone } from 'generated/proto/event_dump_zone_pb';
|
||||
import type { GameEventMeta } from 'types';
|
||||
import { GamePersistence } from '../../persistence';
|
||||
|
||||
export function dumpZone(data: DumpZoneData, meta: GameEventMeta): void {
|
||||
export function dumpZone(data: Event_DumpZone, meta: GameEventMeta): void {
|
||||
GamePersistence.zoneDumped(meta.gameId, meta.playerId, data);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { FlipCardData, GameEventMeta } from 'types';
|
||||
import type { Event_FlipCard } from 'generated/proto/event_flip_card_pb';
|
||||
import type { GameEventMeta } from 'types';
|
||||
import { GamePersistence } from '../../persistence';
|
||||
|
||||
export function flipCard(data: FlipCardData, meta: GameEventMeta): void {
|
||||
export function flipCard(data: Event_FlipCard, meta: GameEventMeta): void {
|
||||
GamePersistence.cardFlipped(meta.gameId, meta.playerId, data);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { GameEventMeta, GameSayData } from 'types';
|
||||
import type { Event_GameSay } from 'generated/proto/event_game_say_pb';
|
||||
import type { GameEventMeta } from 'types';
|
||||
import { GamePersistence } from '../../persistence';
|
||||
|
||||
export function gameSay(data: GameSayData, meta: GameEventMeta): void {
|
||||
export function gameSay(data: Event_GameSay, meta: GameEventMeta): void {
|
||||
GamePersistence.gameSay(meta.gameId, meta.playerId, data.message);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { GameEventMeta, GameStateChangedData } from 'types';
|
||||
import type { Event_GameStateChanged } from 'generated/proto/event_game_state_changed_pb';
|
||||
import type { GameEventMeta } from 'types';
|
||||
import { GamePersistence } from '../../persistence';
|
||||
|
||||
export function gameStateChanged(data: GameStateChangedData, meta: GameEventMeta): void {
|
||||
export function gameStateChanged(data: Event_GameStateChanged, meta: GameEventMeta): void {
|
||||
GamePersistence.gameStateChanged(meta.gameId, data);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { GamePersistence } from '../../persistence';
|
||||
import { GameEventMeta, PlayerProperties } from 'types';
|
||||
import type { ServerInfo_PlayerProperties } from 'generated/proto/serverinfo_playerproperties_pb';
|
||||
import type { GameEventMeta } from 'types';
|
||||
|
||||
export function joinGame(data: { playerProperties: PlayerProperties }, meta: GameEventMeta): void {
|
||||
export function joinGame(data: { playerProperties: ServerInfo_PlayerProperties }, meta: GameEventMeta): void {
|
||||
GamePersistence.playerJoined(meta.gameId, data.playerProperties);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { GameEventMeta, MoveCardData } from 'types';
|
||||
import type { Event_MoveCard } from 'generated/proto/event_move_card_pb';
|
||||
import type { GameEventMeta } from 'types';
|
||||
import { GamePersistence } from '../../persistence';
|
||||
|
||||
export function moveCard(data: MoveCardData, meta: GameEventMeta): void {
|
||||
export function moveCard(data: Event_MoveCard, meta: GameEventMeta): void {
|
||||
GamePersistence.cardMoved(meta.gameId, meta.playerId, data);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { GameEventMeta, PlayerProperties } from 'types';
|
||||
import type { ServerInfo_PlayerProperties } from 'generated/proto/serverinfo_playerproperties_pb';
|
||||
import type { GameEventMeta } from 'types';
|
||||
import { GamePersistence } from '../../persistence';
|
||||
|
||||
export function playerPropertiesChanged(data: { playerProperties: PlayerProperties }, meta: GameEventMeta): void {
|
||||
export function playerPropertiesChanged(data: { playerProperties: ServerInfo_PlayerProperties }, meta: GameEventMeta): void {
|
||||
GamePersistence.playerPropertiesChanged(meta.gameId, meta.playerId, data.playerProperties);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { GameEventMeta, RevealCardsData } from 'types';
|
||||
import type { Event_RevealCards } from 'generated/proto/event_reveal_cards_pb';
|
||||
import type { GameEventMeta } from 'types';
|
||||
import { GamePersistence } from '../../persistence';
|
||||
|
||||
export function revealCards(data: RevealCardsData, meta: GameEventMeta): void {
|
||||
export function revealCards(data: Event_RevealCards, meta: GameEventMeta): void {
|
||||
GamePersistence.cardsRevealed(meta.gameId, meta.playerId, data);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { GameEventMeta, ReverseTurnData } from 'types';
|
||||
import type { Event_ReverseTurn } from 'generated/proto/event_reverse_turn_pb';
|
||||
import type { GameEventMeta } from 'types';
|
||||
import { GamePersistence } from '../../persistence';
|
||||
|
||||
export function reverseTurn(data: ReverseTurnData, meta: GameEventMeta): void {
|
||||
export function reverseTurn(data: Event_ReverseTurn, meta: GameEventMeta): void {
|
||||
GamePersistence.turnReversed(meta.gameId, data.reversed);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { GameEventMeta, RollDieData } from 'types';
|
||||
import type { Event_RollDie } from 'generated/proto/event_roll_die_pb';
|
||||
import type { GameEventMeta } from 'types';
|
||||
import { GamePersistence } from '../../persistence';
|
||||
|
||||
export function rollDie(data: RollDieData, meta: GameEventMeta): void {
|
||||
export function rollDie(data: Event_RollDie, meta: GameEventMeta): void {
|
||||
GamePersistence.dieRolled(meta.gameId, meta.playerId, data);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { GameEventMeta, SetActivePhaseData } from 'types';
|
||||
import type { Event_SetActivePhase } from 'generated/proto/event_set_active_phase_pb';
|
||||
import type { GameEventMeta } from 'types';
|
||||
import { GamePersistence } from '../../persistence';
|
||||
|
||||
export function setActivePhase(data: SetActivePhaseData, meta: GameEventMeta): void {
|
||||
export function setActivePhase(data: Event_SetActivePhase, meta: GameEventMeta): void {
|
||||
GamePersistence.activePhaseSet(meta.gameId, data.phase);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { GameEventMeta, SetActivePlayerData } from 'types';
|
||||
import type { Event_SetActivePlayer } from 'generated/proto/event_set_active_player_pb';
|
||||
import type { GameEventMeta } from 'types';
|
||||
import { GamePersistence } from '../../persistence';
|
||||
|
||||
export function setActivePlayer(data: SetActivePlayerData, meta: GameEventMeta): void {
|
||||
export function setActivePlayer(data: Event_SetActivePlayer, meta: GameEventMeta): void {
|
||||
GamePersistence.activePlayerSet(meta.gameId, data.activePlayerId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { GameEventMeta, SetCardAttrData } from 'types';
|
||||
import type { Event_SetCardAttr } from 'generated/proto/event_set_card_attr_pb';
|
||||
import type { GameEventMeta } from 'types';
|
||||
import { GamePersistence } from '../../persistence';
|
||||
|
||||
export function setCardAttr(data: SetCardAttrData, meta: GameEventMeta): void {
|
||||
export function setCardAttr(data: Event_SetCardAttr, meta: GameEventMeta): void {
|
||||
GamePersistence.cardAttrChanged(meta.gameId, meta.playerId, data);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { GameEventMeta, SetCardCounterData } from 'types';
|
||||
import type { Event_SetCardCounter } from 'generated/proto/event_set_card_counter_pb';
|
||||
import type { GameEventMeta } from 'types';
|
||||
import { GamePersistence } from '../../persistence';
|
||||
|
||||
export function setCardCounter(data: SetCardCounterData, meta: GameEventMeta): void {
|
||||
export function setCardCounter(data: Event_SetCardCounter, meta: GameEventMeta): void {
|
||||
GamePersistence.cardCounterChanged(meta.gameId, meta.playerId, data);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { GameEventMeta, SetCounterData } from 'types';
|
||||
import type { Event_SetCounter } from 'generated/proto/event_set_counter_pb';
|
||||
import type { GameEventMeta } from 'types';
|
||||
import { GamePersistence } from '../../persistence';
|
||||
|
||||
export function setCounter(data: SetCounterData, meta: GameEventMeta): void {
|
||||
export function setCounter(data: Event_SetCounter, meta: GameEventMeta): void {
|
||||
GamePersistence.counterSet(meta.gameId, meta.playerId, data);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { GameEventMeta, ShuffleData } from 'types';
|
||||
import type { Event_Shuffle } from 'generated/proto/event_shuffle_pb';
|
||||
import type { GameEventMeta } from 'types';
|
||||
import { GamePersistence } from '../../persistence';
|
||||
|
||||
export function shuffle(data: ShuffleData, meta: GameEventMeta): void {
|
||||
export function shuffle(data: Event_Shuffle, meta: GameEventMeta): void {
|
||||
GamePersistence.zoneShuffled(meta.gameId, meta.playerId, data);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,33 +1,31 @@
|
|||
import { GameDispatch } from 'store';
|
||||
import {
|
||||
AttachCardData,
|
||||
ChangeZonePropertiesData,
|
||||
CreateArrowData,
|
||||
CreateCounterData,
|
||||
CreateTokenData,
|
||||
DelCounterData,
|
||||
DeleteArrowData,
|
||||
DestroyCardData,
|
||||
DrawCardsData,
|
||||
DumpZoneData,
|
||||
FlipCardData,
|
||||
GameStateChangedData,
|
||||
MoveCardData,
|
||||
PlayerProperties,
|
||||
RevealCardsData,
|
||||
RollDieData,
|
||||
SetCardAttrData,
|
||||
SetCardCounterData,
|
||||
SetCounterData,
|
||||
ShuffleData,
|
||||
} from 'types';
|
||||
import type { Event_AttachCard } from 'generated/proto/event_attach_card_pb';
|
||||
import type { Event_ChangeZoneProperties } from 'generated/proto/event_change_zone_properties_pb';
|
||||
import type { Event_CreateArrow } from 'generated/proto/event_create_arrow_pb';
|
||||
import type { Event_CreateCounter } from 'generated/proto/event_create_counter_pb';
|
||||
import type { Event_CreateToken } from 'generated/proto/event_create_token_pb';
|
||||
import type { Event_DelCounter } from 'generated/proto/event_del_counter_pb';
|
||||
import type { Event_DeleteArrow } from 'generated/proto/event_delete_arrow_pb';
|
||||
import type { Event_DestroyCard } from 'generated/proto/event_destroy_card_pb';
|
||||
import type { Event_DrawCards } from 'generated/proto/event_draw_cards_pb';
|
||||
import type { Event_DumpZone } from 'generated/proto/event_dump_zone_pb';
|
||||
import type { Event_FlipCard } from 'generated/proto/event_flip_card_pb';
|
||||
import type { Event_GameStateChanged } from 'generated/proto/event_game_state_changed_pb';
|
||||
import type { Event_MoveCard } from 'generated/proto/event_move_card_pb';
|
||||
import type { ServerInfo_PlayerProperties } from 'generated/proto/serverinfo_playerproperties_pb';
|
||||
import type { Event_RevealCards } from 'generated/proto/event_reveal_cards_pb';
|
||||
import type { Event_RollDie } from 'generated/proto/event_roll_die_pb';
|
||||
import type { Event_SetCardAttr } from 'generated/proto/event_set_card_attr_pb';
|
||||
import type { Event_SetCardCounter } from 'generated/proto/event_set_card_counter_pb';
|
||||
import type { Event_SetCounter } from 'generated/proto/event_set_counter_pb';
|
||||
import type { Event_Shuffle } from 'generated/proto/event_shuffle_pb';
|
||||
|
||||
export class GamePersistence {
|
||||
static gameStateChanged(gameId: number, data: GameStateChangedData): void {
|
||||
static gameStateChanged(gameId: number, data: Event_GameStateChanged): void {
|
||||
GameDispatch.gameStateChanged(gameId, data);
|
||||
}
|
||||
|
||||
static playerJoined(gameId: number, playerProperties: PlayerProperties): void {
|
||||
static playerJoined(gameId: number, playerProperties: ServerInfo_PlayerProperties): void {
|
||||
GameDispatch.playerJoined(gameId, playerProperties);
|
||||
}
|
||||
|
||||
|
|
@ -35,7 +33,7 @@ export class GamePersistence {
|
|||
GameDispatch.playerLeft(gameId, playerId, reason);
|
||||
}
|
||||
|
||||
static playerPropertiesChanged(gameId: number, playerId: number, properties: PlayerProperties): void {
|
||||
static playerPropertiesChanged(gameId: number, playerId: number, properties: ServerInfo_PlayerProperties): void {
|
||||
GameDispatch.playerPropertiesChanged(gameId, playerId, properties);
|
||||
}
|
||||
|
||||
|
|
@ -55,67 +53,67 @@ export class GamePersistence {
|
|||
GameDispatch.gameSay(gameId, playerId, message);
|
||||
}
|
||||
|
||||
static cardMoved(gameId: number, playerId: number, data: MoveCardData): void {
|
||||
static cardMoved(gameId: number, playerId: number, data: Event_MoveCard): void {
|
||||
GameDispatch.cardMoved(gameId, playerId, data);
|
||||
}
|
||||
|
||||
static cardFlipped(gameId: number, playerId: number, data: FlipCardData): void {
|
||||
static cardFlipped(gameId: number, playerId: number, data: Event_FlipCard): void {
|
||||
GameDispatch.cardFlipped(gameId, playerId, data);
|
||||
}
|
||||
|
||||
static cardDestroyed(gameId: number, playerId: number, data: DestroyCardData): void {
|
||||
static cardDestroyed(gameId: number, playerId: number, data: Event_DestroyCard): void {
|
||||
GameDispatch.cardDestroyed(gameId, playerId, data);
|
||||
}
|
||||
|
||||
static cardAttached(gameId: number, playerId: number, data: AttachCardData): void {
|
||||
static cardAttached(gameId: number, playerId: number, data: Event_AttachCard): void {
|
||||
GameDispatch.cardAttached(gameId, playerId, data);
|
||||
}
|
||||
|
||||
static tokenCreated(gameId: number, playerId: number, data: CreateTokenData): void {
|
||||
static tokenCreated(gameId: number, playerId: number, data: Event_CreateToken): void {
|
||||
GameDispatch.tokenCreated(gameId, playerId, data);
|
||||
}
|
||||
|
||||
static cardAttrChanged(gameId: number, playerId: number, data: SetCardAttrData): void {
|
||||
static cardAttrChanged(gameId: number, playerId: number, data: Event_SetCardAttr): void {
|
||||
GameDispatch.cardAttrChanged(gameId, playerId, data);
|
||||
}
|
||||
|
||||
static cardCounterChanged(gameId: number, playerId: number, data: SetCardCounterData): void {
|
||||
static cardCounterChanged(gameId: number, playerId: number, data: Event_SetCardCounter): void {
|
||||
GameDispatch.cardCounterChanged(gameId, playerId, data);
|
||||
}
|
||||
|
||||
static arrowCreated(gameId: number, playerId: number, data: CreateArrowData): void {
|
||||
static arrowCreated(gameId: number, playerId: number, data: Event_CreateArrow): void {
|
||||
GameDispatch.arrowCreated(gameId, playerId, data);
|
||||
}
|
||||
|
||||
static arrowDeleted(gameId: number, playerId: number, data: DeleteArrowData): void {
|
||||
static arrowDeleted(gameId: number, playerId: number, data: Event_DeleteArrow): void {
|
||||
GameDispatch.arrowDeleted(gameId, playerId, data);
|
||||
}
|
||||
|
||||
static counterCreated(gameId: number, playerId: number, data: CreateCounterData): void {
|
||||
static counterCreated(gameId: number, playerId: number, data: Event_CreateCounter): void {
|
||||
GameDispatch.counterCreated(gameId, playerId, data);
|
||||
}
|
||||
|
||||
static counterSet(gameId: number, playerId: number, data: SetCounterData): void {
|
||||
static counterSet(gameId: number, playerId: number, data: Event_SetCounter): void {
|
||||
GameDispatch.counterSet(gameId, playerId, data);
|
||||
}
|
||||
|
||||
static counterDeleted(gameId: number, playerId: number, data: DelCounterData): void {
|
||||
static counterDeleted(gameId: number, playerId: number, data: Event_DelCounter): void {
|
||||
GameDispatch.counterDeleted(gameId, playerId, data);
|
||||
}
|
||||
|
||||
static cardsDrawn(gameId: number, playerId: number, data: DrawCardsData): void {
|
||||
static cardsDrawn(gameId: number, playerId: number, data: Event_DrawCards): void {
|
||||
GameDispatch.cardsDrawn(gameId, playerId, data);
|
||||
}
|
||||
|
||||
static cardsRevealed(gameId: number, playerId: number, data: RevealCardsData): void {
|
||||
static cardsRevealed(gameId: number, playerId: number, data: Event_RevealCards): void {
|
||||
GameDispatch.cardsRevealed(gameId, playerId, data);
|
||||
}
|
||||
|
||||
static zoneShuffled(gameId: number, playerId: number, data: ShuffleData): void {
|
||||
static zoneShuffled(gameId: number, playerId: number, data: Event_Shuffle): void {
|
||||
GameDispatch.zoneShuffled(gameId, playerId, data);
|
||||
}
|
||||
|
||||
static dieRolled(gameId: number, playerId: number, data: RollDieData): void {
|
||||
static dieRolled(gameId: number, playerId: number, data: Event_RollDie): void {
|
||||
GameDispatch.dieRolled(gameId, playerId, data);
|
||||
}
|
||||
|
||||
|
|
@ -131,11 +129,11 @@ export class GamePersistence {
|
|||
GameDispatch.turnReversed(gameId, reversed);
|
||||
}
|
||||
|
||||
static zoneDumped(gameId: number, playerId: number, data: DumpZoneData): void {
|
||||
static zoneDumped(gameId: number, playerId: number, data: Event_DumpZone): void {
|
||||
GameDispatch.zoneDumped(gameId, playerId, data);
|
||||
}
|
||||
|
||||
static zonePropertiesChanged(gameId: number, playerId: number, data: ChangeZonePropertiesData): void {
|
||||
static zonePropertiesChanged(gameId: number, playerId: number, data: Event_ChangeZoneProperties): void {
|
||||
GameDispatch.zonePropertiesChanged(gameId, playerId, data);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,24 +1,27 @@
|
|||
import { ServerDispatch } from 'store';
|
||||
import { BanHistoryItem, LogItem, WarnHistoryItem, WarnListItem } from 'types';
|
||||
import type { ServerInfo_Ban } from 'generated/proto/serverinfo_ban_pb';
|
||||
import type { ServerInfo_ChatMessage } from 'generated/proto/serverinfo_chat_message_pb';
|
||||
import type { ServerInfo_Warning } from 'generated/proto/serverinfo_warning_pb';
|
||||
import type { Response_WarnList } from 'generated/proto/response_warn_list_pb';
|
||||
|
||||
export class ModeratorPersistence {
|
||||
static banFromServer(userName: string): void {
|
||||
ServerDispatch.banFromServer(userName);
|
||||
}
|
||||
|
||||
static banHistory(userName: string, banHistory: BanHistoryItem[]): void {
|
||||
static banHistory(userName: string, banHistory: ServerInfo_Ban[]): void {
|
||||
ServerDispatch.banHistory(userName, banHistory);
|
||||
}
|
||||
|
||||
static viewLogs(logs: LogItem[]): void {
|
||||
static viewLogs(logs: ServerInfo_ChatMessage[]): void {
|
||||
ServerDispatch.viewLogs(logs);
|
||||
}
|
||||
|
||||
static warnHistory(userName: string, warnHistory: WarnHistoryItem[]): void {
|
||||
static warnHistory(userName: string, warnHistory: ServerInfo_Warning[]): void {
|
||||
ServerDispatch.warnHistory(userName, warnHistory);
|
||||
}
|
||||
|
||||
static warnListOptions(warnList: WarnListItem[]): void {
|
||||
static warnListOptions(warnList: Response_WarnList[]): void {
|
||||
ServerDispatch.warnListOptions(warnList);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import { RoomsDispatch } from 'store';
|
||||
import { Message, User } from 'types';
|
||||
import { Message } from 'types';
|
||||
import type { ServerInfo_User } from 'generated/proto/serverinfo_user_pb';
|
||||
import type { ServerInfo_Room } from 'generated/proto/serverinfo_room_pb';
|
||||
import type { ServerInfo_Game } from 'generated/proto/serverinfo_game_pb';
|
||||
|
||||
|
|
@ -35,7 +36,7 @@ export class RoomPersistence {
|
|||
RoomsDispatch.addMessage(roomId, message);
|
||||
}
|
||||
|
||||
static userJoined(roomId: number, user: User) {
|
||||
static userJoined(roomId: number, user: ServerInfo_User) {
|
||||
RoomsDispatch.userJoined(roomId, user);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,9 @@
|
|||
import { GameDispatch, ServerDispatch } from 'store';
|
||||
import { DeckList, DeckStorageTreeItem, ReplayMatch, StatusEnum, User, WebSocketConnectOptions } from 'types';
|
||||
import { StatusEnum, WebSocketConnectOptions } from 'types';
|
||||
import type { ServerInfo_User } from 'generated/proto/serverinfo_user_pb';
|
||||
import type { Response_DeckList } from 'generated/proto/response_deck_list_pb';
|
||||
import type { ServerInfo_DeckStorage_TreeItem } from 'generated/proto/serverinfo_deckstorage_pb';
|
||||
import type { ServerInfo_ReplayMatch } from 'generated/proto/serverinfo_replay_match_pb';
|
||||
import { GameEntry } from 'store/game/game.interfaces';
|
||||
import { sanitizeHtml } from 'websocket/utils';
|
||||
import {
|
||||
|
|
@ -51,11 +55,11 @@ export class SessionPersistence {
|
|||
ServerDispatch.testConnectionFailed();
|
||||
}
|
||||
|
||||
static updateBuddyList(buddyList: User[]) {
|
||||
static updateBuddyList(buddyList: ServerInfo_User[]) {
|
||||
ServerDispatch.updateBuddyList(buddyList);
|
||||
}
|
||||
|
||||
static addToBuddyList(user: User) {
|
||||
static addToBuddyList(user: ServerInfo_User) {
|
||||
ServerDispatch.addToBuddyList(user);
|
||||
}
|
||||
|
||||
|
|
@ -63,11 +67,11 @@ export class SessionPersistence {
|
|||
ServerDispatch.removeFromBuddyList(userName);
|
||||
}
|
||||
|
||||
static updateIgnoreList(ignoreList: User[]) {
|
||||
static updateIgnoreList(ignoreList: ServerInfo_User[]) {
|
||||
ServerDispatch.updateIgnoreList(ignoreList);
|
||||
}
|
||||
|
||||
static addToIgnoreList(user: User) {
|
||||
static addToIgnoreList(user: ServerInfo_User) {
|
||||
ServerDispatch.addToIgnoreList(user);
|
||||
}
|
||||
|
||||
|
|
@ -87,15 +91,15 @@ export class SessionPersistence {
|
|||
}
|
||||
}
|
||||
|
||||
static updateUser(user: User) {
|
||||
static updateUser(user: ServerInfo_User) {
|
||||
ServerDispatch.updateUser(user);
|
||||
}
|
||||
|
||||
static updateUsers(users: User[]) {
|
||||
static updateUsers(users: ServerInfo_User[]) {
|
||||
ServerDispatch.updateUsers(users);
|
||||
}
|
||||
|
||||
static userJoined(user: User) {
|
||||
static userJoined(user: ServerInfo_User) {
|
||||
ServerDispatch.userJoined(user);
|
||||
}
|
||||
|
||||
|
|
@ -171,7 +175,7 @@ export class SessionPersistence {
|
|||
ServerDispatch.accountImageChanged({ avatarBmp });
|
||||
}
|
||||
|
||||
static getUserInfo(userInfo: User) {
|
||||
static getUserInfo(userInfo: ServerInfo_User) {
|
||||
ServerDispatch.getUserInfo(userInfo);
|
||||
}
|
||||
|
||||
|
|
@ -238,11 +242,11 @@ export class SessionPersistence {
|
|||
ServerDispatch.deckDelete(deckId);
|
||||
}
|
||||
|
||||
static updateServerDecks(deckList: DeckList): void {
|
||||
static updateServerDecks(deckList: Response_DeckList): void {
|
||||
ServerDispatch.backendDecks(deckList);
|
||||
}
|
||||
|
||||
static uploadServerDeck(path: string, treeItem: DeckStorageTreeItem): void {
|
||||
static uploadServerDeck(path: string, treeItem: ServerInfo_DeckStorage_TreeItem): void {
|
||||
ServerDispatch.deckUpload(path, treeItem);
|
||||
}
|
||||
|
||||
|
|
@ -254,11 +258,11 @@ export class SessionPersistence {
|
|||
ServerDispatch.deckDelDir(path);
|
||||
}
|
||||
|
||||
static replayList(matchList: ReplayMatch[]): void {
|
||||
static replayList(matchList: ServerInfo_ReplayMatch[]): void {
|
||||
ServerDispatch.replayList(matchList);
|
||||
}
|
||||
|
||||
static replayAdded(matchInfo: ReplayMatch): void {
|
||||
static replayAdded(matchInfo: ServerInfo_ReplayMatch): void {
|
||||
ServerDispatch.replayAdded(matchInfo);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue