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

@ -194,12 +194,12 @@ export class PegasusActor extends Actor {
let comp = this.items.filter(item => item.type == 'vehiclemodule');
return comp;
}
getVehicleWeaponModules( activated = false ) {
getVehicleWeaponModules(activated = false) {
let comp = []
if (activated ) {
if (activated) {
comp = this.items.filter(item => item.type == 'vehicleweaponmodule' && item.system.activated)
} else {
comp = this.items.filter(item => item.type == 'vehicleweaponmodule' )
comp = this.items.filter(item => item.type == 'vehicleweaponmodule')
}
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') })
}
}
/* -------------------------------------------- */
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() {
@ -755,13 +775,13 @@ export class PegasusActor extends Actor {
ui.notifications.warn("Container is already full !")
return
} 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
this.updateEmbeddedDocuments( "Item", [{ _id: object.id, 'system.containerid':"" }])
this.updateEmbeddedDocuments("Item", [{ _id: object.id, 'system.containerid': "" }])
}
}
/* -------------------------------------------- */
checkVirtue(virtue) {
let vices = this.getVices()
@ -794,7 +814,7 @@ export class PegasusActor extends Actor {
console.log("Pre-process", item)
if (!item) {
return
return
}
if (item.type != "effect" && __isVehicle[item.type]) {
ui.notifications.warn("You can't drop Vehicles item over a character sheet.")
@ -1478,7 +1498,7 @@ export class PegasusActor extends Actor {
}
if (bonus != stat.bonuseffect) {
stat.bonuseffect = bonus
if ( stat.bonuseffect + stat.value < 1) {
if (stat.bonuseffect + stat.value < 1) {
stat.value = 1
stat.bonuseffect = 0
}
@ -1536,6 +1556,19 @@ export class PegasusActor extends Actor {
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) {
console.log("Using spec : ", spec, inc)
@ -1853,10 +1886,10 @@ export class PegasusActor extends Actor {
ChatMessage.create({ content: `${vehicle.name} is moving at Slow speed : add a D4 to your Attack Dice Pool against this Vehicle` })
}
}
if (this.type == "vehicle" && rollData.statKey == "man" && this.system.statistics.ad.currentspeed == "fast") {
if (this.type == "vehicle" && rollData.statKey == "man" && this.system.statistics.ad.currentspeed == "fast") {
ChatMessage.create({ content: `${this.name} is moving at Fast speed : anyone using the vehicles MAN Dice Pool suffers a D8 Hindrance which is added to the Difficulty Dice Pool against this Vehicle` })
}
if (this.type == "vehicle" && rollData.statKey == "man" && this.system.statistics.ad.currentspeed == "extfast") {
if (this.type == "vehicle" && rollData.statKey == "man" && this.system.statistics.ad.currentspeed == "extfast") {
ChatMessage.create({ content: `${this.name} is moving at Extremely Fast speed : anyone using the vehicles MAN Dice Pool suffers a D12 Hindrance which is added to the Difficulty Dice Pool against this Vehicle` })
}
if (rollData.subKey == "defence" && rollData.vehicle && rollData.vehicle.system.statistics.ad.currentspeed == "crawling") {
@ -1865,7 +1898,7 @@ export class PegasusActor extends Actor {
if (rollData.subKey == "defence" && rollData.vehicle && rollData.vehicle.system.statistics.ad.currentspeed == "slow") {
ChatMessage.create({ content: `${this.name} is moving at Slow speed : add a D4 to your Attack Dice Pool against this Vehicle` })
}
}
}
}
/* -------------------------------------------- */
@ -2257,15 +2290,15 @@ export class PegasusActor extends Actor {
}
if (bonus != stat.bonuseffect) {
stat.bonuseffect = bonus
if ( stat.bonuseffect + stat.level < 1) {
if (stat.bonuseffect + stat.level < 1) {
stat.level = 1
stat.bonuseffect = 0
}
if (stat.currentlevel > stat.bonuseffect+stat.level) {
stat.currentlevel = stat.bonuseffect+stat.level
if (stat.currentlevel > stat.bonuseffect + stat.level) {
stat.currentlevel = stat.bonuseffect + stat.level
}
this.update({ [`system.statistics.${statKey}`]: stat })
}
}
}
}
@ -2409,12 +2442,12 @@ export class PegasusActor extends Actor {
}
}
// NRG max management
if (item.type == "powercoremodule" ) {
if (this.system.statistics.pc.maxnrg != item.system.nrg ) {
this.update( {'system.statistics.pc.maxnrg': item.system.nrg })
if (item.type == "powercoremodule") {
if (this.system.statistics.pc.maxnrg != item.system.nrg) {
this.update({ 'system.statistics.pc.maxnrg': item.system.nrg })
}
}
// Cargo management
if (__isVehicleCargo[item.type]) {
let capacity = this.getCurrentCargoCapacity()
@ -2545,7 +2578,7 @@ export class PegasusActor extends Actor {
}
/* -------------------------------------------- */
async addVehicleModuleEffects( mod) {
async addVehicleModuleEffects(mod) {
let effects = []
for (let effect of mod.system.effects) {
if (!effect.system) {
@ -2559,7 +2592,7 @@ export class PegasusActor extends Actor {
}
}
/* -------------------------------------------- */
async removeVehicleModuleEffects( mod) {
async removeVehicleModuleEffects(mod) {
let toRem = []
for (let item of this.items) {
if (item.type == 'effect' && item.system.effectId == mod.id) {
@ -2597,7 +2630,7 @@ export class PegasusActor extends Actor {
this.removeVehicleModuleEffects(mod)
}
} else {
if ( mod.system.activated) {
if (mod.system.activated) {
this.removeVehicleModuleEffects(mod)
} else {
this.addVehicleModuleEffects(mod)
@ -2627,7 +2660,7 @@ export class PegasusActor extends Actor {
let lvChanged = level - arc.maxshieldlevel
arc.maxshieldlevel = level
arc.shieldlevel += lvChanged
if ( arc.shieldlevel <= 0 || arc.shieldlevel > level) {
if (arc.shieldlevel <= 0 || arc.shieldlevel > level) {
arc.shieldlevel = level
}
setTimeout(shift, this.update({ [`system.arcs.${arcKey}`]: arc }))
@ -2650,7 +2683,7 @@ export class PegasusActor extends Actor {
let lvChanged = level - arc.maxarmourlevel
arc.maxarmourlevel = level
arc.armourlevel += lvChanged
if ( arc.armourlevel <= 0 || arc.armourlevel > arc.maxarmourlevel) {
if (arc.armourlevel <= 0 || arc.armourlevel > arc.maxarmourlevel) {
arc.armourlevel = level
}
setTimeout(500, this.update({ [`system.arcs.${arcKey}`]: arc }))
@ -2659,7 +2692,7 @@ export class PegasusActor extends Actor {
}
/* -------------------------------------------- */
updateMaxNrg(currentLevel) {
this.update({ 'system.statistics.pc.maxnrg': Number( PegasusUtility.getDiceValue(currentLevel) ) })
this.update({ 'system.statistics.pc.maxnrg': Number(PegasusUtility.getDiceValue(currentLevel)) })
}
/* -------------------------------------------- */
setTurningArc(currentLevel) {

View File

@ -191,11 +191,11 @@ export class PegasusActorCreate {
let excludedPerks = this.actor.items.filter(it => it.type == "perk" && !it.system.upgradable)
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.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--;
if (this.nbPerks == 0 || this.rolePerks.length == 0) {
this.nbGlobalSpec = 5
@ -239,12 +239,26 @@ export class PegasusActorCreate {
this.actor.addIncPerk(perk, 1)
this.nbGlobalPerk--;
if (this.nbGlobalPerk == 0) {
this.showCharacterEnd()
this.nbGlobalStatus = 1
this.showGlobalStatus()
//this.showCharacterEnd()
} else {
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()
}
}
}
@ -492,7 +506,16 @@ export class PegasusActorCreate {
formData.perks.sort(function compare(a, b) { if (a.name < b.name) { return -1 } else { return 1 } })
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() {
await this.actor.computeNRGHealth()

File diff suppressed because one or more lines are too long

View File

@ -160,6 +160,32 @@
</table>
{{/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")}}
<div>Follow the next steps from the rulebook page 50 !. You can now spend 150 CDPs to customise your character.
</div>