This commit is contained in:
shoopea 2019-05-19 12:05:04 +08:00
parent 5ef14e6c05
commit bb522e9fcd
3 changed files with 55 additions and 77 deletions

62
def.go
View File

@ -159,34 +159,40 @@ const (
castleWolf = 7
objSubTypeMessageUnknown = 301
objSubTypeMessageWar = 302
objSubTypeMessageMiniWar = 303
objSubTypeMessageGuildWar = 304
objSubTypeMessageReport = 305
objSubTypeMessageGReport = 306
objSubTypeMessageQuest = 307
objSubTypeMessageDuelFight = 308
objSubTypeMessageHero = 309
objSubTypeMessageMe = 310
objSubTypeMessageInventory = 311
objSubTypeMessagePillageInc = 312
objSubTypeMessagePillageGo = 313
objSubTypeMessagePillageTimeout = 314
objSubTypeMessagePillageWin = 315
objSubTypeMessagePillageLoss = 316
objSubTypeMessageTributeInc = 317
objSubTypeMessageTributeAck = 318
objSubTypeMessageAuctionAnnounce = 319
objSubTypeMessageAuctionUpdReq = 320
objSubTypeMessageAuctionUpdAck = 321
objSubTypeMessageTimeAck = 322
objSubTypeMessageTimeReq = 323
objSubTypeMessageGo = 324
objSubTypeMessageGoQuest = 325
objSubTypeMessageGoArena = 326
objSubTypeMessageArena = 327
objSubTypeMessageTop = 328
objSubTypeMessageMenu = 329
objSubTypeMessageWar = 302 // from Chat Wars Reports (not done)
objSubTypeMessageMiniWar = 303 // from Chat Wars Mini Reports (done)
objSubTypeMessageGuildWar = 304 // from Chat Wars Reports (not done)
objSubTypeMessageReportReq = 305 // /report (done)
objSubTypeMessageReportAck = 306 // result from /report (not done)
objSubTypeMessageGReportReq = 307 // /g_report (done)
objSubTypeMessageGReportAck = 308 // result from /g_report (not done)
objSubTypeMessageQuestResult = 309 // result from going to quest (not done)
objSubTypeMessageDuelFight = 310 // result from going to duel fight (done)
objSubTypeMessageHeroReq = 311 // /hero (done)
objSubTypeMessageHeroAck = 312 // result from /hero (not done)
objSubTypeMessageMeReq = 313 // 🏅Me (done)
objSubTypeMessageMeAck = 314 // result from 🏅Me (not done)
objSubTypeMessageInventoryReq = 315 // /inv (done)
objSubTypeMessageInventoryAck = 316 // result from /inv (not done)
objSubTypeMessagePillageInc = 317 // random incoming pillage (done)
objSubTypeMessagePillageGo = 318 // ack from /go (done)
objSubTypeMessagePillageTimeout = 319 // ack from lack of /go (done)
objSubTypeMessagePillageWin = 320 // pillage successfully intercepted (done)
objSubTypeMessagePillageLoss = 321 // pillage not intercepted (done)
objSubTypeMessageTributeInc = 322 // request for a /pledge (not done)
objSubTypeMessageTributeAck = 323 // pledge accepted (not done)
objSubTypeMessageAuctionAnnounce = 324 // from Boris and Co, Ltd (done)
objSubTypeMessageAuctionUpdReq = 325 // /l_123456 msg (not done)
objSubTypeMessageAuctionUpdAck = 326 // result from /l_123456 (not done)
objSubTypeMessageTimeAck = 327 // result from /time (done)
objSubTypeMessageTimeReq = 328 // /time (done)
objSubTypeMessageGo = 329 // /go (done)
objSubTypeMessagePledge = 330 // /pledge (done)
objSubTypeMessageGoQuest = 331 // 🌲Forest or 🍄Swamp or ⛰Valley (not done)
objSubTypeMessageGoFastFight = 332 // ▶Fast fight (not done)
objSubTypeMessageGoArena = 333 // 📯Arena (not done)
objSubTypeMessageTop = 334
objSubTypeMessageMenu = 335
objSubTypeJobPillage = 601
objSubTypeJobTribute = 602
objSubTypeJobStatus = 603

49
sql.go
View File

@ -1304,55 +1304,6 @@ INSERT INTO obj_item (obj_id, intl_id, name, weight) VALUES
log.Println("initDB : Database set up")
}
func resetMsgParsingRules() {
_, err := db.Exec(`TRUNCATE TABLE msg_rules;`)
failOnError(err, "resetMsgParsingRules : truncate table msg_rules")
_, err = db.Exec(`INSERT INTO msg_rules (prio, msg_type_id, descn, rule)
VALUES (5000, ` + strconv.Itoa(objSubTypeMessageReport) + `, "Player war report", "^(?P<Castle>[🐉🦅🐺🦈🦌🥔🌑])(\\[(?P<Guild>[A-Z0-9]{1,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){0,1}(💰Gold: (?P<Gold>\\-{0,1}[0-9]+)\\n){0,1}(📦Stock: (?P<Stock>\\-{0,1}[0-9]+)){0,1}(\\n(?P<Stamina>(🔋Stamina restored))){0,1}(\\n(?P<Crit>(⚡Critical strike))){0,1}$")
,(5000, ` + strconv.Itoa(objSubTypeMessageAuctionAnnounce) + `, "Auction annouce", "^Lot #(?P<Lot>[0-9]+) : (?P<Item>.*)\\n(Quality: (?P<Quality>.*)\\n){0,1}(Condition: (?P<Cond>.*)\\n){0,1}Seller: (?P<Seller>.*)\\nCurrent price: (?P<Price>[0-9]+) pouch\\(es\\)\\nBuyer: (?P<Buyer>.*)\\nEnd At: (?P<End>.*)\\nStatus: (?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(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.$")
,(5000, ` + strconv.Itoa(objSubTypeMessagePillageWin) + `,"Pillage Win", "^You successfully defeated (\\[(?P<Guild>[A-Z0-9]{1,3})\\]){0,1}(?P<Attacker>.*). As he was crawling away, you picked up some of the gold he left behind. Received (?P<Gold>[0-9]+) gold and (?P<Exp>[0-9]+) exp.$")
,(5000, ` + strconv.Itoa(objSubTypeMessagePillageTimeout) + `,"Pillage Timeout", "^You\\'ve failed to protect the villagers. No more rewards for you.$")
,(5000, ` + strconv.Itoa(objSubTypeMessageDuelFight) + `, "Duel Fight result #2", "(?P<Life1>(\\-){0,1}[0-9]+).*(?P<Castle1>[🐉🦅🐺🦈🦌🥔🌑])(\\[(?P<Guild1>[A-Z0-9]{1,3})\\]){0,1}(?P<Duelist1>.*)\\n` +
`VS\\n` +
`(?P<Life2>(\\-){0,1}[0-9]+).*(?P<Castle2>[🐉🦅🐺🦈🦌🥔🌑])(\\[(?P<Guild2>[A-Z0-9]{1,3})\\]){0,1}(?P<Duelist2>.*)\\n` +
`(?s:.*)\\n` +
`(\\[(?P<WinGuild>[A-Z0-9]{1,3})\\]){0,1}(?P<WinDuelist>.*) from .*(?P<WinCastle>[🐉🦅🐺🦈🦌🥔🌑]).* Castle stands victorious over (\\[(?P<LossGuild>[A-Z0-9]{1,3})\\]){0,1}(?P<LossDuelist>.*) from .*(?P<LossCastle>[🐉🦅🐺🦈🦌🥔🌑]).* Castle, with blood slowly dripping from his (?P<Weapon>.*).\\n` +
`You received: (?P<Exp>[0-9]+) exp.\\n` +
`(?s:.*)$")
,(5000, ` + strconv.Itoa(objSubTypeMessageDuelFight) + `, "Duel Fight result #1", "(?P<Life1>(\\-){0,1}[0-9]+).*(?P<Castle1>[🐉🦅🐺🦈🦌🥔🌑])(\\[(?P<Guild1>[A-Z0-9]{1,3})\\]){0,1}(?P<Duelist1>.*)\\n` +
`VS\\n` +
`(?P<Life2>(\\-){0,1}[0-9]+).*(?P<Castle2>[🐉🦅🐺🦈🦌🥔🌑])(\\[(?P<Guild2>[A-Z0-9]{1,3})\\]){0,1}(?P<Duelist2>.*)\\n` +
`(?s:.*)\\n` +
`(\\[(?P<WinGuild>[A-Z0-9]{1,3})\\]){0,1}(?P<WinDuelist>.*) from .*(?P<WinCastle>[🐉🦅🐺🦈🦌🥔🌑]).* Castle was stronger than (\\[(?P<LossGuild>[A-Z0-9]{1,3})\\]){0,1}(?P<LossDuelist>.*) from .*(?P<LossCastle>[🐉🦅🐺🦈🦌🥔🌑]).* Castle.\\n` +
`You received: (?P<Exp>[0-9]+) exp.\\n` +
`(?s:.*)$")
;`)
failOnError(err, "resetMsgParsingRules : populate table msg_rules")
}
func putUnprocessedMsg(m ChatWarsMessage) (int64, error) {
tx, err := db.Begin()
logOnError(err, "putUnprocessedMsg : start transaction")

View File

@ -126,6 +126,27 @@ func SQLIdentifyMsgWorker(id int, objIds <-chan int64) {
case objSubTypeMessageGo:
err = setObjSubTypeId(objId, objSubTypeMessageGo)
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : setObjSubTypeId(Go)")
case objSubTypeMessageReportReq:
err = setObjSubTypeId(objId, objSubTypeMessageReportReq)
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : setObjSubTypeId(ReportReq)")
case objSubTypeMessageGReportReq:
err = setObjSubTypeId(objId, objSubTypeMessageGReportReq)
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : setObjSubTypeId(GReportReq)")
case objSubTypeMessageHeroReq:
err = setObjSubTypeId(objId, objSubTypeMessageHeroReq)
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : setObjSubTypeId(HeroReq)")
case objSubTypeMessageMeReq:
err = setObjSubTypeId(objId, objSubTypeMessageMeReq)
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : setObjSubTypeId(MeReq)")
case objSubTypeMessageInventoryReq:
err = setObjSubTypeId(objId, objSubTypeMessageInventoryReq)
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : setObjSubTypeId(InventoryReq)")
case objSubTypeMessageTimeReq:
err = setObjSubTypeId(objId, objSubTypeMessageTimeReq)
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : setObjSubTypeId(TimeReq)")
case objSubTypeMessagePledge:
err = setObjSubTypeId(objId, objSubTypeMessagePledge)
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : setObjSubTypeId(Pledge)")
case objSubTypeMessagePillageGo:
err = setObjSubTypeId(objId, objSubTypeMessagePillageGo)
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : setObjSubTypeId(PillageGo)")