Fix #31 - Global perl select
This commit is contained in:
parent
cc0dc9e43c
commit
dad117fc17
@ -194,12 +194,12 @@ export class PegasusActor extends Actor {
|
|||||||
let comp = this.items.filter(item => item.type == 'vehiclemodule');
|
let comp = this.items.filter(item => item.type == 'vehiclemodule');
|
||||||
return comp;
|
return comp;
|
||||||
}
|
}
|
||||||
getVehicleWeaponModules( activated = false ) {
|
getVehicleWeaponModules(activated = false) {
|
||||||
let comp = []
|
let comp = []
|
||||||
if (activated ) {
|
if (activated) {
|
||||||
comp = this.items.filter(item => item.type == 'vehicleweaponmodule' && item.system.activated)
|
comp = this.items.filter(item => item.type == 'vehicleweaponmodule' && item.system.activated)
|
||||||
} else {
|
} else {
|
||||||
comp = this.items.filter(item => item.type == 'vehicleweaponmodule' )
|
comp = this.items.filter(item => item.type == 'vehicleweaponmodule')
|
||||||
}
|
}
|
||||||
return comp;
|
return comp;
|
||||||
}
|
}
|
||||||
@ -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() {
|
||||||
@ -755,10 +775,10 @@ export class PegasusActor extends Actor {
|
|||||||
ui.notifications.warn("Container is already full !")
|
ui.notifications.warn("Container is already full !")
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
this.updateEmbeddedDocuments( "Item", [{ _id: object.id, 'system.containerid':containerId }])
|
this.updateEmbeddedDocuments("Item", [{ _id: object.id, 'system.containerid': containerId }])
|
||||||
}
|
}
|
||||||
} else if (object && object.system.containerid) { // remove from container
|
} else if (object && object.system.containerid) { // remove from container
|
||||||
this.updateEmbeddedDocuments( "Item", [{ _id: object.id, 'system.containerid':"" }])
|
this.updateEmbeddedDocuments("Item", [{ _id: object.id, 'system.containerid': "" }])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1478,7 +1498,7 @@ export class PegasusActor extends Actor {
|
|||||||
}
|
}
|
||||||
if (bonus != stat.bonuseffect) {
|
if (bonus != stat.bonuseffect) {
|
||||||
stat.bonuseffect = bonus
|
stat.bonuseffect = bonus
|
||||||
if ( stat.bonuseffect + stat.value < 1) {
|
if (stat.bonuseffect + stat.value < 1) {
|
||||||
stat.value = 1
|
stat.value = 1
|
||||||
stat.bonuseffect = 0
|
stat.bonuseffect = 0
|
||||||
}
|
}
|
||||||
@ -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)
|
||||||
@ -2257,12 +2290,12 @@ export class PegasusActor extends Actor {
|
|||||||
}
|
}
|
||||||
if (bonus != stat.bonuseffect) {
|
if (bonus != stat.bonuseffect) {
|
||||||
stat.bonuseffect = bonus
|
stat.bonuseffect = bonus
|
||||||
if ( stat.bonuseffect + stat.level < 1) {
|
if (stat.bonuseffect + stat.level < 1) {
|
||||||
stat.level = 1
|
stat.level = 1
|
||||||
stat.bonuseffect = 0
|
stat.bonuseffect = 0
|
||||||
}
|
}
|
||||||
if (stat.currentlevel > stat.bonuseffect+stat.level) {
|
if (stat.currentlevel > stat.bonuseffect + stat.level) {
|
||||||
stat.currentlevel = stat.bonuseffect+stat.level
|
stat.currentlevel = stat.bonuseffect + stat.level
|
||||||
}
|
}
|
||||||
this.update({ [`system.statistics.${statKey}`]: stat })
|
this.update({ [`system.statistics.${statKey}`]: stat })
|
||||||
}
|
}
|
||||||
@ -2409,9 +2442,9 @@ export class PegasusActor extends Actor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// NRG max management
|
// NRG max management
|
||||||
if (item.type == "powercoremodule" ) {
|
if (item.type == "powercoremodule") {
|
||||||
if (this.system.statistics.pc.maxnrg != item.system.nrg ) {
|
if (this.system.statistics.pc.maxnrg != item.system.nrg) {
|
||||||
this.update( {'system.statistics.pc.maxnrg': item.system.nrg })
|
this.update({ 'system.statistics.pc.maxnrg': item.system.nrg })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2545,7 +2578,7 @@ export class PegasusActor extends Actor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async addVehicleModuleEffects( mod) {
|
async addVehicleModuleEffects(mod) {
|
||||||
let effects = []
|
let effects = []
|
||||||
for (let effect of mod.system.effects) {
|
for (let effect of mod.system.effects) {
|
||||||
if (!effect.system) {
|
if (!effect.system) {
|
||||||
@ -2559,7 +2592,7 @@ export class PegasusActor extends Actor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async removeVehicleModuleEffects( mod) {
|
async removeVehicleModuleEffects(mod) {
|
||||||
let toRem = []
|
let toRem = []
|
||||||
for (let item of this.items) {
|
for (let item of this.items) {
|
||||||
if (item.type == 'effect' && item.system.effectId == mod.id) {
|
if (item.type == 'effect' && item.system.effectId == mod.id) {
|
||||||
@ -2597,7 +2630,7 @@ export class PegasusActor extends Actor {
|
|||||||
this.removeVehicleModuleEffects(mod)
|
this.removeVehicleModuleEffects(mod)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ( mod.system.activated) {
|
if (mod.system.activated) {
|
||||||
this.removeVehicleModuleEffects(mod)
|
this.removeVehicleModuleEffects(mod)
|
||||||
} else {
|
} else {
|
||||||
this.addVehicleModuleEffects(mod)
|
this.addVehicleModuleEffects(mod)
|
||||||
@ -2627,7 +2660,7 @@ export class PegasusActor extends Actor {
|
|||||||
let lvChanged = level - arc.maxshieldlevel
|
let lvChanged = level - arc.maxshieldlevel
|
||||||
arc.maxshieldlevel = level
|
arc.maxshieldlevel = level
|
||||||
arc.shieldlevel += lvChanged
|
arc.shieldlevel += lvChanged
|
||||||
if ( arc.shieldlevel <= 0 || arc.shieldlevel > level) {
|
if (arc.shieldlevel <= 0 || arc.shieldlevel > level) {
|
||||||
arc.shieldlevel = level
|
arc.shieldlevel = level
|
||||||
}
|
}
|
||||||
setTimeout(shift, this.update({ [`system.arcs.${arcKey}`]: arc }))
|
setTimeout(shift, this.update({ [`system.arcs.${arcKey}`]: arc }))
|
||||||
@ -2650,7 +2683,7 @@ export class PegasusActor extends Actor {
|
|||||||
let lvChanged = level - arc.maxarmourlevel
|
let lvChanged = level - arc.maxarmourlevel
|
||||||
arc.maxarmourlevel = level
|
arc.maxarmourlevel = level
|
||||||
arc.armourlevel += lvChanged
|
arc.armourlevel += lvChanged
|
||||||
if ( arc.armourlevel <= 0 || arc.armourlevel > arc.maxarmourlevel) {
|
if (arc.armourlevel <= 0 || arc.armourlevel > arc.maxarmourlevel) {
|
||||||
arc.armourlevel = level
|
arc.armourlevel = level
|
||||||
}
|
}
|
||||||
setTimeout(500, this.update({ [`system.arcs.${arcKey}`]: arc }))
|
setTimeout(500, this.update({ [`system.arcs.${arcKey}`]: arc }))
|
||||||
@ -2659,7 +2692,7 @@ export class PegasusActor extends Actor {
|
|||||||
}
|
}
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
updateMaxNrg(currentLevel) {
|
updateMaxNrg(currentLevel) {
|
||||||
this.update({ 'system.statistics.pc.maxnrg': Number( PegasusUtility.getDiceValue(currentLevel) ) })
|
this.update({ 'system.statistics.pc.maxnrg': Number(PegasusUtility.getDiceValue(currentLevel)) })
|
||||||
}
|
}
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
setTurningArc(currentLevel) {
|
setTurningArc(currentLevel) {
|
||||||
|
@ -191,11 +191,11 @@ export class PegasusActorCreate {
|
|||||||
let excludedPerks = this.actor.items.filter(it => it.type == "perk" && !it.system.upgradable)
|
let excludedPerks = this.actor.items.filter(it => it.type == "perk" && !it.system.upgradable)
|
||||||
this.rolePerks = []
|
this.rolePerks = []
|
||||||
for (let perk of this.rolePerks) {
|
for (let perk of this.rolePerks) {
|
||||||
if ( !excludedPerks.find(it => it.name == perk.name)) {
|
if (!excludedPerks.find(it => it.name == perk.name)) {
|
||||||
this.rolePerks.push(perk)
|
this.rolePerks.push(perk)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.rolePerks.sort(function(a, b) { if (a.name < b.name) {return -1} else {return 1} })
|
this.rolePerks.sort(function (a, b) { if (a.name < b.name) { return -1 } else { return 1 } })
|
||||||
this.nbPerks--;
|
this.nbPerks--;
|
||||||
if (this.nbPerks == 0 || this.rolePerks.length == 0) {
|
if (this.nbPerks == 0 || this.rolePerks.length == 0) {
|
||||||
this.nbGlobalSpec = 5
|
this.nbGlobalSpec = 5
|
||||||
@ -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
@ -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>
|
||||||
|
Loading…
Reference in New Issue
Block a user