Fix #31 - Global perl select

This commit is contained in:
sladecraven 2022-11-26 16:03:11 +01:00
parent cc0dc9e43c
commit dad117fc17
4 changed files with 145 additions and 97 deletions

View File

@ -280,6 +280,26 @@ export class PegasusActor extends Actor {
ChatMessage.create({ content: `Tactician Bonus Dice has been removed to ${this.name}`, whisper: ChatMessage.getWhisperRecipients('GM') }) ChatMessage.create({ content: `Tactician Bonus Dice has been removed to ${this.name}`, whisper: ChatMessage.getWhisperRecipients('GM') })
} }
} }
/* -------------------------------------------- */
getStatus(statusKey) {
if ( statusKey == "nrg") {
return duplicate(this.system.nrg)
}
return duplicate(this.system.secondary[statusKey])
}
/* -------------------------------------------- */
async addStatusBonus(statusKey, value) {
let status = this.getStatus(statusKey)
let effect = duplicate(__bonusEffect)
effect.name = `${status.label} Creation Bonus`
effect.system.affectstatus = true
effect.system.affectedstatus = statusKey
effect.system.effectlevel = value
effect.system.bonusdice = false
effect.system.locked = true
await this.createEmbeddedDocuments('Item', [effect])
}
/* -------------------------------------------- */ /* -------------------------------------------- */
isEnhancer() { isEnhancer() {
@ -1536,6 +1556,19 @@ export class PegasusActor extends Actor {
await this.update({ [`data.statistics.${key}`]: stat }) await this.update({ [`data.statistics.${key}`]: stat })
} }
/* -------------------------------------------- */
async modStatus(key, inc = 1) {
if ( key == "nrg") {
let nrg = duplicate(this.system.nrg)
nrg.mod += parseInt(inc)
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 })
}
}
/* -------------------------------------------- */ /* -------------------------------------------- */
async addIncSpec(spec, inc = 1) { async addIncSpec(spec, inc = 1) {
console.log("Using spec : ", spec, inc) console.log("Using spec : ", spec, inc)

View File

@ -239,12 +239,26 @@ export class PegasusActorCreate {
this.actor.addIncPerk(perk, 1) this.actor.addIncPerk(perk, 1)
this.nbGlobalPerk--; this.nbGlobalPerk--;
if (this.nbGlobalPerk == 0) { if (this.nbGlobalPerk == 0) {
this.showCharacterEnd() this.nbGlobalStatus = 1
this.showGlobalStatus()
//this.showCharacterEnd()
} else { } else {
this.showGlobalPerk() this.showGlobalPerk()
} }
} }
if (step == 'select-global-status') {
PegasusUtility.removeChatMessageId(PegasusUtility.findChatMessageId(event.currentTarget))
let statusKey = $(event.currentTarget).data("status-key")
this.actor.addStatusBonus(statusKey, 1)
this.nbGlobalStatus--;
if (this.nbGlobalStatus == 0) {
this.showCharacterEnd()
} else {
this.showGlobalStatus()
}
}
} }
@ -493,6 +507,15 @@ export class PegasusActorCreate {
this.renderChatMessage(formData) this.renderChatMessage(formData)
} }
/* -------------------------------------------- */
async showGlobalStatus() {
let formData = this.createFormData("select-global-status")
formData.status = duplicate(this.actor.system.secondary)
formData.status["nrg"] = duplicate(this.actor.system.nrg)
this.renderChatMessage(formData)
}
/* -------------------------------------------- */ /* -------------------------------------------- */
async showCharacterEnd() { async showCharacterEnd() {
await this.actor.computeNRGHealth() await this.actor.computeNRGHealth()

File diff suppressed because one or more lines are too long

View File

@ -160,6 +160,32 @@
</table> </table>
{{/if}} {{/if}}
{{#if (eq step "select-global-perk")}}
<div>Choose a new perk or add +1DT for en existing one.
</div>
<table class="table-create-actor">
{{#each perks as |perk index|}}
<tr>
<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}}
</table>
{{/if}}
{{#if (eq step "select-global-status")}}
<div>Now add a +1 bonus to a status
</div>
<table class="table-create-actor">
{{#each status as |stat key|}}
<tr>
<td><a class="view-item-from-chat" data-step="{{@root.step}}" data-status-key="{{key}}">{{stat.label}}</a></td>
<td><a class="chat-card-button chat-create-actor" data-step-name="{{@root.step}}" data-status-key="{{key}}" >Select it !</a></td>
</tr>
{{/each}}
</table>
{{/if}}
{{#if (eq step "character-end")}} {{#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>Follow the next steps from the rulebook page 50 !. You can now spend 150 CDPs to customise your character.
</div> </div>