diff --git a/modules/pegasus-actor-sheet.js b/modules/pegasus-actor-sheet.js index 9943e56..42da1a0 100644 --- a/modules/pegasus-actor-sheet.js +++ b/modules/pegasus-actor-sheet.js @@ -54,6 +54,7 @@ export class PegasusActorSheet extends ActorSheet { subActors: duplicate(this.actor.getSubActors()), race: duplicate(this.actor.getRace()), role: duplicate(this.actor.getRole()), + effects: duplicate(this.actor.getEffects()), options: this.options, owner: this.document.isOwner, editScore: this.options.editScore, @@ -86,6 +87,12 @@ export class PegasusActorSheet extends ActorSheet { PegasusUtility.confirmDelete(this, li); }); + html.find('.park-round-count').change(ev => { + const li = $(ev.currentTarget).parents(".item"); + let itemId = li.data("item-id"); + this.actor.updatePerkRounds( itemId, Number(event.currentTarget.value)) + }); + html.find('.subactor-edit').click(ev => { const li = $(ev.currentTarget).parents(".item"); let actorId = li.data("actor-id"); diff --git a/modules/pegasus-actor.js b/modules/pegasus-actor.js index a0f40f0..f8e6e06 100644 --- a/modules/pegasus-actor.js +++ b/modules/pegasus-actor.js @@ -100,6 +100,11 @@ export class PegasusActor extends Actor { return comp; } /* -------------------------------------------- */ + getEffects() { + let comp = this.data.items.filter( item => item.type == 'effect'); + return comp; + } + /* -------------------------------------------- */ getPowers() { let comp = this.data.items.filter( item => item.type == 'power'); return comp; @@ -409,7 +414,12 @@ export class PegasusActor extends Actor { /* -------------------------------------------- */ getStat( statKey) { - let stat = duplicate(this.data.data.statistics[statKey]); + let stat + if (statKey == 'mr') { + stat = duplicate(this.data.data.mr); + } else { + stat = duplicate(this.data.data.statistics[statKey]); + } stat.dice = PegasusUtility.getDiceFromLevel(stat.value); return stat; } @@ -424,6 +434,14 @@ export class PegasusActor extends Actor { return spec; } + /* -------------------------------------------- */ + updatePerkRounds( itemId, roundValue) { + let item = this.items.get( itemId) + if (item) { + this.updateEmbeddedDocuments( 'Item', [ { _id: item.id, 'data.roundcount': roundValue }] ); + } + } + /* -------------------------------------------- */ async rollMR() { let mr = duplicate( this.data.data.mr) ; diff --git a/modules/pegasus-create-char.js b/modules/pegasus-create-char.js index aeb71a3..d723bf8 100644 --- a/modules/pegasus-create-char.js +++ b/modules/pegasus-create-char.js @@ -16,6 +16,8 @@ export class PegasusActorCreate { this.races = racesPack.map(i => i.toObject()); const rolesPack = await PegasusUtility.loadCompendium("fvtt-pegasus-rpg.role"); this.roles = rolesPack.map(i => i.toObject()); + const perksPack = await PegasusUtility.loadCompendium("fvtt-pegasus-rpg.perk"); + this.perks = perksPack.map(i => i.toObject()); this.showRaces() } @@ -55,7 +57,7 @@ export class PegasusActorCreate { if ( race.data.selectablestats ) { this.manageSelectableStats(race); } else if ( race.data.perksgained) { - this.showRacePerks(race); + this.manageRacePerks(race); } else { this.showRoles() } @@ -83,24 +85,19 @@ export class PegasusActorCreate { this.processSelectableStats(); } - if (step == 'select-race-perks-all') { + if (step == 'select-race-perks') { PegasusUtility.removeChatMessageId(PegasusUtility.findChatMessageId(event.currentTarget)); let perk = this.racePerks.find( item => item._id == itemId); this.actor.createEmbeddedDocuments( 'Item', [perk]); this.racePerks = this.racePerks.filter( item => item._id != itemId); - this.nbperks -= 1; - if ( this.nbperks == 0 || this.racePerks.length == 0) { + this.nbRacePerks -= 1; + if ( this.nbRacePerks == 0 || this.racePerks.length == 0) { this.showRoles() - }else { - this.showRacePerks(); + } else { + this.manageRacePerks() } } - if (step == 'select-race-perks') { - PegasusUtility.removeChatMessageId(PegasusUtility.findChatMessageId(event.currentTarget)); - this.showRoles() - } - if ( step == 'select-role') { let role = this.roles.find( item => item._id == itemId); PegasusUtility.removeChatMessageId(PegasusUtility.findChatMessageId(event.currentTarget)); @@ -205,18 +202,23 @@ export class PegasusActorCreate { /* --------------- -------------------- --------- */ manageRacePerks(race) { + console.log("MANAG RACE PERKsS", this.currentRace) + if ( !this.currentRace.data.perksgained ) { + this.showRoles() + return; + } + console.log("MANAG RACE PERKsS 2", this.currentRace) if ( !this.racePerks) { // First init - this.racePerks = duplicate(race.data.perks) - this.nbRacePerks = race.data.perksnumber; - } - let formData - if (race.data.perksall) { - formData = this.createFormData("select-race-perks-all") - } else { - formData = this.createFormData("select-race-perks") - formData.raceperks = this.racePerks; - formData.nbraceperks = this.nbRacePerks; + if ( this.currentRace.data.perksall) { + this.racePerks = duplicate(this.perks) + } else { + this.racePerks = duplicate(this.currentRace.data.perks) + } + this.nbRacePerks = this.currentRace.data.perksnumber; } + let formData = this.createFormData("select-race-perks") + formData.raceperks = this.racePerks; + formData.nbraceperks = this.nbRacePerks; this.renderChatMessage(formData) } @@ -224,7 +226,7 @@ export class PegasusActorCreate { async processSelectableStats() { // End of race options choice if ( this.raceSelectableStats.numberstats == 0) { - this.showRoles() + this.manageRacePerks(); return; } let formData = this.createFormData("select-race-stats") diff --git a/modules/pegasus-item-sheet.js b/modules/pegasus-item-sheet.js index 0356272..57c3dc4 100644 --- a/modules/pegasus-item-sheet.js +++ b/modules/pegasus-item-sheet.js @@ -65,6 +65,7 @@ export class PegasusItemSheet extends ItemSheet { limited: this.object.limited, options: this.options, owner: this.document.isOwner, + mr: (this.object.type == 'specialisation'), isGM: game.user.isGM } @@ -338,10 +339,31 @@ export class PegasusItemSheet extends ItemSheet { } } } + + /* -------------------------------------------- */ + async addEffectSpec( event, item, dataItem) { + let newItem = duplicate(item.data); + if ( event.toElement.className == 'drop-effect-spec') { + let specArray = duplicate(this.object.data.data.recoveryrollspec); + specArray.push( newItem ); + await this.object.update( { 'data.recoveryrollspec': specArray} ); + } + } /* -------------------------------------------- */ async _onDrop(event) { //console.log(event); + if (this.object.type == 'effect' ) { + let data = event.dataTransfer.getData('text/plain'); + if (data) { + let dataItem = JSON.parse( data ); + let item = await this.searchItem( dataItem); + if ( item.data.type == 'specialisation') { + return this.addEffectSpec( event, item, dataItem); + } + } + } + if (this.object.type == 'race' ) { let data = event.dataTransfer.getData('text/plain'); if (data) { diff --git a/modules/pegasus-utility.js b/modules/pegasus-utility.js index 77398ef..10d4602 100644 --- a/modules/pegasus-utility.js +++ b/modules/pegasus-utility.js @@ -20,6 +20,11 @@ export class PegasusUtility { this.optionsDiceList = ""; this.buildDiceLists(); PegasusCommands.init(); + + Handlebars.registerHelper('upper', function (text) { + return text.toUpperCase(); + }); + } /* -------------------------------------------- */ diff --git a/styles/simple.css b/styles/simple.css index 0f14140..5388ba8 100644 --- a/styles/simple.css +++ b/styles/simple.css @@ -1160,6 +1160,7 @@ ul, li { .ul-level1 { padding-left: 2rem; } +.drop-effect-spec, .drop-ability-weapon, .drop-ability-armor, .drop-race-perk, diff --git a/system.json b/system.json index 2071e27..b61a752 100644 --- a/system.json +++ b/system.json @@ -100,9 +100,9 @@ "styles": [ "styles/simple.css" ], - "templateVersion": 46, + "templateVersion": 49, "title": "Pegasus RPG", "url": "https://www.uberwald.me/data/files/fvtt-pegasus-rpg", - "version": "0.0.46", + "version": "0.0.49", "background" : "./images/ui/pegasus_welcome_page.webp" } \ No newline at end of file diff --git a/template.json b/template.json index f8ed310..0ee0ff2 100644 --- a/template.json +++ b/template.json @@ -174,7 +174,21 @@ } }, "Item": { - "types": [ "race", "role", "ability", "specialisation", "perk", "power" , "armor", "shield", "equipment", "weapon"], + "types": [ "race", "role", "ability", "specialisation", "perk", "power" , "armor", "shield", "equipment", "weapon", "effect"], + "effect": { + "type": "", + "genre": "", + "effectlevel": 0, + "stataffected": "", + "statdice": false, + "bonusdice": false, + "otherdice": false, + "hindrance" : false, + "resistedby": "", + "recoveryroll": false, + "recoveryrollspec": [], + "description": "" + }, "race": { "description": "", "environment": "", diff --git a/templates/actor-sheet.html b/templates/actor-sheet.html index 9bd9914..18a0978 100644 --- a/templates/actor-sheet.html +++ b/templates/actor-sheet.html @@ -120,7 +120,7 @@
  • {{spec.name}} - {{spec.data.statistic}} + {{upper spec.data.statistic}} {{spec.data.dice}}
    @@ -140,7 +140,17 @@
  • {{perk.name}} - {{perk.data.level}} + Lvl:{{perk.data.level}} + Rounds: + +
    {{#if perk.data.active}}{{else}}{{/if}} @@ -184,24 +194,17 @@ @@ -219,6 +222,24 @@
  • + +

    Effects

    +
    + +

    Weapons

    diff --git a/templates/chat-create-actor.html b/templates/chat-create-actor.html index a99823d..17d0800 100644 --- a/templates/chat-create-actor.html +++ b/templates/chat-create-actor.html @@ -57,13 +57,13 @@ {{/if}} {{#if (eq step "select-race-perks-all")}} -
    Select {{nbperks}} from the Perks Comepndium. Once done, click the button below
    +
    Select {{nbperks}} from the Perks Compendium. Once done, click the button below
    Race Perks selected!
    {{/if}} {{#if (eq step "select-race-perks")}} -
    Now select {{nbperks}} for your character +
    Now select {{nbraceperks}} Perk(s) for your character
    {{#each raceperks as |perk index|}} diff --git a/templates/partial-options-statistics.html b/templates/partial-options-statistics.html index eac07c5..910b0d1 100644 --- a/templates/partial-options-statistics.html +++ b/templates/partial-options-statistics.html @@ -1,6 +1,9 @@ {{#if notapplicable}} {{/if}} +{{#if all}} + +{{/if}}