Commit 93a657948ca6af21d3a71baf6b5cdedaa7a93297

Authored by 陆恒
1 parent bf8feb78
Exists in master

提交

src/HttpServer/logic/datadef.go
@@ -712,12 +712,18 @@ type UserData struct { @@ -712,12 +712,18 @@ type UserData struct {
712 Taskinfo TaskData //任务数据 712 Taskinfo TaskData //任务数据
713 AchieveMent AchieveMentData //成就数据 713 AchieveMent AchieveMentData //成就数据
714 PosInfo []CatPosInfo //位置信息 从0开始 714 PosInfo []CatPosInfo //位置信息 从0开始
  715 + DuboCat []DuboCatInfo //赌博猫信息
715 BuyCatInfo []BuyCatInfoData //商店购买猫数据 第一个元素为1级猫 第二个为2级猫以此类推 716 BuyCatInfo []BuyCatInfoData //商店购买猫数据 第一个元素为1级猫 第二个为2级猫以此类推
716 CatRoomInfo []CatRoomData //猫咖店数据 717 CatRoomInfo []CatRoomData //猫咖店数据
717 CaiPiaoInfo []UserCaiPiaoHistory //记录玩家参与过的赌博猫历史记录 718 CaiPiaoInfo []UserCaiPiaoHistory //记录玩家参与过的赌博猫历史记录
718 719
719 } 720 }
720 721
  722 +type DuboCatInfo struct {
  723 + CatID int
  724 + ChooseNum int //选择的号码
  725 +}
  726 +
