test alch sorting
This commit is contained in:
parent
e8d020b475
commit
74b37fc688
25
job.go
25
job.go
@ -2034,8 +2034,10 @@ func jobAlchAll(j Job) {
|
|||||||
p JobPayloadAlchAll
|
p JobPayloadAlchAll
|
||||||
maxManaItems map[int64]int64
|
maxManaItems map[int64]int64
|
||||||
maxResItems map[int64]int64
|
maxResItems map[int64]int64
|
||||||
itemInStock bool
|
itemsCode map[int64]string
|
||||||
|
itemInStock, itemInserted bool
|
||||||
eta, out string
|
eta, out string
|
||||||
|
list []int64
|
||||||
)
|
)
|
||||||
|
|
||||||
err := setJobStart(j.ID64)
|
err := setJobStart(j.ID64)
|
||||||
@ -2090,6 +2092,7 @@ func jobAlchAll(j Job) {
|
|||||||
if err == nil {
|
if err == nil {
|
||||||
maxManaItems = make(map[int64]int64)
|
maxManaItems = make(map[int64]int64)
|
||||||
maxResItems = make(map[int64]int64)
|
maxResItems = make(map[int64]int64)
|
||||||
|
itemsCode = make(map[int64]string)
|
||||||
|
|
||||||
// pre-fill maps with references and quantities
|
// pre-fill maps with references and quantities
|
||||||
muxObjItem.RLock()
|
muxObjItem.RLock()
|
||||||
@ -2099,6 +2102,7 @@ func jobAlchAll(j Job) {
|
|||||||
if rx.MatchString(o.Craft.Command) {
|
if rx.MatchString(o.Craft.Command) {
|
||||||
maxManaItems[o.ObjID64] = p.ManaMax / o.Craft.Mana
|
maxManaItems[o.ObjID64] = p.ManaMax / o.Craft.Mana
|
||||||
maxResItems[o.ObjID64] = maxManaItems[o.ObjID64]
|
maxResItems[o.ObjID64] = maxManaItems[o.ObjID64]
|
||||||
|
itemsCode[o.ObjID64] = o.Code
|
||||||
for _, i := range o.Craft.Items {
|
for _, i := range o.Craft.Items {
|
||||||
itemInStock = false
|
itemInStock = false
|
||||||
for _, s := range cwm.Stock {
|
for _, s := range cwm.Stock {
|
||||||
@ -2131,11 +2135,26 @@ func jobAlchAll(j Job) {
|
|||||||
} else {
|
} else {
|
||||||
eta = "0m"
|
eta = "0m"
|
||||||
}
|
}
|
||||||
|
list = make([]int64, 0)
|
||||||
for k, q := range maxManaItems {
|
for k, q := range maxManaItems {
|
||||||
if q == maxResItems[k] {
|
if q == maxResItems[k] {
|
||||||
o, _ := getObjItem(k)
|
itemInserted = false
|
||||||
out = fmt.Sprintf("%s\n<code>%s - %s - %d</code>", out, o.Code, o.Names[0], q)
|
for i, n := range list {
|
||||||
|
if itemsCode[n] > itemsCode[k] {
|
||||||
|
itemInserted = true
|
||||||
|
list = append(list, 0)
|
||||||
|
copy(list[i+1:], list[i:])
|
||||||
|
list[i] = k
|
||||||
}
|
}
|
||||||
|
if !itemInserted {
|
||||||
|
list = append(list, k)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for _, i := range list {
|
||||||
|
o, _ := getObjItem(i)
|
||||||
|
out = fmt.Sprintf("%s\n<code>%s - %s - %d</code>", out, o.Code, o.Names[0], maxManaItems[i])
|
||||||
}
|
}
|
||||||
|
|
||||||
c := TGCommand{
|
c := TGCommand{
|
||||||
|
Loading…
Reference in New Issue
Block a user