HUD + liste de talents

This commit is contained in:
LeRatierBretonnien 2022-12-03 23:13:08 +01:00
parent 6b508c96be
commit 5ab6b99ef6
10 changed files with 196 additions and 22 deletions

View File

@ -48,6 +48,7 @@ export class HawkmoonActorSheet extends ActorSheet {
profils: duplicate(this.actor.getProfils() || {}),
combat: this.actor.getCombatValues(),
equipements: duplicate(this.actor.getEquipments()),
initiative: this.actor.getFlag("world", "last-initiative") || -1,
description: await TextEditor.enrichHTML(this.object.system.biodata.description, {async: true}),
habitat: await TextEditor.enrichHTML(this.object.system.biodata.habitat, {async: true}),
options: this.options,

View File

@ -490,6 +490,11 @@ export class HawkmoonActor extends Actor {
return talents
}
/* -------------------------------------------- */
buildListeAdversites() {
return []
}
/* -------------------------------------------- */
getCommonRollData(attrKey = undefined, compId = undefined, compName = undefined) {
let rollData = HawkmoonUtility.getBasicRollData()

71
modules/hawkmoon-hud.js Normal file
View File

@ -0,0 +1,71 @@
/* -------------------------------------------- */
/* -------------------------------------------- */
export class HawkmoonTokenHud {
static init() {
// Integration du TokenHUD
Hooks.on('renderTokenHUD', (app, html, data) => { HawkmoonTokenHud.addTokenHudExtensions(app, html, data._id) });
}
/* -------------------------------------------- */
static async removeExtensionHud(app, html, tokenId) {
html.find('.control-icon.hawkmoon-adversite').remove()
}
/* -------------------------------------------- */
static async addExtensionHud(app, html, tokenId) {
let token = canvas.tokens.get(tokenId)
let actor = token.actor
app.hasExtension = true
const hudData = { actor: actor }
const controlIconActions = html.find('.control-icon[data-action=combat]');
// initiative
await HawkmoonTokenHud._configureSubMenu(controlIconActions, 'systems/fvtt-hawkmoon-cyd/templates/hud-adversites.html', hudData,
(event) => {
let adversite = event.currentTarget.attributes['data-action-index'].value
let value = Number(event.currentTarget.attributes['data-action-value'].value)
hudData.actor.incDecAdversite( adversite, value)
} )
}
/* -------------------------------------------- */
static async addTokenHudExtensions(app, html, tokenId) {
const controlIconCombat = html.find('.control-icon[data-action=combat]')
if (controlIconCombat.length>0 ) {
HawkmoonTokenHud.addExtensionHud(app, html, tokenId);
}
}
/* -------------------------------------------- */
static async _configureSubMenu(insertionPoint, template, hudData, onMenuItem) {
const hud = $(await renderTemplate(template, hudData))
const list = hud.find('div.hawkmoon-hud-list')
HawkmoonTokenHud._toggleHudListActive(hud, list);
hud.find('img.hawkmoon-hud-togglebutton').click(event => HawkmoonTokenHud._toggleHudListActive(hud, list));
list.find('.hawkmoon-hud-adversite').click(onMenuItem);
insertionPoint.after(hud);
}
/* -------------------------------------------- */
static _showControlWhen(control, condition) {
if (condition) {
control.show()
}
else {
control.hide()
}
}
/* -------------------------------------------- */
static _toggleHudListActive(hud, list) {
hud.toggleClass('active')
HawkmoonTokenHud._showControlWhen(list, hud.hasClass('active'))
}
}

View File

@ -17,6 +17,7 @@ import { HawkmoonUtility } from "./hawkmoon-utility.js";
import { HawkmoonCombat } from "./hawkmoon-combat.js";
import { HawkmoonItem } from "./hawkmoon-item.js";
import { HawkmoonAutomation } from "./hawkmoon-automation.js";
import { HawkmoonTokenHud } from "./hawkmoon-hud.js";
/* -------------------------------------------- */
/* Foundry VTT Initialization */
@ -64,6 +65,7 @@ Hooks.once("init", async function () {
HawkmoonUtility.init()
HawkmoonAutomation.init()
HawkmoonTokenHud.init()
});
@ -110,7 +112,8 @@ function registerUsageCount(registerKey) {
/* -------------------------------------------- */
Hooks.once("ready", function () {
HawkmoonUtility.ready();
HawkmoonUtility.ready()
// User warning
if (!game.user.isGM && game.user.character == undefined) {
ui.notifications.info("Attention ! Aucun personnage n'est relié au joueur !");

View File

@ -96,7 +96,7 @@ export class HawkmoonUtility {
static async ready() {
const skills = await HawkmoonUtility.loadCompendium("fvtt-hawkmoon-cyd.skills")
this.skills = skills.map(i => i.toObject())
// Setup pause logo
let logoPause = "systems/fvtt-hawkmoon-cyd/assets/logos/" + game.settings.get("fvtt-hawkmoon-cyd", "hawkmoon-pause-logo") + ".webp"
let logoImg = document.querySelector('#pause').children[0]
@ -154,6 +154,7 @@ export class HawkmoonUtility {
'systems/fvtt-hawkmoon-cyd/templates/partial-item-prix.html',
'systems/fvtt-hawkmoon-cyd/templates/partial-sante-etat.html',
'systems/fvtt-hawkmoon-cyd/templates/partial-automation.html',
'systems/fvtt-hawkmoon-cyd/templates/hud-adversites.html',
]
return loadTemplates(templatePaths);
}
@ -216,8 +217,8 @@ export class HawkmoonUtility {
}
/* -------------------------------------------- */
static getActorFromRollData(rollData) {
let actor = game.actors.get( rollData.actorId)
static getActorFromRollData(rollData) {
let actor = game.actors.get(rollData.actorId)
if (rollData.tokenId) {
let token = canvas.tokens.placeables.find(t => t.id == rollData.tokenId)
if (token) {
@ -307,7 +308,7 @@ export class HawkmoonUtility {
/* -------------------------------------------- */
static computeResult(rollData) {
rollData.diceResult = rollData.roll.terms[0].results[0].result
if (rollData.mainDice.includes("d20") ) {
if (rollData.mainDice.includes("d20")) {
let diceValue = rollData.roll.terms[0].results[0].result
if (diceValue % 2 == 1) {
//console.log("PAIR/IMP2", diceValue)
@ -325,7 +326,7 @@ export class HawkmoonUtility {
rollData.isHeroique = ((rollData.finalResult - rollData.difficulte) >= 10)
rollData.isDramatique = ((rollData.finalResult - rollData.difficulte) <= -10)
}
}
/* -------------------------------------------- */
@ -340,8 +341,8 @@ export class HawkmoonUtility {
rollData.attr = duplicate(actor.system.attributs[rollData.attrKey])
}
if ( rollData.maitriseId != "none") {
rollData.selectedMaitrise = rollData.maitrises.find(p => p.id == rollData.maitriseId )
if (rollData.maitriseId != "none") {
rollData.selectedMaitrise = rollData.maitrises.find(p => p.id == rollData.maitriseId)
rollData.diceFormula = "2" + rollData.mainDice + "kh"
} else {
rollData.diceFormula = "1" + rollData.mainDice
@ -352,15 +353,15 @@ export class HawkmoonUtility {
rollData.predilections = duplicate(rollData.competence.system.predilections.filter(pred => pred.acquise && !pred.maitrise && !pred.used) || [])
let compmod = (rollData.competence.system.niveau == 0) ? -3 : 0
rollData.diceFormula += `+${rollData.attr.value}+${rollData.competence.system.niveau}+${rollData.modificateur}+${compmod}`
if ( rollData.selectedTalents && rollData.selectedTalents.length > 0) {
if (rollData.selectedTalents && rollData.selectedTalents.length > 0) {
for (let id of rollData.selectedTalents) {
let talent = rollData.talents.find(t => t._id == id)
let bonusOK = true
if ( talent.system.baCost ) {
bonusOK = actor.checkBonneAventure( talent.system.baCost)
if ( bonusOK ) {
actor.changeBonneAventure( -talent.system.baCost )
if (talent.system.baCost) {
bonusOK = actor.checkBonneAventure(talent.system.baCost)
if (bonusOK) {
actor.changeBonneAventure(-talent.system.baCost)
} else {
ui.notifications.warn("Vous n'avez pas assez de points de Bonne Aventure !")
}
@ -369,7 +370,7 @@ export class HawkmoonUtility {
rollData.diceFormula += `+${talent.system.bonus}`
}
}
}
}
rollData.diceFormula += `+${rollData.bonusMalusContext}`
} else {
rollData.diceFormula += `+${rollData.attr.value}*${rollData.multiplier}+${rollData.modificateur}+${rollData.bonusMalusContext}`
@ -522,7 +523,7 @@ export class HawkmoonUtility {
let defender = game.canvas.tokens.get(rollData.defenderTokenId).actor
rollData.armeDefense = defender.getBestDefenseValue()
rollData.targetVigueur = defender.getVigueur()
if ( rollData.armeDefense) {
if (rollData.armeDefense) {
rollData.difficulte = rollData.armeDefense.system.totalDefensif
} else {
ui.notifications.warn("Aucune arme de défense équipée, difficulté manuelle à positionner.")
@ -580,13 +581,13 @@ export class HawkmoonUtility {
let message = game.messages.get(li.attr("data-message-id"))
let rollData = message.getFlag("world", "hawkmoon-roll")
let actor = this.getActorFromRollData(rollData)
return (!rollData.isReroll && actor.getBonneAventure() > 0 )
return (!rollData.isReroll && actor.getBonneAventure() > 0)
}
let canApplyPE = function (li) {
let message = game.messages.get(li.attr("data-message-id"))
let rollData = message.getFlag("world", "hawkmoon-roll")
let actor = this.getActorFromRollData(rollData)
return (!rollData.isReroll && actor.getEclat() > 0 )
return (!rollData.isReroll && actor.getEclat() > 0)
}
options.push(
{
@ -643,4 +644,21 @@ export class HawkmoonUtility {
d.render(true);
}
}
/************************************************************************************/
static async __create_talents_table() {
let compName = "fvtt-hawkmoon-cyd.talents-cellule"
const compData = await HawkmoonUtility.loadCompendium(compName)
let talents = compData.map(i => i.toObject())
let htmlTab = "<table border='1'><tbody>";
for (let entryData of talents) {
console.log(entryData)
htmlTab += `<tr><td>@UUID[Compendium.${compName}.${entryData._id}]{${entryData.name}}</td>`
htmlTab += `<td>${entryData.system.description}</td>`;
//htmlTab += `<td>${entryData.system.resumebonus}</td>`;
htmlTab += "</tr>\n";
}
htmlTab += "</table>";
await JournalEntry.create({ name: 'Liste des Talents de Cellule', content: htmlTab });
}
}

2
packs/aides-de-jeu.db Normal file

File diff suppressed because one or more lines are too long

View File

@ -790,6 +790,7 @@ ul, li {
width: fit-content;
height: fit-content;
min-width: 6rem;
min-height: 1.2rem;
flex-basis: auto;
padding: 0;
line-height: 1rem;
@ -896,6 +897,22 @@ ul, li {
border: 0px;
}
.hud-adversite-container {
position: relative;
text-align: center;
color: white;
width: 64px;
min-height: 64px;
}
.hud-adversite-text {
font-weight: bold;
font-size:0.9rem;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -85%);
}
.actor-icon {
float: left;
width: 48px;

View File

@ -1,7 +1,7 @@
{
"id": "fvtt-hawkmoon-cyd",
"description": "Hawmoon RPG for FoundryVTT (CYD system - French)",
"version": "10.1.1",
"version": "10.1.2",
"authors": [
{
"name": "Uberwald/LeRatierBretonnien",
@ -35,7 +35,7 @@
"gridUnits": "m",
"license": "LICENSE.txt",
"manifest": "https://www.uberwald.me/gitea/public/fvtt-hawkmoon-cyd/raw/branch/master/system.json",
"download": "https://www.uberwald.me/gitea/public/fvtt-hawkmoon-cyd/archive/fvtt-hawkmoon-cyd-10.1.1.zip",
"download": "https://www.uberwald.me/gitea/public/fvtt-hawkmoon-cyd/archive/fvtt-hawkmoon-cyd-10.1.2.zip",
"packs": [
{
"type": "Item",
@ -117,6 +117,15 @@
"system": "fvtt-hawkmoon-cyd",
"private": false,
"flags": {}
},
{
"type": "JournalEntry",
"label": "Aides de Jeu",
"name": "aides-de-jeu",
"path": "packs/aides-de-jeu.db",
"system": "fvtt-hawkmoon-cyd",
"private": false,
"flags": {}
}
],
"primaryTokenAttribute": "sante.vigueur",

View File

@ -233,7 +233,7 @@
<ul class="item-list alternate-list">
<li class="item flexrow">
<button class="chat-card-button roll-initiative">Initiative</button>
<button class="chat-card-button roll-initiative">Initiative (actuelle : {{initiative}} )</button>
</li>
</ul>

View File

@ -0,0 +1,48 @@
<div class="control-icon hawkmoon-adversite ">
<img class="hawkmoon-hud-togglebutton" src="icons/svg/sword.svg" width="36" height="36" title="Action" />
<div class="hawkmoon-hud-list tokenhudext right">
<div class="flexrow tokenhudicon">
<div class="hawkmoon-hud-adversite hud-adversite-container" data-action-value="-1"
data-action-index="bleue" title="Adversite Bleue">
<img class="icon-adversite" src="systems/fvtt-hawkmoon-cyd/assets/icons/gemme_bleue.webp">
<div class="hud-adversite-text">&nbsp;-1</div>
</div>
<div class="hawkmoon-hud-adversite hud-adversite-container" data-action-value="+1"
data-action-index="bleue" title="Adversite Bleue">
<img class="icon-adversite" src="systems/fvtt-hawkmoon-cyd/assets/icons/gemme_bleue.webp">
<div class="hud-adversite-text">&nbsp;+1</div>
</div>
</div>
<div class="flexrow tokenhudicon">
<div class="hawkmoon-hud-adversite hud-adversite-container" data-action-value="-1"
data-action-index="rouge" title="Adversite Rouge">
<img class="icon-adversite" src="systems/fvtt-hawkmoon-cyd/assets/icons/gemme_rouge.webp">
<div class="hud-adversite-text">&nbsp;-1</div>
</div>
<div class="hawkmoon-hud-adversite hud-adversite-container" data-action-value="+1"
data-action-index="rouge" title="Adversite Rouge">
<img class="icon-adversite" src="systems/fvtt-hawkmoon-cyd/assets/icons/gemme_rouge.webp">
<div class="hud-adversite-text">&nbsp;+1</div>
</div>
</div>
<div class="flexrow tokenhudicon">
<div class="hawkmoon-hud-adversite hud-adversite-container" data-action-value="-1"
data-action-index="noire" title="Adversite Noire">
<img class="icon-adversite" src="systems/fvtt-hawkmoon-cyd/assets/icons/gemme_noire.webp">
<div class="hud-adversite-text">&nbsp;-1</div>
</div>
<div class="hawkmoon-hud-adversite hud-adversite-container" data-action-value="+1"
data-action-index="noire" title="Adversite Noire">
<img class="icon-adversite" src="systems/fvtt-hawkmoon-cyd/assets/icons/gemme_noire.webp">
<div class="hud-adversite-text">&nbsp;+1</div>
</div>
</div>
</div>
</div>