Gestion des predilections et rework dons
This commit is contained in:
parent
cd1ecf1d96
commit
665feac605
@ -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) {
|
||||
@ -293,7 +300,6 @@ export class MournbladeUtility {
|
||||
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
|
||||
}
|
||||
|
||||
|
@ -1116,7 +1116,7 @@ ul, li {
|
||||
cursor: pointer;
|
||||
color: #ffffff;
|
||||
font-size: 0.8rem;
|
||||
padding: 4px 12px 0px 12px;
|
||||
padding: 4px 4px 0px 4px;
|
||||
text-decoration: none;
|
||||
text-shadow: 0px 1px 0px #4d3534;
|
||||
position: relative;
|
||||
|
@ -17,7 +17,7 @@
|
||||
"library": false,
|
||||
"license": "LICENSE.txt",
|
||||
"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",
|
||||
"media": [],
|
||||
"minimumCoreVersion": "0.8.0",
|
||||
@ -70,9 +70,9 @@
|
||||
"styles": [
|
||||
"styles/simple.css"
|
||||
],
|
||||
"templateVersion": 9,
|
||||
"templateVersion": 11,
|
||||
"title": "Mournblade",
|
||||
"url": "",
|
||||
"version": "0.0.11",
|
||||
"version": "0.0.13",
|
||||
"background": "./images/ui/mournblade_welcome.webp"
|
||||
}
|
@ -105,14 +105,10 @@
|
||||
"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":{
|
||||
"templates": [ "base" ]
|
||||
},
|
||||
"predilection": {
|
||||
"competence": "",
|
||||
"templates": [ "base" ]
|
||||
},
|
||||
"equipement": {
|
||||
"rarete": 0,
|
||||
"prix": 0,
|
||||
@ -137,6 +133,7 @@
|
||||
"attribut1": "",
|
||||
"attribut2": "",
|
||||
"attribut3": "",
|
||||
"predilections": [],
|
||||
"templates": [ "base" ]
|
||||
},
|
||||
"protection": {
|
||||
|
@ -80,6 +80,16 @@
|
||||
</ul>
|
||||
</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>
|
||||
|
||||
|
@ -50,6 +50,11 @@
|
||||
<li>Echec Dramatique!!!</li>
|
||||
{{/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>
|
||||
</div>
|
||||
|
||||
|
@ -1,56 +1,77 @@
|
||||
<form class="{{cssClass}}" autocomplete="off">
|
||||
<header class="sheet-header">
|
||||
<img class="item-sheet-img" src="{{img}}" data-edit="img" title="{{name}}"/>
|
||||
<div class="header-fields">
|
||||
<h1 class="charname"><input name="name" type="text" value="{{name}}" placeholder="Name"/></h1>
|
||||
</div>
|
||||
</header>
|
||||
<header class="sheet-header">
|
||||
<img class="item-sheet-img" src="{{img}}" data-edit="img" title="{{name}}" />
|
||||
<div class="header-fields">
|
||||
<h1 class="charname"><input name="name" type="text" value="{{name}}" placeholder="Name" /></h1>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
{{!-- Sheet Body --}}
|
||||
<section class="sheet-body">
|
||||
{{!-- Sheet Body --}}
|
||||
<section class="sheet-body">
|
||||
|
||||
<div class="flexcol">
|
||||
<span class="flexrow">
|
||||
<label class="generic-label">Niveau : </label>
|
||||
<input type="text" class="padd-right status-small-label color-class-common" name="data.niveau" value="{{data.niveau}}"
|
||||
data-dtype="Number" />
|
||||
<input type="text" class="padd-right status-small-label color-class-common" name="data.niveau"
|
||||
value="{{data.niveau}}" data-dtype="Number" />
|
||||
</span>
|
||||
<span class="flexrow">
|
||||
<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}}
|
||||
{{#each attributs as |attrLabel attrKey|}}
|
||||
<option value="{{attrKey}}">{{attrLabel}}</option>
|
||||
{{/each}}
|
||||
<option value="{{attrKey}}">{{attrLabel}}</option>
|
||||
{{/each}}
|
||||
{{/select}}
|
||||
</select>
|
||||
</span>
|
||||
<span class="flexrow">
|
||||
<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>
|
||||
{{#select data.attribut2}}
|
||||
{{#each attributs as |attrLabel attrKey|}}
|
||||
<option value="{{attrKey}}">{{attrLabel}}</option>
|
||||
{{/each}}
|
||||
{{#each attributs as |attrLabel attrKey|}}
|
||||
<option value="{{attrKey}}">{{attrLabel}}</option>
|
||||
{{/each}}
|
||||
{{/select}}
|
||||
</select>
|
||||
</span>
|
||||
<span class="flexrow">
|
||||
<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>
|
||||
{{#select data.attribut3}}
|
||||
{{#each attributs as |attrLabel attrKey|}}
|
||||
<option value="{{attrKey}}">{{attrLabel}}</option>
|
||||
{{/each}}
|
||||
{{#each attributs as |attrLabel attrKey|}}
|
||||
<option value="{{attrKey}}">{{attrLabel}}</option>
|
||||
{{/each}}
|
||||
{{/select}}
|
||||
</select>
|
||||
</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}}
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
</section>
|
||||
</form>
|
@ -14,9 +14,11 @@
|
||||
<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 data.allegeance}}
|
||||
<option value="tous">Tous</option>
|
||||
<option value="chaos">Chaos</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>
|
||||
</span>
|
||||
@ -24,13 +26,15 @@
|
||||
<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" />
|
||||
</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>
|
||||
<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}}
|
||||
|
||||
</div>
|
||||
|
@ -1,5 +1,5 @@
|
||||
<span>
|
||||
<label class="generic-label">Description</label>
|
||||
<h3>Description</h3>
|
||||
</span>
|
||||
<div class="medium-editor item-text-long-line">
|
||||
{{editor content=data.description target="data.description" button=true owner=owner editable=editable}}
|
||||
|
Loading…
Reference in New Issue
Block a user