test
This commit is contained in:
parent
f7ef018ae8
commit
0f8fddf555
38
msg.go
Normal file
38
msg.go
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"regexp"
|
||||||
|
"strconv"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
func parseSubTypeMessageMiniWar(m *ChatWarsMessage, r *regexp.Regexp) (*ChatWarsMessageMiniWar, err) {
|
||||||
|
t, err := time.Parse("02/01/06 15:04", r.ReplaceAllString(m.Text, "${Time}"))
|
||||||
|
logOnError(err, "parseSubTypeMessageMiniWar : parsing time : "+r.ReplaceAllString(m.Text, "${Time}"))
|
||||||
|
cwm := ChatWarsMessageMiniWar{
|
||||||
|
Time: t,
|
||||||
|
Report: make(map[string]*ChatWarsMessageMiniWarCastle),
|
||||||
|
}
|
||||||
|
for i := 1; i <= 7; i++ {
|
||||||
|
loot := fmt.Sprintf("${Loot%d}", i)
|
||||||
|
gardian := fmt.Sprintf("${Gardian%d}", i)
|
||||||
|
result := fmt.Sprintf("${Result%d}", i)
|
||||||
|
gold := fmt.Sprintf("${Gold%d}", i)
|
||||||
|
stock := fmt.Sprintf("${Stock%d}", i)
|
||||||
|
rep := ChatWarsMessageMiniWarCastle{
|
||||||
|
Gardian: r.ReplaceAllString(m.Text, gardian),
|
||||||
|
Result: r.ReplaceAllString(m.Text, result),
|
||||||
|
}
|
||||||
|
rep.Gold, err = strconv.ParseInt(r.ReplaceAllString(m.Text, gold), 10, 64)
|
||||||
|
rep.Stock, err = strconv.ParseInt(r.ReplaceAllString(m.Text, stock), 10, 64)
|
||||||
|
cwm.Report[r.ReplaceAllString(m.Text, loot)] = &rep
|
||||||
|
}
|
||||||
|
for i := 1; i <= 7; i++ {
|
||||||
|
score := fmt.Sprintf("${Score%d}", i)
|
||||||
|
points := fmt.Sprintf("${Points%d}", i)
|
||||||
|
cwm.Report[r.ReplaceAllString(m.Text, score)].Points, err = strconv.ParseInt(r.ReplaceAllString(m.Text, points), 10, 64)
|
||||||
|
}
|
||||||
|
|
||||||
|
return cwm, err
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user