This commit is contained in:
2021-02-09 23:32:55 +01:00
parent 92f8fe4ee8
commit 42af291a7c
25 changed files with 587 additions and 62 deletions

View File

@ -128,7 +128,25 @@ export class SoSActor extends Actor {
computeWound() {
return Math.ceil( (this.data.data.stats.strength.value + this.data.data.stats.endurance.value) / 2);
}
/* -------------------------------------------- */
async wornObject( itemID) {
let item = this.getOwnedItem(itemID);
if (item && item.data.data) {
let update = { _id: item._id, "data.worn": !item.data.data.worn };
await this.updateEmbeddedEntity("OwnedItem", update);
}
}
/* -------------------------------------------- */
async equipObject(itemID) {
let item = this.getOwnedItem(itemID);
if (item && item.data.data) {
let update = { _id: item._id, "data.equiped": !item.data.data.equiped };
await this.updateEmbeddedEntity("OwnedItem", update);
}
}
/* -------------------------------------------- */
async controlScores() {
// Defense check
@ -155,6 +173,29 @@ export class SoSActor extends Actor {
}
}
/* -------------------------------------------- */
async updateSkill(skillName, value) {
let skill = this.data.items.find( item => item.name == skillName);
if (skill) {
const update = { _id: skill._id, 'data.value': value };
const updated = await this.updateEmbeddedEntity("OwnedItem", update); // Updates one EmbeddedEntity
}
}
/* -------------------------------------------- */
async updateSkillExperience(skillName, value) {
let skill = this.data.items.find( item => item.name == skillName);
if (skill) {
const update = { _id: skill._id, 'data.xp': value };
const updated = await this.updateEmbeddedEntity("OwnedItem", update); // Updates one EmbeddedEntity
}
}
/* -------------------------------------------- */
getApplicableConsequences( ) {
let consequences = this.data.items.filter( item => item.type == 'consequence' && item.data.severity != 'none');
return consequences;
}
/* -------------------------------------------- */
async rollStat( statKey ) {
@ -163,7 +204,9 @@ export class SoSActor extends Actor {
stat: duplicate(this.data.data.stats[statKey]),
actor: this,
modifierList: SoSUtility.fillRange(-10, +10),
tnList: SoSUtility.fillRange(6, 20)
tnList: SoSUtility.fillRange(6, 20),
consequencesList: duplicate( this.getApplicableConsequences() ),
malusConsequence: 0
}
let html = await renderTemplate('systems/foundryvtt-shadows-over-sol/templates/dialog-flip.html', flipData);
new SoSFlipDialog(flipData, html).render(true);
@ -175,10 +218,12 @@ export class SoSActor extends Actor {
let flipData = {
mode: 'skill',
statList: duplicate(this.data.data.stats),
consequencesList: duplicate( this.getApplicableConsequences() ),
skill: duplicate(skill),
actor: this,
modifierList: SoSUtility.fillRange(-10, +10),
tnList: SoSUtility.fillRange(6, 20)
tnList: SoSUtility.fillRange(6, 20),
malusConsequence: 0
}
flipData.statList['nostat'] = { label: "No stat (ie defaulting skills)", value: 0, cardsuit: "none" }
let html = await renderTemplate('systems/foundryvtt-shadows-over-sol/templates/dialog-flip.html', flipData);