Commit d26b6cc922b7e3248818470febdd086c6a1353c2
1 parent
72603731
Exists in
master
提交
Showing
2 changed files
with
53 additions
and
11 deletions
Show diff stats
src/HttpServer/logic/function.go
| ... | ... | @@ -615,15 +615,25 @@ func MergeRedBagCat(uinfo *UserData, pos int) int { |
| 615 | 615 | |
| 616 | 616 | //走随机合成逻辑 |
| 617 | 617 | sumrate := float32(0) |
| 618 | + var reallist []jsonconf.RedCatDesc | |
| 618 | 619 | for _, v := range jsonconf.GetJsonConf().RedCatConfig { |
| 619 | 620 | sumrate += v.Rate |
| 621 | + if v.Rate > 0 { | |
| 622 | + reallist = append(reallist, v) | |
| 623 | + } | |
| 624 | + } | |
| 625 | + if len(reallist) == 0 { | |
| 626 | + logger.Error("MergeRedBagCat nil") | |
| 627 | + return 0 | |
| 620 | 628 | } |
| 621 | 629 | rand.Seed(time.Now().UnixNano()) |
| 622 | 630 | randnum := rand.Intn(100) |
| 631 | + index := -1 | |
| 623 | 632 | tmprate := 0 |
| 624 | - for _, v := range jsonconf.GetJsonConf().RedCatConfig { | |
| 633 | + for k, v := range reallist { | |
| 625 | 634 | tmprate += int(v.Rate * 100 / sumrate) |
| 626 | 635 | if tmprate >= randnum { |
| 636 | + index = k | |
| 627 | 637 | uinfo.PosInfo[pos].Position = pos |
| 628 | 638 | uinfo.PosInfo[pos].Cat = REDCATIDEXTRA + v.Id |
| 629 | 639 | if v.Id == 13 { |
| ... | ... | @@ -644,6 +654,14 @@ func MergeRedBagCat(uinfo *UserData, pos int) int { |
| 644 | 654 | } |
| 645 | 655 | } |
| 646 | 656 | |
| 657 | + if index == -1 { | |
| 658 | + //没有找到 直接获得第一个 | |
| 659 | + uinfo.PosInfo[pos].Cat = reallist[0].Id + REDCATIDEXTRA | |
| 660 | + uinfo.PosInfo[pos].RedPacket = reallist[0].Money | |
| 661 | + uinfo.PosInfo[pos].Position = pos | |
| 662 | + rtpos = pos | |
| 663 | + } | |
| 664 | + | |
| 647 | 665 | //翻拍次数+ |
| 648 | 666 | uinfo.FlopCardLefCnt++ |
| 649 | 667 | return rtpos |
| ... | ... | @@ -653,7 +671,27 @@ func (uinfo *UserData) CheckBuyCatSHop() { |
| 653 | 671 | //检查可购买的猫是否会增加 |
| 654 | 672 | //需要扩充一下商店 |
| 655 | 673 | curshoplv := len(uinfo.BuyCatInfo) |
| 656 | - if uinfo.Highestlv-5 > curshoplv { | |
| 674 | + //获取最高猫的配置 | |
| 675 | + highcfg := jsonconf.GetCatConfig(uinfo.Highestlv) | |
| 676 | + if highcfg == nil { | |
| 677 | + logger.Error("CheckBuyCatSHop err nil") | |
| 678 | + return | |
| 679 | + } | |
| 680 | + | |
| 681 | + if highcfg.Level_buy > curshoplv { | |
| 682 | + offset := highcfg.Level_buy - curshoplv | |
| 683 | + for i := 0; i < offset; i++ { | |
| 684 | + var info BuyCatInfoData | |
| 685 | + info.Buytime = 0 | |
| 686 | + cafcfg := jsonconf.GetCatConfig(curshoplv + i + 1) | |
| 687 | + if cafcfg != nil { | |
| 688 | + info.CurPrice, _ = strconv.ParseInt(cafcfg.Price, 10, 64) | |
| 689 | + } | |
| 690 | + info.IsMaxBuytime = 0 | |
| 691 | + uinfo.BuyCatInfo = append(uinfo.BuyCatInfo, info) | |
| 692 | + } | |
| 693 | + } | |
| 694 | + /*if uinfo.Highestlv-5 > curshoplv { | |
| 657 | 695 | var info BuyCatInfoData |
| 658 | 696 | info.Buytime = 0 |
| 659 | 697 | cafcfg := jsonconf.GetCatConfig(uinfo.Highestlv - 5) |
| ... | ... | @@ -662,7 +700,7 @@ func (uinfo *UserData) CheckBuyCatSHop() { |
| 662 | 700 | } |
| 663 | 701 | info.IsMaxBuytime = 0 |
| 664 | 702 | uinfo.BuyCatInfo = append(uinfo.BuyCatInfo, info) |
| 665 | - } | |
| 703 | + }*/ | |
| 666 | 704 | } |
| 667 | 705 | |
| 668 | 706 | func (udata *UserData) CalcGoldRate() int64 { | ... | ... |
src/HttpServer/logic/logic.go
| ... | ... | @@ -857,12 +857,15 @@ func HandlerLimitCatList(w http.ResponseWriter, data string, uuid int) { |
| 857 | 857 | if pos >= 0 && pos < len(uinfo.PosInfo) { |
| 858 | 858 | //如果可领取了再加入列表 |
| 859 | 859 | if nowtime > uinfo.PosInfo[pos].StartTime+uinfo.PosInfo[pos].Time { |
| 860 | - var tmp LimitCatListData | |
| 861 | - tmp.CatId = uinfo.PosInfo[pos].Cat | |
| 862 | - tmp.Status = 0 | |
| 863 | - tmp.Cash = uinfo.PosInfo[pos].RedPacket | |
| 864 | - tmp.Date = time.Now().Format("2006-01-02T 15:04:05") | |
| 865 | - resp.Data = append(resp.Data, tmp) | |
| 860 | + if uinfo.PosInfo[pos].RedPacket > 0 { | |
| 861 | + var tmp LimitCatListData | |
| 862 | + tmp.CatId = uinfo.PosInfo[pos].Cat | |
| 863 | + tmp.Status = 0 | |
| 864 | + tmp.Cash = uinfo.PosInfo[pos].RedPacket | |
| 865 | + tmp.Date = time.Now().Format("2006-01-02T 15:04:05") | |
| 866 | + resp.Data = append(resp.Data, tmp) | |
| 867 | + } | |
| 868 | + | |
| 866 | 869 | } else { |
| 867 | 870 | logger.Info("HandlerLimitCatList nowtime=%v,endtime=%v", nowtime, uinfo.PosInfo[pos].StartTime+uinfo.PosInfo[pos].Time) |
| 868 | 871 | } |
| ... | ... | @@ -1180,7 +1183,7 @@ func HandlerRecvTimingReward(w http.ResponseWriter, data string, uuid int) { |
| 1180 | 1183 | addgold := uinfo.Goldrate * ZHENGHOURMULT |
| 1181 | 1184 | uinfo.Gold += addgold |
| 1182 | 1185 | uinfo.LastTimingRewardHour = nowh |
| 1183 | - uinfo.GetWatchAdsGoldTime-- | |
| 1186 | + //uinfo.GetWatchAdsGoldTime-- | |
| 1184 | 1187 | |
| 1185 | 1188 | SaveUserInfo(uinfo, strconv.Itoa(uuid)) |
| 1186 | 1189 | |
| ... | ... | @@ -1418,7 +1421,8 @@ func HandlerExchangePos(w http.ResponseWriter, data string, uuid int) { |
| 1418 | 1421 | if uinfo.PosInfo[rdata.From].Cat == 36 { |
| 1419 | 1422 | //todo 走红包猫的逻辑 |
| 1420 | 1423 | MergeRedBagCat(uinfo, rdata.From) |
| 1421 | - DoAutoMergeRedCat(uinfo, uuid) | |
| 1424 | + uinfo.CleadPos(rdata.To) | |
| 1425 | + //DoAutoMergeRedCat(uinfo, uuid) | |
| 1422 | 1426 | //此处处理一下红包猫的自动合成逻辑 |
| 1423 | 1427 | if uinfo.Highestlv < 37 { |
| 1424 | 1428 | //非红包猫 | ... | ... |