Update powers
This commit is contained in:
@@ -10,7 +10,7 @@ export class WarheroActorSheet extends ActorSheet {
|
||||
|
||||
/** @override */
|
||||
static get defaultOptions() {
|
||||
|
||||
|
||||
return mergeObject(super.defaultOptions, {
|
||||
classes: ["fvtt-warhero", "sheet", "actor"],
|
||||
template: "systems/fvtt-warhero/templates/actor-sheet.html",
|
||||
@@ -49,7 +49,7 @@ export class WarheroActorSheet extends ActorSheet {
|
||||
conditions: this.actor.checkAndPrepareEquipments( duplicate(this.actor.getConditions()) ),
|
||||
armors: this.actor.checkAndPrepareEquipments( duplicate(this.actor.getArmors())),
|
||||
shields: this.actor.checkAndPrepareEquipments( duplicate(this.actor.getShields())),
|
||||
powers: this.actor.checkAndPrepareEquipments( duplicate(this.actor.getPowers())),
|
||||
powers: this.actor.sortPowers(),
|
||||
equipments: this.actor.checkAndPrepareEquipments(duplicate(this.actor.getEquipmentsOnly()) ),
|
||||
slotEquipments: this.actor.buildEquipmentsSlot(),
|
||||
subActors: duplicate(this.actor.getSubActors()),
|
||||
@@ -168,7 +168,11 @@ export class WarheroActorSheet extends ActorSheet {
|
||||
const weaponId = li.data("item-id")
|
||||
this.actor.rollDamage(weaponId)
|
||||
});
|
||||
|
||||
html.find('.roll-damage-2hands').click((event) => {
|
||||
const li = $(event.currentTarget).parents(".item")
|
||||
const weaponId = li.data("item-id")
|
||||
this.actor.rollDamage(weaponId, true)
|
||||
});
|
||||
html.find('.lock-unlock-sheet').click((event) => {
|
||||
this.options.editScore = !this.options.editScore;
|
||||
this.render(true);
|
||||
|
@@ -133,6 +133,19 @@ export class WarheroActor extends Actor {
|
||||
WarheroUtility.sortArrayObjectsByName(comp)
|
||||
return comp;
|
||||
}
|
||||
sortPowers() {
|
||||
let schools = {}
|
||||
for(let power of this.items) {
|
||||
if (power.type == "power") {
|
||||
power = duplicate(power)
|
||||
let school = schools[power.system.magicschool] || []
|
||||
school.push(power)
|
||||
WarheroUtility.sortArrayObjectsByNameAndLevel(school)
|
||||
schools[power.system.magicschool] = school
|
||||
}
|
||||
}
|
||||
return schools
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getShields() {
|
||||
let comp = duplicate(this.items.filter(item => item.type == 'shield') || []);
|
||||
@@ -186,12 +199,16 @@ export class WarheroActor extends Actor {
|
||||
/* -------------------------------------------- */
|
||||
prepareWeapon(weapon) {
|
||||
let formula = weapon.system.damage
|
||||
if (weapon.system.weapontype == "long") {
|
||||
if (weapon.system.weapontype == "long" || weapon.system.weapontype == "short") {
|
||||
formula += "+" + this.system.statistics.str.value
|
||||
}
|
||||
if (weapon.system.weapontype == "twohanded") {
|
||||
formula += "+" + Math.floor(this.system.statistics.str.value*1.5)
|
||||
}
|
||||
if (weapon.system.weapontype == "polearm") {
|
||||
formula += "+" + Math.floor(this.system.statistics.str.value*1)
|
||||
weapon.damageFormula2Hands = weapon.system.damage2hands + "+" + Math.floor(this.system.statistics.str.value*1.5)
|
||||
}
|
||||
weapon.damageFormula = formula
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
@@ -664,7 +681,7 @@ export class WarheroActor extends Actor {
|
||||
}
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
rollDamage(weaponId) {
|
||||
rollDamage(weaponId, is2hands = false) {
|
||||
let weapon = this.items.get(weaponId)
|
||||
if (weapon) {
|
||||
weapon = duplicate(weapon)
|
||||
@@ -672,6 +689,7 @@ export class WarheroActor extends Actor {
|
||||
let rollData = this.getCommonRollData()
|
||||
rollData.mode = "damage"
|
||||
rollData.weapon = weapon
|
||||
rollData.is2hands = is2hands
|
||||
rollData.img = weapon.img
|
||||
this.startRoll(rollData)
|
||||
}
|
||||
|
@@ -7,6 +7,7 @@ export const WARHERO_CONFIG = {
|
||||
polearm: {damage: "1d6", label: "WH.conf.polearm"},
|
||||
shooting: {damage: "2d6", label: "WH.conf.shooting"},
|
||||
throwing: {damage: "1d8", label: "WH.conf.throwing"},
|
||||
special: {damage: "1d6", label: "WH.conf.special"},
|
||||
},
|
||||
|
||||
armorTypes : {
|
||||
|
@@ -12,6 +12,7 @@ import { WarheroActor } from "./warhero-actor.js";
|
||||
import { WarheroItemSheet } from "./warhero-item-sheet.js";
|
||||
import { WarheroActorSheet } from "./warhero-actor-sheet.js";
|
||||
import { WarheroNPCSheet } from "./warhero-npc-sheet.js";
|
||||
import { WarheroMonsterSheet } from "./warhero-monster-sheet.js";
|
||||
import { WarheroUtility } from "./warhero-utility.js";
|
||||
import { WarheroCombat } from "./warhero-combat.js";
|
||||
import { WarheroItem } from "./warhero-item.js";
|
||||
@@ -60,11 +61,12 @@ Hooks.once("init", async function () {
|
||||
/* -------------------------------------------- */
|
||||
// Register sheet application classes
|
||||
Actors.unregisterSheet("core", ActorSheet);
|
||||
Actors.registerSheet("fvtt-crucible", WarheroActorSheet, { types: ["character"], makeDefault: true });
|
||||
Actors.registerSheet("fvtt-crucible", WarheroNPCSheet, { types: ["npc"], makeDefault: false });
|
||||
Actors.registerSheet("fvtt-warhero", WarheroActorSheet, { types: ["character"], makeDefault: true });
|
||||
Actors.registerSheet("fvtt-warhero", WarheroNPCSheet, { types: ["npc"], makeDefault: false });
|
||||
Actors.registerSheet("fvtt-warhero", WarheroMonsterSheet, { types: ["monster"], makeDefault: false });
|
||||
|
||||
Items.unregisterSheet("core", ItemSheet);
|
||||
Items.registerSheet("fvtt-crucible", WarheroItemSheet, { makeDefault: true });
|
||||
Items.registerSheet("fvtt-warhero", WarheroItemSheet, { makeDefault: true });
|
||||
|
||||
WarheroUtility.init()
|
||||
});
|
||||
|
27
modules/warhero-monster-sheet.js
Normal file
27
modules/warhero-monster-sheet.js
Normal file
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* Extend the basic ActorSheet with some very simple modifications
|
||||
* @extends {ActorSheet}
|
||||
*/
|
||||
import { WarheroActorSheet } from "./warhero-actor-sheet.js";
|
||||
|
||||
import { WarheroUtility } from "./warhero-utility.js";
|
||||
|
||||
/* -------------------------------------------- */
|
||||
export class WarheroMonsterSheet extends WarheroActorSheet {
|
||||
|
||||
/** @override */
|
||||
static get defaultOptions() {
|
||||
|
||||
|
||||
return mergeObject(super.defaultOptions, {
|
||||
classes: ["warhero-rpg", "sheet", "actor"],
|
||||
template: "systems/fvtt-warhero/templates/npc-sheet.html",
|
||||
width: 640,
|
||||
height: 720,
|
||||
tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "stats" }],
|
||||
dragDrop: [{ dragSelector: ".item-list .item", dropSelector: null }],
|
||||
editScore: true
|
||||
});
|
||||
}
|
||||
|
||||
}
|
@@ -2,18 +2,18 @@
|
||||
* Extend the basic ActorSheet with some very simple modifications
|
||||
* @extends {ActorSheet}
|
||||
*/
|
||||
|
||||
import { WarheroActorSheet } from "./warhero-actor-sheet.js";
|
||||
import { WarheroUtility } from "./warhero-utility.js";
|
||||
|
||||
/* -------------------------------------------- */
|
||||
export class WarheroNPCSheet extends ActorSheet {
|
||||
export class WarheroNPCSheet extends WarheroActorSheet {
|
||||
|
||||
/** @override */
|
||||
static get defaultOptions() {
|
||||
|
||||
return mergeObject(super.defaultOptions, {
|
||||
classes: ["warhero-rpg", "sheet", "actor"],
|
||||
template: "systems/fvtt-warhero/templates/npc-sheet.html",
|
||||
template: "systems/fvtt-warhero/templates/monster-sheet.html",
|
||||
width: 640,
|
||||
height: 720,
|
||||
tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "stats" }],
|
||||
@@ -22,188 +22,4 @@ export class WarheroNPCSheet extends ActorSheet {
|
||||
});
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async getData() {
|
||||
const objectData = this.object.system
|
||||
let actorData = duplicate(objectData)
|
||||
|
||||
let formData = {
|
||||
title: this.title,
|
||||
id: this.actor.id,
|
||||
type: this.actor.type,
|
||||
img: this.actor.img,
|
||||
name: this.actor.name,
|
||||
editable: this.isEditable,
|
||||
cssClass: this.isEditable ? "editable" : "locked",
|
||||
data: actorData,
|
||||
limited: this.object.limited,
|
||||
skills: this.actor.getSkills( ),
|
||||
weapons: this.actor.checkAndPrepareEquipments( duplicate(this.actor.getWeapons()) ),
|
||||
armors: this.actor.checkAndPrepareEquipments( duplicate(this.actor.getArmors())),
|
||||
shields: this.actor.checkAndPrepareEquipments( duplicate(this.actor.getShields())),
|
||||
spells: this.actor.checkAndPrepareEquipments( duplicate(this.actor.getLore())),
|
||||
equipments: this.actor.checkAndPrepareEquipments(duplicate(this.actor.getEquipmentsOnly()) ),
|
||||
equippedWeapons: this.actor.checkAndPrepareEquipments(duplicate(this.actor.getEquippedWeapons()) ),
|
||||
equippedArmor: this.actor.getEquippedArmor(),
|
||||
equippedShield: this.actor.getEquippedShield(),
|
||||
feats: duplicate(this.actor.getFeats()),
|
||||
subActors: duplicate(this.actor.getSubActors()),
|
||||
race: duplicate(this.actor.getRace()),
|
||||
moneys: duplicate(this.actor.getMoneys()),
|
||||
encCapacity: this.actor.getEncumbranceCapacity(),
|
||||
saveRolls: this.actor.getSaveRoll(),
|
||||
conditions: this.actor.getConditions(),
|
||||
containersTree: this.actor.containersTree,
|
||||
encCurrent: this.actor.encCurrent,
|
||||
options: this.options,
|
||||
owner: this.document.isOwner,
|
||||
editScore: this.options.editScore,
|
||||
isGM: game.user.isGM
|
||||
}
|
||||
this.formData = formData;
|
||||
|
||||
console.log("PC : ", formData, this.object);
|
||||
return formData;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
/** @override */
|
||||
activateListeners(html) {
|
||||
super.activateListeners(html);
|
||||
|
||||
// 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 => {
|
||||
const li = $(ev.currentTarget).parents(".item")
|
||||
let itemId = li.data("item-id")
|
||||
const item = this.actor.items.get( itemId );
|
||||
item.sheet.render(true);
|
||||
});
|
||||
// Delete Inventory Item
|
||||
html.find('.item-delete').click(ev => {
|
||||
const li = $(ev.currentTarget).parents(".item")
|
||||
WarheroUtility.confirmDelete(this, li)
|
||||
})
|
||||
html.find('.item-add').click(ev => {
|
||||
let dataType = $(ev.currentTarget).data("type")
|
||||
this.actor.createEmbeddedDocuments('Item', [{ name: "NewItem", type: dataType }], { renderSheet: true })
|
||||
})
|
||||
|
||||
html.find('.equip-activate').click(ev => {
|
||||
const li = $(ev.currentTarget).parents(".item")
|
||||
let itemId = li.data("item-id")
|
||||
this.actor.equipActivate( itemId)
|
||||
});
|
||||
html.find('.equip-deactivate').click(ev => {
|
||||
const li = $(ev.currentTarget).parents(".item")
|
||||
let itemId = li.data("item-id")
|
||||
this.actor.equipDeactivate( itemId)
|
||||
});
|
||||
|
||||
html.find('.subactor-edit').click(ev => {
|
||||
const li = $(ev.currentTarget).parents(".item");
|
||||
let actorId = li.data("actor-id");
|
||||
let actor = game.actors.get( actorId );
|
||||
actor.sheet.render(true);
|
||||
});
|
||||
|
||||
html.find('.subactor-delete').click(ev => {
|
||||
const li = $(ev.currentTarget).parents(".item");
|
||||
let actorId = li.data("actor-id");
|
||||
this.actor.delSubActor(actorId);
|
||||
});
|
||||
html.find('.quantity-minus').click(event => {
|
||||
const li = $(event.currentTarget).parents(".item");
|
||||
this.actor.incDecQuantity( li.data("item-id"), -1 );
|
||||
} );
|
||||
html.find('.quantity-plus').click(event => {
|
||||
const li = $(event.currentTarget).parents(".item");
|
||||
this.actor.incDecQuantity( li.data("item-id"), +1 );
|
||||
} );
|
||||
|
||||
html.find('.ammo-minus').click(event => {
|
||||
const li = $(event.currentTarget).parents(".item")
|
||||
this.actor.incDecAmmo( li.data("item-id"), -1 );
|
||||
} );
|
||||
html.find('.ammo-plus').click(event => {
|
||||
const li = $(event.currentTarget).parents(".item")
|
||||
this.actor.incDecAmmo( li.data("item-id"), +1 )
|
||||
} );
|
||||
|
||||
html.find('.roll-ability').click((event) => {
|
||||
const abilityKey = $(event.currentTarget).data("ability-key");
|
||||
this.actor.rollAbility(abilityKey);
|
||||
});
|
||||
html.find('.roll-skill').click((event) => {
|
||||
const li = $(event.currentTarget).parents(".item")
|
||||
const skillId = li.data("item-id")
|
||||
this.actor.rollSkill(skillId)
|
||||
});
|
||||
|
||||
html.find('.roll-weapon').click((event) => {
|
||||
const li = $(event.currentTarget).parents(".item");
|
||||
const skillId = li.data("item-id")
|
||||
this.actor.rollWeapon(skillId)
|
||||
});
|
||||
html.find('.roll-armor-die').click((event) => {
|
||||
this.actor.rollArmorDie()
|
||||
});
|
||||
html.find('.roll-shield-die').click((event) => {
|
||||
this.actor.rollShieldDie()
|
||||
});
|
||||
html.find('.roll-target-die').click((event) => {
|
||||
this.actor.rollDefenseRanged()
|
||||
});
|
||||
|
||||
html.find('.roll-save').click((event) => {
|
||||
const saveKey = $(event.currentTarget).data("save-key")
|
||||
this.actor.rollSave(saveKey)
|
||||
});
|
||||
|
||||
|
||||
html.find('.lock-unlock-sheet').click((event) => {
|
||||
this.options.editScore = !this.options.editScore;
|
||||
this.render(true);
|
||||
});
|
||||
html.find('.item-link a').click((event) => {
|
||||
const itemId = $(event.currentTarget).data("item-id");
|
||||
const item = this.actor.getOwnedItem(itemId);
|
||||
item.sheet.render(true);
|
||||
});
|
||||
html.find('.item-equip').click(ev => {
|
||||
const li = $(ev.currentTarget).parents(".item");
|
||||
this.actor.equipItem( li.data("item-id") );
|
||||
this.render(true);
|
||||
});
|
||||
|
||||
html.find('.update-field').change(ev => {
|
||||
const fieldName = $(ev.currentTarget).data("field-name");
|
||||
let value = Number(ev.currentTarget.value);
|
||||
this.actor.update( { [`${fieldName}`]: value } );
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
/** @override */
|
||||
setPosition(options = {}) {
|
||||
const position = super.setPosition(options);
|
||||
const sheetBody = this.element.find(".sheet-body");
|
||||
const bodyHeight = position.height - 192;
|
||||
sheetBody.css("height", bodyHeight);
|
||||
return position;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
/** @override */
|
||||
_updateObject(event, formData) {
|
||||
// Update the Actor
|
||||
return this.object.update(formData);
|
||||
}
|
||||
}
|
||||
|
@@ -66,7 +66,7 @@ export class WarheroUtility {
|
||||
console.log("Element Found !!!!")
|
||||
}) */
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------- */
|
||||
static upperFirst(text) {
|
||||
if (typeof text !== 'string') return text
|
||||
@@ -544,10 +544,10 @@ export class WarheroUtility {
|
||||
|
||||
let actor = game.actors.get(rollData.actorId)
|
||||
|
||||
if ( rollData.mode == "power") {
|
||||
if (rollData.mode == "power") {
|
||||
let manaCost = Array.from(rollData.powerLevel)[0]
|
||||
if( actor.spentMana(manaCost)) {
|
||||
let powerKey = "level"+rollData.powerLevel
|
||||
if (actor.spentMana(manaCost)) {
|
||||
let powerKey = "level" + rollData.powerLevel
|
||||
rollData.powerText = rollData.power.system[powerKey]
|
||||
let msg = await this.createChatWithRollMode(rollData.alias, {
|
||||
content: await renderTemplate(`systems/fvtt-warhero/templates/chat-generic-result.html`, rollData)
|
||||
@@ -556,13 +556,19 @@ export class WarheroUtility {
|
||||
}
|
||||
return
|
||||
}
|
||||
if ( rollData.mode == "damage") {
|
||||
let myRoll = new Roll(rollData.weapon.damageFormula + "+" + rollData.bonusMalus).roll({ async: false })
|
||||
if (rollData.mode == "damage") {
|
||||
let formula
|
||||
if (rollData.weapon.system.weapontype == "special") {
|
||||
formula = rollData.weapon.system.damageformula
|
||||
} else {
|
||||
formula = (rollData.is2hands) ? rollData.weapon.damageFormula2Hands : rollData.weapon.damageFormula
|
||||
}
|
||||
let myRoll = new Roll(formula + "+" + rollData.bonusMalus, actor.system).roll({ async: false })
|
||||
await this.showDiceSoNice(myRoll, game.settings.get("core", "rollMode"))
|
||||
rollData.roll = myRoll
|
||||
rollData.diceFormula = myRoll.formula
|
||||
rollData.diceResult = myRoll.terms[0].results[0].result
|
||||
|
||||
|
||||
let msg = await this.createChatWithRollMode(rollData.alias, {
|
||||
content: await renderTemplate(`systems/fvtt-warhero/templates/chat-generic-result.html`, rollData)
|
||||
})
|
||||
@@ -570,12 +576,17 @@ export class WarheroUtility {
|
||||
return
|
||||
}
|
||||
|
||||
// ability/save/size => 0
|
||||
let diceFormula = "1d20"
|
||||
if ( rollData.stat) {
|
||||
diceFormula += "+" + rollData.stat.value
|
||||
let diceFormula
|
||||
if (rollData.weapon.system.weapontype == "special") {
|
||||
diceFormula = rollData.weapon.system.rollformula
|
||||
} else {
|
||||
// ability/save/size => 0
|
||||
diceFormula = "1d20"
|
||||
if (rollData.stat) {
|
||||
diceFormula += "+" + rollData.stat.value
|
||||
}
|
||||
}
|
||||
if ( rollData.usemWeaponMalus) {
|
||||
if (rollData.usemWeaponMalus) {
|
||||
diceFormula += "+" + rollData.mWeaponMalus
|
||||
}
|
||||
diceFormula += "+" + rollData.bonusMalus
|
||||
@@ -584,7 +595,7 @@ export class WarheroUtility {
|
||||
console.log("Roll formula", diceFormula)
|
||||
let myRoll = rollData.roll
|
||||
if (!myRoll) { // New rolls only of no rerolls
|
||||
myRoll = new Roll(diceFormula).roll({ async: false })
|
||||
myRoll = new Roll(diceFormula, actor.system).roll({ async: false })
|
||||
await this.showDiceSoNice(myRoll, game.settings.get("core", "rollMode"))
|
||||
}
|
||||
rollData.roll = myRoll
|
||||
@@ -619,7 +630,19 @@ export class WarheroUtility {
|
||||
return 0;
|
||||
})
|
||||
}
|
||||
|
||||
static sortArrayObjectsByNameAndLevel(myArray) {
|
||||
myArray.sort((a, b) => {
|
||||
let fa = a.system.level + a.name.toLowerCase();
|
||||
let fb = b.system.level + b.name.toLowerCase();
|
||||
if (fa < fb) {
|
||||
return -1;
|
||||
}
|
||||
if (fa > fb) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
})
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
static getUsers(filter) {
|
||||
return game.users.filter(filter).map(user => user.id);
|
||||
|
Reference in New Issue
Block a user