test craft all

This commit is contained in:
shoopea 2020-02-10 18:18:20 +08:00
parent dcc358d823
commit 6d2602ba24

5
job.go
View File

@ -2063,6 +2063,7 @@ func jobCraftAll(j Job) {
totalRecipes = make(map[string]int64) totalRecipes = make(map[string]int64)
completeItems = make(map[string]float64) completeItems = make(map[string]float64)
// pre-fill maps with references and quantities
muxObjItem.RLock() muxObjItem.RLock()
for _, o := range objItems { for _, o := range objItems {
if o.ItemTypeID == cacheObjSubType[`item_other`] { if o.ItemTypeID == cacheObjSubType[`item_other`] {
@ -2081,6 +2082,7 @@ func jobCraftAll(j Job) {
} }
muxObjItem.RUnlock() muxObjItem.RUnlock()
// check what we have in store
for _, i := range p2.Vault { for _, i := range p2.Vault {
if item, ok := itemParts[i.ItemID64]; ok { if item, ok := itemParts[i.ItemID64]; ok {
totalParts[item] = i.Quantity totalParts[item] = i.Quantity
@ -2092,6 +2094,9 @@ func jobCraftAll(j Job) {
for k, i := range ratioItems { for k, i := range ratioItems {
recipes, _ := totalRecipes[k] recipes, _ := totalRecipes[k]
parts, _ := totalParts[k] parts, _ := totalParts[k]
if k == "a83" || k == "a84" {
log.Printf("jobCraftAll[%s] ratio : %d | parts : %d | recipes : %d", i, parts, recipes)
}
if (recipes > 0 && parts > (i-1)) || (parts >= i) { if (recipes > 0 && parts > (i-1)) || (parts >= i) {
completeItems[k] = float64(MinInt64(recipes*i, parts) / i) completeItems[k] = float64(MinInt64(recipes*i, parts) / i)
maxItems = MaxInt64(maxItems, int64(completeItems[k])) maxItems = MaxInt64(maxItems, int64(completeItems[k]))