This commit is contained in:
shoopea 2019-06-14 12:01:59 +08:00
parent 6a1e74bdc9
commit 8a4fba6ce8
3 changed files with 29 additions and 19 deletions

View File

@ -4,7 +4,7 @@ ChirpNestBot
- [ ] Adjust /time clock for auctions/... (delay between cw and real time ?)
- [ ] Update old auctions with client
- [ ] Convert config to json and insert sql structure in it
- [ ] add metrics
- [ ] Add metrics
- [ ] Eliminate cache map race conditions (all maps with read/write) and use redis ?
- [ ] Transform import/export to jobs, feed msg to identification channel instead of inserting directly
- [ ] Turn on/off queue consumption
@ -25,6 +25,6 @@ ChirpNestBot
- [x] Export/import all messages
- [x] Test HTML in message
- [x] Update auction from broadcast
Progression :
- Progression :
- 0 -> 4 : Forest + Foray ;
- 5 -> 10 : Forest + Foray + Arena ;

View File

@ -154,6 +154,8 @@ func main() {
MQTGCmdQueue = make(chan TGCommand, MQTGCmdQueueSize)
JobQueue = make(chan Job, JobQueueSize)
clientsQueue = make(map[int64]*MQClient)
clientsKeepAlive = make(map[int64]*MQKeepAlive)
clientsCW = new(sync.Map)
clientsKeepAlive = new(sync.Map)

42
obj.go
View File

@ -609,32 +609,40 @@ func silentGetObjItemID(code string, name string) int64 {
i := v.(ChatWarsItem)
return i.ObjID64
}
if ok, _ := regexp.MatchString(`(u|a|e)[0-9]+[a-z]{0,1}`, c); ok {
if ok, _ := regexp.MatchString(`^((u|e)[0-9]+|a[0-9]+[a-e]{0,1})$`, c); ok || len(c) == 0 {
r := regexp.MustCompile(`^((?P<Modifier>⚡\+[0-9]+) ){0,1}(?P<BaseName>.+?)( \+(?P<Atk>[0-9]+)⚔){0,1}( \+(?P<Def>[0-9]+)🛡){0,1}( \+(?P<Mana>[0-9]+)💧){0,1}$`)
n2 := r.ReplaceAllString(n, "${BaseName}")
if v, ok := cacheObjItem.Load(n2); ok {
i := v.(ChatWarsItem)
return i.ObjID64
}
fmt.Printf("silentGetObjItemID(unique) : Modifier : `%s`\n", r.ReplaceAllString(n, "${Modifier}"))
fmt.Printf("silentGetObjItemID(unique) : BaseName : `%s`\n", r.ReplaceAllString(n, "${BaseName}"))
fmt.Printf("silentGetObjItemID(unique) : Atk : `%s`\n", r.ReplaceAllString(n, "${Atk}"))
fmt.Printf("silentGetObjItemID(unique) : Def : `%s`\n", r.ReplaceAllString(n, "${Def}"))
fmt.Printf("silentGetObjItemID(unique) : Mana : `%s`\n", r.ReplaceAllString(n, "${Mana}"))
i := ChatWarsItem{}
cacheObjItem.Range(func(k, v interface{}) bool {
i = v.(ChatWarsItem)
if ok, _ := regexp.MatchString(`^(a|e)[0-9]+$`, i.Code); !ok { //only gear can be custom named
return true
}
s := regexp.QuoteMeta(i.Name)
m := fmt.Sprintf("^(%s.*|.*%s)$ ", s, s)
if ok, _ := regexp.MatchString(m, n2); ok {
return false
} else {
i = ChatWarsItem{
ObjID64: 0,
}
return true
}
}
if len(c) == 0 {
r := regexp.MustCompile(`^((?P<Modifier>⚡\+[0-9]+) ){0,1}(?P<BaseName>.+?)( \+(?P<Atk>[0-9]+)⚔){0,1}( \+(?P<Def>[0-9]+)🛡){0,1}( \+(?P<Mana>[0-9]+)💧){0,1}$`)
n2 := r.ReplaceAllString(n, "${BaseName}")
if v, ok := cacheObjItem.Load(n2); ok {
i := v.(ChatWarsItem)
})
if i.ObjID64 != 0 {
return i.ObjID64
} else {
fmt.Printf("silentGetObjItemID : Modifier : `%s`\n", r.ReplaceAllString(n, "${Modifier}"))
fmt.Printf("silentGetObjItemID : BaseName : `%s`\n", r.ReplaceAllString(n, "${BaseName}"))
fmt.Printf("silentGetObjItemID : Atk : `%s`\n", r.ReplaceAllString(n, "${Atk}"))
fmt.Printf("silentGetObjItemID : Def : `%s`\n", r.ReplaceAllString(n, "${Def}"))
fmt.Printf("silentGetObjItemID : Mana : `%s`\n", r.ReplaceAllString(n, "${Mana}"))
}
fmt.Printf("silentGetObjItemID(null) : Modifier : `%s`\n", r.ReplaceAllString(n, "${Modifier}"))
fmt.Printf("silentGetObjItemID(null) : BaseName : `%s`\n", r.ReplaceAllString(n, "${BaseName}"))
fmt.Printf("silentGetObjItemID(null) : Atk : `%s`\n", r.ReplaceAllString(n, "${Atk}"))
fmt.Printf("silentGetObjItemID(null) : Def : `%s`\n", r.ReplaceAllString(n, "${Def}"))
fmt.Printf("silentGetObjItemID(null) : Mana : `%s`\n", r.ReplaceAllString(n, "${Mana}"))
}
return 0