Fully implement settings persistence
This commit is contained in:
@@ -24,27 +24,10 @@ export async function createProfile(
|
||||
dpoint: 0,
|
||||
};
|
||||
|
||||
const missions: MissionState = {
|
||||
team: [],
|
||||
solo: [],
|
||||
};
|
||||
|
||||
const settings: Settings = {
|
||||
bgMusic: 0,
|
||||
forceQuitEn: false,
|
||||
steeringForce: 4,
|
||||
bgVolume: 10,
|
||||
seVolume: 10,
|
||||
cornerGuide: true,
|
||||
lineGuide: false,
|
||||
ghostEn: false,
|
||||
taResultSkip: false,
|
||||
};
|
||||
|
||||
const missions: MissionState = { team: [], solo: [] };
|
||||
const settings: Settings = { music: 0, pack: 13640, paperCup: 0, gauges: 5 };
|
||||
const story: Story = { x: 0, y: 0, rows: [] };
|
||||
|
||||
const timeAttack: TimeAttackState = { courses: [] };
|
||||
|
||||
const unlocks: Unlocks = { cup: 0, gauges: 0, music: 0 };
|
||||
|
||||
await Promise.all([
|
||||
|
||||
@@ -28,6 +28,7 @@ export async function saveProfile(
|
||||
w.story().save(req.profileId, req.story),
|
||||
w.titles().save(req.profileId, req.titles),
|
||||
w.unlocks().save(req.profileId, req.unlocks),
|
||||
w.settings().save(req.profileId, req.settings),
|
||||
]);
|
||||
|
||||
return {
|
||||
|
||||
@@ -6,21 +6,23 @@ export async function saveTimeAttack(
|
||||
w: World,
|
||||
req: SaveTimeAttackRequest
|
||||
): Promise<SaveTimeAttackResponse> {
|
||||
const state = await w.timeAttack().load(req.profileId);
|
||||
const existing = state.courses.find(
|
||||
course => course.courseId === req.payload.courseId
|
||||
);
|
||||
|
||||
if (existing === undefined || existing.totalMsec > req.payload.totalMsec) {
|
||||
const newCourses = state.courses.filter(
|
||||
course => course.courseId !== req.payload.courseId
|
||||
if (req.payload.totalMsec > 0) {
|
||||
const state = await w.timeAttack().load(req.profileId);
|
||||
const existing = state.courses.find(
|
||||
course => course.courseId === req.payload.courseId
|
||||
);
|
||||
|
||||
newCourses.push(req.payload);
|
||||
if (existing === undefined || existing.totalMsec > req.payload.totalMsec) {
|
||||
const newCourses = state.courses.filter(
|
||||
course => course.courseId !== req.payload.courseId
|
||||
);
|
||||
|
||||
const newState = { courses: newCourses };
|
||||
newCourses.push(req.payload);
|
||||
|
||||
await w.timeAttack().save(req.profileId, newState);
|
||||
const newState = { courses: newCourses };
|
||||
|
||||
await w.timeAttack().save(req.profileId, newState);
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user