Char creation
This commit is contained in:
parent
f3bc082e8c
commit
91ab828681
@ -483,6 +483,24 @@ export class PegasusActor extends Actor {
|
|||||||
await this.deleteEmbeddedDocuments( 'Item', items);
|
await this.deleteEmbeddedDocuments( 'Item', items);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
async addItemWithoutDuplicate( newItem ) {
|
||||||
|
let item = this.data.items.filter( item => item.type == newItem.type && item.name.toLowerCase() == newItem.name.toLowerCase() )
|
||||||
|
if ( !item ) {
|
||||||
|
await this.createEmbeddedDocuments( 'Item', [newItem]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
computeNRGHealth( ) {
|
||||||
|
let focValue = this.data.data.statistics.foc.value;
|
||||||
|
this.update( {'data.secondary.nrg.max': focValue, 'data.secondary.nrg.value': focValue} )
|
||||||
|
let phyValue = this.data.data.statistics.phy.value;
|
||||||
|
this.update( {'data.secondary.health.max': phyValue, 'data.secondary.health.value': phyValue} )
|
||||||
|
let mndValue = this.data.data.statistics.mnd.value;
|
||||||
|
this.update( {'data.secondary.delirium.max': mndValue, 'data.secondary.delirium.value': mndValue} )
|
||||||
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async modStat( key, inc=1) {
|
async modStat( key, inc=1) {
|
||||||
let stat = duplicate(this.data.data.statistics[key])
|
let stat = duplicate(this.data.data.statistics[key])
|
||||||
@ -490,6 +508,29 @@ export class PegasusActor extends Actor {
|
|||||||
await this.update( { [`data.statistics.${key}`] : stat } )
|
await this.update( { [`data.statistics.${key}`] : stat } )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
async valueStat( key, inc=1) {
|
||||||
|
key = key.toLowerCase()
|
||||||
|
let stat = duplicate( this.data.data.statistics[key] )
|
||||||
|
stat.value += parseInt(inc)
|
||||||
|
await this.update( { [`data.statistics.${key}`] : stat } )
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
async addIncSpec( spec, inc=1) {
|
||||||
|
console.log("Using spec : ", spec, inc)
|
||||||
|
let specExist = this.data.items.find( item => item.type == 'specialisation' && item.name.toLowerCase() == spec.name.toLowerCase())
|
||||||
|
if (specExist) {
|
||||||
|
specExist = duplicate(specExist)
|
||||||
|
specExist.data.level += inc;
|
||||||
|
let update = { _id: specExist._id, "data.level": specExist.data.level };
|
||||||
|
await this.updateEmbeddedDocuments('Item', [ update ]);
|
||||||
|
} else {
|
||||||
|
spec.data.level += inc;
|
||||||
|
await this.createEmbeddedDocuments( 'Item', [ spec ]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async applyRace( race ) {
|
async applyRace( race ) {
|
||||||
let updates = { 'data.racename':race.name }
|
let updates = { 'data.racename':race.name }
|
||||||
@ -533,6 +574,9 @@ export class PegasusActor extends Actor {
|
|||||||
this.getIncreaseStatValue( updates, role.data.statincrease1)
|
this.getIncreaseStatValue( updates, role.data.statincrease1)
|
||||||
this.getIncreaseStatValue( updates, role.data.statincrease2)
|
this.getIncreaseStatValue( updates, role.data.statincrease2)
|
||||||
|
|
||||||
|
newItems = newItems.concat(duplicate(role.data.specialisationsplus1))
|
||||||
|
newItems = newItems.concat(duplicate(role.data.specialperk))
|
||||||
|
|
||||||
await this.update( updates )
|
await this.update( updates )
|
||||||
await this.createEmbeddedDocuments('Item', newItems)
|
await this.createEmbeddedDocuments('Item', newItems)
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,66 @@ export class PegasusActorCreate {
|
|||||||
|
|
||||||
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));
|
||||||
this.actor.applyRole( role );
|
this.actor.applyRole( role );
|
||||||
|
this.currentRole = role;
|
||||||
|
this.nbRoleStat = 2;
|
||||||
|
this.roleStats = duplicate(role.data.statincreasechoice)
|
||||||
|
this.showRoleStat( );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( step == 'select-role-stat') {
|
||||||
|
PegasusUtility.removeChatMessageId(PegasusUtility.findChatMessageId(event.currentTarget));
|
||||||
|
let statKey = $(event.currentTarget).data("stat-key");
|
||||||
|
this.actor.valueStat( statKey, 1);
|
||||||
|
|
||||||
|
for (let stat of this.roleStats ) {
|
||||||
|
if ( stat.name.toLowerCase() == statKey.toLowerCase()) {
|
||||||
|
stat.flag = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.nbRoleStat--;
|
||||||
|
if ( this.nbRoleStat == 0 || this.roleStats.length == 0) {
|
||||||
|
this.roleSpec = duplicate(this.currentRole.data.specincrease)
|
||||||
|
this.nbDT2 = 1;
|
||||||
|
this.nbDT1 = 2;
|
||||||
|
this.showRoleSpecialisations()
|
||||||
|
} else{
|
||||||
|
this.showRoleStat( );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (step == 'select-role-spec') {
|
||||||
|
PegasusUtility.removeChatMessageId(PegasusUtility.findChatMessageId(event.currentTarget));
|
||||||
|
let spec = this.roleSpec.find( item => item._id == itemId);
|
||||||
|
if (this.nbDT2 > 0) {
|
||||||
|
this.actor.addIncSpec(spec, 2)
|
||||||
|
this.nbDT2--;
|
||||||
|
} else {
|
||||||
|
this.actor.addIncSpec(spec, 1)
|
||||||
|
this.nbDT1--;
|
||||||
|
}
|
||||||
|
this.roleSpec = this.roleSpec.filter( item => item._id != itemId);//Remove selected spec
|
||||||
|
if ( this.nbDT1 == 0 || this.roleSpec.length == 0) {
|
||||||
|
this.rolePerks = duplicate(this.currentRole.data.perks)
|
||||||
|
this.nbPerks = 2;
|
||||||
|
this.showRolePerks()
|
||||||
|
} else {
|
||||||
|
this.showRoleSpecialisations()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (step == 'select-role-perk') {
|
||||||
|
PegasusUtility.removeChatMessageId(PegasusUtility.findChatMessageId(event.currentTarget));
|
||||||
|
let perk = this.rolePerks.find( item => item._id == itemId);
|
||||||
|
this.actor.addItemWithoutDuplicate(perk)
|
||||||
|
this.nbPerks--;
|
||||||
|
this.rolePerks = this.rolePerks.filter( item => item._id != itemId);//Remove selected perk
|
||||||
|
if (this.nbPerks == 0 || this.rolePerks.length == 0) {
|
||||||
|
this.showCharacterEnd()
|
||||||
|
} else {
|
||||||
|
this.showRolePerks()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,4 +230,72 @@ export class PegasusActorCreate {
|
|||||||
};
|
};
|
||||||
await ChatMessage.create( chatData );
|
await ChatMessage.create( chatData );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
async showRoleStat( ) {
|
||||||
|
let formData = this.createFormData("select-role-stat")
|
||||||
|
formData.rolestats = []
|
||||||
|
for(let stat of this.roleStats) {
|
||||||
|
if (stat.flag) {
|
||||||
|
formData.rolestats.push( duplicate(this.actor.data.data.statistics[stat.name.toLowerCase()]) )
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.log("STAT", this.roleStats, formData)
|
||||||
|
let chatData = {
|
||||||
|
user: game.user.id,
|
||||||
|
alias : this.actor.name,
|
||||||
|
rollMode: game.settings.get("core", "rollMode"),
|
||||||
|
whisper: [game.user.id].concat( ChatMessage.getWhisperRecipients('GM') ),
|
||||||
|
content: await renderTemplate('systems/fvtt-pegasus-rpg/templates/chat-create-actor.html', formData)
|
||||||
|
};
|
||||||
|
await ChatMessage.create( chatData );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
async showRoleSpecialisations() {
|
||||||
|
let formData = this.createFormData("select-role-spec")
|
||||||
|
formData.rolespec = duplicate(this.roleSpec)
|
||||||
|
formData.dt = 1
|
||||||
|
if (this.nbDT2 > 0 ) {
|
||||||
|
formData.dt = 2
|
||||||
|
}
|
||||||
|
let chatData = {
|
||||||
|
user: game.user.id,
|
||||||
|
alias : this.actor.name,
|
||||||
|
rollMode: game.settings.get("core", "rollMode"),
|
||||||
|
whisper: [game.user.id].concat( ChatMessage.getWhisperRecipients('GM') ),
|
||||||
|
content: await renderTemplate('systems/fvtt-pegasus-rpg/templates/chat-create-actor.html', formData)
|
||||||
|
};
|
||||||
|
await ChatMessage.create( chatData );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
async showRolePerks() {
|
||||||
|
let formData = this.createFormData("select-role-perk")
|
||||||
|
formData.roleperks = duplicate(this.rolePerks)
|
||||||
|
formData.nbperks = this.nbPerks
|
||||||
|
let chatData = {
|
||||||
|
user: game.user.id,
|
||||||
|
alias : this.actor.name,
|
||||||
|
rollMode: game.settings.get("core", "rollMode"),
|
||||||
|
whisper: [game.user.id].concat( ChatMessage.getWhisperRecipients('GM') ),
|
||||||
|
content: await renderTemplate('systems/fvtt-pegasus-rpg/templates/chat-create-actor.html', formData)
|
||||||
|
};
|
||||||
|
await ChatMessage.create( chatData );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
async showCharacterEnd() {
|
||||||
|
this.actor.computeNRGHealth()
|
||||||
|
let formData = this.createFormData("character-end")
|
||||||
|
let chatData = {
|
||||||
|
user: game.user.id,
|
||||||
|
alias : this.actor.name,
|
||||||
|
rollMode: game.settings.get("core", "rollMode"),
|
||||||
|
whisper: [game.user.id].concat( ChatMessage.getWhisperRecipients('GM') ),
|
||||||
|
content: await renderTemplate('systems/fvtt-pegasus-rpg/templates/chat-create-actor.html', formData)
|
||||||
|
};
|
||||||
|
await ChatMessage.create( chatData );
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
File diff suppressed because one or more lines are too long
@ -100,9 +100,9 @@
|
|||||||
"styles": [
|
"styles": [
|
||||||
"styles/simple.css"
|
"styles/simple.css"
|
||||||
],
|
],
|
||||||
"templateVersion": 33,
|
"templateVersion": 34,
|
||||||
"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.33",
|
"version": "0.0.34",
|
||||||
"background" : "./images/ui/pegasus_welcome_page.webp"
|
"background" : "./images/ui/pegasus_welcome_page.webp"
|
||||||
}
|
}
|
@ -70,4 +70,49 @@
|
|||||||
</table>
|
</table>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
|
{{#if (eq step "select-role-stat")}}
|
||||||
|
<div>Choose 1 Stat at +1DT :
|
||||||
|
</div>
|
||||||
|
<table class="table-create-actor">
|
||||||
|
{{#each rolestats as |rolestat key|}}
|
||||||
|
<tr>
|
||||||
|
<td>{{rolestat.label}}</td>
|
||||||
|
<td><a class="chat-card-button chat-create-actor" data-step-name="{{@root.step}}" data-stat-key="{{rolestat.abbrev}}">Select it !</a></td>
|
||||||
|
</tr>
|
||||||
|
{{/each}}
|
||||||
|
</table>
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
{{#if (eq step "select-role-spec")}}
|
||||||
|
<div>Now select a specialisation at +{{dt}}DT.
|
||||||
|
</div>
|
||||||
|
<table class="table-create-actor">
|
||||||
|
{{#each rolespec as |spec index|}}
|
||||||
|
<tr>
|
||||||
|
<td>{{spec.name}}</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}}
|
||||||
|
</table>
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
{{#if (eq step "select-role-perk")}}
|
||||||
|
<div>Now select a Perk.
|
||||||
|
</div>
|
||||||
|
<table class="table-create-actor">
|
||||||
|
{{#each roleperks as |perk index|}}
|
||||||
|
<tr>
|
||||||
|
<td>{{perk.name}}</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}}
|
||||||
|
</table>
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
{{#if (eq step "character-end")}}
|
||||||
|
<div>Follow the next steps from the rulebook page 50 !. You can now spend 150 CDPs to customise your character.
|
||||||
|
</div>
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user