fix: unify opening booster prop ids as 2006 and 2007
This commit is contained in:
@@ -46,7 +46,7 @@ export default async function (ctx: FunctionContext) {
|
||||
data.infiniteRocketTime = user.data?.infiniteRocketTime || 0;
|
||||
let propType = Number(ctx.body.propType);
|
||||
let propData = ctx.body.propData;
|
||||
const boosterField = propType === 2004 ? "hourglassAmount" : propType === 2005 ? "rocketAmount" : null;
|
||||
const boosterField = propType === 2006 ? "hourglassAmount" : propType === 2007 ? "rocketAmount" : null;
|
||||
if (!propType && propType != 0) {
|
||||
return { code: 0, data: null, msg: "未获取到propType" };
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ function save(propType, propData, extra = {}) {
|
||||
return userProp({ body: { uid: "u1", token: "valid", action: "save", propType, propData, ...extra } });
|
||||
}
|
||||
|
||||
for (const [propType, field, responseField] of [[2004, "hourglassAmount", "hourglass"], [2005, "rocketAmount", "rocket"]]) {
|
||||
for (const [propType, field, responseField] of [[2006, "hourglassAmount", "hourglass"], [2007, "rocketAmount", "rocket"]]) {
|
||||
test(`${propType} saves only its own count and timestamp`, async () => {
|
||||
reset();
|
||||
const original = { ...user };
|
||||
@@ -69,7 +69,7 @@ for (const [propType, field, responseField] of [[2004, "hourglassAmount", "hourg
|
||||
|
||||
test(`${propType} does not undo concurrent changes to another prop or infinite entitlement`, async () => {
|
||||
reset();
|
||||
const otherField = propType === 2004 ? "rocketAmount" : "hourglassAmount";
|
||||
const otherField = propType === 2006 ? "rocketAmount" : "hourglassAmount";
|
||||
beforeUpdate = () => Object.assign(user, { hammerAmount: 8, [otherField]: 9, infiniteRocketTime: 999 });
|
||||
await save(propType, "2");
|
||||
assert.equal(user[field], 2);
|
||||
@@ -88,7 +88,7 @@ for (const [propType, field, responseField] of [[2004, "hourglassAmount", "hourg
|
||||
}
|
||||
|
||||
test("invalid token cannot change either new prop", async () => {
|
||||
for (const propType of [2004, 2005]) {
|
||||
for (const propType of [2006, 2007]) {
|
||||
reset();
|
||||
assert.equal((await save(propType, "3", { token: "invalid" })).code, 0);
|
||||
assert.deepEqual(writes, []);
|
||||
|
||||
Reference in New Issue
Block a user