Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
ironmonk88 authored Jan 12, 2021
1 parent 977f41b commit b06aabf
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions alwayshp.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export class AlwaysHPApp extends Application {
}

get getValue() {
return $('#alwayshp-hp', this.element).val();
return parseInt($('#alwayshp-hp', this.element).val());
}

clearInput() {
Expand All @@ -157,14 +157,14 @@ export class AlwaysHPApp extends Application {
ev.preventDefault();
log('set character to hurt');
let value = this.getValue;
if(value != '') AlwaysHP.changeHP(value);
if(value != '') AlwaysHP.changeHP(Math.abs(value));
this.clearInput();
});
html.find('#alwayshp-btn-heal').click(ev => {
ev.preventDefault();
log('set character to heal');
let value = this.getValue;
if (value != '') AlwaysHP.changeHP(-value);
if (value != '') AlwaysHP.changeHP(-Math.abs(value));
this.clearInput();
});
html.find('#alwayshp-btn-fullheal').click(ev => {
Expand All @@ -186,6 +186,18 @@ export class AlwaysHPApp extends Application {
range.moveStart('character', 0);
range.select();
}
}).keypress(ev => {
if (ev.which == 13) {
let value = this.getValue;
if (value != '' && value != 0) {
ev.preventDefault();

let rawvalue = $('#alwayshp-hp', this.element).val();

AlwaysHP.changeHP(rawvalue.startsWith('+') ? -Math.abs(value) : Math.abs(value)); //Heal with a + but everything else is a hurt
this.clearInput();
}
}
});
html.find('#alwayshp-move-handle').mousedown(ev => {
ev.preventDefault();
Expand Down

0 comments on commit b06aabf

Please sign in to comment.