Initial import
This commit is contained in:
@@ -42,13 +42,7 @@ export class WastelandActorSheet extends ActorSheet {
|
||||
skills: this.actor.getSkills(),
|
||||
armes: duplicate(this.actor.getWeapons()),
|
||||
protections: duplicate(this.actor.getArmors()),
|
||||
dons: duplicate(this.actor.getDons()),
|
||||
alignement: this.actor.getAlignement(),
|
||||
aspect: this.actor.getAspect(),
|
||||
marge: this.actor.getMarge(),
|
||||
tendances:duplicate(this.actor.getTendances()),
|
||||
runes:duplicate(this.actor.getRunes()),
|
||||
traitsChaotiques:duplicate(this.actor.getTraitsChaotiques()),
|
||||
pouvoirs:duplicate(this.actor.getPouvoirs()),
|
||||
origine: duplicate(this.actor.getOrigine() || {}),
|
||||
heritage: duplicate(this.actor.getHeritage() || {}),
|
||||
metier: duplicate(this.actor.getMetier() || {}),
|
||||
@@ -118,10 +112,10 @@ export class WastelandActorSheet extends ActorSheet {
|
||||
let compId = li.data("item-id")
|
||||
this.actor.rollCompetence(attrKey, compId)
|
||||
})
|
||||
html.find('.roll-rune').click((event) => {
|
||||
html.find('.roll-pouvoir').click((event) => {
|
||||
const li = $(event.currentTarget).parents(".item")
|
||||
let runeId = li.data("item-id")
|
||||
this.actor.rollRune(runeId)
|
||||
let pouvoirId = li.data("item-id")
|
||||
this.actor.rollPouvoir(pouvoirId)
|
||||
})
|
||||
html.find('.roll-arme-offensif').click((event) => {
|
||||
const li = $(event.currentTarget).parents(".item")
|
||||
|
@@ -106,21 +106,12 @@ export class WastelandActor extends Actor {
|
||||
WastelandUtility.sortArrayObjectsByName(items)
|
||||
return items
|
||||
}
|
||||
getDons() {
|
||||
return this.getItemSorted(["don"])
|
||||
}
|
||||
getTendances() {
|
||||
return this.getItemSorted(["tendance"])
|
||||
}
|
||||
getRunes() {
|
||||
return this.getItemSorted(["rune"])
|
||||
getPouvoirs() {
|
||||
return this.getItemSorted(["pouvoir"])
|
||||
}
|
||||
getEquipments() {
|
||||
return this.getItemSorted(["equipement"])
|
||||
}
|
||||
getTraitsChaotiques() {
|
||||
return this.getItemSorted(["traitchaotique"])
|
||||
}
|
||||
getMonnaies() {
|
||||
return this.getItemSorted(["monnaie"])
|
||||
}
|
||||
@@ -160,17 +151,6 @@ export class WastelandActor extends Actor {
|
||||
return comp
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getAspect() {
|
||||
return (this.system.balance.loi > this.system.balance.chaos) ? this.system.balance.loi : this.system.balance.chaos
|
||||
}
|
||||
getMarge() {
|
||||
return Math.abs( this.system.balance.loi - this.system.balance.chaos)
|
||||
}
|
||||
getAlignement() {
|
||||
return (this.system.balance.loi > this.system.balance.chaos) ? "loyal" : "chaotique"
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getDefenseBase() {
|
||||
return this.system.attributs.tre.value + 5
|
||||
@@ -213,9 +193,9 @@ export class WastelandActor extends Actor {
|
||||
if (this.system.sante.base != newSante) {
|
||||
this.update({ 'system.sante.base': newSante })
|
||||
}
|
||||
let newAme = (this.system.attributs.cla.value + this.system.attributs.tre.value) * this.system.biodata.amemultiplier + 5
|
||||
if (this.system.ame.fullmax != newAme) {
|
||||
this.update({ 'system.ame.fullmax': newAme })
|
||||
let newPsyche = (this.system.attributs.cla.value + this.system.attributs.tre.value) * this.system.biodata.psychemultiplier + 5
|
||||
if (this.system.psyche.fullmax != newPsyche) {
|
||||
this.update({ 'system.psyche.fullmax': newPsyche })
|
||||
}
|
||||
}
|
||||
|
||||
@@ -240,7 +220,7 @@ export class WastelandActor extends Actor {
|
||||
/* -------------------------------------------- */
|
||||
async equipItem(itemId) {
|
||||
let item = this.items.find(item => item.id == itemId)
|
||||
if (item && item.system) {
|
||||
if (item?.system) {
|
||||
let update = { _id: item.id, "system.equipped": !item.system.equipped }
|
||||
await this.updateEmbeddedDocuments('Item', [update]); // Updates one EmbeddedEntity
|
||||
}
|
||||
@@ -286,18 +266,10 @@ export class WastelandActor extends Actor {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
canEclatDoubleD20() {
|
||||
return (this.getAlignement() == "loyal" && this.system.eclat.value > 0)
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
subPointsAme(runeMode, value) {
|
||||
let ame = duplicate(this.system.ame)
|
||||
if(runeMode == "prononcer") {
|
||||
ame.value -= value
|
||||
} else {
|
||||
ame.currentmax -= value
|
||||
}
|
||||
this.update( {'system.ame': ame})
|
||||
subPointsPsyche(value) {
|
||||
let psyche = duplicate(this.system.psyche)
|
||||
psyche.currentmax -= value
|
||||
this.update( {'system.psyche': psyche})
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@@ -324,7 +296,7 @@ export class WastelandActor extends Actor {
|
||||
/* -------------------------------------------- */
|
||||
async equipGear(equipmentId) {
|
||||
let item = this.items.find(item => item.id == equipmentId);
|
||||
if (item && item.system.data) {
|
||||
if (item?.system) {
|
||||
let update = { _id: item.id, "system.equipped": !item.system.equipped };
|
||||
await this.updateEmbeddedDocuments('Item', [update]); // Updates one EmbeddedEntity
|
||||
}
|
||||
@@ -360,7 +332,7 @@ export class WastelandActor extends Actor {
|
||||
let objetQ = this.items.get(objetId)
|
||||
if (objetQ) {
|
||||
let newQ = objetQ.system.quantite + incDec;
|
||||
const updated = await this.updateEmbeddedDocuments('Item', [{ _id: objetQ.id, 'system.quantite': newQ }]); // pdates one EmbeddedEntity
|
||||
await this.updateEmbeddedDocuments('Item', [{ _id: objetQ.id, 'system.quantite': newQ }]); // pdates one EmbeddedEntity
|
||||
}
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
@@ -408,7 +380,7 @@ export class WastelandActor extends Actor {
|
||||
rollData.actorId = this.id
|
||||
rollData.tokenId = this.token?.id
|
||||
rollData.img = this.img
|
||||
rollData.canEclatDoubleD20 = this.canEclatDoubleD20()
|
||||
rollData.canEclatDoubleD20 = true // Always true in Wastelan
|
||||
rollData.doubleD20 = false
|
||||
rollData.attributs = WastelandUtility.getAttributs()
|
||||
|
||||
@@ -446,7 +418,7 @@ export class WastelandActor extends Actor {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async rollRune(runeId) {
|
||||
async rollPouvoir(pouvoirId) {
|
||||
let comp = this.items.find(comp => comp.type == "competence" && comp.name.toLowerCase() == "savoir : runes")
|
||||
if ( !comp) {
|
||||
ui.notifications.warn("La compétence Savoirs : Runes n'a pas été trouvée, abandon.")
|
||||
|
@@ -36,7 +36,7 @@ Hooks.once("init", async function () {
|
||||
};
|
||||
|
||||
/* -------------------------------------------- */
|
||||
game.socket.on("system.fvtt-wasteland-rpg", data => {
|
||||
game.socket.on("system.fvtt-wasteland", data => {
|
||||
WastelandUtility.onSocketMesssage(data);
|
||||
});
|
||||
|
||||
@@ -114,11 +114,6 @@ Hooks.once("ready", function () {
|
||||
});
|
||||
}
|
||||
|
||||
// CSS patch for v9
|
||||
if (game.version) {
|
||||
let sidebar = document.getElementById("sidebar");
|
||||
sidebar.style.width = "min-content";
|
||||
}
|
||||
registerUsageCount('fvtt-wasteland')
|
||||
welcomeMessage();
|
||||
});
|
||||
|
@@ -536,40 +536,49 @@ export class WastelandUtility {
|
||||
/* -------------------------------------------- */
|
||||
static chatRollMenu(html, options) {
|
||||
let canApply = li => canvas.tokens.controlled.length && li.find(".wasteland-roll").length
|
||||
let canApplyBALoyal = function (li) {
|
||||
let hasBA = function (li) {
|
||||
let message = game.messages.get(li.attr("data-message-id"))
|
||||
let rollData = message.getFlag("world", "wasteland-roll")
|
||||
let actor = WastelandUtility.getActorFromRollData(rollData)
|
||||
return (!rollData.isReroll && actor.getBonneAventure() > 0 && actor.getAlignement() == "loyal")
|
||||
if (rollData?.actorId) {
|
||||
let actor = game.actors.get(rollData.actorId)
|
||||
return actor.getBonneAventure() > 0
|
||||
|
||||
}
|
||||
return false
|
||||
}
|
||||
let canApplyPELoyal = function (li) {
|
||||
let hasBA2 = function (li) {
|
||||
let message = game.messages.get(li.attr("data-message-id"))
|
||||
let rollData = message.getFlag("world", "wasteland-roll")
|
||||
let actor = WastelandUtility.getActorFromRollData(rollData)
|
||||
return (!rollData.isReroll && actor.getEclat() > 0 && actor.getAlignement() == "loyal")
|
||||
if (rollData?.actorId) {
|
||||
let actor = game.actors.get(rollData.actorId)
|
||||
return actor.getBonneAventure() >= 2
|
||||
|
||||
}
|
||||
return false
|
||||
}
|
||||
let canApplyBAChaotique = function (li) {
|
||||
let hasBA3 = function (li) {
|
||||
let message = game.messages.get(li.attr("data-message-id"))
|
||||
let rollData = message.getFlag("world", "wasteland-roll")
|
||||
let actor = WastelandUtility.getActorFromRollData(rollData)
|
||||
return (!rollData.isReroll && actor.getBonneAventure() > 0 && actor.getAlignement() == "chaotique")
|
||||
if (rollData?.actorId) {
|
||||
let actor = game.actors.get(rollData.actorId)
|
||||
return actor.getBonneAventure() >= 3
|
||||
|
||||
}
|
||||
return false
|
||||
}
|
||||
let canApplyBAChaotique3 = function (li) {
|
||||
let hasPE = function (li) {
|
||||
let message = game.messages.get(li.attr("data-message-id"))
|
||||
let rollData = message.getFlag("world", "wasteland-roll")
|
||||
let actor = WastelandUtility.getActorFromRollData(rollData)
|
||||
return (!rollData.isReroll && actor.getBonneAventure() > 2 && actor.getAlignement() == "chaotique")
|
||||
}
|
||||
let canApplyPEChaotique = function (li) {
|
||||
let message = game.messages.get(li.attr("data-message-id"))
|
||||
let rollData = message.getFlag("world", "wasteland-roll")
|
||||
let actor = WastelandUtility.getActorFromRollData(rollData)
|
||||
return (!rollData.isReroll && actor.getEclat() > 0 && actor.getAlignement() == "chaotique")
|
||||
if (rollData?.actorId) {
|
||||
let actor = game.actors.get(rollData.actorId)
|
||||
return actor.getEclat() >= 1
|
||||
|
||||
}
|
||||
return false
|
||||
}
|
||||
let hasPredilection = function (li) {
|
||||
let message = game.messages.get(li.attr("data-message-id"))
|
||||
let rollData = message.getFlag("world", "wasteland-roll")
|
||||
let actor = WastelandUtility.getActorFromRollData(rollData)
|
||||
if (rollData.competence) {
|
||||
let nbPred = rollData.competence.data.predilections.filter(pred => !pred.used).length
|
||||
return (!rollData.isReroll && rollData.competence && nbPred > 0)
|
||||
@@ -579,7 +588,6 @@ export class WastelandUtility {
|
||||
let canCompetenceDouble = function (li) {
|
||||
let message = game.messages.get(li.attr("data-message-id"))
|
||||
let rollData = message.getFlag("world", "wasteland-roll")
|
||||
let actor = WastelandUtility.getActorFromRollData(rollData)
|
||||
if (rollData.competence) {
|
||||
return rollData.competence.data.doublebonus
|
||||
}
|
||||
@@ -587,58 +595,74 @@ export class WastelandUtility {
|
||||
}
|
||||
options.push(
|
||||
{
|
||||
name: "Ajouer +3 (1 point de Bonne Aventure)",
|
||||
name: "Ajouter +3 (1 point de Bonne Aventure)",
|
||||
icon: "<i class='fas fa-user-plus'></i>",
|
||||
condition: canApply && canApplyBALoyal,
|
||||
condition: canApply && hasBA,
|
||||
callback: li => WastelandUtility.applyBonneAventureRoll(li, -1, "+3")
|
||||
}
|
||||
)
|
||||
options.push(
|
||||
{
|
||||
name: "Ajouer +6 (1 point de Bonne Aventure)",
|
||||
name: "Gain de 1 Point de Santé / 24 heure (1 point de Bonne Aventure)",
|
||||
icon: "<i class='fas fa-user-plus'></i>",
|
||||
condition: canApply && canApplyBALoyal && canCompetenceDouble,
|
||||
callback: li => WastelandUtility.applyBonneAventureRoll(li, -1, "+6")
|
||||
condition: canApply && hasBA,
|
||||
callback: li => WastelandUtility.incDecSante(1)
|
||||
}
|
||||
)
|
||||
options.push(
|
||||
{
|
||||
name: "Ajouer +1d6 (1 point de Bonne Aventure)",
|
||||
name: "Gain de 2 Points de Santé / 24 heure (2 points de Bonne Aventure)",
|
||||
icon: "<i class='fas fa-user-plus'></i>",
|
||||
condition: canApply && canApplyBAChaotique,
|
||||
callback: li => WastelandUtility.applyBonneAventureRoll(li, -1, "+1d6")
|
||||
condition: canApply && hasBA2,
|
||||
callback: li => WastelandUtility.incDecSante(2)
|
||||
}
|
||||
)
|
||||
options.push(
|
||||
{
|
||||
name: "Ajouer +2d6 (1 point de Bonne Aventure)",
|
||||
name: "Relancer le jet (3 points de Bonne Aventure)",
|
||||
icon: "<i class='fas fa-user-plus'></i>",
|
||||
condition: canApply && canApplyBAChaotique && canCompetenceDouble,
|
||||
callback: li => WastelandUtility.applyBonneAventureRoll(li, -1, "+2d6")
|
||||
}
|
||||
)
|
||||
options.push(
|
||||
{
|
||||
name: "Relancer le dé (3 points de Bonne Aventure)",
|
||||
icon: "<i class='fas fa-user-plus'></i>",
|
||||
condition: canApply && canApplyBAChaotique3,
|
||||
condition: canApply && hasBA3,
|
||||
callback: li => WastelandUtility.applyBonneAventureRoll(li, -3, "reroll")
|
||||
}
|
||||
)
|
||||
options.push(
|
||||
{
|
||||
name: "Bénéficier d'1 action supplémentaire (3 points de Bonne Aventure)",
|
||||
icon: "<i class='fas fa-user-plus'></i>",
|
||||
condition: canApply && hasBA3,
|
||||
callback: li => WastelandUtility.applyBonneAventureRoll(li, -3, "newaction")
|
||||
}
|
||||
)
|
||||
options.push(
|
||||
{
|
||||
name: "Ajouter +10 (1 Point d'Eclat)",
|
||||
icon: "<i class='fas fa-user-plus'></i>",
|
||||
condition: canApply && canApplyPELoyal,
|
||||
condition: canApply && hasPE,
|
||||
callback: li => WastelandUtility.applyEclatRoll(li, -1, "+10")
|
||||
}
|
||||
)
|
||||
options.push(
|
||||
{
|
||||
name: "Ajouter +20 (1 Point d'Eclat)",
|
||||
name: "Double le résultat du d20 (1 Point d'Eclat)",
|
||||
icon: "<i class='fas fa-user-plus'></i>",
|
||||
condition: canApply && canApplyPELoyal && canCompetenceDouble,
|
||||
callback: li => WastelandUtility.applyEclatRoll(li, -1, "+20")
|
||||
condition: canApply && hasPE,
|
||||
callback: li => WastelandUtility.applyEclatRoll(li, -1, "double20")
|
||||
}
|
||||
)
|
||||
options.push(
|
||||
{
|
||||
name: "Annuler une blessure (1 Point d'Eclat)",
|
||||
icon: "<i class='fas fa-user-plus'></i>",
|
||||
condition: canApply && hasPE,
|
||||
callback: li => WastelandUtility.cancelBlessure(li)
|
||||
}
|
||||
)
|
||||
options.push(
|
||||
{
|
||||
name: "Recharger ses points de BA (1 Point d'Eclat)",
|
||||
icon: "<i class='fas fa-user-plus'></i>",
|
||||
condition: canApply && hasPE,
|
||||
callback: li => WastelandUtility.reloadBA(li)
|
||||
}
|
||||
)
|
||||
return options
|
||||
|
Reference in New Issue
Block a user