mirror of
https://github.com/Nighthawk42/roll20-character-sheets.git
synced 2026-09-11 01:22:32 +00:00
Starting on web worker code.
This commit is contained in:
@@ -24,4 +24,3 @@ table.abilityScores
|
||||
+abilityScoreRow('Intelligence', 'int')
|
||||
+abilityScoreRow('Wisdom', 'wis')
|
||||
+abilityScoreRow('Charisma', 'cha')
|
||||
// +labelledAbove('Ability Score Notes')(style='width: 100%;'): +textarea('appearance')(style='height: 0.6in;')
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
td: .mathOperator +
|
||||
td: +readOnlyBox(abilityShortName + '_mod')(style='width: 0.25in;')
|
||||
td: .mathOperator +
|
||||
td: +readOnlyBox('attack_size')(style='width: 0.25in;')
|
||||
td: +readOnlyBox('size')(style='width: 0.25in;')
|
||||
td: .mathOperator +
|
||||
td: +fieldBox('number', attackName + '_equipment')
|
||||
td: .mathOperator +
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
+labelledUnderlined('Size')(style='width: 1.2in;'): +select('size')
|
||||
option(value=4) Colossal
|
||||
option(value=3) Gargantuan
|
||||
option(value=2) Huge
|
||||
option(value=1) Large
|
||||
option(value=-8) Colossal
|
||||
option(value=-4) Gargantuan
|
||||
option(value=-2) Huge
|
||||
option(value=-1) Large
|
||||
option(value=0, selected=true) Medium
|
||||
option(value=-1) Small
|
||||
option(value=-2) Tiny
|
||||
option(value=-3) Diminuitive
|
||||
option(value=-4) Fine
|
||||
option(value=1) Small
|
||||
option(value=2) Tiny
|
||||
option(value=4) Diminuitive
|
||||
option(value=8) Fine
|
||||
|
||||
@@ -2,7 +2,7 @@ mixin fieldBox(type, name, label)
|
||||
.fieldBox(style=attributes.style)
|
||||
if(label)
|
||||
label= label
|
||||
.inner: input(type=type, name='attr_' + name)
|
||||
.inner: input(type=type, name='attr_' + name, value=attributes.value)
|
||||
|
||||
mixin fraction(name)
|
||||
.fraction
|
||||
@@ -11,7 +11,7 @@ mixin fraction(name)
|
||||
input(type='number', name='attr_' + name + '_max')
|
||||
|
||||
mixin input(type, name)
|
||||
input(type=type, name='attr_' + name, placeholder=attributes.placeholder, style=attributes.style)
|
||||
input(type=type, name='attr_' + name, placeholder=attributes.placeholder, style=attributes.style, value=attributes.value)
|
||||
|
||||
mixin labelledAbove(label)
|
||||
.labelledAbove(style=attributes.style)
|
||||
@@ -41,7 +41,8 @@ mixin option(view, value)
|
||||
option(value=value)= view
|
||||
|
||||
mixin readOnlyBox(name)
|
||||
.readOnlyBox(style=attributes.style): span(name='attr_' + name) 0
|
||||
.readOnlyBox(style=attributes.style): span(name='attr_' + name)
|
||||
+input('number', name)(value='0', style='display:none;')
|
||||
|
||||
mixin repeating(name)
|
||||
fieldset(class='repeating_' + name)
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
include fields.pug
|
||||
include tabs.pug
|
||||
|
||||
+input('text', 'debug')(value=' ', style='display: none;')
|
||||
|
||||
.top
|
||||
.pfLogo
|
||||
.topStats(style='margin-bottom: 1em;')
|
||||
@@ -27,4 +29,7 @@ include tabs.pug
|
||||
+tab('Magic', 'mainTabs')
|
||||
include magic/index.pug
|
||||
+tab('Notes', 'mainTabs')
|
||||
.test Notes
|
||||
include notes/index.pug
|
||||
|
||||
script(type='text/worker')
|
||||
include ../worker_test.js
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
.notesTab
|
||||
+textarea('notes')(style='height: 6in;')
|
||||
+338
-153
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,113 @@
|
||||
(() => {
|
||||
'use strict';
|
||||
|
||||
function _debug(msg) {
|
||||
return _setAttrs({
|
||||
debug: msg
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Promise-wrapped getAttrs.
|
||||
*/
|
||||
function _getAttrs(attrs) {
|
||||
return new Promise((resolve, reject) => {
|
||||
getAttrs(attrs, resolve);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Promise-wrapped getSectionIDs.
|
||||
*/
|
||||
function _getSectionIds(sectionName) {
|
||||
return new Promise((resolve, reject) => {
|
||||
getSectionIDs(sectionName, resolve);
|
||||
});
|
||||
}
|
||||
|
||||
function _onChange(attrNames, cb) {
|
||||
let list = _.chain(attrNames)
|
||||
.map(name => {
|
||||
return 'change:' + name
|
||||
})
|
||||
.value();
|
||||
|
||||
on(list.join(' '), cb);
|
||||
}
|
||||
|
||||
/**
|
||||
* Promise-wrapped setAttrs.
|
||||
*/
|
||||
function _setAttrs(values) {
|
||||
return new Promise((resolve, reject) => {
|
||||
log(values);
|
||||
setAttrs(values, undefined, resolve);
|
||||
});
|
||||
}
|
||||
|
||||
function updateAbilityMod(abilityName) {
|
||||
return _getAttrs([abilityName, abilityName + '_temp'])
|
||||
.then(values => {
|
||||
let base = values[abilityName];
|
||||
let temp = values[abilityName + '_temp'];
|
||||
return _setAttrs({
|
||||
[abilityName] + '_mod': Math.floor((base + temp - 10)/2)
|
||||
}});
|
||||
});
|
||||
}
|
||||
|
||||
function updateChaMod() {
|
||||
return updateAbilityMod('cha');
|
||||
}
|
||||
|
||||
function updateConMod() {
|
||||
return updateAbilityMod('con');
|
||||
}
|
||||
|
||||
function updateDexMod() {
|
||||
return updateAbilityMod('dex');
|
||||
}
|
||||
|
||||
function updateIntMod() {
|
||||
return updateAbilityMod('int');
|
||||
}
|
||||
|
||||
function updateStrMod() {
|
||||
return updateAbilityMod('str');
|
||||
}
|
||||
|
||||
function updateWisMod() {
|
||||
return updateAbilityMod('wis');
|
||||
}
|
||||
|
||||
|
||||
|
||||
_onChange(['cha', 'cha_temp'], () => {
|
||||
return updateChaMod();
|
||||
});
|
||||
|
||||
_onChange(['con', 'con_temp'], () => {
|
||||
return updateConMod();
|
||||
});
|
||||
|
||||
_onChange(['dex', 'dex_temp'], () => {
|
||||
return updateDexMod();
|
||||
});
|
||||
|
||||
_onChange(['int', 'int_temp'], () => {
|
||||
return updateIntMod();
|
||||
});
|
||||
|
||||
_onChange(['str', 'str_temp'], () => {
|
||||
return updateStrMod();
|
||||
});
|
||||
|
||||
_onChange(['wis', 'wis_temp'], () => {
|
||||
return updateWisMod();
|
||||
});
|
||||
|
||||
|
||||
on('sheet:opened', () => {
|
||||
updateAll();
|
||||
});
|
||||
})();
|
||||
@@ -0,0 +1,39 @@
|
||||
(() => {
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Promise-wrapped getAttrs.
|
||||
*/
|
||||
function _getAttrs(attrs) {
|
||||
return new Promise((resolve, reject) => {
|
||||
getAttrs(attrs, resolve);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Promise-wrapped setAttrs.
|
||||
*/
|
||||
function _setAttrs(values) {
|
||||
return new Promise(resolve, reject => {
|
||||
setAttrs(values, undefined, () => {
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
on('sheet:opened', () => {
|
||||
(new Promise((resolve, reject) => {
|
||||
resolve(42);
|
||||
}))
|
||||
.then(value => {
|
||||
return _setAttrs({
|
||||
debug: value
|
||||
});
|
||||
})
|
||||
.then(() => {
|
||||
setAttrs({
|
||||
debug: 11
|
||||
});
|
||||
});
|
||||
});
|
||||
})();
|
||||
Reference in New Issue
Block a user