test
This commit is contained in:
parent
5453570fca
commit
8838d459c3
17
obj.go
17
obj.go
@ -3,6 +3,7 @@ package main
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"sync"
|
||||
@ -599,19 +600,22 @@ func getObjItemID(c string, n string) int64 {
|
||||
|
||||
func silentGetObjItemID(code string, name string) int64 {
|
||||
if v, ok := cacheObjItem.Load(code); ok && len(code) > 0 {
|
||||
i := v.(ChatWarsItem)
|
||||
return i.ObjID64
|
||||
item := v.(ChatWarsItem)
|
||||
log.Printf("Matching item code %s with %s.\n", code, item.Code)
|
||||
return item.ObjID64
|
||||
}
|
||||
if v, ok := cacheObjItem.Load(name); ok && len(name) > 0 {
|
||||
i := v.(ChatWarsItem)
|
||||
return i.ObjID64
|
||||
item := v.(ChatWarsItem)
|
||||
log.Printf("Matching item name %s with %s.\n", name, item.Name)
|
||||
return item.ObjID64
|
||||
}
|
||||
if ok, _ := regexp.MatchString(`^((u|e)[0-9]+|(a|w)[0-9]+[a-e]{0,1})$`, code); ok || len(code) == 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}$`)
|
||||
basename := r.ReplaceAllString(name, "${BaseName}")
|
||||
if v, ok := cacheObjItem.Load(basename); ok && len(basename) > 0 {
|
||||
i := v.(ChatWarsItem)
|
||||
return i.ObjID64
|
||||
item := v.(ChatWarsItem)
|
||||
log.Printf("Matching item basename %s with %s.\n", basename, item.Name)
|
||||
return item.ObjID64
|
||||
}
|
||||
item := ChatWarsItem{
|
||||
ObjID64: 0,
|
||||
@ -633,6 +637,7 @@ func silentGetObjItemID(code string, name string) int64 {
|
||||
|
||||
})
|
||||
if item.ObjID64 != 0 {
|
||||
log.Printf("Matching item modified basename %s with %s.\n", basename, item.Name)
|
||||
return item.ObjID64
|
||||
} else {
|
||||
fmt.Printf("silentGetObjItemID : Modifier : `%s`\n", r.ReplaceAllString(name, "${Modifier}"))
|
||||
|
Loading…
Reference in New Issue
Block a user