Edit research branches in local saves
This commit is contained in:
1 parent
3e2acc5a17
commit
3e08e9314e
14 files changed
+291
-15
No files matched your search
@@ -1,5 +1,5 @@
|
||||
import type { AppErrorCode } from '@shared/errors.ts';
|
||||
import type { CurrencyEdits, OfficialImportOptions, OfficialPreview, SaveDetails, SaveList } from '@shared/schemas/saves.ts';
|
||||
import type { CurrencyEdits, OfficialImportOptions, OfficialPreview, ResearchBranch, ResearchOperation, SaveDetails, SaveList, SaveResearch } from '@shared/schemas/saves.ts';
|
||||
|
||||
interface Location {
|
||||
readonly gameFolder: string;
|
||||
@@ -12,9 +12,11 @@ export type SaveTask = Location & (
|
||||
| { readonly operation: 'edit'; readonly userId: string; readonly values: CurrencyEdits }
|
||||
| { readonly operation: 'previewOfficial'; readonly paths: readonly string[]; readonly includeUsedVehicles: boolean }
|
||||
| { readonly operation: 'importOfficial'; readonly paths: readonly string[]; readonly userId: string; readonly options: OfficialImportOptions }
|
||||
| { readonly operation: 'readResearch'; readonly userId: string; readonly branch?: ResearchBranch }
|
||||
| { readonly operation: 'editResearch'; readonly userId: string; readonly branch: ResearchBranch; readonly action: ResearchOperation }
|
||||
| { readonly operation: 'remove'; readonly userId: string }
|
||||
| { readonly operation: 'filter'; readonly profile: Uint8Array; readonly filter: boolean }
|
||||
| { readonly operation: 'create'; readonly login: string; readonly password: string; readonly nick: string }
|
||||
);
|
||||
export type SaveResult = SaveList['saves'] | SaveDetails | OfficialPreview | { userId: string } | Uint8Array | null;
|
||||
export type SaveResult = SaveList['saves'] | SaveDetails | OfficialPreview | SaveResearch | { userId: string } | Uint8Array | null;
|
||||
export type SaveReply = { ok: true; result: SaveResult } | { ok: false; error: AppErrorCode };
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { MessageEvent } from 'electron';
|
||||
import { AccountStore, editSaveCurrencies, importOfficialBackup, listSaveSummaries, prepareTransferredProfile, previewOfficialBackup, readSaveDetails } from '@wto/server';
|
||||
import { AccountStore, editSaveCurrencies, editSaveResearch, importOfficialBackup, listSaveSummaries, prepareTransferredProfile, previewOfficialBackup, readSaveDetails, readSaveResearch } from '@wto/server';
|
||||
import type { SaveTask, SaveReply } from './save-protocol.ts';
|
||||
|
||||
function execute(task: SaveTask): SaveReply {
|
||||
@@ -17,6 +17,14 @@ function execute(task: SaveTask): SaveReply {
|
||||
return { ok: true, result: previewOfficialBackup(task, task.paths, task.includeUsedVehicles) };
|
||||
case 'importOfficial':
|
||||
return { ok: true, result: importOfficialBackup(task, task.userId, task.paths, task.options) };
|
||||
case 'readResearch': {
|
||||
const result = readSaveResearch(task, task.userId, task.branch);
|
||||
return result ? { ok: true, result } : { ok: false, error: 'save_not_found' };
|
||||
}
|
||||
case 'editResearch': {
|
||||
const result = editSaveResearch(task, task.userId, task.branch, task.action);
|
||||
return result ? { ok: true, result } : { ok: false, error: 'save_operation_failed' };
|
||||
}
|
||||
case 'remove':
|
||||
return new AccountStore(task.dataFolder).remove(task.userId)
|
||||
? { ok: true, result: null } : { ok: false, error: 'save_not_found' };
|
||||
|
||||
Reference in new issue
Block a user