Browse Source

Finalize spell imports

master
Brandon Cornejo 5 years ago
parent
commit
79f9260d13
  1. 3
      acks/npc/npc_party.py
  2. 144
      roll20/base64.js
  3. 6
      roll20/char_sheet.css
  4. 35
      roll20/char_sheet.html
  5. 19
      roll20/npc_party_import.js

3
acks/npc/npc_party.py

@ -106,9 +106,6 @@ def select_spell_list(npc, data):
level_set.add(choice(overall_spell_list[level]).id) level_set.add(choice(overall_spell_list[level]).id)
npc_spell_list.extend(level_set) npc_spell_list.extend(level_set)
# FOR DEBUG XXX NOTE
npc_spell_list.append(106)
return ','.join(str(sid) for sid in npc_spell_list) return ','.join(str(sid) for sid in npc_spell_list)
def calc_hp(conmod, hit_die_size, level): def calc_hp(conmod, hit_die_size, level):

144
roll20/base64.js

@ -0,0 +1,144 @@
// Github: https://github.com/shdwjk/Roll20API/blob/master/Base64/Base64.js
// By: The Aaron, Arcane Scriptomancer
// Contact: https://app.roll20.net/users/104025/the-aaron
// modified from: http://www.webtoolkit.info/
const Base64 = (() => { // eslint-disable-line no-unused-vars
const version = '0.3.2';
const lastUpdate = 1576507905;
const keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
const checkInstall = () => {
log('-=> Base64 v'+version+' <=- ['+(new Date(lastUpdate*1000))+']');
};
// private method for UTF-8 encoding
const utf8_encode = (string) => {
let utftext = '';
for (let n = 0; n < string.length; n++) {
let c1 = string.charCodeAt(n);
if (c1 < 128) {
utftext += String.fromCharCode(c1);
}
else if((c1 > 127) && (c1 < 2048)) {
utftext += String.fromCharCode((c1 >> 6) | 192);
utftext += String.fromCharCode((c1 & 63) | 128);
}
else {
utftext += String.fromCharCode((c1 >> 12) | 224);
utftext += String.fromCharCode(((c1 >> 6) & 63) | 128);
utftext += String.fromCharCode((c1 & 63) | 128);
}
}
return utftext;
};
// private method for UTF-8 decoding
const utf8_decode = (utftext) => {
let string = '';
let i = 0;
while ( i < utftext.length ) {
let c1 = utftext.charCodeAt(i);
if (c1 < 128) {
string += String.fromCharCode(c1);
i++;
}
else if((c1 > 191) && (c1 < 224)) {
let c2 = utftext.charCodeAt(i+1);
string += String.fromCharCode(((c1 & 31) << 6) | (c2 & 63));
i += 2;
}
else {
let c2 = utftext.charCodeAt(i+1);
let c3 = utftext.charCodeAt(i+2);
string += String.fromCharCode(((c1 & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
i += 3;
}
}
return string;
};
const encode = (input) => {
let output = '';
let i = 0;
input = utf8_encode(input);
while (i < input.length) {
let chr1 = input.charCodeAt(i++);
let chr2 = input.charCodeAt(i++);
let chr3 = input.charCodeAt(i++);
let enc1 = chr1 >> 2;
let enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
let enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
let enc4 = chr3 & 63;
if (isNaN(chr2)) {
enc3 = enc4 = 64;
} else if (isNaN(chr3)) {
enc4 = 64;
}
output = output +
keyStr.charAt(enc1) + keyStr.charAt(enc2) +
keyStr.charAt(enc3) + keyStr.charAt(enc4);
}
return output;
};
// public method for decoding
const decode = (input) => {
let output = '';
let i = 0;
input = input.replace(/[^A-Za-z0-9+/=]/g, "");
while (i < input.length) {
let enc1 = keyStr.indexOf(input.charAt(i++));
let enc2 = keyStr.indexOf(input.charAt(i++));
let enc3 = keyStr.indexOf(input.charAt(i++));
let enc4 = keyStr.indexOf(input.charAt(i++));
let chr1 = (enc1 << 2) | (enc2 >> 4);
let chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
let chr3 = ((enc3 & 3) << 6) | enc4;
output = output + String.fromCharCode(chr1);
if (enc3 !== 64) {
output = output + String.fromCharCode(chr2);
}
if (enc4 !== 64) {
output = output + String.fromCharCode(chr3);
}
}
output = utf8_decode(output);
return output;
};
on("ready",()=>{
checkInstall();
});
return {
encode: encode,
decode: decode
};
})();

6
roll20/char_sheet.css

@ -120,7 +120,7 @@ div.sheet-currency-grid {
} }
div.sheet-spells-grid { div.sheet-spells-grid {
display: grid; display: grid;
grid-template-columns: 1fr 1fr 1fr 1fr 1fr 1fr 1fr;
grid-template-columns: 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr;
row-gap: 5px; row-gap: 5px;
column-gap: 10px; column-gap: 10px;
margin-bottom: 5px; margin-bottom: 5px;
@ -207,7 +207,7 @@ input.sheet-spells-input {
grid-column: 1 / span 2; grid-column: 1 / span 2;
} }
.sheet-grid-span-4-2 { .sheet-grid-span-4-2 {
grid-column: 4 / span 2;
grid-column: 4 / span 3;
} }
input.sheet-input-big { input.sheet-input-big {
width: 55px!important; width: 55px!important;
@ -250,7 +250,7 @@ input.sheet-input-big {
} }
.sheet-spells-title { .sheet-spells-title {
text-align: center; text-align: center;
grid-column: 1 / span 7;
grid-column: 1 / span 9;
} }
.sheet-exp-title { .sheet-exp-title {
text-align: center; text-align: center;

35
roll20/char_sheet.html

@ -284,7 +284,7 @@
<div class="sheet-spells-title"> <div class="sheet-spells-title">
<h3>Spells Per Day</h3> <h3>Spells Per Day</h3>
</div> </div>
<span></span><span>One</span><span>Two</span><span>Three</span><span>Four</span><span>Five</span><span>Six</span>
<span></span><span>One</span><span>Two</span><span>Three</span><span>Four</span><span>Five</span><span>Six</span><span></span><span></span>
<span>Used</span> <span>Used</span>
<input class="spells-input" type="text" name="attr_spells_l1"> <input class="spells-input" type="text" name="attr_spells_l1">
<input class="spells-input" type="text" name="attr_spells_l2"> <input class="spells-input" type="text" name="attr_spells_l2">
@ -292,6 +292,7 @@
<input class="spells-input" type="text" name="attr_spells_l4"> <input class="spells-input" type="text" name="attr_spells_l4">
<input class="spells-input" type="text" name="attr_spells_l5"> <input class="spells-input" type="text" name="attr_spells_l5">
<input class="spells-input" type="text" name="attr_spells_l6"> <input class="spells-input" type="text" name="attr_spells_l6">
<span></span><span></span>
<span>Total</span> <span>Total</span>
<input class="spells-input" type="text" name="attr_spells_l1_max"> <input class="spells-input" type="text" name="attr_spells_l1_max">
@ -300,32 +301,23 @@
<input class="spells-input" type="text" name="attr_spells_l4_max"> <input class="spells-input" type="text" name="attr_spells_l4_max">
<input class="spells-input" type="text" name="attr_spells_l5_max"> <input class="spells-input" type="text" name="attr_spells_l5_max">
<input class="spells-input" type="text" name="attr_spells_l6_max"> <input class="spells-input" type="text" name="attr_spells_l6_max">
<span></span><span></span>
</div> </div>
<div class="spells-grid"> <div class="spells-grid">
<div class="sheet-spells-title sheet-margin-top"> <div class="sheet-spells-title sheet-margin-top">
<h3>Spellbook</h3> <h3>Spellbook</h3>
</div> </div>
<span class="grid-span-1-2">Spell Name</span><span>Level</span><span class="grid-span-4-2">Effect</span><span>Damage</span><span></span><span></span><span></span>
<!-- DEBUG --
<br/>
<input class="sheet-name-input grid-span-1-2" type="text" name="attr_spell_name">
<div><input class="sheet-stat-input" type="text" name="attr_spell_level"></div>
<div class="grid-span-4-2">
<input class="sheet-stat-input" type="text" name="attr_spell_effect">
</div>
<div><input class="sheet-stat-input" type="text" name="attr_spell_damage"></div>
<div><button class="sheet-roll-button" type="roll" value="&{template:acks} {{name=@{spell_name}}} {{subheader=Level @{spell_level} Arcane Spell}} {{desc=@{spell_effect}}} {{damage=[[@{spell_damage}]]}}" name="roll_Spell"></button></div>
-- /DEBUG -->
<span class="grid-span-1-2">Spell Name</span><span>Level</span><span class="grid-span-4-2">Effect</span><span>Range</span><span>Roll</span><span></span><span></span><span></span><span></span>
</div> </div>
<fieldset class="repeating_spells"> <fieldset class="repeating_spells">
<div class="spells-grid"> <div class="spells-grid">
<input class="sheet-name-input grid-span-1-2" type="text" name="attr_spell_name"> <input class="sheet-name-input grid-span-1-2" type="text" name="attr_spell_name">
<div><input class="sheet-stat-input" type="text" name="attr_spell_level"></div> <div><input class="sheet-stat-input" type="text" name="attr_spell_level"></div>
<div class="grid-span-4-2">
<textarea class="sheet-stat-input sheet-txtarea" name="attr_spell_effect" ></textarea>
</div>
<div><input class="sheet-stat-input" type="text" name="attr_spell_damage"></div>
<div><button class="sheet-roll-button" type="roll" value="&{template:acks} {{name=@{spell_name}}} {{subheader=Level @{spell_level} Arcane Spell}} {{desc=@{spell_effect}}} {{damage=[[@{spell_damage}]]}}" name="roll_Spell"></button></div>
<div class="grid-span-4-2"><textarea class="sheet-stat-input sheet-txtarea" name="attr_spell_effect" ></textarea></div>
<div><input class="sheet-stat-input" type="text" name="attr_spell_range"></div>
<div><input class="sheet-stat-input" type="text" name="attr_spell_roll"></div>
<div><button class="sheet-roll-button" type="roll" value="&{template:acks} {{name=@{spell_name}}} {{subheader=Level @{spell_level} @{spell_school} Spell}} {{desc=@{spell_effect}}} {{roll=[[@{spell_roll}]]}} {{range=@{spell_range}}}" name="roll_Spell"></button></div>
<div class="sheet-hidden"><input type="text" name="attr_spell_school"></div>
</div> </div>
</fieldset> </fieldset>
</div> </div>
@ -452,13 +444,16 @@
<div class="sheet-acks-subheader sheet-acks-row">{{subheader}}</div> <div class="sheet-acks-subheader sheet-acks-row">{{subheader}}</div>
{{/subheader}} {{/subheader}}
{{#target}} {{#target}}
<div class="sheet-acks-row">Target <span class="sheet-acks-target-value">{{target}}+</span></div>
<div class="sheet-acks-row"><strong>Target</strong> <span class="sheet-acks-target-value">{{target}}+</span></div>
{{/target}} {{/target}}
{{#range}}
<div class="sheet-acks-row"><strong>Range</strong> <span class="sheet-acks-target-value">{{range}}</span></div>
{{/range}}
{{#roll}} {{#roll}}
<div class="sheet-acks-row">Roll {{roll}}</div>
<div class="sheet-acks-row"><strong>Roll</strong> {{roll}}</div>
{{/roll}} {{/roll}}
{{#damage}} {{#damage}}
<div class="sheet-acks-row">Damage {{damage}}</div>
<div class="sheet-acks-row"><strong>Damage</strong> {{damage}}</div>
{{/damage}} {{/damage}}
{{#desc}} {{#desc}}
<div class="sheet-acks-row sheet-acks-desc">{{desc}}</div> <div class="sheet-acks-row sheet-acks-desc">{{desc}}</div>

19
roll20/npc_party_import.js

@ -107,6 +107,25 @@ on("chat:message", function(msg) {
addAttr(sheet.id, melee_name + "_attack_name", c.melee.name, null); addAttr(sheet.id, melee_name + "_attack_name", c.melee.name, null);
addAttr(sheet.id, melee_name + "_attack_throw_mod", c.melee.throw_mod, null); addAttr(sheet.id, melee_name + "_attack_throw_mod", c.melee.throw_mod, null);
addAttr(sheet.id, melee_name + "_attack_dmg", c.melee.damage, null); addAttr(sheet.id, melee_name + "_attack_dmg", c.melee.damage, null);
if(c.spells) {
for(spell of c.spells) {
let spell_name = "repeating_spells_" + generateRowID();
addAttr(sheet.id, spell_name + "_spell_name", spell.name, null);
addAttr(sheet.id, spell_name + "_spell_effect", Base64.decode(spell.description), null);
addAttr(sheet.id, spell_name + "_spell_range", spell.range, null);
addAttr(sheet.id, spell_name + "_spell_roll", spell.roll || 0, null);
if(spell.is_arcane) {
addAttr(sheet.id, spell_name + "_spell_school", "Arcane", null);
addAttr(sheet.id, spell_name + "_spell_level", spell.arcane, null);
}
if(spell.is_divine) {
addAttr(sheet.id, spell_name + "_spell_school", "Divine", null);
addAttr(sheet.id, spell_name + "_spell_level", spell.divine, null);
}
}
}
} }
} }

Loading…
Cancel
Save