From 742f96fcbe5f38c73fb8d95511d6e1caa905e7fb Mon Sep 17 00:00:00 2001 From: sladecraven Date: Fri, 3 Dec 2021 18:31:43 +0100 Subject: [PATCH] Initial import --- modules/pegasus-actor-sheet.js | 8 +++ modules/pegasus-actor.js | 94 ++++++++++++----------------- modules/pegasus-utility.js | 1 + system.json | 4 +- template.json | 20 +++--- templates/actor-sheet.html | 73 ++++++++++++++-------- templates/item-armor-sheet.html | 12 ++-- templates/item-equipment-sheet.html | 8 ++- templates/item-perk-sheet.html | 36 +++++++++-- templates/item-power-sheet.html | 17 ++++-- templates/item-race-sheet.html | 16 ++--- templates/item-role-sheet.html | 4 +- templates/item-shield-sheet.html | 8 ++- templates/item-weapon-sheet.html | 14 ++++- 14 files changed, 199 insertions(+), 116 deletions(-) diff --git a/modules/pegasus-actor-sheet.js b/modules/pegasus-actor-sheet.js index 54a6016..8320464 100644 --- a/modules/pegasus-actor-sheet.js +++ b/modules/pegasus-actor-sheet.js @@ -48,6 +48,7 @@ export class PegasusActorSheet extends ActorSheet { shields: duplicate(this.actor.getShields()), equipments: duplicate(this.actor.getEquipments()), perks: duplicate(this.actor.getPerks()), + activePerks: duplicate(this.actor.getActivePerks()), powers: duplicate(this.actor.getPowers()), subActors: duplicate(this.actor.getSubActors()), options: this.options, @@ -162,6 +163,13 @@ export class PegasusActorSheet extends ActorSheet { const li = $(ev.currentTarget).parents(".item"); this.actor.equipItem( li.data("item-id") ); this.render(true); + + }); + html.find('.perk-active').click(ev => { + const li = $(ev.currentTarget).parents(".item"); + this.actor.activatePerk( li.data("item-id") ); + this.render(true); + }); } diff --git a/modules/pegasus-actor.js b/modules/pegasus-actor.js index 81194c1..ae16c82 100644 --- a/modules/pegasus-actor.js +++ b/modules/pegasus-actor.js @@ -84,7 +84,11 @@ export class PegasusActor extends Actor { super._preUpdate(changed, options, user); } - + /* -------------------------------------------- */ + getActivePerks() { + let perks = this.data.items.filter( item => item.type == 'perk' && item.data.data.active); + return perks; + } /* -------------------------------------------- */ getPerks() { let comp = this.data.items.filter( item => item.type == 'perk'); @@ -139,6 +143,15 @@ export class PegasusActor extends Actor { return comp; } + /* -------------------------------------------- */ + async activatePerk(perkId ) { + let item = this.data.items.find( item => item.id == perkId ); + if (item && item.data.data) { + let update = { _id: item.id, "data.active": !item.data.data.active }; + await this.updateEmbeddedDocuments('Item', [update]); // Updates one EmbeddedEntity + } + } + /* -------------------------------------------- */ async equipItem(itemId ) { let item = this.data.items.find( item => item.id == itemId ); @@ -392,6 +405,7 @@ export class PegasusActor extends Actor { rollMode: game.settings.get("core", "rollMode"), title: `Stat ${stat.label} `, stat: stat, + activePerks: duplicate(this.getActivePerks()), optionsDiceList: PegasusUtility.getOptionsDiceList(), bonusDicesLevel: 0, hindranceDicesLevel: 0, @@ -420,10 +434,11 @@ export class PegasusActor extends Actor { actorId: this.id, img: spec.img, rollMode: game.settings.get("core", "rollMode"), - title: `Specialisation Roll : ${spec.name} `, - spec : spec , - optionsDiceList: PegasusUtility.getOptionsDiceList(), + title: `Spec. : ${spec.name} `, stat: this.getStat( spec.data.statistic ), + spec : spec , + activePerks: duplicate(this.getActivePerks()), + optionsDiceList: PegasusUtility.getOptionsDiceList(), bonusDicesLevel: 0, hindranceDicesLevel: 0, otherDicesLevel: 0, @@ -439,17 +454,6 @@ export class PegasusActor extends Actor { } } - /* -------------------------------------------- */ - applyTechniqueCost( techId) { - let tech = duplicate(this.data.items.find( item => item.id == techId)); - if (tech ) { - let attr = this.getAttributeFromChiName( tech.data.chicolor); - let chiscore = attr.chiscore - tech.data.chicost; - chiscore = (chiscore < 0) ? 0 : chiscore; - this.update( { [`data.attributes.${attr.key}.chiscore`]: chiscore } ); - } - } - /* -------------------------------------------- */ updateWithTarget( rollData) { let objectDefender @@ -469,48 +473,30 @@ export class PegasusActor extends Actor { } /* -------------------------------------------- */ - async rollTechnique( techId ) { - let technique = this.data.items.find( item => item.type == 'technique' && item.id == techId); - if (technique) { - let usedChi = this.getAttributeFromChiName( technique.data.data.chicolor); - if ( usedChi.chiscore < 0 || technique.data.data.chicost > usedChi.chiscore) { - ui.notifications.warn(`Not enough ${usedChi.chi} to use Technique ${technique.name}`); - return; - } - - let chi = undefined; - let skill = this.data.items.find( item => item.type == 'skill' && item.name == technique.data.data.skillchi); - if ( !skill) { - chi = this.getAttributeFromChiName( technique.data.data.skillchi); - } + async rollPower( powId ) { + let power = this.data.items.find( item => item.type == 'power' && item.id == powId); + if (power) { let rollData = { - mode: "technique", + mode: "power", alias: this.name, - armorModifier: this.getArmorModifier(), actorImg: this.img, actorId: this.id, - img: technique.img, + img: power.img, rollMode: game.settings.get("core", "rollMode"), - title: `Technique ${technique.name} `, - technique: duplicate(technique), - optionsNegative: WotGUtility.getNegativeModifiers(), - optionsPositive: WotGUtility.getPositiveModifiers(), - negativeModifier: 0, - positiveModifier: 0, - specialtiesBonus: 0 - } - if ( skill) { - rollData.skill = duplicate(skill); - rollData.attr = this.getAttribute( skill.data.data.attribute ); - } else { - rollData.attr = chi; + title: `Power ${power.name} `, + power: duplicate(power), + activePerks: duplicate(this.getActivePerks()), + optionsDiceList: PegasusUtility.getOptionsDiceList(), + bonusDicesLevel: 0, + hindranceDicesLevel: 0, + otherDicesLevel: 0, } this.updateWithTarget(rollData); this.syncRoll( rollData); - let rollDialog = await WotGRollDialog.create( this, rollData); + let rollDialog = await PegasusRollDialog.create( this, rollData); console.log(rollDialog); rollDialog.render( true ); } else { @@ -534,22 +520,20 @@ export class PegasusActor extends Actor { actorId: this.id, img: weapon.img, rollMode: game.settings.get("core", "rollMode"), - armorModifier: this.getArmorModifier(), title: "Attack : " + weapon.name, weapon: weapon, - skillKey : 0, - optionsNegative: WotGUtility.getNegativeModifiers(), - optionsPositive: WotGUtility.getPositiveModifiers(), - negativeModifier: 0, - positiveModifier: 0, - specialtiesBonus: 0, - } + activePerks: duplicate(this.getActivePerks()), + optionsDiceList: PegasusUtility.getOptionsDiceList(), + bonusDicesLevel: 0, + hindranceDicesLevel: 0, + otherDicesLevel: 0, + } this.updateWithTarget(rollData); this.syncRoll( rollData); - let rollDialog = await WotGRollDialog.create( this, rollData); + let rollDialog = await PegasusRollDialog.create( this, rollData); console.log("WEAPON ROLL", rollData); rollDialog.render( true ); } else { diff --git a/modules/pegasus-utility.js b/modules/pegasus-utility.js index 6e53f1d..8f6d2d6 100644 --- a/modules/pegasus-utility.js +++ b/modules/pegasus-utility.js @@ -122,6 +122,7 @@ export class PegasusUtility { const templatePaths = [ 'systems/fvtt-pegasus-rpg/templates/editor-notes-gm.html', + 'systems/fvtt-pegasus-rpg/templates/partial-roll-common-dices.html', 'systems/fvtt-pegasus-rpg/templates/partial-options-statistics.html', 'systems/fvtt-pegasus-rpg/templates/partial-options-level.html', 'systems/fvtt-pegasus-rpg/templates/partial-options-equipment-types.html' diff --git a/system.json b/system.json index 6ba0911..bfbdb27 100644 --- a/system.json +++ b/system.json @@ -40,9 +40,9 @@ "styles": [ "styles/simple.css" ], - "templateVersion": 4, + "templateVersion": 6, "title": "Pegasus RPG", "url": "https://www.uberwald.me/data/files/fvtt-pegasus-rpg", - "version": "0.0.4'", + "version": "0.0.6", "background" : "" } \ No newline at end of file diff --git a/template.json b/template.json index 96bb399..c688850 100644 --- a/template.json +++ b/template.json @@ -40,7 +40,7 @@ "mod": 0 }, "soc":{ - "label": "Sociability", + "label": "Social", "abbrev": "soc", "level": 1, "mod": 0 @@ -52,19 +52,19 @@ "mod": 0 }, "phy":{ - "label": "Physical", + "label": "Physique", "abbrev": "phy", "level": 1, "mod": 0 }, "com":{ - "label": "Communication", + "label": "Combat", "abbrev": "com", "level": 1, "mod": 0 }, "def":{ - "label": "Defense", + "label": "Defence", "abbrev": "def", "level": 1, "mod": 0 @@ -92,20 +92,24 @@ "health": { "label": "Health", "value": 0, + "type": "value", "max": 0 }, "delirium": { "label": "Delirium", "value": 0, + "type": "value", "max": 0 }, "nrg": { - "label": "NRJ", + "label": "NRG", "value": 0, + "type": "value", "max": 0 }, "mr": { "label": "MR", + "type": "dice", "value": 0 } } @@ -123,7 +127,7 @@ } }, "Item": { - "types": [ "race", "role", "ability", "specialisation", "perk", "power" , "armor", "equipment", "weapon"], + "types": [ "race", "role", "ability", "specialisation", "perk", "power" , "armor", "shield", "equipment", "weapon"], "race": { "description": "", "environment": "", @@ -149,6 +153,7 @@ "level": 1, "active": false, "roundcount": 0, + "nbuse": "", "description": "", "upgrades": "", "rules": "" @@ -161,7 +166,8 @@ "range": "", "action": "", "type": "", - "effects": "" + "effects": "", + "purchasedeffects": "" }, "armor": { "statistic": "", diff --git a/templates/actor-sheet.html b/templates/actor-sheet.html index f86d26c..c430ba2 100644 --- a/templates/actor-sheet.html +++ b/templates/actor-sheet.html @@ -15,7 +15,7 @@ Statistics Specialisations Powers - Fight + Combat Equipment Biography @@ -42,7 +42,7 @@ {{{@root.optionsDiceList}}} {{/select}} - + {{/each}} @@ -55,8 +55,12 @@

{{stat2.label}}

{{/each}} @@ -70,29 +74,50 @@ {{!-- Other Tab --}}
- -
-

Specialisations

-
    - {{#each specs as |spec key|}} -
  • - - {{spec.name}} - {{spec.data.statistic}} - {{spec.data.dice}} -
    - - -
    -
  • - {{/each}} -
+ +
+ +
+

Specialisations

+
    + {{#each specs as |spec key|}} +
  • + + {{spec.name}} + {{spec.data.statistic}} + {{spec.data.dice}} +
    + + +
    +
  • + {{/each}} +
+
+ +
+

Perks

+ +
- +
{{!-- Combat Tab --}} -
+

Weapons

@@ -105,7 +130,7 @@ Speed {{weapon.data.speed}} Damage {{weapon.data.damage}} diff --git a/templates/item-armor-sheet.html b/templates/item-armor-sheet.html index 02b50f0..fee2317 100644 --- a/templates/item-armor-sheet.html +++ b/templates/item-armor-sheet.html @@ -18,7 +18,7 @@ {{/select}} -
  • +
  • @@ -32,9 +32,13 @@
  • - -
  • -
  • + +
  • +
  • {{editor content=data.description target="data.description" button=true owner=owner editable=editable}}
    diff --git a/templates/item-equipment-sheet.html b/templates/item-equipment-sheet.html index daee4ac..97c1e1d 100644 --- a/templates/item-equipment-sheet.html +++ b/templates/item-equipment-sheet.html @@ -28,9 +28,13 @@
  • - +
  • -
  • +
  • {{editor content=data.description target="data.description" button=true owner=owner editable=editable}}
    diff --git a/templates/item-perk-sheet.html b/templates/item-perk-sheet.html index 865cc0e..1f768bc 100644 --- a/templates/item-perk-sheet.html +++ b/templates/item-perk-sheet.html @@ -10,18 +10,46 @@
    +
      +
    • + +
    • +
    • + +
    • +
    • + +
    • +
    • + +
    • +
    {{editor content=data.description target="data.description" button=true owner=owner editable=editable}}
    - -
    - {{editor content=data.upgrades target="data.upgrades" button=true owner=owner editable=editable}} -
    {{editor content=data.rules target="data.rules" button=true owner=owner editable=editable}}
    + +
    + {{editor content=data.upgrades target="data.upgrades" button=true owner=owner editable=editable}} +
    diff --git a/templates/item-power-sheet.html b/templates/item-power-sheet.html index 8cfe21d..df3b34d 100644 --- a/templates/item-power-sheet.html +++ b/templates/item-power-sheet.html @@ -14,6 +14,7 @@
  • + {{#if data.rollneeded}}
  • -
  • + {{/if}} +
  • -
  • +
  • @@ -54,12 +58,17 @@ {{/select}} -
  • +
  • {{editor content=data.effects target="data.effects" button=true owner=owner editable=editable}}
  • - < +
  • +
    + {{editor content=data.purchasedeffects target="data.purchasedeffects" button=true owner=owner editable=editable}} +
    +
  • +
    diff --git a/templates/item-race-sheet.html b/templates/item-race-sheet.html index 9c98723..416d59e 100644 --- a/templates/item-race-sheet.html +++ b/templates/item-race-sheet.html @@ -10,6 +10,14 @@
    + +
    + {{editor content=data.statistics target="data.statistics" button=true owner=owner editable=editable}} +
    + +
    + {{editor content=data.abilities target="data.abilities" button=true owner=owner editable=editable}} +
    {{editor content=data.description target="data.description" button=true owner=owner editable=editable}} @@ -26,14 +34,6 @@
    {{editor content=data.outlook target="data.outlook" button=true owner=owner editable=editable}}
    - -
    - {{editor content=data.abilities target="data.abilities" button=true owner=owner editable=editable}} -
    - -
    - {{editor content=data.statistics target="data.statistics" button=true owner=owner editable=editable}} -
    diff --git a/templates/item-role-sheet.html b/templates/item-role-sheet.html index e748533..167ceb6 100644 --- a/templates/item-role-sheet.html +++ b/templates/item-role-sheet.html @@ -2,7 +2,9 @@
    -

    +

    + +

    diff --git a/templates/item-shield-sheet.html b/templates/item-shield-sheet.html index ba58211..d6cdb71 100644 --- a/templates/item-shield-sheet.html +++ b/templates/item-shield-sheet.html @@ -34,9 +34,13 @@
  • - +
  • -
  • +
  • {{editor content=data.description target="data.description" button=true owner=owner editable=editable}}
    diff --git a/templates/item-weapon-sheet.html b/templates/item-weapon-sheet.html index 20ad3f8..0820d8b 100644 --- a/templates/item-weapon-sheet.html +++ b/templates/item-weapon-sheet.html @@ -19,7 +19,11 @@
  • - +
  • @@ -32,9 +36,13 @@
  • - +
  • -
  • +
  • {{editor content=data.description target="data.description" button=true owner=owner editable=editable}}