mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-11 00:24:47 -07:00
upgrade packages + improve typing
This commit is contained in:
parent
fd55f4fb7f
commit
19f5eefdd2
138 changed files with 4504 additions and 11015 deletions
|
|
@ -2,7 +2,9 @@ import {
|
|||
BanHistoryItem,
|
||||
DeckList,
|
||||
DeckStorageTreeItem,
|
||||
Game,
|
||||
LogItem,
|
||||
ProtoInit,
|
||||
ReplayMatch,
|
||||
SortDirection,
|
||||
StatusEnum,
|
||||
|
|
@ -12,20 +14,30 @@ import {
|
|||
WarnHistoryItem,
|
||||
WarnListItem,
|
||||
} from 'types';
|
||||
import { create } from '@bufbuild/protobuf';
|
||||
import { ServerInfo_GameSchema } from 'generated/proto/serverinfo_game_pb';
|
||||
import { ServerInfo_UserSchema } from 'generated/proto/serverinfo_user_pb';
|
||||
import { ServerInfo_ReplayMatchSchema } from 'generated/proto/serverinfo_replay_match_pb';
|
||||
import { ServerInfo_ChatMessageSchema } from 'generated/proto/serverinfo_chat_message_pb';
|
||||
import { ServerInfo_BanSchema } from 'generated/proto/serverinfo_ban_pb';
|
||||
import { ServerInfo_WarningSchema } from 'generated/proto/serverinfo_warning_pb';
|
||||
import { Response_WarnListSchema } from 'generated/proto/response_warn_list_pb';
|
||||
import { ServerInfo_DeckStorage_TreeItemSchema, ServerInfo_DeckStorage_FolderSchema } from 'generated/proto/serverinfo_deckstorage_pb';
|
||||
import { Response_DeckListSchema } from 'generated/proto/response_deck_list_pb';
|
||||
import { ServerState } from '../server.interfaces';
|
||||
|
||||
export function makeUser(overrides: Partial<User> = {}): User {
|
||||
return {
|
||||
export function makeUser(overrides: ProtoInit<User> = {}): User {
|
||||
return create(ServerInfo_UserSchema, {
|
||||
name: 'TestUser',
|
||||
accountageSecs: 0n,
|
||||
privlevel: '',
|
||||
userLevel: 0,
|
||||
...overrides,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
export function makeLogItem(overrides: Partial<LogItem> = {}): LogItem {
|
||||
return {
|
||||
export function makeLogItem(overrides: ProtoInit<LogItem> = {}): LogItem {
|
||||
return create(ServerInfo_ChatMessageSchema, {
|
||||
message: '',
|
||||
senderId: '',
|
||||
senderIp: '',
|
||||
|
|
@ -35,11 +47,11 @@ export function makeLogItem(overrides: Partial<LogItem> = {}): LogItem {
|
|||
targetType: '',
|
||||
time: '',
|
||||
...overrides,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
export function makeBanHistoryItem(overrides: Partial<BanHistoryItem> = {}): BanHistoryItem {
|
||||
return {
|
||||
export function makeBanHistoryItem(overrides: ProtoInit<BanHistoryItem> = {}): BanHistoryItem {
|
||||
return create(ServerInfo_BanSchema, {
|
||||
adminId: '',
|
||||
adminName: '',
|
||||
banTime: '',
|
||||
|
|
@ -47,47 +59,45 @@ export function makeBanHistoryItem(overrides: Partial<BanHistoryItem> = {}): Ban
|
|||
banReason: '',
|
||||
visibleReason: '',
|
||||
...overrides,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
export function makeWarnHistoryItem(overrides: Partial<WarnHistoryItem> = {}): WarnHistoryItem {
|
||||
return {
|
||||
export function makeWarnHistoryItem(overrides: ProtoInit<WarnHistoryItem> = {}): WarnHistoryItem {
|
||||
return create(ServerInfo_WarningSchema, {
|
||||
userName: '',
|
||||
adminName: '',
|
||||
reason: '',
|
||||
timeOf: '',
|
||||
...overrides,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
export function makeWarnListItem(overrides: Partial<WarnListItem> = {}): WarnListItem {
|
||||
return {
|
||||
warning: '',
|
||||
export function makeWarnListItem(overrides: ProtoInit<WarnListItem> = {}): WarnListItem {
|
||||
return create(Response_WarnListSchema, {
|
||||
warning: [],
|
||||
userName: '',
|
||||
userClientid: '',
|
||||
...overrides,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
export function makeDeckTreeItem(overrides: Partial<DeckStorageTreeItem> = {}): DeckStorageTreeItem {
|
||||
return {
|
||||
export function makeDeckTreeItem(overrides: ProtoInit<DeckStorageTreeItem> = {}): DeckStorageTreeItem {
|
||||
return create(ServerInfo_DeckStorage_TreeItemSchema, {
|
||||
id: 1,
|
||||
name: 'item',
|
||||
file: { creationTime: 0 },
|
||||
folder: null,
|
||||
...overrides,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
export function makeDeckList(overrides: Partial<DeckList> = {}): DeckList {
|
||||
return {
|
||||
root: { items: [] },
|
||||
export function makeDeckList(overrides: ProtoInit<DeckList> = {}): DeckList {
|
||||
return create(Response_DeckListSchema, {
|
||||
root: create(ServerInfo_DeckStorage_FolderSchema, { items: [] }),
|
||||
...overrides,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
export function makeReplayMatch(overrides: Partial<ReplayMatch> = {}): ReplayMatch {
|
||||
return {
|
||||
export function makeReplayMatch(overrides: ProtoInit<ReplayMatch> = {}): ReplayMatch {
|
||||
return create(ServerInfo_ReplayMatchSchema, {
|
||||
gameId: 1,
|
||||
roomName: 'Test Room',
|
||||
timeStarted: 0,
|
||||
|
|
@ -97,7 +107,11 @@ export function makeReplayMatch(overrides: Partial<ReplayMatch> = {}): ReplayMat
|
|||
doNotHide: false,
|
||||
replayList: [],
|
||||
...overrides,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
export function makeGame(overrides: Partial<Game> = {}): Game {
|
||||
return { ...create(ServerInfo_GameSchema, { description: '' }), gameType: '', ...overrides };
|
||||
}
|
||||
|
||||
export function makeConnectOptions(overrides: Partial<WebSocketConnectOptions> = {}): WebSocketConnectOptions {
|
||||
|
|
@ -148,6 +162,7 @@ export function makeServerState(overrides: Partial<ServerState> = {}): ServerSta
|
|||
replays: [],
|
||||
backendDecks: null,
|
||||
gamesOfUser: {},
|
||||
registrationError: null,
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue