Rollable damages + protection

This commit is contained in:
sladecraven 2022-01-16 22:53:41 +01:00
parent 831b192691
commit 2a83ba027b
9 changed files with 99 additions and 17 deletions

View File

@ -108,6 +108,7 @@
"BOL.ui.duration": "Duration",
"BOL.ui.spellkeep": "Maintain",
"BOL.ui.concentrate": "Concentrate",
"BOL.ui.registerInit": "Register Init.",
"BOL.featureCategory.origins": "Origines",
"BOL.featureCategory.races": "Races",

View File

@ -109,6 +109,7 @@
"BOL.ui.duration": "Durée",
"BOL.ui.spellkeep": "Prolongation",
"BOL.ui.concentrate": "Concentration",
"BOL.ui.registerInit": "Enregistrer comme Init. de combat",
"BOL.featureCategory.origins": "Origines",
"BOL.featureCategory.races": "Races",

View File

@ -243,6 +243,16 @@ export class BoLActor extends Actor {
}
}
/*-------------------------------------------- */
registerInit(initScore, isCritical, isFumble) {
this.update( { 'data.combat.lastinit': initScore, 'data.combat.iscritical': isCritical, 'data.combat.isfumble': isFumble} )
}
/*-------------------------------------------- */
getLastInitData() {
return this.data.data.combat
}
/*-------------------------------------------- */
async subHeroPoints( nb) {
let newHeroP = this.data.data.resources.hero.value - nb;

View File

@ -8,9 +8,9 @@ import { preloadHandlebarsTemplates } from "./system/templates.js";
import { registerHandlebarsHelpers } from "./system/helpers.js";
import { registerSystemSettings } from "./system/settings.js";
import registerHooks from "./system/hooks.js";
// import {DataLoader} from "./system/data.js";
import { Macros } from "./system/macros.js";
import { BoLUtility } from "./system/bol-utility.js";
import { BoLCombatManager } from "./system/bol-combat.js";
Hooks.once('init', async function () {
@ -33,12 +33,13 @@ Hooks.once('init', async function () {
*/
CONFIG.Combat.initiative = {
formula: "2d6+@attributes.mind.value+@aptitudes.init.value",
decimals: 0
decimals: 2
};
0
// Define custom Entity classes
CONFIG.Actor.documentClass = BoLActor;
CONFIG.Item.documentClass = BoLItem;
CONFIG.Combat.documentClass = BoLCombatManager;
// Register sheet application classes
Actors.unregisterSheet("core", ActorSheet);

View File

@ -1,6 +1,8 @@
import { BoLUtility } from "../system/bol-utility.js";
const __adv2dice = { ["1B"]: 3, ["2B"]: 4, ["2"]: 2, ["1M"]: 3, ["2M"]: 4}
const _apt2attr = {init: "mind", melee: "agility", ranged: "agility", def: "vigor"}
export class BoLRoll {
static options() {
return { classes: ["bol", "dialog"] };
@ -10,7 +12,9 @@ export class BoLRoll {
if (adv == 0) return "2"
return Math.abs(adv) + (adv < 0)?'M':'B';
}
static getDefaultAttribute( key ) {
return _apt2attr[key]
}
static attributeCheck(actor, actorData, dataset, event) {
// const elt = $(event.currentTarget)[0];
// let key = elt.attributes["data-rolling"].value;
@ -37,7 +41,11 @@ export class BoLRoll {
// let key = elt.attributes["data-rolling"].value;
const key = dataset.key;
const adv = dataset.adv;
let aptitude = eval(`actor.data.data.aptitudes.${key}`);
let attrKey = this.getDefaultAttribute(key)
let attribute = eval(`actor.data.data.attributes.${attrKey}`);
let label = (aptitude.label) ? game.i18n.localize(aptitude.label) : null;
let description = actor.name + " - " + game.i18n.localize('BOL.ui.aptitudeCheck') + " - " + game.i18n.localize(aptitude.label);
return this.displayRollDialog(
@ -45,6 +53,7 @@ export class BoLRoll {
mode: "aptitude",
actor: actor,
actorData: actorData,
attribute: attribute,
aptitude: aptitude,
label: label,
description: description,
@ -134,6 +143,7 @@ export class BoLRoll {
rollData.mod = html.find('#mod').val() || 0;
let careers = html.find('#career').val();
rollData.career = (!careers || careers.length == 0) ? 0 : Math.max(...careers.map(i => parseInt(i)));
rollData.registerInit = (rollData.aptKey == 'init') ? $('#register-init').is(":checked") : false;
let shieldMalus = 0;
if ( rollData.mode == "weapon") {
@ -188,6 +198,10 @@ export class BoLDefaultRoll {
this.rollData.isFailure = !this.rollData.isSuccess
this.rollData.reroll = this.rollData.actor.heroReroll()
if (this.rollData.registerInit) {
this.rollData.actor.registerInit( r.total, this.rollData.isCritical);
}
this._buildChatMessage(this.rollData).then(msgFlavor => {
r.toMessage({
user: game.user.id,

View File

@ -1,5 +1,17 @@
/*
Init order =
10 - Legendary
9 - Heroic
8 - Success
7 - Rivals/adversary
6 - Coriaces/tough
5 - Failure
4 - Pietaille
3 - Echec critique
*/
export class RdDCombatManager extends Combat {
export class BoLCombatManager extends Combat {
/************************************************************************************/
async rollInitiative(ids, formula = undefined, messageOptions = {}) {
@ -9,13 +21,33 @@ export class RdDCombatManager extends Combat {
const currentId = this.combatant._id;
// calculate initiative
if ( game.combat.current.round == 1) {
for (let cId = 0; cId < ids.length; cId++) {
const combatant = this.combatants.get(ids[cId]);
// TODO
let fvttInit = 5
if (combatant.actor.type == 'character') {
let initData = combatant.actor.getLastInitData();
if (initData.isLegendary) {
fvttInit = 10
} else if (initData.isCritical) {
fvttInit = 9
} else if (initData.lastinit >= 9) {
fvttInit = 8
} else if (initData.isFumble) {
fvttInit = 3
}
} else {
fvttInit = 4 // Pietaille par defaut
if ( combatant.actor.getSubtype == 'adversary') {
fvttInit = 7
}
if ( combatant.actor.getSubtype == 'tough') {
fvttInit = 6
}
}
fvttInit += (cId / 10)
await this.updateEmbeddedDocuments("Combatant", [{ _id: ids[cId], initiative: fvttInit }]);
}
console.log("TODO : Compute init for actor");
}
}
}
}

View File

@ -7,8 +7,8 @@
"url": "https://github.com/ZigmundKreud/bol",
"license": "LICENSE.txt",
"flags": {},
"version": "0.8.9.7",
"templateVersion": 14,
"version": "0.8.9.9",
"templateVersion": 16,
"minimumCoreVersion": "0.8.6",
"compatibleCoreVersion": "9",
"scripts": [],

View File

@ -11,6 +11,12 @@
"notes": "",
"languages": []
},
"combat": {
"lastinit": 0,
"iscritical": false,
"isfumble": false,
"islegendary": false
},
"prot": {
"key": "prot",
"label": "BOL.aptitudes.prot",

View File

@ -8,8 +8,25 @@
</div>
</header>
{{> "systems/bol/templates/dialogs/attribute-roll-part.hbs"}}
{{> "systems/bol/templates/dialogs/aptitude-roll-part.hbs"}}
{{#if (equals aptitude.key "init" )}}
<div class="flexrow" style="margin-bottom: 1px;">
<div class="flex1 center bg-darkred">
<label for="mod">{{localize 'BOL.ui.registerInit'}}</label>
</div>
<div class="flex1 center cell">
<label class="checkbox">
<input class="field-value" type="checkbox" name="register-init" id="register-init" checked />
</label>
</div>
</div>
{{/if}}
{{> "systems/bol/templates/dialogs/adv-roll-part.hbs"}}
{{> "systems/bol/templates/dialogs/mod-roll-part.hbs"}}