This commit is contained in:
shoopea 2020-01-27 13:34:52 +08:00
parent 821a149cbc
commit 8e86ad3c6e

28
job.go
View File

@ -1814,7 +1814,6 @@ func jobCraftItem(j Job) {
totalMana = item.Craft.Mana * p.Quantity
for _, v := range item.Craft.Items {
log.Printf("jobCraftItem[%s] : %s - %d\n", item.Code, v.Code, v.Quantity)
requiredItems[v.Code] = v.Quantity * p.Quantity
missingItems[v.Code] = 0
craftItems[v.Code] = 0
@ -1852,33 +1851,36 @@ func jobCraftItem(j Job) {
}
log.Printf("jobCraftItem[%s] : Mana : %d\n", item.Code, totalMana)
for code, req := range requiredItems {
ava, _ := availableItems[code]
craft, _ := craftItems[code]
missing, _ := missingItems[code]
log.Printf("jobCraftItem[%s] : %s - Req : %d / Ava : %d / Craft : %d / Missing : %d\n", item.Code, code, req, ava, craft, missing)
}
/* we can finish the job */
out := fmt.Sprintf("Summary for <b>%s</b>\n", item.Names[0])
out = fmt.Sprintf("%s<code> Mana : %d</code>\n", out, totalMana)
out = fmt.Sprintf("%s<pre> Items :</pre>\n", out)
out := fmt.Sprintf("<code>Summary for %s\n", item.Names[0])
out = fmt.Sprintf("%s Mana : %d\n", out, totalMana)
out = fmt.Sprintf("%s Items :\n", out)
for k, v := range requiredItems {
obj, _ := getObjItem(getObjItemID(k, ``))
ava, _ := availableItems[k]
out = fmt.Sprintf("%s<code> [%s] %s : %d (%d)</code>\n", out, obj.Code, obj.Names[0], v, ava)
out = fmt.Sprintf("%s [%s] %s : %d (%d)\n", out, obj.Code, obj.Names[0], v, ava)
}
out = fmt.Sprintf("%s<pre> Missing :</pre>\n", out)
out = fmt.Sprintf("%s Missing :\n", out)
for k, v := range missingItems {
obj, _ := getObjItem(getObjItemID(k, ``))
out = fmt.Sprintf("%s<code> [%s] %s : %d</code>\n", out, obj.Code, obj.Names[0], v)
if v > 0 {
obj, _ := getObjItem(getObjItemID(k, ``))
out = fmt.Sprintf("%s [%s] %s : %d\n", out, obj.Code, obj.Names[0], v)
}
}
out = fmt.Sprintf("%s<pre> To craft :</pre>\n", out)
out = fmt.Sprintf("%s To craft :\n", out)
for k, v := range craftItems {
obj, _ := getObjItem(getObjItemID(k, ``))
out = fmt.Sprintf("%s<code> [%s] %s : %d</code>\n", out, obj.Code, obj.Names[0], v)
if v > 0 {
obj, _ := getObjItem(getObjItemID(k, ``))
out = fmt.Sprintf("%s [%s] %s : %d\n", out, obj.Code, obj.Names[0], v)
}
}
out = fmt.Sprintf("%s</code>", out)
c := TGCommand{
Type: commandReplyMsg,