Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds support for marking and handling intense training with a teacher… #60

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions dragonbane.css
Original file line number Diff line number Diff line change
Expand Up @@ -1620,3 +1620,9 @@
box-shadow: 0 0 2px #FFF inset;
word-break: break-all;
}
.system-dragonbane .checkbox-container {
display: flex;
flex-direction: row;
align-items: center;
justify-content: flex-start;
}
9 changes: 9 additions & 0 deletions dragonbane.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,15 @@ function registerSettings() {
default: true,
type: Boolean
});
// If true, support intensive training with a teacher
game.settings.register("dragonbane", "automaticSkillIntensiveTraining", {
name: "DoD.SETTINGS.automaticSkillIntensiveTraining",
hint: "DoD.SETTINGS.automaticSkillIntensiveTrainingHint",
scope: "world",
config: true,
default: false,
type: Boolean
});
}

Hooks.once("init", function () {
Expand Down
6 changes: 5 additions & 1 deletion lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,9 @@
"hide": "Hide",
"hideTooltip": "Hides skill from the list of Skills on the character's main tab",
"markAdvancement": "Mark skill for advancement",
"markTaught": "Immediately roll to advance skill due to intense training with a teacher.",
"rollAdvancement": "Roll to advance skill at end of session.\rRight-click to remove mark without rolling.",
"rollTaught": "Has already performed intense training with a teacher.",
"type": "Type",
"typeTooltip": "The skill's Type"
},
Expand Down Expand Up @@ -539,7 +541,9 @@
"allowDealDamageOnSelected": "Damage selected token",
"allowDealDamageOnSelectedHint": "If checked, the GM may deal damage (and heal) the selected token if no token has been targeted.",
"automaticSkillAdvancementMark": "Automate skill checkmark",
"automaticSkillAdvancementMarkHint": "Automatically set improvement checkmark on Dragon and Demon rolls."
"automaticSkillAdvancementMarkHint": "Automatically set improvement checkmark on Dragon and Demon rolls.",
"automaticSkillIntensiveTraining": "Handle intensive training with a teacher.",
"automaticSkillIntensiveTrainingHint": "Handle intensive training with a teacher (will add a second checkbox to be clicked after intensive training, if that advancement is successful it will be blocked until an advancement check has been filled.)"
},
"WARNING": {
"kinAbility": "Could not find Kin Ability: {ability}",
Expand Down
6 changes: 5 additions & 1 deletion lang/sv.json
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,9 @@
"hide": "Dölj",
"hideTooltip": "Dölj från listan med Färdigheter på karaktärens översiktsflik",
"markAdvancement": "Sätt förbättringskryss",
"markTaught": "Slå omedelbart förbättringsslag pga intensiv träning med lärare.",
"rollAdvancement": "Slå förbättringsslag i slutet av spelpasset.\rHögerklicka för att ta bort markeringen utan att slå förbättringsslag.",
"rollTaught": "Har redan utfört intensiv träning med en lärare",
"type": "Typ",
"typeTooltip": "Färdighetens typ"
},
Expand Down Expand Up @@ -543,7 +545,9 @@
"allowDealDamageOnSelected": "Skada på vald spelfigur",
"allowDealDamageOnSelectedHint": "Spelledaren (GM) kan tillfoga skada (och hela skada) på vald spelfigur om ingen spelfigur satts som mål.",
"automaticSkillAdvancementMark": "Automatiskt förbättringskryss",
"automaticSkillAdvancementMarkHint": "Sätt automatiskt förbättringskryss vid Drakslag eller Demonslag."
"automaticSkillAdvancementMarkHint": "Sätt automatiskt förbättringskryss vid Drakslag eller Demonslag.",
"automaticSkillIntensiveTraining": "Hantera intensiv träning med en lärare.",
"automaticSkillIntensiveTrainingHint": "Hantera intensiv träning med en lärare (lägger till en knapp för intensiv träning, om det lyckas blockeras knappen tills förbättringskryss är ifyllt.)"
},
"WARNING": {
"kinAbility": "Kan ej hitta Släktesförmåga: {ability}",
Expand Down
55 changes: 49 additions & 6 deletions modules/character-sheet.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as DoDChat from "./chat.js";
import { DoD } from "./config.js";
import {DoD} from "./config.js";
import DoDAttributeTest from "./tests/attribute-test.js";
import DoDSkillTest from "./tests/skill-test.js";
import DoDSpellTest from "./tests/spell-test.js";
Expand Down Expand Up @@ -89,7 +89,8 @@ export default class DoDCharacterSheet extends ActorSheet {
editable: this.isEditable,
actor: baseData.actor,
system: baseData.data.system,
config: CONFIG.DoD
config: CONFIG.DoD,
automaticSkillIntensiveTraining: game.settings.get("dragonbane", "automaticSkillIntensiveTraining") ?? false
};

async function enrich(html) {
Expand Down Expand Up @@ -359,6 +360,7 @@ export default class DoDCharacterSheet extends ActorSheet {
html.find(".use-ability").on("click contextmenu", this._onUseAbility.bind(this));
html.find("[data-action='roll-advancement']").on("click contextmenu", this._onAdvancementRoll.bind(this))
html.find(".mark-advancement").on("click", this._onMarkAdvancement.bind(this))
html.find(".mark-taught").on("click", this._onMarkTaught.bind(this))

html.find(".hit-points-max-label").change(this._onEditHp.bind(this));
html.find(".hit-points-current-label").change(this._onEditCurrentHp.bind(this));
Expand Down Expand Up @@ -1160,14 +1162,56 @@ export default class DoDCharacterSheet extends ActorSheet {
case 0: // Cancel
return;
case 1: // Mark
await skillItem.update({ "system.advance": true });
await skillItem.update({ "system.advance": true, "system.taught": false });
return;
case 2: // Train
await skillItem.update({ "system.value": baseChance * 2 });
return;
}
} else {
await skillItem.update({ "system.advance": true });
await skillItem.update({ "system.advance": true, "system.taught": false });
}
}

async _onMarkTaught(event) {
event.preventDefault();
const itemId = event.currentTarget.closest("tr").dataset.itemId;
const skillItem = this.actor.items.get(itemId);

// left click to roll, right-click to clear
if (event.type === "click") {

if (skillItem.system.taught) {
return;
}

// Make roll
const roll = await new Roll("D20").roll(game.release.generation < 12 ? { async: true } : {});
const advance = Math.min(DoD.skillMaximum, roll.result) > skillItem.system.value;
const flavorText = advance ?
game.i18n.format("DoD.skill.advancementSuccess", {
skill: skillItem.name,
old: skillItem.system.value,
new: skillItem.system.value + 1
}) :
game.i18n.format("DoD.skill.advancementFail", { skill: skillItem.name });

const msg = await roll.toMessage({
user: game.user.id,
speaker: ChatMessage.getSpeaker({ actor: this.actor }),
flavor: flavorText
});

if (advance) {
if (game.dice3d) {
game.dice3d.waitFor3DAnimationByMessageID(msg.id).then(
() => skillItem.update({ "system.value": skillItem.system.value + 1, "system.taught": true }));
} else {
await skillItem.update({ "system.value": skillItem.system.value + 1, "system.taught": true });
}
}
} else {
await skillItem.update({ "system.taught": false })
}
}

Expand Down Expand Up @@ -1202,9 +1246,8 @@ export default class DoDCharacterSheet extends ActorSheet {
}
}
// always clear advancement
await skillItem.update({ "system.advance": false })
await skillItem.update({ "system.advance": false, "system.taught": false })
}

