Skip to content

Commit

Permalink
fix: Several fixes.
Browse files Browse the repository at this point in the history
Age now displays correctly.
All fields have their values selected on focus
Skill rolls now use the right modifiers, with or without JOAT.
Removed some unused code.
Fixed some deprecation warnings.
Added gender to template.json.
Changed placeholder values.
Added some basic typing.
  • Loading branch information
xdy committed Aug 19, 2020
1 parent 581d42b commit 38d789f
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 52 deletions.
10 changes: 5 additions & 5 deletions src/module/entities/TwodsixActor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default class TwodsixActor extends Actor {
this._prepareCharacterData(actorData);
break;
default:

}

}
Expand All @@ -32,16 +32,16 @@ export default class TwodsixActor extends Actor {
_prepareCharacterData(actorData:ActorData):void {
// Get the Actor's data object
const {data} = actorData;

for (const cha of Object.values(data.characteristics as Record<any, any>)) {
cha.current = cha.value - cha.damage;
cha.mod = calcModFor(cha.current);
}

for (const skill of Object.values(data.skills as Record<any, any>)) {
var characteristic = skill.characteristic;
const characteristic = skill.characteristic;
console.log(skill)
skill.mod = data.characteristics[characteristic].mod;
skill.mod = calcModFor(data.characteristics[characteristic].value);
}
}
}
38 changes: 16 additions & 22 deletions src/module/sheets/TwodsixActorSheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,32 +62,32 @@ export class TwodsixActorSheet extends ActorSheet {
if (!this.options.editable) return;

// Add Inventory Item
html.find('.item-create').click(this._onItemCreate.bind(this));
html.find('.item-create').on('click', this._onItemCreate.bind(this));

// Update Inventory Item
html.find('.item-edit').click(ev => {
html.find('.item-edit').on('click', (ev => {
const li = $(ev.currentTarget).parents(".item");
const item = this.actor.getOwnedItem(li.data("itemId"));
item.sheet.render(true);
});
}));

// Delete Inventory Item
html.find('.item-delete').click(ev => {
html.find('.item-delete').on('click',(ev => {
const li = $(ev.currentTarget).parents(".item");
this.actor.deleteOwnedItem(li.data("itemId"));
li.slideUp(200, () => this.render(false));
});
}));

// Rollable abilities.
html.find('.rollable').click(this._onRoll.bind(this));
html.find('.rollable').on('click',(this._onRoll.bind(this)));

// Upgrade/downgrade skills.
html.find('.upgrade-skill').click(this._onUpgrade.bind(this));
html.find('.downgrade-skill').click(this._onDowngrade.bind(this));
html.find('.upgrade-joat').click(this._onUpgradeJoat.bind(this));
html.find('.downgrade-joat').click(this._onDowngradeJoat.bind(this));
html.find('.upgrade-skill').on('click',this._onUpgrade.bind(this));
html.find('.downgrade-skill').on('click',this._onDowngrade.bind(this));
html.find('.upgrade-joat').on('click',this._onUpgradeJoat.bind(this));
html.find('.downgrade-joat').on('click',this._onDowngradeJoat.bind(this));

html.find('.toggle-skills').click(ev => {
html.find('.toggle-skills').on('click',ev => {
ev.preventDefault();
this.options.hideUntrainedSkills = !this.options.hideUntrainedSkills;
this.actor.sheet.render(true)
Expand Down Expand Up @@ -136,16 +136,10 @@ export class TwodsixActorSheet extends ActorSheet {
* @param {Event} event The originating click event
* @private
*/
_onRoll(event):void {
_onRoll(event: { preventDefault: () => void; currentTarget: any; }):void {
event.preventDefault();
const element = event.currentTarget;
const dataset = element.dataset;
const trainable = element.getAttribute('trainable');
const trained = element.getAttribute('trained');

if (trainable == 'true' && trained == 'false' && !dataset.roll.includes('jackofalltrades.value')) {
dataset.roll += "[email protected]";
}

if (dataset.roll) {
const roll = new Roll(dataset.roll, this.actor.data.data);
Expand All @@ -157,7 +151,7 @@ export class TwodsixActorSheet extends ActorSheet {
}
}

_onUpgradeJoat(event:any):void {
_onUpgradeJoat(event: { preventDefault: () => void; currentTarget: any; }):void {
event.preventDefault();
const element = event.currentTarget;
const actorData = this.actor.data;
Expand All @@ -168,7 +162,7 @@ export class TwodsixActorSheet extends ActorSheet {
}
}

_onDowngradeJoat(event):void {
_onDowngradeJoat(event: { preventDefault: () => void; currentTarget: any; }):void {
event.preventDefault();
const element = event.currentTarget;
const actorData = this.actor.data;
Expand All @@ -184,7 +178,7 @@ export class TwodsixActorSheet extends ActorSheet {
* @param {Event} event The originating click event
* @private
*/
_onUpgrade(event):void {
_onUpgrade(event: { preventDefault: () => void; currentTarget: any; }):void {
event.preventDefault();
const element = event.currentTarget;
const skillName = element.getAttribute('data-label');
Expand All @@ -204,7 +198,7 @@ export class TwodsixActorSheet extends ActorSheet {
* @param {Event} event The originating click event
* @private
*/
_onDowngrade(event):void {
_onDowngrade(event: { preventDefault: () => void; currentTarget: any; }):void {
event.preventDefault();
const element = event.currentTarget;
const skillName = element.getAttribute('data-label');
Expand Down
1 change: 1 addition & 0 deletions static/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"value": 18,
"min": 0
},
"gender": "",
"radiationDose": {
"value": 0,
"min": 0
Expand Down
48 changes: 23 additions & 25 deletions static/templates/actors/actor-sheet.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,55 +5,55 @@
<span class="helper"></span>
<div class="character-photo"><img class="profile-img" src="{{actor.img}}" data-edit="img" title="{{actor.name}}"/></div>
</div>
<div class="character-name"><h2><input name="name" type="text" value="{{actor.name}}" placeholder="Character Name"/></h2></div>
<div class="character-name"><h2><input name="name" type="text" value="{{actor.name}}" placeholder="Character Name" onClick="this.select();"/></h2></div>
<div class="character-bgi">
<span class="bgi-age">Age:<input type="text" name="data.age" value="{{data.age}}" placeholder="0"/></span>
<span class="bgi-gender">Gender:<input name="data.gender" type="text" value="{{data.gender}}" placeholder="Sex"/></span>
<span class="bgi-species">Species:<input name="data.species" type="text" value="{{data.species}}" placeholder="Character Race"/></span>
<span class="bgi-homeworld">Homeworld:<input name="data.homeworld" type="text" value="{{data.homeworld}}" placeholder="Name World"/></span>
<span class="bgi-age">Age:<input type="text" name="data.age.value" value="{{data.age.value}}" placeholder="0"/></span>
<span class="bgi-gender">Gender:<input name="data.gender" type="text" value="{{data.gender}}" placeholder="Gender" onClick="this.select();"/></span>
<span class="bgi-species">Species:<input name="data.species" type="text" value="{{data.species}}" placeholder="Species" onClick="this.select();"/></span>
<span class="bgi-homeworld">Homeworld:<input name="data.homeworld" type="text" value="{{data.homeworld}}" placeholder="Homeworld" onClick="this.select();"/></span>
</div>

<div class="character-characteristics">
<div class="stat str">
<span class="stat-name rollable" data-roll="2d6+{{data.characteristics.strength.mod}}">STR <img src="./systems/twodsix/assets/d6-icon.svg"/></span>
<span class="stat-ability"><input type="number" min="0" name="data.characteristics.strength.value" data-label="data.characteristics.strength.value" value="{{data.characteristics.strength.value}}" placeholder="0" data-dtype="Number"/></span>
<span class="stat-ability"><input type="number" min="0" name="data.characteristics.strength.value" data-label="data.characteristics.strength.value" value="{{data.characteristics.strength.value}}" placeholder="0" data-dtype="Number" onClick="this.select();"/></span>
<span class="stat-modifier"><input readonly type="text" value="{{numberFormat data.characteristics.strength.mod decimals=0 sign=true}}"/></span>
<span class="stat-damage"><input type="number" max="{{data.characteristics.strength.value}}" min="0" name="data.characteristics.strength.damage" value="{{data.characteristics.strength.damage}}" placeholder="0" data-dtype="Number"/></span>
<span class="stat-damage"><input type="number" max="{{data.characteristics.strength.value}}" min="0" name="data.characteristics.strength.damage" value="{{data.characteristics.strength.damage}}" placeholder="0" data-dtype="Number" onClick="this.select();"/></span>
</div>
<div class="stat dex">
<span class="stat-name rollable" data-roll="2d6+{{data.characteristics.dexterity.mod}}">DEX <img src="./systems/twodsix/assets/d6-icon.svg"/></span>
<span class="stat-ability"><input type="number" min="0" name="data.characteristics.dexterity.value" data-label="data.characteristics.dexterity.value" value="{{data.characteristics.dexterity.value}}" placeholder="0" data-dtype="Number"/></span>
<span class="stat-ability"><input type="number" min="0" name="data.characteristics.dexterity.value" data-label="data.characteristics.dexterity.value" value="{{data.characteristics.dexterity.value}}" placeholder="0" data-dtype="Number" onClick="this.select();"/></span>
<span class="stat-modifier"><input readonly type="text" value="{{numberFormat data.characteristics.dexterity.mod decimals=0 sign=true}}"/></span>
<span class="stat-damage"><input type="number" max="{{data.characteristics.dexterity.value}}" min="0" name="data.characteristics.dexterity.damage" value="{{data.characteristics.dexterity.damage}}" placeholder="0" data-dtype="Number"/></span>
<span class="stat-damage"><input type="number" max="{{data.characteristics.dexterity.value}}" min="0" name="data.characteristics.dexterity.damage" value="{{data.characteristics.dexterity.damage}}" placeholder="0" data-dtype="Number" onClick="this.select();"/></span>
</div>
<div class="stat end">
<span class="stat-name rollable" data-roll="2d6+{{data.characteristics.endurance.mod}}">END <img src="./systems/twodsix/assets/d6-icon.svg"/></span></span>
<span class="stat-ability"><input type="number" min="0" name="data.characteristics.endurance.value" data-label="data.characteristics.endurance.value" value="{{data.characteristics.endurance.value}}" placeholder="0" data-dtype="Number"/></span>
<span class="stat-ability"><input type="number" min="0" name="data.characteristics.endurance.value" data-label="data.characteristics.endurance.value" value="{{data.characteristics.endurance.value}}" placeholder="0" data-dtype="Number" onClick="this.select();"/></span>
<span class="stat-modifier"><input readonly type="text" value="{{numberFormat data.characteristics.endurance.mod decimals=0 sign=true}}"/></span>
<span class="stat-damage"><input type="number" max="{{data.characteristics.endurance.value}}" min="0" name="data.characteristics.endurance.damage" value="{{data.characteristics.endurance.damage}}" placeholder="0" data-dtype="Number"/></span>
<span class="stat-damage"><input type="number" max="{{data.characteristics.endurance.value}}" min="0" name="data.characteristics.endurance.damage" value="{{data.characteristics.endurance.damage}}" placeholder="0" data-dtype="Number" onClick="this.select();"/></span>
</div>
<div class="stat int">
<span class="stat-name rollable" data-roll="2d6+{{data.characteristics.intellect.mod}}">INT <img src="./systems/twodsix/assets/d6-icon.svg"/></span></span>
<span class="stat-ability"><input type="number" min="0" name="data.characteristics.intellect.value" data-label="data.characteristics.intellect.value" value="{{data.characteristics.intellect.value}}" placeholder="0" data-dtype="Number"/></span>
<span class="stat-ability"><input type="number" min="0" name="data.characteristics.intellect.value" data-label="data.characteristics.intellect.value" value="{{data.characteristics.intellect.value}}" placeholder="0" data-dtype="Number" onClick="this.select();"/></span>
<span class="stat-modifier"><input readonly type="text" value="{{numberFormat data.characteristics.intellect.mod decimals=0 sign=true}}"/></span>
<span class="stat-damage"><input type="number" max="{{data.characteristics.intellect.value}}" min="0" name="data.characteristics.intellect.damage" value="{{data.characteristics.intellect.damage}}" placeholder="0" data-dtype="Number"/></span>
<span class="stat-damage"><input type="number" max="{{data.characteristics.intellect.value}}" min="0" name="data.characteristics.intellect.damage" value="{{data.characteristics.intellect.damage}}" placeholder="0" data-dtype="Number" onClick="this.select();"/></span>
</div>
<div class="stat edu">
<span class="stat-name rollable" data-roll="2d6+{{data.characteristics.education.mod}}">EDU <img src="./systems/twodsix/assets/d6-icon.svg"/></span></span>
<span class="stat-ability"><input type="number" min="0" name="data.characteristics.education.value" data-label="data.characteristics.education.value" value="{{data.characteristics.education.value}}" placeholder="0" data-dtype="Number"/></span>
<span class="stat-ability"><input type="number" min="0" name="data.characteristics.education.value" data-label="data.characteristics.education.value" value="{{data.characteristics.education.value}}" placeholder="0" data-dtype="Number" onClick="this.select();"/></span>
<span class="stat-modifier"><input readonly type="text" value="{{numberFormat data.characteristics.education.mod decimals=0 sign=true}}"/></span>
<span class="stat-damage"><input type="number" max="{{data.characteristics.education.value}}" min="0" name="data.characteristics.education.damage" value="{{data.characteristics.education.damage}}" placeholder="0" data-dtype="Number"/></span>
<span class="stat-damage"><input type="number" max="{{data.characteristics.education.value}}" min="0" name="data.characteristics.education.damage" value="{{data.characteristics.education.damage}}" placeholder="0" data-dtype="Number" onClick="this.select();"/></span>
</div>
<div class="stat soc">
<span class="stat-name rollable" data-roll="2d6+{{data.characteristics.social.mod}}">SOC <img src="./systems/twodsix/assets/d6-icon.svg"/></span></span>
<span class="stat-ability"><input type="number" min="0" name="data.characteristics.social.value" data-label="data.characteristics.social.value" value="{{data.characteristics.social.value}}" placeholder="0" data-dtype="Number"/></span>
<span class="stat-ability"><input type="number" min="0" name="data.characteristics.social.value" data-label="data.characteristics.social.value" value="{{data.characteristics.social.value}}" placeholder="0" data-dtype="Number" onClick="this.select();"/></span>
<span class="stat-modifier"><input readonly type="text" value="{{numberFormat data.characteristics.social.mod decimals=0 sign=true}}"/></span>
<span class="stat-damage"><input type="number" max="{{data.characteristics.social.value}}" min="0" name="data.characteristics.social.damage" value="{{data.characteristics.social.damage}}" placeholder="0" data-dtype="Number"/></span>
<span class="stat-damage"><input type="number" max="{{data.characteristics.social.value}}" min="0" name="data.characteristics.social.damage" value="{{data.characteristics.social.damage}}" placeholder="0" data-dtype="Number" onClick="this.select();"/></span>
</div>
<div class="special psi">
<span class="special-name rollable" data-roll="2d6+{{data.characteristics.psionics.mod}}">PSI <img src="./systems/twodsix/assets/d6-icon.svg"/></span></span>
<span class="special-ability"><input type="number" min="0" name="data.characteristics.psionics.value" data-label="data.characteristics.psionics.value" value="{{data.characteristics.psionics.value}}" placeholder="0" data-dtype="Number"/></span>
<span class="special-damage"><input type="number" max="{{data.characteristics.psionics.value}}" min="0" name="data.characteristics.psionics.damage" value="{{data.characteristics.psionics.damage}}" placeholder="0" data-dtype="Number"/></span>
<span class="special-ability"><input type="number" min="0" name="data.characteristics.psionics.value" data-label="data.characteristics.psionics.value" value="{{data.characteristics.psionics.value}}" placeholder="0" data-dtype="Number" onClick="this.select();"/></span>
<span class="special-damage"><input type="number" max="{{data.characteristics.psionics.value}}" min="0" name="data.characteristics.psionics.damage" value="{{data.characteristics.psionics.damage}}" placeholder="0" data-dtype="Number" onClick="this.select();"/></span>
<span class="special-modifier"><input readonly type="text" value="{{numberFormat data.characteristics.psionics.mod decimals=0 sign=true}}"/></span>
</div>
</div>
Expand Down Expand Up @@ -119,9 +119,9 @@
<option value="psionics" for="skill-modifier">PSI</option>
{{/select}}
</select>






<span class="skill-arrows flex1">

Expand All @@ -132,11 +132,9 @@

</span>


<!-- TODO Hardcoded dexterity for now, but it should get the value from the dropdown. Also moved dexterity to the top and disabled the select to make it seem less strange. :) -->
<span class="skill-output" trainable="true" trained="{{skill.trained}}" class="flex1 skill-mod rollable"
<span class="skill-output" class="flex1 skill-mod"
data-label="{{skill.label}}">{{numberFormat (getSkillValueWithJoat skill @root.data.jackofalltrades) decimals=0 sign=true}}
<img class="rollable" data-roll="2d6+{{skill.value}}+{{skill.mod}}" src="./systems/twodsix/assets/d6-icon.svg"/>
<img class="rollable" data-roll="2d6+{{getSkillValueWithJoat skill @root.data.jackofalltrades}}+{{skill.mod}}" src="./systems/twodsix/assets/d6-icon.svg"/>
</span>


Expand Down

0 comments on commit 38d789f

Please sign in to comment.