Add fight options

This commit is contained in:
2022-03-10 21:05:53 +01:00
parent eacd32927c
commit 02b3dd5e0f
24 changed files with 447 additions and 227 deletions

View File

@ -48,7 +48,18 @@ export class BoLCombatManager extends Combat {
fvttInit += (cId / 100)
await this.updateEmbeddedDocuments("Combatant", [{ _id: ids[cId], initiative: fvttInit }]);
}
console.log("TODO : Compute init for actor");
}
/************************************************************************************/
nextRound() {
let combatants = this.combatants.contents
for (let c of combatants) {
let actor = game.actors.get( c.data.actorId )
//actor.clearRoundModifiers()
}
super.nextRound()
}
}

View File

@ -139,7 +139,7 @@ export class BoLUtility {
chatGM.whisper = this.getUsers(user => user.isGM);
chatGM.content = "Blind message of " + game.user.name + "<br>" + chatOptions.content;
console.log("blindMessageToGM", chatGM);
game.socket.emit("system.fvtt-fragged-kingdom", { msg: "msg_gm_chat_message", data: chatGM });
game.socket.emit("system.bol", { msg: "msg_gm_chat_message", data: chatGM });
}
/* -------------------------------------------- */
@ -335,53 +335,6 @@ export class BoLUtility {
return undefined;
}
/* -------------------------------------------- */
static async rollBoL(rollData) {
// Dice bonus/malus selection
let nbDice = 2;
let d6BM = 0;
let mode = "";
if (rollData.d6Malus > rollData.d6Bonus) {
d6BM = rollData.d6Malus - rollData.d6Bonus;
mode = "kl2";
}
if (rollData.d6Bonus > rollData.d6Malus) {
d6BM = rollData.d6Bonus - rollData.d6Malus;
mode = "kh2";
}
nbDice += d6BM;
// Final modifier
let modifier = Number(rollData.bonusMalus);
if (rollData.mode == 'career') {
modifier += Number(rollData.attributes[rollData.rollAttribute].value) + Number(rollData.career.data.rank);
} else if (rollData.mode == 'attribute') {
modifier += rollData.attribute.value;
} else if (rollData.mode == 'weapon') {
modifier += Number(rollData.attributes[rollData.rollAttribute].value) + Number(rollData.aptitude.value) + Number(rollData.rangeModifier);
modifier -= rollData.defender.data.aptitudes.def.value;
}
let formula = nbDice + "d6" + mode + "+" + modifier;
console.log("Going to roll ", formula, rollData.attributes, rollData.rollAttribute);
let myRoll = new Roll(formula).roll({ async: false });
await this.showDiceSoNice(myRoll, game.settings.get("core", "rollMode"));
rollData.roll = myRoll;
rollData.formula = formula;
rollData.modifier = modifier;
rollData.nbDice = nbDice;
rollData.finalScore = myRoll.total;
let actor = game.actors.get(rollData.actorId);
actor.saveRollData(rollData);
this.createChatWithRollMode(rollData.alias, {
content: await renderTemplate(`systems/bol/templates/chat/chat-generic-result.hbs`, rollData)
});
}
/* -------------------------------------------- */
static async processAttackSuccess(attackDef) {
if (!game.user.isGM) { // Only GM process this
@ -399,9 +352,10 @@ export class BoLUtility {
attacker: attackDef.attacker,
defender: attackDef.defender,
defenderWeapons: defenderWeapons,
damageTotal: attackDef.damageRoll.total
damageTotal: attackDef.damageRoll.total,
damagesIgnoresArmor: attackDef.damagesIgnoresArmor,
})
});
})
}
/* -------------------------------------------- */
@ -423,7 +377,8 @@ export class BoLUtility {
}
/* -------------------------------------------- */
static getDamageFormula(weaponData) {
static getDamageFormula(weaponData, fightOption) {
let upgradeDamage = (fightOption && fightOption.data.properties.fightoptiontype == "twoweaponsatt")
let damageString = weaponData.properties.damage
let modifier = weaponData.properties.damageModifiers ?? 0
let multiplier = weaponData.properties.damageMultiplier ?? 1
@ -435,26 +390,33 @@ export class BoLUtility {
let formula = damageString
if (damageString.includes("d") || damageString.includes("D")) {
var myReg = new RegExp('(\\d+)[dD]([\\d]+)([MB]*)?([\\+\\d]*)?', 'g');
let res = myReg.exec(damageString);
let nbDice = parseInt(res[1]);
let postForm = 'kh' + nbDice;
let modIndex = 3;
var myReg = new RegExp('(\\d+)[dD]([\\d]+)([MB]*)?([\\+\\d]*)?', 'g')
let res = myReg.exec(damageString)
let nbDice = parseInt(res[1])
let postForm = 'kh' + nbDice
let modIndex = 3
// Upgrade damage if needed
if ( upgradeDamage && ( !res[3] || res[3]=="") ) {
res[3] = "B" // Upgrade to bonus
}
if (res[3]) {
if ( upgradeDamage && res[3] == 'M') {
res[3] = "" // Disable lamlus for upgradeDamage
}
if (res[3] == 'M') {
postForm = 'kl' + nbDice;
nbDice++;
modIndex = 4;
postForm = 'kl' + nbDice
nbDice++
modIndex = 4
}
if (res[3] == 'B') {
postForm = 'kh' + nbDice;
nbDice++;
modIndex = 4;
postForm = 'kh' + nbDice
nbDice++
modIndex = 4
}
}
formula = "(" + nbDice + "d" + res[2] + reroll + postForm + "+" + modifier + ") *" + multiplier;
formula = "(" + nbDice + "d" + res[2] + reroll + postForm + "+" + modifier + ") *" + multiplier
}
return formula;
return formula
}
/* -------------------------------------------- */

View File

@ -254,7 +254,18 @@ BOL.featureSubtypes = {
"boon" : "BOL.featureSubtypes.boon",
"flaw" : "BOL.featureSubtypes.flaw",
"language" : "BOL.featureSubtypes.language",
"godsfaith" : "BOL.featureSubtypes.gods"
"godsfaith" : "BOL.featureSubtypes.gods",
"fightoption" : "BOL.featureSubtypes.fightOption"
}
BOL.fightOptionTypes = {
"armordefault": "BOL.fightOptionTypes.armor",
"intrepid": "BOL.fightOptionTypes.intrepid",
"twoweaponsdef": "BOL.fightOptionTypes.twoweaponsdef",
"twoweaponsatt": "BOL.fightOptionTypes.twoweaponsatt",
"fulldefense": "BOL.fightOptionTypes.fulldefense",
"defense": "BOL.fightOptionTypes.defense",
"attack": "BOL.fightOptionTypes.attack",
}
BOL.itemIcons = {

View File

@ -33,6 +33,7 @@ export const preloadHandlebarsTemplates = async function () {
"systems/bol/templates/item/parts/properties/feature/flaw-properties.hbs",
"systems/bol/templates/item/parts/properties/feature/origin-properties.hbs",
"systems/bol/templates/item/parts/properties/feature/race-properties.hbs",
"systems/bol/templates/item/parts/properties/feature/fightoption-properties.hbs",
// DIALOGS
"systems/bol/templates/chat/rolls/attack-damage-card.hbs",
@ -47,7 +48,8 @@ export const preloadHandlebarsTemplates = async function () {
"systems/bol/templates/dialogs/career-roll-part.hbs",
"systems/bol/templates/dialogs/boons-roll-part.hbs",
"systems/bol/templates/dialogs/flaws-roll-part.hbs",
"systems/bol/templates/dialogs/total-roll-part.hbs",
"systems/bol/templates/dialogs/total-roll-part.hbs",
"systems/bol/templates/dialogs/fightoptions-roll-part.hbs",
];
// Load the template parts