This commit is contained in:
sladecraven 2022-01-12 16:25:55 +01:00
parent 3384157580
commit adcb4a49c9
11 changed files with 134 additions and 41 deletions

View File

@ -54,6 +54,7 @@ export class PegasusActorSheet extends ActorSheet {
subActors: duplicate(this.actor.getSubActors()), subActors: duplicate(this.actor.getSubActors()),
race: duplicate(this.actor.getRace()), race: duplicate(this.actor.getRace()),
role: duplicate(this.actor.getRole()), role: duplicate(this.actor.getRole()),
effects: duplicate(this.actor.getEffects()),
options: this.options, options: this.options,
owner: this.document.isOwner, owner: this.document.isOwner,
editScore: this.options.editScore, editScore: this.options.editScore,
@ -86,6 +87,12 @@ export class PegasusActorSheet extends ActorSheet {
PegasusUtility.confirmDelete(this, li); 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 => { html.find('.subactor-edit').click(ev => {
const li = $(ev.currentTarget).parents(".item"); const li = $(ev.currentTarget).parents(".item");
let actorId = li.data("actor-id"); let actorId = li.data("actor-id");

View File

@ -100,6 +100,11 @@ export class PegasusActor extends Actor {
return comp; return comp;
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
getEffects() {
let comp = this.data.items.filter( item => item.type == 'effect');
return comp;
}
/* -------------------------------------------- */
getPowers() { getPowers() {
let comp = this.data.items.filter( item => item.type == 'power'); let comp = this.data.items.filter( item => item.type == 'power');
return comp; return comp;
@ -409,7 +414,12 @@ export class PegasusActor extends Actor {
/* -------------------------------------------- */ /* -------------------------------------------- */
getStat( statKey) { 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); stat.dice = PegasusUtility.getDiceFromLevel(stat.value);
return stat; return stat;
} }
@ -424,6 +434,14 @@ export class PegasusActor extends Actor {
return spec; return spec;
} }
/* -------------------------------------------- */
updatePerkRounds( itemId, roundValue) {
let item = this.items.get( itemId)
if (item) {
this.updateEmbeddedDocuments( 'Item', [ { _id: item.id, 'data.roundcount': roundValue }] );
}
}
/* -------------------------------------------- */ /* -------------------------------------------- */
async rollMR() { async rollMR() {
let mr = duplicate( this.data.data.mr) ; let mr = duplicate( this.data.data.mr) ;

View File

@ -16,6 +16,8 @@ export class PegasusActorCreate {
this.races = racesPack.map(i => i.toObject()); this.races = racesPack.map(i => i.toObject());
const rolesPack = await PegasusUtility.loadCompendium("fvtt-pegasus-rpg.role"); const rolesPack = await PegasusUtility.loadCompendium("fvtt-pegasus-rpg.role");
this.roles = rolesPack.map(i => i.toObject()); 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() this.showRaces()
} }
@ -55,7 +57,7 @@ export class PegasusActorCreate {
if ( race.data.selectablestats ) { if ( race.data.selectablestats ) {
this.manageSelectableStats(race); this.manageSelectableStats(race);
} else if ( race.data.perksgained) { } else if ( race.data.perksgained) {
this.showRacePerks(race); this.manageRacePerks(race);
} else { } else {
this.showRoles() this.showRoles()
} }
@ -83,24 +85,19 @@ export class PegasusActorCreate {
this.processSelectableStats(); this.processSelectableStats();
} }
if (step == 'select-race-perks-all') { if (step == 'select-race-perks') {
PegasusUtility.removeChatMessageId(PegasusUtility.findChatMessageId(event.currentTarget)); PegasusUtility.removeChatMessageId(PegasusUtility.findChatMessageId(event.currentTarget));
let perk = this.racePerks.find( item => item._id == itemId); let perk = this.racePerks.find( item => item._id == itemId);
this.actor.createEmbeddedDocuments( 'Item', [perk]); this.actor.createEmbeddedDocuments( 'Item', [perk]);
this.racePerks = this.racePerks.filter( item => item._id != itemId); this.racePerks = this.racePerks.filter( item => item._id != itemId);
this.nbperks -= 1; this.nbRacePerks -= 1;
if ( this.nbperks == 0 || this.racePerks.length == 0) { if ( this.nbRacePerks == 0 || this.racePerks.length == 0) {
this.showRoles() this.showRoles()
}else { } else {
this.showRacePerks(); this.manageRacePerks()
} }
} }
if (step == 'select-race-perks') {
PegasusUtility.removeChatMessageId(PegasusUtility.findChatMessageId(event.currentTarget));
this.showRoles()
}
if ( step == 'select-role') { if ( step == 'select-role') {
let role = this.roles.find( item => item._id == itemId); let role = this.roles.find( item => item._id == itemId);
PegasusUtility.removeChatMessageId(PegasusUtility.findChatMessageId(event.currentTarget)); PegasusUtility.removeChatMessageId(PegasusUtility.findChatMessageId(event.currentTarget));
@ -205,18 +202,23 @@ export class PegasusActorCreate {
/* --------------- -------------------- --------- */ /* --------------- -------------------- --------- */
manageRacePerks(race) { 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 if ( !this.racePerks) { // First init
this.racePerks = duplicate(race.data.perks) if ( this.currentRace.data.perksall) {
this.nbRacePerks = race.data.perksnumber; this.racePerks = duplicate(this.perks)
} } else {
let formData this.racePerks = duplicate(this.currentRace.data.perks)
if (race.data.perksall) { }
formData = this.createFormData("select-race-perks-all") this.nbRacePerks = this.currentRace.data.perksnumber;
} else {
formData = this.createFormData("select-race-perks")
formData.raceperks = this.racePerks;
formData.nbraceperks = this.nbRacePerks;
} }
let formData = this.createFormData("select-race-perks")
formData.raceperks = this.racePerks;
formData.nbraceperks = this.nbRacePerks;
this.renderChatMessage(formData) this.renderChatMessage(formData)
} }
@ -224,7 +226,7 @@ export class PegasusActorCreate {
async processSelectableStats() { async processSelectableStats() {
// End of race options choice // End of race options choice
if ( this.raceSelectableStats.numberstats == 0) { if ( this.raceSelectableStats.numberstats == 0) {
this.showRoles() this.manageRacePerks();
return; return;
} }
let formData = this.createFormData("select-race-stats") let formData = this.createFormData("select-race-stats")

View File

@ -65,6 +65,7 @@ export class PegasusItemSheet extends ItemSheet {
limited: this.object.limited, limited: this.object.limited,
options: this.options, options: this.options,
owner: this.document.isOwner, owner: this.document.isOwner,
mr: (this.object.type == 'specialisation'),
isGM: game.user.isGM 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) { async _onDrop(event) {
//console.log(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' ) { if (this.object.type == 'race' ) {
let data = event.dataTransfer.getData('text/plain'); let data = event.dataTransfer.getData('text/plain');
if (data) { if (data) {

View File

@ -20,6 +20,11 @@ export class PegasusUtility {
this.optionsDiceList = ""; this.optionsDiceList = "";
this.buildDiceLists(); this.buildDiceLists();
PegasusCommands.init(); PegasusCommands.init();
Handlebars.registerHelper('upper', function (text) {
return text.toUpperCase();
});
} }
/* -------------------------------------------- */ /* -------------------------------------------- */

View File

@ -1160,6 +1160,7 @@ ul, li {
.ul-level1 { .ul-level1 {
padding-left: 2rem; padding-left: 2rem;
} }
.drop-effect-spec,
.drop-ability-weapon, .drop-ability-weapon,
.drop-ability-armor, .drop-ability-armor,
.drop-race-perk, .drop-race-perk,

View File

@ -100,9 +100,9 @@
"styles": [ "styles": [
"styles/simple.css" "styles/simple.css"
], ],
"templateVersion": 46, "templateVersion": 49,
"title": "Pegasus RPG", "title": "Pegasus RPG",
"url": "https://www.uberwald.me/data/files/fvtt-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" "background" : "./images/ui/pegasus_welcome_page.webp"
} }

View File

@ -174,7 +174,21 @@
} }
}, },
"Item": { "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": { "race": {
"description": "", "description": "",
"environment": "", "environment": "",

View File

@ -120,7 +120,7 @@
<li class="item stat flexrow list-item" data-item-id="{{spec._id}}"> <li class="item stat flexrow list-item" data-item-id="{{spec._id}}">
<img class="sheet-competence-img" src="{{spec.img}}" /> <img class="sheet-competence-img" src="{{spec.img}}" />
<span class="stat-label"><a class="roll-spec">{{spec.name}}</a></span> <span class="stat-label"><a class="roll-spec">{{spec.name}}</a></span>
<span class="stat-label">{{spec.data.statistic}}</span> <span class="stat-label">{{upper spec.data.statistic}}</span>
<span class="stat-label">{{spec.data.dice}}</span> <span class="stat-label">{{spec.data.dice}}</span>
<div class="item-controls"> <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-edit" title="Edit Item"><i class="fas fa-edit"></i></a>
@ -140,7 +140,17 @@
<li class="item stat flexrow list-item" data-item-id="{{perk._id}}"> <li class="item stat flexrow list-item" data-item-id="{{perk._id}}">
<img class="sheet-competence-img" src="{{perk.img}}" /> <img class="sheet-competence-img" src="{{perk.img}}" />
<span class="stat-label">{{perk.name}}</span> <span class="stat-label">{{perk.name}}</span>
<span class="stat-label">{{perk.data.level}}</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>
{{/select}}
</select>
</span>
<div class="item-controls"> <div class="item-controls">
<a class="item-control perk-active" title="active">{{#if perk.data.active}}<i <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> class="fas fa-circle"></i>{{else}}<i class="fas fa-genderless"></i>{{/if}}</a>
@ -184,24 +194,17 @@
<ul class="stat-list alternate-list"> <ul class="stat-list alternate-list">
<li class="item stat flexrow list-item"> <li class="item stat flexrow list-item">
<span class="generic-label"><a class="attack-melee">Melee Attack</a></span> <span class="generic-label"><a class="attack-melee">Melee Attack</a></span>
</li>
<li class="item stat flexrow list-item">
<span class="generic-label"><a class="attack-ranged">Ranged Attack</a></span> <span class="generic-label"><a class="attack-ranged">Ranged Attack</a></span>
</li> </li>
<li class="item stat flexrow list-item">
</li>
<li class="item stat flexrow list-item"> <li class="item stat flexrow list-item">
<span class="generic-label"><a class="defense-roll">Defense</a></span> <span class="generic-label"><a class="defense-roll">Defense</a></span>
</li>
<li class="item stat flexrow list-item">
<span class="generic-label"><a class="damage-melee">Melee/Thrown Damage</a></span>
</li>
<li class="item stat flexrow list-item">
<span class="generic-label"><a class="damage-ranged">Ranged Damage</a></span>
</li>
<li class="item stat flexrow list-item">
<span class="generic-label"><a class="damage-resistance">Damage Resistance</a></span> <span class="generic-label"><a class="damage-resistance">Damage Resistance</a></span>
</li> </li>
<li class="item stat flexrow list-item"> <li class="item stat flexrow list-item">
<span class="generic-label"><a class="unarmed-attack">Unarmed Attack</a></span> <span class="generic-label"><a class="damage-melee">Melee/Thrown Damage</a></span>
<span class="generic-label"><a class="damage-ranged">Ranged Damage</a></span>
</li> </li>
</ul> </ul>
@ -219,6 +222,24 @@
</li> </li>
</ul> </ul>
<span class="generic-label">
<h3>Effects</h3>
</span>
<ul class="stat-list alternate-list">
{{#each effects as |effect key|}}
<li class="item stat flexrow list-item" data-arme-id="{{effect.id}}" data-item-id="{{effect._id}}">
<img class="sheet-competence-img" src="{{effect.img}}" />
<span class="generic-label">{{effect.name}}</span>
<span class="generic-label">{{effect.data.type}}</span>
<span class="generic-label">{{effect.data.genre}}</span>
<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>
</div>
</li>
{{/each}}
</ul>
<span class="generic-label"> <span class="generic-label">
<h3>Weapons</h3> <h3>Weapons</h3>
</span> </span>

View File

@ -57,13 +57,13 @@
{{/if}} {{/if}}
{{#if (eq step "select-race-perks-all")}} {{#if (eq step "select-race-perks-all")}}
<div>Select {{nbperks}} from the Perks Comepndium. Once done, click the button below<br> <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> <a class="chat-card-button chat-create-actor" data-step-name="{{@root.step}}" data-stat-key="{{key}}" >Race Perks selected!</a>
</div> </div>
{{/if}} {{/if}}
{{#if (eq step "select-race-perks")}} {{#if (eq step "select-race-perks")}}
<div>Now select {{nbperks}} for your character <div>Now select {{nbraceperks}} Perk(s) for your character
</div> </div>
<table class="table-create-actor"> <table class="table-create-actor">
{{#each raceperks as |perk index|}} {{#each raceperks as |perk index|}}

View File

@ -1,6 +1,9 @@
{{#if notapplicable}} {{#if notapplicable}}
<option value="notapplicable">Not applicable</option> <option value="notapplicable">Not applicable</option>
{{/if}} {{/if}}
{{#if all}}
<option value="notapplicable">All</option>
{{/if}}
<option value="agi">AGI</option> <option value="agi">AGI</option>
<option value="mnd">MND</option> <option value="mnd">MND</option>
<option value="soc">SOC</option> <option value="soc">SOC</option>