Skip to content

Commit

Permalink
Merge pull request #62 from CurtR95/0.2.2
Browse files Browse the repository at this point in the history
0.2.2 Dice Too Nice
  • Loading branch information
CurtR95 authored Aug 1, 2020
2 parents 27a17dd + ebe8a42 commit 2265076
Show file tree
Hide file tree
Showing 13 changed files with 447 additions and 534 deletions.
1 change: 1 addition & 0 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
"dishonored.roll.power.rune": "<b>|#|</b> Runes",
"dishonored.roll.power.mana": "Costs <b>|#|</b> Mana to use",
"dishonored.roll.item.value": "|#| Coins",
"dishonored.roll.item.quantity": "|#|x Items",



Expand Down
129 changes: 117 additions & 12 deletions module/actors/actor.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,125 @@
/**
* Extend the base Actor entity by defining a custom roll data structure which is ideal for the Simple system.
* @extends {Actor}
*/
import {
DishonoredRollDialog
} from '../apps/roll-dialog.js'
import {
DishonoredRoll
} from '../roll.js'

export class DishonoredActor extends Actor {
prepareData() {
super.prepareData();
// const actorData = this.data;
}
}

const actorData = this.data;
const data = actorData.data;
const flags = actorData.flags;
export class DishonoredSharedActorFunctions {

if (actorData.type === 'character') this._prepareCharacterData(actorData);
// This function renders all the tracks. This will be used every time the character sheet is loaded. It is a vital element as such it runs before most other code!
dishonoredRenderTracks(html, stressTrackMax, voidPointsMax, expPointsMax, momentumMax) {
var i;
// Checks if details for the Stress Track was included, this should happen in all cases!
if (stressTrackMax) {
for (i = 0; i < stressTrackMax; i++) {
if (i + 1 <= html.find('#total-stress')[0].value) {
html.find('[id^="stress"]')[i].setAttribute("data-selected", "true");
html.find('[id^="stress"]')[i].style.backgroundColor = "#191813";
html.find('[id^="stress"]')[i].style.color = "#ffffff";
} else {
html.find('[id^="stress"]')[i].removeAttribute("data-selected");
html.find('[id^="stress"]')[i].style.backgroundColor = "rgb(255, 255, 255, 0.3)";
html.find('[id^="stress"]')[i].style.color = "";
}
}
}
// Checks if details for the Void Track was included, this should happen for all Characters!
if (voidPointsMax) {
for (i = 0; i < voidPointsMax; i++) {
if (i + 1 <= html.find('#total-void')[0].value) {
html.find('[id^="void"]')[i].setAttribute("data-selected", "true");
html.find('[id^="void"]')[i].style.backgroundColor = "#191813";
html.find('[id^="void"]')[i].style.color = "#ffffff";
} else {
html.find('[id^="void"]')[i].removeAttribute("data-selected");
html.find('[id^="void"]')[i].style.backgroundColor = "rgb(255, 255, 255, 0.3)";
html.find('[id^="void"]')[i].style.color = "";
}
}
}
// Checks if details for the Experience Track was included, this should happen for all Characters!
if (expPointsMax) {
for (i = 0; i < expPointsMax; i++) {
if (i + 1 <= html.find('#total-exp')[0].value) {
html.find('[id^="exp"]')[i].setAttribute("data-selected", "true");
html.find('[id^="exp"]')[i].style.backgroundColor = "#191813";
html.find('[id^="exp"]')[i].style.color = "#ffffff";
} else {
html.find('[id^="exp"]')[i].removeAttribute("data-selected");
html.find('[id^="exp"]')[i].style.backgroundColor = "rgb(255, 255, 255, 0.3)";
html.find('[id^="exp"]')[i].style.color = "";
}
}
}
// Checks if details for the Momentum Track was included, this should happen for all Characters!
if(momentumMax) {
for (i = 0; i < 6; i++) {
if (i + 1 <= html.find('#total-mom')[0].value) {
html.find('[id^="mom"]')[i].setAttribute("data-selected", "true");
html.find('[id^="mom"]')[i].style.backgroundColor = "#191813";
html.find('[id^="mom"]')[i].style.color = "#ffffff";
} else {
html.find('[id^="mom"]')[i].removeAttribute("data-selected");
html.find('[id^="mom"]')[i].style.backgroundColor = "rgb(255, 255, 255, 0.3)";
html.find('[id^="mom"]')[i].style.color = "";
}
}
}
}

_prepareCharacterData(actorData) {
const data = actorData.data;
// console.log(data);
}
// This handles performing a skill test using the "Perform Check" button.
async rollSkillTest(event, checkTarget, selectedSkill, selectedStyle, speaker) {
event.preventDefault();
// This creates a dialog to gather details regarding the roll and waits for a response
let rolldialog = await DishonoredRollDialog.create();
if (rolldialog) {
let dicePool = rolldialog.get("dicePoolSlider");
let focusTarget = parseInt(rolldialog.get("dicePoolFocus"));
// Once the response has been collected it then sends it to be rolled.
let dishonoredRoll = new DishonoredRoll();
dishonoredRoll.performSkillTest(dicePool, checkTarget, focusTarget, selectedSkill, selectedStyle, speaker);
}
}

// This handles performing an "item" roll by clicking the item's image.
async rollGenericItem(event, type, id, speaker) {
event.preventDefault();
var item = speaker.items.get(id);
let dishonoredRoll = new DishonoredRoll();
// It will send it to a different method depending what item type was sent to it.
switch(type) {
case "item":
dishonoredRoll.performItemRoll(item, speaker);
break;
case "focus":
dishonoredRoll.performFocusRoll(item, speaker);
break;
case "bonecharm":
dishonoredRoll.performBonecharmRoll(item, speaker);
break;
case "weapon":
dishonoredRoll.performWeaponRoll(item, speaker);
break;
case "armor":
dishonoredRoll.performArmorRoll(item, speaker);
break;
case "talent":
dishonoredRoll.performTalentRoll(item, speaker);
break;
case "contact":
dishonoredRoll.performContactRoll(item, speaker);
break;
case "power":
dishonoredRoll.performPowerRoll(item, speaker);
break;
}
}
}
Loading

0 comments on commit 2265076

Please sign in to comment.