Added support for rolling skill on spells

pull/2/head
Erebus 2020-12-01 09:04:03 +01:00
parent cbafeede44
commit 836875459c
6 changed files with 81 additions and 18 deletions

View File

@ -273,7 +273,7 @@ export class ActorSheetKH extends ActorSheet {
/* Roll spell cost */ /* Roll spell cost */
html.find(".roll-spell-cost").click((ev) => { html.find(".roll-spell-cost").click((ev) => {
const li = $(ev.currentTarget).parents(".item"); const li = $(ev.currentTarget).parents(".item-spell");
let itemId = li.data("itemId"); let itemId = li.data("itemId");
let spell = this.actor.getOwnedItem(itemId); let spell = this.actor.getOwnedItem(itemId);
@ -296,6 +296,63 @@ export class ActorSheetKH extends ActorSheet {
} }
}); });
html.find(".roll-spell-skill").click((ev) => {
const li = $(ev.currentTarget).parents(".item-spell");
let itemId = li.data("itemId");
let spell = this.actor.getOwnedItem(itemId);
if (!spell) {
spell = game.items.get(itemId);
if (!spell) {
console.log("IMPORT ERROR")
return
}
}
let showValue = false
let difficulty = 0
if(this.actor.data.type === "character") {
showValue = true
}
switch (spell.data.data.difficulty.value) {
case "simple":
difficulty = 5
break;
case "easy":
difficulty = 2
break;
case "hard":
difficulty = -2
break;
case "daunting":
difficulty = -5
break;
}
if(spell.data.data.roll.value === "roll" || spell.data.data.roll.value === "attackroll") {
// Retrieve skill based on name
let skill = this.actor.items.find((element) => element.name === spell.data.data.roll.skill);
let skillName = spell.name + " (" + skill.name + ")"
let skillValue = skill.data.data.value
this.khRoller.rollSkillInChat(skillName, skillValue, showValue, this.actor, difficulty)
} else if(spell.data.data.roll.value === "opposite") {
// Retrieve skill based on name
let skill = this.actor.items.find((element) => element.name === spell.data.data.roll.skill);
let skillName = spell.name + " (" + skill.name + ")"
let skillValue = skill.data.data.value
this.khRoller.rollSkillInChat(skillName, skillValue, showValue, this.actor, difficulty)
} else if(spell.data.data.roll.value === "ritual") {
console.log("Not supported yet")
}
});
/* Roll skill */ /* Roll skill */
html.find(".roll-skill").click((ev) => { html.find(".roll-skill").click((ev) => {
const li = $(ev.currentTarget).parents(".item-skill"); const li = $(ev.currentTarget).parents(".item-skill");

View File

@ -97,7 +97,10 @@
margin: auto; margin: auto;
} }
.items .items-list .item { .items .items-list .item,
.items .items-list .item-spell,
.items .items-list .item-weapon,
.items .items-list .item-skill {
line-height: 24px; line-height: 24px;
padding: 3px 0; padding: 3px 0;
border-bottom: 1px solid #bbb; border-bottom: 1px solid #bbb;

View File

@ -233,7 +233,8 @@
"value": "roll", "value": "roll",
"type": "String", "type": "String",
"label": "SPELL.ROLLTITLE", "label": "SPELL.ROLLTITLE",
"skill": "Trolldom" "skill": "Trolldom",
"ritual": {}
}, },
"cost": { "cost": {
"value": "", "value": "",

View File

@ -5,12 +5,12 @@
<div class="roll"> <div class="roll">
<div class="dice-roll"> <div class="dice-roll">
{{#if closed}} {{#if closed}}
<div style="margin: auto;"> <div style="text-align: center; margin-bottom: 0.5rem;">
{{localize "ROLL.CLOSED"}}: {{closed}} {{localize "ROLL.CLOSED"}}: {{closed}}
</div> </div>
{{/if}} {{/if}}
{{#if opened}} {{#if opened}}
<div style="margin: auto;"> <div style="text-align: center; margin-bottom: 0.5rem;">
{{localize "ROLL.OPENED"}}: {{opened}} {{localize "ROLL.OPENED"}}: {{opened}}
</div> </div>
{{/if}} {{/if}}
@ -23,14 +23,14 @@
</div> </div>
</div> </div>
{{#if success}} {{#if success}}
<div style="text-align: center; width: 100%; font-weight: bold; color: limegreen;"> <h2 style="border: none; text-align: center; width: 100%; font-weight: bold; color: limegreen;">
{{#if excetional}}{{localize "ROLL.EXCEPTIONAL"}}{{/if}} {{localize "ROLL.SUCCESS"}} {{#if excetional}}{{localize "ROLL.EXCEPTIONAL"}}{{/if}} {{localize "ROLL.SUCCESS"}}
</div> </h2>
{{/if}} {{/if}}
{{#if failure}} {{#if failure}}
<div style="text-align: center; width: 100%; font-weight: bold; color: darkred;"> <h2 style="border: none; text-align: center; width: 100%; font-weight: bold; color: darkred;">
{{#if excetional}}{{localize "ROLL.EXCEPTIONAL"}}{{/if}} {{localize "ROLL.FAILURE"}} {{#if excetional}}{{localize "ROLL.EXCEPTIONAL"}}{{/if}} {{localize "ROLL.FAILURE"}}
</div> </h2>
{{/if}} {{/if}}
</div> </div>
</div> </div>

View File

@ -25,13 +25,13 @@
<ul class="items"> <ul class="items">
<ul class="items-list"> <ul class="items-list">
{{#each actor.spells as |spell key|}} {{#each actor.spells as |spell key|}}
<li class="item flexrow" data-item-id="{{spell._id}}"> <li class="item-spell flexrow" data-item-id="{{spell._id}}">
<div class="item-name">{{spell.name}}</div> <div class="item-name roll-spell-skill rollable" style="margin-top: auto; margin-bottom: auto;">{{spell.name}}</div>
<div class="cost roll-spell-cost rollable">{{spell.data.cost.value}}</div> <div class="cost roll-spell-cost rollable">{{spell.data.cost.value}}</div>
<div class="difficulty">{{rollDifficulty spell.data.difficulty.value}}</div> <div class="difficulty">{{rollDifficulty spell.data.difficulty.value}}</div>
<div class="item-controls"> <div class="item-controls">
<a class="item-control item-edit" data-parent=".item" title="Edit Item"><i class="fas fa-edit"></i></a> <a class="item-control item-edit" data-parent=".item-spell" title="Edit Item"><i class="fas fa-edit"></i></a>
<a class="item-control item-delete" data-parent=".item" title="Delete Item"><i class="fas fa-trash"></i></a> <a class="item-control item-delete" data-parent=".item-spell" title="Delete Item"><i class="fas fa-trash"></i></a>
</div> </div>
</li> </li>
{{/each}} {{/each}}

View File

@ -1,10 +1,12 @@
<div id="{{id}}" class="roll-dialog"> <div id="{{id}}" class="roll-dialog">
<h1 style="text-align: center;">{{localize skillName}} ({{skillValue}})</h1> <h1 style="text-align: center;">{{localize skillName}} ({{skillValue}})</h1>
<label>{{localize "ROLL.OPENCLOSE"}}</label> <div class="flexrow" style="margin-bottom: 10px;">
<input type="button" name="openclosed" min="0" value="{{startopen}}" style="margin-bottom: 10px; min-height: 26px; min-width: 30px;" /> <label style="margin: auto;">{{localize "ROLL.OPENCLOSE"}}</label>
<label name="notopenedorclosed" style="display: inline-block;">&nbsp;</label> <input type="button" name="openclosed" min="0" value="{{startopen}}" style="min-height: 30px; min-width: 45px;" />
<label name="closed" style="display: none;">{{localize "ROLL.CLOSED"}}</label> <label name="notopenedorclosed" style="margin: auto; display: inline-block;">&nbsp;</label>
<label name="opened" style="display: none;">{{localize "ROLL.OPENED"}}</label> <label name="closed" style="margin: auto; display: none; text-align: center;">{{localize "ROLL.CLOSED"}}</label>
<label name="opened" style="margin: auto; display: none; text-align: center;">{{localize "ROLL.OPENED"}}</label>
</div>
</div> </div>
<script> <script>