Gestion des predilections et rework dons
This commit is contained in:
@@ -36,7 +36,7 @@ export class MournbladeActor extends Actor {
|
||||
|
||||
if (data.type == 'personnage') {
|
||||
const skills = await MournbladeUtility.loadCompendium("fvtt-mournblade.skills")
|
||||
data.items = skills.map(i => i.toObject());
|
||||
data.items = skills.map(i => i.toObject())
|
||||
}
|
||||
if (data.type == 'pnj') {
|
||||
}
|
||||
@@ -92,10 +92,18 @@ export class MournbladeActor extends Actor {
|
||||
/* -------------------------------------------- */
|
||||
prepareDerivedData() {
|
||||
|
||||
if (this.type == 'character') {
|
||||
if (this.type == 'personnage') {
|
||||
let newSante = (this.data.data.attributs.pui.value + this.data.data.attributs.tre.value)*2 + 5
|
||||
if (this.data.data.sante.base!=newSante ) {
|
||||
this.update( {'data.sante.base': newSante} )
|
||||
}
|
||||
let newAme = (this.data.data.attributs.cla.value + this.data.data.attributs.tre.value)*2 + 5
|
||||
if (this.data.data.ame.base!=newAme ) {
|
||||
this.update( {'data.ame.base': newAme} )
|
||||
}
|
||||
}
|
||||
|
||||
super.prepareDerivedData();
|
||||
super.prepareDerivedData()
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@@ -225,6 +233,19 @@ export class MournbladeActor extends Actor {
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getCompetence( compId ) {
|
||||
return this.data.items.get(compId)
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async setPredilectionUsed( compId, predIdx) {
|
||||
let comp = this.data.items.get(compId)
|
||||
let pred = duplicate(comp.data.data.predilections)
|
||||
pred[predIdx].used = true
|
||||
await this.updateEmbeddedDocuments('Item', [ {_id: compId, 'data.predilections': pred}])
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getCommonRollData(attrKey = undefined, compId = undefined) {
|
||||
let rollData = MournbladeUtility.getBasicRollData()
|
||||
|
@@ -119,15 +119,40 @@ export class MournbladeItemSheet extends ItemSheet {
|
||||
|
||||
// Update Inventory Item
|
||||
html.find('.item-edit').click(ev => {
|
||||
const li = $(ev.currentTarget).parents(".item");
|
||||
const item = this.object.options.actor.getOwnedItem(li.data("item-id"));
|
||||
const li = $(ev.currentTarget).parents(".item")
|
||||
const item = this.object.options.actor.getOwnedItem(li.data("item-id"))
|
||||
item.sheet.render(true);
|
||||
});
|
||||
|
||||
html.find('.delete-subitem').click(ev => {
|
||||
this.deleteSubitem(ev);
|
||||
});
|
||||
|
||||
})
|
||||
html.find('.edit-prediction').change(ev => {
|
||||
const li = $(ev.currentTarget).parents(".prediction-item")
|
||||
let index = li.data("prediction-index")
|
||||
let pred = duplicate(this.object.data.data.predilections)
|
||||
pred[index].name = ev.currentTarget.value
|
||||
this.object.update( { 'data.predilections': pred })
|
||||
})
|
||||
html.find('.delete-prediction').click(ev => {
|
||||
const li = $(ev.currentTarget).parents(".prediction-item")
|
||||
let index = li.data("prediction-index")
|
||||
let pred = duplicate(this.object.data.data.predilections)
|
||||
pred.splice(index,1)
|
||||
this.object.update( { 'data.predilections': pred })
|
||||
})
|
||||
html.find('.use-prediction').change(ev => {
|
||||
const li = $(ev.currentTarget).parents(".prediction-item")
|
||||
let index = li.data("prediction-index")
|
||||
let pred = duplicate(this.object.data.data.predilections)
|
||||
pred[index].used = ev.currentTarget.checked
|
||||
this.object.update( { 'data.predilections': pred })
|
||||
})
|
||||
html.find('#add-predilection').click(ev => {
|
||||
let pred = duplicate(this.object.data.data.predilections)
|
||||
pred.push( { name: "Nouvelle prédilection", used: false })
|
||||
this.object.update( { 'data.predilections': pred })
|
||||
})
|
||||
// Update Inventory Item
|
||||
html.find('.item-delete').click(ev => {
|
||||
const li = $(ev.currentTarget).parents(".item");
|
||||
@@ -135,14 +160,6 @@ export class MournbladeItemSheet extends ItemSheet {
|
||||
let itemType = li.data("item-type");
|
||||
});
|
||||
|
||||
html.find('.view-subitem').click(ev => {
|
||||
this.viewSubitem(ev);
|
||||
});
|
||||
|
||||
html.find('.view-spec').click(ev => {
|
||||
this.manageSpec();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
@@ -94,9 +94,16 @@ export class MournbladeUtility {
|
||||
/* -------------------------------------------- */
|
||||
static async chatListeners(html) {
|
||||
|
||||
html.on("click", '.view-item-from-chat', event => {
|
||||
game.system.Mournblade.creator.openItemView(event)
|
||||
});
|
||||
html.on("click", '.predilection-reroll', async event => {
|
||||
let predIdx = $(event.currentTarget).data("predilection-index")
|
||||
let messageId = MournbladeUtility.findChatMessageId(event.currentTarget)
|
||||
let message = game.messages.get(messageId)
|
||||
let rollData = message.getFlag("world", "mournblade-roll")
|
||||
let actor = game.actors.get(rollData.actorId)
|
||||
await actor.setPredilectionUsed( rollData.competence._id, predIdx)
|
||||
rollData.competence = duplicate( actor.getCompetence(rollData.competence._id) )
|
||||
MournbladeUtility.rollMournblade(rollData)
|
||||
})
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@@ -126,7 +133,7 @@ export class MournbladeUtility {
|
||||
}
|
||||
|
||||
static findChatMessage(current) {
|
||||
return MournbladeUtility.findNodeMatching(current, it => it.classList.contains('chat-message') && it.attributes.getNamedItem('data-message-id'));
|
||||
return MournbladeUtility.findNodeMatching(current, it => it.classList.contains('chat-message') && it.attributes.getNamedItem('data-message-id'))
|
||||
}
|
||||
|
||||
static findNodeMatching(current, predicate) {
|
||||
@@ -288,12 +295,11 @@ export class MournbladeUtility {
|
||||
/* -------------------------------------------- */
|
||||
static async rollMournblade(rollData) {
|
||||
|
||||
let actor = game.actors.get(rollData.actorId)
|
||||
let actor = game.actors.get(rollData.actorId)
|
||||
if (rollData.attrKey == "tochoose") { // No attr selected, force address
|
||||
rollData.attrKey = "adr"
|
||||
}
|
||||
if ( !rollData.attr) {
|
||||
console.log("ATTR!!!", rollData.attrKey)
|
||||
rollData.actionImg = "systems/fvtt-mournblade/assets/icons/" + actor.data.data.attributs[rollData.attrKey].labelnorm + ".webp"
|
||||
rollData.attr = duplicate(actor.data.data.attributs[rollData.attrKey])
|
||||
}
|
||||
@@ -306,6 +312,7 @@ export class MournbladeUtility {
|
||||
}
|
||||
}
|
||||
if (rollData.competence) {
|
||||
rollData.predilections = duplicate( rollData.competence.data.predilections.filter( pred => !pred.used) || [] )
|
||||
let compmod = (rollData.competence.data.niveau == 0) ? -3 : 0
|
||||
rollData.diceFormula += `+${rollData.attr.value}+${rollData.competence.data.niveau}+${rollData.modificateur}+${compmod}`
|
||||
} else {
|
||||
@@ -523,6 +530,16 @@ export class MournbladeUtility {
|
||||
let actor = game.actors.get(rollData.actorId)
|
||||
return ( !rollData.isReroll && actor.getEclat() > 0 && actor.getAlignement() == "chaotique")
|
||||
}
|
||||
let hasPredilection = function (li) {
|
||||
let message = game.messages.get(li.attr("data-message-id"))
|
||||
let rollData = message.getFlag("world", "mournblade-roll")
|
||||
let actor = game.actors.get(rollData.actorId)
|
||||
if ( rollData.competence) {
|
||||
let nbPred = rollData.competence.data.predilections.filter( pred => !pred.used).length
|
||||
return ( !rollData.isReroll && rollData.competence && nbPred > 0 )
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
options.push(
|
||||
{
|
||||
@@ -556,14 +573,6 @@ export class MournbladeUtility {
|
||||
callback: li => MournbladeUtility.applyEclatRoll(li, -1, "+10")
|
||||
}
|
||||
)
|
||||
options.push(
|
||||
{
|
||||
name: "Ajouter +1d20(1 Point d'Eclat)",
|
||||
icon: "<i class='fas fa-user-plus'></i>",
|
||||
condition: canApply && canApplyPEChaotique,
|
||||
callback: li => MournbladeUtility.applyEclatRoll(li, -1, "+1d20")
|
||||
}
|
||||
)
|
||||
return options
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user