Skip to content

Commit

Permalink
#277 Fix harks saving
Browse files Browse the repository at this point in the history
  • Loading branch information
kyvg committed Sep 6, 2023
1 parent d540073 commit cd4ce69
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"start": "NODE_ENV=production ts-node src/fwo.ts",
"dev": "ts-node src/cli/dev.ts",
"test": "ts-node src/cli/test.ts -i",
"reset-harks": "ts-node src/scripts/resetHarks.ts",
"lint": "eslint --fix src/ --ext .js,.ts",
"types": "tsc --noEmit"
},
Expand Down
3 changes: 1 addition & 2 deletions src/arena/CharacterService.js
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ class CharacterService {
try {
console.log('Saving char :: id', this.id);
const {
gold, exp, magics, bonus, items, skills, lvl, clan, free, harks,
gold, exp, magics, bonus, items, skills, lvl, clan, free,
} = this;
return await updateCharacter(this.id, {
gold,
Expand All @@ -658,7 +658,6 @@ class CharacterService {
skills,
lvl,
clan,
harks,
penalty: this.charObj.penalty,
free,
expLimit: this.charObj.expLimit,
Expand Down
21 changes: 21 additions & 0 deletions src/cli/resetHarks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { times } from 'lodash';
import { profsData, profsList } from '@/data/profs';
import { connect } from '@/models';
import { CharModel } from '@/models/character';

const main = async () => {
await connect();

await CharModel.bulkWrite(
times(10).map((lvl) => profsList.map((prof) => ({
updateMany: {
filter: { lvl, prof },
update: { $set: { free: lvl * 10, harks: profsData[prof].hark } },
},
}))).flat(),
);

process.exit(0);
};

void main();

0 comments on commit cd4ce69

Please sign in to comment.