Step 4 - Manage perks
This commit is contained in:
parent
0a5e52ec4e
commit
d17afaf142
@ -105,10 +105,15 @@ export class PegasusActorSheet extends ActorSheet {
|
||||
PegasusUtility.confirmDelete(this, li);
|
||||
});
|
||||
|
||||
html.find('.park-round-count').change(ev => {
|
||||
html.find('.effect-used').click(ev => {
|
||||
const li = $(ev.currentTarget).parents(".item");
|
||||
let itemId = li.data("item-id");
|
||||
this.actor.updatePerkRounds( itemId, Number(event.currentTarget.value))
|
||||
this.actor.perkEffectUsed( itemId)
|
||||
});
|
||||
html.find('.perk-status').change(ev => {
|
||||
const li = $(ev.currentTarget).parents(".item");
|
||||
let itemId = li.data("item-id");
|
||||
this.actor.updatePerkStatus( itemId, ev.currentTarget.value)
|
||||
});
|
||||
|
||||
html.find('.subactor-edit').click(ev => {
|
||||
|
@ -343,10 +343,98 @@ export class PegasusActor extends Actor {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
updatePerkRounds(itemId, roundValue) {
|
||||
async perkEffectUsed( itemId) {
|
||||
let effect = this.items.get(itemId)
|
||||
if (effect) {
|
||||
PegasusUtility.createChatWithRollMode(effect.name, {
|
||||
content: await renderTemplate(`systems/fvtt-pegasus-rpg/templates/chat-effect-used.html`, effect.data)
|
||||
});
|
||||
|
||||
this.deleteEmbeddedDocuments('Item', [ effect.id] )
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async updatePerkStatus(itemId, status) {
|
||||
let item = this.items.get(itemId)
|
||||
if (item) {
|
||||
this.updateEmbeddedDocuments('Item', [{ _id: item.id, 'data.roundcount': roundValue }]);
|
||||
|
||||
if (item.data.data.status == status) return;// Ensure we are really changing the status
|
||||
|
||||
let updateOK = true
|
||||
if ( status == "ready") {
|
||||
let effects = []
|
||||
for( let item of this.data.items) {
|
||||
if ( item.type == "effect" && item.data.data.perkId == itemId) {
|
||||
effects.push( item.id)
|
||||
}
|
||||
}
|
||||
if ( effects.length) {
|
||||
await this.deleteEmbeddedDocuments('Item', effects )
|
||||
}
|
||||
if ( item.data.data.features.nrgcost.flag ) {
|
||||
let nrg = duplicate(this.data.data.nrg)
|
||||
nrg.activated -= item.data.data.features.nrgcost.value
|
||||
this.update( {'data.nrg': nrg } )
|
||||
}
|
||||
if (item.data.data.features.bonushealth.flag) {
|
||||
let health = duplicate(this.data.data.secondary.health)
|
||||
health.bonus -= item.data.data.features.bonushealth.value
|
||||
this.update( {'data.secondary.health': health } )
|
||||
}
|
||||
if (item.data.data.features.bonusdelirium.flag) {
|
||||
let delirium = duplicate(this.data.data.delirium.delirium)
|
||||
delirium.bonus -= item.data.data.features.bonusdelirium.value
|
||||
this.update( {'data.secondary.delirium': delirium } )
|
||||
}
|
||||
if (item.data.data.features.bonusnrg.flag) {
|
||||
let nrg = duplicate(this.data.data.nrg)
|
||||
nrg.mod -= item.data.data.features.bonusnrg.value
|
||||
this.update( {'data.nrg': nrg } )
|
||||
}
|
||||
}
|
||||
if ( status == "activated") {
|
||||
// Add effects linked to the perk
|
||||
let effects = []
|
||||
for( let effect of item.data.data.effectsgained) {
|
||||
effect.data.perkId = itemId // Link to the perk, in order to dynamically remove them
|
||||
effect.data.isUsed = false // Flag to indicate removal when used in a roll window
|
||||
effects.push( effect )
|
||||
}
|
||||
if ( effects.length) {
|
||||
await this.createEmbeddedDocuments('Item', effects )
|
||||
}
|
||||
// Manage additional flags
|
||||
if ( item.data.data.features.nrgcost.flag ) {
|
||||
if (this.data.data.nrg.value >= item.data.data.features.nrgcost.value) {
|
||||
let nrg = duplicate(this.data.data.nrg)
|
||||
nrg.activated += item.data.data.features.nrgcost.value
|
||||
nrg.value -= item.data.data.features.nrgcost.value
|
||||
this.update( {'data.nrg': nrg } )
|
||||
} else {
|
||||
updateOK = false
|
||||
ui.notifications.warn("Not enough NRG to activate the Perk " + item.name)
|
||||
}
|
||||
}
|
||||
if (item.data.data.features.bonushealth.flag) {
|
||||
let health = duplicate(this.data.data.secondary.health)
|
||||
health.bonus += item.data.data.features.bonushealth.value
|
||||
this.update( {'data.secondary.health': health } )
|
||||
}
|
||||
if (item.data.data.features.bonusdelirium.flag) {
|
||||
let delirium = duplicate(this.data.data.delirium.delirium)
|
||||
delirium.bonus += item.data.data.features.bonusdelirium.value
|
||||
this.update( {'data.secondary.delirium': delirium } )
|
||||
}
|
||||
if (item.data.data.features.bonusnrg.flag) {
|
||||
let nrg = duplicate(this.data.data.nrg)
|
||||
nrg.mod += item.data.data.features.bonusnrg.value
|
||||
this.update( {'data.nrg': nrg } )
|
||||
}
|
||||
}
|
||||
if (updateOK) {
|
||||
this.updateEmbeddedDocuments('Item', [{ _id: item.id, 'data.status': status }])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -88,7 +88,6 @@ export class PegasusItemSheet extends ItemSheet {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
postItem() {
|
||||
console.log(this.item);
|
||||
let chatData = duplicate(PegasusUtility.data(this.item));
|
||||
if (this.actor) {
|
||||
chatData.actor = { id: this.actor.id };
|
||||
@ -105,7 +104,7 @@ export class PegasusItemSheet extends ItemSheet {
|
||||
});
|
||||
|
||||
renderTemplate('systems/fvtt-pegasus-rpg/templates/post-item.html', chatData).then(html => {
|
||||
let chatOptions = WotGUtility.chatDataSetup(html);
|
||||
let chatOptions = PegasusUtility.chatDataSetup(html);
|
||||
ChatMessage.create(chatOptions)
|
||||
});
|
||||
}
|
||||
@ -325,7 +324,6 @@ export class PegasusItemSheet extends ItemSheet {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async addPerkSpecialisation( event, item, dataItem) {
|
||||
let newItem = duplicate(item.data);
|
||||
@ -340,6 +338,16 @@ export class PegasusItemSheet extends ItemSheet {
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async addPerkEffect( event, item, dataItem) {
|
||||
let newItem = duplicate(item.data)
|
||||
if ( event.toElement.className == 'drop-perk-effect') {
|
||||
let effectArray = duplicate(this.object.data.data.effectsgained)
|
||||
effectArray.push( newItem )
|
||||
await this.object.update( { 'data.effectsgained': effectArray} )
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async addEffectSpec( event, item, dataItem) {
|
||||
let newItem = duplicate(item.data);
|
||||
@ -384,12 +392,15 @@ export class PegasusItemSheet extends ItemSheet {
|
||||
}
|
||||
|
||||
if (this.object.type == 'perk' ) {
|
||||
let data = event.dataTransfer.getData('text/plain');
|
||||
let data = event.dataTransfer.getData('text/plain')
|
||||
if (data) {
|
||||
let dataItem = JSON.parse( data );
|
||||
let item = await PegasusUtility.searchItem( dataItem);
|
||||
let item = await PegasusUtility.searchItem( dataItem)
|
||||
if ( item.data.type == 'specialisation') {
|
||||
return this.addPerkSpecialisation( event, item, dataItem);
|
||||
return this.addPerkSpecialisation( event, item, dataItem)
|
||||
}
|
||||
if ( item.data.type == 'effect') {
|
||||
return this.addPerkEffect( event, item, dataItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -57,6 +57,7 @@ export class PegasusRollDialog extends Dialog {
|
||||
let effectData = effect.effect
|
||||
level = effectData.data.effectlevel
|
||||
genre = effectData.data.genre
|
||||
effectData.data.isUsed = toggled
|
||||
if (effectData.data.bonusdice) {
|
||||
idVal = "#bonusDicesLevel"
|
||||
}
|
||||
|
@ -403,12 +403,24 @@ export class PegasusUtility {
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static removeUsedPerkEffects( rollData) {
|
||||
// De-actived used effects from perks
|
||||
let toRem = []
|
||||
for(let effect of rollData.effectsList) {
|
||||
if (effect.effect.data.perkId && effect.effect.data.isUsed) {
|
||||
toRem.push( effect.effect._id)
|
||||
}
|
||||
}
|
||||
if (toRem.length > 0) {
|
||||
let actor = game.actors.get(rollData.actorId)
|
||||
actor.deleteEmbeddedDocuments('Item', toRem)
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async rollPegasus(rollData) {
|
||||
|
||||
let actor = game.actors.get(rollData.actorId);
|
||||
|
||||
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);
|
||||
@ -476,6 +488,9 @@ export class PegasusUtility {
|
||||
let combat = game.combats.get(rollData.combatId)
|
||||
combat.updateEmbeddedDocuments("Combatant", [{ _id: rollData.combatantId, initiative: rollData.finalScore }]);
|
||||
}
|
||||
|
||||
//this.removeUsedPerkEffects( rollData) // Unused for now
|
||||
|
||||
// And save the roll
|
||||
this.saveRollData(rollData);
|
||||
}
|
||||
|
@ -1163,6 +1163,7 @@ ul, li {
|
||||
.ul-level1 {
|
||||
padding-left: 2rem;
|
||||
}
|
||||
.drop-perk-effect,
|
||||
.drop-ability-effect,
|
||||
.drop-effect-specaffected,
|
||||
.drop-effect-spec,
|
||||
|
@ -180,9 +180,9 @@
|
||||
"styles": [
|
||||
"styles/simple.css"
|
||||
],
|
||||
"templateVersion": 66,
|
||||
"templateVersion": 69,
|
||||
"title": "Pegasus RPG",
|
||||
"url": "https://www.uberwald.me/data/files/fvtt-pegasus-rpg",
|
||||
"version": "0.4.0",
|
||||
"version": "0.4.2",
|
||||
"background" : "./images/ui/pegasus_welcome_page.webp"
|
||||
}
|
||||
|
@ -258,6 +258,7 @@
|
||||
"level": 1,
|
||||
"active": false,
|
||||
"duration": "",
|
||||
"effectsgained": [],
|
||||
"features": {
|
||||
"nrgcost": {
|
||||
"label": "NRG cost to use",
|
||||
@ -277,60 +278,6 @@
|
||||
"type": "string",
|
||||
"value": ""
|
||||
},
|
||||
"gainstatdice": {
|
||||
"label": "Gain Stat Dice Level to Pool",
|
||||
"flag": false,
|
||||
"type": "string",
|
||||
"value": ""
|
||||
},
|
||||
"gainspecdice": {
|
||||
"label": "Gain Specialisation Dice Level",
|
||||
"flag": false,
|
||||
"type": "dropspec",
|
||||
"value": ""
|
||||
},
|
||||
"gainbonusdice": {
|
||||
"label": "Gain Bonus Dice Level to Pool",
|
||||
"flag": false,
|
||||
"type": "string",
|
||||
"value": ""
|
||||
},
|
||||
"gainotherdice": {
|
||||
"label": "Gain Other Dice Level",
|
||||
"flag": false,
|
||||
"type": "string",
|
||||
"value": ""
|
||||
},
|
||||
"targethindrance": {
|
||||
"label": "Apply Hindrance Level to Target",
|
||||
"flag": false,
|
||||
"type": "string",
|
||||
"value": ""
|
||||
},
|
||||
"sufferindrance": {
|
||||
"label": "Perk User suffers Hindrance",
|
||||
"flag": false,
|
||||
"type": "string",
|
||||
"value": ""
|
||||
},
|
||||
"affectedstat": {
|
||||
"label": "Affected Stat",
|
||||
"flag": false,
|
||||
"type": "string",
|
||||
"value": ""
|
||||
},
|
||||
"affectedspec": {
|
||||
"label": "Affected Specialisation",
|
||||
"flag": false,
|
||||
"type": "dropspec",
|
||||
"value": ""
|
||||
},
|
||||
"affectspecial": {
|
||||
"label": "Affects Special",
|
||||
"flag": false,
|
||||
"type": "string",
|
||||
"value": ""
|
||||
},
|
||||
"bonushealth": {
|
||||
"label": "Bonus to Health",
|
||||
"flag": false,
|
||||
@ -348,45 +295,9 @@
|
||||
"flag": false,
|
||||
"type": "string",
|
||||
"value": ""
|
||||
},
|
||||
"gainmomentum": {
|
||||
"label": "Gain Momentum",
|
||||
"flag": false,
|
||||
"type": "string",
|
||||
"value": ""
|
||||
},
|
||||
"applyeffect": {
|
||||
"label": "Apply Effect",
|
||||
"flag": false,
|
||||
"type": "string",
|
||||
"value": ""
|
||||
},
|
||||
"removeeffect": {
|
||||
"label": "Remove Effect",
|
||||
"flag": false,
|
||||
"type": "string",
|
||||
"value": ""
|
||||
},
|
||||
"specialrule": {
|
||||
"label": "Special Rule",
|
||||
"flag": false,
|
||||
"type": "text",
|
||||
"value": ""
|
||||
},
|
||||
"upgrade1": {
|
||||
"label": "Upgrade 1",
|
||||
"flag": false,
|
||||
"type": "string",
|
||||
"value": ""
|
||||
},
|
||||
"upgrade2": {
|
||||
"label": "Upgrade 2",
|
||||
"flag": false,
|
||||
"type": "string",
|
||||
"value": ""
|
||||
}
|
||||
},
|
||||
"roundcount": 0,
|
||||
"status": "",
|
||||
"nbuse": ""
|
||||
},
|
||||
"power": {
|
||||
|
@ -222,6 +222,11 @@
|
||||
<span class="generic-label">{{upperFirst effect.data.genre}}</span>
|
||||
<span class="generic-label">Lvl:{{effect.data.effectlevel}}</span>
|
||||
<span class="generic-label">{{upper effect.data.stataffected}}</span>
|
||||
{{#if effect.data.perkId}}
|
||||
<span class="generic-label"><a class="effect-used">Used?</a></span>
|
||||
{{else}}
|
||||
<span class="generic-label"> </span>
|
||||
{{/if}}
|
||||
<div class="item-controls">
|
||||
<a class="item-control item-edit" title="Edit Item"><i class="fas fa-edit"></i></a>
|
||||
<a class="item-control item-delete" title="Delete Item"><i class="fas fa-trash"></i></a>
|
||||
@ -240,19 +245,17 @@
|
||||
<img class="sheet-competence-img" src="{{perk.img}}" />
|
||||
<span class="stat-label">{{perk.name}}</span>
|
||||
<span class="stat-label">Lvl:{{perk.data.level}}</span>
|
||||
<span class="stat-label">Rounds:
|
||||
<select class="competence-base flexrow park-round-count" type="text" value="{{perk.data.roundcount}}" data-dtype="Number">
|
||||
{{#select perk.data.roundcount}}
|
||||
<option value="3">Ready</option>
|
||||
<option value="2">Activated</option>
|
||||
<option value="1">2 Rounds left</option>
|
||||
<option value="0">1 Round left</option>
|
||||
<span class="stat-label">Perk Status:
|
||||
<select class="competence-base flexrow perk-status" type="text" value="{{perk.data.status}}" data-dtype="String">
|
||||
{{#select perk.data.status}}
|
||||
<option value="ready">Ready</option>
|
||||
<option value="activated">Activated</option>
|
||||
<option value="round2">2 Rounds left</option>
|
||||
<option value="round1">1 Round left</option>
|
||||
{{/select}}
|
||||
</select>
|
||||
</span>
|
||||
<div class="item-controls">
|
||||
<a class="item-control perk-active" title="active">{{#if perk.data.active}}<i
|
||||
class="fas fa-circle"></i>{{else}}<i class="fas fa-genderless"></i>{{/if}}</a>
|
||||
<a class="item-control item-edit" title="Edit Item"><i class="fas fa-edit"></i></a>
|
||||
<a class="item-control item-delete" title="Delete Item"><i class="fas fa-trash"></i></a>
|
||||
</div>
|
||||
|
7
templates/chat-effect-used.html
Normal file
7
templates/chat-effect-used.html
Normal file
@ -0,0 +1,7 @@
|
||||
<div class="post-item" data-transfer="{{transfer}}">
|
||||
<h3><b>{{name}}</b></h3>
|
||||
{{#if img}}
|
||||
<img class="chat-img" src="{{img}}" title="{{name}}" />
|
||||
{{/if}}
|
||||
<div>Effect {{name}} has ben used and removed from the available effects.</div>
|
||||
</div>
|
@ -17,13 +17,13 @@
|
||||
<li class="flexrow"><label class="generic-label">Level</label>
|
||||
<input type="text" class="input-numeric-short padd-right" name="data.level" value="{{data.level}}" data-dtype="Number"/>
|
||||
</li>
|
||||
<li class="flexrow"><label class="generic-label">Remaining round</label>
|
||||
<select class="competence-base flexrow" type="text" name="data.roundcount" value="{{data.roundcount}}" data-dtype="Number">
|
||||
{{#select data.roundcount}}
|
||||
<option value="3">Ready</option>
|
||||
<option value="2">Activated</option>
|
||||
<option value="1">2 Rounds left</option>
|
||||
<option value="0">1 Round left</option>
|
||||
<li class="flexrow"><label class="generic-label">Perk Status</label>
|
||||
<select class="competence-base flexrow" type="text" name="data.status" value="{{data.status}}" data-dtype="String">
|
||||
{{#select data.status}}
|
||||
<option value="ready">Ready</option>
|
||||
<option value="activated">Activated</option>
|
||||
<option value="round2">2 Rounds left</option>
|
||||
<option value="round1">1 Round left</option>
|
||||
{{/select}}
|
||||
</select>
|
||||
</li>
|
||||
@ -38,6 +38,23 @@
|
||||
</select>
|
||||
</li>
|
||||
|
||||
<li class="flexrow"><label class="generic-label">Effects Gained</label>
|
||||
</li>
|
||||
<li>
|
||||
<ul class="ul-level1">
|
||||
<li class="flexrow"><div class="drop-perk-effect"><label>Drop Effects here !</label></div>
|
||||
</li>
|
||||
{{#each data.effectsgained as |effect idx|}}
|
||||
<li class="flexrow">
|
||||
<label name="data.effectsgained[{{idx}}].name"><a class="view-subitem" data-type="effectsgained" data-index="{{idx}}">{{effect.name}}</a></label>
|
||||
<div class="item-controls padd-left">
|
||||
<a class="item-control delete-subitem padd-left" data-type="effectsgained" data-index="{{idx}}" title="Delete Effect"><i class="fas fa-trash"></i></a>
|
||||
</div>
|
||||
</li>
|
||||
{{/each}}
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
{{#each data.features as |feature key|}}
|
||||
<li class="flexrow">
|
||||
<label class="generic-label">{{feature.label}} ? </label>
|
||||
|
@ -3,26 +3,6 @@
|
||||
{{#if img}}
|
||||
<img class="chat-img" src="{{img}}" title="{{name}}" />
|
||||
{{/if}}
|
||||
|
||||
{{#if (eq type "weapon")}}
|
||||
{{#each data.weaponstats as |weaponstat rootkey|}}
|
||||
{{#if weaponstat.deleted}}
|
||||
{{else}}
|
||||
<h4>Stats for {{weaponstat.name}}</h4>
|
||||
{{> "systems/fvtt-fragged-kingdom/templates/weapon-stats-section-tchat.html" stats=weaponstat.data.statstotal isfinal=false header=false}}
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
{{else}}
|
||||
|
||||
{{#if data.statstotal}}
|
||||
{{> "systems/fvtt-fragged-kingdom/templates/weapon-stats-section-tchat.html" stats=data.statstotal isfinal=false title="" header=true}}
|
||||
{{else}}
|
||||
{{#if data.stats}}
|
||||
{{> "systems/fvtt-fragged-kingdom/templates/weapon-stats-section-tchat.html" stats=data.stats isfinal=false title="" header=true}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
|
||||
<h4><b>Description : </b></h4>
|
||||
<p class="card-content">{{{data.description}}}</p>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user