Browse Source

NPC spell generation, front end

master
Brandon Cornejo 5 years ago
parent
commit
b3c8ae7328
  1. 1
      acks/npc/commands.py
  2. 11
      acks/npc/models.py
  3. 3
      acks/npc/npc_party.py
  4. 2
      acks/npc/templates/generate_npc_party.html

1
acks/npc/commands.py

@ -55,6 +55,7 @@ def populate_npc_database():
spell.arcane = 0 spell.arcane = 0
if spell.divine == '': if spell.divine == '':
spell.divine = 0 spell.divine = 0
spell.description = spell.description.strip()
db.session.bulk_save_objects(spells) db.session.bulk_save_objects(spells)
db.session.commit() db.session.commit()

11
acks/npc/models.py

@ -1,3 +1,5 @@
import base64
from flask_sqlalchemy import SQLAlchemy from flask_sqlalchemy import SQLAlchemy
from ..models import db, BaseModel from ..models import db, BaseModel
@ -120,7 +122,7 @@ class Spell(BaseModel):
'is_divine': self.is_divine, 'is_divine': self.is_divine,
'arcane': self.arcane, 'arcane': self.arcane,
'is_arcane': self.is_arcane, 'is_arcane': self.is_arcane,
'description': self.description #.replace('"', '\\"').replace("'", "\\'")
'description': base64.b64encode(self.description.encode('ascii')).decode('ascii')
} }
return spell_dict return spell_dict
@ -283,6 +285,13 @@ class CharacterNPC(BaseModel):
} }
} }
if self.guild.is_divine_spellcaster or self.guild.is_arcane_spellcaster:
npc_dict['spells'] = []
spell_list = self.spell_list()
for level in spell_list:
for spell in spell_list[level]:
npc_dict['spells'].append(spell.roll20_format)
if self.ranged: if self.ranged:
npc_dict['ranged'] = { npc_dict['ranged'] = {
'name': self.ranged.name, 'name': self.ranged.name,

3
acks/npc/npc_party.py

@ -106,6 +106,9 @@ 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):

2
acks/npc/templates/generate_npc_party.html

@ -270,7 +270,7 @@ div.acks-npc-card {
// Fill in spell details // Fill in spell details
document.querySelector('#spell-modal-title').innerText = modal_spell.name; document.querySelector('#spell-modal-title').innerText = modal_spell.name;
document.querySelector('#spell-modal-desc').innerText = modal_spell.description;
document.querySelector('#spell-modal-desc').innerText = atob(modal_spell.description);
if(spell.range) { if(spell.range) {
document.querySelector('#spell-modal-range').innerText = modal_spell.range; document.querySelector('#spell-modal-range').innerText = modal_spell.range;

Loading…
Cancel
Save