Sync attempt
This commit is contained in:
parent
8538af1907
commit
915b89a8c4
@ -134,6 +134,17 @@ export class BoLActor extends Actor {
|
|||||||
return this.itemData.filter(i => i.type === "item" && i.data.category === "equipment" && (i.data.subtype === "other" ||i.data.subtype === "container" ||i.data.subtype === "scroll" || i.data.subtype === "jewel"));
|
return this.itemData.filter(i => i.type === "item" && i.data.category === "equipment" && (i.data.subtype === "other" ||i.data.subtype === "container" ||i.data.subtype === "scroll" || i.data.subtype === "jewel"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
heroReroll( ) {
|
||||||
|
if (this.type == 'character') {
|
||||||
|
return this.data.data.resources.hero.value > 0;
|
||||||
|
} else {
|
||||||
|
if (this.data.data.type == 'adversary') {
|
||||||
|
return this.data.data.resources.hero.value > 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
getResourcesFromType() {
|
getResourcesFromType() {
|
||||||
let resources = {};
|
let resources = {};
|
||||||
if (this.type == 'encounter') {
|
if (this.type == 'encounter') {
|
||||||
|
@ -89,7 +89,7 @@ export class BoLRoll {
|
|||||||
const adv = html.find('#adv').val();
|
const adv = html.find('#adv').val();
|
||||||
const mod = html.find('#mod').val();
|
const mod = html.find('#mod').val();
|
||||||
let careers = html.find('#career').val();
|
let careers = html.find('#career').val();
|
||||||
const career = (careers && careers.length == 0) ? 0 : Math.max(...careers.map(i => parseInt(i)));
|
const career = (!careers || careers.length == 0) ? 0 : Math.max(...careers.map(i => parseInt(i)));
|
||||||
const isMalus = adv < 0;
|
const isMalus = adv < 0;
|
||||||
const dicePool = (isMalus) ? 2 - parseInt(adv) : 2 + parseInt(adv);
|
const dicePool = (isMalus) ? 2 - parseInt(adv) : 2 + parseInt(adv);
|
||||||
const attrValue = eval(`actor.data.data.attributes.${attr}.value`);
|
const attrValue = eval(`actor.data.data.attributes.${attr}.value`);
|
||||||
@ -158,7 +158,7 @@ export class BoLRoll {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let careers = html.find('#career').val();
|
let careers = html.find('#career').val();
|
||||||
const career = (careers && careers.length == 0) ? 0 : Math.max(...careers.map(i => parseInt(i)));
|
const career = (!careers || careers.length == 0) ? 0 : Math.max(...careers.map(i => parseInt(i)));
|
||||||
const isMalus = adv < 0;
|
const isMalus = adv < 0;
|
||||||
const dicePool = (isMalus) ? 2 - parseInt(adv) : 2 + parseInt(adv);
|
const dicePool = (isMalus) ? 2 - parseInt(adv) : 2 + parseInt(adv);
|
||||||
const attrValue = eval(`attackDef.attacker.data.data.attributes.${attr}.value`);
|
const attrValue = eval(`attackDef.attacker.data.data.attributes.${attr}.value`);
|
||||||
@ -206,7 +206,7 @@ export class BoLRoll {
|
|||||||
const adv = html.find('#adv').val();
|
const adv = html.find('#adv').val();
|
||||||
const mod = html.find('#mod').val();
|
const mod = html.find('#mod').val();
|
||||||
let careers = html.find('#career').val();
|
let careers = html.find('#career').val();
|
||||||
const career = (careers && careers.length == 0) ? 0 : Math.max(...careers.map(i => parseInt(i)));
|
const career = (!careers || careers.length == 0) ? 0 : Math.max(...careers.map(i => parseInt(i)));
|
||||||
const isMalus = adv < 0;
|
const isMalus = adv < 0;
|
||||||
const dicePool = (isMalus) ? 2 - parseInt(adv) : 2 + parseInt(adv);
|
const dicePool = (isMalus) ? 2 - parseInt(adv) : 2 + parseInt(adv);
|
||||||
const aptValue = eval(`actor.data.data.aptitudes.${apt}.value`);
|
const aptValue = eval(`actor.data.data.aptitudes.${apt}.value`);
|
||||||
@ -261,6 +261,7 @@ export class BoLDefaultRoll {
|
|||||||
const tplData = {
|
const tplData = {
|
||||||
actor: actor,
|
actor: actor,
|
||||||
label: this._label,
|
label: this._label,
|
||||||
|
reroll: actor.heroReroll(),
|
||||||
isSuccess: this._isSuccess,
|
isSuccess: this._isSuccess,
|
||||||
isFailure: !this._isSuccess,
|
isFailure: !this._isSuccess,
|
||||||
isCritical: this._isCritical,
|
isCritical: this._isCritical,
|
||||||
@ -285,7 +286,7 @@ export class BoLAttackRoll {
|
|||||||
console.log("Attack def",this.attackDef.formula )
|
console.log("Attack def",this.attackDef.formula )
|
||||||
const r = new Roll(this.attackDef.formula);
|
const r = new Roll(this.attackDef.formula);
|
||||||
await r.roll({ "async": false });
|
await r.roll({ "async": false });
|
||||||
//await BoLUtility.showDiceSoNice(r);
|
await BoLUtility.showDiceSoNice(r);
|
||||||
const activeDice = r.terms[0].results.filter(r => r.active);
|
const activeDice = r.terms[0].results.filter(r => r.active);
|
||||||
const diceTotal = activeDice.map(r => r.result).reduce((a, b) => a + b);
|
const diceTotal = activeDice.map(r => r.result).reduce((a, b) => a + b);
|
||||||
this._isSuccess = (r.total >= 9);
|
this._isSuccess = (r.total >= 9);
|
||||||
@ -297,28 +298,11 @@ export class BoLAttackRoll {
|
|||||||
flavor: msgFlavor,
|
flavor: msgFlavor,
|
||||||
speaker: ChatMessage.getSpeaker({ actor: this.attackDef.attacker }),
|
speaker: ChatMessage.getSpeaker({ actor: this.attackDef.attacker }),
|
||||||
flags: { msgType: "default" }
|
flags: { msgType: "default" }
|
||||||
|
}).then( this.processResult() );
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
|
|
||||||
if (this._isSuccess) {
|
async processDefense() {
|
||||||
let attrDamage = this.attackDef.weapon.data.data.properties.damageAttribute;
|
|
||||||
let weaponFormula = BoLUtility.getDamageFormula(this.attackDef.weapon.data.data.properties.damage)
|
|
||||||
let damageFormula = weaponFormula + "+" + this.attackDef.attacker.data.data.attributes[attrDamage].value;
|
|
||||||
this.damageRoll = new Roll(damageFormula);
|
|
||||||
await this.damageRoll.roll({ "async": false });
|
|
||||||
//await BoLUtility.showDiceSoNice(this.damageRoll);
|
|
||||||
// Update attackDef object
|
|
||||||
this.attackDef.damageFormula = damageFormula;
|
|
||||||
this.attackDef.damageRoll = this.damageRoll;
|
|
||||||
|
|
||||||
this._buildDamageChatMessage(this.attackDef.attacker, this.attackDef.weapon, this.damageRoll.total).then(msgFlavor => {
|
|
||||||
this.damageRoll.toMessage({
|
|
||||||
user: game.user.id,
|
|
||||||
flavor: msgFlavor,
|
|
||||||
speaker: ChatMessage.getSpeaker({ actor: this.attackDef.attacker }),
|
|
||||||
flags: { msgType: "default" }
|
|
||||||
});
|
|
||||||
});
|
|
||||||
if (this._isCritical) {
|
if (this._isCritical) {
|
||||||
ChatMessage.create({
|
ChatMessage.create({
|
||||||
alias: this.attackDef.attacker.name,
|
alias: this.attackDef.attacker.name,
|
||||||
@ -335,6 +319,28 @@ export class BoLAttackRoll {
|
|||||||
BoLUtility.sendAttackSuccess( this.attackDef);
|
BoLUtility.sendAttackSuccess( this.attackDef);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async processResult( ) {
|
||||||
|
if (this._isSuccess) {
|
||||||
|
let attrDamage = this.attackDef.weapon.data.data.properties.damageAttribute;
|
||||||
|
let weaponFormula = BoLUtility.getDamageFormula(this.attackDef.weapon.data.data.properties.damage)
|
||||||
|
let damageFormula = weaponFormula + "+" + this.attackDef.attacker.data.data.attributes[attrDamage].value;
|
||||||
|
this.damageRoll = new Roll(damageFormula);
|
||||||
|
await this.damageRoll.roll({ "async": false });
|
||||||
|
await BoLUtility.showDiceSoNice(this.damageRoll);
|
||||||
|
// Update attackDef object
|
||||||
|
this.attackDef.damageFormula = damageFormula;
|
||||||
|
this.attackDef.damageRoll = this.damageRoll;
|
||||||
|
|
||||||
|
this._buildDamageChatMessage(this.attackDef.attacker, this.attackDef.weapon, this.damageRoll.total).then(msgFlavor => {
|
||||||
|
this.damageRoll.toMessage({
|
||||||
|
user: game.user.id,
|
||||||
|
flavor: msgFlavor,
|
||||||
|
speaker: ChatMessage.getSpeaker({ actor: this.attackDef.attacker }),
|
||||||
|
flags: { msgType: "default" }
|
||||||
|
}).then( this.processDefense() );
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_buildDamageChatMessage(actor, weapon, total) {
|
_buildDamageChatMessage(actor, weapon, total) {
|
||||||
@ -354,6 +360,7 @@ export class BoLAttackRoll {
|
|||||||
const tplData = {
|
const tplData = {
|
||||||
actor: actor,
|
actor: actor,
|
||||||
label: this._label,
|
label: this._label,
|
||||||
|
reroll: actor.heroReroll(),
|
||||||
isSuccess: this._isSuccess,
|
isSuccess: this._isSuccess,
|
||||||
isFailure: !this._isSuccess,
|
isFailure: !this._isSuccess,
|
||||||
isCritical: this._isCritical,
|
isCritical: this._isCritical,
|
||||||
|
@ -111,6 +111,7 @@ export class BoLUtility {
|
|||||||
static async chatListeners(html) {
|
static async chatListeners(html) {
|
||||||
// Damage handling
|
// Damage handling
|
||||||
html.on("click", '.damage-increase', event => {
|
html.on("click", '.damage-increase', event => {
|
||||||
|
event.preventDefault();
|
||||||
let attackId = event.currentTarget.attributes['data-attack-id'].value;
|
let attackId = event.currentTarget.attributes['data-attack-id'].value;
|
||||||
let damageMode = event.currentTarget.attributes['data-damage-mode'].value;
|
let damageMode = event.currentTarget.attributes['data-damage-mode'].value;
|
||||||
if ( game.user.isGM) {
|
if ( game.user.isGM) {
|
||||||
@ -120,7 +121,13 @@ export class BoLUtility {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
html.on("click", '.hero-reroll', event => {
|
||||||
|
event.preventDefault();
|
||||||
|
ui.notifications.warn("Not implemented up to now");
|
||||||
|
} );
|
||||||
|
|
||||||
html.on("click", '.damage-handling', event => {
|
html.on("click", '.damage-handling', event => {
|
||||||
|
event.preventDefault();
|
||||||
let attackId = event.currentTarget.attributes['data-attack-id'].value;
|
let attackId = event.currentTarget.attributes['data-attack-id'].value;
|
||||||
let defenseMode = event.currentTarget.attributes['data-defense-mode'].value;
|
let defenseMode = event.currentTarget.attributes['data-defense-mode'].value;
|
||||||
let weaponId = (event.currentTarget.attributes['data-weapon-id']) ? event.currentTarget.attributes['data-weapon-id'].value : -1
|
let weaponId = (event.currentTarget.attributes['data-weapon-id']) ? event.currentTarget.attributes['data-weapon-id'].value : -1
|
||||||
|
@ -13,7 +13,10 @@
|
|||||||
<h2 class="failure"><i class="fas fa-times"></i> {{localize "BOL.ui.failure"}}...</h2>
|
<h2 class="failure"><i class="fas fa-times"></i> {{localize "BOL.ui.failure"}}...</h2>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
<h3><strong>{{description}}</strong>
|
<h3><strong>{{description}}</strong></h3>
|
||||||
|
{{#if reroll}}
|
||||||
|
<a class="button hero-reroll" data-actor-id="{{actor.id}}">Relancer!</a>
|
||||||
|
{{/if}}
|
||||||
{{!#if hasDescription}}
|
{{!#if hasDescription}}
|
||||||
<!--<h4>-->
|
<!--<h4>-->
|
||||||
<!-- <pre class="rollDescr-line">{{!description}}</pre>-->
|
<!-- <pre class="rollDescr-line">{{!description}}</pre>-->
|
||||||
|
Loading…
Reference in New Issue
Block a user