Initial import
This commit is contained in:
parent
c33b758ddd
commit
f142b8f6cd
@ -13,7 +13,7 @@ export class TeDeumActorPJSheet extends ActorSheet {
|
||||
|
||||
return mergeObject(super.defaultOptions, {
|
||||
classes: ["fvtt-tedeum", "sheet", "actor"],
|
||||
template: "systems/fvtt-tedeum/templates/actors/actor-sheet.hbs",
|
||||
template: "systems/fvtt-te-deum/templates/actors/actor-sheet.hbs",
|
||||
width: 860,
|
||||
height:680,
|
||||
tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "skills" }],
|
||||
|
@ -58,110 +58,32 @@ export class TeDeumActor extends Actor {
|
||||
|
||||
// Configure prototype token settings
|
||||
const prototypeToken = {};
|
||||
if (this.type === "pc") Object.assign(prototypeToken, {
|
||||
if (this.type === "pj") Object.assign(prototypeToken, {
|
||||
sight: { enabled: true }, actorLink: true, disposition: CONST.TOKEN_DISPOSITIONS.FRIENDLY
|
||||
});
|
||||
this.updateSource({ prototypeToken });
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getMoneys() {
|
||||
let comp = this.items.filter(item => item.type == 'money');
|
||||
EcrymeUtility.sortArrayObjectsByName(comp)
|
||||
return comp;
|
||||
}
|
||||
getArchetype() {
|
||||
let comp = duplicate(this.items.find(item => item.type == 'archetype') || { name: "Pas d'archetype" })
|
||||
if (comp?.system) {
|
||||
comp.tarot = EcrymeUtility.getTarot(comp.system.lametutelaire)
|
||||
}
|
||||
|
||||
return comp;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
buildAnnencyActorList() {
|
||||
let membersFull = {}
|
||||
for(let id of this.system.base.characters) {
|
||||
let actor = game.actors.get(id)
|
||||
membersFull[id] = { name: actor.name, id: actor.id, img: actor.img }
|
||||
}
|
||||
return membersFull
|
||||
}
|
||||
/* ----------------------- --------------------- */
|
||||
addAnnencyActor(actorId) {
|
||||
let members = duplicate(this.system.base.characters)
|
||||
members.push(actorId)
|
||||
this.update({ 'system.base.characters': members })
|
||||
}
|
||||
async removeAnnencyActor(actorId) {
|
||||
let members = this.system.base.characters.filter(id => id != actorId)
|
||||
this.update({ 'system.base.characters': members })
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getAnnency() {
|
||||
return game.actors.find(a => a.type == 'annency' && a.system.base.characters.includes(this.id))
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getConfrontations() {
|
||||
return this.items.filter(it => it.type == "confrontation")
|
||||
}
|
||||
getRollTraits() {
|
||||
return this.items.filter(it => it.type == "trait" && it.system.traitype == "normal")
|
||||
}
|
||||
getIdeal() {
|
||||
return this.items.find(it => it.type == "trait" && it.system.traitype == "ideal")
|
||||
}
|
||||
getSpleen() {
|
||||
return this.items.find(it => it.type == "trait" && it.system.traitype == "spleen")
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getTrait(id) {
|
||||
//console.log("TRAITS", this.items, this.items.filter(it => it.type == "trait") )
|
||||
return this.items.find(it => it.type == "trait" && it._id == id)
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getSpecialization(id) {
|
||||
let spec = this.items.find(it => it.type == "specialization" && it.id == id)
|
||||
return spec
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getSpecializations(skillKey) {
|
||||
return this.items.filter(it => it.type == "specialization" && it.system.skillkey == skillKey)
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
prepareSkills() {
|
||||
let skills = duplicate(this.system.skills)
|
||||
for (let categKey in skills) {
|
||||
let category = skills[categKey]
|
||||
for (let skillKey in category.skilllist) {
|
||||
let skill = category.skilllist[skillKey]
|
||||
skill.spec = this.getSpecializations(skillKey)
|
||||
}
|
||||
}
|
||||
return skills
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getCephalySkills() {
|
||||
let skills = duplicate(this.system.cephaly.skilllist)
|
||||
return skills
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getImpacts() {
|
||||
let comp = duplicate(this.items.filter(item => item.type == 'impact') || [])
|
||||
getCompetences() {
|
||||
let comp = duplicate(this.items.filter(item => item.type == 'competence') || [])
|
||||
return comp;
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getWeapons() {
|
||||
let comp = duplicate(this.items.filter(item => item.type == 'weapon') || [])
|
||||
EcrymeUtility.sortArrayObjectsByName(comp)
|
||||
getArmes() {
|
||||
let comp = duplicate(this.items.filter(item => item.type == 'arme') || [])
|
||||
TeDeumUtility.sortArrayObjectsByName(comp)
|
||||
return comp;
|
||||
}
|
||||
getManeuvers() {
|
||||
let comp = duplicate(this.items.filter(item => item.type == 'maneuver') || [])
|
||||
EcrymeUtility.sortArrayObjectsByName(comp)
|
||||
getEquipements() {
|
||||
let comp = duplicate(this.items.filter(item => item.type == 'equipement') || [])
|
||||
TeDeumUtility.sortArrayObjectsByName(comp)
|
||||
return comp;
|
||||
}
|
||||
getArmures() {
|
||||
let comp = duplicate(this.items.filter(item => item.type == 'armure') || [])
|
||||
TeDeumUtility.sortArrayObjectsByName(comp)
|
||||
return comp;
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
@ -177,7 +99,7 @@ export class TeDeumActor extends Actor {
|
||||
async equipItem(itemId) {
|
||||
let item = this.items.find(item => item.id == itemId)
|
||||
if (item?.system) {
|
||||
if (item.type == "armor") {
|
||||
if (item.type == "armure") {
|
||||
let armor = this.items.find(item => item.id != itemId && item.type == "armor" && item.system.equipped)
|
||||
if (armor) {
|
||||
ui.notifications.warn("You already have an armor equipped!")
|
||||
@ -221,7 +143,7 @@ export class TeDeumActor extends Actor {
|
||||
// Compute whole enc
|
||||
let enc = 0
|
||||
for (let item of equipments) {
|
||||
//item.data.idrDice = EcrymeUtility.getDiceFromLevel(Number(item.data.idr))
|
||||
//item.data.idrDice = TeDeumUtility.getDiceFromLevel(Number(item.data.idr))
|
||||
if (item.system.equipped) {
|
||||
if (item.system.iscontainer) {
|
||||
enc += item.system.contentsEnc
|
||||
@ -253,36 +175,6 @@ export class TeDeumActor extends Actor {
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
modifyImpact(impactType, impactLevel, modifier) {
|
||||
console.log(impactType, impactLevel, modifier)
|
||||
let current = this.system.impacts[impactType][impactLevel]
|
||||
if (modifier > 0) {
|
||||
while ( EcrymeUtility.getImpactMax(impactLevel) == current && impactLevel != "major") {
|
||||
impactLevel = EcrymeUtility.getNextImpactLevel(impactLevel)
|
||||
current = this.system.impacts[impactType][impactLevel]
|
||||
}
|
||||
}
|
||||
let newImpact = Math.max(this.system.impacts[impactType][impactLevel] + modifier, 0)
|
||||
this.update({ [`system.impacts.${impactType}.${impactLevel}`]: newImpact})
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getImpactMalus(impactKey) {
|
||||
let impacts = this.system.impacts[impactKey]
|
||||
return - ((impacts.serious*2) + (impacts.major*4))
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getImpactsMalus() {
|
||||
let impactsMalus = {
|
||||
physical: this.getImpactMalus("physical"),
|
||||
mental: this.getImpactMalus("mental"),
|
||||
social: this.getImpactMalus("social")
|
||||
}
|
||||
return impactsMalus
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
clearInitiative() {
|
||||
this.getFlag("world", "initiative", -1)
|
||||
@ -344,148 +236,48 @@ export class TeDeumActor extends Actor {
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
modifyConfrontBonus( modifier ) {
|
||||
let newBonus = this.system.internals.confrontbonus + modifier
|
||||
this.update({'system.internals.confrontbonus': newBonus})
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
spentSkillTranscendence(skill, value) {
|
||||
let newValue = this.system.skills[skill.categKey].skilllist[skill.skillKey].value - value
|
||||
newValue = Math.max(0, newValue)
|
||||
this.update({ [`system.skills.${skill.categKey}.skilllist.${skill.skillKey}.value`]: newValue })
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getBonusList() {
|
||||
let bonusList = []
|
||||
for(let i=0; i<this.system.internals.confrontbonus; i++) {
|
||||
bonusList.push( { value: 1, type: "bonus", location: "mainpool"})
|
||||
}
|
||||
return bonusList
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getCommonRollData() {
|
||||
//this.system.internals.confrontbonus = 5 // TO BE REMOVED!!!!
|
||||
let rollData = EcrymeUtility.getBasicRollData()
|
||||
let rollData = TeDeumUtility.getBasicRollData()
|
||||
rollData.alias = this.name
|
||||
rollData.actorImg = this.img
|
||||
rollData.actorId = this.id
|
||||
rollData.img = this.img
|
||||
rollData.isReroll = false
|
||||
rollData.traits = duplicate(this.getRollTraits())
|
||||
rollData.spleen = duplicate(this.getSpleen() || {})
|
||||
rollData.ideal = duplicate(this.getIdeal() || {})
|
||||
rollData.confrontBonus = this.getBonusList()
|
||||
|
||||
return rollData
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getCommonSkill(categKey, skillKey) {
|
||||
let skill = this.system.skills[categKey].skilllist[skillKey]
|
||||
getCommonCompetence(skillid) {
|
||||
let rollData = this.getCommonRollData()
|
||||
|
||||
skill = duplicate(skill)
|
||||
skill.categKey = categKey
|
||||
skill.skillKey = skillKey
|
||||
skill.spec = this.getSpecializations(skillKey)
|
||||
let competence = duplicate(this.items.find(it => it.type =="competence" && it.id == skillid))
|
||||
|
||||
rollData.skill = skill
|
||||
rollData.img = skill.img
|
||||
rollData.impactMalus = this.getImpactMalus(categKey)
|
||||
rollData.competence = competence
|
||||
rollData.img = competence.img
|
||||
|
||||
return rollData
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
rollSkill(categKey, skillKey) {
|
||||
let rollData = this.getCommonSkill(categKey, skillKey)
|
||||
rollData.mode = "skill"
|
||||
rollData.title = game.i18n.localize(rollData.skill.name)
|
||||
rollCompetence(skillId) {
|
||||
let rollData = this.getCommonCompetence(skillId)
|
||||
rollData.mode = "competence"
|
||||
rollData.title = rollData.competence.name
|
||||
this.startRoll(rollData).catch("Error on startRoll")
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
rollSpec(categKey, skillKey, specId) {
|
||||
let rollData = this.getCommonSkill(categKey, skillKey)
|
||||
let spec = this.items.find(it => it.type == "specialization" && it.id == specId)
|
||||
rollData.mode = "skill"
|
||||
rollData.selectedSpecs = [spec.id]
|
||||
rollData.forcedSpec = duplicate(spec)
|
||||
rollData.title = game.i18n.localize(rollData.skill.name)
|
||||
this.startRoll(rollData).catch("Error on startRoll")
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async rollSkillConfront(categKey, skillKey) {
|
||||
let rollData = this.getCommonSkill(categKey, skillKey)
|
||||
rollData.mode = "skill"
|
||||
rollData.title = game.i18n.localize("ECRY.ui.confrontation") + " : " + game.i18n.localize(rollData.skill.name)
|
||||
rollData.executionTotal = rollData.skill.value
|
||||
rollData.preservationTotal = rollData.skill.value
|
||||
rollData.applyTranscendence = "execution"
|
||||
rollData.traitsBonus = duplicate(rollData.traits)
|
||||
rollData.traitsMalus = duplicate(rollData.traits)
|
||||
let confrontStartDialog = await EcrymeConfrontStartDialog.create(this, rollData)
|
||||
confrontStartDialog.render(true)
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
async rollCephalySkillConfront(skillKey) {
|
||||
let rollData = this.getCommonRollData()
|
||||
rollData.mode = "cephaly"
|
||||
rollData.skill = duplicate(this.system.cephaly.skilllist[skillKey])
|
||||
rollData.annency = duplicate(this.getAnnency())
|
||||
rollData.img = rollData.skill.img
|
||||
rollData.skill.categKey = "cephaly"
|
||||
rollData.skill.skillKey = skillKey
|
||||
//rollData.impactMalus = this.getImpactMalus(categKey)
|
||||
rollData.title = game.i18n.localize("ECRY.ui.cephaly") + " : " + game.i18n.localize(rollData.skill.name)
|
||||
rollData.executionTotal = rollData.skill.value
|
||||
rollData.preservationTotal = rollData.skill.value
|
||||
rollData.traitsBonus = duplicate(rollData.traits)
|
||||
rollData.traitsMalus = duplicate(rollData.traits)
|
||||
rollData.applyTranscendence = "execution"
|
||||
let confrontStartDialog = await EcrymeConfrontStartDialog.create(this, rollData)
|
||||
confrontStartDialog.render(true)
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async rollWeaponConfront(weaponId) {
|
||||
let weapon = this.items.get(weaponId)
|
||||
let rollData
|
||||
if (weapon && weapon.system.weapontype == "melee") {
|
||||
rollData = this.getCommonSkill("physical", "fencing")
|
||||
} else {
|
||||
rollData = this.getCommonSkill("physical", "shooting")
|
||||
}
|
||||
rollData.mode = "weapon"
|
||||
rollData.weapon = duplicate(weapon)
|
||||
rollData.title = game.i18n.localize("ECRY.ui.confrontation") + " : " + game.i18n.localize(rollData.skill.name)
|
||||
rollData.executionTotal = rollData.skill.value
|
||||
rollData.preservationTotal = rollData.skill.value
|
||||
rollData.traitsBonus = duplicate(rollData.traits)
|
||||
rollData.traitsMalus = duplicate(rollData.traits)
|
||||
rollData.applyTranscendence = "execution"
|
||||
let confrontStartDialog = await EcrymeConfrontStartDialog.create(this, rollData)
|
||||
confrontStartDialog.render(true)
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
rollWeapon(weaponId) {
|
||||
let weapon = this.items.get(weaponId)
|
||||
rollArme(armeId) {
|
||||
let weapon = this.items.get(armeId)
|
||||
if (weapon) {
|
||||
weapon = duplicate(weapon)
|
||||
let rollData = this.getCommonRollData()
|
||||
if (weapon.system.armetype == "mainsnues" || weapon.system.armetype == "epee") {
|
||||
rollData.attr = { label: "(Physique+Habilité)/2", value: Math.floor((this.getPhysiqueMalus() + this.system.attributs.physique.value + this.system.attributs.habilite.value) / 2) }
|
||||
} else {
|
||||
rollData.attr = duplicate(this.system.attributs.habilite)
|
||||
}
|
||||
rollData.mode = "weapon"
|
||||
rollData.weapon = weapon
|
||||
rollData.mode = "arme"
|
||||
rollData.arme = weapon
|
||||
rollData.img = weapon.img
|
||||
rollData.title = weapon.name
|
||||
this.startRoll(rollData).catch("Error on startRoll")
|
||||
|
@ -7,7 +7,6 @@ export class TeDeumUtility {
|
||||
static async init() {
|
||||
Hooks.on('renderChatLog', (log, html, data) => TeDeumUtility.chatListeners(html));
|
||||
Hooks.on("getChatLogEntryContext", (html, options) => TeDeumUtility.chatMenuManager(html, options));
|
||||
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -51,52 +50,6 @@ export class TeDeumUtility {
|
||||
return game.user.isGM
|
||||
})
|
||||
|
||||
game.settings.register("fvtt-ecryme", "ecryme-game-level", {
|
||||
name: game.i18n.localize("ECRY.settings.gamelevel"),
|
||||
label: game.i18n.localize("ECRY.settings.gamelevelhelp"),
|
||||
scope: 'world',
|
||||
config: true,
|
||||
type: String,
|
||||
choices: {
|
||||
"level_e": game.i18n.localize("ECRY.settings.cogs"),
|
||||
"level_c": game.i18n.localize("ECRY.settings.cephaly"),
|
||||
"level_b": game.i18n.localize("ECRY.settings.boheme"),
|
||||
"level_a": game.i18n.localize("ECRY.settings.amertume"),
|
||||
},
|
||||
restricted: true
|
||||
})
|
||||
|
||||
this.buildSkillConfig()
|
||||
|
||||
}
|
||||
|
||||
/*-------------------------------------------- */
|
||||
static hasCephaly() {
|
||||
let level = game.settings.get("fvtt-ecryme", "ecryme-game-level")
|
||||
return level != "level_e"
|
||||
}
|
||||
/*-------------------------------------------- */
|
||||
static hasBoheme() {
|
||||
let level = game.settings.get("fvtt-ecryme", "ecryme-game-level")
|
||||
return level == "level_b" || level == "level_a"
|
||||
}
|
||||
/*-------------------------------------------- */
|
||||
static hasAmertume() {
|
||||
let level = game.settings.get("fvtt-ecryme", "ecryme-game-level")
|
||||
return level == "level_a"
|
||||
}
|
||||
|
||||
/*-------------------------------------------- */
|
||||
static buildSkillConfig() {
|
||||
game.system.ecryme.config.skills = {}
|
||||
for (let categKey in game.data.template.Actor.templates.core.skills) {
|
||||
let category = game.data.template.Actor.templates.core.skills[categKey]
|
||||
for (let skillKey in category.skilllist) {
|
||||
let skill = duplicate(category.skilllist[skillKey])
|
||||
skill.categKey = categKey // Auto reference the category
|
||||
game.system.ecryme.config.skills[skillKey] = skill
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*-------------------------------------------- */
|
||||
@ -113,7 +66,7 @@ export class TeDeumUtility {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async loadCompendium(compendium, filter = item => true) {
|
||||
let compendiumData = await EcrymeUtility.loadCompendiumData(compendium)
|
||||
let compendiumData = await TeDeumUtility.loadCompendiumData(compendium)
|
||||
return compendiumData.filter(filter)
|
||||
}
|
||||
|
||||
@ -128,162 +81,32 @@ export class TeDeumUtility {
|
||||
}
|
||||
return actor
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
static getImpactFromEffect(effectValue) {
|
||||
if (effectValue >= __effect2Impact.length) {
|
||||
return "major"
|
||||
}
|
||||
return __effect2Impact[effectValue]
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
static async processConfrontation() {
|
||||
let confront = {
|
||||
type: "confront-data",
|
||||
rollData1: this.confrontData1,
|
||||
rollData2: this.confrontData2,
|
||||
}
|
||||
// Compute margin
|
||||
confront.marginExecution = this.confrontData1.executionTotal - this.confrontData2.preservationTotal
|
||||
confront.marginPreservation = this.confrontData1.preservationTotal - this.confrontData2.executionTotal
|
||||
console.log(confront.marginExecution, confront.marginPreservation)
|
||||
// Filter margin
|
||||
let maxMargin // Dummy max
|
||||
if (confront.marginExecution > 0) { // Successful hit
|
||||
// Limit with skill+spec
|
||||
maxMargin = confront.rollData1.skill.value + ((confront.rollData1.spec) ? 2 : 0)
|
||||
confront.marginExecution = Math.min(confront.marginExecution, maxMargin)
|
||||
} else { // Failed hit
|
||||
maxMargin = confront.rollData2.skill.value + ((confront.rollData2.spec) ? 2 : 0)
|
||||
confront.marginExecution = -Math.min(Math.abs(confront.marginExecution), maxMargin)
|
||||
}
|
||||
|
||||
if (confront.marginPreservation > 0) { // Successful defense
|
||||
// Limit with skill+spec
|
||||
maxMargin = confront.rollData1.skill.value + ((confront.rollData1.spec) ? 2 : 0)
|
||||
confront.marginPreservation = Math.min(confront.marginPreservation, maxMargin)
|
||||
} else { // Failed defense
|
||||
maxMargin = confront.rollData2.skill.value + ((confront.rollData2.spec) ? 2 : 0)
|
||||
confront.marginPreservation = - Math.min(Math.abs(confront.marginPreservation), maxMargin)
|
||||
}
|
||||
|
||||
// Compute effects
|
||||
confront.effectExecution = confront.marginExecution
|
||||
if (confront.rollData1.weapon && confront.marginExecution > 0) {
|
||||
confront.effectExecution += confront.rollData1.weapon.system.effect
|
||||
confront.impactExecution = this.getImpactFromEffect(confront.effectExecution)
|
||||
}
|
||||
if (confront.marginExecution < 0) {
|
||||
confront.bonus2 = -confront.marginExecution
|
||||
}
|
||||
confront.effectPreservation = confront.marginPreservation
|
||||
if (confront.rollData2.weapon && confront.marginPreservation < 0) {
|
||||
confront.effectPreservation = - (Math.abs(confront.marginPreservation) + confront.rollData2.weapon.system.effect)
|
||||
confront.impactPreservation = this.getImpactFromEffect(Math.abs(confront.effectPreservation))
|
||||
}
|
||||
if (confront.marginPreservation > 0) {
|
||||
confront.bonus1 = -confront.marginPreservation
|
||||
}
|
||||
|
||||
let msg = await this.createChatWithRollMode(this.confrontData1.alias, {
|
||||
content: await renderTemplate(`systems/fvtt-ecryme/templates/chat/chat-confrontation-result.hbs`, confront)
|
||||
})
|
||||
await msg.setFlag("world", "ecryme-rolldata", confront)
|
||||
console.log("Confront result", confront)
|
||||
|
||||
this.lastConfront = confront
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
static async manageCephalyDifficulty(rollData, difficulty) {
|
||||
rollData.difficulty = Number(difficulty)
|
||||
if (rollData.executionTotal > difficulty) {
|
||||
rollData.marginExecution = rollData.executionTotal - difficulty
|
||||
rollData.cephalySuccess = "ECRY.rule." + __cephalySuccess[(rollData.marginExecution > 10) ? 10 : rollData.marginExecution]
|
||||
} else {
|
||||
rollData.marginExecution = -1
|
||||
}
|
||||
if (rollData.preservationTotal < difficulty) {
|
||||
rollData.marginPreservation = difficulty - rollData.preservationTotal
|
||||
rollData.cephalyFailure = "ECRY.rule." + __cephalyFailure[(rollData.marginPreservation > 10) ? 10 : rollData.marginPreservation]
|
||||
} else {
|
||||
rollData.marginPreservation = -1
|
||||
}
|
||||
let msg = await this.createChatWithRollMode(rollData.alias, {
|
||||
content: await renderTemplate(`systems/fvtt-ecryme/templates/chat/chat-cephaly-result.hbs`, rollData)
|
||||
})
|
||||
msg.setFlag("world", "ecryme-rolldata", rollData)
|
||||
console.log("Cephaly result", rollData)
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static manageConfrontation(rollData) {
|
||||
console.log("Confront", rollData)
|
||||
// Auto - Reset
|
||||
if (this.confrontData1 && this.confrontData2) {
|
||||
this.confrontData1 = undefined
|
||||
this.confrontData2 = undefined
|
||||
}
|
||||
// Then attribute
|
||||
if (!this.confrontData1) {
|
||||
this.confrontData1 = rollData
|
||||
} else if (this.confrontData1 && this.confrontData1.rollId != rollData.rollId) {
|
||||
this.confrontData2 = rollData
|
||||
this.processConfrontation().catch("Error during confrontation processing")
|
||||
} else {
|
||||
ui.notifications.warn(game.i18n.localize("ECRY.warn.confrontalready"))
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static chatMenuManager(html, options) {
|
||||
let canTranscendRoll = []
|
||||
for (let i = 1; i <= 10; i++) {
|
||||
canTranscendRoll[i] = function (li) {
|
||||
let message = game.messages.get(li.attr("data-message-id"))
|
||||
let rollData = message.getFlag("world", "rolldata")
|
||||
//console.log(">>>>>>>>>>>>>>>>>>>>>>>>>> Menu !!!!", rollData)
|
||||
if (rollData.skill && i <= rollData.skill.value && !rollData.transcendUsed && rollData.spec) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
options.push({
|
||||
name: game.i18n.localize("ECRY.chat.spectranscend") + i,
|
||||
icon: '<i class="fas fa-plus-square"></i>',
|
||||
condition: canTranscendRoll[i],
|
||||
callback: li => {
|
||||
let message = game.messages.get(li.attr("data-message-id"))
|
||||
let rollData = message.getFlag("world", "rolldata")
|
||||
EcrymeUtility.transcendFromSpec(rollData, i).catch("Error on Transcend")
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
/* -------------------------------------------- */ /* -------------------------------------------- */
|
||||
static async chatListeners(html) {
|
||||
|
||||
html.on("click", '.button-select-confront', event => {
|
||||
let messageId = EcrymeUtility.findChatMessageId(event.currentTarget)
|
||||
let messageId = TeDeumUtility.findChatMessageId(event.currentTarget)
|
||||
let message = game.messages.get(messageId)
|
||||
let rollData = message.getFlag("world", "ecryme-rolldata")
|
||||
ui.notifications.info( game.i18n.localize("ECRY.chat.confrontselect"))
|
||||
EcrymeUtility.manageConfrontation(rollData)
|
||||
TeDeumUtility.manageConfrontation(rollData)
|
||||
})
|
||||
html.on("click", '.button-apply-cephaly-difficulty', event => {
|
||||
let messageId = EcrymeUtility.findChatMessageId(event.currentTarget)
|
||||
let messageId = TeDeumUtility.findChatMessageId(event.currentTarget)
|
||||
let message = game.messages.get(messageId)
|
||||
let rollData = message.getFlag("world", "ecryme-rolldata")
|
||||
let difficulty = $("#" + rollData.rollId + "-cephaly-difficulty").val()
|
||||
EcrymeUtility.manageCephalyDifficulty(rollData, difficulty)
|
||||
TeDeumUtility.manageCephalyDifficulty(rollData, difficulty)
|
||||
})
|
||||
html.on("click", '.button-apply-impact', event => {
|
||||
let messageId = EcrymeUtility.findChatMessageId(event.currentTarget)
|
||||
let messageId = TeDeumUtility.findChatMessageId(event.currentTarget)
|
||||
let message = game.messages.get(messageId)
|
||||
let actor = game.actors.get($(event.currentTarget).data("actor-id"))
|
||||
actor.modifyImpact($(event.currentTarget).data("impact-type"), $(event.currentTarget).data("impact"), 1)
|
||||
})
|
||||
html.on("click", '.button-apply-bonus', event => {
|
||||
let messageId = EcrymeUtility.findChatMessageId(event.currentTarget)
|
||||
let messageId = TeDeumUtility.findChatMessageId(event.currentTarget)
|
||||
let message = game.messages.get(messageId)
|
||||
let actor = game.actors.get($(event.currentTarget).data("actor-id"))
|
||||
actor.modifyConfrontBonus($(event.currentTarget).data("bonus"))
|
||||
@ -295,14 +118,14 @@ export class TeDeumUtility {
|
||||
static async preloadHandlebarsTemplates() {
|
||||
|
||||
const templatePaths = [
|
||||
'systems/fvtt-ecryme/templates/actors/editor-notes-gm.hbs',
|
||||
'systems/fvtt-ecryme/templates/items/partial-item-nav.hbs',
|
||||
'systems/fvtt-ecryme/templates/items/partial-item-equipment.hbs',
|
||||
'systems/fvtt-ecryme/templates/items/partial-item-description.hbs',
|
||||
'systems/fvtt-ecryme/templates/dialogs/partial-common-roll-dialog.hbs',
|
||||
'systems/fvtt-ecryme/templates/dialogs/partial-confront-dice-area.hbs',
|
||||
'systems/fvtt-ecryme/templates/dialogs/partial-confront-bonus-area.hbs',
|
||||
'systems/fvtt-ecryme/templates/actors/partial-impacts.hbs',
|
||||
'systems/fvtt-te-deum/templates/actors/editor-notes-gm.hbs',
|
||||
'systems/fvtt-te-deum/templates/items/partial-item-nav.hbs',
|
||||
'systems/fvtt-te-deum/templates/items/partial-item-equipment.hbs',
|
||||
'systems/fvtt-te-deum/templates/items/partial-item-description.hbs',
|
||||
'systems/fvtt-te-deum/templates/dialogs/partial-common-roll-dialog.hbs',
|
||||
'systems/fvtt-te-deum/templates/dialogs/partial-confront-dice-area.hbs',
|
||||
'systems/fvtt-te-deum/templates/dialogs/partial-confront-bonus-area.hbs',
|
||||
'systems/fvtt-te-deum/templates/actors/partial-impacts.hbs',
|
||||
]
|
||||
return loadTemplates(templatePaths);
|
||||
}
|
||||
@ -315,7 +138,7 @@ export class TeDeumUtility {
|
||||
}
|
||||
|
||||
static findChatMessageId(current) {
|
||||
return EcrymeUtility.getChatMessageId(EcrymeUtility.findChatMessage(current));
|
||||
return TeDeumUtility.getChatMessageId(TeDeumUtility.findChatMessage(current));
|
||||
}
|
||||
|
||||
static getChatMessageId(node) {
|
||||
@ -323,7 +146,7 @@ export class TeDeumUtility {
|
||||
}
|
||||
|
||||
static findChatMessage(current) {
|
||||
return EcrymeUtility.findNodeMatching(current, it => it.classList.contains('chat-message') && it.attributes.getNamedItem('data-message-id'));
|
||||
return TeDeumUtility.findNodeMatching(current, it => it.classList.contains('chat-message') && it.attributes.getNamedItem('data-message-id'));
|
||||
}
|
||||
|
||||
static findNodeMatching(current, predicate) {
|
||||
@ -331,7 +154,7 @@ export class TeDeumUtility {
|
||||
if (predicate(current)) {
|
||||
return current;
|
||||
}
|
||||
return EcrymeUtility.findNodeMatching(current.parentElement, predicate);
|
||||
return TeDeumUtility.findNodeMatching(current.parentElement, predicate);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
@ -384,7 +207,7 @@ export class TeDeumUtility {
|
||||
content: await renderTemplate(msg.data.template, rollData),
|
||||
whisper: game.user.id
|
||||
})
|
||||
chatMsg.setFlag("world", "ecryme-rolldata", rollData)
|
||||
chatMsg.setFlag("world", "tedeum-rolldata", rollData)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -471,55 +294,12 @@ export class TeDeumUtility {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static computeRollFormula(rollData, actor, isConfrontation = false) {
|
||||
// Build the dice formula
|
||||
let diceFormula = (isConfrontation) ? "4d6" : "2d6"
|
||||
if (rollData.useIdeal) {
|
||||
diceFormula = (isConfrontation) ? "5d6kh2" : "3d6kh2"
|
||||
}
|
||||
if (rollData.useSpleen) {
|
||||
diceFormula = (isConfrontation) ? "5d6kl2" : "3d6kl2"
|
||||
}
|
||||
if (rollData.skill) {
|
||||
diceFormula += "+" + rollData.skill.value
|
||||
}
|
||||
if (rollData.skillTranscendence) {
|
||||
diceFormula += "+" + rollData.skillTranscendence
|
||||
actor.spentSkillTranscendence(rollData.skill, rollData.skillTranscendence)
|
||||
}
|
||||
if (rollData.selectedSpecs && rollData.selectedSpecs.length > 0) {
|
||||
rollData.spec = actor.getSpecialization(rollData.selectedSpecs[0])
|
||||
diceFormula += "+" + (String(rollData.spec.system?.bonus) || "2")
|
||||
}
|
||||
rollData.bonusMalusTraits = 0
|
||||
if (rollData.traitsBonus && rollData.traitsBonus.length > 0) {
|
||||
rollData.traitsBonusList = []
|
||||
for (let id of rollData.traitsBonus) {
|
||||
let trait = actor.getTrait(id)
|
||||
console.log(trait, id)
|
||||
rollData.traitsBonusList.push(trait)
|
||||
rollData.bonusMalusTraits += trait.system.level
|
||||
}
|
||||
}
|
||||
if (rollData.traitsMalus && rollData.traitsMalus.length > 0) {
|
||||
rollData.traitsMalusList = []
|
||||
for (let id of rollData.traitsMalus) {
|
||||
let trait = actor.getTrait(id)
|
||||
rollData.traitsMalusList.push(trait)
|
||||
rollData.bonusMalusTraits -= trait.system.level
|
||||
}
|
||||
}
|
||||
diceFormula += "+" + rollData.bonusMalusTraits
|
||||
diceFormula += "+" + rollData.bonusMalusPerso
|
||||
diceFormula += "+" + rollData.impactMalus
|
||||
if (rollData.annency) {
|
||||
diceFormula += "+" + rollData.annencyBonus
|
||||
}
|
||||
rollData.diceFormula = diceFormula
|
||||
rollData.diceFormula = ""
|
||||
return diceFormula
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async rollEcryme(rollData) {
|
||||
static async rollTeDeum(rollData) {
|
||||
|
||||
let actor = game.actors.get(rollData.actorId)
|
||||
// Fix difficulty
|
||||
@ -540,28 +320,12 @@ export class TeDeumUtility {
|
||||
this.computeResults(rollData)
|
||||
|
||||
let msg = await this.createChatWithRollMode(rollData.alias, {
|
||||
content: await renderTemplate(`systems/fvtt-ecryme/templates/chat/chat-generic-result.hbs`, rollData)
|
||||
content: await renderTemplate(`systems/fvtt-te-deum/templates/chat/chat-generic-result.hbs`, rollData)
|
||||
})
|
||||
await msg.setFlag("world", "ecryme-rolldata", rollData)
|
||||
console.log("Rolldata result", rollData)
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async transcendFromSpec(rollData, value) {
|
||||
rollData.total += value
|
||||
rollData.transcendUsed = true
|
||||
this.computeResults(rollData)
|
||||
//console.log("Adding spec", value, rollData.total)
|
||||
|
||||
let actor = game.actors.get(rollData.actorId)
|
||||
actor.spentSkillTranscendence(rollData.skill, value)
|
||||
|
||||
let msg = await this.createChatWithRollMode(rollData.alias, {
|
||||
content: await renderTemplate(`systems/fvtt-ecryme/templates/chat/chat-generic-result.hbs`, rollData)
|
||||
})
|
||||
await msg.setFlag("world", "ecryme-rolldata", rollData)
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static sortArrayObjectsByName(myArray) {
|
||||
myArray.sort((a, b) => {
|
||||
@ -606,7 +370,7 @@ export class TeDeumUtility {
|
||||
static blindMessageToGM(chatData) {
|
||||
chatData.whisper = this.getUsers(user => user.isGM);
|
||||
console.log("blindMessageToGM", chatData);
|
||||
game.socket.emit("system.fvtt-ecryme", { name: "msg_gm_chat_message", data: chatData });
|
||||
game.socket.emit("system.fvtt-te-deum", { name: "msg_gm_chat_message", data: chatData });
|
||||
}
|
||||
|
||||
|
||||
@ -650,26 +414,17 @@ export class TeDeumUtility {
|
||||
let rollData = {
|
||||
rollId: randomID(16),
|
||||
type: "roll-data",
|
||||
bonusMalusPerso: 0,
|
||||
bonusMalusSituation: 0,
|
||||
bonusMalusDef: 0,
|
||||
annencyBonus: 0,
|
||||
bonusMalusPortee: 0,
|
||||
skillTranscendence: 0,
|
||||
rollMode: game.settings.get("core", "rollMode"),
|
||||
difficulty: "-",
|
||||
useSpleen: false,
|
||||
useIdeal: false,
|
||||
impactMalus: 0,
|
||||
config: duplicate(game.system.ecryme.config)
|
||||
difficulty: "pardefaut",
|
||||
config: duplicate(game.system.tedeum.config)
|
||||
}
|
||||
EcrymeUtility.updateWithTarget(rollData)
|
||||
TeDeumUtility.updateWithTarget(rollData)
|
||||
return rollData
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static updateWithTarget(rollData) {
|
||||
let target = EcrymeUtility.getTarget()
|
||||
let target = TeDeumUtility.getTarget()
|
||||
if (target) {
|
||||
rollData.defenderTokenId = target.id
|
||||
}
|
||||
@ -683,11 +438,11 @@ export class TeDeumUtility {
|
||||
/* -------------------------------------------- */
|
||||
static async confirmDelete(actorSheet, li) {
|
||||
let itemId = li.data("item-id");
|
||||
let msgTxt = "<p>Are you sure to remove this Item ?";
|
||||
let msgTxt = "<p>Etes vous certain de supprimer cet item ?";
|
||||
let buttons = {
|
||||
delete: {
|
||||
icon: '<i class="fas fa-check"></i>',
|
||||
label: "Yes, remove it",
|
||||
label: "Oui, aucun souci",
|
||||
callback: () => {
|
||||
actorSheet.actor.deleteEmbeddedDocuments("Item", [itemId]);
|
||||
li.slideUp(200, () => actorSheet.render(false));
|
||||
@ -695,12 +450,12 @@ export class TeDeumUtility {
|
||||
},
|
||||
cancel: {
|
||||
icon: '<i class="fas fa-times"></i>',
|
||||
label: "Cancel"
|
||||
label: "Annuler"
|
||||
}
|
||||
}
|
||||
msgTxt += "</p>";
|
||||
let d = new Dialog({
|
||||
title: "Confirm removal",
|
||||
title: "Confimer la suppression",
|
||||
content: msgTxt,
|
||||
buttons: buttons,
|
||||
default: "cancel"
|
||||
|
22
modules/data/tedeum-schema-armure.js
Normal file
22
modules/data/tedeum-schema-armure.js
Normal file
@ -0,0 +1,22 @@
|
||||
export default class TeDeumArmureSchema extends foundry.abstract.TypeDataModel {
|
||||
static defineSchema() {
|
||||
const fields = foundry.data.fields;
|
||||
const requiredInteger = { required: true, nullable: false, integer: true };
|
||||
const schema = {};
|
||||
|
||||
schema.localisation = new fields.SchemaField(
|
||||
Object.values(LOCALISATION).reduce((obj, loc) => {
|
||||
obj[loc.id] =new fields.SchemaField({
|
||||
protege: new fields.BooleanField({initial: false}),
|
||||
});
|
||||
return obj;
|
||||
}, {})
|
||||
);
|
||||
|
||||
schema.protection = new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 });
|
||||
|
||||
schema.description = new fields.HTMLField({ required: true, blank: true });
|
||||
|
||||
return schema;
|
||||
}
|
||||
}
|
11
modules/data/tedeum-schema-equipement.js
Normal file
11
modules/data/tedeum-schema-equipement.js
Normal file
@ -0,0 +1,11 @@
|
||||
export default class TeDeumArmureSchema extends foundry.abstract.TypeDataModel {
|
||||
static defineSchema() {
|
||||
const fields = foundry.data.fields;
|
||||
const requiredInteger = { required: true, nullable: false, integer: true };
|
||||
const schema = {};
|
||||
|
||||
schema.description = new fields.HTMLField({ required: true, blank: true });
|
||||
|
||||
return schema;
|
||||
}
|
||||
}
|
@ -52,7 +52,7 @@ export class TeDeumRollDialog extends Dialog {
|
||||
activateListeners(html) {
|
||||
super.activateListeners(html);
|
||||
|
||||
var dialog = this;
|
||||
let dialog = this;
|
||||
function onLoad() {
|
||||
}
|
||||
$(function () { onLoad(); });
|
||||
|
@ -1,9 +1,9 @@
|
||||
import { TeDeumUtility } from "../common/tedeum-utility.js";
|
||||
|
||||
export const defaultItemImg = {
|
||||
arme: "systems/fvtt-ecryme/images/icons/icon_arme.webp",
|
||||
equipment: "systems/fvtt-ecryme/images/icons/icon_equipment.webp",
|
||||
competence: "systems/fvtt-ecryme/images/icons/icon_competence.webp",
|
||||
arme: "systems/fvtt-te-deum/images/icons/icon_arme.webp",
|
||||
equipement: "systems/fvtt-te-deum/images/icons/icon_equipement.webp",
|
||||
competence: "systems/fvtt-te-deum/images/icons/icon_competence.webp",
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -10,8 +10,12 @@
|
||||
// Import Modules
|
||||
import { TeDeumActor } from "./actors/tedeum-actor.js";
|
||||
import { TeDeumItemSheet } from "./items/tedeum-item-sheet.js";
|
||||
import { TeDeumActorSheet } from "./actors/tedeum-actor-sheet.js";
|
||||
import { TeDeumActorPJSheet } from "./actors/tedeum-actor-sheet.js";
|
||||
import { TeDeumPJSchema } from "./common/tedeum-schema-pj.js";
|
||||
import { TeDeumArmeSchema } from "./common/tedeum-schema-arme.js";
|
||||
import { TeDeumArmureSchema } from "./common/tedeum-schema-armure.js";
|
||||
import { TeDeumCompetenceSchema } from "./common/tedeum-schema-competence.js";
|
||||
import { TeDeumEquipementSchema } from "./common/tedeum-schema-equipement.js";
|
||||
import { TeDeumUtility } from "./common/tedeum-utility.js";
|
||||
import { TeDeumCombat } from "./app/tedeum-combat.js";
|
||||
import { TeDeumItem } from "./items/tedeum-item.js";
|
||||
@ -56,8 +60,10 @@ Hooks.once("init", async function () {
|
||||
pnj: TeDeumPJSchema,
|
||||
};
|
||||
CONFIG.Item.dataModels = {
|
||||
arme: models.TeDeumArmeSchema,
|
||||
competence: models.TeDeumCompetenceSchema,
|
||||
arme: TeDeumArmeSchema,
|
||||
competence: TeDeumCompetenceSchema,
|
||||
equipement: TeDeumEquipementSchema,
|
||||
armure: TeDeumArmureSchema,
|
||||
};
|
||||
|
||||
Actors.unregisterSheet("core", ActorSheet);
|
||||
|
@ -5,8 +5,10 @@
|
||||
"pnj": {}
|
||||
},
|
||||
"Item": {
|
||||
"types": ["arme", "competence"],
|
||||
"types": ["arme", "competence", "armure", "equipement"],
|
||||
"arme": {},
|
||||
"competence": {}
|
||||
"competence": {},
|
||||
"armure": {},
|
||||
"equipement": {}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user