Commit 9cdf9ccefdd915fd6196a480b34f550c8cb8de7d

Authored by 陆恒
1 parent d7315860

提交读取签到配置

Showing 1 changed file with 67 additions and 41 deletions   Show diff stats
src/HttpServer/jsonconf/jsonconf.go
... ... @@ -12,62 +12,78 @@ var (
12 12 )
13 13  
14 14 type AchieveDesc struct {
15   - Id int `json:"id"`
16   - Task string `json:"task"`
17   - Num int `json:"num"`
18   - Reward []int `json:"reward"`
19   - TaskType int `json:"type"`
  15 + Id int `json:"id"`
  16 + Task string `json:"task"`
  17 + Num int `json:"num"`
  18 + Reward []int `json:"reward"`
  19 + TaskType int `json:"type"`
20 20 }
21 21  
22 22 type LevelDesc struct {
23   - Id int `json:"id"`
24   - Level int `json:"level"`
25   - Exp int `json:"exp"`
26   - Cash int `json:"cash"`
27   - Extracash int `json:"extracash"`
  23 + Id int `json:"id"`
  24 + Level int `json:"level"`
  25 + Exp int `json:"exp"`
  26 + Cash int `json:"cash"`
  27 + Extracash int `json:"extracash"`
28 28 }
29 29  
30 30 type MoneyBoxLevelDesc struct {
31   - Id int `json:"id"`
32   - Level int `json:"level"`
33   - Min int `json:"min"`
34   - Max int `json:"max"`
  31 + Id int `json:"id"`
  32 + Level int `json:"level"`
  33 + Min int `json:"min"`
  34 + Max int `json:"max"`
35 35 }
36 36  
37 37 type MoneyBoxTimesDesc struct {
38   - Id int `json:"id"`
39   - Times int `json:"times"`
40   - Login int `json:"login"`
41   - Score int `json:"score"`
  38 + Id int `json:"id"`
  39 + Times int `json:"times"`
  40 + Login int `json:"login"`
  41 + Score int `json:"score"`
42 42 }
43 43  
44 44 type WithDrawDesc struct {
45   - Id int `json:"id"`
46   - Money float32 `json:"money"`
47   - Coin int `json:"coin"`
48   - Task int `json:"task"`
49   - Level int `json:"level"`
50   - Isnew int `json:"new"`
  45 + Id int `json:"id"`
  46 + Money float32 `json:"money"`
  47 + Coin int `json:"coin"`
  48 + Task int `json:"task"`
  49 + Level int `json:"level"`
  50 + Isnew int `json:"new"`
  51 +}
  52 +
  53 +type SignRewardDetail struct {
  54 + Id int `json:"id"`
  55 + Num int `json:"num"`
  56 +}
  57 +
  58 +type SignReward struct {
  59 + Reward1 []SignRewardDetail
  60 + Reward2 []SignRewardDetail
  61 +}
  62 +
  63 +type SignConfigDesc struct {
  64 + Rule int `json:"rule"`
  65 + Round int `json:"round"`
  66 + Reward SignReward `json:"reward"`
51 67 }
52 68  
53 69 type GameConfig struct {
54   - AchieventConfig []AchieveDesc
55   - TaskConfig []AchieveDesc
56   - LevelConfig []LevelDesc
57   - MoneyBoxConfig []MoneyBoxLevelDesc
  70 + AchieventConfig []AchieveDesc
  71 + TaskConfig []AchieveDesc
  72 + LevelConfig []LevelDesc
  73 + MoneyBoxConfig []MoneyBoxLevelDesc
58 74 MoneyBoxTimeConfig []MoneyBoxTimesDesc
59   - WithDrawConfig []WithDrawDesc
  75 + WithDrawConfig []WithDrawDesc
  76 + SignConfig SignConfigDesc
60 77 }
61 78  
62 79 func GetJsonConf() *GameConfig {
63 80 return g_jsonconf
64 81 }
65 82  
66   -
67 83 func GetMoneyBoxCfg(lv int) *MoneyBoxLevelDesc {
68 84 rt := new(MoneyBoxLevelDesc)
69 85 rt = nil
70   - for _,val := range g_jsonconf.MoneyBoxConfig {
  86 + for _, val := range g_jsonconf.MoneyBoxConfig {
71 87 if val.Level == lv {
72 88 rt = &val
73 89 break
... ... @@ -98,7 +114,7 @@ func LoadJsonConf() error {
98 114 err = json.Unmarshal([]byte(content), &g_jsonconf.AchieventConfig)
99 115 if err != nil {
100 116 logger.Info("loadJsonConf failed1,err=%v", err)
101   - return err
  117 + return err
102 118 }
103 119  
104 120 path = "../jsonconf/DailyTask.json"
... ... @@ -111,7 +127,7 @@ func LoadJsonConf() error {
111 127 err = json.Unmarshal([]byte(content), &g_jsonconf.TaskConfig)
112 128 if err != nil {
113 129 logger.Info("loadJsonConf failed1,err=%v", err)
114   - return err
  130 + return err
115 131 }
116 132  
117 133 path = "../jsonconf/LevelConfig.json"
... ... @@ -124,7 +140,7 @@ func LoadJsonConf() error {
124 140 err = json.Unmarshal([]byte(content), &g_jsonconf.LevelConfig)
125 141 if err != nil {
126 142 logger.Info("loadJsonConf failed1,err=%v", err)
127   - return err
  143 + return err
128 144 }
129 145  
130 146 path = "../jsonconf/MoneyboxLevel.json"
... ... @@ -137,10 +153,9 @@ func LoadJsonConf() error {
137 153 err = json.Unmarshal([]byte(content), &g_jsonconf.MoneyBoxConfig)
138 154 if err != nil {
139 155 logger.Info("loadJsonConf failed1,err=%v", err)
140   - return err
  156 + return err
141 157 }
142 158  
143   -
144 159 path = "../jsonconf/MoneyboxTimes.json"
145 160 content, err = file_get_contents(path)
146 161 if err != nil {
... ... @@ -151,10 +166,9 @@ func LoadJsonConf() error {
151 166 err = json.Unmarshal([]byte(content), &g_jsonconf.MoneyBoxTimeConfig)
152 167 if err != nil {
153 168 logger.Info("loadJsonConf failed1,err=%v", err)
154   - return err
  169 + return err
155 170 }
156 171  
157   -
158 172 path = "../jsonconf/WithdrawConfig.json"
159 173 content, err = file_get_contents(path)
160 174 if err != nil {
... ... @@ -165,10 +179,22 @@ func LoadJsonConf() error {
165 179 err = json.Unmarshal([]byte(content), &g_jsonconf.WithDrawConfig)
166 180 if err != nil {
167 181 logger.Info("loadJsonConf failed1,err=%v", err)
168   - return err
  182 + return err
169 183 }
170 184  
  185 + path = "../jsonconf/SignConfig.json"
  186 + content, err = file_get_contents(path)
  187 + if err != nil {
  188 + logger.Info("loadJsonConf failed1,err=%v", err)
  189 + return err
  190 + }
  191 +
  192 + err = json.Unmarshal([]byte(content), &g_jsonconf.SignConfig)
  193 + if err != nil {
  194 + logger.Info("loadJsonConf failed1,err=%v", err)
  195 + return err
  196 + }
171 197  
172 198 logger.Info("loadJsonConf success pconf=%v,err=%v", *g_jsonconf, err)
173   - return err
174   -}
175 199 \ No newline at end of file
  200 + return err
  201 +}
... ...