Compare commits

..

5 Commits

Author SHA1 Message Date
d5f27ae9ea Manage hindrance dices 2023-09-13 08:06:08 +02:00
b81e5ec17e Switch to v11 2023-09-11 20:35:03 +02:00
6a3cb66391 Switch to v11 2023-09-11 20:34:33 +02:00
ba50c86800 Addd gitignore 2023-09-11 20:34:15 +02:00
8cc2380f0a Sync compendiums 2022-11-30 12:00:09 +01:00
18 changed files with 392 additions and 152 deletions

14
.gitignore vendored Normal file
View File

@ -0,0 +1,14 @@
.vscode/settings.json
.idea
.history
todo.md
/.vscode
/ignored/
/node_modules/
/jsconfig.json
/package.json
/package-lock.json
/packs/*/
/packs/*/CURRENT
/packs/*/LOG
/packs/*/LOCK

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

View File

@ -1,25 +1,28 @@
{
"ITEM": {
"TypeRace": "Race",
"TypeRole": "Role",
"TypeAbility": "Ability",
"TypeSpecialisation": "Specialisation",
"TypePerk": "Perk",
"TypePower": "Power",
"TypeArmor": "Armor",
"TypeShield": "Shield",
"TypeEquipment": "Equipment",
"TypeWeapon": "Weapon",
"TypeEffect": "Effect",
"TypeMoney": "Money",
"TypeVirtue": "Virtue",
"TypeVice": "Vice",
"TypeVehiclehull": "Vehicule Hull",
"TypePowercoremodule": "Power Core Module",
"TypeMobilitymodule": "Mobility Module",
"TypeCombatmodule": "Combat Module",
"TypeVehiclemodule": "Vehicle Module",
"TypeVehicleweaponmodule" : "Vehicle Weapon Module",
"TypePropulsionmodule": "Propulsion module"
}
"TYPES": {
"Item": {
"Race": "Race",
"Role": "Role",
"Ability": "Ability",
"Specialisation": "Specialisation",
"Perk": "Perk",
"Power": "Power",
"Armor": "Armor",
"Shield": "Shield",
"Equipment": "Equipment",
"Weapon": "Weapon",
"Effect": "Effect",
"Money": "Money",
"Virtue": "Virtue",
"Vice": "Vice",
"Vehiclehull": "Vehicule Hull",
"Powercoremodule": "Power Core Module",
"Mobilitymodule": "Mobility Module",
"Combatmodule": "Combat Module",
"Vehiclemodule": "Vehicle Module",
"Vehicleweaponmodule" : "Vehicle Weapon Module",
"Propulsionmodule": "Propulsion module"
}
}
}

View File

