-
Notifications
You must be signed in to change notification settings - Fork 224
/
facility.go
64 lines (51 loc) · 1.22 KB
/
facility.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package facility
import (
"encoding/json"
"fmt"
"io/ioutil"
"os"
"github.com/llr104/slgserver/log"
"go.uber.org/zap"
)
type conditions struct {
Type int `json:"type"`
Level int `json:"level"`
}
type facility struct {
Title string `json:"title"`
Des string `json:"des"`
Name string `json:"name"`
Type int8 `json:"type"`
Additions []int8 `json:"additions"`
Conditions []conditions `json:"conditions"`
Levels []fLevel `json:"levels"`
}
type NeedRes struct {
Decree int `json:"decree"`
Grain int `json:"grain"`
Wood int `json:"wood"`
Iron int `json:"iron"`
Stone int `json:"stone"`
Gold int `json:"gold"`
}
type fLevel struct {
Level int `json:"level"`
Values []int `json:"values"`
Need NeedRes `json:"need"`
Time int `json:"time"` //升级需要的时间
}
func NewFacility(jsonName string) *facility {
f := &facility{}
f.load(jsonName)
return f
}
func (this *facility) load(jsonName string) {
jdata, err := ioutil.ReadFile(jsonName)
if err != nil {
log.DefaultLog.Error("facility load file error",
zap.Error(err), zap.String("file", jsonName))
os.Exit(0)
}
json.Unmarshal(jdata, this)
fmt.Println(this)
}