Malus armure/bouclier et cout en PP supplementaire

This commit is contained in:
sladecraven 2022-03-27 12:42:29 +02:00
parent e5b8c8f2c7
commit 9e5e07b227
16 changed files with 206 additions and 81 deletions

View File

@ -92,9 +92,19 @@ a:hover {
clip: rect(0 0 0 0);
overflow: hidden;
}
.roll-box {
border-width: 1px;
border-color: #000000;
margin-bottom: 2px;
}
.hide {
display: none;
}
ul.no-bullets {
list-style-type: none; /* Remove bullets */
padding: 0; /* Remove padding */
margin: 0; /* Remove margins */
}
.ellipsis {
text-overflow: ellipsis;
overflow: hidden;

View File

@ -148,6 +148,8 @@
"BOL.ui.status": "Status",
"BOL.ui.toactivated": "Active (>Désactiver)",
"BOL.ui.todeactivated": "Inactive (>Activer)",
"BOL.ui.armorAgiMalus": "Armor+Shield Malus (Agi)",
"BOL.ui.armorInitMalus": "Armor Malus (Init)",
"BOL.featureCategory.origins": "Origines",
"BOL.featureCategory.races": "Races",

View File

@ -150,6 +150,8 @@
"BOL.ui.toactivated": "Active (>Désactiver)",
"BOL.ui.todeactivated": "Inactive (>Activer)",
"BOL.ui.status": "Statut",
"BOL.ui.armorAgiMalus": "Malus d'Armure+Bouclier (Agi)",
"BOL.ui.armorInitMalus": "Malus d'Armure (Init)",
"BOL.featureCategory.origins": "Origines",
"BOL.featureCategory.races": "Races",

View File

@ -290,12 +290,52 @@ export class BoLActor extends Actor {
return false
}
/*-------------------------------------------- */
getPPCostArmor() {
let armors = this.armors
let ppCostArmor = 0
for (let armor of armors) {
if (armor.data.worn) {
ppCostArmor += Number(armor.data.properties.modifiers.powercost) || 0
}
}
return ppCostArmor
}
/*-------------------------------------------- */
getArmorAgiMalus() {
let malusAgi = 0
for (let armor of this.armors) {
if (armor.data.worn) {
malusAgi += Number(armor.data.properties.modifiers.agility) || 0
}
}
for (let shield of this.shields) {
if (shield.data.worn) {
malusAgi += Number(shield.data.properties.modifiers.agility) || 0
}
}
return malusAgi
}
/*-------------------------------------------- */
getArmorInitMalus() {
let armors = this.armors
let malusInit = 0
for (let armor of armors) {
if (armor.data.worn) {
malusInit += Number(armor.data.properties.modifiers.init) || 0
}
}
return malusInit
}
/*-------------------------------------------- */
spendPowerPoint(ppCost) {
let newPP = this.data.data.resources.power.value - ppCost
newPP = (newPP < 0) ? 0 : newPP
this.update({ 'data.resources.power.value': newPP })
}
/*-------------------------------------------- */
resetAlchemyStatus(alchemyId) {
let alchemy = this.data.items.get(alchemyId)
if (alchemy) {
@ -303,6 +343,7 @@ export class BoLActor extends Actor {
}
}
/*-------------------------------------------- */
async spendAlchemyPoint(alchemyId, pcCost) {
let alchemy = this.data.items.get(alchemyId)
if (alchemy) {

View File

@ -31,6 +31,8 @@ export class BoLRoll {
label: label,
careerBonus: 0,
description: description,
armorAgiMalus: actor.getArmorAgiMalus(),
armorInitMalus: actor.getArmorAgiMalus(),
mod: 0
}
return this.displayRollDialog(rollData)
@ -53,6 +55,8 @@ export class BoLRoll {
aptitude: aptitude,
attrValue: attribute.value,
aptValue: aptitude.value,
armorAgiMalus: actor.getArmorAgiMalus(),
armorInitMalus: actor.getArmorAgiMalus(),
label: label,
careerBonus: 0,
description: description,
@ -89,6 +93,8 @@ export class BoLRoll {
aptitude: aptitude,
attrValue: attribute.value,
aptValue: aptitude.value,
armorAgiMalus: actor.getArmorAgiMalus(),
armorInitMalus: actor.getArmorAgiMalus(),
mod: 0,
modRanged: 0,
label: (weapon.name) ? weapon.name : game.i18n.localize('BOL.ui.noWeaponName'),
@ -132,6 +138,8 @@ export class BoLRoll {
pcCost: Number(alchemyData.properties.pccost),
pcCostCurrent: Number(alchemyData.properties.pccurrent),
mod: Number(alchemyData.properties.difficulty),
armorAgiMalus: actor.getArmorAgiMalus(),
armorInitMalus: actor.getArmorAgiMalus(),
label: alchemy.name,
description: game.i18n.localize('BOL.ui.makeAlchemy') + "+" + alchemy.name,
}
@ -162,8 +170,11 @@ export class BoLRoll {
aptValue: 0,
ppCurrent: Number(actor.data.data.resources.power.value),
careerBonus: actor.getSorcererBonus(),
ppCostArmor: actor.getPPCostArmor(),
ppCost: Number(spell.data.data.properties.ppcost),
mod: Number(spellData.properties.difficulty),
armorAgiMalus: actor.getArmorAgiMalus(),
armorInitMalus: actor.getArmorAgiMalus(),
label: spell.name,
description: game.i18n.localize('BOL.ui.focusSpell') + " : " + spell.name,
}
@ -173,6 +184,10 @@ export class BoLRoll {
/* -------------------------------------------- */
static updateTotalDice() {
this.updateArmorMalus(this.rollData)
this.updatePPCost(this.rollData)
this.rollData.bmDice = this.rollData.nbBoons - this.rollData.nbFlaws + this.rollData.bDice - this.rollData.mDice
this.rollData.nbDice = 2 + Math.abs(this.rollData.bmDice)
if (this.rollData.bmDice == 0) {
@ -184,7 +199,7 @@ export class BoLRoll {
$('#roll-modifier').val(this.rollData.attrValue + "+" + this.rollData.aptValue + "+" + this.rollData.careerBonus + "+" + this.rollData.mod + "+" +
this.rollData.modRanged + "+" + this.rollData.weaponModifier + "-" + this.rollData.defence + "-" + this.rollData.modArmorMalus + "-" +
this.rollData.shieldMalus + "+" + this.rollData.attackModifier )
this.rollData.shieldMalus + "+" + this.rollData.attackModifier + "+" + this.rollData.appliedArmorMalus)
}
/* -------------------------------------------- */
@ -214,6 +229,27 @@ export class BoLRoll {
}
}
}
/* -------------------------------------------- */
static updateArmorMalus(rollData) {
rollData.appliedArmorMalus = 0
if (rollData.attribute.key == "agility") {
$("#armor-agi-malus").show()
rollData.appliedArmorMalus += rollData.armorAgiMalus
} else {
$("#armor-agi-malus").hide()
}
if (rollData.aptitude && rollData.aptitude.key == "init") {
$("#armor-init-malus").show()
rollData.appliedArmorMalus += rollData.armorInitMalus
} else {
$("#armor-init-malus").hide()
}
}
/* ------------------------------ -------------- */
static updatePPCost(rollData) {
$('#ppcost').html(rollData.ppCost + " + Armor(" + rollData.ppCostArmor + ")=" + Number(rollData.ppCost + rollData.ppCostArmor))
}
/* ------------------------------ -------------- */
static rollDialogListener(html) {
@ -222,8 +258,8 @@ export class BoLRoll {
html.find('#optcond').change((event) => { // Dynamic change of PP cost of spell
let pp = BoLUtility.computeSpellCost(this.rollData.spell, event.currentTarget.selectedOptions.length)
$('#ppcost').html(pp)
this.rollData.ppCost = pp
this.updatePPCost( this.rollData)
})
html.find('#mod').change((event) => {
@ -334,6 +370,8 @@ export class BoLRoll {
// Specific stuff
this.preProcessWeapon(rollData)
this.preProcessFightOption(rollData)
this.updateArmorMalus(rollData)
this.updatePPCost(rollData)
// Save
this.rollData = rollData
console.log("ROLLDATA", rollData)
@ -366,7 +404,7 @@ export class BoLRoll {
const isMalus = rollData.mDice > 0
rollData.nbDice += (rollData.attackBonusDice) ? 1 : 0
const modifiers = rollData.attrValue + rollData.aptValue + rollData.careerBonus + rollData.mod + rollData.weaponModifier - rollData.defence - rollData.modArmorMalus + rollData.shieldMalus + rollData.attackModifier
const modifiers = rollData.attrValue + rollData.aptValue + rollData.careerBonus + rollData.mod + rollData.weaponModifier - rollData.defence - rollData.modArmorMalus + rollData.shieldMalus + rollData.attackModifier + rollData.appliedArmorMalus
const formula = (isMalus) ? rollData.nbDice + "d6kl2 + " + modifiers : rollData.nbDice + "d6kh2 + " + modifiers
rollData.formula = formula
rollData.modifiers = modifiers
@ -384,6 +422,7 @@ export class BoLRoll {
}
}
/* -------------------------------------------- */
export class BoLDefaultRoll {
constructor(rollData) {
@ -404,6 +443,7 @@ export class BoLDefaultRoll {
this.rollData.applyId = randomID(16)
}
/* -------------------------------------------- */
async roll() {
const r = new Roll(this.rollData.formula)
@ -425,7 +465,7 @@ export class BoLDefaultRoll {
this.rollData.actor.registerInit(r.total, this.rollData.isCritical, this.rollData.isFumble)
}
if (this.rollData.isSuccess && this.rollData.mode == "spell") { // PP cost management
this.rollData.actor.spendPowerPoint(this.rollData.ppCost)
this.rollData.actor.spendPowerPoint(this.rollData.ppCost + this.rollData.ppCostArmor)
}
if (this.rollData.mode == "alchemy") { // PP cost management
this.rollData.actor.resetAlchemyStatus(this.rollData.alchemy.id)
@ -434,6 +474,7 @@ export class BoLDefaultRoll {
await this.sendChatMessage()
}
/* -------------------------------------------- */
async sendChatMessage() {
this._buildChatMessage(this.rollData).then(msgFlavor => {
this.rollData.roll.toMessage({
@ -445,6 +486,7 @@ export class BoLDefaultRoll {
});
}
/* -------------------------------------------- */
upgradeToCritical() {
// Force to Critical roll
this.rollData.isCritical = true
@ -457,10 +499,12 @@ export class BoLDefaultRoll {
this.sendChatMessage()
}
/* -------------------------------------------- */
setSuccess(flag) {
this.rollData.isSuccess = flag
}
/* -------------------------------------------- */
async sendDamageMessage() {
this._buildDamageChatMessage(this.rollData).then(msgFlavor => {
this.rollData.damageRoll.toMessage({
@ -472,6 +516,7 @@ export class BoLDefaultRoll {
});
}
/* -------------------------------------------- */
getDamageAttributeValue(attrDamage) {
let attrDamageValue = 0
if (attrDamage.includes("vigor")) {
@ -483,6 +528,7 @@ export class BoLDefaultRoll {
return attrDamageValue
}
/* -------------------------------------------- */
async rollDamage() {
if (this.rollData.mode != "weapon") { // Only specific process in Weapon mode
return;
@ -514,11 +560,13 @@ export class BoLDefaultRoll {
}
}
/* -------------------------------------------- */
_buildDamageChatMessage(rollData) {
const rollMessageTpl = 'systems/bol/templates/chat/rolls/damage-roll-card.hbs';
return renderTemplate(rollMessageTpl, rollData)
}
/* -------------------------------------------- */
_buildChatMessage(rollData) {
const rollMessageTpl = 'systems/bol/templates/chat/rolls/default-roll-card.hbs';
return renderTemplate(rollMessageTpl, rollData);

View File

@ -190,10 +190,11 @@ export class BoLUtility {
});
html.on("click", '.damage-handling', event => {
event.preventDefault();
let attackId = event.currentTarget.attributes['data-attack-id'].value;
let defenseMode = event.currentTarget.attributes['data-defense-mode'].value;
event.preventDefault()
let attackId = event.currentTarget.attributes['data-attack-id'].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
console.log("Process handling !!! -> socket emit")
if (game.user.isGM) {
BoLUtility.processDamageHandling(event, attackId, defenseMode, weaponId)
} else {
@ -209,7 +210,7 @@ export class BoLUtility {
}
BoLUtility.removeChatMessageId(BoLUtility.findChatMessageId(event.currentTarget));
//console.log("Damage Handling", event, attackId, defenseMode, weaponId)
console.log("Damage Handling", event, attackId, defenseMode, weaponId)
// Only GM process this
let attackDef = this.attackStore[attackId]
if (attackDef) {
@ -365,6 +366,7 @@ export class BoLUtility {
BoLUtility.processAttackSuccess(sockmsg.data);
}
if (sockmsg.name == "msg_damage_handling") {
console.log("Msg received !!!!")
BoLUtility.processDamageHandling(sockmsg.data.event, sockmsg.data.attackId, sockmsg.data.defenseMode)
}
}

View File

@ -1,4 +1,4 @@
<div class="flexrow" style="margin-bottom: 1px;">
<div class="flexrow box-roll">
<div class="flex1 center bg-darkred">
<label for="attr">{{localize 'BOL.ui.attribute'}}</label>
</div>

View File

@ -1,5 +1,5 @@
{{#if (count boons)}}
<div class="flexrow" style="margin-bottom: 1px;">
<div class="flexrow roll-box" >
<div class="flex1 center bg-darkred">
<label for="mod">{{localize 'BOL.ui.boons'}}</label>
</div>

View File

@ -1,5 +1,5 @@
{{#if careers}}
<div class="flexrow" style="margin-bottom: 1px;">
<div class="flexrow roll-box">
<div class="flex1 center bg-darkred">
<label for="mod">{{localize 'BOL.ui.careers'}}</label>
</div>

View File

@ -1,5 +1,5 @@
{{#if fightOption}}
<div class="flexrow" style="margin-bottom: 1px;">
<div class="flexrow roll-box">
<div class="flex1 center bg-darkred">
<label for="fg">{{localize 'BOL.ui.fightOption'}}</label>
</div>

View File

@ -1,5 +1,5 @@
{{#if (count flaws)}}
<div class="flexrow" style="margin-bottom: 1px;">
<div class="flexrow roll-box">
<div class="flex1 center bg-darkred">
<label for="mod">{{localize 'BOL.ui.flaws'}}</label>
</div>

View File

@ -1,5 +1,5 @@
{{#if isRanged}}
<div class="flexrow" style="margin-bottom: 1px;">
<div class="flexrow roll-box">
<div class="flex1 center bg-darkred">
<label for="modRanged">{{localize 'BOL.ui.rangeModifiers'}}</label>
</div>
@ -19,7 +19,25 @@
</div>
{{/if}}
<div class="flexrow" style="margin-bottom: 1px;">
<div class="flexrow roll-box hide" id="armor-agi-malus">
<div class="flex1 center bg-darkred">
<label for="mod">{{localize 'BOL.ui.armorAgiMalus'}}</label>
</div>
<div class="flex1 center cell">
<label>{{armorAgiMalus}}</label>
</div>
</div>
<div class="flexrow roll-box hide" id="armor-init-malus">
<div class="flex1 center bg-darkred">
<label for="mod">{{localize 'BOL.ui.armorInitMalus'}}</label>
</div>
<div class="flex1 center cell">
<label>{{armorInitMalus}}</label>
</div>
</div>
<div class="flexrow roll-box" >
<div class="flex1 center bg-darkred">
<label for="mod">{{localize 'BOL.ui.modifiers'}}</label>
</div>

View File

@ -10,41 +10,43 @@
{{> "systems/bol/templates/dialogs/attribute-roll-part.hbs"}}
<div class="flexrow" style="margin-bottom: 1px;">
<div class="flexrow roll-box">
<div class="flex1 center bg-darkred">
<label for="mod">{{localize 'BOL.ui.sorcererRank'}}</label>
</div>
<div class="flex1 center cell">{{careerBonus}}</div>
</div>
<div class="flexrow" style="margin-bottom: 1px;">
<div class="flexrow roll-box" >
<div class="flex1 center bg-darkred">
<label for="mod">{{localize 'BOL.ui.ppcost'}}</label>
</div>
<div class="flex1 center cell" id="ppcost">{{ppCost}}</div>
</div>
<div class="flexrow" style="margin-bottom: 1px;">
<div class="flexrow roll-box" >
<div class="flex1 center bg-darkred">
<label for="mod">{{localize 'BOL.ui.ppAvailable'}}</label>
</div>
<div class="flex1 center cell">{{ppCurrent}}</div>
</div>
<div class="flexrow" style="margin-bottom: 1px;">
<div class="flexrow roll-box" >
<div class="flex1 center bg-darkred">
<label for="mod">{{localize 'BOL.ui.mandatoryconditions'}}</label>
</div>
<div class="flex1 center cell">
<ul class="no-bullets">
{{#each spell.data.data.properties.mandatoryconditions as | cond idx|}}
{{#if (lt idx @root.spell.data.data.properties.nbmandatoryconditions)}}
<label for="mod">{{cond}}</label>
<li><label for="mod">{{cond}}</label></li>
{{/if}}
{{/each}}
</ul>
</div>
</div>
<div class="flexrow" style="margin-bottom: 1px;">
<div class="flexrow roll-box" >
<div class="flex1 center bg-darkred">
<label for="mod">{{localize 'BOL.ui.optionnalconditions'}}</label>
</div>

View File

@ -1,4 +1,4 @@
<div class="flexrow" style="margin-bottom: 1px;">
<div class="flexrow roll-box" >
<div class="flex1 center bg-darkred">
<label for="mod">{{localize 'BOL.ui.nbdices'}}</label>
</div>
@ -6,7 +6,7 @@
<input class="flex1" type="text" id="roll-nbdice" value="2" disabled>
</div>
</div>
<div class="flexrow" style="margin-bottom: 1px;">
<div class="flexrow roll-box" >
<div class="flex1 center bg-darkred">
<label for="mod">{{localize 'BOL.ui.totalmod'}}</label>
</div>

View File

@ -12,14 +12,14 @@
{{> "systems/bol/templates/dialogs/aptitude-roll-part.hbs"}}
<div class="flexrow" style="margin-bottom: 1px;">
<div class="flexrow roll-box" >
<div class="flex1 center bg-darkred">
<label for="mod">{{localize 'BOL.ui.targetDefence'}}</label>
</div>
<div class="flex1 center cell">{{defence}}</div>
</div>
{{#if (eq shieldBlock 'blockall')}}
<div class="flexrow" style="margin-bottom: 1px;">
<div class="flexrow roll-box" >
<div class="flex1 center bg-darkred">
<label for="mod">{{localize 'BOL.ui.shieldMalus'}}</label>
</div>
@ -27,7 +27,7 @@
</div>
{{/if}}
{{#if (eq shieldBlock 'blockone')}}
<div class="flexrow" style="margin-bottom: 1px;">
<div class="flexrow roll-box" >
<div class="flex1 center bg-darkred">
<label for="mod">{{localize 'BOL.ui.shieldMalus'}}</label>
</div>

View File

@ -83,7 +83,7 @@
<div class="form-group">
<label class="property-label">{{localize "BOL.itemModifiers.init"}}</label>
<div class="form-fields">
<input class="field-value" type="text" name="data.properties.modifiers.init" value="{{data.properties.modifiers.init}}" data-dtype="Number"/>
<input class="field-value" type="text" name="data.properties.modifiers.init" value="{{data.properties.modifiers.c}}" data-dtype="Number"/>
</div>
</div>
<div class="form-group">