diff --git a/tbc/items.go b/tbc/items.go
index b52aaa5..4117257 100644
--- a/tbc/items.go
+++ b/tbc/items.go
@@ -433,8 +433,8 @@ func NewEquipmentSet(names ...string) Equipment {
for _, v := range names {
item, ok := ItemLookup[v]
if !ok {
- fmt.Printf("Unable to find item: '%s'", v)
- return e
+ fmt.Printf("Unable to find item: '%s'\n", v)
+ continue
}
if item.Slot == EquipFinger {
if e[EquipFinger1].Name == "" {
diff --git a/tbc/stats.go b/tbc/stats.go
index 6a1f70b..9046d16 100644
--- a/tbc/stats.go
+++ b/tbc/stats.go
@@ -57,20 +57,30 @@ func (st Stats) Clone() Stats {
return ns
}
-func (st Stats) Print() string {
+func (st Stats) Print(pretty bool) string {
output := "{ "
+ printed := false
for k, v := range st {
name := Stat(k).StatName()
if name == "none" {
continue
}
+ if printed {
+ printed = false
+ output += ","
+ if pretty {
+ output += "\n"
+ }
+ }
+ if pretty {
+ output += "\t"
+ }
if v < 50 {
- output += "\t\"" + name + "\": " + strconv.FormatFloat(v, 'f', 3, 64)
+ printed = true
+ output += "\"" + name + "\": " + strconv.FormatFloat(v, 'f', 3, 64)
} else {
- output += "\t\"" + name + "\": " + strconv.FormatFloat(v, 'f', 0, 64)
- }
- if k != len(st)-1 {
- output += ",\n"
+ printed = true
+ output += "\"" + name + "\": " + strconv.FormatFloat(v, 'f', 0, 64)
}
}
output += " }"
diff --git a/ui/index.html b/ui/index.html
index 25e6da9..519b2cb 100644
--- a/ui/index.html
+++ b/ui/index.html
@@ -190,6 +190,22 @@
TBC Elemental Shaman Simulator
+
+
+
+ Stat | Gear |
+ | | |
+ | | |
+ | | |
+ | | |
+ | | |
+ | | |
+ | | |
+ | | |
+ | | |
+
+
+
@@ -211,7 +227,7 @@ Standard Elemental Build
diff --git a/ui/lib.wasm b/ui/lib.wasm
index a057bbc..42146ca 100755
Binary files a/ui/lib.wasm and b/ui/lib.wasm differ
diff --git a/ui/main_wasm.go b/ui/main_wasm.go
index 81386f9..79b965b 100644
--- a/ui/main_wasm.go
+++ b/ui/main_wasm.go
@@ -48,7 +48,10 @@ func GearList(this js.Value, args []js.Value) interface{} {
// GearStats takes a gear list and returns their total stats.
// This could power a simple 'current stats of all gear' UI.
func GearStats(this js.Value, args []js.Value) interface{} {
- return getGear(args[0]).Stats().Print()
+ stats := getGear(args[0]).Stats()
+ stats[tbc.StatSpellCrit] += (stats[tbc.StatInt] / 80) / 100
+ stats[tbc.StatMana] += stats[tbc.StatInt] * 15
+ return stats.Print(false)
}
// getGear converts js string array to a list of equipment items.
@@ -136,13 +139,13 @@ func Simulate(this js.Value, args []js.Value) interface{} {
customHaste = args[5].Float()
}
gear := getGear(args[2])
- fmt.Printf("Gear Stats: %s", gear.Stats().Print())
+ fmt.Printf("Gear Stats: %s", gear.Stats().Print(true))
opt := parseOptions(args[3])
stats := opt.StatTotal(gear)
if customHaste != 0 {
stats[tbc.StatHaste] = customHaste
}
- fmt.Printf("Total Stats: %s", stats.Print())
+ fmt.Printf("Total Stats: %s", stats.Print(true))
simi := args[0].Int()
if simi == 1 {
diff --git a/ui/ui.css b/ui/ui.css
index f95c2f6..7ae5a4f 100644
--- a/ui/ui.css
+++ b/ui/ui.css
@@ -1,3 +1,14 @@
+#gearstats {
+ background-color: #404040;
+ height: 90%;
+ margin-left: auto;
+}
+#gearstats table {
+ width: 100%;
+}
+#gearstats table tr {
+ text-align: right;
+}
#calcdiv {
flex: 1;
}
@@ -29,6 +40,12 @@ h2, h3, h4, pre, input {
h4 {
font-size: 1em;
}
+#gear li:hover {
+ color: orange;
+}
+#gear li:active {
+ color: orange;
+}
.uk-tab {
color: #D0D0D0;
}
@@ -52,7 +69,7 @@ h4 {
}
.uk-button {
line-height: 1.1;
- width: 250px;
+ width: 90%;
height: 40px;
padding: 1px;
color: #D0D0D0;
diff --git a/ui/ui.js b/ui/ui.js
index efe2e1e..a15ef5c 100644
--- a/ui/ui.js
+++ b/ui/ui.js
@@ -321,15 +321,24 @@ function removeGear(ele) {
// updateGear will update the gear UI elements (to redraw when new gear is selected)
function updateGear(newGear) {
+ var gearlist = [];
slotToID.forEach(k => {
var item = newGear[k];
if (item != null && item.name != "") {
var button = document.getElementById(k).firstElementChild;
button.innerText = item.name;
+ gearlist.push(item.name);
}
});
currentGear = newGear;
+
+ var gearjson = gearstats(gearlist);
+ var gearParse = JSON.parse(gearjson);
+ for (const [key, value] of Object.entries(gearParse)) {
+ var lab = document.getElementById(key.toLowerCase());
+ lab.innerText = value;
+ }
}
// turns a search string into a list of lowercase terms and if there is punctuation or not.
@@ -456,7 +465,7 @@ function searchHandler(ele, event) {
} else {
le.classList.remove("lisearch");
}
- le.style.color = "#F0F0F0";
+ le.style.removeProperty("color")
} else {
le.style.color = "#888888";
le.classList.remove("lisearch");
@@ -469,8 +478,7 @@ function clearSearch(e) {
var numChild = e.parentElement.children[2].childElementCount;
for (var i = 0; i < numChild; i++) {
var le = e.parentElement.children[2].children[i];
- // le.style.display = "block";
- le.style.color = "#F0F0F0";
+ le.style.removeProperty("color")
le.classList.remove("lisearch");
}
}