Carrrièes, stat patch et log

This commit is contained in:
sladecraven 2022-01-30 09:18:49 +01:00
parent 222842d2e6
commit e3c9213969
7 changed files with 96 additions and 102 deletions

View File

@ -37,32 +37,6 @@ Hooks.once('init', () => {
return statParserFR( statString, type); return statParserFR( statString, type);
} }
/*---------------------------------------------------------------------*/
game.wfrp4e.utility.handleConditionClick = function(event) {
let cond = $(event.currentTarget).attr("data-cond")
if (!cond)
cond = event.target.text;
cond = cond.trim();
let condkey
// En vo, les noms d'états sont égaux aux clés en minuscules
if ( game.wfrp4e.config.conditions[cond.toLowerCase()] ) {
condkey = cond.toLowerCase();
} else {
try {
condkey = game.wfrp4e.utility.findKey(cond.toLowerCase(), game.wfrp4e.config.conditions, {caseInsensitive: true});
}
catch {
ui.notifications.error("L'état est inconnu : " + cond);
}
}
let condName = game.wfrp4e.config.conditions[condkey];
let condDescr = game.wfrp4e.config.conditionDescriptions[condkey];
let messageContent = `<b>${condName}</b><br>${condDescr}`
let chatData = game.wfrp4e.utility.chatDataSetup(messageContent)
ChatMessage.create(chatData);
}
/*---------------------------------------------------------------------*/ /*---------------------------------------------------------------------*/
game.wfrp4e.entities.ItemWfrp4e.prototype.computeSpellDamage = function(formula, isMagicMissile) { game.wfrp4e.entities.ItemWfrp4e.prototype.computeSpellDamage = function(formula, isMagicMissile) {
try { try {
@ -510,3 +484,31 @@ Hooks.once('init', () => {
} ); } );
/* -------------------------------------------- */
// Register world usage statistics
function registerUsageCount( registerKey ) {
if ( game.user.isGM ) {
game.settings.register(registerKey, "world-key", {
name: "Unique world key",
scope: "world",
config: false,
type: String
});
let worldKey = game.settings.get(registerKey, "world-key")
if ( worldKey == undefined || worldKey == "" ) {
worldKey = randomID(32)
game.settings.set(registerKey, "world-key", worldKey )
}
// Simple API counter
$.ajax(`https://jdr.lahiette.com/fvtt_appcount/count.php?name="${registerKey}"&worldKey="${worldKey}"&version="${game.release.generation}.${game.release.build}"&system="${game.system.id}"&systemversion="${game.system.data.version}"`)
/* -------------------------------------------- */
}
}
/*---------------------------------------------------------------------*/
Hooks.once('ready', () => {
registerUsageCount("wh4-fr-translation")
});

File diff suppressed because one or more lines are too long

View File

@ -1078,7 +1078,7 @@
"WFRP4E.ConditionName.Broken" : "Brisé", "WFRP4E.ConditionName.Broken" : "Brisé",
"WFRP4E.ConditionName.Deafened" : "Assourdi", "WFRP4E.ConditionName.Deafened" : "Assourdi",
"WFRP4E.ConditionName.Entangled" : "Empêtré", "WFRP4E.ConditionName.Entangled" : "Empêtré",
"WFRP4E.ConditionName.Fatigued" : "Exténué", "WFRP4E.ConditionName.Fatigued" : "Extenué",
"WFRP4E.ConditionName.Poisoned" : "Empoisonné", "WFRP4E.ConditionName.Poisoned" : "Empoisonné",
"WFRP4E.ConditionName.Prone" : "A Terre", "WFRP4E.ConditionName.Prone" : "A Terre",
"WFRP4E.ConditionName.Stunned" : "Assommé", "WFRP4E.ConditionName.Stunned" : "Assommé",

View File

@ -2,7 +2,7 @@
"name": "WH4-fr-translation", "name": "WH4-fr-translation",
"title": "WFRP4e - Core Module en français.", "title": "WFRP4e - Core Module en français.",
"description": "Traduction Française pour Warhammer v4.", "description": "Traduction Française pour Warhammer v4.",
"version": "5.0.16", "version": "5.0.18",
"minimumCoreVersion" : "0.8.0", "minimumCoreVersion" : "0.8.0",
"compatibleCoreVersion": "9", "compatibleCoreVersion": "9",
"author": "LeRatierBretonnien", "author": "LeRatierBretonnien",

View File

@ -140,30 +140,32 @@ export class WH4FRPatchConfig {
this.patch_subspecies(); this.patch_subspecies();
this.patch_career(); this.patch_career();
game.wfrp4e.config.conditionScripts = { /*game.wfrp4e.config.conditionScripts = {
"ablaze" : async function (actor) { "ablaze" : async function (actor) {
let effect = actor.hasCondition("ablaze") let effect = actor.hasCondition("ablaze")
let value = effect.conditionValue; let value = effect.conditionValue;
let leastProtectedLoc; let leastProtectedLoc;
let leastProtectedValue = 999; let leastProtectedValue = 999;
for (let loc in actor.status.armour) { for (let loc in actor.status.armour)
if (actor.status.armour[loc].value != undefined && actor.status.armour[loc].value < leastProtectedValue) { {
if (actor.status.armour[loc].value != undefined && actor.status.armour[loc].value < leastProtectedValue)
{
leastProtectedLoc = loc; leastProtectedLoc = loc;
leastProtectedValue = actor.status.armour[loc].value; leastProtectedValue = actor.status.armour[loc].value;
} }
} }
let rollString = `1d10 + ${value - 1}` let rollString = `1d10 + ${value - 1}`
let roll = new Roll(`${rollString} - ${leastProtectedValue || 0}`).roll(); let roll = await new Roll(`${rollString} - ${leastProtectedValue || 0}`).roll();
let msg = `<h2>En Flammes</h2><b>Formule</b>: ${rollString}<br><b>Lancer</b>: ${roll.terms.map(i => i.total).splice(0, 3).join(" ")}` // Don't show AP in the roll formula let msg = `<h2>${game.i18n.localize("WFRP4E.ConditionName.Ablaze")}</h2><b>${game.i18n.localize("Formula")}</b>: ${rollString}<br><b>${game.i18n.localize("Roll")}</b>: ${roll.terms.map(i => i.total).splice(0, 3).join(" ")}` // Don't show AP in the roll formula
actor.runEffects("preApplyCondition", {effect, data : {msg, roll, rollString}}) actor.runEffects("preApplyCondition", {effect, data : {msg, roll, rollString}})
value = effect.conditionValue; value = effect.conditionValue;
let damageMsg = (`<br>` + await actor.applyBasicDamage(roll.total, {damageType : game.wfrp4e.config.DAMAGE_TYPE.IGNORE_AP, suppressMsg : true})).split("") let damageMsg = (`<br>` + await actor.applyBasicDamage(roll.total, {damageType : game.wfrp4e.config.DAMAGE_TYPE.IGNORE_AP, suppressMsg : true})).split("")
damageMsg.splice(damageMsg.length-1, 1) // Removes the parentheses and adds + AP amount. damageMsg.splice(damageMsg.length-1, 1) // Removes the parentheses and adds + AP amount.
msg += damageMsg.join("").concat(` + ${leastProtectedValue} AP)`) msg += damageMsg.join("").concat(` + ${leastProtectedValue} ${game.i18n.localize("AP")})`)
let messageData = game.wfrp4e.utility.chatDataSetup(msg); let messageData = game.wfrp4e.utility.chatDataSetup(msg);
messageData.speaker = {alias: actor.data.token.name} messageData.speaker = {alias: actor.data.token.name}
actor.runEffects("applyCondition", {effect, data : {messageData}}) actor.runEffects("applyCondition", {effect, data : {messageData}})
@ -217,7 +219,7 @@ export class WH4FRPatchConfig {
actor.runEffects("applyCondition", { effect, data: { messageData, bleedingRoll } }) actor.runEffects("applyCondition", { effect, data: { messageData, bleedingRoll } })
return messageData return messageData
} }
} }*/
game.wfrp4e.config.statusEffects = [ game.wfrp4e.config.statusEffects = [
{ {
@ -239,7 +241,7 @@ export class WH4FRPatchConfig {
wfrp4e: { wfrp4e: {
"trigger": "endRound", "trigger": "endRound",
"effectTrigger": "prefillDialog", "effectTrigger": "prefillDialog",
"script": "args.prefillModifiers.modifier -= 10 * getProperty(this.effect, 'flags.wfrp4e.value')", "script": "args.prefillModifiers.modifier -= 10 * this.effect.conditionValue",
"value": 1 "value": 1
} }
} }
@ -280,7 +282,7 @@ export class WH4FRPatchConfig {
wfrp4e: { wfrp4e: {
"trigger": "endRound", "trigger": "endRound",
"effectTrigger": "prefillDialog", "effectTrigger": "prefillDialog",
"script": "args.prefillModifiers.modifier -= 10 * getProperty(this.effect, 'flags.wfrp4e.value')", "script": "args.prefillModifiers.modifier -= 10 * this.effect.conditionValue",
"value": 1 "value": 1
} }
} }
@ -308,7 +310,7 @@ export class WH4FRPatchConfig {
flags: { flags: {
wfrp4e: { wfrp4e: {
"effectTrigger": "prefillDialog", "effectTrigger": "prefillDialog",
"script": "args.prefillModifiers.modifier -= 10 * getProperty(this.effect, 'flags.wfrp4e.value')", "script": "args.prefillModifiers.modifier -= 10 * this.effect.conditionValue",
"value" : 1 "value" : 1
} }
} }
@ -322,13 +324,13 @@ export class WH4FRPatchConfig {
"trigger": "endRound", "trigger": "endRound",
"effectTrigger": "dialogChoice", "effectTrigger": "dialogChoice",
"effectData" : { "effectData" : {
"description": "Tests relatifs à la vue", "description" : "Tests related to sight",
"modifier" : "-10 * this.flags.wfrp4e.value" "modifier" : "-10 * this.flags.wfrp4e.value"
}, },
"value": 1, "value": 1,
"secondaryEffect" :{ "secondaryEffect" :{
"effectTrigger": "targetPrefillDialog", "effectTrigger": "targetPrefillDialog",
"script": "if (args.type == 'weapon' && args.item.attackType=='melee') args.prefillModifiers.modifier += 10 * getProperty(this.effect, 'flags.wfrp4e.value')", "script": "if (args.item && args.item.attackType=='melee') args.prefillModifiers.modifier += 10 * this.effect.conditionValue",
} }
} }
} }
@ -340,7 +342,7 @@ export class WH4FRPatchConfig {
flags: { flags: {
wfrp4e: { wfrp4e: {
"effectTrigger": "prefillDialog", "effectTrigger": "prefillDialog",
"script": "args.prefillModifiers.modifier -= 10 * getProperty(this.effect, 'flags.wfrp4e.value')", "script": "args.prefillModifiers.modifier -= 10 * this.effect.conditionValue",
"value": 1 "value": 1
} }
} }
@ -353,7 +355,7 @@ export class WH4FRPatchConfig {
wfrp4e: { wfrp4e: {
"effectTrigger": "dialogChoice", "effectTrigger": "dialogChoice",
"effectData" : { "effectData" : {
"description": "Tout les tests relatifs au mouvement", "description" : "Tests related to movement of any kind",
"modifier" : "-20" "modifier" : "-20"
}, },
"value": null, "value": null,
@ -372,14 +374,14 @@ export class WH4FRPatchConfig {
wfrp4e: { wfrp4e: {
"effectTrigger": "dialogChoice", "effectTrigger": "dialogChoice",
"effectData" : { "effectData" : {
"description": "Tests affectés ", "description" : "Tests to affect",
"slBonus" : "-1" "slBonus" : "-1"
}, },
"script" : ` "script" : `
if (this.flags.wfrp4e.fearName) if (this.flags.wfrp4e.fearName)
this.flags.wfrp4e.effectData.description += " " + this.flags.wfrp4e.fearName this.flags.wfrp4e.effectData.description += " " + this.flags.wfrp4e.fearName
else else
this.flags.wfrp4e.effectData.description += " la source de la Peur" this.flags.wfrp4e.effectData.description += " the source of fear"
`, `,
"value": null "value": null
} }

View File

@ -34,7 +34,7 @@ import WFRP_Utility from "/systems/wfrp4e/modules/system/utility-wfrp4e.js";
import "./xregexp-all.js"; import "./xregexp-all.js";
const us_carac = 'm\\s+ws\\s+bs\\s+s\\s+t\\s+i\\s+agi?\\s+dex\\s+int\\s+\\wp\\s+fel\\s+w'; const us_carac = 'm\\s+ws\\s+bs\\s+s\\s+t\\s+i\\s+agi?\\s+dex\\s+int\\s+\\wp\\s+fel\\s+w';
const fr_carac = 'm\\s+ws\\s+bs\\s+s\\s+t\\s+i\\s+agi?\\s+dex\\s+int\\s+\\wp\\s+fel\\s+w'; const fr_carac = 'm\\s+ws\\s+bs\\s+s\\s+t\\s+i\\s+agi?\\s+dex\\s+int\\s+\\wp\\s+fel\\s+w';
const carac_val = '(?<m>[0-9-]+)\\s+(?<ws>[0-9-]+)\\s+(?<bs>[0-9-]+)\\s+(?<s>[0-9-]+)\\s+(?<t>[0-9-]+)\\s+(?<i>[0-9-]+)\\s+(?<ag>[0-9-]+)\\s+(?<dex>[0-9-]+)\\s+(?<int>[0-9-]+)\\s+(?<wp>[0-9-]+)\\s+(?<fel>[0-9-]+)\\s+(?<w>[0-9-\*]+)'; const carac_val = '(?<m>[0-9\\-]+)\\s+(?<ws>[0-9\\-]+)\\s+(?<bs>[0-9\\-]+)\\s+(?<s>[0-9\\-]+)\\s+(?<t>[0-9\\-]+)\\s+(?<i>[0-9\\-]+)\\s+(?<ag>[0-9\\-]+)\\s+(?<dex>[0-9\\-]+)\\s+(?<int>[0-9\\-]+)\\s+(?<wp>[0-9\\-]+)\\s+(?<fel>[0-9\\-]+)\\s+(?<w>[0-9\\-\*]+)';
const name_val = '(?<name>[a-zA-Z\\s\\-,]*)[\\s\\r\\na-zA-Z]*(?<tiers>.*|[\\(\\)a-z0-9]+)'; const name_val = '(?<name>[a-zA-Z\\s\\-,]*)[\\s\\r\\na-zA-Z]*(?<tiers>.*|[\\(\\)a-z0-9]+)';
let sectionData = [ let sectionData = [
{ name: "trait", toFind: "Traits\\s*:", secondParse: '(?<name>[a-z\\s]*)[\\s\\+]*(?<value>.*|[\\+0-9]+)', index: -1 }, { name: "trait", toFind: "Traits\\s*:", secondParse: '(?<name>[a-z\\s]*)[\\s\\+]*(?<value>.*|[\\+0-9]+)', index: -1 },
@ -164,6 +164,9 @@ function __patchName ( name) {
export default async function statParserFR(statString, type = "npc") { export default async function statParserFR(statString, type = "npc") {
let model = duplicate(game.system.model.Actor[type]); let model = duplicate(game.system.model.Actor[type]);
// Patch wront/strange carac value before processing
statString = statString.replace(/ /g, " 0")
let reg1 = XRegExp(us_carac, 'gi'); let reg1 = XRegExp(us_carac, 'gi');
let res = reg1.test(statString); let res = reg1.test(statString);
if (res) { //stat block identified go on if (res) { //stat block identified go on
@ -196,7 +199,8 @@ export default async function statParserFR(statString, type = "npc") {
let resCarac = XRegExp.exec(statString, reg2); // resr contains all carac found let resCarac = XRegExp.exec(statString, reg2); // resr contains all carac found
// Setup carac // Setup carac
if (resCarac["Agi"]) resCarac["Ag"] = resCarac["Agi"]; // Auto patch //console.log("CARAC", resCarac)
if (resCarac["Agi"]) resCarac["Ag"] = resCarac["Agi"] // Auto patch
model.details.move.value = Number(resCarac["m"]); model.details.move.value = Number(resCarac["m"]);
for (let key in model.characteristics) { for (let key in model.characteristics) {
if (resCarac[key] === '-') resCarac[key] = 0; if (resCarac[key] === '-') resCarac[key] = 0;

View File

@ -1,14 +0,0 @@
{
"folders": [
{
"path": "."
},
{
"path": "../WFRP4e-FoundryVTT"
},
{
"path": "../../../foundry/foundrydata-dev/Data/modules/wfrp4e-core"
}
],
"settings": {}
}