Commit 563689aefd6e36b452d54bbd151aa3166acead71

Authored by 陆恒
1 parent d23ad20a
Exists in master

提交翻牌

src/HttpServer/jsonconf/RedCatConfig.json
1   -[{"id":1,"name":"全球招财猫","skin":"abonus","money":0,"rate":0.002,"is_37":1,"dec_red":"每天获得平台收益分红20%","dec_get":"1.1周内邀请人数排名前10,<br/>官方将主动联系赠予"},{"id":2,"name":"1天招财猫","skin":"abonus","money":150,"rate":0,"is_37":1,"dec_red":"获得1天平台收益","dec_get":"1.2只36级猫合成可能获得<br/>2.五大神猫合成必得"},{"id":3,"name":"东方招财猫","skin":"dir1","money":0,"rate":300,"is_37":1,"dec_red":"集齐5大神猫,可召唤一天招财猫","dec_get":"1.2只36级猫合成可能获得"},{"id":4,"name":"南方招财猫","skin":"dir2","money":0,"rate":200,"is_37":1,"dec_red":"集齐5大神猫,可召唤一天招财猫","dec_get":"1.2只36级猫合成可能获得"},{"id":5,"name":"西方招财猫","skin":"dir3","money":0,"rate":200,"is_37":1,"dec_red":"集齐5大神猫,可召唤一天招财猫","dec_get":"1.2只36级猫合成可能获得"},{"id":6,"name":"北方招财猫","skin":"dir4","money":0,"rate":100,"is_37":1,"dec_red":"集齐5大神猫,可召唤一天招财猫","dec_get":"1.2只36级猫合成可能获得"},{"id":7,"name":"正中招财猫","skin":"dir5","money":0,"rate":0,"is_37":1,"dec_red":"集齐5大神猫,可召唤一天招财猫","dec_get":"1.2只36级猫合成可能获得"},{"id":8,"name":"情侣猫男","skin":"man","money":0,"rate":120,"is_37":1,"dec_red":"两只不同性别的情侣猫合成可获得52元红包","dec_get":"1.2只36级猫合成可能获得"},{"id":9,"name":"情侣猫女","skin":"woman","money":52,"rate":0,"is_37":1,"dec_red":"两只不同性别的情侣猫合成可获得52元红包","dec_get":"1.2只36级猫合成可能获得"},{"id":10,"name":"红包猫","skin":"redpacket","money":5,"rate":70,"is_37":0,"dec_red":"点击打开将直接获得5元红包","dec_get":"1.2只36级猫合成可能获得<br/>2.幸运扑克牌抽取获得<br/>3.大转盘抽奖获得"},{"id":11,"name":"发财猫","skin":"gambling","money":88,"rate":0,"is_37":0,"dec_red":"每期号码达到150,中午12.00开奖88元红包","dec_get":"1.幸运扑克牌抽取获得"},{"id":12,"name":"限时招财猫","skin":"abonus","money":0.17,"rate":0,"is_37":0,"dec_red":"可获得5-15min全平台分红","dec_get":"1.幸运扑克牌抽取获得"},{"id":13,"name":"10min招财猫","skin":"abonus","money":0.35,"rate":0,"is_37":0,"dec_red":"","dec_get":""},{"id":14,"name":"15min招财猫","skin":"abonus","money":1.563,"rate":0,"is_37":0,"dec_red":"","dec_get":""}]
2 1 \ No newline at end of file
  2 +[{"id":1,"name":"全球招财猫","skin":"abonus","money":0,"rate":0.002,"is_37":1,"dec_red":"每天获得平台收益分红20%","dec_get":"1.1周内邀请人数排名前10,<br/>官方将主动联系赠予"},{"id":2,"name":"1天招财猫","skin":"abonus","money":150,"rate":0,"is_37":1,"dec_red":"获得1天平台收益","dec_get":"1.2只36级猫合成可能获得<br/>2.五大神猫合成必得"},{"id":3,"name":"东方招财猫","skin":"dir1","money":0,"rate":300,"is_37":1,"dec_red":"集齐5大神猫,可召唤一天招财猫","dec_get":"1.2只36级猫合成可能获得"},{"id":4,"name":"南方招财猫","skin":"dir2","money":0,"rate":200,"is_37":1,"dec_red":"集齐5大神猫,可召唤一天招财猫","dec_get":"1.2只36级猫合成可能获得"},{"id":5,"name":"西方招财猫","skin":"dir3","money":0,"rate":200,"is_37":1,"dec_red":"集齐5大神猫,可召唤一天招财猫","dec_get":"1.2只36级猫合成可能获得"},{"id":6,"name":"北方招财猫","skin":"dir4","money":0,"rate":100,"is_37":1,"dec_red":"集齐5大神猫,可召唤一天招财猫","dec_get":"1.2只36级猫合成可能获得"},{"id":7,"name":"正中招财猫","skin":"dir5","money":0,"rate":0,"is_37":1,"dec_red":"集齐5大神猫,可召唤一天招财猫","dec_get":"1.2只36级猫合成可能获得"},{"id":8,"name":"情侣猫男","skin":"man","money":0,"rate":120,"is_37":1,"dec_red":"两只不同性别的情侣猫合成可获得52元红包","dec_get":"1.2只36级猫合成可能获得"},{"id":9,"name":"情侣猫女","skin":"woman","money":52,"rate":0,"is_37":1,"dec_red":"两只不同性别的情侣猫合成可获得52元红包","dec_get":"1.2只36级猫合成可能获得"},{"id":10,"name":"红包猫","skin":"redpacket","money":5,"rate":70,"is_37":0,"dec_red":"点击打开将直接获得5元红包","dec_get":"1.2只36级猫合成可能获得<br/>2.幸运扑克牌抽取获得<br/>3.大转盘抽奖获得"},{"id":11,"name":"发财猫","skin":"gambling","money":88,"rate":0,"is_37":0,"dec_red":"每期号码达到150,中午12.00开奖88元红包","dec_get":"1.幸运扑克牌抽取获得"},{"id":12,"name":"限时招财猫","skin":"abonus","money":0.17,"rate":0,"is_37":0,"dec_red":"可获得5-15min全平台分红","dec_get":"1.幸运扑克牌抽取获得"},{"id":13,"name":"10min招财猫","skin":"abonus","money":0.35,"rate":0,"is_37":0,"dec_red":"","dec_ get":""},{"id":14,"name":"15min招财猫","skin":"abonus","money":1.563,"rate":0,"is_37":0,"dec_red":"","dec_get":""}]
