Gestion des predilections et rework dons

This commit is contained in:
sladecraven 2022-06-05 23:27:38 +02:00
parent cd1ecf1d96
commit 826e147be2
11 changed files with 158 additions and 74 deletions

View File

@ -36,7 +36,7 @@ export class MournbladeActor extends Actor {
if (data.type == 'personnage') { if (data.type == 'personnage') {
const skills = await MournbladeUtility.loadCompendium("fvtt-mournblade.skills") 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') { if (data.type == 'pnj') {
} }
@ -92,10 +92,18 @@ export class MournbladeActor extends Actor {
/* -------------------------------------------- */ /* -------------------------------------------- */
prepareDerivedData() { 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) { getCommonRollData(attrKey = undefined, compId = undefined) {
let rollData = MournbladeUtility.getBasicRollData() let rollData = MournbladeUtility.getBasicRollData()

View File

@ -119,15 +119,40 @@ export class MournbladeItemSheet extends ItemSheet {
// Update Inventory Item // Update Inventory Item
html.find('.item-edit').click(ev => { html.find('.item-edit').click(ev => {
const li = $(ev.currentTarget).parents(".item"); const li = $(ev.currentTarget).parents(".item")
const item = this.object.options.actor.getOwnedItem(li.data("item-id")); const item = this.object.options.actor.getOwnedItem(li.data("item-id"))
item.sheet.render(true); item.sheet.render(true);
}); });
html.find('.delete-subitem').click(ev => { html.find('.delete-subitem').click(ev => {
this.deleteSubitem(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 // Update Inventory Item
html.find('.item-delete').click(ev => { html.find('.item-delete').click(ev => {
const li = $(ev.currentTarget).parents(".item"); const li = $(ev.currentTarget).parents(".item");
@ -135,14 +160,6 @@ export class MournbladeItemSheet extends ItemSheet {
let itemType = li.data("item-type"); let itemType = li.data("item-type");
}); });
html.find('.view-subitem').click(ev => {
this.viewSubitem(ev);
});
html.find('.view-spec').click(ev => {
this.manageSpec();
});
} }
/* -------------------------------------------- */ /* -------------------------------------------- */

View File

@ -94,9 +94,16 @@ export class MournbladeUtility {
/* -------------------------------------------- */ /* -------------------------------------------- */
static async chatListeners(html) { static async chatListeners(html) {
html.on("click", '.view-item-from-chat', event => { html.on("click", '.predilection-reroll', async event => {
game.system.Mournblade.creator.openItemView(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) { 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) { static findNodeMatching(current, predicate) {
@ -288,12 +295,11 @@ export class MournbladeUtility {
/* -------------------------------------------- */ /* -------------------------------------------- */
static async rollMournblade(rollData) { 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 if (rollData.attrKey == "tochoose") { // No attr selected, force address
rollData.attrKey = "adr" rollData.attrKey = "adr"
} }
if ( !rollData.attr) { if ( !rollData.attr) {
console.log("ATTR!!!", rollData.attrKey)
rollData.actionImg = "systems/fvtt-mournblade/assets/icons/" + actor.data.data.attributs[rollData.attrKey].labelnorm + ".webp" rollData.actionImg = "systems/fvtt-mournblade/assets/icons/" + actor.data.data.attributs[rollData.attrKey].labelnorm + ".webp"
rollData.attr = duplicate(actor.data.data.attributs[rollData.attrKey]) rollData.attr = duplicate(actor.data.data.attributs[rollData.attrKey])
} }
@ -306,6 +312,7 @@ export class MournbladeUtility {
} }
} }
if (rollData.competence) { if (rollData.competence) {
rollData.predilections = duplicate( rollData.competence.data.predilections.filter( pred => !pred.used) || [] )
let compmod = (rollData.competence.data.niveau == 0) ? -3 : 0 let compmod = (rollData.competence.data.niveau == 0) ? -3 : 0
rollData.diceFormula += `+${rollData.attr.value}+${rollData.competence.data.niveau}+${rollData.modificateur}+${compmod}` rollData.diceFormula += `+${rollData.attr.value}+${rollData.competence.data.niveau}+${rollData.modificateur}+${compmod}`
} else { } else {
@ -523,6 +530,16 @@ export class MournbladeUtility {
let actor = game.actors.get(rollData.actorId) let actor = game.actors.get(rollData.actorId)
return ( !rollData.isReroll && actor.getEclat() > 0 && actor.getAlignement() == "chaotique") 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( options.push(
{ {
@ -556,14 +573,6 @@ export class MournbladeUtility {
callback: li => MournbladeUtility.applyEclatRoll(li, -1, "+10") 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 return options
} }

View File

@ -1116,7 +1116,7 @@ ul, li {
cursor: pointer; cursor: pointer;
color: #ffffff; color: #ffffff;
font-size: 0.8rem; font-size: 0.8rem;
padding: 4px 12px 0px 12px; padding: 4px 4px 0px 4px;
text-decoration: none; text-decoration: none;
text-shadow: 0px 1px 0px #4d3534; text-shadow: 0px 1px 0px #4d3534;
position: relative; position: relative;

View File

@ -17,7 +17,7 @@
"library": false, "library": false,
"license": "LICENSE.txt", "license": "LICENSE.txt",
"manifest": "https://www.uberwald.me/gitea/public/fvtt-mournblade/raw/branch/main/system.json", "manifest": "https://www.uberwald.me/gitea/public/fvtt-mournblade/raw/branch/main/system.json",
"download": "https://www.uberwald.me/gitea/public/fvtt-mournblade/archive/fvtt-mournblade-0.0.11.zip", "download": "https://www.uberwald.me/gitea/public/fvtt-mournblade/archive/fvtt-mournblade-0.0.13.zip",
"manifestPlusVersion": "1.0.0", "manifestPlusVersion": "1.0.0",
"media": [], "media": [],
"minimumCoreVersion": "0.8.0", "minimumCoreVersion": "0.8.0",
@ -70,9 +70,9 @@
"styles": [ "styles": [
"styles/simple.css" "styles/simple.css"
], ],
"templateVersion": 9, "templateVersion": 11,
"title": "Mournblade", "title": "Mournblade",
"url": "", "url": "",
"version": "0.0.11", "version": "0.0.13",
"background": "./images/ui/mournblade_welcome.webp" "background": "./images/ui/mournblade_welcome.webp"
} }

View File

@ -105,14 +105,10 @@
"description": "" "description": ""
} }
}, },
"types": [ "arme", "competence", "protection", "pacte", "traitchaotique", "monnaie", "don", "tendance", "rune", "predilection", "equipement", "capacite"], "types": [ "arme", "competence", "protection", "pacte", "traitchaotique", "monnaie", "don", "tendance", "rune", "equipement", "capacite"],
"capacite":{ "capacite":{
"templates": [ "base" ] "templates": [ "base" ]
}, },
"predilection": {
"competence": "",
"templates": [ "base" ]
},
"equipement": { "equipement": {
"rarete": 0, "rarete": 0,
"prix": 0, "prix": 0,
@ -137,6 +133,7 @@
"attribut1": "", "attribut1": "",
"attribut2": "", "attribut2": "",
"attribut3": "", "attribut3": "",
"predilections": [],
"templates": [ "base" ] "templates": [ "base" ]
}, },
"protection": { "protection": {

View File

@ -80,6 +80,16 @@
</ul> </ul>
</div> </div>
<div class="flexrow">
<h4 class="item-name-label competence-name">Santé</h4>
<input type="text" class="padd-right status-small-label color-class-common" name="data.sante.value" value="{{data.sante.value}}" data-dtype="Number" />
<input type="text" class="padd-right status-small-label color-class-common" name="data.sante.base" value="{{data.sante.base}}" data-dtype="Number" />
<h4 class="item-name-label competence-name">Ame</h4>
<input type="text" class="padd-right status-small-label color-class-common" name="data.ame.value" value="{{data.ame.value}}" data-dtype="Number" />
<input type="text" class="padd-right status-small-label color-class-common" name="data.ame.base" value="{{data.ame.base}}" data-dtype="Number" />
</div>
</div> </div>

View File

@ -50,6 +50,11 @@
<li>Echec Dramatique!!!</li> <li>Echec Dramatique!!!</li>
{{/if}} {{/if}}
{{#each predilections as |pred key|}}
<li>
<button class="chat-card-button predilection-reroll" data-predilection-index="{{key}}">Predilection : {{pred.name}}</button>
</li>
{{/each}}
</ul> </ul>
</div> </div>

View File

@ -1,56 +1,77 @@
<form class="{{cssClass}}" autocomplete="off"> <form class="{{cssClass}}" autocomplete="off">
<header class="sheet-header"> <header class="sheet-header">
<img class="item-sheet-img" src="{{img}}" data-edit="img" title="{{name}}"/> <img class="item-sheet-img" src="{{img}}" data-edit="img" title="{{name}}" />
<div class="header-fields"> <div class="header-fields">
<h1 class="charname"><input name="name" type="text" value="{{name}}" placeholder="Name"/></h1> <h1 class="charname"><input name="name" type="text" value="{{name}}" placeholder="Name" /></h1>
</div> </div>
</header> </header>
{{!-- Sheet Body --}}
<section class="sheet-body">
{{!-- Sheet Body --}}
<section class="sheet-body">
<div class="flexcol"> <div class="flexcol">
<span class="flexrow"> <span class="flexrow">
<label class="generic-label">Niveau : </label> <label class="generic-label">Niveau : </label>
<input type="text" class="padd-right status-small-label color-class-common" name="data.niveau" value="{{data.niveau}}" <input type="text" class="padd-right status-small-label color-class-common" name="data.niveau"
data-dtype="Number" /> value="{{data.niveau}}" data-dtype="Number" />
</span> </span>
<span class="flexrow"> <span class="flexrow">
<label class="generic-label">Attribut 1 : </label> <label class="generic-label">Attribut 1 : </label>
<select class="status-small-label color-class-common" type="text" name="data.attribut1" value="{{data.attribut1}}" data-dtype="string" > <select class="status-small-label color-class-common" type="text" name="data.attribut1"
value="{{data.attribut1}}" data-dtype="string">
{{#select data.attribut1}} {{#select data.attribut1}}
{{#each attributs as |attrLabel attrKey|}} {{#each attributs as |attrLabel attrKey|}}
<option value="{{attrKey}}">{{attrLabel}}</option> <option value="{{attrKey}}">{{attrLabel}}</option>
{{/each}} {{/each}}
{{/select}} {{/select}}
</select> </select>
</span> </span>
<span class="flexrow"> <span class="flexrow">
<label class="generic-label">Attribut 2 : </label> <label class="generic-label">Attribut 2 : </label>
<select class="status-small-label color-class-common" type="text" name="data.attribut2" value="{{data.attribut2}}" data-dtype="string" > <select class="status-small-label color-class-common" type="text" name="data.attribut2"
value="{{data.attribut2}}" data-dtype="string">
<option value="none">Aucun</option> <option value="none">Aucun</option>
{{#select data.attribut2}} {{#select data.attribut2}}
{{#each attributs as |attrLabel attrKey|}} {{#each attributs as |attrLabel attrKey|}}
<option value="{{attrKey}}">{{attrLabel}}</option> <option value="{{attrKey}}">{{attrLabel}}</option>
{{/each}} {{/each}}
{{/select}} {{/select}}
</select> </select>
</span> </span>
<span class="flexrow"> <span class="flexrow">
<label class="generic-label">Attribut 3 : </label> <label class="generic-label">Attribut 3 : </label>
<select class="status-small-label color-class-common" type="text" name="data.attribut3" value="{{data.attribut3}}" data-dtype="string" > <select class="status-small-label color-class-common" type="text" name="data.attribut3"
value="{{data.attribut3}}" data-dtype="string">
<option value="none">Aucun</option> <option value="none">Aucun</option>
{{#select data.attribut3}} {{#select data.attribut3}}
{{#each attributs as |attrLabel attrKey|}} {{#each attributs as |attrLabel attrKey|}}
<option value="{{attrKey}}">{{attrLabel}}</option> <option value="{{attrKey}}">{{attrLabel}}</option>
{{/each}} {{/each}}
{{/select}} {{/select}}
</select> </select>
</span> </span>
<span class="flexrow">
<h3>Prédilections</h3>
</span>
<ul>
{{#each data.predilections as |predilection key|}}
<li class="prediction-item item flexrow" data-prediction-index="{{key}}">
<input type="text" class="padd-right color-class-common edit-prediction"
name="data.predilections[{{key}}]" value="{{predilection.name}}" data-dtype="String" />
<input class="use-prediction" type="checkbox" name="predilection.used" value="{{predilection.used}}" {{checked predilection.used}} />
<a class="item-control delete-prediction" title="Supprimer une predilection"><i class="fas fa-trash"></i></a>
</li>
{{/each}}
</ul>
<span class="flexrow">
<button id="add-predilection" class="chat-card-button">Ajouter une prédilection</button>
</span>
{{> systems/fvtt-mournblade/templates/partial-item-description.html}} {{> systems/fvtt-mournblade/templates/partial-item-description.html}}
</div> </div>
</section> </section>
</form> </form>

View File

@ -14,9 +14,11 @@
<label class="generic-label">Allégeance : </label> <label class="generic-label">Allégeance : </label>
<select class="status-small-label color-class-common" type="text" name="data.allegeance" value="{{data.allegeance}}" data-dtype="string" > <select class="status-small-label color-class-common" type="text" name="data.allegeance" value="{{data.allegeance}}" data-dtype="string" >
{{#select data.allegeance}} {{#select data.allegeance}}
<option value="tous">Tous</option>
<option value="chaos">Chaos</option> <option value="chaos">Chaos</option>
<option value="loi">Loi</option> <option value="loi">Loi</option>
<option value="betes">Seigneurs de Bêtes</option> <option value="betes">Seigneurs des Bêtes</option>
<option value="elementaires">Seigneurs Elementaires</option>
{{/select}} {{/select}}
</select> </select>
</span> </span>
@ -24,13 +26,15 @@
<label class="generic-label">Prérequis : </label> <label class="generic-label">Prérequis : </label>
<input type="text" class="padd-right status-small-label color-class-common" name="data.prerequis" value="{{data.prerequis}}" data-dtype="String" /> <input type="text" class="padd-right status-small-label color-class-common" name="data.prerequis" value="{{data.prerequis}}" data-dtype="String" />
</span> </span>
<span class="flexrow">
<label class="generic-label">Sacrifice : </label>
<div class="small-editor item-text-long-line">
{{editor content=data.sacrifice target="data.sacrifice" button=true owner=owner editable=editable}}
</div>
</span>
<span>
<h3>Sacrifices</h3>
</span>
<div class="small-editor item-text-long-line">
{{editor content=data.sacrifice target="data.sacrifice" button=true owner=owner editable=editable}}
</div>
{{> systems/fvtt-mournblade/templates/partial-item-description.html}} {{> systems/fvtt-mournblade/templates/partial-item-description.html}}
</div> </div>

View File

@ -1,5 +1,5 @@
<span> <span>
<label class="generic-label">Description</label> <h3>Description</h3>
</span> </span>
<div class="medium-editor item-text-long-line"> <div class="medium-editor item-text-long-line">
{{editor content=data.description target="data.description" button=true owner=owner editable=editable}} {{editor content=data.description target="data.description" button=true owner=owner editable=editable}}