automatically calculate base combat values
This commit is contained in:
parent
a020cb7403
commit
ecfbe9fa2a
15 changed files with 195 additions and 27 deletions
28
src/module/migrations/0-1-0.ts
Normal file
28
src/module/migrations/0-1-0.ts
Normal file
|
@ -0,0 +1,28 @@
|
|||
export async function migrate(): Promise<void> {
|
||||
for (const a of game.actors.entities) {
|
||||
const updateData = getActorUpdateData();
|
||||
console.log(`Migrating actor ${a.name}`);
|
||||
await a.update(updateData, { enforceTypes: false });
|
||||
}
|
||||
}
|
||||
|
||||
function getActorUpdateData(): Record<string, unknown> {
|
||||
const updateData = {
|
||||
data: {
|
||||
combatValues: [
|
||||
"hitPoints",
|
||||
"defense",
|
||||
"initiative",
|
||||
"movement",
|
||||
"meleeAttack",
|
||||
"rangedAttack",
|
||||
"spellcasting",
|
||||
"targetedSpellcasting",
|
||||
].reduce((acc, curr) => {
|
||||
acc[curr] = { "-=base": null };
|
||||
return acc;
|
||||
}, {}),
|
||||
},
|
||||
};
|
||||
return updateData;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue