test new messages

This commit is contained in:
shoopea 2019-10-10 17:15:58 +08:00
parent 1cb80243d8
commit 511ba82c7f
5 changed files with 58 additions and 135 deletions

18
def.go
View File

@ -237,20 +237,6 @@ type ChatWarsMessagePillageInc struct {
Castle string `json:"castle"`
}
type ChatWarsMessageMiniWar struct {
ObjID64 int64 `json:"obj_id"`
Report map[string]*ChatWarsMessageMiniWarCastle `json:"castle"`
Time time.Time `json:"time"`
}
type ChatWarsMessageMiniWarCastle struct {
Gardian string `json:"gardian"`
Result string `json:"result"`
Gold int64 `json:"gold"`
Stock int64 `json:"stock"`
Points int64 `json:"points"`
}
type ChatWarsMessageUnionWar struct {
}
@ -395,7 +381,7 @@ const (
objSubTypeGuild = 201
objSubTypeMessageUnknown = 301
objSubTypeMessageWar = 302 // from Chat Wars Reports (not done)
objSubTypeMessageMiniWar = 303 // from Chat Wars Mini Reports (done)
objSubTypeMessageMiniWar = 303 // FIXME DELETE
objSubTypeMessageGuildWar = 304 // from Chat Wars Reports (not done)
objSubTypeMessageReportReq = 305 // /report (done)
objSubTypeMessageReportAck = 306 // result from /report (done)
@ -484,6 +470,8 @@ const (
objSubTypeMessageOrderbookSearch = 389 // /t <something>
objSubTypeMessageQuestReq = 390 // quest
objSubTypeMessageQuestAck = 391 // forest/swamp/valley/arena
objSubTypeMessageBattle = 392 // wind is howling
objSubTypeMessageTopReq = 394
objSubTypeJobPillage = 601
objSubTypeJobTribute = 602
objSubTypeJobStatus = 603

30
msg.go
View File

@ -405,36 +405,6 @@ func parseSubTypeMessageDuelFight(m *ChatWarsMessage, r *regexp.Regexp) (*ChatWa
return &cwm, nil
}
func parseSubTypeMessageMiniWar(m *ChatWarsMessage, r *regexp.Regexp) (*ChatWarsMessageMiniWar, error) {
t, err := time.Parse("02/01/06 15:04", r.ReplaceAllString(m.Text, "${Time}"))
logOnError(err, "parseSubTypeMessageMiniWar : parsing time : "+r.ReplaceAllString(m.Text, "${Time}"))
cwm := ChatWarsMessageMiniWar{
Time: t,
Report: make(map[string]*ChatWarsMessageMiniWarCastle),
}
for i := 1; i <= 7; i++ {
loot := fmt.Sprintf("${Loot%d}", i)
gardian := fmt.Sprintf("${Gardian%d}", i)
result := fmt.Sprintf("${Result%d}", i)
gold := fmt.Sprintf("${Gold%d}", i)
stock := fmt.Sprintf("${Stock%d}", i)
rep := ChatWarsMessageMiniWarCastle{
Gardian: r.ReplaceAllString(m.Text, gardian),
Result: r.ReplaceAllString(m.Text, result),
}
rep.Gold, err = strconv.ParseInt(r.ReplaceAllString(m.Text, gold), 10, 64)
rep.Stock, err = strconv.ParseInt(r.ReplaceAllString(m.Text, stock), 10, 64)
cwm.Report[r.ReplaceAllString(m.Text, loot)] = &rep
}
for i := 1; i <= 7; i++ {
score := fmt.Sprintf("${Score%d}", i)
points := fmt.Sprintf("${Points%d}", i)
cwm.Report[r.ReplaceAllString(m.Text, score)].Points, err = strconv.ParseInt(r.ReplaceAllString(m.Text, points), 10, 64)
}
return &cwm, err
}
func parseSubTypeMessagePillageInc(m *ChatWarsMessage, r *regexp.Regexp) (*ChatWarsMessagePillageInc, error) {
cwm := ChatWarsMessagePillageInc{}
cwm.Attacker = r.ReplaceAllString(m.Text, "${Attacker}")

View File

@ -25,25 +25,7 @@ func resetMsgParsingRules() {
`End At: (?P<End>.*)\\n` +
`Status: (?P<Status>.*)(\\n)` +
`*(?s:.*)")
,(5000, ` + strconv.Itoa(objSubTypeMessageTimeAck) + `, "Time", "^In Chat Wars world now\\n(?P<Time>.*)\\n(?P<Hour>[0-9]{2}):(?P<Minute>[0-9]{2})\\n(?P<Day>[0-9]{2}) (?P<Month>.+) (?P<Year>[0-9]{4})\\n(?s:.*)$")` +
`,(5000, ` + strconv.Itoa(objSubTypeMessageMiniWar) + `, "Mini War", "^⛳Battle results:\\n` +
`(?P<Gardian1>🔱){0,1}.*(?P<Loot1>(Moonlight|Wolfpack|Deerhorn|Dragonscale|Sharkteeth|Potato|Highnest)):(?P<Result1>[^\\x{1F4B0}\\x{1F4E6}]*)((?P<Gold1>(\\-|\\+)[0-9]+)\\x{1F4B0}){0,1}[ ]*((?P<Stock1>(\\-|\\+)[0-9]+)\\x{1F4E6}){0,1}\\n` +
`(?P<Gardian2>🔱){0,1}.*(?P<Loot2>(Moonlight|Wolfpack|Deerhorn|Dragonscale|Sharkteeth|Potato|Highnest)):(?P<Result2>[^\\x{1F4B0}\\x{1F4E6}]*)((?P<Gold2>(\\-|\\+)[0-9]+)\\x{1F4B0}){0,1}[ ]*((?P<Stock2>(\\-|\\+)[0-9]+)\\x{1F4E6}){0,1}\\n` +
`(?P<Gardian3>🔱){0,1}.*(?P<Loot3>(Moonlight|Wolfpack|Deerhorn|Dragonscale|Sharkteeth|Potato|Highnest)):(?P<Result3>[^\\x{1F4B0}\\x{1F4E6}]*)((?P<Gold3>(\\-|\\+)[0-9]+)\\x{1F4B0}){0,1}[ ]*((?P<Stock3>(\\-|\\+)[0-9]+)\\x{1F4E6}){0,1}\\n` +
`(?P<Gardian4>🔱){0,1}.*(?P<Loot4>(Moonlight|Wolfpack|Deerhorn|Dragonscale|Sharkteeth|Potato|Highnest)):(?P<Result4>[^\\x{1F4B0}\\x{1F4E6}]*)((?P<Gold4>(\\-|\\+)[0-9]+)\\x{1F4B0}){0,1}[ ]*((?P<Stock4>(\\-|\\+)[0-9]+)\\x{1F4E6}){0,1}\\n` +
`(?P<Gardian5>🔱){0,1}.*(?P<Loot5>(Moonlight|Wolfpack|Deerhorn|Dragonscale|Sharkteeth|Potato|Highnest)):(?P<Result5>[^\\x{1F4B0}\\x{1F4E6}]*)((?P<Gold5>(\\-|\\+)[0-9]+)\\x{1F4B0}){0,1}[ ]*((?P<Stock5>(\\-|\\+)[0-9]+)\\x{1F4E6}){0,1}\\n` +
`(?P<Gardian6>🔱){0,1}.*(?P<Loot6>(Moonlight|Wolfpack|Deerhorn|Dragonscale|Sharkteeth|Potato|Highnest)):(?P<Result6>[^\\x{1F4B0}\\x{1F4E6}]*)((?P<Gold6>(\\-|\\+)[0-9]+)\\x{1F4B0}){0,1}[ ]*((?P<Stock6>(\\-|\\+)[0-9]+)\\x{1F4E6}){0,1}\\n` +
`(?P<Gardian7>🔱){0,1}.*(?P<Loot7>(Moonlight|Wolfpack|Deerhorn|Dragonscale|Sharkteeth|Potato|Highnest)):(?P<Result7>[^\\x{1F4B0}\\x{1F4E6}]*)((?P<Gold7>(\\-|\\+)[0-9]+)\\x{1F4B0}){0,1}[ ]*((?P<Stock7>(\\-|\\+)[0-9]+)\\x{1F4E6}){0,1}\\n` +
`\\n🏆Scores:\\n` +
`.*(?P<Score1>(Moonlight|Wolfpack|Deerhorn|Dragonscale|Sharkteeth|Potato|Highnest)): (?P<Points1>\\+([0-9]+|NaN))\\n` +
`.*(?P<Score2>(Moonlight|Wolfpack|Deerhorn|Dragonscale|Sharkteeth|Potato|Highnest)): (?P<Points2>\\+([0-9]+|NaN))\\n` +
`.*(?P<Score3>(Moonlight|Wolfpack|Deerhorn|Dragonscale|Sharkteeth|Potato|Highnest)): (?P<Points3>\\+([0-9]+|NaN))\\n` +
`.*(?P<Score4>(Moonlight|Wolfpack|Deerhorn|Dragonscale|Sharkteeth|Potato|Highnest)): (?P<Points4>\\+([0-9]+|NaN))\\n` +
`.*(?P<Score5>(Moonlight|Wolfpack|Deerhorn|Dragonscale|Sharkteeth|Potato|Highnest)): (?P<Points5>\\+([0-9]+|NaN))\\n` +
`.*(?P<Score6>(Moonlight|Wolfpack|Deerhorn|Dragonscale|Sharkteeth|Potato|Highnest)): (?P<Points6>\\+([0-9]+|NaN))\\n` +
`.*(?P<Score7>(Moonlight|Wolfpack|Deerhorn|Dragonscale|Sharkteeth|Potato|Highnest)): (?P<Points7>\\+([0-9]+|NaN))\\n` +
`(?s:.*)` +
`Battle (?P<Time>[0-9]{2}/[0-9]{2}/[0-9]{2} [0-9]{2}:[0-9]{2})$")
,(5000, ` + strconv.Itoa(objSubTypeMessageTimeAck) + `, "Time", "^In Chat Wars world now\\n(?P<Time>.*)\\n(?P<Hour>[0-9]{2}):(?P<Minute>[0-9]{2})\\n(?P<Day>[0-9]{2}) (?P<Month>.+) (?P<Year>[0-9]{4})\\n(?s:.*)$")
,(5000, ` + strconv.Itoa(objSubTypeMessagePillageInc) + `, "Pillage Inc", "^You were strolling around on your horse when you noticed (\\[(?P<Guild>[A-Z0-9]{1,3})\\]){0,1}(?P<Attacker>.*) of .{1}(?P<Castle>(Moonlight|Wolfpack|Deerhorn|Dragonscale|Sharkteeth|Potato|Highnest)) Castle trying to pillage a local village. To stop him click /go$")
,(5000, ` + strconv.Itoa(objSubTypeMessageGo) + `, "Go", "^/go$")
,(5000, ` + strconv.Itoa(objSubTypeMessagePillageGo) + `,"Pillage Go", "^You lift up your sword and charge at the violator.$")
@ -161,9 +143,13 @@ func resetMsgParsingRules() {
`🎒Bag: (?P<BagUsed>[0-9]+)\\/(?P<BagDispo>[0-9]+) \\/inv\\n\\n` +
`State:\\n(?P<State>.*)\\n\\n` +
`More: \\/hero(?s:.*)$")
,(5000, ` + strconv.Itoa(objSubTypeMessageBattle) + `, "Battle", "^The wind is howling in the meadows, castles are unusually quiet\\. Warriors are mending their wounds and repairing armor after a tiresome battle\\. All the establishments and castle gates are closed for the next couple of minutes\\. Await the battle report at @chtwrsReports$")
,(5000, ` + strconv.Itoa(objSubTypeMessageGoArena) + `, "Go Arena", "^📯Arena$")
,(5000, ` + strconv.Itoa(objSubTypeMessageGoQuestReq) + `, "Go Quest Req Forest", "^🌲Forest$")
,(5000, ` + strconv.Itoa(objSubTypeMessageGoQuestReq) + `, "Go Quest Req Swamp", "^🍄Swamp$")
,(5000, ` + strconv.Itoa(objSubTypeMessageGoQuestReq) + `, "Go Quest Req Valley", "^🏔Valley$")
,(5000, ` + strconv.Itoa(objSubTypeMessageGoQuestReq) + `, "Go Quest Req Valley", "^⛰Valley$")
,(5000, ` + strconv.Itoa(objSubTypeMessageGoQuestReq) + `, "Go Quest Req Village", "^🗡Foray$")
,(5000, ` + strconv.Itoa(objSubTypeMessageGoQuestReq) + `, "Go Quest Req Mirkwood", "^🍂Mirkwood$")
,(5000, ` + strconv.Itoa(objSubTypeMessageGoQuestReq) + `, "Go Quest Req Dead Marshes", "^.*Dead Marshes$")
,(5000, ` + strconv.Itoa(objSubTypeMessageGoQuestReq) + `, "Go Quest Req Devil's Valley", "^🌋Devil's Valley$")
@ -238,6 +224,7 @@ func resetMsgParsingRules() {
,(5000, ` + strconv.Itoa(objSubTypeMessageUnequipGearAck) + `, "Unequip Ack", "^Item unequipped: (?P<Item>.+)$")
,(5000, ` + strconv.Itoa(objSubTypeMessageNoStamina) + `, "Unequip Ack", "^Not enough stamina. Come back after you take a rest.\\n\\n` +
`To get more stamina, invite friends to the game via invite link. Press /promo to get it.$")
,(5000, ` + strconv.Itoa(objSubTypeMessageTopReq) + `, "Top Req", "^/top(?P<TopType>[0-9]+)$")
,(5000, ` + strconv.Itoa(objSubTypeMessageQuestResult) + `, "Quest result #01", "^On your way to the swamp, you saw a group of people shouting angrily at their supposed leader\\. The leader was in tears and explained that loyalty can be won again, even if the medals are lost. You left confused. But a few meters away you found a badge with almost unrecognizable letters: tl\\.\\. You sold it to a merchant\\.(?s:.*)$")
,(5000, ` + strconv.Itoa(objSubTypeMessageQuestResult) + `, "Quest result #02", "^You were taking a walk when you found two burning marks on the ground that disappeared after a few meters\\. Near them there was some kind of almanac with a lot of numbers written in it\\. It was a cold day so you used it to make a campfire to warm yourself and then went back to the castle\\.(?s:.*)$")
,(5000, ` + strconv.Itoa(objSubTypeMessageQuestResult) + `, "Quest result #03", "^Mrrrrgl mrrrgl mrrrrrrgl mrrrgl. Mrrrrrrrrrrrgl mrrrrgl mrrrrrrrgl mrrrrrrgl mrrrrrrrrl\\. Mrrrrrgl\\.(?s:.*)$")
@ -329,19 +316,40 @@ func resetMsgParsingRules() {
,(5000, ` + strconv.Itoa(objSubTypeMessageQuestResult) + `, "Quest result #89", "^You came across a man with an arrow in his knee\\. You helped him, and he taught you some ancient gibberish\\. The moment you said the last word, he was hit by sudden blast of wind and ended up impaled on a tree branch\\. Weird\\.(?s:.*)$")
,(5000, ` + strconv.Itoa(objSubTypeMessageQuestResult) + `, "Quest result #90", "^In the valley you encountered a sleeping dragon\\. Even the loudest thunder couldn't wake it up, so you robbed its cave\\.(?s:.*)$")
,(5000, ` + strconv.Itoa(objSubTypeMessageQuestResult) + `, "Quest result #91", "^At the edge of the known lands, there is an old cursed field, full of relics of ancient civilisations that destroyed each other\\. You love coming back there, to collect antique items\\. This time you found a strange dusky helmet\\. The engraving on it illustrated a worshipping of an old powder cult, which decorated the top of the helmet\\. The helmet seemed to have an occult meaning to it, but having lesser interest in those, you just sold it to historians\\.(?s:.*)$")
,(5000, ` + strconv.Itoa(objSubTypeMessageQuestResult) + `, "Quest result #91", "^At the edge of the known lands, there is an old cursed field, full of relics of ancient civilisations that destroyed each other\\. You love coming back there, to collect antique items\\. This time you found a strange dusky helmet\\. The engraving on it illustrated a worshipping of an old powder cult, which decorated the top of the helmet\\. The helmet seemed to have an occult meaning to it, but having lesser interest in those, you just sold it to historians\\.(?s:.*)$")
,(5000, ` + strconv.Itoa(objSubTypeMessageQuestResult) + `, "Quest result #91", "^It was a really nice and sunny day, so you sat under a tree and enjoyed the weather\\.\\.\\.$")
,(5000, ` + strconv.Itoa(objSubTypeMessageQuestResult) + `, "Quest result #92", "^Wandering around, you saw a little golden ball flying around. Quickly, you hopped on your broom and started chasing it\\. Just as you were about to catch the ball, you woke up, realising it was just a dream$")
,(5000, ` + strconv.Itoa(objSubTypeMessageQuestResult) + `, "Quest result #93", "^You fell asleep and in your dream there was a beautiful land where seven colourful armies were battling each other\\. “How is that different from real life and why is there a taste of mushrooms and berries in my mouth\\?” was your thought when you woke up\\.$")
,(5000, ` + strconv.Itoa(objSubTypeMessageQuestResult) + `, "Quest result #94", "^It was a cool and refreshing night, so you made a campfire out in the woods\\.$")
,(5000, ` + strconv.Itoa(objSubTypeMessageQuestResult) + `, "Quest result #95", "^In the forest you met a redhead woman. Now you know nothing. You returned home empty handed\\.$")
,(5000, ` + strconv.Itoa(objSubTypeMessageQuestResult) + `, "Quest result #96", "^You've stepped into a pile of dung\\. Now you stink\\. Nothing else happened\\.$")
,(5000, ` + strconv.Itoa(objSubTypeMessageQuestResult) + `, "Quest result #97", "^As you were about to head out for an adventure, you got a feeling you were forgetting something, so you wasted some time trying to remember what it was\\. Finally you gave up and stayed home\.$")
,(5000, ` + strconv.Itoa(objSubTypeMessageQuestReq) + `, "Quest Req", "^🗺Quests$")
,(5000, ` + strconv.Itoa(objSubTypeMessageQuestAck) + `, "Quest Ack #1", "^🌲Forest [0-9]min\\n` +
`Many things can happen in the forest\\.\\n\\n` +
`🍄Swamp [0-9]min\\n` +
`Who knows what is lurking in mud\\.\\n\\n` +
`🗡Foray 🔋🔋\\n` +
`Foray is a dangerous activity\\. Someone can notice you and may beat you up\\. But if you go unnoticed, you will acquire a lot of loot\\.$")
,(5000, ` + strconv.Itoa(objSubTypeMessageQuestAck) + `, "Quest Ack #1", "^🌲Forest [0-9]min\\n` +
`Many things can happen in the forest\\.\\n\\n` +
`🍄Swamp [0-9]min\\n` +
`Who knows what is lurking in mud\\.\\n\\n` +
`🗡Foray 🔋🔋\\n` +
`Foray is a dangerous activity\\. Someone can notice you and may beat you up\\. But if you go unnoticed, you will acquire a lot of loot\\.\\n\\n` +
`📯Arena (🔒){0,1}\\n` +
`Arena isn't a place for the weak\\. Here you fight against other players and if you stand victorious, you acquire precious experience\\.$")
,(5000, ` + strconv.Itoa(objSubTypeMessageQuestAck) + `, "Quest Ack #2", "^🌲Forest [0-9]min\\n` +
`Many things can happen in the forest\\.\\n\\n` +
`🍄Swamp [0-9]min\\n` +
`Who knows what is lurking in mud\\.\\n\\n` +
`🏔Mountain Valley [0-9]min\\n` +
`Watch out for landslides\\.\\n\\n` +
`🗡Foray 🔋🔋\\n` +
`Foray is a dangerous activity\\. Someone can notice you and may beat you up\\. But if you go unnoticed, you will acquire a lot of loot\\.\\n\\n` +
`📯Arena (🔒){0,1}\\n` +
`Arena isn't a place for the weak\\. Here you fight against other players and if you stand victorious, you acquire precious experience\\.$")
,(5000, ` + strconv.Itoa(objSubTypeMessageQuestAck) + `, "Quest Ack #1", "^🍂Mirkwood [0-9]min\\n` +
,(5000, ` + strconv.Itoa(objSubTypeMessageQuestAck) + `, "Quest Ack #3", "^🍂Mirkwood [0-9]min\\n` +
`A corrupted forest, inhabited by twisted creatures\.\\n\\n` +
`.*The Dead Marshes [0-9]min\\n` +
`The dead don't test\\.\\n\\n` +

89
sql.go
View File

@ -223,30 +223,6 @@ func initDB() {
failOnError(err, "initDB : create table obj_msg_auction_announce")
log.Println("initDB : obj_msg_auction_announce created ...")
_, err = db.Exec(`CREATE TABLE obj_msg_mini_war (
obj_id BIGINT UNSIGNED NOT NULL
,date DATETIME NOT NULL
,FOREIGN KEY (obj_id) REFERENCES obj(id) ON DELETE CASCADE
,UNIQUE KEY (date)
) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_bin;`)
failOnError(err, "initDB : create table obj_msg_mini_war")
log.Println("initDB : obj_msg_mini_war created ...")
_, err = db.Exec(`CREATE TABLE obj_msg_mini_war_castle (
obj_id BIGINT UNSIGNED NOT NULL
,castle_id BIGINT UNSIGNED NOT NULL
,gardian TINYINT NOT NULL
,result VARCHAR(8)
,gold INT NOT NULL
,stock INT NOT NULL
,points INT NOT NULL
,FOREIGN KEY (obj_id) REFERENCES obj(id) ON DELETE CASCADE
,FOREIGN KEY (castle_id) REFERENCES obj_castle(obj_id) ON DELETE CASCADE
,UNIQUE KEY (obj_id, castle_id)
) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_bin;`)
failOnError(err, "initDB : create table obj_msg_mini_war_castle")
log.Println("initDB : obj_msg_mini_war_castle created ...")
_, err = db.Exec(`CREATE TABLE obj_msg_duel_fight (
obj_id BIGINT UNSIGNED NOT NULL
,win_castle_id BIGINT UNSIGNED NOT NULL
@ -289,6 +265,32 @@ func initDB() {
failOnError(err, "initDB : create table obj_msg_auction_upd_ack")
log.Println("initDB : obj_msg_auction_upd_ack created ...")
_, err = db.Exec(`CREATE TABLE obj_msg_exp (
obj_id BIGINT UNSIGNED NOT NULL
,exp INT NOT NULL
,FOREIGN KEY (obj_id) REFERENCES obj(id) ON DELETE CASCADE
) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_bin;`)
failOnError(err, "initDB : create table obj_msg_exp")
log.Println("initDB : obj_msg_exp created ...")
_, err = db.Exec(`CREATE TABLE obj_msg_gold (
obj_id BIGINT UNSIGNED NOT NULL
,gold INT NOT NULL
,FOREIGN KEY (obj_id) REFERENCES obj(id) ON DELETE CASCADE
) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_bin;`)
failOnError(err, "initDB : create table obj_msg_gold")
log.Println("initDB : obj_msg_gold created ...")
_, err = db.Exec(`CREATE TABLE obj_msg_item (
obj_id BIGINT UNSIGNED NOT NULL
,item_id BIGINT UNSIGNED NOT NULL
,quantity INT NOT NULL
,FOREIGN KEY (obj_id) REFERENCES obj(id) ON DELETE CASCADE
,FOREIGN KEY (item_id) REFERENCES obj_item(obj_id) ON DELETE CASCADE
) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_bin;`)
failOnError(err, "initDB : create table obj_msg_gold")
log.Println("initDB : obj_msg_item created ...")
_, err = db.Exec(`CREATE TABLE msg_rules (
id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT
,prio SMALLINT NOT NULL
@ -456,7 +458,6 @@ func initDB() {
,(` + strconv.Itoa(objSubTypeGuild) + `, "guild", "Guild", ` + strconv.Itoa(objTypeGuild) + `)
,(` + strconv.Itoa(objSubTypeMessageUnknown) + `, "unknown", "Unknown", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageWar) + `, "war", "War report", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageMiniWar) + `, "mini_war", "Mini war reprot", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageGuildWar) + `, "guild_war", "Guilds war report", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageReportReq) + `, "report_req", "Player war report request", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageReportAck) + `, "report_ack", "Player war report ack", ` + strconv.Itoa(objTypeMessage) + `)
@ -661,44 +662,6 @@ func insertMsgAuctionAnnounce(m *ChatWarsMessageAuctionAnnounce) error {
return nil
}
func insertMsgMiniWar(m *ChatWarsMessageMiniWar) error {
objSubTypeId, err := getObjSubTypeId(m.ObjID64)
if err != nil {
return err
}
if objSubTypeId != objSubTypeMessageUnknown && objSubTypeId != objSubTypeMessageMiniWar {
return errors.New("Message type mismatch")
}
stmt1, err := db.Prepare(`INSERT INTO obj_msg_mini_war (obj_id, date)
VALUES (?, ?);`)
if err != nil {
return err
}
defer stmt1.Close()
_, err = stmt1.Exec(m.ObjID64, m.Time)
if err != nil {
return err
}
stmt2, err := db.Prepare(`INSERT INTO obj_msg_mini_war_castle (obj_id, castle_id, gardian, result, gold, stock, points)
VALUES (?, ?, ?, ?, ?, ?, ?);`)
if err != nil {
return err
}
defer stmt2.Close()
for c, r := range m.Report {
_, err = stmt2.Exec(m.ObjID64, getObjCastleID(c), r.Gardian, r.Result, r.Gold, r.Stock, r.Points)
if err != nil {
return err
}
}
return nil
}
func insertMsgPillageInc(m *ChatWarsMessagePillageInc) error {
objSubTypeId, err := getObjSubTypeId(m.ObjID64)
if err != nil {

View File

@ -377,12 +377,6 @@ func SQLIdentifyMsgWorker(id int, objIds <-chan int64) {
cwm, err := parseSubTypeMessageReportAck(m, rule.re)
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing objSubTypeMessageReportAck.")
cwm.ObjID64 = objId
case objSubTypeMessageMiniWar:
cwm, err := parseSubTypeMessageMiniWar(m, rule.re)
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing objSubTypeMessageMiniWar.")
cwm.ObjID64 = objId
err = insertMsgMiniWar(cwm)
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : insertMsgMiniWar")
case objSubTypeMessagePillageInc:
cwm, err := parseSubTypeMessagePillageInc(m, rule.re)
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing objSubTypeMessagePillageInc.")