Commit 26e94c6ce623cea4644e8cb4de0b53be30b0b0de
1 parent
72059f69
Exists in
master
提交
Showing
5 changed files
with
116 additions
and
66 deletions
Show diff stats
src/HttpServer/logic/constdef.go
@@ -53,6 +53,8 @@ const ( | @@ -53,6 +53,8 @@ const ( | ||
53 | WATCH_ADD_DAY_LIMIT = 50 //当天获取红包次数限制 | 53 | WATCH_ADD_DAY_LIMIT = 50 //当天获取红包次数限制 |
54 | ACCGOLDRATELIMIT = 3 //玩家每天看视频加速金币次数 | 54 | ACCGOLDRATELIMIT = 3 //玩家每天看视频加速金币次数 |
55 | WATCHADSGOLDLIMIT = 15 //玩家每天看广告领金币限制次数 | 55 | WATCHADSGOLDLIMIT = 15 //玩家每天看广告领金币限制次数 |
56 | + TIMEINGREWARDLIMIT = 15 //整点奖励限制次数 | ||
57 | + OFFLINETIMESLIMIT = 10 //离线奖励领取次数限制 | ||
56 | WATCHADSGOLDLRATE = 10800 //看广告领取金币的秒数 | 58 | WATCHADSGOLDLRATE = 10800 //看广告领取金币的秒数 |
57 | ZHENGHOURMULT = 3600 //整点领取金币的秒数 | 59 | ZHENGHOURMULT = 3600 //整点领取金币的秒数 |
58 | DRAWTICKETNUM = 5 //每日送的抽奖券次数 | 60 | DRAWTICKETNUM = 5 //每日送的抽奖券次数 |
src/HttpServer/logic/datadef.go
@@ -43,6 +43,7 @@ type GetUserDataReq struct { | @@ -43,6 +43,7 @@ type GetUserDataReq struct { | ||
43 | type offlineRewardDesc struct { | 43 | type offlineRewardDesc struct { |
44 | OfflineTime int `json:"offlineTime"` | 44 | OfflineTime int `json:"offlineTime"` |
45 | Income string `json:"income"` | 45 | Income string `json:"income"` |
46 | + LeftTimes int `json:"leftTimes"` | ||
46 | } | 47 | } |
47 | 48 | ||
48 | type GetUserDataData struct { | 49 | type GetUserDataData struct { |
@@ -838,60 +839,62 @@ type WithDrawInfo struct { | @@ -838,60 +839,62 @@ type WithDrawInfo struct { | ||
838 | 839 | ||
839 | //玩家数据 | 840 | //玩家数据 |
840 | type UserData struct { | 841 | type UserData struct { |
841 | - UserId int //玩家id | ||
842 | - Gameid string //玩家Gameid | ||
843 | - Channel string //玩家Channel | ||
844 | - RegTime int //注册时间 | ||
845 | - ContinueLoginDay int //连续登陆天数 | ||
846 | - SumLoginDay int //累计登录天数 | ||
847 | - Gold int64 //金币 | ||
848 | - GoldSum int64 //玩家累计金币 | ||
849 | - Love int64 //爱心值 | ||
850 | - Goldrate int64 //金币生成速率 | ||
851 | - Loverate int64 //爱心生产速率 | ||
852 | - Highestlv int //当前最高猫等级 | ||
853 | - InviteId int //邀请者uid | ||
854 | - CurBoxLv int //当前猫箱子等级 | ||
855 | - IsDouble int //当前加速标签 1表示3倍收益 0表示正常 | ||
856 | - StartDoubleTime int //开始双倍时间 | ||
857 | - DoubleLeftTimes int //剩余加速金币次数 | ||
858 | - GetWatchAdsGoldTime int //看广告领金币次数 | ||
859 | - DrawTicket int //抽奖券次数 | ||
860 | - DrawTicketTimes int //剩余增加抽奖券次数 | ||
861 | - DratMult int //下次抽奖的倍数 | ||
862 | - DrawLastRewardId int //上一次的奖励ID | ||
863 | - DrawTableCount int //当前抽奖次数 5次以后归零 | ||
864 | - IsAuto int //当前是否自动合成 | ||
865 | - IsBoxAcc int //是否处于加速生成箱子状态 | ||
866 | - RandGiftNum int //当前剩余空投猫粮次数 | ||
867 | - RandGiftDay int //记录当前猫粮日期,当日期变化则重置RandGiftNum | ||
868 | - RandGiftTime int //记录上一次空投猫粮时间 | ||
869 | - Redbag float32 //红包值 单位为分 | ||
870 | - Head string //头像地址 | ||
871 | - NickName string //昵称 | ||
872 | - RealName string //实名 | ||
873 | - IsFirstRedBgCat int //是否合成过红包猫 0表示否1表示是 | ||
874 | - OfflineGold int64 //离线金币 | ||
875 | - OfflineLove int64 //离线爱心 | ||
876 | - LastLoginTime int //上次登陆时间 | ||
877 | - LastTimingRewardHour int //上次领取整点奖励的时刻 | ||
878 | - FlopCardCnt int //翻牌次数计数 | ||
879 | - FlopCardLefCnt int //剩余翻拍次数 | ||
880 | - TodayZhaocai float32 //当天招财猫收益 | ||
881 | - IsNew int //是否需要引导 | ||
882 | - RandRedBagLeftTime int //剩余随机红包次数 | ||
883 | - SumRandRedBagTimes int //已领取的随机红包总次数 | ||
884 | - StoreRandRedBag int //存储的随机红包个数 | ||
885 | - FlyBoxNumTimes int //生意飞天宝箱次数 | ||
886 | - CatShopInfo CatShopData //猫咖门店数据 | ||
887 | - Taskinfo TaskData //任务数据 | ||
888 | - AchieveMent AchieveMentData //成就数据 | ||
889 | - PosInfo []CatPosInfo //位置信息 从0开始 | ||
890 | - DuboCat []DuboCatInfo //赌博猫信息 | ||
891 | - BuyCatInfo []BuyCatInfoData //商店购买猫数据 第一个元素为1级猫 第二个为2级猫以此类推 | ||
892 | - CatRoomInfo []CatRoomData //猫咖店数据 | ||
893 | - CaiPiaoInfo []UserCaiPiaoHistory //记录玩家参与过的赌博猫历史记录 | ||
894 | - WithDraw WithDrawInfo //提现记录信息 | 842 | + UserId int //玩家id |
843 | + Gameid string //玩家Gameid | ||
844 | + Channel string //玩家Channel | ||
845 | + RegTime int //注册时间 | ||
846 | + ContinueLoginDay int //连续登陆天数 | ||
847 | + SumLoginDay int //累计登录天数 | ||
848 | + Gold int64 //金币 | ||
849 | + GoldSum int64 //玩家累计金币 | ||
850 | + Love int64 //爱心值 | ||
851 | + Goldrate int64 //金币生成速率 | ||
852 | + Loverate int64 //爱心生产速率 | ||
853 | + Highestlv int //当前最高猫等级 | ||
854 | + InviteId int //邀请者uid | ||
855 | + CurBoxLv int //当前猫箱子等级 | ||
856 | + IsDouble int //当前加速标签 1表示3倍收益 0表示正常 | ||
857 | + StartDoubleTime int //开始双倍时间 | ||
858 | + DoubleLeftTimes int //剩余加速金币次数 | ||
859 | + GetWatchAdsGoldTime int //看广告领金币次数 | ||
860 | + DrawTicket int //抽奖券次数 | ||
861 | + DrawTicketTimes int //剩余增加抽奖券次数 | ||
862 | + DratMult int //下次抽奖的倍数 | ||
863 | + DrawLastRewardId int //上一次的奖励ID | ||
864 | + DrawTableCount int //当前抽奖次数 5次以后归零 | ||
865 | + IsAuto int //当前是否自动合成 | ||
866 | + IsBoxAcc int //是否处于加速生成箱子状态 | ||
867 | + RandGiftNum int //当前剩余空投猫粮次数 | ||
868 | + RandGiftDay int //记录当前猫粮日期,当日期变化则重置RandGiftNum | ||
869 | + RandGiftTime int //记录上一次空投猫粮时间 | ||
870 | + Redbag float32 //红包值 单位为分 | ||
871 | + Head string //头像地址 | ||
872 | + NickName string //昵称 | ||
873 | + RealName string //实名 | ||
874 | + IsFirstRedBgCat int //是否合成过红包猫 0表示否1表示是 | ||
875 | + OfflineGold int64 //离线金币 | ||
876 | + OfflineLove int64 //离线爱心 | ||
877 | + LastLoginTime int //上次登陆时间 | ||
878 | + LastTimingRewardHour int //当天领取整点奖励的次数 | ||
879 | + LeftTimingRewardTimes int //剩余整点奖励次数 | ||
880 | + FlopCardCnt int //翻牌次数计数 | ||
881 | + FlopCardLefCnt int //剩余翻拍次数 | ||
882 | + TodayZhaocai float32 //当天招财猫收益 | ||
883 | + IsNew int //是否需要引导 | ||
884 | + RandRedBagLeftTime int //剩余随机红包次数 | ||
885 | + SumRandRedBagTimes int //已领取的随机红包总次数 | ||
886 | + StoreRandRedBag int //存储的随机红包个数 | ||
887 | + FlyBoxNumTimes int //生意飞天宝箱次数 | ||
888 | + LeftOfflineTimes int //离线奖励剩余领取次数 | ||
889 | + CatShopInfo CatShopData //猫咖门店数据 | ||
890 | + Taskinfo TaskData //任务数据 | ||
891 | + AchieveMent AchieveMentData //成就数据 | ||
892 | + PosInfo []CatPosInfo //位置信息 从0开始 | ||
893 | + DuboCat []DuboCatInfo //赌博猫信息 | ||
894 | + BuyCatInfo []BuyCatInfoData //商店购买猫数据 第一个元素为1级猫 第二个为2级猫以此类推 | ||
895 | + CatRoomInfo []CatRoomData //猫咖店数据 | ||
896 | + CaiPiaoInfo []UserCaiPiaoHistory //记录玩家参与过的赌博猫历史记录 | ||
897 | + WithDraw WithDrawInfo //提现记录信息 | ||
895 | 898 | ||
896 | } | 899 | } |
897 | 900 |
src/HttpServer/logic/function.go
@@ -471,6 +471,11 @@ func (u *UserData) HandlePassDay() { | @@ -471,6 +471,11 @@ func (u *UserData) HandlePassDay() { | ||
471 | u.DrawTicketTimes = DRAWTICKETGETLIMIT | 471 | u.DrawTicketTimes = DRAWTICKETGETLIMIT |
472 | u.RandRedBagLeftTime = RANDGIFTLIMIT | 472 | u.RandRedBagLeftTime = RANDGIFTLIMIT |
473 | u.FlyBoxNumTimes = FLYBOXNUMLIMIT | 473 | u.FlyBoxNumTimes = FLYBOXNUMLIMIT |
474 | + u.LeftTimingRewardTimes = TIMEINGREWARDLIMIT | ||
475 | + u.LeftOfflineTimes = OFFLINETIMESLIMIT | ||
476 | + /*randint := rand.Intn(100) | ||
477 | + floatval := float32(randint) / 100 | ||
478 | + u.TodayZhaocai = 180 + floatval*/ | ||
474 | } | 479 | } |
475 | 480 | ||
476 | u.LastLoginTime = int(nowtime.Unix()) | 481 | u.LastLoginTime = int(nowtime.Unix()) |
@@ -546,6 +551,12 @@ func InitUserInfo(data *UserLoginReq, resp *UserLoginResp, uuid int) { | @@ -546,6 +551,12 @@ func InitUserInfo(data *UserLoginReq, resp *UserLoginResp, uuid int) { | ||
546 | udata.SumLoginDay = 1 | 551 | udata.SumLoginDay = 1 |
547 | udata.RandRedBagLeftTime = RANDGIFTLIMIT | 552 | udata.RandRedBagLeftTime = RANDGIFTLIMIT |
548 | udata.FlyBoxNumTimes = FLYBOXNUMLIMIT | 553 | udata.FlyBoxNumTimes = FLYBOXNUMLIMIT |
554 | + udata.LeftTimingRewardTimes = TIMEINGREWARDLIMIT | ||
555 | + udata.LeftOfflineTimes = OFFLINETIMESLIMIT | ||
556 | + /*randint := rand.Intn(100) | ||
557 | + floatval := float32(randint) / 100 | ||
558 | + udata.TodayZhaocai = 180 + floatval*/ | ||
559 | + | ||
549 | udata.SumRandRedBagTimes = 0 | 560 | udata.SumRandRedBagTimes = 0 |
550 | udata.StoreRandRedBag = 0 | 561 | udata.StoreRandRedBag = 0 |
551 | udata.Gameid = data.Gameid | 562 | udata.Gameid = data.Gameid |
src/HttpServer/logic/httpserver.go
@@ -18,11 +18,18 @@ import ( | @@ -18,11 +18,18 @@ import ( | ||
18 | "net/http" | 18 | "net/http" |
19 | ) | 19 | ) |
20 | 20 | ||
21 | +var G_randVal = float32(188.11) | ||
22 | + | ||
21 | func StartHttpTicker() { | 23 | func StartHttpTicker() { |
22 | ticker := time.NewTicker(time.Second * time.Duration(30)) | 24 | ticker := time.NewTicker(time.Second * time.Duration(30)) |
23 | 25 | ||
24 | go func() { | 26 | go func() { |
25 | for range ticker.C { | 27 | for range ticker.C { |
28 | + if time.Now().Hour() == 0 && time.Now().Minute() < 1 { | ||
29 | + randint := rand.Intn(100) | ||
30 | + floatval := float32(randint) / 100 | ||
31 | + G_randVal = 180 + floatval | ||
32 | + } | ||
26 | if time.Now().Hour() == 12 { | 33 | if time.Now().Hour() == 12 { |
27 | //处理开奖 | 34 | //处理开奖 |
28 | waits := GetWaitCaiCatList() | 35 | waits := GetWaitCaiCatList() |
src/HttpServer/logic/logic.go
@@ -752,7 +752,7 @@ func HandlerGetUserData(w http.ResponseWriter, data string, uuid int) { | @@ -752,7 +752,7 @@ func HandlerGetUserData(w http.ResponseWriter, data string, uuid int) { | ||
752 | 752 | ||
753 | if nowtime-int64(lasttime) > 5*60 { | 753 | if nowtime-int64(lasttime) > 5*60 { |
754 | //算离线收益 | 754 | //算离线收益 |
755 | - resp.Data.TimingReward = false | 755 | + |
756 | offsec := nowtime - int64(lasttime) | 756 | offsec := nowtime - int64(lasttime) |
757 | if offsec > 2*3600 { | 757 | if offsec > 2*3600 { |
758 | offsec = 2 * 3600 | 758 | offsec = 2 * 3600 |
@@ -764,6 +764,7 @@ func HandlerGetUserData(w http.ResponseWriter, data string, uuid int) { | @@ -764,6 +764,7 @@ func HandlerGetUserData(w http.ResponseWriter, data string, uuid int) { | ||
764 | resp.Data.Output = "0" | 764 | resp.Data.Output = "0" |
765 | resp.Data.OfflineReward.OfflineTime = int(offsec) | 765 | resp.Data.OfflineReward.OfflineTime = int(offsec) |
766 | resp.Data.OfflineReward.Income = strconv.FormatInt(uinfo.OfflineGold, 10) | 766 | resp.Data.OfflineReward.Income = strconv.FormatInt(uinfo.OfflineGold, 10) |
767 | + resp.Data.OfflineReward.LeftTimes = uinfo.LeftOfflineTimes | ||
767 | } else { | 768 | } else { |
768 | //按费离线收益计算 | 769 | //按费离线收益计算 |
769 | //先计算一下双倍时间是否过期了 | 770 | //先计算一下双倍时间是否过期了 |
@@ -793,7 +794,7 @@ func HandlerGetUserData(w http.ResponseWriter, data string, uuid int) { | @@ -793,7 +794,7 @@ func HandlerGetUserData(w http.ResponseWriter, data string, uuid int) { | ||
793 | addgold = uinfo.Goldrate * offsec | 794 | addgold = uinfo.Goldrate * offsec |
794 | } | 795 | } |
795 | 796 | ||
796 | - resp.Data.TimingReward = true | 797 | + //resp.Data.TimingReward = true |
797 | resp.Data.Now = int(time.Now().Unix()) * 1000 | 798 | resp.Data.Now = int(time.Now().Unix()) * 1000 |
798 | 799 | ||
799 | uinfo.Gold += addgold | 800 | uinfo.Gold += addgold |
@@ -812,7 +813,16 @@ func HandlerGetUserData(w http.ResponseWriter, data string, uuid int) { | @@ -812,7 +813,16 @@ func HandlerGetUserData(w http.ResponseWriter, data string, uuid int) { | ||
812 | SaveUserInfo(uinfo, strconv.Itoa(uuid)) | 813 | SaveUserInfo(uinfo, strconv.Itoa(uuid)) |
813 | } | 814 | } |
814 | 815 | ||
815 | - resp.Data.TimingRewardTimes = uinfo.GetWatchAdsGoldTime | 816 | + //计算一下整点奖励是否可以领取 |
817 | + resp.Data.TimingReward = false | ||
818 | + nowt := time.Now() | ||
819 | + nowmin := nowt.Minute() + nowt.Hour()*60 | ||
820 | + if nowmin/30 >= uinfo.LastTimingRewardHour { | ||
821 | + resp.Data.TimingReward = true | ||
822 | + } | ||
823 | + | ||
824 | + resp.Data.TimingReward = false | ||
825 | + resp.Data.TimingRewardTimes = uinfo.LeftTimingRewardTimes | ||
816 | 826 | ||
817 | //保存此次计算时间 | 827 | //保存此次计算时间 |
818 | nowtimestr := strconv.FormatInt(nowtime, 10) | 828 | nowtimestr := strconv.FormatInt(nowtime, 10) |
@@ -851,6 +861,13 @@ func HandlerGetOfflineReward(w http.ResponseWriter, data string, uuid int) { | @@ -851,6 +861,13 @@ func HandlerGetOfflineReward(w http.ResponseWriter, data string, uuid int) { | ||
851 | break | 861 | break |
852 | } | 862 | } |
853 | 863 | ||
864 | + if uinfo.LeftOfflineTimes < 1 { | ||
865 | + logger.Error("HandlerGetUserData LeftOfflineTimes failed=%v", err) | ||
866 | + resp.Code = 1 | ||
867 | + resp.Message = "离线奖励剩余领取次数为0" | ||
868 | + break | ||
869 | + } | ||
870 | + | ||
854 | addgold := uinfo.OfflineGold | 871 | addgold := uinfo.OfflineGold |
855 | 872 | ||
856 | if rdata.Optype == 2 { | 873 | if rdata.Optype == 2 { |
@@ -862,6 +879,7 @@ func HandlerGetOfflineReward(w http.ResponseWriter, data string, uuid int) { | @@ -862,6 +879,7 @@ func HandlerGetOfflineReward(w http.ResponseWriter, data string, uuid int) { | ||
862 | uinfo.AddToRank() | 879 | uinfo.AddToRank() |
863 | 880 | ||
864 | //此处todo 记录离线领取的次数 | 881 | //此处todo 记录离线领取的次数 |
882 | + uinfo.LeftOfflineTimes-- | ||
865 | 883 | ||
866 | //领取过后将离线金币清零 | 884 | //领取过后将离线金币清零 |
867 | uinfo.OfflineGold = 0 | 885 | uinfo.OfflineGold = 0 |
@@ -1016,7 +1034,8 @@ func HandlerGetMainPageInfo(w http.ResponseWriter, data string, uuid int) { | @@ -1016,7 +1034,8 @@ func HandlerGetMainPageInfo(w http.ResponseWriter, data string, uuid int) { | ||
1016 | } | 1034 | } |
1017 | 1035 | ||
1018 | resp.Data.Level = len(uinfo.BuyCatInfo) | 1036 | resp.Data.Level = len(uinfo.BuyCatInfo) |
1019 | - resp.Data.TotalCashReward = uinfo.TodayZhaocai | 1037 | + resp.Data.TotalCashReward = G_randVal |
1038 | + | ||
1020 | resp.Data.Guide = true | 1039 | resp.Data.Guide = true |
1021 | if uinfo.IsNew == 0 { | 1040 | if uinfo.IsNew == 0 { |
1022 | resp.Data.Guide = false | 1041 | resp.Data.Guide = false |
@@ -1376,7 +1395,7 @@ func HandlerRecvRedCat(w http.ResponseWriter, data string, uuid int) { | @@ -1376,7 +1395,7 @@ func HandlerRecvRedCat(w http.ResponseWriter, data string, uuid int) { | ||
1376 | uinfo.CleadPos(cpos) | 1395 | uinfo.CleadPos(cpos) |
1377 | 1396 | ||
1378 | uinfo.CalcGoldRate() | 1397 | uinfo.CalcGoldRate() |
1379 | - uinfo.TodayZhaocai += addredpack | 1398 | + //uinfo.TodayZhaocai += addredpack |
1380 | 1399 | ||
1381 | SaveUserInfo(uinfo, strconv.Itoa(uuid)) | 1400 | SaveUserInfo(uinfo, strconv.Itoa(uuid)) |
1382 | resp.Data.Num = addredpack | 1401 | resp.Data.Num = addredpack |
@@ -1572,16 +1591,23 @@ func HandlerRecvTimingReward(w http.ResponseWriter, data string, uuid int) { | @@ -1572,16 +1591,23 @@ func HandlerRecvTimingReward(w http.ResponseWriter, data string, uuid int) { | ||
1572 | } | 1591 | } |
1573 | 1592 | ||
1574 | //判断一下领取的时间点是否正确 | 1593 | //判断一下领取的时间点是否正确 |
1575 | - nowt := time.Now() | ||
1576 | - if nowt.Minute() < 50 && nowt.Minute() > 10 { | 1594 | + if uinfo.LeftTimingRewardTimes < 1 { |
1595 | + logger.Error("HandlerRecvTimingReward LeftTimingRewardTimes failed=%v", err) | ||
1596 | + resp.Code = 1 | ||
1597 | + resp.Message = "剩余领取次数为0" | ||
1598 | + break | ||
1599 | + } | ||
1600 | + //nowt := time.Now() | ||
1601 | + /*if nowt.Minute() < 50 && nowt.Minute() > 10 { | ||
1577 | logger.Error("HandlerRecvTimingReward time failed=%v", err) | 1602 | logger.Error("HandlerRecvTimingReward time failed=%v", err) |
1578 | resp.Code = 1 | 1603 | resp.Code = 1 |
1579 | resp.Message = "time failed" | 1604 | resp.Message = "time failed" |
1580 | break | 1605 | break |
1581 | - } | 1606 | + }*/ |
1582 | 1607 | ||
1583 | - nowh := 0 | ||
1584 | - if nowt.Minute() >= 50 { | 1608 | + //nowmin := nowt.Hour()*60+nowt.Minute() |
1609 | + //if nowmin /30 < | ||
1610 | + /*if nowt.Minute() >= 50 { | ||
1585 | //领取的是笑一个小时 | 1611 | //领取的是笑一个小时 |
1586 | if nowt.Hour() < 23 { | 1612 | if nowt.Hour() < 23 { |
1587 | if uinfo.LastTimingRewardHour >= nowt.Hour()+1 { | 1613 | if uinfo.LastTimingRewardHour >= nowt.Hour()+1 { |
@@ -1615,11 +1641,12 @@ func HandlerRecvTimingReward(w http.ResponseWriter, data string, uuid int) { | @@ -1615,11 +1641,12 @@ func HandlerRecvTimingReward(w http.ResponseWriter, data string, uuid int) { | ||
1615 | break | 1641 | break |
1616 | } | 1642 | } |
1617 | nowh = nowt.Hour() | 1643 | nowh = nowt.Hour() |
1618 | - } | 1644 | + }*/ |
1619 | 1645 | ||
1620 | addgold := uinfo.Goldrate * ZHENGHOURMULT | 1646 | addgold := uinfo.Goldrate * ZHENGHOURMULT |
1621 | uinfo.Gold += addgold | 1647 | uinfo.Gold += addgold |
1622 | - uinfo.LastTimingRewardHour = nowh | 1648 | + uinfo.LastTimingRewardHour++ |
1649 | + uinfo.LeftTimingRewardTimes-- | ||
1623 | //uinfo.GetWatchAdsGoldTime-- | 1650 | //uinfo.GetWatchAdsGoldTime-- |
1624 | 1651 | ||
1625 | SaveUserInfo(uinfo, strconv.Itoa(uuid)) | 1652 | SaveUserInfo(uinfo, strconv.Itoa(uuid)) |