async _onConditionClick(event) {
if (event.target.className === "condition-input") {
return; // event is handled by input element
Expand Down
1 change: 1 addition & 0 deletions modules/data/items/skillData.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export default class DoDSkillData extends DoDItemBaseData {
attribute: new fields.StringField({ required: true, initial: "" }),
value: new fields.NumberField({ required: true, initial: 0 }),
advance: new fields.NumberField({ required: true, initial: 0 }),
taught: new fields.NumberField({ required: true, initial: 0 }),
hideTrained: new fields.BooleanField({ required: true, initial: false }),
});
};
Expand Down
60 changes: 51 additions & 9 deletions templates/partials/character-sheet-skills.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
<table class="sheet-table core-skills item-list">
<tr class="sheet-table-header">
<th></th>
{{#if @root.automaticSkillIntensiveTraining}}
<th></th>
{{/if}}
<th class="number-header">
{{localize "DoD.ui.character-sheet.skillValue"}}
</th>
Expand All @@ -21,15 +24,26 @@
<td class="checkbox-data icon-data">
{{#if skill.canImproveSkill}}
{{#if skill.system.advance}}
<button type="button" class="roll-advancement" data-action="roll-advancement" title="{{localize "DoD.skill.rollAdvancement"}}">
<i class="fas fa-circle-arrow-up"></i>
</button>
<button type="button" class="roll-advancement" data-action="roll-advancement" title="{{localize "DoD.skill.rollAdvancement"}}">
<i class="fas fa-circle-arrow-up"></i>
</button>
{{else}}
<input title="{{localize "DoD.skill.markAdvancement"}}" class="mark-advancement" data-field="system.advance" type="checkbox" {{checked skill.system.advance}} />
{{/if}}
{{#if @root.automaticSkillIntensiveTraining}}
<td class="checkbox-data">
{{#if skill.system.taught}}
<button type="button" class="roll-taught" data-action="roll-taught" title="{{localize "DoD.skill.rollTaught"}}">
<i class="fas fa-brain"></i>
</button>
{{else}}
<input title="{{localize "DoD.skill.markTaught"}}" class="mark-taught" data-field="system.taught" type=checkbox {{checked skill.system.taught}} />
{{/if}}
</td>
{{/if}}
{{/if}}
</td>
<td class="number-data narrow">
<td class="number-data narrow" >
<input class="inline-edit" data-field="system.value" type="text" value="{{skill.system.value}}" data-dtype="Number"/>
</td>
<td class="skill-name text-data">
Expand Down Expand Up @@ -57,6 +71,9 @@
<table class="sheet-table weapon-skills item-list">
<tr class="sheet-table-header">
<th></th>
{{#if @root.automaticSkillIntensiveTraining}}
<th></th>
{{/if}}
<th class="number-header">
{{localize "DoD.ui.character-sheet.skillValue"}}
</th>
Expand All @@ -73,12 +90,23 @@
<td class="checkbox-data icon-data">
{{#if skill.canImproveSkill}}
{{#if skill.system.advance}}
<button type="button" class="roll-advancement" data-action="roll-advancement" title="{{localize "DoD.skill.rollAdvancement"}}">
<i class="fas fa-circle-arrow-up"></i>
</button>
<button type="button" class="roll-advancement" data-action="roll-advancement" title="{{localize "DoD.skill.rollAdvancement"}}">
<i class="fas fa-circle-arrow-up"></i>
</button>
{{else}}
<input title="{{localize "DoD.skill.markAdvancement"}}" class="mark-advancement" data-field="system.advance" type="checkbox" {{checked skill.system.advance}} />
{{/if}}
{{#if @root.automaticSkillIntensiveTraining}}
<td class="checkbox-data">
{{#if skill.system.taught}}
<button type="button" class="roll-taught" data-action="roll-taught" title="{{localize "DoD.skill.rollTaught"}}">
<i class="fas fa-brain"></i>
</button>
{{else}}
<input title="{{localize "DoD.skill.markTaught"}}" class="mark-taught" data-field="system.taught" type=checkbox {{checked skill.system.taught}} />
{{/if}}
</td>
{{/if}}
{{/if}}
</td>
<td class="number-data narrow">
Expand Down Expand Up @@ -107,6 +135,9 @@
<table class="sheet-table secondary-skills item-list">
<tr class="sheet-table-header">
<th></th>
{{#if @root.automaticSkillIntensiveTraining}}
<th></th>
{{/if}}
<th class="number-header">
{{localize "DoD.ui.character-sheet.skillValue"}}
</th>
Expand All @@ -126,10 +157,21 @@
<i class="fas fa-circle-arrow-up"></i>
</button>
{{else}}
<input title="{{localize "DoD.skill.markAdvancement"}}" class="mark-advancement" data-field="system.advance" type="checkbox" {{checked skill.system.advance}} />
<input title="{{localize "DoD.skill.markAdvancement"}}" class="mark-advancement" data-field="system.advance" type="checkbox" {{checked skill.system.advance}} />
{{/if}}
{{/if}}
</td>
</td>
{{#if @root.automaticSkillIntensiveTraining}}
<td class="checkbox-data">
{{#if skill.system.taught}}
<button type="button" class="roll-taught" data-action="roll-taught" title="{{localize "DoD.skill.rollTaught"}}">
<i class="fas fa-brain"></i>
</button>
{{else}}
<button title="{{localize "DoD.skill.markTaught"}}" class="mark-taught" data-field="system.taught" type="button" {{checked skill.system.taught}} />
{{/if}}
</td>
{{/if}}
<td class="number-data narrow">
<input class="inline-edit" data-field="system.value" type="text" value="{{skill.system.value}}" data-dtype="Number"/>
</td>
Expand Down