From cb1189c623b1673da83ab74067ff11fe2523e188 Mon Sep 17 00:00:00 2001 From: stijnb1234 Date: Thu, 2 Sep 2021 17:09:29 +0200 Subject: [PATCH] Fixed some calculation / view issues. --- dist/js/calculator.js | 25 +++++++++++++++++-------- index.html | 28 ++++++++++++++-------------- 2 files changed, 31 insertions(+), 22 deletions(-) diff --git a/dist/js/calculator.js b/dist/js/calculator.js index 0c63cb3..5b4877b 100644 --- a/dist/js/calculator.js +++ b/dist/js/calculator.js @@ -33,26 +33,35 @@ function toJSON(item, models) { //Insert models json['overrides'] = []; + //Insert default model + json['overrides'][0] = { + 'predicate': { + 'damaged': 0, + 'damage': 0 + }, + 'model': 'item/' + item + }; + for (let i = 0; i < models.length; i++) { const model = models[i]; const damage = getMappedDamage(i+1, itemDamages[item]); - json['overrides'][i] = { + json['overrides'][i+1] = { 'predicate': { 'damaged': 0, - 'damage': damage, - 'model': 'item/' + model - } + 'damage': damage + }, + 'model': model }; } //Insert damaged model - json['overrides'][models.length] = { + json['overrides'][models.length+1] = { 'predicate': { 'damaged': 1, - 'damage': 0, - 'model': 'item/' + item - } + 'damage': 0 + }, + 'model': 'item/' + item }; return JSON.stringify(json, null, 2); diff --git a/index.html b/index.html index b2512d6..5d56e71 100644 --- a/index.html +++ b/index.html @@ -6,13 +6,12 @@ - - + + @@ -37,12 +36,12 @@
- - + @@ -67,7 +67,7 @@ + crossorigin="anonymous" referrerpolicy="no-referrer">