Minor various fixes

This commit is contained in:
sladecraven 2022-11-28 13:58:04 +01:00
parent 7755d87e48
commit 9e70a12b98
5 changed files with 75 additions and 53 deletions

View File

@ -137,12 +137,12 @@ export class PegasusActor extends Actor {
/* -------------------------------------------- */ /* -------------------------------------------- */
getMT() { getMT() {
let modifier = 0 let modifier = 0
for(let effect of this.items) { for (let effect of this.items) {
if (effect.type =="effect" && effect.system.affectstatus && effect.system.affectedstatus =="mt") { if (effect.type == "effect" && effect.system.affectstatus && effect.system.affectedstatus == "mt") {
if ( effect.system.genre == "positive") { if (effect.system.genre == "positive") {
modifier += effect.system.effectlevel modifier += effect.system.effectlevel
} }
if ( effect.system.genre == "negative") { if (effect.system.genre == "negative") {
modifier -= effect.system.effectlevel modifier -= effect.system.effectlevel
} }
} }
@ -153,12 +153,12 @@ export class PegasusActor extends Actor {
/* -------------------------------------------- */ /* -------------------------------------------- */
getKBV() { getKBV() {
let modifier = 0 let modifier = 0
for(let effect of this.items) { for (let effect of this.items) {
if (effect.type =="effect" && effect.system.affectstatus && effect.system.affectedstatus == "kbv") { if (effect.type == "effect" && effect.system.affectstatus && effect.system.affectedstatus == "kbv") {
if ( effect.system.genre == "positive") { if (effect.system.genre == "positive") {
modifier += effect.system.effectlevel modifier += effect.system.effectlevel
} }
if ( effect.system.genre == "negative") { if (effect.system.genre == "negative") {
modifier -= effect.system.effectlevel modifier -= effect.system.effectlevel
} }
} }
@ -509,28 +509,28 @@ export class PegasusActor extends Actor {
let update = { _id: item.id, "system.activated": !item.system.activated } let update = { _id: item.id, "system.activated": !item.system.activated }
await this.updateEmbeddedDocuments('Item', [update]) // Updates one EmbeddedEntity await this.updateEmbeddedDocuments('Item', [update]) // Updates one EmbeddedEntity
} }
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
setHandInformation( info) { setHandInformation(info) {
this.update( {'system.biodata.preferredhand': info} ) this.update({ 'system.biodata.preferredhand': info })
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
increaseRoleAbility() { increaseRoleAbility() {
let role = this.getRole() let role = this.getRole()
let level = role.system.rolelevel + 1 let level = role.system.rolelevel + 1
this.updateEmbeddedDocuments('Item', [ {_id: role.id, 'system.rolelevel': level} ]) this.updateEmbeddedDocuments('Item', [{ _id: role.id, 'system.rolelevel': level }])
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
setBonusInformation( info) { setBonusInformation(info) {
this.update( {'system.biodata.bonusselection': info}) this.update({ 'system.biodata.bonusselection': info })
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
addCDP( value) { addCDP(value) {
let cdp = this.system.biodata.cdp let cdp = this.system.biodata.cdp
cdp += value cdp += value
this.update( {'system.biodata.cdp': cdp}) this.update({ 'system.biodata.cdp': cdp })
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
@ -904,11 +904,11 @@ export class PegasusActor extends Actor {
} }
} }
if (item.type == 'race') { if (item.type == "race") {
this.applyRace(item) this.applyRace(item)
} else if (item.type == 'role') { } else if (item.type == "role") {
this.applyRole(item) this.applyRole(item)
} else if (item.type == 'ability') { } else if (item.type == "ability") {
this.applyAbility(item, [], true) this.applyAbility(item, [], true)
if (!onDrop) { if (!onDrop) {
await this.createEmbeddedDocuments('Item', [item]) await this.createEmbeddedDocuments('Item', [item])
@ -1311,7 +1311,8 @@ export class PegasusActor extends Actor {
/* -------------------------------------------- */ /* -------------------------------------------- */
async deleteAllItemsByType(itemType) { async deleteAllItemsByType(itemType) {
let items = this.items.filter(item => item.type == itemType); let items = this.items.filter(item => item.type == itemType).map(item => item.id)
console.log("Dele....", items)
await this.deleteEmbeddedDocuments('Item', items); await this.deleteEmbeddedDocuments('Item', items);
} }
@ -1493,10 +1494,8 @@ export class PegasusActor extends Actor {
updates['system.biodata.moralitythreshold'] = moralitythreshold updates['system.biodata.moralitythreshold'] = moralitythreshold
} }
if (!this.isToken) { if (!this.isToken) {
if (this.warnMorality != this.system.biodata.morality && this.system.biodata.morality < 0) { if (this.warnMorality != this.system.biodata.morality && this.system.biodata.morality <= 0) {
ChatMessage.create({ content: "WARNING: Your character is dangerously close to becoming corrupted and defeated. Start on a path of redemption!" }) ChatMessage.create({ content: "WARNING: Your character is dangerously close to becoming corrupted and defeated. Start on a path of redemption!" })
}
if (this.warnMorality != this.system.biodata.morality && this.system.biodata.morality == 0) {
ChatMessage.create({ content: "This character can no longer spend CDP until their Morality has reached 1 or higher" }) ChatMessage.create({ content: "This character can no longer spend CDP until their Morality has reached 1 or higher" })
} }
if (this.warnMorality != this.system.biodata.morality) { if (this.warnMorality != this.system.biodata.morality) {
@ -1533,8 +1532,8 @@ export class PegasusActor extends Actor {
this.system.combat.hindrancedice = hindrance this.system.combat.hindrancedice = hindrance
this.getTraumaState() this.getTraumaState()
this.cleanupPerksIfTrauma() this.cleanupPerksIfTrauma()
this.parseStatEffects() await this.parseStatEffects()
this.parseStatusEffects() await this.parseStatusEffects()
} }
} }
@ -1570,11 +1569,13 @@ export class PegasusActor extends Actor {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
parseStatusEffects() { async parseStatusEffects() {
if (this.system.biodata.noautobonus) { // If we are in "no-bonus mode if (this.system.biodata.noautobonus) { // If we are in "no-bonus mode
return return
} }
let effects = this.items.filter(effect => effect.type == "effect" && effect.system.affectstatus && (Number(effect.system.effectlevel) > 0)) let effects = this.items.filter(effect => effect.type == "effect" && effect.system.affectstatus && (Number(effect.system.effectlevel) > 0))
let abilities = this.items.filter(ability => ability.type == "ability" && ability.system.statusaffected != "notapplicable")
for (let statusKey in this.system.secondary) { for (let statusKey in this.system.secondary) {
let status = duplicate(this.system.secondary[statusKey]) let status = duplicate(this.system.secondary[statusKey])
let bonus = 0 let bonus = 0
@ -1583,12 +1584,18 @@ export class PegasusActor extends Actor {
bonus += Number(effect.system.effectlevel) bonus += Number(effect.system.effectlevel)
} }
} }
for (let ability of abilities) {
if (ability.system.statusaffected && ability.system.statusaffected == statusKey) {
bonus += Number(effect.system.statusmodifier)
}
}
if (bonus != status.bonus) { if (bonus != status.bonus) {
status.bonus = bonus status.bonus = bonus
this.update({ [`system.secondary.${statusKey}`]: status }) await this.update({ [`system.secondary.${statusKey}`]: status })
} }
} }
console.log("Ablities", this.name, abilities)
let nrg = duplicate(this.system.nrg) let nrg = duplicate(this.system.nrg)
let bonus = 0 let bonus = 0
for (let effect of effects) { for (let effect of effects) {
@ -1596,11 +1603,15 @@ export class PegasusActor extends Actor {
bonus += Number(effect.system.effectlevel) bonus += Number(effect.system.effectlevel)
} }
} }
for (let ability of abilities) {
if (ability.system.statusaffected && ability.system.statusaffected == "nrg") {
bonus += Number(ability.system.statusmodifier)
}
}
if (bonus != nrg.mod) { if (bonus != nrg.mod) {
nrg.mod = bonus nrg.mod = bonus
this.update({ [`system.nrg`]: nrg }) await this.update({ [`system.nrg`]: nrg })
} }
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
@ -1688,9 +1699,15 @@ export class PegasusActor extends Actor {
ability.system = ability.data ability.system = ability.data
} }
if (ability.system.affectedstat != "notapplicable") { if (ability.system.affectedstat != "notapplicable") {
let stat = duplicate(this.system.statistics[ability.system.affectedstat]) if ( ability.system.affectedstat == "mr") {
stat.mod += Number(ability.system.statmodifier) let stat = duplicate(this.system.mr)
updates[`system.statistics.${ability.system.affectedstat}`] = stat stat.mod += Number(ability.system.statmodifier)
updates[`system.mr`] = stat
} else {
let stat = duplicate(this.system.statistics[ability.system.affectedstat])
stat.mod += Number(ability.system.statmodifier)
updates[`system.statistics.${ability.system.affectedstat}`] = stat
}
} }
// manage status bonus // manage status bonus
if (ability.system.statusaffected != "notapplicable") { if (ability.system.statusaffected != "notapplicable") {
@ -1751,11 +1768,11 @@ export class PegasusActor extends Actor {
/* -------------------------------------------- */ /* -------------------------------------------- */
async applyRace(race) { async applyRace(race) {
let updates = { 'system.biodata.racename': race.name } let updates = { 'system.biodata.racename': race.name }
updates['system.biodata.sizenum'] = race.system.size
let newItems = [] let newItems = []
await this.deleteAllItemsByType('race') await this.deleteAllItemsByType("race")
newItems.push(race); newItems.push(race)
console.log("DROPPED RACE", race)
for (let ability of race.system.abilities) { for (let ability of race.system.abilities) {
if (!ability.system) ability.system = ability.data if (!ability.system) ability.system = ability.data
newItems.push(ability) newItems.push(ability)
@ -1896,11 +1913,11 @@ export class PegasusActor extends Actor {
} }
if (role.name.toLowerCase() == "defender" && subKey == "defence") { if (role.name.toLowerCase() == "defender" && subKey == "defence") {
rollData.effectsList.push({ label: "Defender Role Bonus", type: "effect", applied: true, isdynamic: true, value: this.getRoleLevel() }) rollData.effectsList.push({ label: "Defender Role Bonus", type: "effect", applied: true, isdynamic: true, value: this.getRoleLevel() })
rollData.dicePool = rollData.dicePool.concat(PegasusUtility.buildDicePool("effect-bonus-dice", this.getRoleLevel(), 0,"Defender Role Bonus")) rollData.dicePool = rollData.dicePool.concat(PegasusUtility.buildDicePool("effect-bonus-dice", this.getRoleLevel(), 0, "Defender Role Bonus"))
} }
if (role.name.toLowerCase() == "scrapper" && statKey == "com") { if (role.name.toLowerCase() == "scrapper" && statKey == "com") {
rollData.effectsList.push({ label: "Scrapper Role Bonus", type: "effect", applied: true, isdynamic: true, value: this.getRoleLevel() }) rollData.effectsList.push({ label: "Scrapper Role Bonus", type: "effect", applied: true, isdynamic: true, value: this.getRoleLevel() })
rollData.dicePool = rollData.dicePool.concat(PegasusUtility.buildDicePool("effect-bonus-dice", this.getRoleLevel(), 0,"Scrapper Role Bonus")) rollData.dicePool = rollData.dicePool.concat(PegasusUtility.buildDicePool("effect-bonus-dice", this.getRoleLevel(), 0, "Scrapper Role Bonus"))
} }
} }

View File

@ -580,7 +580,7 @@ export class PegasusActorCreate {
/* -------------------------------------------- */ /* -------------------------------------------- */
async showGlobalSpec() { async showGlobalSpec() {
let formData = this.createFormData("select-global-spec") let formData = this.createFormData("select-global-spec")
let excludedSpecs = this.actor.items.filter(it => it.type == "specialisation" && it.system.level >= 4) let excludedSpecs = this.actor.items.filter(it => it.type == "specialisation" && it.system.level >= 5)
formData.specs = [] formData.specs = []
for (let spec of this.specs) { for (let spec of this.specs) {
let isOK = true let isOK = true

View File

@ -446,6 +446,7 @@
"perksgained": false, "perksgained": false,
"perksall": false, "perksall": false,
"perksnumber": 0, "perksnumber": 0,
"size": 0,
"perks": [], "perks": [],
"perksrole": "", "perksrole": "",
"statistics": "" "statistics": ""

View File

@ -16,25 +16,25 @@
<div class="tab details" data-group="primary" data-tab="details"> <div class="tab details" data-group="primary" data-tab="details">
<ul> <ul>
<li class="flexrow"><label class="generic-label">Affected stat</label> <li class="flexrow"><label class="generic-label">Affected stat</label>
<select class="competence-base flexrow" type="text" name="data.affectedstat" value="{{data.affectedstat}}" data-dtype="String"> <select class="competence-base flexrow" type="text" name="system.affectedstat" value="{{data.affectedstat}}" data-dtype="String">
{{#select data.affectedstat}} {{#select data.affectedstat}}
{{> systems/fvtt-pegasus-rpg/templates/partial-options-statistics.html notapplicable=true mr=false}} {{> systems/fvtt-pegasus-rpg/templates/partial-options-statistics.html notapplicable=true mr=true}}
{{/select}} {{/select}}
</select> </select>
</li> </li>
<li class="flexrow"><label class="generic-label">Stat modifier</label> <li class="flexrow"><label class="generic-label">Stat modifier</label>
<input type="text" class="padd-right" name="data.statmodifier" value="{{data.statmodifier}}" data-dtype="Number"/> <input type="text" class="padd-right" name="system.statmodifier" value="{{data.statmodifier}}" data-dtype="Number"/>
</li> </li>
<li class="flexrow"><label class="generic-label">Affected status</label> <li class="flexrow"><label class="generic-label">Affected status</label>
<select class="competence-base flexrow" type="text" name="data.statusaffected" value="{{data.statusaffected}}" data-dtype="String"> <select class="competence-base flexrow" type="text" name="system.statusaffected" value="{{data.statusaffected}}" data-dtype="String">
{{#select data.statusaffected}} {{#select data.statusaffected}}
{{{optionsStatusList}}} {{{optionsStatusList}}}
{{/select}} {{/select}}
</select> </select>
</li> </li>
<li class="flexrow"><label class="generic-label">Status modifier</label> <li class="flexrow"><label class="generic-label">Status modifier</label>
<input type="text" class="padd-right" name="data.statusmodifier" value="{{data.statusmodifier}}" data-dtype="Number"/> <input type="text" class="padd-right" name="system.statusmodifier" value="{{data.statusmodifier}}" data-dtype="Number"/>
</li> </li>
<li class="flexrow"><label class="generic-label">Effects Gained</label> <li class="flexrow"><label class="generic-label">Effects Gained</label>
@ -45,7 +45,7 @@
</li> </li>
{{#each data.effectsgained as |effect idx|}} {{#each data.effectsgained as |effect idx|}}
<li class="flexrow"> <li class="flexrow">
<label name="data.effectsgained[{{idx}}].name"><a class="view-subitem" data-type="effectsgained" data-index="{{idx}}">{{effect.name}}</a></label> <label name="system.effectsgained[{{idx}}].name"><a class="view-subitem" data-type="effectsgained" data-index="{{idx}}">{{effect.name}}</a></label>
<div class="item-controls padd-left"> <div class="item-controls padd-left">
<a class="item-control delete-subitem padd-left" data-type="effectsgained" data-index="{{idx}}" title="Delete Effect"><i class="fas fa-trash"></i></a> <a class="item-control delete-subitem padd-left" data-type="effectsgained" data-index="{{idx}}" title="Delete Effect"><i class="fas fa-trash"></i></a>
</div> </div>
@ -62,7 +62,7 @@
</li> </li>
{{#each data.powersgained as |power idx|}} {{#each data.powersgained as |power idx|}}
<li class="flexrow"> <li class="flexrow">
<label name="data.powersgained[{{idx}}].name"><a class="view-subitem" data-type="powersgained" data-index="{{idx}}">{{power.name}}</a></label> <label name="system.powersgained[{{idx}}].name"><a class="view-subitem" data-type="powersgained" data-index="{{idx}}">{{power.name}}</a></label>
<div class="item-controls padd-left"> <div class="item-controls padd-left">
<a class="item-control delete-subitem padd-left" data-type="powersgained" data-index="{{idx}}" title="Delete Power"><i class="fas fa-trash"></i></a> <a class="item-control delete-subitem padd-left" data-type="powersgained" data-index="{{idx}}" title="Delete Power"><i class="fas fa-trash"></i></a>
</div> </div>
@ -78,7 +78,7 @@
</li> </li>
{{#each data.specialisations as |spec idx|}} {{#each data.specialisations as |spec idx|}}
<li class="flexrow"> <li class="flexrow">
<label name="data.specialisations[{{idx}}].name"><a class="view-subitem" data-type="specialisations" data-index="{{idx}}">{{spec.name}}</a></label> <label name="system.specialisations[{{idx}}].name"><a class="view-subitem" data-type="specialisations" data-index="{{idx}}">{{spec.name}}</a></label>
<div class="item-controls padd-left"> <div class="item-controls padd-left">
<a class="item-control delete-subitem padd-left" data-type="specialisations" data-index="{{idx}}" title="Delete Specialisation"><i class="fas fa-trash"></i></a> <a class="item-control delete-subitem padd-left" data-type="specialisations" data-index="{{idx}}" title="Delete Specialisation"><i class="fas fa-trash"></i></a>
</div> </div>
@ -89,7 +89,7 @@
</li> </li>
<li class="flexrow"><label class="generic-label">Threat Level Value</label> <li class="flexrow"><label class="generic-label">Threat Level Value</label>
<input type="text" class="input-numeric-short padd-right" name="data.threatlevel" value="{{data.threatlevel}}" data-dtype="Number"/> <input type="text" class="input-numeric-short padd-right" name="system.threatlevel" value="{{data.threatlevel}}" data-dtype="Number"/>
</li> </li>
<li class="flexrow"><label class="generic-label">Attacks Gained</label> <li class="flexrow"><label class="generic-label">Attacks Gained</label>
@ -99,7 +99,7 @@
</li> </li>
{{#each data.attackgained as |weapon idx|}} {{#each data.attackgained as |weapon idx|}}
<li class="flexrow"> <li class="flexrow">
<label name="data.specialisations[{{idx}}].name"><a class="view-subitem" data-type="attackgained" data-index="{{idx}}">{{weapon.name}}</a></label> <label name="system.specialisations[{{idx}}].name"><a class="view-subitem" data-type="attackgained" data-index="{{idx}}">{{weapon.name}}</a></label>
<div class="item-controls padd-left"> <div class="item-controls padd-left">
<a class="item-control delete-subitem padd-left" data-type="attackgained" data-index="{{idx}}" title="Delete Weapon"><i class="fas fa-trash"></i></a> <a class="item-control delete-subitem padd-left" data-type="attackgained" data-index="{{idx}}" title="Delete Weapon"><i class="fas fa-trash"></i></a>
</div> </div>
@ -116,7 +116,7 @@
</li> </li>
{{#each data.armorgained as |armor idx|}} {{#each data.armorgained as |armor idx|}}
<li class="flexrow"> <li class="flexrow">
<label name="data.specialisations[{{idx}}].name"><a class="view-subitem" data-type="armorgained" data-index="{{idx}}">{{armor.name}}</a></label> <label name="dasystema.specialisations[{{idx}}].name"><a class="view-subitem" data-type="armorgained" data-index="{{idx}}">{{armor.name}}</a></label>
<div class="item-controls padd-left"> <div class="item-controls padd-left">
<a class="item-control delete-subitem padd-left" data-type="armorgained" data-index="{{idx}}" title="Delete Armor"><i class="fas fa-trash"></i></a> <a class="item-control delete-subitem padd-left" data-type="armorgained" data-index="{{idx}}" title="Delete Armor"><i class="fas fa-trash"></i></a>
</div> </div>

View File

@ -14,19 +14,19 @@
<label class="generic-label">Description</label> <label class="generic-label">Description</label>
<div class="medium-editor item-text-long-line"> <div class="medium-editor item-text-long-line">
{{editor data.description target="data.description" button=true owner=owner editable=editable}} {{editor description target="system.description" button=true owner=owner editable=editable}}
</div> </div>
<label class="generic-label">Environment</label> <label class="generic-label">Environment</label>
<div class="medium-editor item-text-long-line"> <div class="medium-editor item-text-long-line">
{{editor data.environment target="data.environment" button=true owner=owner editable=editable}} {{editor data.environment target="system.environment" button=true owner=owner editable=editable}}
</div> </div>
<label class="generic-label">Society/Culture</label> <label class="generic-label">Society/Culture</label>
<div class="medium-editor item-text-long-line"> <div class="medium-editor item-text-long-line">
{{editor data.society_culture target="data.society_culture" button=true owner=owner editable=editable}} {{editor data.society_culture target="system.society_culture" button=true owner=owner editable=editable}}
</div> </div>
<label class="generic-label">Outlook</label> <label class="generic-label">Outlook</label>
<div class="medium-editor item-text-long-line"> <div class="medium-editor item-text-long-line">
{{editor data.outlook target="data.outlook" button=true owner=owner editable=editable}} {{editor data.outlook target="system.outlook" button=true owner=owner editable=editable}}
</div> </div>
</div> </div>
@ -52,6 +52,10 @@
</ul> </ul>
<ul> <ul>
<li class="flexrow">
<label class="generic-label">Size</label>
<input type="text" class="input-numeric-short padd-right" name="system.size" value="{{data.size}}" data-dtype="Number"/>
</li>
<li class="flexrow"><label class="generic-label">Selectable Stats ?</label> <li class="flexrow"><label class="generic-label">Selectable Stats ?</label>
<label class="attribute-value checkbox"><input type="checkbox" name="system.selectablestats" {{checked <label class="attribute-value checkbox"><input type="checkbox" name="system.selectablestats" {{checked
system.selectablestats}} /></label> system.selectablestats}} /></label>