test craft

This commit is contained in:
shoopea 2020-01-27 12:08:38 +08:00
parent 8a1d244d08
commit ca052bc10c
2 changed files with 15 additions and 11 deletions

17
def.go
View File

@ -416,14 +416,15 @@ type JobPayloadGWithdrawItem struct {
}
type JobPayloadGWithdraw struct {
MsgID64 int64 `json:"msg_id"`
ChatID64 int64 `json:"chat_id"`
UserID64 int64 `json:"user_id"`
Items []JobPayloadGWithdrawItem `json:"items"`
Status int64 `json:"status"`
CleanupMsg []ChatWarsMessage `json:"cleanup_msg"`
Validated bool `json:"validated"`
Inspecting string `json:"inspecting"`
MsgID64 int64 `json:"msg_id"`
ChatID64 int64 `json:"chat_id"`
UserID64 int64 `json:"user_id"`
VaultJobID64 int64 `json:"vault_job_id"`
Items []JobPayloadGWithdrawItem `json:"items"`
Status int64 `json:"status"`
CleanupMsg []ChatWarsMessage `json:"cleanup_msg"`
Validated bool `json:"validated"`
Inspecting string `json:"inspecting"`
}
type JobPayloadGDeposit struct {

9
job.go
View File

@ -1803,7 +1803,8 @@ func jobCraftItem(j Job) {
err = json.Unmarshal(b, &p2)
logOnError(err, "jobCraftItem : Unmarshal(p2)")
item = getObjItem(p.ObjItemID64)
item, err = getObjItem(p.ObjItemID64)
logOnError(err, "jobCraftItem : getObjItem")
availableItems = make(map[string]int64)
requiredItems = make(map[string]int64)
missingItems = make(map[string]int64)
@ -1828,7 +1829,8 @@ func jobCraftItem(j Job) {
missing, _ := missingItems[code]
if (ava + craft + missing) < req {
update = true
obj := getObjItem(getObjItemID(code, ``))
obj, err := getObjItem(getObjItemID(code, ``))
logOnError(err, "jobCraftItem : getObjItem")
if obj.Craft != nil {
craftItems[code] = req - ava
totalMana = (req - ava) * obj.Craft.Mana
@ -1844,11 +1846,12 @@ 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, v.Code, req, ava, craft, missing)
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 */