721 type UserCaiPiaoHistory struct { 727 type UserCaiPiaoHistory struct {
722 Cnum int //选择的号码 728 Cnum int //选择的号码
723 RewardNum int //当期开奖的号码 729 RewardNum int //当期开奖的号码
src/HttpServer/logic/function.go
@@ -277,7 +277,7 @@ func (u *UserData) DoFlopCardd(resp *DoFlopResp) { @@ -277,7 +277,7 @@ func (u *UserData) DoFlopCardd(resp *DoFlopResp) {
277 case FLOPTYPE_GLAMCAT: 277 case FLOPTYPE_GLAMCAT:
278 catid = 11 + REDCATIDEXTRA 278 catid = 11 + REDCATIDEXTRA
279 catfg = jsonconf.GetRedCatConfig(catid) 279 catfg = jsonconf.GetRedCatConfig(catid)
280 - u.SetRedCatPos(catid, 0, catfg.Money, 0) 280 + u.SetDuboCatPos(catid)
281 } 281 }
282 u.Gold += addgold 282 u.Gold += addgold
283 u.CalcGoldRate() 283 u.CalcGoldRate()
@@ -471,6 +471,15 @@ func InitUserInfo(data *UserLoginReq, resp *UserLoginResp, uuid int) { @@ -471,6 +471,15 @@ func InitUserInfo(data *UserLoginReq, resp *UserLoginResp, uuid int) {
471 redishandler.GetRedisClient().HSet(redis.USER_LAST_CALC_TIME, strconv.Itoa(uuid), nowtimestr) 471 redishandler.GetRedisClient().HSet(redis.USER_LAST_CALC_TIME, strconv.Itoa(uuid), nowtimestr)
472 } 472 }
473 473
  474 +//设置赌博猫
  475 +func (u *UserData) SetDuboCatPos(catlv int) {
  476 +
  477 + var du DuboCatInfo
  478 + du.ChooseNum = 0
  479 + du.CatID = catlv
  480 + u.DuboCat = append(u.DuboCat, du)
  481 +}
  482 +
474 //设置红包猫 483 //设置红包猫
475 func (u *UserData) SetRedCatPos(catlv, time int, redpack float32, starttime int) { 484 func (u *UserData) SetRedCatPos(catlv, time int, redpack float32, starttime int) {
476 pos := getCatPutPos(u, catlv) 485 pos := getCatPutPos(u, catlv)
src/HttpServer/logic/logic.go
@@ -1343,6 +1343,28 @@ func HandlerAutoChoose(w http.ResponseWriter, data string, uuid int) { @@ -1343,6 +1343,28 @@ func HandlerAutoChoose(w http.ResponseWriter, data string, uuid int) {
1343 1343
1344 for { 1344 for {
1345 1345
  1346 + //先校验一下有没有空的猫
  1347 + uinfo, err := GetUserInfo(strconv.Itoa(uuid))
  1348 + if err != nil || uinfo == nil {
  1349 + logger.Error("HandlerExchangePos getuserinfo failed=%v", err)
  1350 + resp.Code = 1
  1351 + resp.Message = "get userinfo failed"
  1352 + break
  1353 + }
  1354 + catpos := -1
  1355 + for k, val := range uinfo.DuboCat {
  1356 + if val.ChooseNum != 0 {
  1357 + catpos = k
  1358 + }
  1359 + }
  1360 + if catpos == -1 {
  1361 + //当前没有可以选择号码的猫
  1362 + logger.Error("HandlerAutoChoose no cat failed=%v", err)
  1363 + resp.Code = 1
  1364 + resp.Message = "抱歉你没有猫可以选择号码"
  1365 + break
  1366 + }
  1367 +
1346 //首先找一个可以选取的号码 1368 //首先找一个可以选取的号码
1347 cnum := 0 1369 cnum := 0
1348 vv, err := redishandler.GetRedisClient().HGetAllKeys(redis.CAIPIAOLEFTNUM_KEY) 1370 vv, err := redishandler.GetRedisClient().HGetAllKeys(redis.CAIPIAOLEFTNUM_KEY)
@@ -1380,6 +1402,10 @@ func HandlerAutoChoose(w http.ResponseWriter, data string, uuid int) { @@ -1380,6 +1402,10 @@ func HandlerAutoChoose(w http.ResponseWriter, data string, uuid int) {
1380 resp.Code = 1 1402 resp.Code = 1
1381 break 1403 break
1382 } else { 1404 } else {
  1405 + if catpos >= 0 && catpos < len(uinfo.DuboCat) {
  1406 + uinfo.DuboCat[catpos].ChooseNum = cnum
  1407 + }
  1408 + SaveUserInfo(uinfo, strconv.Itoa(uuid))
1383 //将该号码移除 1409 //将该号码移除
1384 redishandler.GetRedisClient().HDel(redis.CAIPIAOLEFTNUM_KEY, strconv.Itoa(cnum)) 1410 redishandler.GetRedisClient().HDel(redis.CAIPIAOLEFTNUM_KEY, strconv.Itoa(cnum))
1385 //添加 1411 //添加
@@ -1443,6 +1469,7 @@ func HandlerChooseNum(w http.ResponseWriter, data string, uuid int) { @@ -1443,6 +1469,7 @@ func HandlerChooseNum(w http.ResponseWriter, data string, uuid int) {
1443 } 1469 }
1444 1470
1445 for { 1471 for {
  1472 +
1446 //先判断一下当前号码是否已被选取 1473 //先判断一下当前号码是否已被选取
1447 isexist, err := redishandler.GetRedisClient().HExists(redis.CAIPIAOLEFTNUM_KEY, strconv.Itoa(rdata.Number)) 1474 isexist, err := redishandler.GetRedisClient().HExists(redis.CAIPIAOLEFTNUM_KEY, strconv.Itoa(rdata.Number))
1448 if err != nil { 1475 if err != nil {
@@ -1459,6 +1486,26 @@ func HandlerChooseNum(w http.ResponseWriter, data string, uuid int) { @@ -1459,6 +1486,26 @@ func HandlerChooseNum(w http.ResponseWriter, data string, uuid int) {
1459 resp.Code = 100 1486 resp.Code = 100
1460 break 1487 break
1461 } 1488 }
  1489 + uinfo, err := GetUserInfo(strconv.Itoa(uuid))
  1490 + if err != nil || uinfo == nil {
  1491 + logger.Error("HandlerChooseNum getuserinfo failed=%v", err)
  1492 + resp.Code = 1
  1493 + resp.Message = "get userinfo failed"
  1494 + break
  1495 + }
  1496 + catpos := -1
  1497 + for k, val := range uinfo.DuboCat {
  1498 + if val.ChooseNum != 0 {
  1499 + catpos = k
  1500 + }
  1501 + }
  1502 + if catpos == -1 {
  1503 + //当前没有可以选择号码的猫
  1504 + logger.Error("HandlerChooseNum no cat failed=%v", err)
  1505 + resp.Code = 1
  1506 + resp.Message = "抱歉你没有猫可以选择号码"
  1507 + break
  1508 + }
1462 1509
1463 //加入当前彩池 1510 //加入当前彩池
1464 curpool := GetCurCaiCatList() 1511 curpool := GetCurCaiCatList()
@@ -1474,7 +1521,7 @@ func HandlerChooseNum(w http.ResponseWriter, data string, uuid int) { @@ -1474,7 +1521,7 @@ func HandlerChooseNum(w http.ResponseWriter, data string, uuid int) {
1474 //添加 1521 //添加
1475 var tmp UserCaiPiaoInfo 1522 var tmp UserCaiPiaoInfo
1476 tmp.ChooseNum = rdata.Number 1523 tmp.ChooseNum = rdata.Number
1477 - tmp.CatId = rdata.CatId 1524 + tmp.CatId = 48
1478 tmp.UserId = uuid 1525 tmp.UserId = uuid
1479 curpool.List = append(curpool.List, tmp) 1526 curpool.List = append(curpool.List, tmp)
1480 curpool.CurNum = len(curpool.List) 1527 curpool.CurNum = len(curpool.List)