Generic roll and update items

This commit is contained in:
sladecraven 2022-01-13 21:05:55 +01:00
parent 3d70f556fb
commit b4b41f5c96
5 changed files with 63 additions and 18 deletions

View File

@ -200,11 +200,15 @@ export class PegasusActorSheet extends ActorSheet {
this.actor.equipItem( li.data("item-id") );
this.render(true);
});
html.find('.update-field').change(ev => {
const fieldName = $(ev.currentTarget).data("field-name");
let value = ev.currentTarget.value;
this.actor.update( { [`${fieldName}`]: value } );
});
html.find('.perk-active').click(ev => {
const li = $(ev.currentTarget).parents(".item");
this.actor.activatePerk( li.data("item-id") );
this.render(true);
});
}

View File

@ -1,6 +1,7 @@
import { PegasusUtility } from "./pegasus-utility.js";
import { PegasusActor } from "./pegasus-actor.js";
import { PegasusActorSheet } from "./pegasus-actor-sheet.js";
import { PegasusItemSheet } from "./pegasus-item-sheet.js";
export class PegasusActorCreate {
@ -176,6 +177,42 @@ export class PegasusActorCreate {
}
}
/* -------------------------------------------- */
async openItemView( event) {
let step = $(event.currentTarget).data("step");
let itemId = $(event.currentTarget).data("item-id");
let itemData
if ( step == 'select-race') {
itemData = this.races.find( item => item._id == itemId );
}
if ( step == 'select-race-optionnal') {
itemData = this.raceOptionnalAbilities.optionnalabilities.find( item => item._id == itemId );
}
if ( step == 'select-race-perks') {
itemData = this.perks.find( item => item._id == itemId );
}
if ( step == 'select-race-perks'){
itemData = this.racePerks.find( item => item._id == itemId );
}
if ( step == 'select-role') {
itemData = this.roles.find( item => item._id == itemId );
}
if ( step == 'select-role-start-spec') {
itemData = this.roleSpecStart.find( item => item._id == itemId );
}
if (step == 'select-role-spec') {
itemData = this.roleSpec.find( item => item._id == itemId );
}
if (step == 'select-role-perk') {
itemData = this.rolePerks.find( item => item._id == itemId );
}
if (itemData) {
let item = await Item.create(itemData, {temporary: true});
new PegasusItemSheet(item).render(true);
}
}
/* -------------------------------------------- */
manageSelectableStats( race ) {
this.raceSelectableStats = {

View File

@ -128,10 +128,11 @@ export class PegasusUtility {
static async chatListeners(html) {
html.on("click", '.chat-create-actor', event => {
console.log("Event !")
game.system.pegasus.creator.processChatEvent(event);
} );
html.on("click", '.view-item-from-chat', event => {
game.system.pegasus.creator.openItemView( event)
} );
}
/* -------------------------------------------- */

View File

@ -188,6 +188,15 @@
<div class="tab fight" data-group="primary" data-tab="combat">
<div class="flexcol">
<ul>
<li class="item flexrow list-item" data-key="nrg">
<span class="stat-label flexrow" name="nrg"><h4>{{data.nrg.label}}</h4> </span>
<input type="text" class="padd-right update-field" data-field-name="data.nrg.activated" value="{{data.nrg.activated}}" data-dtype="Number"/>
<input type="text" class="padd-right update-field" data-field-name="data.nrg.value" value="{{data.nrg.value}}" data-dtype="Number"/>
<input type="text" class="padd-right update-field" data-field-name="data.nrg.max" value="{{data.nrg.max}}" data-dtype="Number"/>
</li>
</ul>
<span class="generic-label">
<h3>Basic Actions</h3>
</span>

View File

@ -11,7 +11,7 @@
<table class="table-create-actor">
{{#each races as |race index|}}
<tr>
<td>{{race.name}}</td>
<td><a class="view-item-from-chat" data-step="{{@root.step}}" data-item-id="{{race._id}}">{{race.name}}</a></td>
<td><a class="chat-card-button chat-create-actor" data-step-name="{{@root.step}}" data-item-id="{{race._id}}" >Select it !</a></td>
</tr>
{{/each}}
@ -25,7 +25,7 @@
<table class="table-create-actor">
{{#each optionnalabilities as |ability index|}}
<tr>
<td>{{ability.name}}</td>
<td><a class="view-item-from-chat" data-step="{{@root.step}}" data-item-id="{{ability._id}}">{{ability.name}}</a></td>
<td><a class="chat-card-button chat-create-actor" data-step-name="{{@root.step}}" data-item-id="{{ability._id}}" >Select it !</a></td>
</tr>
{{/each}}
@ -56,19 +56,13 @@
</table>
{{/if}}
{{#if (eq step "select-race-perks-all")}}
<div>Select {{nbperks}} from the Perks Compendium. Once done, click the button below<br>
<a class="chat-card-button chat-create-actor" data-step-name="{{@root.step}}" data-stat-key="{{key}}" >Race Perks selected!</a>
</div>
{{/if}}
{{#if (eq step "select-race-perks")}}
<div>Now select {{nbraceperks}} Perk(s) for your character
</div>
<table class="table-create-actor">
{{#each raceperks as |perk index|}}
<tr>
<td>{{perk.name}}</td>
<td><a class="view-item-from-chat" data-step="{{@root.step}}" data-item-id="{{perk._id}}">{{perk.name}}</a></td>
<td><a class="chat-card-button chat-create-actor" data-step-name="{{@root.step}}" data-item-id="{{perk._id}}" >Select it !</a></td>
</tr>
{{/each}}
@ -81,7 +75,7 @@
<table class="table-create-actor">
{{#each roles as |role index|}}
<tr>
<td>{{role.name}}</td>
<td><a class="view-item-from-chat" data-step="{{@root.step}}" data-item-id="{{role._id}}">{{role.name}}</a></td>
<td><a class="chat-card-button chat-create-actor" data-step-name="{{@root.step}}" data-item-id="{{role._id}}" >Select it !</a></td>
</tr>
{{/each}}
@ -94,7 +88,7 @@
<table class="table-create-actor">
{{#each rolestartspec as |spec index|}}
<tr>
<td>{{spec.name}}</td>
<td><a class="view-item-from-chat" data-step="{{@root.step}}" data-item-id="{{spec._id}}">{{spec.name}}</a></td>
<td><a class="chat-card-button chat-create-actor" data-step-name="{{@root.step}}" data-item-id="{{spec._id}}" >Select it !</a></td>
</tr>
{{/each}}
@ -120,7 +114,7 @@
<table class="table-create-actor">
{{#each rolespec as |spec index|}}
<tr>
<td>{{spec.name}}</td>
<td><a class="view-item-from-chat" data-step="{{@root.step}}" data-item-id="{{spec._id}}">{{spec.name}}</a></td>
<td><a class="chat-card-button chat-create-actor" data-step-name="{{@root.step}}" data-item-id="{{spec._id}}" >Select it !</a></td>
</tr>
{{/each}}
@ -133,7 +127,7 @@
<table class="table-create-actor">
{{#each roleperks as |perk index|}}
<tr>
<td>{{perk.name}}</td>
<td><a class="view-item-from-chat" data-step="{{@root.step}}" data-item-id="{{perk._id}}">{{perk.name}}</a></td>
<td><a class="chat-card-button chat-create-actor" data-step-name="{{@root.step}}" data-item-id="{{perk._id}}" >Select it !</a></td>
</tr>
{{/each}}