This commit is contained in:
shoopea 2019-05-08 18:31:52 +08:00
parent 4ad2dea2de
commit 87b7a941da

View File

@ -79,23 +79,30 @@ func SQLIdentifyMsgWorker(id int, objIds <-chan int64) {
log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Message retrieved (%d)\n%s\n", objId, m.Text)
// War reports
// r := regexp.MustCompile(`^(?P<Castle>.)(?P<Guild>(\[[A-Z]{3}\]){0,1})(?P<User>([A-Za-z0-9 ]*)) ⚔:(?P<Attack>[0-9]+) .:(?P<Defense>[0-9]+) Lvl: (?P<Level>[0-9]+)\nYour result on the battlefield:\n.Exp: (?P<Exp>[0-9]+)\n.Gold: (?P<Gold>[0-9]+)\n.Stock: (?P<Stock>[0-9]+)\n(?s:.*)$`) // FIXME defense/exp/gold/stock characters !
r := regexp.MustCompile(`^(?P<Castle>[🐉🦅🐺🦈🦌🥔🌑])(?P<Guild>(\[[A-Z]{3}\]){0,1})(?P<User>([A-Za-z0-9 ]*)) ⚔:(?P<Attack>[0-9]+)(?P<AttackMod>\((-|\+)[0-9]+\)){0,1} 🛡:(?P<Defense>[0-9]+) Lvl: (?P<Level>[0-9]+)\nYour result on the battlefield:\n🔥Exp: (?P<Exp>[0-9]+)\n💰Gold: (?P<Gold>-{0,1}[0-9]+)\n📦Stock: (?P<Stock>-{0,1}[0-9]+)\n\n(?P<Stamina>(🔋Stamina restored)){0,1}(\n)*(?P<Crit>(⚡Critical strike)){0,1}(\n)*(?s:.*)$`)
if r.FindStringSubmatch(m.Text) != nil {
log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : War report identified (%d)\n", objId)
log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Castle : %s (%d)\n", r.ReplaceAllString(m.Text, "${Castle}"), objId)
log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Guild : %s (%d)\n", r.ReplaceAllString(m.Text, "${Guild}"), objId)
log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : User : %s (%d)\n", r.ReplaceAllString(m.Text, "${User}"), objId)
log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Attack : %s (%d)\n", r.ReplaceAllString(m.Text, "${Attack}"), objId)
log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : AttackMod : %s (%d)\n", r.ReplaceAllString(m.Text, "${AttackMod}"), objId)
log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Defense : %s (%d)\n", r.ReplaceAllString(m.Text, "${Defense}"), objId)
log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Level : %s (%d)\n", r.ReplaceAllString(m.Text, "${Level}"), objId)
log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Exp : %s (%d)\n", r.ReplaceAllString(m.Text, "${Exp}"), objId)
log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Gold : %s (%d)\n", r.ReplaceAllString(m.Text, "${Gold}"), objId)
log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Stock : %s (%d)\n", r.ReplaceAllString(m.Text, "${Stock}"), objId)
log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Stamina : %s (%d)\n", r.ReplaceAllString(m.Text, "${Stamina}"), objId)
log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Crit : %s (%d)\n", r.ReplaceAllString(m.Text, "${Crit}"), objId)
for i := 0; i < len(msgParsingRules) && msgParsingRules[i].re.FindStringSubmatch(m.Text) != nil; i++ {
}
if i == len(msgParsingRules) {
log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Can't find message type (%d)\n", objId)
} else {
log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Unknown message type (%d)\n", objId)
switch msgParsingRules[i].MsgTypeID {
case objSubTypeMessageReport:
log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : War report identified (%d)\n", objId)
log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Castle : %s (%d)\n", r.ReplaceAllString(m.Text, "${Castle}"), objId)
log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Guild : %s (%d)\n", r.ReplaceAllString(m.Text, "${Guild}"), objId)
log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : User : %s (%d)\n", r.ReplaceAllString(m.Text, "${User}"), objId)
log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Attack : %s (%d)\n", r.ReplaceAllString(m.Text, "${Attack}"), objId)
log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : AttackMod : %s (%d)\n", r.ReplaceAllString(m.Text, "${AttackMod}"), objId)
log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Defense : %s (%d)\n", r.ReplaceAllString(m.Text, "${Defense}"), objId)
log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Level : %s (%d)\n", r.ReplaceAllString(m.Text, "${Level}"), objId)
log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Exp : %s (%d)\n", r.ReplaceAllString(m.Text, "${Exp}"), objId)
log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Gold : %s (%d)\n", r.ReplaceAllString(m.Text, "${Gold}"), objId)
log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Stock : %s (%d)\n", r.ReplaceAllString(m.Text, "${Stock}"), objId)
log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Stamina : %s (%d)\n", r.ReplaceAllString(m.Text, "${Stamina}"), objId)
log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Crit : %s (%d)\n", r.ReplaceAllString(m.Text, "${Crit}"), objId)
default:
log.Printf("SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Unknwon message type in rule %d : %d (%d)\n", msgParsingRules[i].ID, msgParsingRules[i].MsgTypeID, objId)
}
}
}
}