diff --git a/app/characters.py b/app/characters.py
index 6802989..bb34bbc 100644
--- a/app/characters.py
+++ b/app/characters.py
@@ -9,6 +9,7 @@ from app import gm_level, log_audit
from app.luclient import translate_from_locale
import xmltodict
import xml.etree.ElementTree as ET
+import json
character_blueprint = Blueprint('characters', __name__)
@@ -78,7 +79,7 @@ def view(id):
character_json = xmltodict.parse(
CharacterXML.query.filter(
CharacterXML.id == id
- ).first().xml_data,
+ ).first().xml_data.replace("\"stt=", "\" stt="),
attr_prefix="attr_"
)
@@ -91,9 +92,10 @@ def view(id):
# stupid fix for jinja parsing
character_json["obj"]["inv"]["holdings"] = character_json["obj"]["inv"].pop("items")
# sort by items slot index
- for inv in character_json["obj"]["inv"]["holdings"]["in"]:
- if "i" in inv.keys() and type(inv["i"]) == list:
- inv["i"] = sorted(inv["i"], key=lambda i: int(i['attr_s']))
+ if type(character_json["obj"]["inv"]["holdings"]["in"]) == list:
+ for inv in character_json["obj"]["inv"]["holdings"]["in"]:
+ if "i" in inv.keys() and type(inv["i"]) == list:
+ inv["i"] = sorted(inv["i"], key=lambda i: int(i['attr_s']))
return render_template(
'character/view.html.j2',
@@ -119,7 +121,7 @@ def view_xml(id):
character_xml = CharacterXML.query.filter(
CharacterXML.id == id
- ).first().xml_data
+ ).first().xml_data.replace("\"stt=", "\" stt=")
response = make_response(character_xml)
response.headers.set('Content-Type', 'text/xml')
@@ -190,7 +192,7 @@ def rescue(id):
CharacterXML.id == id
).first()
- character_xml = ET.XML(character_data.xml_data)
+ character_xml = ET.XML(character_data.xml_data.replace("\"stt=", "\" stt="))
for zone in character_xml.findall('.//r'):
if int(zone.attrib["w"]) % 100 == 0:
form.save_world.choices.append(
diff --git a/app/luclient.py b/app/luclient.py
index 9872ed6..c5b9d65 100644
--- a/app/luclient.py
+++ b/app/luclient.py
@@ -281,6 +281,7 @@ def register_luclient_jinja_helpers(app):
@app.template_filter('parse_lzid')
def parse_lzid(lzid):
+ if not lzid: return [1000, 1000, 1000]
return[
(int(lzid) & ((1 << 16) - 1)),
((int(lzid) >> 16) & ((1 << 16) - 1)),
diff --git a/app/templates/partials/_charxml.html.j2 b/app/templates/partials/_charxml.html.j2
index 46b347e..20082df 100644
--- a/app/templates/partials/_charxml.html.j2
+++ b/app/templates/partials/_charxml.html.j2
@@ -63,9 +63,13 @@
Play time:
+ {% if character_json.obj.char.attr_time %}
{{ (character_json.obj.char.attr_time|int/60/60/24)|int }} Days
{{ (character_json.obj.char.attr_time|int/60/60)|int - ((character_json.obj.char.attr_time|int/60/60/24)|int) * 24}} Hours
{{ (character_json.obj.char.attr_time|int/60 - (character_json.obj.char.attr_time|int/60/60)|int*60)|int }} Minutes
+ {% else %}
+ None
+ {% endif %}
@@ -110,9 +114,15 @@
{# Inv ID 0 - Index: 0 #}
{% for item in character_json.obj.inv.holdings.in %}
{% if item.attr_t == "0" %}
- {% for inv_item in item.i %}
- {% include 'partials/charxml/_inv_grid.html.j2' %}
- {% endfor %}
+ {% if item.i is iterable and (item.i is not string and item.i is not mapping) %}
+ {% for inv_item in item.i %}
+ {% include 'partials/charxml/_inv_grid.html.j2' %}
+ {% endfor %}
+ {% else %}
+ {% with inv_item=item.i %}
+ {% include 'partials/charxml/_inv_grid.html.j2' %}
+ {% endwith %}
+ {% endif %}
{% endif %}
{% endfor %}
@@ -120,9 +130,15 @@
{# Inv ID 1 - Index: 1 #}
{% for item in character_json.obj.inv.holdings.in %}
{% if item.attr_t == "1" %}
- {% for inv_item in item.i %}
- {% include 'partials/charxml/_inv_grid.html.j2' %}
- {% endfor %}
+ {% if item.i is iterable and (item.i is not string and item.i is not mapping) %}
+ {% for inv_item in item.i %}
+ {% include 'partials/charxml/_inv_grid.html.j2' %}
+ {% endfor %}
+ {% else %}
+ {% with inv_item=item.i %}
+ {% include 'partials/charxml/_inv_grid.html.j2' %}
+ {% endwith %}
+ {% endif %}
{% endif %}
{% endfor %}
@@ -130,9 +146,15 @@
{# Inv ID 14 - Index: 10 #}
{% for item in character_json.obj.inv.holdings.in %}
{% if item.attr_t == "14" %}
- {% for inv_item in item.i %}
- {% include 'partials/charxml/_inv_grid.html.j2' %}
- {% endfor %}
+ {% if item.i is iterable and (item.i is not string and item.i is not mapping) %}
+ {% for inv_item in item.i %}
+ {% include 'partials/charxml/_inv_grid.html.j2' %}
+ {% endfor %}
+ {% else %}
+ {% with inv_item=item.i %}
+ {% include 'partials/charxml/_inv_grid.html.j2' %}
+ {% endwith %}
+ {% endif %}
{% endif %}
{% endfor %}
@@ -140,9 +162,15 @@
{# Inv ID 2 - Index: 2 #}
{% for item in character_json.obj.inv.holdings.in %}
{% if item.attr_t == "2" %}
- {% for inv_item in item.i %}
- {% include 'partials/charxml/_inv_grid.html.j2' %}
- {% endfor %}
+ {% if item.i is iterable and (item.i is not string and item.i is not mapping) %}
+ {% for inv_item in item.i %}
+ {% include 'partials/charxml/_inv_grid.html.j2' %}
+ {% endfor %}
+ {% else %}
+ {% with inv_item=item.i %}
+ {% include 'partials/charxml/_inv_grid.html.j2' %}
+ {% endwith %}
+ {% endif %}
{% endif %}
{% endfor %}
@@ -150,19 +178,31 @@
{# Inv ID 5 - Index: 6 #}
{% for item in character_json.obj.inv.holdings.in %}
{% if item.attr_t == "5" %}
- {% for inv_item in item.i %}
- {% include 'partials/charxml/_inv_grid.html.j2' %}
- {% endfor %}
+ {% if item.i is iterable and (item.i is not string and item.i is not mapping) %}
+ {% for inv_item in item.i %}
+ {% include 'partials/charxml/_inv_grid.html.j2' %}
+ {% endfor %}
+ {% else %}
+ {% with inv_item=item.i %}
+ {% include 'partials/charxml/_inv_grid.html.j2' %}
+ {% endwith %}
+ {% endif %}
{% endif %}
{% endfor %}
{# Inv ID 7 - Index: 8 #}
{% for item in character_json.obj.inv.holdings.in %}
- {% if item.attr_t == "7" %}
- {% for inv_item in item.i %}
- {% include 'partials/charxml/_inv_grid.html.j2' %}
- {% endfor %}
+ {% if item.attr_t == "1" %}
+ {% if item.i is iterable and (item.i is not string and item.i is not mapping) %}
+ {% for inv_item in item.i %}
+ {% include 'partials/charxml/_inv_grid.html.j2' %}
+ {% endfor %}
+ {% else %}
+ {% with inv_item=item.i %}
+ {% include 'partials/charxml/_inv_grid.html.j2' %}
+ {% endwith %}
+ {% endif %}
{% endif %}
{% endfor %}
@@ -187,10 +227,14 @@
- {% for zone in character_json.obj.char.zs.s %}
- {% include 'partials/charxml/_zone_stats.html.j2' %}
- {{ '
' if not loop.last else "" }}
- {% endfor %}
+ {% if character_json.obj.char.zs %}
+ {% for zone in character_json.obj.char.zs.s %}
+ {% include 'partials/charxml/_zone_stats.html.j2' %}
+ {{ '
' if not loop.last else "" }}
+ {% endfor %}
+ {% else %}
+ No Stats Yet
+ {% endif %}