Step 4 - Hindrance on health/delirium
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
|
||||
import { PegasusUtility } from "./pegasus-utility.js";
|
||||
import { PegasusItemSheet } from "./pegasus-item-sheet.js";
|
||||
import { PegasusRollDialog } from "./pegasus-roll-dialog.js";
|
||||
|
||||
/* -------------------------------------------- */
|
||||
export class PegasusActorSheet extends ActorSheet {
|
||||
@@ -68,6 +69,17 @@ export class PegasusActorSheet extends ActorSheet {
|
||||
return formData;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async openGenericRoll() {
|
||||
let rollData = PegasusUtility.getBasicRollData()
|
||||
rollData.alias = "Dice Pool Roll",
|
||||
rollData.mode = "generic"
|
||||
rollData.title = `Dice Pool Roll`;
|
||||
|
||||
let rollDialog = await PegasusRollDialog.create( this.actor, rollData);
|
||||
rollDialog.render( true );
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
/** @override */
|
||||
activateListeners(html) {
|
||||
@@ -75,6 +87,10 @@ export class PegasusActorSheet extends ActorSheet {
|
||||
|
||||
// Everything below here is only needed if the sheet is editable
|
||||
if (!this.options.editable) return;
|
||||
|
||||
html.bind("keydown", function(e) { // Ignore Enter in actores sheet
|
||||
if (e.keyCode === 13) return false;
|
||||
});
|
||||
|
||||
// Update Inventory Item
|
||||
html.find('.item-edit').click(ev => {
|
||||
@@ -120,6 +136,9 @@ export class PegasusActorSheet extends ActorSheet {
|
||||
html.find('.unarmed-attack').click((event) => {
|
||||
this.actor.rollUnarmedAttack();
|
||||
});
|
||||
html.find('.generic-pool-roll').click((event) => {
|
||||
this.openGenericRoll()
|
||||
} );
|
||||
html.find('.attack-melee').click((event) => {
|
||||
this.actor.rollPool( 'com');
|
||||
});
|
||||
@@ -227,6 +246,7 @@ export class PegasusActorSheet extends ActorSheet {
|
||||
async _onDropItem(event, dragData) {
|
||||
let item = await PegasusUtility.searchItem( dragData)
|
||||
this.actor.preprocessItem( event, item, true )
|
||||
super._onDropItem(event, dragData)
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
@@ -66,10 +66,6 @@ export class PegasusActor extends Actor {
|
||||
for (let key in this.data.data.statistics) {
|
||||
let attr = this.data.data.statistics[key];
|
||||
}
|
||||
/*if ( h != this.data.data.secondary.health.max) {
|
||||
this.data.data.secondary.health.max = h;
|
||||
updates.push( {'data.secondary.health.max': h} );
|
||||
}*/
|
||||
if (updates.length > 0) {
|
||||
this.update(updates);
|
||||
}
|
||||
@@ -262,11 +258,11 @@ export class PegasusActor extends Actor {
|
||||
this.applyRace(item.data)
|
||||
} else if ( item.data.type == 'ability') {
|
||||
this.applyAbility(item.data, [], true)
|
||||
await this.createEmbeddedDocuments('Item', [item.data] )
|
||||
if ( !onDrop) {
|
||||
await this.createEmbeddedDocuments('Item', [item.data] )
|
||||
}
|
||||
} else {
|
||||
if ( onDrop) {
|
||||
await super._onDropItem(event, dragData)
|
||||
} else {
|
||||
if ( !onDrop) {
|
||||
await this.createEmbeddedDocuments('Item', [item.data] )
|
||||
}
|
||||
}
|
||||
@@ -428,6 +424,16 @@ export class PegasusActor extends Actor {
|
||||
//console.log("UPD", updates, this.data.data.biodata)
|
||||
await this.update(updates)
|
||||
}
|
||||
|
||||
// Update current hindrance level
|
||||
let hindrance = this.data.data.combat.hindrancedice
|
||||
if ( this.data.data.secondary.health.value < 0) {
|
||||
hindrance += Math.abs(this.data.data.secondary.health.value)
|
||||
}
|
||||
if ( this.data.data.secondary.delirium.value < 0) {
|
||||
hindrance += Math.abs(this.data.data.secondary.delirium.value)
|
||||
}
|
||||
this.data.data.combat.hindrancedice = hindrance
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@@ -470,17 +476,63 @@ export class PegasusActor extends Actor {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
applyAbility(ability, updates = [], directUpdate = false) {
|
||||
async applyAbility(ability, updates = [], directUpdate = false) {
|
||||
// manage stat bonus
|
||||
if (ability.data.affectedstat != "notapplicable") {
|
||||
let stat = duplicate(this.data.data.statistics[ability.data.affectedstat])
|
||||
stat.value += parseInt(ability.data.statlevelincrease)
|
||||
stat.mod += parseInt(ability.data.statmodifier)
|
||||
stat.mod += Number(ability.data.statmodifier)
|
||||
updates[`data.statistics.${ability.data.affectedstat}`] = stat
|
||||
if(directUpdate) {
|
||||
this.update(updates)
|
||||
}
|
||||
// manage status bonus
|
||||
if (ability.data.statusaffected != "notapplicable") {
|
||||
if ( ability.data.statusaffected == 'nrg' ) {
|
||||
let nrg = duplicate( this.data.data.nrg)
|
||||
nrg.mod += Number(ability.data.statusmodifier)
|
||||
updates[`data.nrg`] = nrg
|
||||
}
|
||||
if ( ability.data.statusaffected == 'health' ) {
|
||||
let health = duplicate( this.data.data.secondary.health)
|
||||
health.bonus += Number(ability.data.statusmodifier)
|
||||
updates[`data.secondary.health`] = health
|
||||
}
|
||||
if ( ability.data.statusaffected == 'delirium' ) {
|
||||
let delirium = duplicate( this.data.data.secondary.delirium)
|
||||
delirium.bonus += Number(ability.data.statusmodifier)
|
||||
updates[`data.secondary.delirium`] = delirium
|
||||
}
|
||||
}
|
||||
if ( directUpdate ) {
|
||||
await this.update(updates)
|
||||
}
|
||||
let newItems = []
|
||||
if (ability.data.effectsgained) {
|
||||
for (let effect of ability.data.effectsgained) {
|
||||
newItems.push(effect);
|
||||
}
|
||||
}
|
||||
if (ability.data.powersgained) {
|
||||
for (let power of ability.data.powersgained) {
|
||||
newItems.push(power);
|
||||
}
|
||||
}
|
||||
if (ability.data.specialisations) {
|
||||
for (let spec of ability.data.specialisations) {
|
||||
newItems.push(spec);
|
||||
}
|
||||
}
|
||||
if (ability.data.attackgained) {
|
||||
for (let weapon of ability.data.attackgained) {
|
||||
newItems.push(weapon);
|
||||
}
|
||||
}
|
||||
if (ability.data.armorgained) {
|
||||
for (let armor of ability.data.armorgained) {
|
||||
newItems.push(armor);
|
||||
}
|
||||
}
|
||||
await this.createEmbeddedDocuments('Item', newItems)
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async applyRace(race) {
|
||||
let updates = { 'data.biodata.racename': race.name }
|
||||
@@ -492,26 +544,11 @@ export class PegasusActor extends Actor {
|
||||
newItems.push(ability)
|
||||
this.applyAbility(ability, updates)
|
||||
}
|
||||
if (race.data.powersgained) {
|
||||
for (let power of race.data.powersgained) {
|
||||
if (race.data.perksgained) {
|
||||
for (let power of race.data.perks) {
|
||||
newItems.push(power);
|
||||
}
|
||||
}
|
||||
if (race.data.specialisations) {
|
||||
for (let spec of race.data.specialisations) {
|
||||
newItems.push(spec);
|
||||
}
|
||||
}
|
||||
if (race.data.attackgained) {
|
||||
for (let weapon of race.data.attackgained) {
|
||||
newItems.push(weapon);
|
||||
}
|
||||
}
|
||||
if (race.data.armorgained) {
|
||||
for (let armor of race.data.armorgained) {
|
||||
newItems.push(armor);
|
||||
}
|
||||
}
|
||||
|
||||
await this.update(updates)
|
||||
await this.createEmbeddedDocuments('Item', newItems)
|
||||
@@ -551,6 +588,9 @@ export class PegasusActor extends Actor {
|
||||
if (this.data.data.combat.stunlevel > 0) {
|
||||
effectsList.push( { label: "Stun Hindrance", type: "hindrance", applied: false, value: this.data.data.combat.stunlevel } )
|
||||
}
|
||||
if (this.data.data.combat.hindrancedice > 0) {
|
||||
effectsList.push( { label: "Health/Delirium Hindrance", type: "hindrance", applied: false, value: this.data.data.combat.hindrancedice } )
|
||||
}
|
||||
let effects = this.data.items.filter( item => item.type == 'effect' )
|
||||
for( let effect of effects) {
|
||||
effect = duplicate(effect)
|
||||
@@ -576,6 +616,7 @@ export class PegasusActor extends Actor {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
addArmorsShields( rollData, statKey = "none", useShield = false) {
|
||||
if (statKey == 'phy') {
|
||||
|
||||
@@ -68,11 +68,14 @@ export class PegasusCommands {
|
||||
return this.process(command, params, content, msg);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
process(command, params, content, msg) {
|
||||
return this._processCommand(this.commandsTable, command, params, content, msg);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
_processCommand(commandsTable, name, params, content = '', msg = {}, path = "") {
|
||||
console.log("===> Processing command")
|
||||
let command = commandsTable[name];
|
||||
path = path + name + " ";
|
||||
if (command && command.subTable) {
|
||||
|
||||
@@ -288,6 +288,16 @@ export class PegasusItemSheet extends ItemSheet {
|
||||
await this.object.update( { 'data.powersgained': powArray} );
|
||||
}
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
async addAbilityEffect( event, item, dataItem) {
|
||||
let newItem = duplicate(item.data);
|
||||
newItem._id = randomID( dataItem.id.length );
|
||||
if ( event.toElement.className == 'drop-ability-effect') {
|
||||
let powArray = duplicate(this.object.data.data.effectsgained);
|
||||
powArray.push( newItem );
|
||||
await this.object.update( { 'data.effectsgained': powArray} );
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async addAbilitySpec( event, item, dataItem) {
|
||||
@@ -399,6 +409,9 @@ export class PegasusItemSheet extends ItemSheet {
|
||||
if (data) {
|
||||
let dataItem = JSON.parse( data );
|
||||
let item = await PegasusUtility.searchItem( dataItem);
|
||||
if ( item.data.type == 'effect') {
|
||||
return this.addAbilityEffect( event, item, dataItem);
|
||||
}
|
||||
if ( item.data.type == 'power') {
|
||||
return this.addAbilityPower( event, item, dataItem);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user