@ -41,6 +41,7 @@ export class PegasusActorSheet extends ActorSheet {
effects: this.object.effects.map(e => foundry.utils.deepClone(e.data)),
limited: this.object.limited,
specs: this.actor.getSpecs( ),
config: game.system.pegasus.config,
optionsDiceList: PegasusUtility.getOptionsDiceList(),
optionsLevel: PegasusUtility.getOptionsLevel(),
weapons: this.actor.checkAndPrepareEquipments( duplicate(this.actor.getWeapons()) ),
@ -53,7 +54,7 @@ export class PegasusActorSheet extends ActorSheet {
powers: duplicate(this.actor.getPowers()),
subActors: duplicate(this.actor.getSubActors()),
race: duplicate(this.actor.getRace()),
role: duplicate(this.actor.getRole()),
role: this.actor.getRole(),
effects: duplicate(this.actor.getEffects()),
moneys: duplicate(this.actor.getMoneys()),
virtues: duplicate(this.actor.getVirtues()),

View File

@ -112,6 +112,14 @@ export class PegasusActor extends Actor {
/* -------------------------------------------- */
prepareDerivedData() {
if (this.system.secondary.stealthhealth) {
this.update({ "system.secondary": { "-=stealthhealth": null } })
}
if (this.system.secondary.socialhealth) {
this.update({ "system.secondary": { "-=socialhealth": null } })
}
if (!this.traumaState) {
this.traumaState = "none"
}
@ -275,8 +283,8 @@ export class PegasusActor extends Actor {
return race[0] ?? [];
}
getRole() {
let role = this.items.filter(item => item.type == 'role')
return role[0] ?? [];
let role = this.items.find(item => item.type == 'role')
return role;
}
/* -------------------------------------------- */
getRoleLevel() {
@ -668,7 +676,7 @@ export class PegasusActor extends Actor {
for (let spec of specThreat) {
tl += PegasusUtility.getDiceValue(spec.system.level)
}
tl += this.system.nrg.absolutemax + this.system.secondary.health.max + this.system.secondary.delirium.max
tl += this.system.nrg.absolutemax /* NO MORE USED + this.system.secondary.health.max + this.system.secondary.delirium.max*/
tl += this.getPerks().length * 5
let weapons = this.getWeapons()
@ -758,10 +766,11 @@ export class PegasusActor extends Actor {
/* -------------------------------------------- */
modifyStun(incDec) {
let combat = duplicate(this.system.combat)
let myself = this
let combat = duplicate(myself.system.combat)
combat.stunlevel += incDec
if (combat.stunlevel >= 0) {
this.update({ 'system.combat': combat })
myself.update({ 'system.combat': combat })
let chatData = {
user: game.user.id,
rollMode: game.settings.get("core", "rollMode"),
@ -780,11 +789,12 @@ export class PegasusActor extends Actor {
if (stunAbove > 0) {
ChatMessage.create({ content: `${this.name} Stun threshold has been exceeded.` })
}
/* NO MORE AUTOMATION HERE
if (incDec > 0 && stunAbove > 0) {
let delirium = duplicate(this.system.secondary.delirium)
let delirium = duplicate(myself.system.secondary.delirium)
delirium.value -= incDec
this.update({ 'system.secondary.delirium': delirium })
}
myself.update({ 'system.secondary.delirium': delirium })
}*/
}
/* -------------------------------------------- */
@ -949,7 +959,7 @@ export class PegasusActor extends Actor {
async equipGear(equipmentId) {
let item = this.items.find(item => item.id == equipmentId);
if (item && item.system) {
let update = { _id: item.id, "data.equipped": !item.system.equipped };
let update = { _id: item.id, "system.equipped": !item.system.equipped };
await this.updateEmbeddedDocuments('Item', [update]); // Updates one EmbeddedEntity
}
}
@ -1144,7 +1154,7 @@ export class PegasusActor extends Actor {
async updatePerkUsed(itemId, index, checked) {
let item = this.items.get(itemId)
if (item && index) {
let key = "data.used" + index
let key = "system.used" + index
await this.updateEmbeddedDocuments('Item', [{ _id: itemId, [`${key}`]: checked }])
item = this.items.get(itemId) // Refresh
if (item.system.nbuse == "next1action" && item.system.used1) {
@ -1236,6 +1246,7 @@ export class PegasusActor extends Actor {
nrg.max += item.system.features.nrgcost.value
await this.update({ 'system.nrg': nrg })
}
/* NO MORE USED
if (item.system.features.bonushealth.flag) {
let health = duplicate(this.system.secondary.health)
health.value -= Number(item.system.features.bonushealth.value) || 0
@ -1253,7 +1264,7 @@ export class PegasusActor extends Actor {
nrg.value -= Number(item.system.features.bonusnrg.value) || 0
nrg.max -= Number(item.system.features.bonusnrg.value) || 0
await this.update({ 'system.nrg': nrg })
}
}*/
this.disableWeaverPerk(item)
PegasusUtility.createChatWithRollMode(item.name, {
content: await renderTemplate(`systems/fvtt-pegasus-rpg/templates/chat-perk-ready.html`, { name: this.name, perk: duplicate(item) })
@ -1286,6 +1297,7 @@ export class PegasusActor extends Actor {
ui.notifications.warn("Not enough NRG to activate the Perk " + item.name)
}
}
/* NO MORE USED
if (item.system.features.bonushealth.flag) {
let health = duplicate(this.system.secondary.health)
health.value += Number(item.system.features.bonushealth.value) || 0
@ -1297,7 +1309,7 @@ export class PegasusActor extends Actor {
delirium.value += Number(item.system.features.bonusdelirium.value) || 0
delirium.max += Number(item.system.features.bonusdelirium.value) || 0
await this.update({ 'system.secondary.delirium': delirium })
}
}*/
if (item.system.features.bonusnrg.flag) {
let nrg = duplicate(this.system.nrg)
nrg.value += Number(item.system.features.bonusnrg.value) || 0
@ -1334,14 +1346,11 @@ export class PegasusActor extends Actor {
getTraumaState() {
this.traumaState = "none"
if (this.type == "character") {
let negDelirium = -Math.floor((this.system.secondary.delirium.max + 1) / 2)
if (this.type == "character") {
if (this.system.secondary.delirium.value <= 0 && this.system.secondary.delirium.value >= negDelirium) {
this.traumaState = "trauma"
}
if (this.system.secondary.delirium.value < negDelirium) {
this.traumaState = "severetrauma"
}
if (this.system.secondary.delirium.status == "trauma") {
this.traumaState = "trauma"
}
if (this.system.secondary.delirium.status == "severetrauma" || this.system.secondary.delirium.status == "defeated") {
this.traumaState = "severetrauma"
}
}
return this.traumaState
@ -1438,6 +1447,7 @@ export class PegasusActor extends Actor {
if (this.isOwner || game.user.isGM) {
let updates = {}
/* No more used
let phyDiceValue = PegasusUtility.getDiceValue(this.system.statistics.phy.value) + this.system.secondary.health.bonus + this.system.statistics.phy.mod + PegasusUtility.getDiceValue(this.system.statistics.phy.bonuseffect);
if (phyDiceValue != this.system.secondary.health.max) {
updates['system.secondary.health.max'] = phyDiceValue
@ -1466,7 +1476,7 @@ export class PegasusActor extends Actor {
}
if (this.computeValue) {
updates['system.secondary.socialhealth.value'] = socDiceValue
}
}*/
let nrgValue = PegasusUtility.getDiceValue(this.system.statistics.foc.value) + this.system.nrg.mod + this.system.statistics.foc.mod + PegasusUtility.getDiceValue(this.system.statistics.foc.bonuseffect)
if (nrgValue != this.system.nrg.absolutemax) {
@ -1510,11 +1520,11 @@ export class PegasusActor extends Actor {
}
let race = this.getRace()
if (race && race.name && (race.name != this.system.biodata.racename)) {
if (race?.name && (race.name != this.system.biodata.racename)) {
updates['system.biodata.racename'] = race.name
}
let role = this.getRole()
if (role && role.name && (role.name != this.system.biodata.rolename)) {
if (role?.name && (role.name != this.system.biodata.rolename)) {
updates['system.biodata.rolename'] = role.name
}
if (Object.entries(updates).length > 0) {
@ -1527,22 +1537,91 @@ export class PegasusActor extends Actor {
// Update current hindrance level
let hindrance = this.system.combat.hindrancedice
if (!this.checkIgnoreHealth()) {
if (this.system.secondary.health.value < 0) {
if (this.system.secondary.health.value < -Math.floor((this.system.secondary.health.max + 1) / 2)) { // Severe wounded
hindrance += 3
} else {
hindrance += 1
}
if (this.system.secondary.health.status == "wounded") {
hindrance += 1
}
if (this.system.secondary.health.status == "severlywounded" || this.system.secondary.health.status == "defeated") {
hindrance += 3
}
}
this.system.combat.hindrancedice = hindrance
this.getTraumaState()
this.cleanupPerksIfTrauma()
await this.parseStatEffects()
this.parseStatEffects()
this.parseDamageValues()
await this.parseStatusEffects()
}
}
/* -------------------------------------------- */
getArmorResistanceBonus() {
let bonus = 0
for (let a of armors) {
bonus += Number(a.system.resistance)
}
return bonus
}
/* -------------------------------------------- */
parseDamageValues() {
if (this.system.biodata.noautobonus) { // If we are in "no-bonus mode
return
}
let updates = []
let role = this.getRole() // Get the role for optionnal bonuses
let roleBonus = 0
/* Get MDL bonus */
let meleeBonus = 0
let effects = this.items.filter(effect => effect.type == "effect" && effect.system.affectstatus && effect.system.affectstatus == "mdl" && (Number(effect.system.effectlevel) > 0))
for (let e of effects) {
meleeBonus += Number(e.system.effectlevel)
}
let weaponsMelee = this.items.filter(it => it.type == "weapon" && it.system.damagestatistic.toLowerCase() == "str")
for (let w of weaponsMelee) {
let damage = Number(w.system.damage) + this.system.biodata.sizenum + this.system.biodata.sizebonus + this.system.statistics.str.value + this.system.statistics.str.bonuseffect + meleeBonus
if (damage != w.system.mdl) {
updates.push({ _id: w.id, "system.mdl": damage })
}
}
let rangedBonus = 0
effects = this.items.filter(effect => effect.type == "effect" && effect.system.affectstatus && effect.system.affectstatus == "rdl" && (Number(effect.system.effectlevel) > 0))
for (let e of effects) {
rangedBonus += Number(e.system.effectlevel)
}
if (role?.name?.toLowerCase() == "ranged") { // Add ranged bonus to ADRL
roleBonus = this.getRoleLevel()
}
let weaponsRanged = this.items.filter(it => it.type == "weapon" && it.system.damagestatistic.toLowerCase() == "pre")
for (let w of weaponsRanged) {
let damage = roleBonus + Number(w.system.damage) + rangedBonus
if (damage != w.system.rdl) {
updates.push({ _id: w.id, "system.rdl": damage })
}
}
let armorBonus = 0
effects = this.items.filter(effect => effect.type == "effect" && effect.system.affectstatus && effect.system.affectstatus == " adrl" && (Number(effect.system.effectlevel) > 0))
for (let e of effects) {
armorBonus += Number(e.system.effectlevel)
}
roleBonus = 0
if (role?.name?.toLowerCase() == "defender") { // Add defender bonus to ADRL
roleBonus = this.getRoleLevel()
}
let armors = this.items.filter(it => it.type == "armor")
for (let a of armors) {
let adrl = roleBonus + this.system.statistics.phy.value + this.system.statistics.phy.bonuseffect + this.system.biodata.sizenum + this.system.biodata.sizebonus + a.system.resistance + armorBonus
if (adrl != a.system.adrl) {
updates.push({ _id: a.id, "system.adrl": adrl })
}
}
if (updates.length > 0) {
this.updateEmbeddedDocuments('Item', updates)
}
}
/* -------------------------------------------- */
parseStatEffects() {
if (this.system.biodata.noautobonus) { // If we are in "no-bonus mode
@ -1623,7 +1702,7 @@ export class PegasusActor extends Actor {
async modStat(key, inc = 1) {
let stat = duplicate(this.system.statistics[key])
stat.mod += parseInt(inc)
await this.update({ [`data.statistics.${key}`]: stat })
await this.update({ [`system.statistics.${key}`]: stat })
}
/* -------------------------------------------- */
@ -1631,7 +1710,7 @@ export class PegasusActor extends Actor {
key = key.toLowerCase()
let stat = duplicate(this.system.statistics[key])
stat.value += parseInt(inc)
await this.update({ [`data.statistics.${key}`]: stat })
await this.update({ [`system.statistics.${key}`]: stat })
}
/* -------------------------------------------- */
@ -1639,11 +1718,11 @@ export class PegasusActor extends Actor {
if (key == "nrg") {
let nrg = duplicate(this.system.nrg)
nrg.mod += parseInt(inc)
await this.update({ [`data.nrg`]: nrg })
await this.update({ [`system.nrg`]: nrg })
} else {
let status = duplicate(this.system.secondary[key])
status.bonus += parseInt(inc)
await this.update({ [`data.secondary.${key}`]: status })
await this.update({ [`system.secondary.${key}`]: status })
}
}
@ -1682,7 +1761,7 @@ export class PegasusActor extends Actor {
if (objetQ) {
let newQ = objetQ.system.quantity + incDec
if (newQ >= 0) {
const updated = await this.updateEmbeddedDocuments('Item', [{ _id: objetQ.id, 'system.quantity': newQ }]) // pdates one EmbeddedEntity
await this.updateEmbeddedDocuments('Item', [{ _id: objetQ.id, 'system.quantity': newQ }]) // pdates one EmbeddedEntity
}
}
}
@ -1692,26 +1771,26 @@ export class PegasusActor extends Actor {
if (objetQ) {
let newQ = objetQ.system.ammocurrent + incDec;
if (newQ >= 0 && newQ <= objetQ.system.ammomax) {
const updated = await this.updateEmbeddedDocuments('Item', [{ _id: objetQ.id, 'system.ammocurrent': newQ }]); // pdates one EmbeddedEntity
await this.updateEmbeddedDocuments('Item', [{ _id: objetQ.id, 'system.ammocurrent': newQ }]); // pdates one EmbeddedEntity
}
}
}
/* -------------------------------------------- */
async applyAbility(ability, updates = [], directUpdate = false) {
async applyAbility(ability, updates = {}, directUpdate = false) {
// manage stat bonus
if (!ability.system) {
ability.system = ability.data
}
if (ability.system.affectedstat != "notapplicable") {
if ( ability.system.affectedstat == "mr") {
if (ability.system.affectedstat == "mr") {
let stat = duplicate(this.system.mr)
stat.mod += Number(ability.system.statmodifier)
updates[`system.mr`] = stat
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
updates[`system.statistics.${ability.system.affectedstat}`] = stat
}
}
// manage status bonus
@ -1721,6 +1800,7 @@ export class PegasusActor extends Actor {
nrg.mod += Number(ability.system.statusmodifier)
updates[`system.nrg`] = nrg
}
/* NO MORE USED
if (ability.system.statusaffected == 'health') {
let health = duplicate(this.system.secondary.health)
health.bonus += Number(ability.system.statusmodifier)
@ -1740,7 +1820,7 @@ export class PegasusActor extends Actor {
let stealthhealth = duplicate(this.system.secondary.stealthhealth)
stealthhealth.bonus += Number(ability.system.statusmodifier)
updates[`system.secondary.stealthhealth`] = delirium
}
}*/
}
if (directUpdate) {
await this.update(updates)
@ -1810,7 +1890,7 @@ export class PegasusActor extends Actor {
getIncreaseStatValue(updates, statKey) {
let stat = duplicate(this.system.statistics[statKey])
stat.value += 1;
updates[`data.statistics.${statKey}`] = stat
updates[`system.statistics.${statKey}`] = stat
}
/* -------------------------------------------- */
@ -1835,6 +1915,48 @@ export class PegasusActor extends Actor {
}
/* -------------------------------------------- */
computeCurrentHindrances() {
let hindrancesDices = 0
if (this.type == "character") {
if (this.system.combat.stunlevel > 0) {
hindrancesDices += 2
}
hindrancesDices += this.system.combat.hindrancedice
let overCapacity = Math.floor(this.encCurrent / this.getEncumbranceCapacity())
if (overCapacity > 0) {
hindrancesDices += overCapacity
}
let effects = this.items.filter(item => item.type == 'effect')
for (let effect of effects) {
if (effect.system.hindrance) {
hindrancesDices += effect.system.effectlevel
}
}
}
if (this.type == "vehicle") {
if (this.system.stun.value > 0) {
hindrancesDices += 2
}
if (this.isVehicleCrawling()) {
hindrancesDices += 3
}
if (this.isVehicleSlow()) {
hindrancesDices += 1
}
if (this.isVehicleAverage()) {
hindrancesDices += 1
}
if (this.isVehicleFast()) {
hindrancesDices += 3
}
if (this.isVehicleExFast()) {
hindrancesDices += 5
}
}
return hindrancesDices
}
/* -------------------------------------------- */
addHindrancesList(effectsList) {
@ -1886,12 +2008,8 @@ export class PegasusActor extends Actor {
/* ROLL SECTION
/* -------------------------------------------- */
pushEffect(rollData, effect) {
if (this.getTraumaState() == "none" && !this.checkNoBonusDice()) {
if ((this.getTraumaState() == "none" && !this.checkNoBonusDice()) || !effect.system.bonusdice) {
rollData.effectsList.push({ label: effect.name, type: "effect", applied: false, effect: effect, value: effect.system.effectlevel })
} else {
if (!effect.system.bonusdice) { // Do not push bonus dice effect when TraumaState is activated
rollData.effectsList.push({ label: effect.name, type: "effect", applied: false, effect: effect, value: effect.system.effectlevel })
}
}
}
@ -1922,15 +2040,15 @@ export class PegasusActor extends Actor {
/* -------------------------------------------- */
addRoleBonus(rollData, statKey, subKey) {
let role = this.getRole()
if (role.name.toLowerCase() == "ranged" && subKey == "ranged-dmg") {
if (role && role.name.toLowerCase() == "ranged" && subKey == "ranged-dmg") {
rollData.effectsList.push({ label: "Ranged Role Bonus", type: "effect", applied: true, isdynamic: true, value: this.getRoleLevel() })
rollData.dicePool = rollData.dicePool.concat(PegasusUtility.buildDicePool("effect-bonus-dice", this.getRoleLevel(), 0, "Ranged Role Bonus"))
}
if (role.name.toLowerCase() == "defender" && subKey == "defence") {
if (role && role.name.toLowerCase() == "defender" && (subKey == "defence" || subKey == "dmg-res")) {
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"))
}
if (role.name.toLowerCase() == "scrapper" && statKey == "com") {
if (role && role.name.toLowerCase() == "scrapper" && statKey == "com") {
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"))
}
@ -2019,7 +2137,8 @@ export class PegasusActor extends Actor {
let rollData = PegasusUtility.getBasicRollData(isInit)
rollData.alias = this.name
rollData.actorImg = this.img
rollData.actorId = this.id
rollData.tokenId = this.token?.id
rollData.actorId = (this.token) ? this.token.actor.id : this.id
rollData.img = this.img
rollData.traumaState = this.getTraumaState()
rollData.levelRemaining = this.getLevelRemaining()
@ -2109,7 +2228,9 @@ export class PegasusActor extends Actor {
})
}
}
}
}
rollData.hindranceDices = this.computeCurrentHindrances()
this.processSizeBonus(rollData)
this.addEffects(rollData, isInit, isPower, subKey == "power-dmg")

30
modules/pegasus-config.js Normal file
View File

@ -0,0 +1,30 @@
export const PEGASUS_CONFIG = {
healthStatus: {
healthy: { key: "healthy", name: 'Healthy', hindrance: 0 },
injured: { key: "injured",name: 'Injured',hindrance: 0 },
wounded: { key: "wounded",name: 'Wounded',hindrance: 1, rolls: 'ALL' },
severlywounded: { key: "severlywounded",name: 'Severly Wounded',hindrance: 3, rolls: 'ALL' },
defeated: { key: "defeated",name:'Defeated',hindrance: 3, defeated: true}
},
deliriumStatus: {
stable: { key:'stable', name: 'Stable', hindrance: 0 },
unstable: { key:'unstable',name: 'Unstable', hindrance: 0 },
trauma: { key:'trauma',name: 'Trauma', hindrance: 0, nobonusdice: true },
severetrauma: { key:'severetrauma',name: 'Severe Trauma', hindrance: 0, nobonusdice: true, noperks: true },
defeated: { key:'defeated',name:'Defeated',hindrance: 0, defeated: true}
},
concealmentStatus: {
hidden: { key:'hidden',name: 'Hidden', hindrance: 0 },
covered: { key:'covered',name: 'Covered', hindrance: 0 },
exposed: { key:'exposed',name: 'Exposed', hindrance: 1, rolls: 'STL' },
detected: { key:'detected',name: 'Detected', hindrance: 3, rolls: 'STL'},
located: { key:'located',name: 'Located', hindrance: 0 }
},
confidenceStatus: {
confident: { key:'confident',name: 'Confident', hindrance: 0 },
uncertain: { key:'uncertain',name: 'Uncertain', hindrance: 0 },
shaken: { key:'shaken',name: 'Shaken', hindrance: 0, hasfear: true },
anxious: { key:'anxious',name: 'Anxious', hindrance: 0, nostunrecover: true },
lostface: { key:'lostface',name: 'Lost Face', hindrance: 0 }
}
}

View File

@ -423,7 +423,6 @@ export class PegasusItemSheet extends ItemSheet {
}
}
/* -------------------------------------------- */
async _onDrop(event) {

View File

@ -17,6 +17,7 @@ import { PegasusUtility } from "./pegasus-utility.js";
import { PegasusCombat } from "./pegasus-combat.js";
import { PegasusItem } from "./pegasus-item.js";
import { PegasusToken } from "./pegasus-token.js";
import { PEGASUS_CONFIG } from "./pegasus-config.js"
/* -------------------------------------------- */
/* Foundry VTT Initialization */
@ -58,7 +59,8 @@ Hooks.once("init", async function () {
CONFIG.Actor.documentClass = PegasusActor
CONFIG.Item.documentClass = PegasusItem
game.system.pegasus = {
utility: PegasusUtility
utility: PegasusUtility,
config: PEGASUS_CONFIG
}
/* -------------------------------------------- */

View File

@ -70,6 +70,24 @@ export class PegasusUtility {
Handlebars.registerHelper('getDice', function (a) {
return PegasusUtility.getDiceFromLevel(a)
})
Handlebars.registerHelper('getStatusConfig', function (a) {
let key = a + "Status"
//console.log("TABE", key, game.system.pegasus.config[key] )
return game.system.pegasus.config[key]
})
Handlebars.registerHelper('valueAtIndex', function (arr, idx) {
return arr[idx];
})
Handlebars.registerHelper('for', function (from, to, incr, block) {
let accum = '';
for (let i = from; i <= to; i += incr)
accum += block.fn(i);
return accum;
})
Handlebars.registerHelper('isGM', function () {
return game.user.isGM
})
}
@ -131,10 +149,10 @@ export class PegasusUtility {
let diceKey = PegasusUtility.getDiceFromLevel(level)
let diceList = diceKey.split(" ")
for (let myDice of diceList) {
myDice = myDice.trim()
let myDiceTrim = myDice.trim()
let newDice = {
name: name, key: myDice, level: PegasusUtility.getLevelFromDice(myDice), mod: mod, effect: effectName,
img: `systems/fvtt-pegasus-rpg/images/dice/${myDice}.webp`
name: name, key: myDiceTrim, level: PegasusUtility.getLevelFromDice(myDiceTrim), mod: mod, effect: effectName,
img: `systems/fvtt-pegasus-rpg/images/dice/${myDiceTrim}.webp`
}
dicePool.push(newDice)
mod = 0 // Only first dice has modifier
@ -146,10 +164,10 @@ export class PegasusUtility {
static updateEffectsBonusDice(rollData) {
let newDicePool = rollData.dicePool.filter(dice => dice.name != "effect-bonus-dice")
for (let effect of rollData.effectsList) {
if (effect && effect.applied && effect.type == "effect" && !effect.effect?.system?.hindrance && effect.effect && effect.effect.system.bonusdice) {
if (effect?.applied && effect.type == "effect" && !effect.effect?.system?.hindrance && effect.effect && effect.effect.system.bonusdice) {
newDicePool = newDicePool.concat(this.buildDicePool("effect-bonus-dice", effect.effect.system.effectlevel, 0, effect.effect.name))
}
if (effect && effect.applied && effect.type == "effect" && effect.value && effect.isdynamic && !effect.effect?.system?.hindrance) {
if (effect?.applied && effect.type == "effect" && effect.value && effect.isdynamic && !effect.effect?.system?.hindrance) {
newDicePool = newDicePool.concat(this.buildDicePool("effect-bonus-dice", effect.value, 0, effect.name))
}
}
@ -160,7 +178,7 @@ export class PegasusUtility {
static updateHindranceBonusDice(rollData) {
let newDicePool = rollData.dicePool.filter(dice => dice.name != "effect-hindrance")
for (let hindrance of rollData.effectsList) {
if (hindrance && hindrance.applied && (hindrance.type == "hindrance" || (hindrance.type == "effect" && hindrance.effect?.system?.hindrance))) {
if (hindrance?.applied && (hindrance.type == "hindrance" || (hindrance.type == "effect" && hindrance.effect?.system?.hindrance))) {
console.log("Adding Hindrance 1", hindrance, newDicePool)
newDicePool = newDicePool.concat(this.buildDicePool("effect-hindrance", (hindrance.value) ? hindrance.value : hindrance.effect.system.effectlevel, 0, hindrance.name))
console.log("Adding Hindrance 2", newDicePool)
@ -803,6 +821,12 @@ export class PegasusUtility {
/* -------------------------------------------- */
static async rollPegasus(rollData) {
let actor = game.actors.get(rollData.actorId)
if (rollData.tokenId) {
let token = canvas.tokens.placeables.find(t => t.id == rollData.tokenId)
if (token) {
actor = token.actor
}
}
let diceFormulaTab = []
for (let dice of rollData.dicePool) {
@ -815,9 +839,19 @@ export class PegasusUtility {
let myRoll = rollData.roll
if (!myRoll || rollData.rerollHero || rollData.rerollMomentum) { // New rolls only of no rerolls
myRoll = new Roll(diceFormula).roll({ async: false })
await this.showDiceSoNice(myRoll, game.settings.get("core", "rollMode"))
rollData.roll = myRoll
}
if ( rollData.hindranceDices > 0) {
rollData.hindranceRoll = new Roll(rollData.hindranceDices + "d6").roll({ async: false })
this.showDiceSoNice(rollData.hindranceRoll, game.settings.get("core", "rollMode"))
for (let res of rollData.hindranceRoll.terms[0].results) {
if (res.result == 6) {
rollData.hindranceFailure = true
}
}
}
await this.showDiceSoNice(myRoll, game.settings.get("core", "rollMode"))
// Final score and keep data
rollData.finalScore = myRoll.total
@ -1037,7 +1071,7 @@ export class PegasusUtility {
}
//rollData.attackerId = this.id
console.log("Target/DEFENDER", defenderActor)
defenderActor.addHindrancesList(rollData.effectsList)
//defenderActor.addHindrancesList(rollData.effectsList) /* No more used */
}
}
@ -1115,7 +1149,7 @@ export class PegasusUtility {
let friends = canvas.tokens.placeables.filter(newToken => newToken.actor.type == "character" && !newToken.document.hidden && newToken.document.disposition == token.document.disposition)
for (let friend of friends) {
if (friend.actor.id != token.actor.id) {
let existing = toApply[friend.actor.id] || { actor: friend.actor, add: false, level: 0, names: [] }
let existing = toApply[friend.id] || { token: friend, add: false, level: 0, names: [] }
let visible = canvas.effects.visibility.testVisibility(friend.center, { object: token })
console.log("parse visible TACTICIAN : ", visible, token.name, friend.name)
if (visible) {
@ -1123,22 +1157,22 @@ export class PegasusUtility {
existing.level += token.actor.getRoleLevel()
existing.names.push(token.actor.name)
}
toApply[friend.actor.id] = existing
toApply[friend.id] = existing
}
}
}
for (let id in toApply) {
let applyDef = toApply[id]
let hasBonus = applyDef.actor.hasTacticianBonus()
let hasBonus = applyDef.token.actor.hasTacticianBonus()
if (applyDef.add) {
if (!hasBonus) {
applyDef.actor.addTacticianEffect(applyDef.names.toString(), applyDef.level)
await applyDef.token.actor.addTacticianEffect(applyDef.names.toString(), applyDef.level)
} else if (applyDef.level != hasBonus.system.effectlevel) {
await applyDef.actor.removeTacticianEffect()
applyDef.actor.addTacticianEffect(applyDef.names.toString(), applyDef.level)
await applyDef.token.actor.removeTacticianEffect()
await applyDef.token.actor.addTacticianEffect(applyDef.names.toString(), applyDef.level)
}
} else if (hasBonus) {
applyDef.actor.removeTacticianEffect()
await applyDef.token.actor.removeTacticianEffect()
}
}
//Delete all effects if no more tacticians (ie deleted case)
@ -1146,7 +1180,7 @@ export class PegasusUtility {
let allTokens = canvas.tokens.placeables.filter(token => token.actor.type == "character")
for (let token of allTokens) {
if (token.actor.hasTacticianBonus()) {
token.actor.removeTacticianEffect()
await token.actor.removeTacticianEffect()
}
}
}
@ -1163,7 +1197,7 @@ export class PegasusUtility {
let friends = canvas.tokens.placeables.filter(newToken => newToken.actor.type == "character" && !newToken.document.hidden && newToken.document.disposition == token.document.disposition)
for (let friend of friends) {
if (friend.actor.id != token.actor.id) {
let existing = toApply[friend.actor.id] || { actor: friend.actor, add: false, level: 0, names: [] }
let existing = toApply[friend.id] || { token: friend, add: false, level: 0, names: [] }
let visible = canvas.effects.visibility.testVisibility(friend.center, { object: token })
console.log("parse visible ENHANCER: ", visible, token.name, friend.name)
if (visible) {
@ -1174,22 +1208,22 @@ export class PegasusUtility {
existing.names.push(token.actor.name)
}
}
toApply[friend.actor.id] = existing
toApply[friend.id] = existing
}
}
}
for (let id in toApply) {
let applyDef = toApply[id]
let hasBonus = applyDef.actor.hasEnhancerBonus()
let hasBonus = applyDef.token.actor.hasEnhancerBonus()
if (applyDef.add) {
if (!hasBonus) {
applyDef.actor.addEnhancerEffect(applyDef.names.toString(), applyDef.level)
await applyDef.token.actor.addEnhancerEffect(applyDef.names.toString(), applyDef.level)
} else if (applyDef.level != hasBonus.system.effectlevel) {
await applyDef.actor.removeEnhancerEffect()
applyDef.actor.addEnhancerEffect(applyDef.names.toString(), applyDef.level)
await applyDef.token.actor.removeEnhancerEffect()
await applyDef.token.actor.addEnhancerEffect(applyDef.names.toString(), applyDef.level)
}
} else if (hasBonus) {
applyDef.actor.removeEnhancerEffect()
await applyDef.token.actor.removeEnhancerEffect()
}
}
// Delete all effects if no more tacticians (ie deleted case)
@ -1197,7 +1231,7 @@ export class PegasusUtility {
let allTokens = canvas.tokens.placeables.filter(token => token.actor.type == "character")
for (let token of allTokens) {
if (token.actor.hasEnhancerBonus()) {
token.actor.removeEnhancerEffect()
await token.actor.removeEnhancerEffect()
}
}
}
@ -1220,9 +1254,11 @@ export class PegasusUtility {
if (token.document.disposition == 0) {
ennemies = canvas.tokens.placeables.filter(newToken => newToken.actor.type == "character" && !newToken.document.hidden && (newToken.document.disposition == -1 || newToken.document.disposition == 1 ))
}
console.log("Ennemies for token", token.actor.name, ennemies)
for (let ennemy of ennemies) {
if (ennemy.actor.id != token.actor.id) {
let existing = toApply[ennemy.actor.id] || { actor: ennemy.actor, add: false, level: 0, names: [] }
//console.log("Adding ennemy", ennemy.id)
let existing = toApply[ennemy.id] || { token: ennemy, add: false, level: 0, names: [] }
let visible = canvas.effects.visibility.testVisibility(ennemy.center, { object: token })
if (visible) {
let dist = canvas.grid.measureDistances([{ ray: new Ray(token.center, ennemy.center) }], { gridSpaces: false })
@ -1232,30 +1268,31 @@ export class PegasusUtility {
existing.names.push(token.actor.name)
}
}
toApply[ennemy.actor.id] = existing
toApply[ennemy.id] = existing
}
}
}
//console.log("To apply stuff : ", toApply)
for (let id in toApply) {
let applyDef = toApply[id]
let hasHindrance = applyDef.actor.hasAgitatorHindrance()
let hasHindrance = applyDef.token.actor.hasAgitatorHindrance()
if (applyDef.add) {
if (!hasHindrance) {
applyDef.actor.addAgitatorHindrance(applyDef.names.toString(), applyDef.level)
await applyDef.token.actor.addAgitatorHindrance(applyDef.names.toString(), applyDef.level)
} else if (applyDef.level != hasHindrance.system.effectlevel) {
await applyDef.actor.removeAgitatorHindrance()
applyDef.actor.addAgitatorHindrance(applyDef.names.toString(), applyDef.level)
await applyDef.token.actor.removeAgitatorHindrance()
await applyDef.token.actor.addAgitatorHindrance(applyDef.names.toString(), applyDef.level)
}
} else if (hasHindrance) {
applyDef.actor.removeAgitatorHindrance()
await applyDef.token.actor.removeAgitatorHindrance()
}
}
// Delete all effects if no more agtators (ie deleted case)
// Delete all effects if no more agitators (ie deleted case)
if (agitatorTokens.length == 0) {
let allTokens = canvas.tokens.placeables.filter(token => token.actor.type == "character")
for (let token of allTokens) {
if (token.actor.hasAgitatorHindrance()) {
token.actor.removeAgitatorHindrance()
await token.actor.removeAgitatorHindrance()
}
}
}
@ -1273,9 +1310,9 @@ export class PegasusUtility {
this.lastRoleEffectProcess = now
console.log("=========================+> Searching/Processing roles effects")
await this.processTactician()
/*NO MORE USED : await this.processTactician()*/
await this.processEnhancer()
await this.processAgitator()
/*NO MORE USED : await this.processAgitator()*/
}

View File

@ -23,8 +23,7 @@
"manifest": "https://www.uberwald.me/gitea/uberwald/fvtt-pegasus-rpg/raw/branch/master/system.json",
"compatibility": {
"minimum": "10",
"verified": "10",
"maximum": "10"
"verified": "11"
},
"id": "fvtt-pegasus-rpg",
"packs": [
@ -253,7 +252,7 @@
],
"title": "Pegasus RPG",
"url": "https://www.uberwald.me/data/files/fvtt-pegasus-rpg",
"version": "10.2.6",
"download": "https://www.uberwald.me/gitea/uberwald/fvtt-pegasus-rpg/archive/fvtt-pegasus-rpg-v10.2.6.zip",
"version": "11.0.4",
"download": "https://www.uberwald.me/gitea/uberwald/fvtt-pegasus-rpg/archive/fvtt-pegasus-rpg-v11.0.4.zip",
"background": "systems/fvtt-pegasus-rpg/images/ui/pegasus_welcome_page.webp"
}

View File

@ -171,6 +171,7 @@
"type": "value",
"ismax": true,
"iscombat": true,
"status": "healthy",
"bonus": 0,
"max": 0
},
@ -180,22 +181,25 @@
"type": "value",
"ismax": true,
"iscombat": true,
"status": "stable",
"bonus": 0,
"max": 0
},
"stealthhealth": {
"label": "STL Health",
"concealment": {
"label": "Concealment",
"type": "value",
"value": 0,
"ismax": true,
"status": "hidden",
"bonus": 0,
"max": 0
},
"socialhealth": {
"label": "SOC Health",
"confidence": {
"label": "Confidence",
"type": "value",
"value": 0,
"ismax": true,
"status": "confident",
"bonus": 0,
"max": 0
}
@ -595,6 +599,7 @@
"armor": {
"statistic": "",
"resistance": "",
"adrl": 0,
"weight": 0,
"cost": 0,
"idr": "",
@ -645,6 +650,8 @@
"weapon": {
"statistic": "",
"damagestatistic": "",
"mdl": 0,
"rdl": 0,
"damage": "",
"canbethrown": false,
"cost": 0,

View File

@ -59,12 +59,6 @@
<div class="stat-item status-block">
{{> systems/fvtt-pegasus-rpg/templates/partial-actor-status.html}}
</div>
<!--
<label class="status-small-label">Active NRG</label>
<input type="text" class="padd-right status-small-label no-grow" name="system.nrg.activated" value="{{data.nrg.activated}}" data-dtype="Number"/>
-->
</div>
</div>
</div>

View File

@ -26,6 +26,7 @@
{{/if}}
{{#if isResistance}}
<li>Armor Resistance Dice : {{armor.system.resistanceDice}}</li>
<li>ADRL : {{armor.system.adrl}}</li>
{{/if}}
{{#if stat}}
<li>Statistic : {{stat.label}}</li>
@ -38,6 +39,12 @@
<li>Weapon : {{weaponName}}</li>
{{/if}}
{{#if weapon}}
{{#if (eq weapon.weapon.system.damagestatistic "str")}}
<li>MDL : {{weapon.weapon.system.mdl}}</li>
{{/if}}
{{#if (eq weapon.weapon.system.statistic "agi")}}
<li>RDL : {{weapon.weapon.system.rdl}}</li>
{{/if}}
{{#if vehicle}}
<li>Damage type : {{weapon.weapon.system.damagetype}}</li>
{{else}}
@ -49,13 +56,13 @@
<li>Power Damage type : {{power.system.powerdamagetype}} {{power.system.powerdamagetypelevel}}</li>
{{/if}}
{{#if isResistance}}
<li><strong>Defense Result : {{finalScore}}</strong>
{{#if hindranceFailure}}
<li><strong>Failed due to Hindrance Dice(s) !!</strong>
{{else}}
{{#if isDamage}}
<li><strong>Damages : {{finalScore}}</strong>
{{#if isResistance}}
<li><strong>Defense Result : {{finalScore}}</strong>
{{else}}
<li><strong>Final Result : {{finalScore}}</strong>
<li><strong>Final Result : {{finalScore}}</strong>
{{/if}}
{{/if}}

View File

@ -26,13 +26,21 @@
</select>
</li>
<li class="flexrow"><label class="generic-label">DMG RES Dice</label>
<li class="flexrow"><label class="generic-label">Damage Resistance</label>
<select class="competence-base flexrow" type="text" name="system.resistance" value="{{data.resistance}}" data-dtype="Number">
{{#select data.resistance}}
{{{optionsDiceList}}}
{{/select}}
</select>
</li>
{{#if owner}}
<li class="flexrow">
<label class="generic-label">ADRL</label>
<label class="generic-label">{{data.adrl}}</label>
</li>
{{/if}}
<li class="flexrow"><label class="generic-label">Location Protected</label>
<input type="text" class="" name="system.locationprotected" value="{{data.locationprotected}}" data-dtype="String"/>
</li>

View File

@ -93,13 +93,12 @@
<label class="attribute-value checkbox"><input type="checkbox" name="system.affectstatus" {{checked data.affectstatus}}/></label>
</li>
{{#if data.affectstatus}}
<li class="flexrow"><label class="generic-label">Affected status</label>
<li class="flexrow"><label class="generic-label">Affected status/Auto damage</label>
<select class="competence-base flexrow" type="text" name="system.affectedstatus" value="{{data.affectedstatus}}" data-dtype="String">
{{#select data.affectedstatus}}
<option value="health">Health</option>
<option value="delirium">Delirium</option>
<option value="socialhealth">Social Health</option>
<option value="stealthhealth">Stealth Health</option>
<option value="mdl">MDL</option>
<option value="rdl">RDL</option>
<option value="adrl">ADRL</option>
<option value="nrg">NRG</option>
<option value="mt">MT</option>
<option value="kbv">KBV</option>

View File

@ -38,6 +38,19 @@
</select>
</li>
{{#if (and owner (eq data.damagestatistic "str"))}}
<li class="flexrow">
<label class="generic-label">MDL</label>
<label class="competence-base">{{data.mdl}}</label>
</li>
{{/if}}
{{#if (and owner (eq data.damagestatistic "pre"))}}
<li class="flexrow">
<label class="generic-label">RDL</label>
<label class="competence-base">{{data.rdl}}</label>
</li>
{{/if}}
<li class="flexrow"><label class="generic-label">Item size</label>
<input type="text" class="" name="system.itemsize" value="{{data.itemsize}}" data-dtype="String"/>
</li>

View File

@ -1,25 +1,17 @@
<ul class="status-block">
<li class="item flexrow">
<span class="stat-label status-small-label status-col-name"><label class="status-small-label"><strong>Status</strong></label></span>
<span class="status-header-label status-small-label no-grow"><label class="status-small-label">Cur</label></span>
<span class="status-header-label status-small-label no-grow"><label class="status-small-label">Mod</label></span>
<span class="status-header-label status-small-label no-grow"><label class="status-small-label">Max</label></span>
<span class="status-header-label status-small-label no-grow"><label class="status-medium-label">State</label></span>
</li>
{{#each data.secondary as |stat2 key|}}
<li class="item flexrow " data-attr-key="{{key}}">
<span class="stat-label flexrow status-col-name" name="{{key}}">
<label class="status-small-label"><strong>{{stat2.label}}</strong><br>
{{#if (eq key "health")}}
(KOV -{{stat2.max}})
{{/if}}
{{#if (eq key "delirium")}}
(MV -{{stat2.max}})
{{/if}}
</label>
</span>
<input type="text" class="padd-right status-small-label no-grow" name="system.secondary.{{key}}.value" value="{{stat2.value}}" data-dtype="Number"/>
<input type="text" class="padd-right status-small-label no-grow" name="system.secondary.{{key}}.bonus" value="{{stat2.bonus}}" data-dtype="Number" {{@root.disabledBonus}}/>
<input type="text" class="padd-right status-small-label no-grow" name="system.secondary.{{key}}.max" value="{{stat2.max}}" data-dtype="Number"/>
<select class="padd-right status-small-label" type="text" name="system.secondary.{{key}}.status" value="{{stat2.status}}" data-dtype="String">
{{selectOptions (getStatusConfig key) selected=stat2.status nameAttr="key" labelAttr="name" }}
</select>
</li>
{{/each}}
<li class="item flexrow " data-key="nrg">

View File

@ -87,7 +87,7 @@
<div class="flexrow dice-pool-stack">
{{#each dicePool as |dice idx|}}
<span><a class="pool-remove-dice" data-dice-idx="{{idx}}" data-dice-level="{{dice.level}}" data-dice-key="{{dice.key}}"><img class="dice-pool-image"
src="{{dice.img}}"></a></span>
src="{{dice.img}}" alt="dices"></a></span>
{{/each}}
</div>
</div>
@ -100,10 +100,24 @@
<div class="flexrow">
{{#each diceList as |dice idx|}}
<span><a class="pool-add-dice" data-dice-key="{{dice.key}}" data-dice-level="{{dice.level}}"><img class="dice-pool-image"
src="{{dice.img}}"></a></span>
src="{{dice.img}}" alt="dices"></a></span>
{{/each}}
</div>
{{/if}}
{{#if hindranceDices}}
<div class="dice-pool-div">
<span>
<h3 class="dice-pool-label">Hindrance Dices</h3>
</span>
<div class="flexrow dice-pool-stack">
{{#for 1 hindranceDices 1}}
<span><a class="" data-dice-idx="{{idx}}" data-dice-level="2" data-dice-key="d6"><img class="dice-pool-image"
src="systems/fvtt-pegasus-rpg/images/dice/hindrance-dice.png" alt="dices"></a></span>
{{/for}}
</div>
</div>
{{/if}}
<div class="flexrow">