test parsing alch

This commit is contained in:
shoopea 2020-02-29 17:21:27 +08:00
parent 5c81d83064
commit cceed5fe14
2 changed files with 40 additions and 4 deletions

35
msg.go
View File

@ -96,6 +96,30 @@ func parseSubTypeMessageStockAnyAck(m *ChatWarsMessage, r *regexp.Regexp) (*Chat
return &cwm, nil
}
func parseSubTypeMessageAlchStockAck(m *ChatWarsMessage, r *regexp.Regexp) (*ChatWarsMessageStockAnyAck, error) {
cwm := ChatWarsMessageStockAnyAck{}
items := []ChatWarsItems{}
re := regexp.MustCompile(`\n\/aa_([0-9]{2}) ([a-zA-Z ']+) x (?[0-9]+)`)
for _, l := range re.FindAllStringSubmatch(r.ReplaceAllString(m.Text, "${Stuff}"), -1) {
fmt.Printf("parseSubTypeMessageAlchStockAck : %+q\n", l)
i := getObjItemID(l[1], ``)
q, _ := strconv.ParseInt(l[3], 10, 64)
if i != 0 {
item := ChatWarsItems{
ItemID64: i,
Quantity: q,
}
items = append(items, item)
log.Printf("parseSubTypeMessageAlchStockAck : %d - %d\n", i, q)
}
}
cwm.Stock = items
cwm.Msg = m
return &cwm, nil
}
func parseSubTypeMessageGDepositReq(m *ChatWarsMessage, r *regexp.Regexp) (*ChatWarsMessageGDepositReq, error) {
cwm := ChatWarsMessageGDepositReq{}
@ -413,12 +437,19 @@ func parseSubTypeMessageMeAck(m *ChatWarsMessage, r *regexp.Regexp) (*ChatWarsMe
cwm.Level = i
i, err = strconv.ParseInt(r.ReplaceAllString(m.Text, "${ManaNow}"), 10, 64)
logOnError(err, "parseSubTypeMessageMeAck : ParseInt(ManaNow)")
if err != nil {
cwm.ManaNow = 0
} else {
cwm.ManaNow = i
}
i, err = strconv.ParseInt(r.ReplaceAllString(m.Text, "${ManaMax}"), 10, 64)
logOnError(err, "parseSubTypeMessageMeAck : ParseInt(ManaMax)")
if err != nil {
cwm.ManaMax = 0
} else {
cwm.ManaMax = i
}
/*
log.Printf("parseSubTypeMessageMeAck : Me report identified\n")
log.Printf("parseSubTypeMessageMeAck : Castle : %s\n", r.ReplaceAllString(m.Text, "${Castle}"))

View File

@ -554,6 +554,11 @@ func SQLIdentifyMsgWorker(id int, objIds <-chan int64) {
case cacheObjSubType[`msg_bot_peace_up`]:
case cacheObjSubType[`msg_bot_alch_all`]:
botAlchAll(m)
case cacheObjSubType[`msg_stock_alch_req`]:
case cacheObjSubType[`msg_stock_alch_ack`]:
_, err := parseSubTypeMessageAlchStockAck(m, rule.re)
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing cacheObjSubType[`msg_stock_alch_ack`]")
case cacheObjSubType[`msg_skill_too_low`]:
default:
//log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Unknwon message type in rule %d : %d (%d)\n%s\n", msgParsingRules[i].ID, msgParsingRules[i].MsgTypeID64, objId, m.Text)
}