This commit is contained in:
shoopea 2020-06-28 11:24:57 +02:00
parent 2821e603e2
commit 061fcbdddd
4 changed files with 28 additions and 4 deletions

4
def.go
View File

@ -184,7 +184,9 @@ type ChatWarsItem struct {
Auction bool `json:"auction"`
Craftable bool `json:"craftable"`
Craft *ChatWarsItemCraft `json:"craft"`
Classes []ChatWarsClass
Quality string `json:"-"`
Modifiers string `json:"-"`
Classes []ChatWarsClass `json:"-"`
}
type ChatWarsItemCraft struct {

22
msg.go
View File

@ -289,6 +289,25 @@ func parseSubTypeMessageAuctionAnnounce(m *ChatWarsMessage, r *regexp.Regexp) (*
cwm.Cond = r.ReplaceAllString(m.Text, "${Cond}")
cwm.Mod = r.ReplaceAllString(m.Text, "${Mod}")
cwm.Quality = r.ReplaceAllString(m.Text, "${Quality}")
switch cwm.Quality {
case `Fine`:
cwm.Quality = `e`
case `High`:
cwm.Quality = `d`
case `Great`:
cwm.Quality = `c`
case `Excellent`:
cwm.Quality = `b`
case `Masterpiece`:
cwm.Quality = `a`
case `Epic Fine`:
cwm.Quality = `se`
case `Epic High`:
cwm.Quality = `sd`
default:
cwm.Quality = ``
}
cwm.SellerUserID64 = getObjUserID(r.ReplaceAllString(m.Text, "${SellerUser}"))
cwm.SellerGuildID64 = getObjGuildID(r.ReplaceAllString(m.Text, "${SellerGuild}"))
cwm.SellerCastleID64 = getObjCastleID(r.ReplaceAllString(m.Text, "${SellerCastle}"))
@ -327,6 +346,7 @@ func parseSubTypeMessageGStockAnyAck(m *ChatWarsMessage, r *regexp.Regexp) (*Cha
cwm := ChatWarsMessageGStock{}
stock := []ChatWarsItems{}
re := regexp.MustCompile(`\n([0-9a-z]+) (.*) x ([0-9]+)`)
rq := regexp.MustCompile(`[a-z][0-9]+(?P<Quality>[a-z]+)`)
for _, l := range re.FindAllStringSubmatch(r.ReplaceAllString(m.Text, "${Stock}"), -1) {
i := getObjItemID(l[1], l[2])
q, _ := strconv.ParseInt(l[3], 10, 64)
@ -336,7 +356,9 @@ func parseSubTypeMessageGStockAnyAck(m *ChatWarsMessage, r *regexp.Regexp) (*Cha
Name: l[2],
ItemID64: i,
Quantity: q,
Quality: rq.ReplaceAllString(l[1], "${Quality}"),
}
stock = append(stock, item)
}
}

4
sql.go
View File

@ -258,7 +258,7 @@ func initDB() {
,item_id BIGINT UNSIGNED
,cond VARCHAR(32)
,quality VARCHAR(32)
,modifiers VARCHAR(80)
,modifiers VARCHAR(400)
,seller_castle_id BIGINT UNSIGNED
,seller_guild_id BIGINT UNSIGNED
,seller_id BIGINT UNSIGNED
@ -275,7 +275,7 @@ func initDB() {
,FOREIGN KEY (buyer_guild_id) REFERENCES obj_guild(obj_id) ON DELETE CASCADE
,FOREIGN KEY (seller_castle_id) REFERENCES obj_castle(obj_id) ON DELETE CASCADE
,FOREIGN KEY (buyer_castle_id) REFERENCES obj_castle(obj_id) ON DELETE CASCADE
,KEY (lot_id)
,UNIQUE KEY (lot_id)
) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_bin;`)
failOnError(err, "initDB : create table obj_msg_auction_announce")
log.Println("initDB : obj_msg_auction_announce created ...")

View File

@ -263,7 +263,7 @@ func MQTGCmdWorker(id int, cmds <-chan TGCommand) {
if clt, ok := getLockedClient(c.FromUserID64, false); ok {
j, err := json.Marshal(c)
logOnError(err, "MQTGCmdWorker["+strconv.Itoa(id)+"] : Marshal(c)")
log.Printf("MQTGCmdWorker["+strconv.Itoa(id)+"] : new command.\n%s\n", string(j))
//log.Printf("MQTGCmdWorker["+strconv.Itoa(id)+"] : new command.\n%s\n", string(j))
for clt.MQ.Connection == nil || clt.MQ.Connection.IsClosed() {
clt.Active = false
log.Printf("MQTGCmdWorker : Resetting MQ connection for #%d.\n", c.FromUserID64)