Various fixes and ehnagcements

This commit is contained in:
sladecraven 2022-08-01 21:39:17 +02:00
parent e7faf7937b
commit f0b5220414
13 changed files with 128 additions and 66 deletions

View File

@ -227,6 +227,11 @@ export class CrucibleActorSheet extends ActorSheet {
const skillId = li.data("item-id")
this.actor.rollSkill(skillId)
});
html.find('.roll-weapon').click((event) => {
const li = $(event.currentTarget).parents(".item");
const skillId = li.data("item-id")
this.actor.rollWeapon(skillId)
});
html.find('.weapon-roll').click((event) => {
const li = $(event.currentTarget).parents(".item");
const weaponId = li.data("item-id");

View File

@ -166,6 +166,9 @@ export class CrucibleActor extends Actor {
/* -------------------------------------------- */
getSkills() {
let comp = duplicate(this.data.items.filter(item => item.type == 'skill') || [])
for (let skill of comp) {
CrucibleUtility.updateSkill(skill)
}
CrucibleUtility.sortArrayObjectsByName(comp)
return comp
}
@ -403,12 +406,12 @@ export class CrucibleActor extends Actor {
}
ChatMessage.create(chatData)
if (skill.data.data.exp >= 25) {
await this.updateEmbeddedDocuments('Item', [{ _id: skill.id, 'data.exp': 0, 'data.level': skill.data.data.level + 1 }])
await this.updateEmbeddedDocuments('Item', [{ _id: skill.id, 'data.exp': 0, 'data.explevel': skill.data.data.explevel + 1 }])
let chatData = {
user: game.user.id,
rollMode: game.settings.get("core", "rollMode"),
whisper: [game.user.id].concat(ChatMessage.getWhisperRecipients('GM')),
content: `<div>${this.name} has gained 1 SL in the skill ${skill.name} (new SL : ${skill.data.data.level}) !</div`
content: `<div>${this.name} has gained 1 exp SL in the skill ${skill.name} (new exp SL : ${skill.data.data.explevel}) !</div`
}
ChatMessage.create(chatData)
}
@ -445,10 +448,12 @@ export class CrucibleActor extends Actor {
rollData.img = this.img
rollData.featsDie = this.getFeatsWithDie()
rollData.featsSL = this.getFeatsWithSL()
rollData.armors = this.getArmors()
rollData.featDieName = "none"
rollData.featSLName = "none"
rollData.rollAdvantage = "none"
rollData.advantage = "none"
rollData.disadvantage = "none"
if (abilityKey) {
rollData.ability = this.getAbility(abilityKey)
@ -477,6 +482,7 @@ export class CrucibleActor extends Actor {
return
}
skill = duplicate(skill)
CrucibleUtility.updateSkill(skill)
let abilityKey = skill.data.ability
let rollData = this.getCommonRollData(abilityKey)
rollData.mode = "skill"
@ -487,6 +493,29 @@ export class CrucibleActor extends Actor {
}
}
/* -------------------------------------------- */
rollWeapon(weaponId) {
let weapon = this.data.items.get(weaponId)
if (weapon) {
weapon = duplicate(weapon)
let skill = this.data.items.find( item => item.name.toLowerCase() == weapon.data.skill.toLowerCase())
if (skill) {
skill = duplicate(skill)
CrucibleUtility.updateSkill(skill)
let abilityKey = skill.data.ability
let rollData = this.getCommonRollData(abilityKey)
rollData.mode = "weapon"
rollData.skill = skill
rollData.weapon = weapon
rollData.img = weapon.img
this.startRoll(rollData)
} else {
ui.notifications.warn("Unable to find the relevant skill for weapon " + weapon.name)
}
}
}
/* -------------------------------------------- */
async startRoll(rollData) {
this.syncRoll(rollData)

View File

@ -49,8 +49,12 @@ export class CrucibleItemSheet extends ItemSheet {
/* -------------------------------------------- */
async getData() {
const objectData = CrucibleUtility.data(this.object);
if ( objectData.type == "skill") {
console.log(objectData)
CrucibleUtility.updateSkill(objectData)
}
let itemData = foundry.utils.deepClone(CrucibleUtility.templateData(this.object));
let itemData = foundry.utils.deepClone(CrucibleUtility.templateData(this.object))
let formData = {
title: this.title,
id: this.id,

View File

@ -61,15 +61,18 @@ export class CrucibleRollDialog extends Dialog {
html.find('#advantage').change((event) => {
this.rollData.advantage = event.currentTarget.value
})
html.find('#disadvantage').change((event) => {
this.rollData.disadvantage = event.currentTarget.value
})
html.find('#rollAdvantage').change((event) => {
this.rollData.rollAdvantage = event.currentTarget.value
})
html.find('#featDieName').change((event) => {
/*html.find('#featDieName').change((event) => {
this.rollData.featDieName = event.currentTarget.value
})
html.find('#featDieSL').change((event) => {
this.rollData.featDieSL = event.currentTarget.value
})
})*/
}
}

View File

@ -5,6 +5,7 @@ import { CrucibleCommands } from "./crucible-commands.js";
/* -------------------------------------------- */
const __level2Dice = ["d0", "d4", "d6", "d8", "d10", "d12"];
const __name2DiceValue = { "0": 0, "d0": 0, "d4": 4, "d6": 6, "d8": 8, "d10": 10, "d12": 12 }
const __skillLevel2Dice = ["0d8", "1d8", "2d8","3d8", "4d8", '6d8', "8d8", "10d8"]
/* -------------------------------------------- */
export class CrucibleUtility {
@ -258,6 +259,12 @@ export class CrucibleUtility {
}
}
/* -------------------------------------------- */
static updateSkill( skill) {
skill.data.level = skill.data.background + skill.data.basic + skill.data.class + skill.data.explevel
if (skill.data.level > 7) { skill.data.level = 7}
skill.data.skilldice = __skillLevel2Dice[skill.data.level]
}
/* -------------------------------------------- */
static async rollCrucible(rollData) {
@ -267,17 +274,27 @@ export class CrucibleUtility {
let diceFormula = String(rollData.ability.value) + "d6cs>=5"
if (rollData.skill) {
let level = rollData.skill.data.level
if (rollData.featSLName != "none") {
let feat = rollData.featsSL.find(item => item.name == rollData.featSLName )
level += feat.data.sl
rollData.featSL = feat.data.sl
if (level == 0 && rollData.skill.data.isfeatdie ) {
rollData.hasSLBonus = true
level += 2
if (level > 7) { level = 7}
rollData.skill.data.skilldice = __skillLevel2Dice[level]
}
diceFormula += "+" + String(level) + "d8cs>=5"
diceFormula += "+" + String(rollData.skill.data.skilldice) + "cs>=5"
if (rollData.skill.data.skilltype == "complex" && rollData.skill.data.level == 0) {
rollData.complexSkillDisadvantage = true
rollData.rollAdvantage = "roll-disadvantage"
}
if (rollData.skill.data.level > 0 && rollData.skill.data.isfeatdie) {
rollData.hasFeatDie = true
diceFormula += "+ 1d10cs>=5"
}
if (rollData.skill.data.bonusdice != "none") {
rollData.hasBonusDice = rollData.skill.data.bonusdice
diceFormula += `+ ${rollData.hasBonusDice}cs>=5`
}
}
if(rollData.advantage == "advantage1") {
@ -286,15 +303,21 @@ export class CrucibleUtility {
if(rollData.advantage == "advantage2") {
diceFormula += "+ 2d10cs>=5"
}
if(rollData.advantage == "disadvantage1") {
if(rollData.disadvantage == "disadvantage1") {
diceFormula += "- 1d10cs>=5"
}
if(rollData.advantage == "disadvantage2") {
if(rollData.disadvantage == "disadvantage2") {
diceFormula += "- 2d10cs>=5"
}
if (rollData.featDieName != "none") {
diceFormula += "+ 1d10cs>=5"
let skillArmorPenalty = 0
for (let armor of rollData.armors) {
skillArmorPenalty += armor.data.skillpenalty
}
if (skillArmorPenalty > 0 ) {
rollData.skillArmorPenalty = skillArmorPenalty
diceFormula += `- ${skillArmorPenalty}d10cs>=5`
}
// Performs roll
let myRoll = rollData.roll
if (!myRoll) { // New rolls only of no rerolls

View File

@ -23,3 +23,4 @@
{"_id":"s2AAQviLttcHul3X","name":"Charm","type":"skill","img":"systems/fvtt-crucible-rpg/images/icons/skills/Charm.png","data":{"ability":"cha","armorpenalty":false,"bonusdice":"none","level":0,"background":0,"basic":0,"class":0,"exp":0,"description":"<p>Getting someone to do what you want because they want to do it.</p>"},"effects":[],"folder":null,"sort":0,"permission":{"default":0,"Up3b6rNa3VKAFQC3":3},"flags":{}}
{"_id":"xlYUHAUSfQrsjQoi","name":"Survival","type":"skill","img":"systems/fvtt-crucible-rpg/images/icons/skills/Survival.webp","data":{"ability":"wit","armorpenalty":false,"bonusdice":"","level":0,"background":0,"basic":0,"class":0,"exp":0,"description":"<p>Help me set this snare and we'll eat like kings in the morning.</p>"},"effects":[],"folder":null,"sort":0,"permission":{"default":0,"Up3b6rNa3VKAFQC3":3},"flags":{}}
{"_id":"yAhtkgqf7pKyjJTA","name":"Poison Use","type":"skill","img":"systems/fvtt-crucible-rpg/images/icons/skills/Poison%20Use.webp","data":{"ability":"dex","armorpenalty":false,"bonusdice":"","level":0,"background":0,"basic":0,"class":0,"exp":0,"description":"<p>Let me apply this to my blade.</p>"},"effects":[],"folder":null,"sort":0,"permission":{"default":0,"Up3b6rNa3VKAFQC3":3},"flags":{}}
{"name":"Axe (Copy)","type":"skill","img":"systems/fvtt-crucible-rpg/images/icons/icon_skill.webp","data":{"ability":"agi","armorpenalty":false,"isproficient":true,"isweaponskill":true,"isfeatdie":false,"islore":false,"skilltype":"complex","isinnate":false,"bonusdice":"none","background":0,"basic":0,"class":0,"exp":0,"explevel":0,"description":"","level":2},"effects":[],"folder":null,"sort":0,"permission":{"default":0,"Up3b6rNa3VKAFQC3":3},"flags":{"core":{"sourceId":"Item.Cnw8keaxD1SI3vun"}},"_id":"fJjXMpUILcN983XV"}

View File

@ -208,11 +208,11 @@
"styles": [
"styles/simple.css"
],
"templateVersion": 10,
"templateVersion": 11,
"title": "Crucible RPG",
"manifest": "https://www.uberwald.me/gitea/public/fvtt-crucible-rpg/raw/master/system.json",
"download": "https://www.uberwald.me/gitea/public/fvtt-crucible-rpg/archive/fvtt-crucible-rpg-v0.1.16.zip",
"download": "https://www.uberwald.me/gitea/public/fvtt-crucible-rpg/archive/fvtt-crucible-rpg-v0.1.17.zip",
"url": "https://www.uberwald.me/gitea/public/fvtt-crucible-rpg",
"version": "0.1.16",
"version": "0.1.17",
"background" : "./images/ui/crucible_welcome_page.webp"
}

View File

@ -121,15 +121,16 @@
"armorpenalty": false,
"isproficient": false,
"isweaponskill": false,
"isfeatdie": false,
"islore": false,
"skilltype": "",
"isinnate": false,
"bonusdice": "",
"level": 0,
"background": 0,
"basic": 0,
"class": 0,
"exp": 0,
"explevel": 0,
"description": ""
},
"armor": {

View File

@ -63,7 +63,7 @@
<label class="short-label">Ability</label>
</span>
<span class="item-field-label-short">
<label class="short-label">Score</label>
<label class="short-label">Dice</label>
</span>
<span class="item-field-label-long">
<label class="short-label">Background</label>
@ -75,7 +75,7 @@
src="{{skill.img}}" /></a>
<span class="item-name-label"><a class="roll-skill">{{skill.name}}</a></span>
<span class="item-field-label-short">{{upper skill.data.ability}}</span>
<span class="item-field-label-short">{{skill.data.level}}d8</span>
<span class="item-field-label-short">{{skill.data.skilldice}}</span>
<span class="item-field-label-long">&nbsp;-&nbsp;</span>
<div class="item-filler">&nbsp;</div>
<div class="item-controls item-controls-fixed">
@ -107,7 +107,7 @@
<li class="item flexrow list-item list-item-shadow" data-item-id="{{weapon._id}}">
<a class="item-edit item-name-img" title="Edit Item"><img class="sheet-competence-img"
src="{{weapon.img}}" /></a>
<span class="item-name-label-long">{{weapon.name}}</span>
<span class="item-name-label-long"><a class ="roll-weapon">{{weapon.name}}</a></span>
<span class="item-field-label-short">{{weapon.data.ability}}</span>

View File

@ -47,7 +47,15 @@
{{#if (eq rollAdvantage "roll-disadvantage")}}
<li>Roll with Disadvantage !</li>
{{/if}}
{{#if skillArmorPenalty}}
<li>Armor Penalty : {{skillArmorPenalty}} Disadvantage Dice </li>
{{/if}}
{{#if hasBonusDice}}
<li>Skill bonus dice : {{hasBonusDice}} </li>
{{/if}}
{{#if complexSkillDisadvantage}}
<li>Roll with Disadvantage because of Complex Skill at SL 0 !</li>
{{/if}}

View File

@ -23,12 +23,12 @@
</select>
</li>
<li class="flexrow"><label class="generic-label">Subject to Armor Penalty ?</label>
<label class="attribute-value checkbox"><input type="checkbox" name="data.armorpenalty" {{checked data.armorpenalty}}/></label>
<li class="flexrow"><label class="generic-label">Is Feat Die (or SL +2) ?</label>
<label class="attribute-value checkbox"><input type="checkbox" name="data.isfeatdie" {{checked data.isfeatdie}}/></label>
</li>
<li class="flexrow"><label class="generic-label">Is Proficient ?</label>
<label class="attribute-value checkbox"><input type="checkbox" name="data.isproficient" {{checked data.isproficient}}/></label>
<li class="flexrow"><label class="generic-label">Subject to Armor Penalty ?</label>
<label class="attribute-value checkbox"><input type="checkbox" name="data.armorpenalty" {{checked data.armorpenalty}}/></label>
</li>
<li class="flexrow"><label class="generic-label">Skill Type</label>
@ -41,19 +41,7 @@
</li>
<li class="flexrow"><label class="generic-label">Skill Dice</label>
<select class="competence-base flexrow" type="text" name="data.level" value="{{data.level}}" data-dtype="Number">
{{#select data.level}}
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
{{/select}}
</select>
<input type="text" class="" name="data.skilldice" value="{{data.skilldice}} (level {{data.level}})" data-dtype="String" disabled/>
</li>
<li class="flexrow"><label class="generic-label">Is Innate ?</label>
@ -96,7 +84,11 @@
<input type="text" class="" name="data.class" value="{{data.class}}" data-dtype="Number"/>
</li>
<li class="flexrow"><label class="generic-label">Exp</label>
<li class="flexrow"><label class="generic-label">Exp level</label>
<input type="text" class="" name="data.explevel" value="{{data.explevel}}" data-dtype="Number"/>
</li>
<li class="flexrow"><label class="generic-label">Gained exp (+1 to Exp level at 25)</label>
<input type="text" class="" name="data.exp" value="{{data.exp}}" data-dtype="Number"/>
</li>

View File

@ -31,7 +31,7 @@
</li>
<li class="flexrow"><label class="generic-label">Associated skill</label>
<select class="competence-base flexrow" type="text" name="data.skill" value="{{data.skill}}" data-dtype="Number">
<select class="competence-base flexrow" type="text" name="data.skill" value="{{data.skill}}" data-dtype="String">
{{#select data.skill}}
{{#each weaponSkills as |skill idx|}}
<option value="{{skill.name}}">{{skill.name}}</option>

View File

@ -13,20 +13,40 @@
<span class="roll-dialog-label">{{ability.value}}d6</span>
</div>
{{#if weapon}}
<div class="flexrow">
<span class="roll-dialog-label">Weapon : </span>
<span class="roll-dialog-label">{{weapon.name}}</span>
</div>
{{/if}}
{{#if skill}}
<div class="flexrow">
<span class="roll-dialog-label">Skill : </span>
<span class="roll-dialog-label">{{skill.name}} - {{skill.data.level}}d8</span>
<span class="roll-dialog-label">{{skill.name}} - {{skill.data.skilldice}}</span>
</div>
<div class="flexrow">
<span class="roll-dialog-label">Feature die or SL+2? : </span>
<span class="roll-dialog-label">{{#if skill.data.isfeatdie}} Yes {{else}} No {{/if}}</span>
</div>
{{/if}}
<div class="flexrow">
<span class="roll-dialog-label">Advantage/Disadvantage : </span>
<span class="roll-dialog-label">Advantage : </span>
<select class="status-small-label color-class-common" type="text" id="advantage" value="{{advantage}}" data-dtype="String" >
{{#select advantage}}
<option value="none">None</option>
<option value="advantage1">1 Advantage</option>
<option value="advantage2">2 Advantages</option>
{{/select}}
</select>
</div>
<div class="flexrow">
<span class="roll-dialog-label">Disadvantage : </span>
<select class="status-small-label color-class-common" type="text" id="disadvantage" value="{{disadvantage}}" data-dtype="String" >
{{#select isadvantage}}
<option value="none">None</option>
<option value="disadvantage1">1 Disadvantage</option>
<option value="disadvantage2">2 Disadvantages</option>
{{/select}}
@ -44,30 +64,6 @@
</select>
</div>
<div class="flexrow">
<span class="roll-dialog-label">Feature Die : </span>
<select class="status-small-label color-class-common" type="text" id="featDieName" value="{{featDieName}}" data-dtype="String" >
{{#select featDieName}}
<option value="none">None</option>
{{#each featsDie as |feat idx|}}
<option value="{{feat.name}}">{{feat.name}}</option>
{{/each}}
{{/select}}
</select>
</div>
<div class="flexrow">
<span class="roll-dialog-label">Feature SL : </span>
<select class="status-small-label color-class-common" type="text" id="featSLName" value="{{featSLName}}" data-dtype="String" >
{{#select featSLName}}
<option value="none">None</option>
{{#each featsSL as |feat idx|}}
<option value="{{feat.name}}">{{feat.name}} ({{feat.data.sl}})</option>
{{/each}}
{{/select}}
</select>
</div>
</div>
</form>