idz: Add field "c" to story cell tuple

This commit is contained in:
BemaniWitch 2020-10-31 19:33:14 -04:00 committed by Tau
parent dcb4f12a99
commit 1154414885
6 changed files with 48 additions and 4 deletions

View File

@ -144,6 +144,7 @@ create table "idz_story_cell_state" (
"col_no" integer not null,
"a" integer not null,
"b" integer not null,
"c" integer not null,
constraint "idz_story_cell_state_uq" unique (
"profile_id",
"row_no",

View File

@ -38,6 +38,23 @@ create table "idz_stamp_unlock" (
constraint "idz_stamp_unlock_uq" unique ("profile_id", "stamp_no")
);
create table "new_idz_story_cell_state" (
"id" integer primary key not null,
"profile_id" integer not null
references "idz_profile"("id")
on delete cascade,
"row_no" integer not null,
"col_no" integer not null,
"a" integer not null,
"b" integer not null,
"c" integer not null,
constraint "idz_story_cell_state_uq" unique (
"profile_id",
"row_no",
"col_no"
)
);
create table "idz_weekly_missions" (
"id" integer primary key not null
references "idz_profile"("id")
@ -69,6 +86,26 @@ insert into "new_idz_settings" (
0
from "idz_settings" as x;
insert into "new_idz_story_cell_state" (
"id",
"profile_id",
"row_no",
"col_no",
"a",
"b",
"c"
) select
x."id",
x."profile_id",
x."row_no",
x."col_no",
x."a",
x."b",
0
from "idz_story_cell_state" as x;
drop table "idz_settings";
drop table "idz_story_cell_state";
alter table "new_idz_settings" rename to "idz_settings";
alter table "new_idz_story_cell_state" rename to "idz_story_cell_state";

View File

@ -19,7 +19,8 @@ export function saveProfile2(buf: Buffer): SaveProfileRequest {
for (let j = 0; j < 9; j++) {
const a = buf.readUInt32LE(rowOffset + 0x04 + j * 4);
const b = buf.readUInt16LE(rowOffset + 0x28 + j * 2);
const cell = { a, b };
const c = 0; // Added in idz2
const cell = { a, b, c };
cells.set(j, cell);
}

View File

@ -21,7 +21,8 @@ export function saveProfile3(buf: Buffer): SaveProfileRequest {
for (let j = 0; j < 9; j++) {
const a = buf.readUInt8(rowOffset + 0x00 + j);
const b = buf.readUInt8(rowOffset + 0x09 + j);
const cell = { a, b };
const c = 0; // Added in idz2
const cell = { a, b, c };
cells.set(j, cell);
}

View File

@ -1,6 +1,7 @@
export interface StoryCell {
a: number;
b: number;
c: number;
}
export interface StoryRow {

View File

@ -18,7 +18,7 @@ function cellChanged(
return true;
}
return lhs.a !== rhs.a || lhs.b !== rhs.b;
return lhs.a !== rhs.a || lhs.b !== rhs.b || lhs.c !== rhs.c;
}
export class SqlStoryRepository implements FacetRepository<Story> {
@ -63,6 +63,7 @@ export class SqlStoryRepository implements FacetRepository<Story> {
gridRow.cells.set(colNo, {
a: 0,
b: 0,
c: 0,
});
}
@ -70,6 +71,7 @@ export class SqlStoryRepository implements FacetRepository<Story> {
cell.a = parseInt(row.a!);
cell.b = parseInt(row.b!);
cell.c = parseInt(row.c!);
}
return result;
@ -109,9 +111,10 @@ export class SqlStoryRepository implements FacetRepository<Story> {
col_no: j,
a: cell.a,
b: cell.b,
c: cell.c,
})
.onConflict("profile_id", "row_no", "col_no")
.doUpdate(["a", "b"]);
.doUpdate(["a", "b", "c"]);
await this._txn.modify(cellSql);
}