Finishing v0.0.3

pull/2/head
Erebus 2020-12-01 17:20:38 +01:00
parent ce1e29aefb
commit 4cb6c390a4
10 changed files with 156 additions and 15 deletions

View File

@ -23,6 +23,7 @@
"CURRENCY.QUARTER": "Quarter",
"CURRENCY.SHEKEL": "Shekel",
"CURRENCY.TITLE": "Currency",
"CURRENCY.SILVER": "Silver",
"DICE.ROLL": "Dice roll",

View File

@ -24,6 +24,7 @@
"CURRENCY.QUARTER": "Kvarting",
"CURRENCY.SHEKEL": "Shekel",
"CURRENCY.TITLE": "Mynt",
"CURRENCY.SILVER": "Silver",
"DICE.ROLL": "Tärningsslag",

View File

@ -200,6 +200,85 @@ export class ActorSheetKH extends ActorSheet {
},
]);
new ContextMenu(html, "li.item-spell", [
{
name: game.i18n.localize("MENU.SHOWROLLDIALOG"),
icon: '<i class="far dice"></i>',
callback: (li) => {
let itemId = li.data("itemId");
let _item = this.actor.items.find((element) => element._id == itemId);
if (!_item) {
_item = game.items.get(itemId);
if (!_item) {
console.log("IMPORT ERROR")
return
}
}
let showValue = false
let difficulty = 0
if(this.actor.data.type === "character") {
showValue = true
}
switch (_item.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(_item.data.data.roll.value === "roll" || _item.data.data.roll.value === "attackroll") {
// Retrieve skill based on name
let skill = this.actor.items.find((element) => element.name === _item.data.data.roll.skill);
let skillName = _item.name
let skillValue = skill.data.data.value
if(this.actor.data.type === "character") {
skillName = _item.name + " (" + skill.name + ")"
}
this.khRoller.rollSkillDialogInChat(skillName, skillValue, showValue, this.actor, difficulty)
} else if(_item.data.data.roll.value === "opposite") {
// Retrieve skill based on name
let skill = this.actor.items.find((element) => element.name === _item.data.data.roll.skill);
let skillName = _item.name
let skillValue = skill.data.data.value
if(this.actor.data.type === "character") {
skillName = _item.name + " (" + skill.name + ")"
}
this.khRoller.rollSkillDialogInChat(skillName, skillValue, showValue, this.actor, difficulty)
} else if(_item.data.data.roll.value === "ritual") {
console.log("Not supported yet")
this.khRoller.rollSkillDialogInChat("Ritual", -1, showValue, this.actor, difficulty)
}
},
},
{
name: game.i18n.localize("MENU.SENTTOCHAT"),
icon: '<i class="far fa-comment"></i>',
callback: (li) => {
let itemId = li.data("itemId");
this._itemDetailsToChat(itemId);
},
},
]);
new ContextMenu(html, "li.item-attack", [
{
name: game.i18n.localize("MENU.SHOWROLLDIALOG"),
@ -226,6 +305,20 @@ export class ActorSheetKH extends ActorSheet {
},
]);
new ContextMenu(html, "li.item-defence", [
{
name: game.i18n.localize("MENU.SHOWROLLDIALOG"),
icon: '<i class="far dice"></i>',
callback: (li) => {
const skillValue = li.data("defence");
let skillName = "ADVERSARY.DEFENCE";
this.khRoller.rollSkillDialogInChat(skillName, skillValue, false, this.actor)
},
}
]);
html.find(".feature").click(async (ev) => {
const featureName = $(ev.currentTarget).data("feature");
const featureValue = this.actor.data.data.feature[featureName].value;
@ -245,6 +338,33 @@ export class ActorSheetKH extends ActorSheet {
html.find(".item-delete").click((ev) => {
let parent = $(ev.currentTarget).data("parent")
const li = $(ev.currentTarget).parents(parent);
const item = this.actor.getOwnedItem(li.data("itemId"));
if(item) {
if (item.type === "armor") {
let initValue = -1
if (item.data.data.equipable.equipped) {
initValue = 4
this.actor.items.map((i) => {
if (i.type === "armor") {
if (i._id !== item._id && i.data.data.equipable.equipped && i.data?.data?.modifications) {
for (let k of Object.keys(i.data.data.modifications)) {
if (i.data.data.modifications[k].modtype === "init") {
initValue = i.data.data.modifications[k].value;
}
}
}
}
});
}
if (initValue > 0) {
this.actor.update({["data.combat.init"]: initValue});
}
}
}
this.actor.deleteOwnedItem(li.data("itemId"));
@ -336,17 +456,25 @@ export class ActorSheetKH extends ActorSheet {
// 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 skillName = spell.name
let skillValue = skill.data.data.value
if(this.actor.data.type === "character") {
skillName = spell.name + " (" + skill.name + ")"
}
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 skillName = spell.name
let skillValue = skill.data.data.value
if(this.actor.data.type === "character") {
skillName = spell.name + " (" + skill.name + ")"
}
this.khRoller.rollSkillInChat(skillName, skillValue, showValue, this.actor, difficulty)
} else if(spell.data.data.roll.value === "ritual") {
console.log("Not supported yet")

View File

@ -6,6 +6,9 @@ export default class KHHooks {
let actorbaseSkills;
if(game.settings.get("kopparhavet", "gameSystem") === "hjaltarnas-tid") {
// Set currency name
actor.update({ "data.currency.shekel.label": "CURRENCY.SILVER" });
actorbaseSkills = CONFIG.KH.baseSkillsHT
skillIndex = await game.packs.get("kopparhavet.skills-ht").getContent();
} else {

View File

@ -169,6 +169,20 @@ function registerHandlebarsHelpers() {
}
});
Handlebars.registerHelper("spellRoll", function (roll) {
roll = normalize(roll, "roll");
switch (roll) {
case "roll":
return game.i18n.localize("SPELL.ROLL");
case "attackroll":
return game.i18n.localize("SPELL.ATTACKROLL");
case "opposite":
return game.i18n.localize("SPELL.OPPOSITE");
case "ritual":
return game.i18n.localize("SPELL.RITUAL");
}
});
Handlebars.registerHelper('plaintextToHTML', function(value) {
// strip tags, add <br/> tags
return new Handlebars.SafeString(value.replace(/(<([^>]+)>)/gi, "").replace(/(?:\r\n|\r|\n)/g, '<br/>'));

View File

@ -100,14 +100,9 @@
.items .items-list .item,
.items .items-list .item-spell,
.items .items-list .item-weapon,
.items .items-list .item-skill {
line-height: 24px;
padding: 3px 0;
border-bottom: 1px solid #bbb;
text-align: center;
}
.items .items-list .item-nor {
.items .items-list .item-skill,
.items .items-list .item-nor,
.items .items-list .item-defence {
line-height: 24px;
padding: 3px 0;
border-bottom: 1px solid #bbb;

View File

@ -53,6 +53,6 @@
"url": "https://pi.rikspolisen.se/foundryvtt/kopparhavet",
"socket": true,
"manifest": "https://pi.rikspolisen.se/foundryvtt/kopparhavet/raw/branch/master/system.json",
"download": "https://pi.rikspolisen.se/foundryvtt/kopparhavet/archive/v0.1.zip",
"download": "https://pi.rikspolisen.se/foundryvtt/kopparhavet/archive/v0.0.3.zip",
"license": ""
}

View File

@ -74,8 +74,7 @@
<strong>{{localize data.cost.label}}:</strong> {{data.cost.value}}
<strong>{{localize data.difficulty.label}}:</strong> {{rollDifficulty data.difficulty.value}}
<div style="grid-column-start: 1; grid-column-end: 5;">
<strong>{{localize data.roll.label}}</strong>
{{data.roll.value}}
<strong>{{localize data.roll.label}}:</strong> {{spellRoll data.roll.value}}
</div>
</div>
{{#if data.description}}

View File

@ -7,7 +7,7 @@
<div class="item-value" style="flex: none;"><input name="data.combat.init" class="skill-value" type="number" value="{{data.combat.init}}" data-dtype="Number" /></div>
</li>
<li class="item-nor flexrow">
<li class="item-defence flexrow" data-defence="{{data.combat.defence}}">
<div class="item-name roll-defence rollable" data-defence="{{data.combat.defence}}" style="flex-grow: 8;">{{localize "ADVERSARY.DEFENCE"}}</div>
<div class="item-value" style="flex: none;"><input name="data.combat.defence" class="skill-value" type="text" value="{{data.combat.defence}}" /></div>
</li>

View File

@ -7,7 +7,7 @@
<div class="item-value" style="flex: none;"><input name="data.combat.init" class="skill-value" type="number" value="{{data.combat.init}}" data-dtype="Number" /></div>
</li>
<li class="item-nor flexrow">
<li class="item-defence flexrow" data-defence="{{data.combat.defence}}">
<div class="item-name roll-defence rollable" data-defence="{{data.combat.defence}}" style="flex-grow: 8;">{{localize "ADVERSARY.DEFENCE"}}</div>
<div class="item-value" style="flex: none;"><input name="data.combat.defence" class="skill-value" type="text" value="{{data.combat.defence}}" /></div>
</li>