3 3 \ No newline at end of file
... ...
src/HttpServer/jsonconf/jsonconf.go
... ... @@ -61,6 +61,16 @@ func GetJsonConf() *GameConfig {
61 61 return g_jsonconf
62 62 }
63 63  
  64 +func GetCardConfig(time int) *CardDesc {
  65 + for _, v := range g_jsonconf.CardConfig {
  66 + if v.Time == time {
  67 + return &v
  68 + }
  69 + }
  70 +
  71 + return &g_jsonconf.CardConfig[len(g_jsonconf.CardConfig)-1]
  72 +}
  73 +
64 74 func GetTurnTable(ctype int) []TurnTableDesc {
65 75 var rtslice []TurnTableDesc
66 76 for _, v := range g_jsonconf.TurnTableConfig {
... ...
src/HttpServer/logic/constdef.go
... ... @@ -30,15 +30,14 @@ const (
30 30  
31 31 )
32 32  
33   -//奖励类型枚举
  33 +//翻牌类型枚举
34 34 const (
35   - REWARDTYPE_STAR = 1 //星星
36   - REWARDTYPE_CHUI = 2
37   - REWARDTYPE_SHUA = 3
38   - REWARDTYPE_SWAP = 4
39   - REWARDTYPE_ELIMITE = 5
40   - REWARDTYPE_EXP = 6
41   - REWARDTYPE_GOLD = 7
  35 + FLOPTYPE_15MIN = 1 //15min当前产出
  36 + FLOPTYPE_45MIN = 2 //45min当前产出
  37 + FLOPTYPE_FENCAT15MIN = 3 //分红猫15min
  38 + FLOPTYPE_FENCAT10MIN = 4 //10min分红猫
  39 + FLOPTYPE_REDCAT = 5 //红包猫
  40 + FLOPTYPE_GLAMCAT = 6 //赌博猫
42 41 )
43 42  
44 43 const (
... ...
src/HttpServer/logic/datadef.go
... ... @@ -234,6 +234,33 @@ type DrawTableResp struct {
234 234 Data DrawTableData `json:"data"`
235 235 }
236 236  
  237 +type QueryFlopData struct {
  238 + LeftTimes int `json:"leftTimes"`
  239 +}
  240 +
  241 +type QueryFlopResp struct {
  242 + Code int `json:"code"`
  243 + Message string `json:"message"`
  244 + Data QueryFlopData `json:"data"`
  245 +}
  246 +
  247 +type DoFlopRespReward struct {
  248 + RewardId int `json:"rewardId"`
  249 + CatId int `json:"catId"`
  250 + Coin string `json:"coin"`
  251 +}
  252 +
  253 +type DoFlopRespData struct {
  254 + Reward DoFlopRespReward `json:"reward"`
  255 + LeftTimes int `json:"leftTimes"`
  256 + Coin DoBuyCatCoin `json:"coin"`
  257 +}
  258 +type DoFlopResp struct {
  259 + Code int `json:"code"`
  260 + Message string `json:"message"`
  261 + Data DoFlopRespData `json:"data"`
  262 +}
  263 +
237 264 type AcclecteBoxResp struct {
238 265 Code int `json:"code"`
239 266 Message string `json:"message"`
... ... @@ -625,6 +652,8 @@ type UserData struct {
625 652 OfflineLove int64 //离线爱心
626 653 LastLoginTime int //上次登陆时间
627 654 LastTimingRewardHour int //上次领取整点奖励的时刻
  655 + FlopCardCnt int //翻牌次数计数
  656 + FlopCardLefCnt int //剩余翻拍次数
628 657 CatShopInfo CatShopData //猫咖门店数据
629 658 Taskinfo TaskData //任务数据
630 659 AchieveMent AchieveMentData //成就数据
... ...
src/HttpServer/logic/function.go
... ... @@ -125,6 +125,65 @@ func (u *UserData) DrawTable() int {
125 125 return idx
126 126 }
127 127  
  128 +func (u *UserData) DoFlopCardd(resp *DoFlopResp) {
  129 + cfg := jsonconf.GetCardConfig(u.FlopCardCnt)
  130 + if cfg == nil {
  131 + logger.Error("HandlerDoFlop getcfg failed=%v", u.FlopCardCnt)
  132 + resp.Code = 1
  133 + resp.Message = "getcfg"
  134 + return
  135 + }
  136 +
  137 + addgold := int64(0)
  138 + var catfg *jsonconf.RedCatDesc
  139 + catid := 0
  140 + ctime := 0
  141 + nowt := int(time.Now().Unix())
  142 + switch cfg.Ctype {
  143 + case FLOPTYPE_15MIN:
  144 + addgold = u.Goldrate * 15 * 60
  145 +
  146 + case FLOPTYPE_45MIN:
  147 + addgold = u.Goldrate * 15 * 60
  148 + case FLOPTYPE_FENCAT15MIN:
  149 + catid = 14 + 100
  150 + ctime = 15 * 60
  151 + catfg = jsonconf.GetRedCatConfig(catid)
  152 + u.SetRedCatPos(catid, ctime, catfg.Money, nowt)
  153 + case FLOPTYPE_FENCAT10MIN:
  154 + catid = 13 + 100
  155 + ctime = 10 * 60
  156 + catfg = jsonconf.GetRedCatConfig(catid)
  157 + u.SetRedCatPos(catid, ctime, catfg.Money, nowt)
  158 + case FLOPTYPE_REDCAT:
  159 + catid = 10 + 100
  160 + catfg = jsonconf.GetRedCatConfig(catid)
  161 + u.SetRedCatPos(catid, 0, catfg.Money, 0)
  162 + case FLOPTYPE_GLAMCAT:
  163 + catid = 11 + 100
  164 + catfg = jsonconf.GetRedCatConfig(catid)
  165 + u.SetRedCatPos(catid, 0, catfg.Money, 0)
  166 + }
  167 + u.Gold += addgold
  168 + u.CalcGoldRate()
  169 +
  170 + u.FlopCardLefCnt--
  171 + u.FlopCardCnt++
  172 +
  173 + SaveUserInfo(u, strconv.Itoa(u.UserId))
  174 +
  175 + resp.Data.LeftTimes = u.FlopCardLefCnt
  176 + resp.Data.Coin.UserId = u.UserId
  177 + resp.Data.Coin.Coin = strconv.FormatInt(u.Gold, 10)
  178 + resp.Data.Coin.IcomeRate = strconv.FormatInt(u.Goldrate, 10)
  179 + resp.Data.Coin.UpdateTime = int(time.Now().Unix())
  180 +
  181 + resp.Data.Reward.RewardId = u.FlopCardCnt
  182 + resp.Data.Reward.Coin = strconv.FormatInt(addgold, 10)
  183 + resp.Data.LeftTimes = u.FlopCardLefCnt
  184 +
  185 +}
  186 +
128 187 func (u *UserData) HandlePassDay() {
129 188 isdiffday := false
130 189 nowtime := time.Now()
... ... @@ -221,6 +280,7 @@ func InitUserInfo(data *UserLoginReq, resp *UserLoginResp, uuid int) {
221 280 udata.DrawTicketTimes = DRAWTICKETGETLIMIT
222 281 udata.DratMult = 1
223 282 udata.DrawTableCount = 1
  283 + udata.FlopCardCnt = 1
224 284  
225 285 //初始化16个猫爬架
226 286 for i := 0; i < 16; i++ {
... ... @@ -289,6 +349,21 @@ func InitUserInfo(data *UserLoginReq, resp *UserLoginResp, uuid int) {
289 349 redishandler.GetRedisClient().HSet(redis.USER_LAST_CALC_TIME, strconv.Itoa(uuid), nowtimestr)
290 350 }
291 351  
  352 +//设置红包猫
  353 +func (u *UserData) SetRedCatPos(catlv, time int, redpack float32, starttime int) {
  354 + pos := getCatPutPos(u, catlv)
  355 + if pos < 0 || pos >= len(u.PosInfo) {
  356 + logger.Error("CleadPos failed pos=%v,posinfo=%v", pos, u.PosInfo)
  357 + return
  358 + }
  359 +
  360 + u.PosInfo[pos].Cat = catlv
  361 + u.PosInfo[pos].Position = pos
  362 + u.PosInfo[pos].StartTime = starttime
  363 + u.PosInfo[pos].RedPacket = redpack
  364 + u.PosInfo[pos].Time = time
  365 +}
  366 +
292 367 //计算购买后猫箱子的位置,将箱子放到对应位置 返回值表示位置 -1表示失败都满了
293 368 func getCatPutPos(uinfo *UserData, clv int) int {
294 369 pos := -1
... ... @@ -437,6 +512,8 @@ func MergeRedBagCat(uinfo *UserData, pos int) int {
437 512 }
438 513 }
439 514  
  515 + //翻拍次数+
  516 + uinfo.FlopCardLefCnt++
440 517 return rtpos
441 518 }
442 519  
... ...
src/HttpServer/logic/httpserver.go
... ... @@ -45,6 +45,8 @@ func startServerHttpServe() {
45 45 http.HandleFunc("/api/turntable/addTicket", AddTicket) //增加抽奖券
46 46 http.HandleFunc("/api/turntable/multiple", Multiple) //增加倍数
47 47 http.HandleFunc("/api/turntable/draw", DrawTable) //抽奖
  48 + http.HandleFunc("/api/flop/leftTimes", QueryFlop) //剩余翻牌次数
  49 + http.HandleFunc("/api/flop/flop", DoFlop) //进行翻牌
48 50  
49 51 /////---------------------------------------------------------------------old
50 52 http.HandleFunc("/happycat/exchangetwoPos", ExchangePos) //交换位置
... ... @@ -639,6 +641,42 @@ func RedCatList(w http.ResponseWriter, r *http.Request) {
639 641 //HandlerRecvTimingReward(w, s, Uuid)
640 642 }
641 643  
  644 +func DoFlop(w http.ResponseWriter, r *http.Request) {
  645 + Uuid := 0
  646 + if len(r.Header) > 0 {
  647 + Uuid, _ = strconv.Atoi(r.Header.Get("uid"))
  648 + }
  649 + if Uuid == 0 {
  650 + SetHeader(w)
  651 + return
  652 + }
  653 + result, _ := ioutil.ReadAll(r.Body)
  654 + r.Body.Close()
  655 +
  656 + s := string(result)
  657 + logger.Info("DoFlop , body:%v,uuid=%v", s, Uuid)
  658 +
  659 + HandlerDoFlop(w, s, Uuid)
  660 +}
  661 +
  662 +func QueryFlop(w http.ResponseWriter, r *http.Request) {
  663 + Uuid := 0
  664 + if len(r.Header) > 0 {
  665 + Uuid, _ = strconv.Atoi(r.Header.Get("uid"))
  666 + }
  667 + if Uuid == 0 {
  668 + SetHeader(w)
  669 + return
  670 + }
  671 + result, _ := ioutil.ReadAll(r.Body)
  672 + r.Body.Close()
  673 +
  674 + s := string(result)
  675 + logger.Info("QueryFlop , body:%v,uuid=%v", s, Uuid)
  676 +
  677 + HandlerQueryFlop(w, s, Uuid)
  678 +}
  679 +
642 680 func DrawTable(w http.ResponseWriter, r *http.Request) {
643 681 Uuid := 0
644 682 if len(r.Header) > 0 {
... ...
src/HttpServer/logic/logic.go
... ... @@ -403,6 +403,69 @@ func HandlerGetMainPageInfo(w http.ResponseWriter, data string, uuid int) {
403 403 fmt.Fprint(w, string(respstr))
404 404 }
405 405  
  406 +func HandlerDoFlop(w http.ResponseWriter, data string, uuid int) {
  407 + SetHeader(w)
  408 + var resp DoFlopResp
  409 + resp.Code = 0
  410 + resp.Message = "success"
  411 +
  412 + for {
  413 +
  414 + uinfo, err := GetUserInfo(strconv.Itoa(uuid))
  415 + if err != nil || uinfo == nil {
  416 + logger.Error("HandlerDoFlop getuserinfo failed=%v", err)
  417 + resp.Code = 1
  418 + resp.Message = "get userinfo failed"
  419 + break
  420 + }
  421 +
  422 + //判断一下翻拍次数是否足够
  423 + if uinfo.FlopCardLefCnt <= 0 {
  424 + logger.Error("HandlerDoFlop flopcnt failed=%v", err)
  425 + resp.Code = 1
  426 + resp.Message = "翻拍次数不足"
  427 + break
  428 + }
  429 +
  430 + uinfo.DoFlopCardd(&resp)
  431 +
  432 + resp.Code = 0
  433 + break
  434 + }
  435 +
  436 + //回包
  437 + respstr, _ := json.Marshal(&resp)
  438 + fmt.Fprint(w, string(respstr))
  439 +
  440 +}
  441 +
  442 +func HandlerQueryFlop(w http.ResponseWriter, data string, uuid int) {
  443 + SetHeader(w)
  444 + var resp QueryFlopResp
  445 + resp.Code = 0
  446 + resp.Message = "success"
  447 +
  448 + for {
  449 +
  450 + uinfo, err := GetUserInfo(strconv.Itoa(uuid))
  451 + if err != nil || uinfo == nil {
  452 + logger.Error("HandlerQueryFlop getuserinfo failed=%v", err)
  453 + resp.Code = 1
  454 + resp.Message = "get userinfo failed"
  455 + break
  456 + }
  457 +
  458 + resp.Data.LeftTimes = uinfo.FlopCardLefCnt
  459 + resp.Code = 0
  460 + break
  461 + }
  462 +
  463 + //回包
  464 + respstr, _ := json.Marshal(&resp)
  465 + fmt.Fprint(w, string(respstr))
  466 +
  467 +}
  468 +
406 469 func HandlerDrawTable(w http.ResponseWriter, data string, uuid int) {
407 470 SetHeader(w)
408 471 var resp DrawTableResp
... ... @@ -1167,6 +1230,9 @@ func HandlerExchangePos(w http.ResponseWriter, data string, uuid int) {
1167 1230 uinfo.Highestlv = uinfo.PosInfo[rdata.To].Cat
1168 1231 resp.Data.NewCat = uinfo.PosInfo[rdata.To].Cat
1169 1232 uinfo.CheckBuyCatSHop()
  1233 +
  1234 + //翻拍次数+
  1235 + uinfo.FlopCardLefCnt++
1170 1236 }
1171 1237  
1172 1238 }
... ...