diff --git a/def.go b/def.go index 8e31174..d6e4179 100644 --- a/def.go +++ b/def.go @@ -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 { diff --git a/msg.go b/msg.go index f576965..29fdfb0 100644 --- a/msg.go +++ b/msg.go @@ -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[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) } } diff --git a/sql.go b/sql.go index c06e7fb..de7b45c 100644 --- a/sql.go +++ b/sql.go @@ -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 ...") diff --git a/workers.go b/workers.go index f2bfdc6..b8a36d0 100644 --- a/workers.go +++ b/workers.go @@ -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)