test items sorting

This commit is contained in:
shoopea 2020-12-09 14:14:45 +01:00
parent 9e41862a01
commit b1300b571b

15
job.go
View File

@ -2404,8 +2404,10 @@ func jobCraftAll(j Job) {
if p.ItemTypeID == cacheObjSubType[`item_part`] { if p.ItemTypeID == cacheObjSubType[`item_part`] {
ratioItems[o.Code] = i.Quantity ratioItems[o.Code] = i.Quantity
itemParts[p.ObjID64] = o.Code itemParts[p.ObjID64] = o.Code
totalParts[o.Code] = 0
} else if p.ItemTypeID == cacheObjSubType[`item_recipe`] { } else if p.ItemTypeID == cacheObjSubType[`item_recipe`] {
itemRecipes[p.ObjID64] = o.Code itemRecipes[p.ObjID64] = o.Code
totalRecipes[o.Code] = 0
} }
} }
} }
@ -2436,12 +2438,17 @@ func jobCraftAll(j Job) {
for maxItems > 0 { for maxItems > 0 {
out = fmt.Sprintf("%s%d Items :\n", out, maxItems) out = fmt.Sprintf("%s%d Items :\n", out, maxItems)
items := make([]string, 0)
for k, v := range completeItems { for k, v := range completeItems {
if maxItems == int64(v) { if maxItems == int64(v) {
o, _ := getObjItem(getSilentObjItemID(k, ``)) items = append(items, k)
out = fmt.Sprintf("%s %s - %s\n", out, k, o.Names[0])
} }
} }
sort.Strings(items)
for _, k := range items {
o, _ := getObjItem(getSilentObjItemID(k, ``))
out = fmt.Sprintf("%s %s - %s\n", out, k, o.Names[0])
}
maxItems -= 1 maxItems -= 1
} }
@ -2451,7 +2458,7 @@ func jobCraftAll(j Job) {
parts, _ := totalParts[k] parts, _ := totalParts[k]
if parts == ratioItems[k]-1 { if parts == ratioItems[k]-1 {
o, _ := getObjItem(getSilentObjItemID(k, ``)) o, _ := getObjItem(getSilentObjItemID(k, ``))
out = fmt.Sprintf("%s %s - %s\n", out, k, o.Names[0]) out = fmt.Sprintf("%s %s - %s [%d]\n", out, k, o.Names[0], totalRecipes[k])
} }
} }
} }
@ -2462,7 +2469,7 @@ func jobCraftAll(j Job) {
recipe, _ := totalRecipes[k] recipe, _ := totalRecipes[k]
if recipe == 0 { if recipe == 0 {
o, _ := getObjItem(getSilentObjItemID(k, ``)) o, _ := getObjItem(getSilentObjItemID(k, ``))
out = fmt.Sprintf("%s %s - %s\n", out, k, o.Names[0]) out = fmt.Sprintf("%s %s - %s [%d]\n", out, k, o.Names[0], totalParts[k])
} }
} }
} }