Skip to content

Commit

Permalink
migrate accomplishment/origin/goal values
Browse files Browse the repository at this point in the history
  • Loading branch information
moo-man committed Jan 9, 2025
1 parent 3c5d4dd commit ded8588
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 16 deletions.
7 changes: 7 additions & 0 deletions scripts/common/migration.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,13 @@ export default class Migration {
{
foundry.utils.setProperty(migrated, "system.archetype.id", archetype.id);
}

if (faction)
{
foundry.utils.setProperty(migrated, "system.bio.origin", faction.system.backgrounds.origin.find(i => i.active)?.description || "");
foundry.utils.setProperty(migrated, "system.bio.accomplishment", faction.system.backgrounds.accomplishment.find(i => i.active)?.description || "");
foundry.utils.setProperty(migrated, "system.bio.goal", faction.system.backgrounds.goal.find(i => i.active)?.description || "");
}
}

return migrated;
Expand Down
32 changes: 19 additions & 13 deletions scripts/model/actor/agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,9 @@ export class AgentModel extends StandardWNGActorModel {
height : new fields.StringField(),
eye : new fields.StringField(),
hair : new fields.StringField(),
origin : new fields.SchemaField({
value : new fields.StringField(),
bonus : new fields.StringField()
}),
accomplishment : new fields.SchemaField({
value : new fields.StringField(),
bonus : new fields.StringField()
}),
goal : new fields.SchemaField({
value : new fields.StringField(),
bonus : new fields.StringField()
}),
origin : new fields.StringField(),
accomplishment : new fields.StringField(),
goal : new fields.StringField(),
objective : new fields.StringField()
})

Expand Down Expand Up @@ -90,7 +81,22 @@ export class AgentModel extends StandardWNGActorModel {
}

this.experience.current = this.experience.total - this.experience.spent;
}


static migrateData(data)
{
super.migrateData(data);
if (typeof data.bio.origin == "object")
{
data.bio.origin = data.bio.origin.value;
}
if (typeof data.bio.accomplishment == "object")
{
data.bio.accomplishment = data.bio.accomplishment.value;
}
if (typeof data.bio.goal == "object")
{
data.bio.goal = data.bio.goal.value;
}
}
}
6 changes: 3 additions & 3 deletions static/template/actor/tab/notes.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,19 @@
<div class="form-row background">
<div class="form-field">
<label>{{localize "BIO.ORIGIN"}}</label>
<input type="text" name="system.bio.origin.value" value="{{system.bio.origin.value}}" />
<input type="text" name="system.bio.origin" value="{{system.bio.origin}}" />
</div>
</div>
<div class="form-row background">
<div class="form-field">
<label>{{localize "BIO.ACCOMPLISHMENT"}}</label>
<input type="text" name="system.bio.accomplishment.value" value="{{system.bio.accomplishment.value}}" />
<input type="text" name="system.bio.accomplishment" value="{{system.bio.accomplishment}}" />
</div>
</div>
<div class="form-row background">
<div class="form-field">
<label>{{localize "BIO.GOAL"}}</label>
<input type="text" name="system.bio.goal.value" value="{{system.bio.goal.value}}" />
<input type="text" name="system.bio.goal" value="{{system.bio.goal}}" />
</div>
</div>
<hr>
Expand Down

0 comments on commit ded8588

Please sign in to comment.