Roll damage + fix

This commit is contained in:
2025-01-05 10:25:58 +01:00
parent c7cc39886d
commit 614adecde7
36 changed files with 145 additions and 119 deletions

View File

@@ -399,6 +399,24 @@ i.lethalfantasy {
.lethalfantasy .character-main .character-resources-edit {
min-width: 400px;
}
.lethalfantasy .tab.character-biography .biodata {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 10px;
}
.lethalfantasy .tab.character-biography .biodata .biodata-elem {
display: flex;
align-items: center;
gap: 10px;
}
.lethalfantasy .tab.character-biography .biodata .biodata-elem .item-img {
width: 32px;
height: 32px;
margin: 5px 0 0 0;
}
.lethalfantasy .tab.character-biography .biodata .biodata-elem .name {
min-width: 8rem;
}
.lethalfantasy .character-biography prose-mirror.inactive {
min-height: 40px;
}

View File

@@ -478,6 +478,7 @@
"Platinums": "Platinum"
},
"Label": {
"biodata": "Biodata",
"titleChallenge": "Challenge",
"titleSave": "Save",
"titleSkill": "Skill",

View File

@@ -1,5 +1,4 @@
import LethalFantasyActorSheet from "./base-actor-sheet.mjs"
import { ROLL_TYPE } from "../../config/system.mjs"
export default class LethalFantasyCharacterSheet extends LethalFantasyActorSheet {
/** @override */
@@ -169,7 +168,7 @@ export default class LethalFantasyCharacterSheet extends LethalFantasyActorSheet
goodSkill = s
}
}
if (rollType === "weapon-damage") {
if (rollType.includes("weapon-damage") ) {
if (s.system.weaponBonus.damage > maxValue) {
maxValue = Number(s.system.weaponBonus.damage)
goodSkill = s
@@ -218,9 +217,10 @@ export default class LethalFantasyCharacterSheet extends LethalFantasyActorSheet
return
}
break
case "weapon-damage-small":
case "weapon-damage-medium":
case "weapon-attack":
case "weapon-defense":
case "weapon-damage":
let weapon = this.actor.items.find((i) => i.type === "weapon" && i.id === rollKey)
let skill
let skills = this.actor.items.filter((i) => i.type === "skill" && i.name.toLowerCase() === weapon.name.toLowerCase())
@@ -256,9 +256,6 @@ export default class LethalFantasyCharacterSheet extends LethalFantasyActorSheet
rollTarget.rollKey = rollKey
rollTarget.combat = foundry.utils.duplicate(this.actor.system.combat)
break
case ROLL_TYPE.DAMAGE:
rollTarget = elt.dataset.itemId
break
default:
ui.notifications.error(game.i18n.localize("LETHALFANTASY.Notifications.rollTypeNotFound") + String(rollType))
break

View File

@@ -9,13 +9,6 @@ import * as CHARACTERISTICS from "./characteristic-tables.mjs"
export const SYSTEM_ID = "fvtt-lethal-fantasy"
export const DEV_MODE = false
export const ROLL_TYPE = Object.freeze({
SAVE: "save",
RESOURCE: "resource",
DAMAGE: "damage",
ATTACK: "attack",
})
export const MONEY = {
tinbit: {
id: "tinbit",
@@ -155,7 +148,6 @@ export const SYSTEM = {
CHARACTERISTIC_DAMAGE,
MONEY,
ASCII,
ROLL_TYPE,
CHOICE_MODIFIERS,
CHOICE_DICE,
DEV_MODE,

View File

@@ -1,4 +1,3 @@
import { ROLL_TYPE } from "../config/system.mjs"
import LethalFantasyUtils from "../utils.mjs"
export default class LethalFantasyActor extends Actor {
@@ -26,6 +25,7 @@ export default class LethalFantasyActor extends Actor {
return super.create(data, options);
}
async _preCreate(data, options, user) {
await super._preCreate(data, options, user)
@@ -41,13 +41,4 @@ export default class LethalFantasyActor extends Actor {
}
}
async rollResource(resource) {
if (this.type !== "character") return
await this.system.roll(ROLL_TYPE.RESOURCE, resource)
}
async rollSave(save, avantage) {
if (this.type !== "character") return
await this.system.roll(ROLL_TYPE.SAVE, save, avantage)
}
}

View File

@@ -1,4 +1,4 @@
import { ROLL_TYPE, SYSTEM } from "../config/system.mjs"
import { SYSTEM } from "../config/system.mjs"
import LethalFantasyUtils from "../utils.mjs"
export default class LethalFantasyRoll extends Roll {
@@ -44,14 +44,6 @@ export default class LethalFantasyRoll extends Roll {
return this.options.actorImage
}
get introText() {
return this.options.introText
}
get introTextTooltip() {
return this.options.introTextTooltip
}
get modifier() {
return this.options.modifier
}
@@ -96,49 +88,6 @@ export default class LethalFantasyRoll extends Roll {
return this.options.rollTarget
}
/**
* Generates introductory text based on the roll type.
*
* @returns {string} The formatted introductory text for the roll.
*/
_createIntroText() {
let text
switch (this.type) {
case ROLL_TYPE.SAVE:
const saveLabel = game.i18n.localize(`LETHALFANTASY.Character.FIELDS.caracteristiques.${this.target}.valeur.label`)
text = game.i18n.format("LETHALFANTASY.Roll.save", { save: saveLabel })
text = text.concat("<br>").concat(`Seuil : ${this.treshold}`)
break
case ROLL_TYPE.RESOURCE:
const resourceLabel = game.i18n.localize(`LETHALFANTASY.Character.FIELDS.ressources.${this.target}.valeur.label`)
text = game.i18n.format("LETHALFANTASY.Roll.resource", { resource: resourceLabel })
break
case ROLL_TYPE.DAMAGE:
const damageLabel = this.target
text = game.i18n.format("LETHALFANTASY.Roll.damage", { item: damageLabel })
break
case ROLL_TYPE.ATTACK:
const attackLabel = this.target
text = game.i18n.format("LETHALFANTASY.Roll.attack", { item: attackLabel })
break
}
return text
}
/**
* Generates an introductory text tooltip with characteristics and modifiers.
*
* @returns {string} A formatted string containing the value, help, hindrance, and modifier.
*/
_createIntroTextTooltip() {
let tooltip = game.i18n.format("LETHALFANTASY.Tooltip.saveIntroTextTooltip", { value: this.value, aide: this.aide, gene: this.gene, modificateur: this.modificateur })
if (this.hasTarget) {
tooltip = tooltip.concat(`<br>Cible : ${this.targetName}`)
}
return tooltip
}
/**
* Prompt the user with a dialog to configure and execute a roll.
*
@@ -196,6 +145,20 @@ export default class LethalFantasyRoll extends Roll {
options.rollTarget.value = options.rollTarget.combat.defenseModifier + options.rollTarget.weaponSkillModifier
options.rollTarget.charModifier = options.rollTarget.combat.defenseModifier
}
} else if (options.rollType.includes("weapon-damage")) {
options.rollName = options.rollTarget.name
hasModifier = true
hasChangeDice = false
options.rollTarget.value = options.rollTarget.combat.damageModifier + options.rollTarget.weaponSkillModifier
options.rollTarget.charModifier = options.rollTarget.combat.damageModifier
if (options.rollType.includes("small")) {
dice = options.rollTarget.weapon.system.damage.damageS
} else {
dice = options.rollTarget.weapon.system.damage.damageM
}
dice = dice.replace("E", "")
baseFormula = dice
maxValue = 20
}
if (options.rollType === "save" && options.rollTarget.rollKey === "pain") {
@@ -342,11 +305,11 @@ export default class LethalFantasyRoll extends Roll {
} else {
rollTotal = diceSum + rollModifier.total
}
} else {
rollTotal = diceSum
}
rollBase.options.resultType = resultType
rollBase.options.introText = rollBase._createIntroText()
rollBase.options.introTextTooltip = rollBase._createIntroTextTooltip()
rollBase.options.rollTotal = rollTotal
rollBase.options.diceResults = diceResults
rollBase.options.rollTarget = options.rollTarget
@@ -385,8 +348,10 @@ export default class LethalFantasyRoll extends Roll {
return `${game.i18n.localize("LETHALFANTASY.Label.weapon-attack")}`
case "weapon-defense":
return `${game.i18n.localize("LETHALFANTASY.Label.weapon-defense")}`
case "weapon-damage":
return `${game.i18n.localize("LETHALFANTASY.Label.weapon-damage")}`
case "weapon-damage-small":
return `${game.i18n.localize("LETHALFANTASY.Label.weapon-damage-small")}`
case "weapon-damage-medium":
return `${game.i18n.localize("LETHALFANTASY.Label.weapon-damage-medium")}`
default:
return game.i18n.localize("LETHALFANTASY.Label.titleStandard")
}
@@ -415,8 +380,6 @@ export default class LethalFantasyRoll extends Roll {
* @property {string} actorId - The ID of the actor performing the roll.
* @property {string} actingCharName - The name of the character performing the roll.
* @property {string} actingCharImg - The image of the character performing the roll.
* @property {string} introText - Introductory text for the roll.
* @property {string} introTextTooltip - Tooltip for the introductory text.
* @property {string} resultType - The type of result (e.g., success, failure).
* @property {boolean} hasTarget - Indicates if the roll has a target.
* @property {string} targetName - The name of the target.
@@ -442,8 +405,6 @@ export default class LethalFantasyRoll extends Roll {
diceResults: this.diceResults,
actingCharName: this.actorName,
actingCharImg: this.actorImage,
introText: this.introText,
introTextTooltip: this.introTextTooltip,
resultType: this.resultType,
hasTarget: this.hasTarget,
targetName: this.targetName,
@@ -470,10 +431,8 @@ export default class LethalFantasyRoll extends Roll {
isSave: this.isSave,
isChallenge: this.isChallenge,
isFailure: this.resultType === "failure",
introText: this.introText,
rollType: this.type,
rollTarget: this.rollTarget,
introTextTooltip: this.introTextTooltip,
actingCharName: this.actorName,
actingCharImg: this.actorImage,
hasTarget: this.hasTarget,

View File

@@ -1,4 +1,4 @@
import { ROLL_TYPE, SYSTEM } from "../config/system.mjs"
import { SYSTEM } from "../config/system.mjs"
import LethalFantasyRoll from "../documents/roll.mjs"
import LethalFantasyUtils from "../utils.mjs"

View File

@@ -1,5 +1,4 @@
import LethalFantasyRoll from "../documents/roll.mjs"
import { ROLL_TYPE } from "../config/system.mjs"
export default class LethalFantasyOpponent extends foundry.abstract.TypeDataModel {
static defineSchema() {
@@ -26,13 +25,13 @@ export default class LethalFantasyOpponent extends foundry.abstract.TypeDataMode
/**
* Rolls a dice attack for an opponent.
* @param {number} rollValue The dice to roll.
* @param {number} rollType Type of roll.
* @param {number} rollTarget The name of the attack
* @returns {Promise<null>} - A promise that resolves to null if the roll is cancelled.
*/
async roll(rollValue, rollTarget) {
async roll(rollType, rollTarget) {
let roll = await LethalFantasyRoll.prompt({
rollType: ROLL_TYPE.ATTACK,
rollType: rollType,
rollValue,
rollTarget,
actorId: this.parent.id,

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
packs/lf-gifts/MANIFEST-000070 LFS Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
packs/lf-skills/MANIFEST-000074 LFS Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -296,6 +296,27 @@
}
}
.tab.character-biography {
.biodata {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 10px;
.biodata-elem {
display: flex;
align-items: center;
gap: 10px;
.item-img {
width: 32px;
height: 32px;
margin: 5px 0 0 0;
}
.name {
min-width: 8rem;
}
}
}
}
.character-biography {
prose-mirror.inactive {
min-height: 40px;

View File

@@ -6,7 +6,7 @@
"download": "#{DOWNLOAD}#",
"url": "#{URL}#",
"license": "LICENSE",
"version": "12.0.11",
"version": "12.0.12",
"authors": [
{
"name": "Uberwald",

View File

@@ -1,10 +1,54 @@
<section class="tab character-{{tab.id}} {{tab.cssClass}}" data-tab="{{tab.id}}" data-group="{{tab.group}}">
<fieldset>
<legend>{{localize "LETHALFANTASY.Label.biodata"}}</legend>
<div class="biodata">
<div class="biodata-elem">
<span class="name">Class</span>
{{formInput systemFields.biodata.fields.class value=system.biodata.class }}
</div>
<div class="biodata-elem">
<span class="name">Level</span>
{{formInput systemFields.biodata.fields.level value=system.biodata.level }}
</div>
<div class="biodata-elem">
<span class="name">Mortal</span>
{{formInput systemFields.biodata.fields.mortal value=system.biodata.mortal }}
</div>
<div class="biodata-elem">
<span class="name">Alignment</span>
{{formInput systemFields.biodata.fields.alignment value=system.biodata.alignment }}
</div>
<div class="biodata-elem">
<span class="name">Age</span>
{{formInput systemFields.biodata.fields.age value=system.biodata.age }}
</div>
<div class="biodata-elem">
<span class="name">Height</span>
{{formInput systemFields.biodata.fields.height value=system.biodata.height }}
</div>
<div class="biodata-elem">
<span class="name">Eyes</span>
{{formInput systemFields.biodata.fields.eyes value=system.biodata.eyes }}
</div>
<div class="biodata-elem">
<span class="name">Hair</span>
{{formInput systemFields.biodata.fields.hair value=system.biodata.hair }}
</div>
</div>
</fieldset>
<fieldset>
<legend>{{localize "LETHALFANTASY.Label.description"}}</legend>
{{formInput systemFields.description enriched=enrichedDescription value=system.description name="system.description" toggled=true}}
{{formInput systemFields.description enriched=enrichedDescription value=system.description name="system.description"
toggled=true}}
</fieldset>
<fieldset>
<legend>{{localize "LETHALFANTASY.Label.notes"}}</legend>
{{formInput systemFields.notes enriched=enrichedNotes value=system.notes name="system.notes" toggled=true}}
</fieldset>
</section>

View File

@@ -23,8 +23,12 @@
<i class="fa-solid fa-shield-halved" data-roll-type="weapon-defense" data-roll-key="{{item.id}}"></i>
</a>
<a class="rollable" data-roll-type="weapon-damage" data-roll-key="{{item.id}}" data-tooltip="Roll Damage">
<i class="fa-regular fa-face-head-bandage" data-roll-type="weapon-damage" data-roll-key="{{item.id}}"></i>
<a class="rollable" data-roll-type="weapon-damage-small" data-roll-key="{{item.id}}" data-tooltip="Roll Damage (Small)">
<i class="fa-regular fa-face-head-bandage" data-roll-type="weapon-damage-small" data-roll-key="{{item.id}}"></i>S
</a>
<a class="rollable" data-roll-type="weapon-damage-medium" data-roll-key="{{item.id}}" data-tooltip="Roll Damage (Medium)">
<i class="fa-regular fa-face-head-bandage" data-roll-type="weapon-damage-medium" data-roll-key="{{item.id}}"></i>M
</a>
</div>