forked from public/bol
Support des jets d'attributs et d'aptitudes
Ajout des macros Amélioration des cartons dans le chat avec gestion des succès/échecs/échecs critiques. Support des carrières dans les dialogues de tests d'attibuts et d'aptitudes.
This commit is contained in:
@ -2,6 +2,8 @@
|
||||
* Extend the basic ActorSheet with some very simple modifications
|
||||
* @extends {ActorSheet}
|
||||
*/
|
||||
import {BoLRoll} from "../controllers/bol-rolls.js";
|
||||
|
||||
export class BoLActorSheet extends ActorSheet {
|
||||
|
||||
/** @override */
|
||||
@ -33,18 +35,6 @@ export class BoLActorSheet extends ActorSheet {
|
||||
const item = this.actor.items.get(li.data("itemId"));
|
||||
item.sheet.render(true);
|
||||
});
|
||||
html.find('.roll-attribute').click(ev => {
|
||||
this.actor.rollAttributeAptitude( $(ev.currentTarget).data("attr-key") );
|
||||
});
|
||||
html.find('.roll-career').click(ev => {
|
||||
const li = $(ev.currentTarget).parents(".item");
|
||||
this.actor.rollCareer( li.data("itemId") );
|
||||
});
|
||||
html.find('.roll-weapon').click(ev => {
|
||||
const li = $(ev.currentTarget).parents(".item");
|
||||
this.actor.rollWeapon( li.data("itemId") );
|
||||
});
|
||||
|
||||
// Equip/Unequip item
|
||||
html.find('.item-equip').click(this._onToggleEquip.bind(this));
|
||||
|
||||
@ -57,6 +47,18 @@ export class BoLActorSheet extends ActorSheet {
|
||||
|
||||
// Rollable abilities.
|
||||
html.find('.rollable').click(this._onRoll.bind(this));
|
||||
|
||||
// html.find('.roll-attribute').click(ev => {
|
||||
// this.actor.rollAttributeAptitude( $(ev.currentTarget).data("attr-key") );
|
||||
// });
|
||||
// html.find('.roll-career').click(ev => {
|
||||
// const li = $(ev.currentTarget).parents(".item");
|
||||
// this.actor.rollCareer( li.data("itemId") );
|
||||
// });
|
||||
// html.find('.roll-weapon').click(ev => {
|
||||
// const li = $(ev.currentTarget).parents(".item");
|
||||
// this.actor.rollWeapon( li.data("itemId") );
|
||||
// });
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -121,14 +123,16 @@ export class BoLActorSheet extends ActorSheet {
|
||||
event.preventDefault();
|
||||
const element = event.currentTarget;
|
||||
const dataset = element.dataset;
|
||||
|
||||
if (dataset.roll) {
|
||||
let roll = new Roll(dataset.roll, this.actor.data.data);
|
||||
let label = dataset.label ? `Rolling ${dataset.label}` : '';
|
||||
roll.roll().toMessage({
|
||||
speaker: ChatMessage.getSpeaker({ actor: this.actor }),
|
||||
flavor: label
|
||||
});
|
||||
const actorData = this.getData();
|
||||
const rollType = dataset.rollType;
|
||||
switch(rollType) {
|
||||
case "attribute" :
|
||||
BoLRoll.attributeCheck(this.actor, actorData, dataset, event);
|
||||
break;
|
||||
case "aptitude" :
|
||||
BoLRoll.aptitudeCheck(this.actor, actorData, dataset, event);
|
||||
break;
|
||||
default : break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,3 @@
|
||||
import { BoLRollDialog } from "../system/roll-dialog.js";
|
||||
import { BoLUtility } from "../system/bol-utility.js";
|
||||
|
||||
/**
|
||||
* Extend the base Actor entity by defining a custom roll data structure which is ideal for the Simple system.
|
||||
* @extends {Actor}
|
||||
@ -14,9 +11,7 @@ export class BoLActor extends Actor {
|
||||
// console.log(actorData);
|
||||
// const data = actorData.data;
|
||||
// const flags = actorData.flags;
|
||||
|
||||
// Make separate methods for each Actor type (character, npc, etc.) to keep
|
||||
// things organized.
|
||||
// Make separate methods for each Actor type (character, npc, etc.) to keep things organized.
|
||||
if (actorData.type === 'character') {
|
||||
this._prepareCharacterData(actorData);
|
||||
}
|
||||
@ -165,97 +160,6 @@ export class BoLActor extends Actor {
|
||||
};
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
buildRollData(mode, title) {
|
||||
return {
|
||||
mode : mode,
|
||||
title : title,
|
||||
actorId: this.id,
|
||||
actorImg: this.img,
|
||||
boons : this.boons,
|
||||
flaws : this.flaws,
|
||||
d6Bonus: 0,
|
||||
d6Malus: 0,
|
||||
rollMode: game.settings.get("core", "rollMode"),
|
||||
optionsBonusMalus: BoLUtility.buildListOptions(-8, +2),
|
||||
bonusMalus: 0
|
||||
}
|
||||
}
|
||||
|
||||
saveRollData( rollData) {
|
||||
this.currentRollData = rollData;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async rollAttributeAptitude( attrKey ) {
|
||||
let attr = this.data.data.attributes[attrKey];
|
||||
if ( !attr) {
|
||||
attr = this.data.data.aptitudes[attrKey];
|
||||
}
|
||||
if (attr) {
|
||||
let rollData = this.buildRollData("attribute", game.i18n.localize(attr.label));
|
||||
rollData.attribute = duplicate(attr);
|
||||
let rollDialog = await BoLRollDialog.create( this, rollData);
|
||||
rollDialog.render( true );
|
||||
} else {
|
||||
ui.notifications.warn("Unable to find attribute " + attrKey );
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async rollCareer( careerId ) {
|
||||
let career = BoLUtility.data(this.data.items.find( item => item.type == 'feature' && item.id == careerId));
|
||||
if (career) {
|
||||
let rollData = this.buildRollData("career", `${career.name} : ${career.data.rank}`);
|
||||
rollData.career = career;
|
||||
rollData.rollAttribute = 'mind';
|
||||
rollData.attributes = duplicate(this.data.data.attributes);
|
||||
let rollDialog = await BoLRollDialog.create( this, rollData);
|
||||
rollDialog.render( true );
|
||||
} else {
|
||||
ui.notifications.warn("Unable to find career for actor " + this.name + " - Career ID " + careerId);
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async rollWeapon( weaponId ) {
|
||||
let weapon = BoLUtility.data(this.data.items.find( item => item.type == 'item' && item.id == weaponId));
|
||||
if (weapon) {
|
||||
let target = BoLUtility.getTarget();
|
||||
// if ( !target) {
|
||||
// ui.notifications.warn("You must have a target to attack with a Weapon");
|
||||
// return;
|
||||
// }
|
||||
let objectDefender = (target) ? BoLUtility.data(game.actors.get(target.data.actorId)) : null;
|
||||
objectDefender = (objectDefender) ? mergeObject(objectDefender, target.data.actorData) : null;
|
||||
let rollData = this.buildRollData("weapon", weapon.name);
|
||||
rollData.weapon = weapon;
|
||||
rollData.target = target;
|
||||
rollData.isRanged = BoLUtility.isRangedWeapon( weapon );
|
||||
rollData.defender = objectDefender;
|
||||
rollData.rollAttribute = 'agility';
|
||||
rollData.attributes = duplicate(this.data.data.attributes); // For damage bonus
|
||||
rollData.rangeModifier = 0;
|
||||
|
||||
if ( weapon.data.type == 'melee') {
|
||||
rollData.aptitude = duplicate(this.data.data.aptitudes.melee);
|
||||
} else {
|
||||
rollData.aptitude = duplicate(this.data.data.aptitudes.ranged);
|
||||
}
|
||||
console.log("WEAPON ! ", rollData);
|
||||
let rollDialog = await BoLRollDialog.create( this, rollData);
|
||||
rollDialog.render( true );
|
||||
} else {
|
||||
ui.notifications.warn("Unable to find weapon for actor " + this.name + " - Weapon ID " + weaponId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {*} item
|
||||
* @param {*} bypassChecks
|
||||
* @returns
|
||||
*/
|
||||
toggleEquipItem(item) {
|
||||
const equipable = item.data.data.properties.equipable;
|
||||
if(equipable){
|
||||
@ -264,6 +168,4 @@ export class BoLActor extends Actor {
|
||||
return item.update(itemData);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
Reference in New Issue
Block a user