This commit is contained in:
shoopea 2019-05-18 18:33:53 +08:00
parent b310196953
commit 278fb1cab6
4 changed files with 66 additions and 35 deletions

23
def.go
View File

@ -101,7 +101,7 @@ type Job struct {
}
type JobPayloadPillage struct {
Date time.Time `json:"date"`
ObjID64 int64 `json:"obj_id"`
}
type JobPayloadTribute struct {
@ -166,15 +166,17 @@ const (
objSubTypeMessageMe = 310
objSubTypeMessageInventory = 311
objSubTypeMessagePillageInc = 312
objSubTypeMessageTributeInc = 313
objSubTypeMessagePillageAck = 314
objSubTypeMessageTributeAck = 315
objSubTypeMessageAuctionAnnounce = 316
objSubTypeMessageAuctionUpdReq = 317
objSubTypeMessageAuctionUpdAck = 318
objSubTypeMessageTimeAck = 319
objSubTypeMessageTimeReq = 320
objSubTypeMessageGo = 321
objSubTypeMessagePillageGo = 313
objSubTypeMessagePillageWin = 314
objSubTypeMessagePillageLoss = 315
objSubTypeMessageTributeInc = 316
objSubTypeMessageTributeAck = 317
objSubTypeMessageAuctionAnnounce = 318
objSubTypeMessageAuctionUpdReq = 319
objSubTypeMessageAuctionUpdAck = 320
objSubTypeMessageTimeAck = 321
objSubTypeMessageTimeReq = 322
objSubTypeMessageGo = 323
objSubTypeJobPillage = 601
objSubTypeJobTribute = 602
objSubTypeJobStatus = 603
@ -190,6 +192,7 @@ const (
objSubTypeItemOther = 706
objJobStatusNew = 0
objJobStatusPillageGo = 1
objJonStatusPending = 10
objJobStatusDone = 20

20
job.go
View File

@ -93,6 +93,7 @@ func jobSetDone(j Job) {
}
func jobPillage(j Job) {
/*
var r JobPayloadPillage
err := setJobStart(j.ID64)
@ -101,8 +102,23 @@ func jobPillage(j Job) {
err = json.Unmarshal(j.Payload, &r)
logOnError(err, "jobPillage : Unmarshal payload")
err = setJobDone(j.ID64)
logOnError(err, "jobPillage : setJobDone")
ids := getSQLListID64(` select og.id
from obj og
,obj_msg omg
,obj op
,obj_msg omp
,obj_job oj
where omg.obj_id = og.id
and og.obj_sub_type_id = ` + strconv.Itoa(objSubTypeMessageGo) `
and omg.user_id = oj.user_id
and omg.sender_user_id = oj.user_id
and oj.obj_id = ` + strconv.Itoa(j.ID64) `
and omp.obj_id = op.id
and op.id = ` + strconv.Itoa(r.ObjID64) `
and omg.date between omp.date and addtime(omp.date, '0 0:3:0.000000');`
err = setJobStatus(j.ID64, objJobStatusPillageGo, time.Now().Add(5 * time.second))
logOnError(err, "jobPillage : setJobDone")
*/
return
}

6
sql.go
View File

@ -310,8 +310,10 @@ func initDB() {
,(` + strconv.Itoa(objSubTypeMessageMe) + `, "me", "Hero short summary", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageInventory) + `, "inv", "Inventory", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessagePillageInc) + `, "pillage_inc", "Pillage incoming", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessagePillageGo) + `, "pillage_go", "Pillage go", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessagePillageWin) + `, "pillage_win", "Pillage win", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessagePillageLoss) + `, "pillage_loss", "Pillage loss", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageTributeInc) + `, "tribute_inc", "Tribute incoming", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessagePillageAck) + `, "pillage_ack", "Pillage acknowledged", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageTributeAck) + `, "tribute_ack", "Tribute acknowledged", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageAuctionAnnounce) + `, "auction_announce", "Auction announce", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageAuctionUpdReq) + `, "auction_upd_req", "Auction update request", ` + strconv.Itoa(objTypeMessage) + `)
@ -1321,6 +1323,8 @@ func resetMsgParsingRules() {
`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.$`)
;`)
failOnError(err, "resetMsgParsingRules : populate table msg_rules")
}

View File

@ -108,12 +108,12 @@ func SQLIdentifyMsgWorker(id int, objIds <-chan int64) {
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : insertMsgPillageInc")
err = setObjSubTypeId(objId, objSubTypeMessagePillageInc)
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : setObjSubTypeId(PillageInc)")
if m.Date.Add(3 * time.Minute).After(time.Now()) {
// if m.Date.Add(3 * time.Minute).After(time.Now()) {
p := JobPayloadPillage{
Date: m.Date,
ObjID64: objId,
}
b, _ := json.Marshal(&p)
err = createJob(objSubTypeJobPillage, objJobPriority, m.UserID64, time.Now().Add(time.Duration(25+rand.Intn(35))*time.Second), b)
err = createJob(objSubTypeJobPillage, objJobPriority, m.UserID64, m.Date.Add(time.Duration(25+rand.Intn(35))*time.Second), b)
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : createJob(JobPillage)")
s := TGCommand{
Type: commandSendMsg,
@ -121,11 +121,19 @@ func SQLIdentifyMsgWorker(id int, objIds <-chan int64) {
ToUserID64: m.UserID64,
}
TGCmdQueue <- s
}
// }
case objSubTypeMessageGo:
err = setObjSubTypeId(objId, objSubTypeMessageGo)
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : setObjSubTypeId(Go)")
case objSubTypeMessagePillageGo:
err = setObjSubTypeId(objId, objSubTypeMessagePillageGo)
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : setObjSubTypeId(PillageGo)")
case objSubTypeMessagePillageWin:
err = setObjSubTypeId(objId, objSubTypeMessagePillageWin)
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : setObjSubTypeId(PillageWin)")
case objSubTypeMessagePillageLoss:
err = setObjSubTypeId(objId, objSubTypeMessagePillageLoss)
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : setObjSubTypeId(PillageLoss)")
case objSubTypeMessageAuctionAnnounce:
cwm := ChatWarsMessageAuctionAnnounce{
ObjID64: objId,