Skip to content

Commit

Permalink
move code
Browse files Browse the repository at this point in the history
  • Loading branch information
alaingilbert committed Aug 20, 2022
1 parent 0b66de7 commit 7368ece
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
15 changes: 15 additions & 0 deletions pkg/ogame/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"golang.org/x/text/transform"
"golang.org/x/text/unicode/norm"
"regexp"
"sort"
"strings"
"unicode"
)
Expand Down Expand Up @@ -63,6 +64,20 @@ func ParseCoord(str string) (coord Coordinate, err error) {
var namesChars = "ЁАБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюяёァイウオガキケコサザシスズソタダチッテデトドニノバパビフプヘマミムャヤラルレロンー偵列加反収器回型塔大太子察射導小履巡帶弾彈惡戦戰抗探撃收星機死残殖毀民洋滅漿炮爆發砲磁罩者能船艦衛諜護路車軌軽輕輸農送運道重間闘防陽際離雷電飛骸鬥魔"
var namesRgx = regexp.MustCompile("[^a-zA-Zα-ωΑ-Ω" + namesChars + "]+")

func unique(s string) string {
//s = strings.ToLower(s)
m := make(map[rune]struct{})
for _, c := range s {
m[c] = struct{}{}
}
arr := make([]string, 0)
for k := range m {
arr = append(arr, string(k))
}
sort.Slice(arr, func(i, j int) bool { return arr[i] < arr[j] })
return strings.Join(arr, "")
}

// DefenceName2ID ...
func DefenceName2ID(name string) ID {
t := transform.Chain(norm.NFD, runes.Remove(runes.In(unicode.Mn)), norm.NFC)
Expand Down
15 changes: 0 additions & 15 deletions pkg/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"io/ioutil"
"net/http"
"regexp"
"sort"
"strconv"
"strings"
)
Expand Down Expand Up @@ -114,20 +113,6 @@ func GetNbrShips(doc *goquery.Document, name string) int64 {
return ParseInt(m[1])
}

func unique(s string) string {
//s = strings.ToLower(s)
m := make(map[rune]struct{})
for _, c := range s {
m[c] = struct{}{}
}
arr := make([]string, 0)
for k := range m {
arr = append(arr, string(k))
}
sort.Slice(arr, func(i, j int) bool { return arr[i] < arr[j] })
return strings.Join(arr, "")
}

func ReadBody(resp *http.Response) (respContent []byte, err error) {
var reader io.ReadCloser
switch resp.Header.Get("Content-Encoding") {
Expand Down

0 comments on commit 7368ece

Please sign in to comment.