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 { type JobPayloadGWithdraw struct {
MsgID64 int64 `json:"msg_id"` MsgID64 int64 `json:"msg_id"`
ChatID64 int64 `json:"chat_id"` ChatID64 int64 `json:"chat_id"`
UserID64 int64 `json:"user_id"` UserID64 int64 `json:"user_id"`
Items []JobPayloadGWithdrawItem `json:"items"` VaultJobID64 int64 `json:"vault_job_id"`
Status int64 `json:"status"` Items []JobPayloadGWithdrawItem `json:"items"`
CleanupMsg []ChatWarsMessage `json:"cleanup_msg"` Status int64 `json:"status"`
Validated bool `json:"validated"` CleanupMsg []ChatWarsMessage `json:"cleanup_msg"`
Inspecting string `json:"inspecting"` Validated bool `json:"validated"`
Inspecting string `json:"inspecting"`
} }
type JobPayloadGDeposit struct { type JobPayloadGDeposit struct {

9
job.go
View File

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