Char creation process finalized
This commit is contained in:
parent
dad117fc17
commit
45e856a30b
@ -282,9 +282,9 @@ export class PegasusActor extends Actor {
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getStatus(statusKey) {
|
||||
if ( statusKey == "nrg") {
|
||||
if (statusKey == "nrg") {
|
||||
return duplicate(this.system.nrg)
|
||||
}
|
||||
}
|
||||
return duplicate(this.system.secondary[statusKey])
|
||||
}
|
||||
|
||||
@ -479,6 +479,29 @@ export class PegasusActor extends Actor {
|
||||
let update = { _id: item.id, "data.activated": !item.system.activated }
|
||||
await this.updateEmbeddedDocuments('Item', [update]) // Updates one EmbeddedEntity
|
||||
}
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
setHandInformation( info) {
|
||||
this.update( {'system.biodata.preferredhand': info} )
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
increaseRoleAbility() {
|
||||
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
addCDP( value) {
|
||||
let cdp = this.system.biodata.cdp
|
||||
cdp += value
|
||||
this.update( {'system.biodata.cdp': cdp})
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
addPPP(value) {
|
||||
let ppp = duplicate(this.system.ppp)
|
||||
ppp.availablePPP += value
|
||||
this.update({ 'system.ppp': ppp })
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -1558,14 +1581,14 @@ export class PegasusActor extends Actor {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async modStatus(key, inc = 1) {
|
||||
if ( key == "nrg") {
|
||||
if (key == "nrg") {
|
||||
let nrg = duplicate(this.system.nrg)
|
||||
nrg.mod += parseInt(inc)
|
||||
await this.update({ [`data.nrg`]: nrg })
|
||||
await this.update({ [`data.nrg`]: nrg })
|
||||
} else {
|
||||
let status = duplicate(this.system.secondary[key])
|
||||
status.bonus += parseInt(inc)
|
||||
await this.update({ [`data.secondary.${key}`]: status })
|
||||
await this.update({ [`data.secondary.${key}`]: status })
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,10 @@ export class PegasusActorCreate {
|
||||
this.perks = perksPack.map(i => i.toObject())
|
||||
const specPack = await PegasusUtility.loadCompendium("fvtt-pegasus-rpg.specialisations")
|
||||
this.specs = specPack.map(i => i.toObject())
|
||||
const virtuePack = await PegasusUtility.loadCompendium("fvtt-pegasus-rpg.virtues")
|
||||
this.virtues = virtuePack.map(i => i.toObject())
|
||||
const vicePack = await PegasusUtility.loadCompendium("fvtt-pegasus-rpg.vices")
|
||||
this.vices = vicePack.map(i => i.toObject())
|
||||
|
||||
this.showRaces()
|
||||
}
|
||||
@ -64,7 +68,7 @@ export class PegasusActorCreate {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
processChatEvent(event) {
|
||||
async processChatEvent(event) {
|
||||
const step = $(event.currentTarget).data("step-name");
|
||||
const itemId = $(event.currentTarget).data("item-id");
|
||||
|
||||
@ -199,7 +203,11 @@ export class PegasusActorCreate {
|
||||
this.nbPerks--;
|
||||
if (this.nbPerks == 0 || this.rolePerks.length == 0) {
|
||||
this.nbGlobalSpec = 5
|
||||
this.showGlobalSpec()
|
||||
if (this.forceVirtue) {
|
||||
this.showVirtue()
|
||||
} else {
|
||||
this.showGlobalSpec()
|
||||
}
|
||||
} else {
|
||||
this.showRolePerks()
|
||||
}
|
||||
@ -212,8 +220,11 @@ export class PegasusActorCreate {
|
||||
this.nbGlobalSpec--;
|
||||
if (this.nbGlobalSpec == 0) {
|
||||
this.nbGlobalStat = 5
|
||||
this.showGlobalStat()
|
||||
//this.showCharacterEnd()
|
||||
if (this.forceVirtue) {
|
||||
this.showVirtue()
|
||||
} else {
|
||||
this.showGlobalStat()
|
||||
}
|
||||
} else {
|
||||
this.showGlobalSpec()
|
||||
}
|
||||
@ -226,8 +237,11 @@ export class PegasusActorCreate {
|
||||
this.nbGlobalStat--
|
||||
if (this.nbGlobalStat == 0) {
|
||||
this.nbGlobalPerk = 1
|
||||
this.showGlobalPerk()
|
||||
//this.showCharacterEnd()
|
||||
if (this.forceVirtue) {
|
||||
this.showVirtue()
|
||||
} else {
|
||||
this.showGlobalPerk()
|
||||
}
|
||||
} else {
|
||||
this.showGlobalStat()
|
||||
}
|
||||
@ -240,8 +254,11 @@ export class PegasusActorCreate {
|
||||
this.nbGlobalPerk--;
|
||||
if (this.nbGlobalPerk == 0) {
|
||||
this.nbGlobalStatus = 1
|
||||
this.showGlobalStatus()
|
||||
//this.showCharacterEnd()
|
||||
if (this.forceVirtue) {
|
||||
this.showVirtue()
|
||||
} else {
|
||||
this.showGlobalStatus()
|
||||
}
|
||||
} else {
|
||||
this.showGlobalPerk()
|
||||
}
|
||||
@ -253,13 +270,102 @@ export class PegasusActorCreate {
|
||||
this.actor.addStatusBonus(statusKey, 1)
|
||||
this.nbGlobalStatus--;
|
||||
if (this.nbGlobalStatus == 0) {
|
||||
this.showCharacterEnd()
|
||||
this.nbBonusSelection = 1
|
||||
if (this.forceVirtue) {
|
||||
this.showVirtue()
|
||||
} else {
|
||||
this.showBonusSelection()
|
||||
}
|
||||
} else {
|
||||
this.showGlobalStatus()
|
||||
}
|
||||
}
|
||||
|
||||
if (step == 'select-bonus-selection') {
|
||||
PegasusUtility.removeChatMessageId(PegasusUtility.findChatMessageId(event.currentTarget))
|
||||
let nextStep = $(event.currentTarget).data("bonus-key")
|
||||
this.forceVirtue = true
|
||||
if (nextStep == "bonus-statistic") {
|
||||
this.nbGlobalStat = 2
|
||||
this.showGlobalStat()
|
||||
}
|
||||
if (nextStep == "bonus-specialisation") {
|
||||
this.nbGlobalSpec = 4
|
||||
this.showGlobalSpec()
|
||||
}
|
||||
if (nextStep == "bonus-perk") {
|
||||
this.nbGlobalPerk = 2
|
||||
this.showGlobalPerk()
|
||||
}
|
||||
if (nextStep == "bonus-status") {
|
||||
this.nbGlobalStatus = 5
|
||||
this.showGlobalStatus()
|
||||
}
|
||||
if (nextStep == "bonus-roleability") {
|
||||
this.actor.increaseRoleAbility()
|
||||
}
|
||||
if (nextStep == "bonus-ppp5") {
|
||||
this.actor.addPPP(5)
|
||||
}
|
||||
if (nextStep == "bonus-wealthy") {
|
||||
ChatMessage.create({ content: "NOT AUTOMATED! Your character starts with x2 Starting Funds" })
|
||||
this.showVirtue()
|
||||
}
|
||||
if (nextStep == "bonus-heirloom") {
|
||||
ChatMessage.create({ content: "NOT AUTOMATED! Your character starts with an item of choice (GM Must approve). This item provides a Level 1 Bonus Dice to a Stat of choice" })
|
||||
this.showVirtue()
|
||||
}
|
||||
if (nextStep == "bonus-vehicle") {
|
||||
ChatMessage.create({ content: "NOT AUTOMATED! Your character starts with a Vehicle of Choice (GM Must approve)." })
|
||||
this.showVirtue()
|
||||
}
|
||||
if (nextStep == "bonus-mount") {
|
||||
ChatMessage.create({ content: "NOT AUTOMATED! Your character starts with a Mount of Choice (GM Must approve)." })
|
||||
this.showVirtue()
|
||||
}
|
||||
if (nextStep == "bonus-sidekick") {
|
||||
ChatMessage.create({ content: "NOT AUTOMATED! Your character starts with a Sidekick of Choice (GM Must approve)." })
|
||||
this.showVirtue()
|
||||
}
|
||||
if (nextStep == "bonus-ambidextrious") {
|
||||
this.actor.setHandInformation("Ambidextrious")
|
||||
this.showVirtue()
|
||||
}
|
||||
}
|
||||
|
||||
if (step == 'select-global-virtue') {
|
||||
PegasusUtility.removeChatMessageId(PegasusUtility.findChatMessageId(event.currentTarget));
|
||||
let virtue = this.virtues.find(item => item._id == itemId);
|
||||
await this.actor.createEmbeddedDocuments('Item', [virtue])
|
||||
this.showVice()
|
||||
}
|
||||
|
||||
if (step == 'select-global-vice') {
|
||||
PegasusUtility.removeChatMessageId(PegasusUtility.findChatMessageId(event.currentTarget));
|
||||
let vice = this.vices.find(item => item._id == itemId);
|
||||
await this.actor.createEmbeddedDocuments('Item', [vice]);
|
||||
if(this.forceEnd) {
|
||||
this.showCharacterEnd()
|
||||
} else {
|
||||
this.showViceQuestion()
|
||||
}
|
||||
}
|
||||
|
||||
if (step == "select-vice-question") {
|
||||
PegasusUtility.removeChatMessageId(PegasusUtility.findChatMessageId(event.currentTarget))
|
||||
let nextStep = $(event.currentTarget).data("question-key")
|
||||
this.forceEnd = true
|
||||
if (nextStep == "vice-next-step") {
|
||||
this.showCharacterEnd()
|
||||
}
|
||||
if (nextStep == "vice-5-cdp") {
|
||||
this.actor.addCDP(5)
|
||||
this.showVice()
|
||||
}
|
||||
if (nextStep == "vice-vertue") {
|
||||
this.showVirtue()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -515,6 +621,85 @@ export class PegasusActorCreate {
|
||||
this.renderChatMessage(formData)
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async showBonusSelection() {
|
||||
let formData = this.createFormData("select-bonus-selection")
|
||||
formData.bonuses = {
|
||||
"bonus-statistic": { name: "Increase 2 Stats" },
|
||||
"bonus-specialisation": { name: "Increase 4 Specialisations" },
|
||||
"bonus-perk": { name: "Choose/Upgrade 2 Perks" },
|
||||
"bonus-status": { name: "Upgrade 5 status" },
|
||||
"bonus-roleability": { name: "Role Ability +1" },
|
||||
"bonus-ppp5": { name: "Gain +5 PPP" },
|
||||
"bonus-wealthy": { name: "Wealthy (money x 2)" },
|
||||
"bonus-heirloom": { name: "Family Heirloom (Special Item)" },
|
||||
"bonus-vehicle": { name: "Starting Vehicle" },
|
||||
"bonus-sidekick": { name: "Starting Sidekick" },
|
||||
"bonus-ambidextrious": { name: "Ambidextrious" }
|
||||
}
|
||||
this.renderChatMessage(formData)
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async showVirtue() {
|
||||
let formData = this.createFormData("select-global-virtue")
|
||||
let virtues = this.actor.items.filter(it => it.type == "virtue")
|
||||
formData.virtues = []
|
||||
for ( let virtue1 of this.virtues) { // Filter existing virtues
|
||||
let isOK = true
|
||||
for(let virtue2 of virtues) {
|
||||
if (virtue1.name == virtue2.name) {
|
||||
isOK = false
|
||||
break
|
||||
}
|
||||
}
|
||||
if (isOK) {
|
||||
formData.virtues.push(virtue1)
|
||||
}
|
||||
}
|
||||
formData.virtues.sort(function compare(a, b) { if (a.name < b.name) { return -1 } else { return 1 } })
|
||||
this.renderChatMessage(formData)
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
async showVice() {
|
||||
let formData = this.createFormData("select-global-vice")
|
||||
let virtues = this.actor.items.filter(it => it.type == "virtue")
|
||||
let vices = this.actor.items.filter(it => it.type == "vice")
|
||||
formData.vices = []
|
||||
for (let vice of this.vices) {
|
||||
let isOK = true
|
||||
for ( let virtue of virtues) {
|
||||
for (let nonVice of virtue.system.unavailablevice) {
|
||||
if(nonVice.name == vice.name) {
|
||||
isOK = false
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
for ( let vice2 of vices) {
|
||||
if(vice2.name == vice.name) {
|
||||
isOK = false
|
||||
break
|
||||
}
|
||||
}
|
||||
if (isOK) {
|
||||
formData.vices.push( vice)
|
||||
}
|
||||
}
|
||||
formData.vices.sort(function compare(a, b) { if (a.name < b.name) { return -1 } else { return 1 } })
|
||||
this.renderChatMessage(formData)
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
showViceQuestion() {
|
||||
let formData = this.createFormData("select-vice-question")
|
||||
formData.questions = {
|
||||
"vice-next-step": { name: "Go to next step" },
|
||||
"vice-5-cdp": { name: "Gain +5 CDP and choose a Vice" },
|
||||
"vice-vertue": { name: "Choose a Virtue and a Vice" }
|
||||
}
|
||||
this.renderChatMessage(formData)
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async showCharacterEnd() {
|
||||
|
@ -186,8 +186,62 @@
|
||||
</table>
|
||||
{{/if}}
|
||||
|
||||
{{#if (eq step "select-bonus-selection")}}
|
||||
<div>Select a bonus
|
||||
</div>
|
||||
<table class="table-create-actor">
|
||||
{{#each bonuses as |bonus key|}}
|
||||
<tr>
|
||||
<td><a class="view-item-from-chat" data-step="{{@root.step}}" data-bonus-key="{{key}}">{{bonus.name}}</a></td>
|
||||
<td><a class="chat-card-button chat-create-actor" data-step-name="{{@root.step}}" data-bonus-key="{{key}}" >Select it !</a></td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
</table>
|
||||
{{/if}}
|
||||
|
||||
{{#if (eq step "select-global-virtue")}}
|
||||
<div>Choose a Virtue.
|
||||
</div>
|
||||
<table class="table-create-actor">
|
||||
{{#each virtues as |virtue index|}}
|
||||
<tr>
|
||||
<td><a class="view-item-from-chat" data-step="{{@root.step}}" data-item-id="{{virtue._id}}">{{virtue.name}}</a></td>
|
||||
<td><a class="chat-card-button chat-create-actor" data-step-name="{{@root.step}}" data-item-id="{{virtue._id}}" >Select it !</a></td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
</table>
|
||||
{{/if}}
|
||||
|
||||
{{#if (eq step "select-global-vice")}}
|
||||
<div>Choose an available Vice.
|
||||
</div>
|
||||
<table class="table-create-actor">
|
||||
{{#each vices as |vice index|}}
|
||||
<tr>
|
||||
<td><a class="view-item-from-chat" data-step="{{@root.step}}" data-item-id="{{vice._id}}">{{vice.name}}</a></td>
|
||||
<td><a class="chat-card-button chat-create-actor" data-step-name="{{@root.step}}" data-item-id="{{vice._id}}" >Select it !</a></td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
</table>
|
||||
{{/if}}
|
||||
|
||||
{{#if (eq step "select-vice-question")}}
|
||||
<div>Would you like to skip, to choose a second Vice for 5 CDP or to choose 1 Virtue and 1 Vice?
|
||||
</div>
|
||||
<table class="table-create-actor">
|
||||
{{#each questions as |question key|}}
|
||||
<tr>
|
||||
<td><a class="view-item-from-chat" data-step="{{@root.step}}" data-question-key="{{key}}">{{question.name}}</a></td>
|
||||
<td><a class="chat-card-button chat-create-actor" data-step-name="{{@root.step}}" data-question-key="{{key}}" >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>Choose Starting Gear, Worst Fear, Desires, Catchphrase & Catchphrase Trigger
|
||||
and fill in the empty fields in the Bio Tab.<br>
|
||||
Automated character creation is over.
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user