mirror of
https://github.com/DarkflameUniverse/NexusDashboard.git
synced 2024-11-25 15:07:18 +00:00
fix single item in inventory displaying
fix parsing of initial char xml to have some sane output initial inventory does not show, but it should not crash
This commit is contained in:
parent
eb7a820b54
commit
b87481e803
@ -9,6 +9,7 @@ from app import gm_level, log_audit
|
|||||||
from app.luclient import translate_from_locale
|
from app.luclient import translate_from_locale
|
||||||
import xmltodict
|
import xmltodict
|
||||||
import xml.etree.ElementTree as ET
|
import xml.etree.ElementTree as ET
|
||||||
|
import json
|
||||||
|
|
||||||
|
|
||||||
character_blueprint = Blueprint('characters', __name__)
|
character_blueprint = Blueprint('characters', __name__)
|
||||||
@ -78,7 +79,7 @@ def view(id):
|
|||||||
character_json = xmltodict.parse(
|
character_json = xmltodict.parse(
|
||||||
CharacterXML.query.filter(
|
CharacterXML.query.filter(
|
||||||
CharacterXML.id == id
|
CharacterXML.id == id
|
||||||
).first().xml_data,
|
).first().xml_data.replace("\"stt=", "\" stt="),
|
||||||
attr_prefix="attr_"
|
attr_prefix="attr_"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -91,6 +92,7 @@ def view(id):
|
|||||||
# stupid fix for jinja parsing
|
# stupid fix for jinja parsing
|
||||||
character_json["obj"]["inv"]["holdings"] = character_json["obj"]["inv"].pop("items")
|
character_json["obj"]["inv"]["holdings"] = character_json["obj"]["inv"].pop("items")
|
||||||
# sort by items slot index
|
# sort by items slot index
|
||||||
|
if type(character_json["obj"]["inv"]["holdings"]["in"]) == list:
|
||||||
for inv in character_json["obj"]["inv"]["holdings"]["in"]:
|
for inv in character_json["obj"]["inv"]["holdings"]["in"]:
|
||||||
if "i" in inv.keys() and type(inv["i"]) == list:
|
if "i" in inv.keys() and type(inv["i"]) == list:
|
||||||
inv["i"] = sorted(inv["i"], key=lambda i: int(i['attr_s']))
|
inv["i"] = sorted(inv["i"], key=lambda i: int(i['attr_s']))
|
||||||
@ -119,7 +121,7 @@ def view_xml(id):
|
|||||||
|
|
||||||
character_xml = CharacterXML.query.filter(
|
character_xml = CharacterXML.query.filter(
|
||||||
CharacterXML.id == id
|
CharacterXML.id == id
|
||||||
).first().xml_data
|
).first().xml_data.replace("\"stt=", "\" stt=")
|
||||||
|
|
||||||
response = make_response(character_xml)
|
response = make_response(character_xml)
|
||||||
response.headers.set('Content-Type', 'text/xml')
|
response.headers.set('Content-Type', 'text/xml')
|
||||||
@ -190,7 +192,7 @@ def rescue(id):
|
|||||||
CharacterXML.id == id
|
CharacterXML.id == id
|
||||||
).first()
|
).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'):
|
for zone in character_xml.findall('.//r'):
|
||||||
if int(zone.attrib["w"]) % 100 == 0:
|
if int(zone.attrib["w"]) % 100 == 0:
|
||||||
form.save_world.choices.append(
|
form.save_world.choices.append(
|
||||||
|
@ -281,6 +281,7 @@ def register_luclient_jinja_helpers(app):
|
|||||||
|
|
||||||
@app.template_filter('parse_lzid')
|
@app.template_filter('parse_lzid')
|
||||||
def parse_lzid(lzid):
|
def parse_lzid(lzid):
|
||||||
|
if not lzid: return [1000, 1000, 1000]
|
||||||
return[
|
return[
|
||||||
(int(lzid) & ((1 << 16) - 1)),
|
(int(lzid) & ((1 << 16) - 1)),
|
||||||
((int(lzid) >> 16) & ((1 << 16) - 1)),
|
((int(lzid) >> 16) & ((1 << 16) - 1)),
|
||||||
|
@ -63,9 +63,13 @@
|
|||||||
Play time:
|
Play time:
|
||||||
</div>
|
</div>
|
||||||
<div class="col">
|
<div class="col">
|
||||||
|
{% 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/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/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
|
{{ (character_json.obj.char.attr_time|int/60 - (character_json.obj.char.attr_time|int/60/60)|int*60)|int }} Minutes
|
||||||
|
{% else %}
|
||||||
|
None
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<hr class="bg-primary"/>
|
<hr class="bg-primary"/>
|
||||||
@ -110,9 +114,15 @@
|
|||||||
{# Inv ID 0 - Index: 0 #}
|
{# Inv ID 0 - Index: 0 #}
|
||||||
{% for item in character_json.obj.inv.holdings.in %}
|
{% for item in character_json.obj.inv.holdings.in %}
|
||||||
{% if item.attr_t == "0" %}
|
{% if item.attr_t == "0" %}
|
||||||
|
{% if item.i is iterable and (item.i is not string and item.i is not mapping) %}
|
||||||
{% for inv_item in item.i %}
|
{% for inv_item in item.i %}
|
||||||
{% include 'partials/charxml/_inv_grid.html.j2' %}
|
{% include 'partials/charxml/_inv_grid.html.j2' %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
{% else %}
|
||||||
|
{% with inv_item=item.i %}
|
||||||
|
{% include 'partials/charxml/_inv_grid.html.j2' %}
|
||||||
|
{% endwith %}
|
||||||
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
@ -120,9 +130,15 @@
|
|||||||
{# Inv ID 1 - Index: 1 #}
|
{# Inv ID 1 - Index: 1 #}
|
||||||
{% for item in character_json.obj.inv.holdings.in %}
|
{% for item in character_json.obj.inv.holdings.in %}
|
||||||
{% if item.attr_t == "1" %}
|
{% 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 %}
|
{% for inv_item in item.i %}
|
||||||
{% include 'partials/charxml/_inv_grid.html.j2' %}
|
{% include 'partials/charxml/_inv_grid.html.j2' %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
{% else %}
|
||||||
|
{% with inv_item=item.i %}
|
||||||
|
{% include 'partials/charxml/_inv_grid.html.j2' %}
|
||||||
|
{% endwith %}
|
||||||
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
@ -130,9 +146,15 @@
|
|||||||
{# Inv ID 14 - Index: 10 #}
|
{# Inv ID 14 - Index: 10 #}
|
||||||
{% for item in character_json.obj.inv.holdings.in %}
|
{% for item in character_json.obj.inv.holdings.in %}
|
||||||
{% if item.attr_t == "14" %}
|
{% if item.attr_t == "14" %}
|
||||||
|
{% if item.i is iterable and (item.i is not string and item.i is not mapping) %}
|
||||||
{% for inv_item in item.i %}
|
{% for inv_item in item.i %}
|
||||||
{% include 'partials/charxml/_inv_grid.html.j2' %}
|
{% include 'partials/charxml/_inv_grid.html.j2' %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
{% else %}
|
||||||
|
{% with inv_item=item.i %}
|
||||||
|
{% include 'partials/charxml/_inv_grid.html.j2' %}
|
||||||
|
{% endwith %}
|
||||||
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
@ -140,9 +162,15 @@
|
|||||||
{# Inv ID 2 - Index: 2 #}
|
{# Inv ID 2 - Index: 2 #}
|
||||||
{% for item in character_json.obj.inv.holdings.in %}
|
{% for item in character_json.obj.inv.holdings.in %}
|
||||||
{% if item.attr_t == "2" %}
|
{% if item.attr_t == "2" %}
|
||||||
|
{% if item.i is iterable and (item.i is not string and item.i is not mapping) %}
|
||||||
{% for inv_item in item.i %}
|
{% for inv_item in item.i %}
|
||||||
{% include 'partials/charxml/_inv_grid.html.j2' %}
|
{% include 'partials/charxml/_inv_grid.html.j2' %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
{% else %}
|
||||||
|
{% with inv_item=item.i %}
|
||||||
|
{% include 'partials/charxml/_inv_grid.html.j2' %}
|
||||||
|
{% endwith %}
|
||||||
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
@ -150,19 +178,31 @@
|
|||||||
{# Inv ID 5 - Index: 6 #}
|
{# Inv ID 5 - Index: 6 #}
|
||||||
{% for item in character_json.obj.inv.holdings.in %}
|
{% for item in character_json.obj.inv.holdings.in %}
|
||||||
{% if item.attr_t == "5" %}
|
{% if item.attr_t == "5" %}
|
||||||
|
{% if item.i is iterable and (item.i is not string and item.i is not mapping) %}
|
||||||
{% for inv_item in item.i %}
|
{% for inv_item in item.i %}
|
||||||
{% include 'partials/charxml/_inv_grid.html.j2' %}
|
{% include 'partials/charxml/_inv_grid.html.j2' %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
{% else %}
|
||||||
|
{% with inv_item=item.i %}
|
||||||
|
{% include 'partials/charxml/_inv_grid.html.j2' %}
|
||||||
|
{% endwith %}
|
||||||
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
<div class="tab-pane fade" id="nav-behaviors" role="tabpanel" aria-labelledby="nav-behaviors-tab">
|
<div class="tab-pane fade" id="nav-behaviors" role="tabpanel" aria-labelledby="nav-behaviors-tab">
|
||||||
{# Inv ID 7 - Index: 8 #}
|
{# Inv ID 7 - Index: 8 #}
|
||||||
{% for item in character_json.obj.inv.holdings.in %}
|
{% for item in character_json.obj.inv.holdings.in %}
|
||||||
{% if item.attr_t == "7" %}
|
{% 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 %}
|
{% for inv_item in item.i %}
|
||||||
{% include 'partials/charxml/_inv_grid.html.j2' %}
|
{% include 'partials/charxml/_inv_grid.html.j2' %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
{% else %}
|
||||||
|
{% with inv_item=item.i %}
|
||||||
|
{% include 'partials/charxml/_inv_grid.html.j2' %}
|
||||||
|
{% endwith %}
|
||||||
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
@ -187,10 +227,14 @@
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
|
{% if character_json.obj.char.zs %}
|
||||||
{% for zone in character_json.obj.char.zs.s %}
|
{% for zone in character_json.obj.char.zs.s %}
|
||||||
{% include 'partials/charxml/_zone_stats.html.j2' %}
|
{% include 'partials/charxml/_zone_stats.html.j2' %}
|
||||||
{{ '<hr class="bg-primary"/>' if not loop.last else "" }}
|
{{ '<hr class="bg-primary"/>' if not loop.last else "" }}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
{% else %}
|
||||||
|
No Stats Yet
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
|
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
|
||||||
|
Loading…
Reference in New Issue
Block a user