First roll
This commit is contained in:
parent
963cb00944
commit
558a7c08a7
@ -29,7 +29,8 @@ export class VadentisActorSheet extends ActorSheet {
|
||||
data.combat = this.actor.combat;
|
||||
data.magie = this.actor.magie;
|
||||
data.editScore = this.options.editScore;
|
||||
console.log("Edit : ", data.editScore);
|
||||
data.donnees = this.actor.getDonnees();
|
||||
data.competences = this.actor.getCompetences();
|
||||
data.isGM = game.user.isGM;
|
||||
|
||||
return data;
|
||||
@ -63,27 +64,34 @@ export class VadentisActorSheet extends ActorSheet {
|
||||
// Delete Inventory Item
|
||||
html.find('.item-delete').click(ev => {
|
||||
const li = $(ev.currentTarget).parents(".item");
|
||||
SoSUtility.confirmDelete(this, li);
|
||||
VadentisUtility.confirmDelete(this, li);
|
||||
});
|
||||
|
||||
html.find('.stat-label a').click((event) => {
|
||||
let statName = event.currentTarget.attributes.name.value;
|
||||
this.actor.rollStat(statName);
|
||||
html.find('.combat-label a').click((event) => {
|
||||
let combatName = event.currentTarget.attributes.name.value;
|
||||
this.actor.rollCombat(combatName);
|
||||
});
|
||||
html.find('.skill-label a').click((event) => {
|
||||
html.find('.competence-label a').click((event) => {
|
||||
const li = $(event.currentTarget).parents(".item");
|
||||
const skill = this.actor.getOwnedItem(li.data("item-id"));
|
||||
this.actor.rollSkill(skill);
|
||||
const competenceId = li.data("item-id");
|
||||
this.actor.rollCompetence(competenceId);
|
||||
});
|
||||
html.find('.weapon-label a').click((event) => {
|
||||
const li = $(event.currentTarget).parents(".item");
|
||||
const weapon = this.actor.getOwnedItem(li.data("item-id"));
|
||||
this.actor.rollWeapon(weapon);
|
||||
});
|
||||
html.find('.skill-value').change((event) => {
|
||||
html.find('.competence-base').change((event) => {
|
||||
let skillName = event.currentTarget.attributes.skillname.value;
|
||||
//console.log("Competence changed :", skillName);
|
||||
this.actor.updateSkill(skillName, parseInt(event.target.value));
|
||||
this.actor.updateCompetence(skillName, "base", parseInt(event.target.value));
|
||||
});
|
||||
html.find('.competence-bonus').change((event) => {
|
||||
let skillName = event.currentTarget.attributes.skillname.value;
|
||||
this.actor.updateCompetence(skillName, "bonus", parseInt(event.target.value));
|
||||
});
|
||||
html.find('.competence-malus').change((event) => {
|
||||
let skillName = event.currentTarget.attributes.skillname.value;
|
||||
this.actor.updateCompetence(skillName, "malus", parseInt(event.target.value));
|
||||
});
|
||||
html.find('.skill-xp').change((event) => {
|
||||
let skillName = event.currentTarget.attributes.skillname.value;
|
||||
|
@ -45,8 +45,49 @@ export class VadentisActor extends Actor {
|
||||
/* -------------------------------------------- */
|
||||
async prepareData() {
|
||||
super.prepareData();
|
||||
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getCompetences() {
|
||||
return this.data.items.filter( item => item.type == 'competence');
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getDonnees() {
|
||||
return this.data.items.filter( item => item.type == 'donnee');
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async updateCompetence( name, field, value) {
|
||||
let competence = this.data.items.find( item => item.type == 'competence' && item.name == name);
|
||||
if (competence) {
|
||||
let dataPath = 'data.'+field;
|
||||
await this.updateOwnedItem( { _id: competence._id, [dataPath]:value });
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
rollCompetence( competenceId ) {
|
||||
console.log("HERE !!!!", competenceId);
|
||||
let competence = this.data.items.find( item => item.type == 'competence' && item._id == competenceId);
|
||||
if ( competence) {
|
||||
let statValue = competence.data.base + competence.data.malus + competence.data.bonus;
|
||||
let formulaFull = `1d20+${competence.data.base}+${competence.data.malus}+${competence.data.bonus}`;
|
||||
let myRoll = new Roll("1d20+"+statValue);
|
||||
myRoll.evaluate();
|
||||
myRoll.toMessage( { flavor: `Jet de compétence : ${competence.name} (${formulaFull})` } );
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
rollCombat( combatName ) {
|
||||
let stat = this.data.data.combat[combatName];
|
||||
let statValue = stat.base + stat.malus + stat.bonus;
|
||||
let formulaFull = `1d20+${stat.base}+${stat.malus}+${stat.bonus}`;
|
||||
let myRoll = new Roll("1d20+"+statValue);
|
||||
myRoll.evaluate();
|
||||
myRoll.toMessage( { flavor: `Jet de ${stat.label} (${formulaFull})` } );
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -61,4 +61,33 @@ export class VadentisUtility extends Entity {
|
||||
return list;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async confirmDelete(actorSheet, li) {
|
||||
let itemId = li.data("item-id");
|
||||
let objet = actorSheet.actor.items.find(item => item._id == itemId);
|
||||
let msgTxt = "<p>Etes vous certain de souhaiter supprimer cet item ?";
|
||||
let buttons = {
|
||||
delete: {
|
||||
icon: '<i class="fas fa-check"></i>',
|
||||
label: "Oui, à supprimer",
|
||||
callback: () => {
|
||||
actorSheet.actor.deleteOwnedItem(itemId);
|
||||
li.slideUp(200, () => actorSheet.render(false));
|
||||
}
|
||||
},
|
||||
cancel: {
|
||||
icon: '<i class="fas fa-times"></i>',
|
||||
label: "Annuler"
|
||||
}
|
||||
}
|
||||
msgTxt += "</p>";
|
||||
let d = new Dialog({
|
||||
title: "Confirmer la suppression",
|
||||
content: msgTxt,
|
||||
buttons: buttons,
|
||||
default: "cancel"
|
||||
});
|
||||
d.render(true);
|
||||
}
|
||||
|
||||
}
|
@ -2,11 +2,11 @@
|
||||
"name": "foundryvtt-vadentis",
|
||||
"title": "Vadentis",
|
||||
"description": "Système Vadentis pour FoundryVTT",
|
||||
"version": "0.0.6",
|
||||
"version": "0.0.7",
|
||||
"manifestPlusVersion": "1.0.0",
|
||||
"minimumCoreVersion": "0.7.5",
|
||||
"compatibleCoreVersion": "0.7.9",
|
||||
"templateVersion": 5,
|
||||
"templateVersion": 6,
|
||||
"author": "Uberwald",
|
||||
"esmodules": [ "modules/vadentis-main.js" ],
|
||||
"styles": ["styles/simple.css"],
|
||||
|
@ -3,12 +3,14 @@
|
||||
"types": ["personnage"],
|
||||
"templates": {
|
||||
"common": {
|
||||
"stats": {
|
||||
"experience": {
|
||||
"experience": {
|
||||
"total": 0,
|
||||
"disponibe": 0,
|
||||
"label": "Expérience"
|
||||
},
|
||||
"total": 0,
|
||||
"disponibe": 0,
|
||||
"label": "Expérience"
|
||||
}
|
||||
},
|
||||
"stats": {
|
||||
"pointsvie": {
|
||||
"value": 0,
|
||||
"max": 0,
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
{{!-- Sheet Tab Navigation --}}
|
||||
<nav class="sheet-tabs tabs" data-group="primary">
|
||||
<a class="item" data-tab="stats">Stats</a>
|
||||
<a class="item" data-tab="principal">Principal</a>
|
||||
<a class="item" data-tab="competences">Compétences</a>
|
||||
<a class="item" data-tab="sorts">Sorts</a>
|
||||
<a class="item" data-tab="equpement">Equipement</a>
|
||||
@ -23,26 +23,51 @@
|
||||
<section class="sheet-body">
|
||||
|
||||
{{!-- Carac Tab --}}
|
||||
<div class="tab items" data-group="primary" data-tab="stats">
|
||||
<div class="tab items" data-group="primary" data-tab="principal">
|
||||
<div class="grid grid-2col">
|
||||
<div class="flex-group-left flexcol">
|
||||
|
||||
<span class="generic-label">Données</span>
|
||||
<ul>
|
||||
{{#each donnees as |donnee key|}}
|
||||
<li class="stat flexrow list-item" data-attribute="{{key}}">
|
||||
<span class="stat-label flexrow tooltip tooltip-nobottom" name="donnee.name">{{donnee.name}}</span>
|
||||
</li>
|
||||
{{/each}}
|
||||
</ul>
|
||||
|
||||
<span class="generic-label">Eglise</span>
|
||||
<ul>
|
||||
{{#each donnees as |donnee key|}}
|
||||
<li class="stat flexrow list-item" data-attribute="{{key}}">
|
||||
<span class="stat-label flexrow tooltip tooltip-nobottom" name="donnee.name">{{donnee.name}}</span>
|
||||
</li>
|
||||
{{/each}}
|
||||
</ul>
|
||||
|
||||
<span><a class="lock-unlock-sheet"><img class="small-button-container"
|
||||
src="systems/foundryvtt-vadentis/images/icons/{{#if editScore}}unlocked.svg{{else}}locked.svg{{/if}}" alt="Editable/Vérouillé"
|
||||
>{{#if editScore}}Editable{{else}}Vérouillé{{/if}}</a></span>
|
||||
<ul class="stat-list alternate-list">
|
||||
<li class="stat flexrow" >
|
||||
<span class="stat-label flexrow tooltip tooltip-nobottom" name="statlabel">Nom </span>
|
||||
<span class="stat-label flexrow tooltip tooltip-nobottom" name="statlabel">Valeur</span>
|
||||
<li class="stat flexrow" >
|
||||
<span class="generic-label flexrow tooltip tooltip-nobottom" name="statlabel">Désignation</span>
|
||||
<span class="generic-label flexrow tooltip tooltip-nobottom" name="statlabel">Valeur</span>
|
||||
<span class="generic-label flexrow tooltip tooltip-nobottom" name="statlabel">Max</span>
|
||||
</li>
|
||||
|
||||
{{#each data.stats as |stat key|}}
|
||||
<li class="stat flexrow list-item" data-attribute="{{key}}">
|
||||
<span class="stat-label flexrow tooltip tooltip-nobottom" name="data.stats.{{key}}.label"><a name={{key}}>{{stat.label}}</a></span>
|
||||
<span class="stat-label flexrow tooltip tooltip-nobottom" name="data.stats.{{key}}.label">{{stat.label}}</span>
|
||||
<select class="stat-value flexrow" type="text" name="data.stats.{{key}}.value" value="{{stat.value}}" data-dtype="Number" {{#unless @root.editScore}}disabled{{/unless}}>
|
||||
{{#select stat.value}}
|
||||
{{>"systems/foundryvtt-vadentis/templates/score-option-list.html"}}
|
||||
{{/select}}
|
||||
</select>
|
||||
<select class="stat-value flexrow" type="text" name="data.stats.{{key}}.max" value="{{stat.max}}" data-dtype="Number" {{#unless @root.editScore}}disabled{{/unless}}>
|
||||
{{#select stat.max}}
|
||||
{{>"systems/foundryvtt-vadentis/templates/score-option-list.html"}}
|
||||
{{/select}}
|
||||
</select>
|
||||
</li>
|
||||
{{/each}}
|
||||
</ul>
|
||||
@ -50,14 +75,14 @@
|
||||
<div class="flex-group-left flexcol">
|
||||
<ul class="stat-list alternate-list">
|
||||
<li class="stat flexrow" >
|
||||
<span class="generic-label flexrow tooltip tooltip-nobottom" name="statlabel">Combat</span>
|
||||
<span class="generic-label flexrow tooltip tooltip-nobottom" name="statlabel">Désignation</span>
|
||||
<span class="generic-label flexrow tooltip tooltip-nobottom" name="statlabel">Valeur</span>
|
||||
<span class="generic-label flexrow tooltip tooltip-nobottom" name="statlabel">Bonus</span>
|
||||
<span class="generic-label flexrow tooltip tooltip-nobottom" name="statlabel">Malus</span>
|
||||
</li>
|
||||
{{#each data.combat as |combat key|}}
|
||||
<li class="stat flexrow list-item" data-attribute="{{key}}">
|
||||
<span class="generic-label flexrow tooltip tooltip-nobottom" name="data.combat.{{key}}.label">{{combat.label}}</span>
|
||||
<span class="stat-label combat-label flexrow tooltip tooltip-nobottom" name="data.combat.{{key}}.label"><a name="{{key}}">{{combat.label}}</a></span>
|
||||
<select class="stat-value flexrow" type="text" name="data.combat.{{key}}.base" value="{{combat.base}}" data-dtype="Number" {{#unless @root.editScore}}disabled{{/unless}}>
|
||||
{{#select combat.base}}
|
||||
{{>"systems/foundryvtt-vadentis/templates/score-option-list.html"}}
|
||||
@ -93,23 +118,17 @@
|
||||
<div class="grid grid-2col">
|
||||
|
||||
<ul class="item-list alterne-list">
|
||||
{{#each data.skill1 as |skill key|}}
|
||||
{{#if skill.data.isLevelUp}}
|
||||
<li class="item flexrow xp-level-up" data-item-id="{{skill._id}}">
|
||||
{{else}}
|
||||
<li class="item flexrow list-item" data-item-id="{{skill._id}}">
|
||||
{{/if}}
|
||||
<img class="sheet-skill-img" src="{{skill.img}}"/>
|
||||
{{#if skill.data.isLevelUp}}
|
||||
<span class="skill-label tooltip tooltip-nobottom">
|
||||
<span class="tooltiptext ttt-xp">
|
||||
</span>
|
||||
<a name={{key}}>{{skill.name}}</a></span>
|
||||
{{else}}
|
||||
<span class="skill-label"><a>{{skill.name}}</a></span>
|
||||
{{/if}}
|
||||
<input class="skill-value" type="text" skillname="{{skill.name}}" value="{{numberFormat skill.data.value decimals=0}}" data-dtype="number" {{#unless @root.data.editStatSkill}}disabled{{/unless}}/>
|
||||
<input class="skill-xp" type="text" skillname="{{skill.name}}" value="{{skill.data.xp}}" data-dtype="number" {{#unless @root.data.editStatSkill}}disabled{{/unless}}/>
|
||||
{{#each competences as |competence key|}}
|
||||
<li class="item flexrow list-item" data-item-id="{{competence._id}}">
|
||||
<img class="sheet-competence-img" src="{{competence.img}}"/>
|
||||
<span class="competence-label"><a>{{competence.name}}</a></span>
|
||||
<select class="competence-base flexrow" type="text" skillname="{{competence.name}}" value="{{competence.data.base}}" data-dtype="Number" {{#unless @root.editScore}}disabled{{/unless}}>
|
||||
{{#select competence.data.base}}
|
||||
{{>"systems/foundryvtt-vadentis/templates/score-option-list.html"}}
|
||||
{{/select}}
|
||||
</select>
|
||||
<input class="competence-malus" type="text" skillname="{{competence.name}}" value="{{competence.data.malus}}" data-dtype="number" {{#unless @root.data.editStatSkill}}disabled{{/unless}}/>
|
||||
<input class="competence-bonus" type="text" skillname="{{competence.name}}" value="{{competence.data.bonus}}" data-dtype="number" {{#unless @root.data.editStatSkill}}disabled{{/unless}}/>
|
||||
<div class="item-controls">
|
||||
<a class="item-control item-edit" title="Edit Item"><i class="fas fa-edit"></i></a>
|
||||
<a class="item-control item-delete" title="Delete Item"><i class="fas fa-trash"></i></a>
|
||||
|
Loading…
Reference in New Issue
Block a user