diff --git a/images/ui/wotg_logo_01.webp b/images/ui/wotg_logo_01.webp deleted file mode 100644 index 381194c..0000000 Binary files a/images/ui/wotg_logo_01.webp and /dev/null differ diff --git a/modules/pegasus-actor-sheet.js b/modules/pegasus-actor-sheet.js index 46acc9b..54a6016 100644 --- a/modules/pegasus-actor-sheet.js +++ b/modules/pegasus-actor-sheet.js @@ -41,6 +41,8 @@ export class PegasusActorSheet extends ActorSheet { effects: this.object.effects.map(e => foundry.utils.deepClone(e.data)), limited: this.object.limited, specs: this.actor.getSpecs( ), + optionsDiceList: PegasusUtility.getOptionsDiceList(), + optionsLevel: PegasusUtility.getOptionsLevel(), weapons: this.actor.checkAndPrepareWeapons( duplicate(this.actor.getWeapons()) ), armors: duplicate(this.actor.getArmors()), shields: duplicate(this.actor.getShields()), @@ -102,10 +104,14 @@ export class PegasusActorSheet extends ActorSheet { this.actor.incrementeQuantite( li.data("item-id") ); } ); - html.find('.skill-roll').click((event) => { + html.find('.roll-stat').click((event) => { + const statId = $(event.currentTarget).data("stat-key"); + this.actor.rollStat(statId); + }); + html.find('.roll-spec').click((event) => { const li = $(event.currentTarget).parents(".item"); - const skillId = li.data("item-id"); - this.actor.rollSkill(skillId); + const specId = li.data("item-id"); + this.actor.rollSpec(specId); }); html.find('.technique-roll').click((event) => { const li = $(event.currentTarget).parents(".item"); diff --git a/modules/pegasus-actor.js b/modules/pegasus-actor.js index cd45e08..81194c1 100644 --- a/modules/pegasus-actor.js +++ b/modules/pegasus-actor.js @@ -126,13 +126,16 @@ export class PegasusActor extends Actor { /* -------------------------------------------- */ getWeapons() { - let comp = this.data.items.filter( item => item.type == 'weapon' ); + let comp = duplicate(this.data.items.filter( item => item.type == 'weapon' ) || []); return comp; } /* -------------------------------------------- */ getSpecs() { - let comp = this.data.items.filter( item => item.type == 'specialisation'); + let comp = duplicate(this.data.items.filter( item => item.type == 'specialisation') || []); + for (let c of comp) { + c.data.dice = PegasusUtility.getDiceFromLevel(c.data.level); + } return comp; } @@ -350,44 +353,89 @@ export class PegasusActor extends Actor { /* -------------------------------------------- */ syncRoll( rollData ) { - let linkedRollId = WotGUtility.getDefenseState(this.id); + let linkedRollId = PegasusUtility.getDefenseState(this.id); if ( linkedRollId) { rollData.linkedRollId = linkedRollId; } - rollData.rollId = randomID(16); this.lastRollId = rollData.rollId; - WotGUtility.saveRollData( rollData ); + PegasusUtility.saveRollData( rollData ); } /* -------------------------------------------- */ - async rollSkill( skillId ) { - let skill = this.data.items.find( item => item.type == 'skill' && item.id == skillId); - if (skill) { + getStat( statKey) { + let stat = duplicate(this.data.data.statistics[statKey]); + stat.dice = PegasusUtility.getDiceFromLevel(stat.value); + return stat; + } + + /* -------------------------------------------- */ + getOneSpec( specId) { + let spec = this.data.items.find( item => item.type == 'specialisation' && item.id == specId); + if (spec) { + spec = duplicate(spec); + spec.data.dice = PegasusUtility.getDiceFromLevel(spec.data.level); + } + return spec; + } + + /* -------------------------------------------- */ + async rollStat(statKey) { + let stat = this.getStat(statKey) ; + if (stat) { let rollData = { - mode: "skill", + rollId:randomID(16), + mode: "stat", alias: this.name, actorImg: this.img, actorId: this.id, - img: skill.img, + img: this.img, rollMode: game.settings.get("core", "rollMode"), - armorModifier: this.getArmorModifier(), - title: `Skill ${skill.name} `, - skill: duplicate(skill), - skillAttr: this.getAttribute( skill.data.data.attribute ), - optionsNegative: WotGUtility.getNegativeModifiers(), - optionsPositive: WotGUtility.getPositiveModifiers(), - negativeModifier: 0, - positiveModifier: 0, - specialtiesBonus: 0, + title: `Stat ${stat.label} `, + stat: stat, + optionsDiceList: PegasusUtility.getOptionsDiceList(), + bonusDicesLevel: 0, + hindranceDicesLevel: 0, + otherDicesLevel: 0, } this.syncRoll( rollData); - let rollDialog = await WotGRollDialog.create( this, rollData); + let rollDialog = await PegasusRollDialog.create( this, rollData); console.log(rollDialog); rollDialog.render( true ); } else { - ui.notifications.warn("Skill not found !"); + ui.notifications.warn("Statistic not found !"); + } + } + + + /* -------------------------------------------- */ + async rollSpec( specId ) { + let spec = this.getOneSpec( specId) + if (spec) { + let rollData = { + mode: "spec", + alias: this.name, + actorImg: this.img, + actorId: this.id, + img: spec.img, + rollMode: game.settings.get("core", "rollMode"), + title: `Specialisation Roll : ${spec.name} `, + spec : spec , + optionsDiceList: PegasusUtility.getOptionsDiceList(), + stat: this.getStat( spec.data.statistic ), + bonusDicesLevel: 0, + hindranceDicesLevel: 0, + otherDicesLevel: 0, + } + + this.syncRoll( rollData); + + let rollDialog = await PegasusRollDialog.create( this, rollData); + console.log(rollDialog); + rollDialog.render( true ); + } else { + ui.notifications.warn("Specialisation not found !"); } } diff --git a/modules/pegasus-item-sheet.js b/modules/pegasus-item-sheet.js index 4f83259..551e233 100644 --- a/modules/pegasus-item-sheet.js +++ b/modules/pegasus-item-sheet.js @@ -59,6 +59,7 @@ export class PegasusItemSheet extends ItemSheet { name: objectData.name, editable: this.isEditable, cssClass: this.isEditable ? "editable" : "locked", + optionsDiceList: PegasusUtility.getOptionsDiceList(), data: itemData, limited: this.object.limited, options: this.options, diff --git a/modules/pegasus-main.js b/modules/pegasus-main.js index 4d28839..daafd04 100644 --- a/modules/pegasus-main.js +++ b/modules/pegasus-main.js @@ -28,6 +28,16 @@ Hooks.once("init", async function () { // preload handlebars templates PegasusUtility.preloadHandlebarsTemplates(); + /* -------------------------------------------- */ + game.settings.register("fvtt-pegasus-rpg", "dice-max-level", { + name: "Maximum level value for dices lists", + hint: "Se the maximum level value for dices lists", + scope: "world", + config: true, + default: 20, + type: Number + }); + /* -------------------------------------------- */ // Set an initiative formula for the system CONFIG.Combat.initiative = { diff --git a/modules/pegasus-roll-dialog.js b/modules/pegasus-roll-dialog.js index 8811b27..9881815 100644 --- a/modules/pegasus-roll-dialog.js +++ b/modules/pegasus-roll-dialog.js @@ -7,12 +7,12 @@ export class PegasusRollDialog extends Dialog { let html let options = { classes: ["WotGdialog"], width: 420, height: 320, 'z-index': 99999 }; - if ( rollData.mode == "skill") { - html = await renderTemplate('systems/fvtt-pegasus-rpg/templates/roll-dialog-skill.html', rollData); + if ( rollData.mode == "stat") { + html = await renderTemplate('systems/fvtt-pegasus-rpg/templates/roll-dialog-stat.html', rollData); + options.height = 320; + } else if (rollData.mode == "spec") { + html = await renderTemplate('systems/fvtt-pegasus-rpg/templates/roll-dialog-spec.html', rollData); options.height = 360; - } else if (rollData.mode == "chidamage") { - html = await renderTemplate('systems/fvtt-pegasus-rpg/templates/roll-dialog-damage-chi.html', rollData); - options.height = 380; } else if (rollData.mode == "technique") { html = await renderTemplate('systems/fvtt-pegasus-rpg/templates/roll-dialog-technique.html', rollData); options.height = 380; @@ -53,7 +53,7 @@ export class PegasusRollDialog extends Dialog { /* -------------------------------------------- */ roll () { - PegasusUtility.rollWotG( this.rollData ) + PegasusUtility.rollPegasus( this.rollData ) } /* -------------------------------------------- */ @@ -65,20 +65,14 @@ export class PegasusRollDialog extends Dialog { } $(function () { onLoad(); }); - html.find('#negativeModifier').change((event) => { - this.rollData.negativeModifier = Number(event.currentTarget.value); + html.find('#bonusDicesLevel').change((event) => { + this.rollData.bonusDicesLevel = Number(event.currentTarget.value); }); - html.find('#positiveModifier').change((event) => { - this.rollData.positiveModifier = Number(event.currentTarget.value); + html.find('#hindranceDicesLevel').change((event) => { + this.rollData.hindranceDicesLevel = Number(event.currentTarget.value); }); - html.find('#specialtiesBonus').change((event) => { - this.rollData.specialtiesBonus = Number(event.currentTarget.value); - }); - html.find('#selectedChi').change((event) => { - this.rollData.selectedChi = Number(event.currentTarget.value); - }); - html.find('#bonusMalus').change((event) => { - this.rollData.bonusMalus = Number(event.currentTarget.value); + html.find('#otherDicesLevel').change((event) => { + this.rollData.otherDicesLevel = Number(event.currentTarget.value); }); } } \ No newline at end of file diff --git a/modules/pegasus-utility.js b/modules/pegasus-utility.js index 10e7399..6e53f1d 100644 --- a/modules/pegasus-utility.js +++ b/modules/pegasus-utility.js @@ -1,4 +1,5 @@ /* -------------------------------------------- */ +const __level2Dice = [ "d0", "d4", "d6", "d8", "d10", "d12" ]; /* -------------------------------------------- */ export class PegasusUtility { @@ -9,6 +10,10 @@ export class PegasusUtility { Hooks.on('renderChatLog', (log, html, data) => PegasusUtility.chatListeners(html)); this.rollDataStore = {} this.defenderStore = {} + this.diceList = []; + this.diceFoundryList = []; + this.optionsDiceList = ""; + this.buildDiceLists(); } /* -------------------------------------------- */ static getSpecs( ) { @@ -21,6 +26,47 @@ export class PegasusUtility { this.specs = specs.map(i => i.toObject()); } + /* -------------------------------------------- */ + static buildDiceLists() { + let maxLevel = game.settings.get("fvtt-pegasus-rpg", "dice-max-level"); + let diceList = [ "0" ]; + let diceFoundryList = [ "d0" ]; + let diceLevel = 1; + let concat = ""; + let concatFoundry = ""; + let optionsDiceList = '0'; + let optionsLevel = '0'; + for(let i=1; i<=maxLevel;i++) { + let currentDices = concat + __level2Dice[diceLevel]; + diceList.push( currentDices ); + diceFoundryList.push( concatFoundry + __level2Dice[diceLevel] + "x" ); + if ( __level2Dice[diceLevel] == "d12") { + concat = concat + "d12 "; + concatFoundry = concatFoundry + "d12x, "; + diceLevel = 1; + } else { + diceLevel++; + } + optionsDiceList += `${currentDices}`; + optionsLevel += `${i}`; + } + this.diceList = diceList; + this.diceFoundryList = diceFoundryList; + this.optionsDiceList = optionsDiceList; + this.optionsLevel = optionsLevel; + + console.log("Defautl dice List", diceList, diceFoundryList); + } + + /* -------------------------------------------- */ + static getOptionsDiceList() { + return this.optionsDiceList; + } + /* -------------------------------------------- */ + static getOptionsLevel() { + return this.optionsLevel; + } + /* -------------------------------------------- */ static computeAttackDefense(defenseRollId) { let defenseRollData = this.getRollData(defenseRollId ); @@ -43,14 +89,6 @@ export class PegasusUtility { defender.processNoDefense( attackRollData ) ; } - /* -------------------------------------------- */ - static reduceDamageWithChi( defenseRollId) { - let defenseRollData = this.getRollData(defenseRollId ); - let attackRollData = this.getRollData(defenseRollData.linkedRollId); - let defender = game.actors.get( defenseRollData.actorId); - defender.reduceDamageWithChi(defenseRollData, attackRollData); - } - /* -------------------------------------------- */ static async chatListeners(html) { @@ -103,28 +141,19 @@ export class PegasusUtility { } return it; } + /* -------------------------------------------- */ - static getChiList() { - let chi = []; - chi.push( { name: "Jade" }); - chi.push( { name: "Crimson" }); - chi.push( { name: "Gold" }); - chi.push( { name: "White" }); - chi.push( { name: "Silver" }); - return chi; + static getDiceFromLevel(level = 0) { + level = Number(level) + return this.diceList[level]; } /* -------------------------------------------- */ - static getskillChiList( ) { - let skillsName = []; - let skills = this.getSkills(); - console.log("SKILLS", skills); - for (let skill of skills) { - skillsName.push( { name: skill.name }); - } - skillsName = skillsName.concat( this.getChiList() ); - return skillsName; + static getFoundryDiceFromLevel(level = 0) { + level = Number(level) + console.log(this.diceFoundryList); + return this.diceFoundryList[level]; } - + /* -------------------------------------------- */ static createDirectOptionList( min, max) { let options = {}; @@ -142,29 +171,6 @@ export class PegasusUtility { } return options; } - /* -------------------------------------------- */ - static getNegativeModifiers(min, max) { - let options = "" - options += `0` - options += `-5` - options += `-10` - return options; - } - /* -------------------------------------------- */ - static getPositiveModifiers(min, max) { - let options = "" - options += `0` - options += `+5` - options += `+10` - options += `+15` - options += `+20` - options += `+30` - options += `+40` - options += `+60` - options += `+50` - options += `+70` - return options; - } /* -------------------------------------------- */ static getTarget() { @@ -300,93 +306,50 @@ export class PegasusUtility { /* -------------------------------------------- */ - static async rollWotG( rollData ) { + static async rollPegasus( rollData ) { - if (rollData.mode == "chidamage" ) { - let defender = game.actors.get( rollData.actorId); - defender.rollChiDamage(rollData); - return; + let dicePool = [ {name:"stat", level: 0, statmod: 0}, {name: "spec", level: 0}, {name:"bonus", level: 0}, {name:"hindrance", level: 0}, {name:"other", level:0} ]; + if (rollData.stat) { + dicePool[0].level += Number(rollData.stat.value); + dicePool[0].statmod = Number(rollData.stat.mod); + } + if (rollData.spec) { + dicePool[1].level += Number(rollData.spec.data.level); + } + if (rollData.bonusDicesLevel) { + dicePool[2].level += Number(rollData.bonusDicesLevel); + } + if (rollData.hindranceDicesLevel) { + dicePool[3].level += Number(rollData.hindranceDicesLevel); + } + if (rollData.otherDicesLevel) { + dicePool[4].level += Number(rollData.otherDicesLevel); } - let nbDice = 0; - if ( rollData.mode == 'skill' || rollData.mode == 'technique') { - nbDice = rollData.skill?.data.level || 0; + let diceFormulaTab = []; + for (let diceGroup of dicePool) { + diceFormulaTab.push( this.getFoundryDiceFromLevel( diceGroup.level) ) } - if ( rollData.mode == 'weapon' ) { - rollData.skill = rollData.weapon.data.skills[rollData.skillKey]; - rollData.skillAttr = rollData.weapon.data.skills[rollData.skillKey].data.attr; - nbDice = rollData.skill?.data.level || 0; - } - if ( rollData.mode == 'technique') { - // Compute number of dice - if (rollData.attr ) { - rollData.skillAttr = rollData.attr; - } - if (rollData.chi ) { - rollData.skillAttr = rollData.chi; - nbDice = rollData.skillAttr.value || 0; - } - } - if ( rollData.skill && rollData.skillAttr.value >= rollData.skill.data.level) { - nbDice++; - } - if ( nbDice == 0) nbDice = 1; - nbDice += rollData.specialtiesBonus; - - // Build dice formula - let diceTab = []; - for(let i=0; i bestScore) bestScore = score; - sortedRoll[dice1.results[0].result] = nbFound; - } - // Final score and keep data - rollData.nbDice = nbDice; - rollData.bestScore = bestScore; - rollData.diceResults = diceResults; - rollData.finalScore = bestScore + rollData.negativeModifier + rollData.positiveModifier; + rollData.finalScore = myRoll.total + dicePool[0].statmod; console.log("ROLLLL!!!!", rollData); let actor = game.actors.get(rollData.actorId); this.createChatWithRollMode( rollData.alias, { - content: await renderTemplate(`systems/fvtt-weapons-of-the-gods/templates/chat-generic-result.html`, rollData) + content: await renderTemplate(`systems/fvtt-pegasus-rpg/templates/chat-generic-result.html`, rollData) }); if ( rollData.defender ) { @@ -401,34 +364,6 @@ export class PegasusUtility { return Math.floor(result/5) + 1; } - /* -------------------------------------------- */ - static removeDice( rollData, diceIndex) { - - let diceResults = rollData.diceResults; - diceResults.splice( diceIndex, 1); - rollData.diceResults = diceResults; - - rollData.nbDice = diceResults.length; - - this.updateRoll(rollData); - } - - /* -------------------------------------------- */ - static addDice(rollId, diceValue) { - - let rollData = this.getRollData( rollId ); - - let diceResults = rollData.diceResults; - let newResult = duplicate(diceResults[0]); - newResult.result = diceValue; - diceResults.push( newResult); - rollData.diceResults = diceResults; - - rollData.nbDice = diceResults.length; - - this.updateRoll(rollData); - } - /* ------------------------- ------------------- */ static async updateRoll( rollData) { @@ -550,18 +485,6 @@ export class PegasusUtility { this.createChatMessage(name, game.settings.get("core", "rollMode"), chatOptions); } - /* -------------------------------------------- */ - static buildDifficultyOptions( ) { - let options = "" - options += `None` - options += `Easy` - options += `Moderate` - options += `Difficult` - options += `Very Difficult` - return options; - - } - /* -------------------------------------------- */ static async confirmDelete(actorSheet, li) { let itemId = li.data("item-id"); diff --git a/styles/simple.css b/styles/simple.css index a795ddb..b3fd01f 100644 --- a/styles/simple.css +++ b/styles/simple.css @@ -1153,7 +1153,7 @@ ul, li { color: #CCC } #pause > img { - content: url(../images/ui/wotg_logo_01.webp); + content: url(../images/ui/pegasus_logo_v1.webp); height: 160px; width: 256px; top: -80px; @@ -1161,7 +1161,7 @@ ul, li { } #logo { - content : url(../images/ui/wotg_logo_01.webp); + content : url(../images/ui/pegasus_logo_v1.webp); width: 110px; height: 70px; } diff --git a/template.json b/template.json index 8c0b90c..96bb399 100644 --- a/template.json +++ b/template.json @@ -142,10 +142,13 @@ }, "specialisation": { "statistic": "", - "level": 0, + "level": 1, "description": "" }, "perk": { + "level": 1, + "active": false, + "roundcount": 0, "description": "", "upgrades": "", "rules": "" diff --git a/templates/actor-sheet.html b/templates/actor-sheet.html index 8d42b92..f86d26c 100644 --- a/templates/actor-sheet.html +++ b/templates/actor-sheet.html @@ -36,10 +36,10 @@ {{#each data.statistics as |stat key|}} - {{stat.label}} + {{stat.label}} {{#select stat.value}} - {{> systems/fvtt-pegasus-rpg/templates/partial-options-level.html}} + {{{@root.optionsDiceList}}} {{/select}} @@ -55,7 +55,7 @@ {{stat2.label}} {{#select stat2.value}} - {{> systems/fvtt-pegasus-rpg/templates/partial-options-level.html}} + {{{@root.optionsLevel}}} {{/select}} @@ -77,7 +77,9 @@ {{#each specs as |spec key|}} - {{spec.name}} + {{spec.name}} + {{spec.data.statistic}} + {{spec.data.dice}} @@ -93,14 +95,6 @@ - - - Health - - / {{data.secondary.health.max}} - - - Weapons {{#each weapons as |weapon key|}} diff --git a/templates/chat-generic-result.html b/templates/chat-generic-result.html index 696dd35..f430cab 100644 --- a/templates/chat-generic-result.html +++ b/templates/chat-generic-result.html @@ -8,11 +8,11 @@ - {{#if (eq mode "skill")}} - Skill : {{skill.name}} + {{#if (eq mode "stat")}} + Statistic : {{stat.label}} {{else}} - {{#if (eq mode "technique")}} - Technique : {{technique.name}} + {{#if (eq mode "spec")}} + Technique : {{spec.name}} {{else}} {{#if (eq mode "weapon")}} Weapon attack : {{weapon.name}} @@ -23,33 +23,14 @@ - - {{#each diceResults as |diceResult key|}} - - {{#if (gt @root.nbDice 2)}} - - {{/if}} - {{diceResult.result}} - - {{#if (gt @root.nbDice 2)}} - - {{/if}} - - {{/each}} - {{#if (eq mode "technique")}} - {{technique.data.chicolor}} Chi cost : {{technique.data.chicost}} - Apply Chi cost - Effect description : {{technique.data.effectdescription}} - {{/if}} {{#if (eq mode "weapon")}} Effect description : {{weapon.data.effectdescription}} {{/if}} - Modifiers : {{negativeModifier}} / {{positiveModifier}} - Total Roll : {{finalScore}} + Final Result : {{finalScore}} {{#if linkedRollId}} Use this Roll as defense diff --git a/templates/item-specialisation-sheet.html b/templates/item-specialisation-sheet.html index b4e2aa3..10aebd6 100644 --- a/templates/item-specialisation-sheet.html +++ b/templates/item-specialisation-sheet.html @@ -21,7 +21,7 @@ Level {{#select data.level}} - {{> systems/fvtt-pegasus-rpg/templates/partial-options-level.html}} + {{{optionsDiceList}}} {{/select}} diff --git a/templates/partial-options-level.html b/templates/partial-options-level.html index 902313d..11fbe37 100644 --- a/templates/partial-options-level.html +++ b/templates/partial-options-level.html @@ -1,3 +1,4 @@ +0 d4 d6 d8 diff --git a/templates/roll-dialog-skill.html b/templates/roll-dialog-skill.html deleted file mode 100644 index fa7d796..0000000 --- a/templates/roll-dialog-skill.html +++ /dev/null @@ -1,46 +0,0 @@ - - - - {{title}} - - - - - {{skillAttr.label}} : {{skillAttr.value}} - Skill Level : {{skill.data.level}} - - - Specialties reminder : - {{skill.data.specialties}} - - - Specialties Dices Bonus : - - {{#select specialtiesBonus}} - 0 - 1 - 2 - {{/select}} - - - - Negative Modifier : - - {{#select negativeModifier}} - {{{optionsNegative}}} - {{/select}} - - - - Positive Modifier : - - {{#select positiveModifier}} - {{{optionsPositive}}} - {{/select}} - - - - - - -