Commit c2bc0824abc2e385943b0d262da70e5783101689

Authored by 王家文
1 parent 23f685c4
Exists in master and in 1 other branch dev-wjw

feat✨:游戏功能配置

configs/conf-cardholder-decode.go
@@ -1,169 +0,0 @@ @@ -1,169 +0,0 @@
1 -package configs  
2 -  
3 -import (  
4 - "apigame/util/util-lx/lxalilog"  
5 - "encoding/json"  
6 - "errors"  
7 - "fmt"  
8 - "strings"  
9 -)  
10 -  
11 -// Decode 解析配置原始数据  
12 -func (c *CardActivityConfig) Decode(gameId string, configRaw *CardActivityConfigRaw) {  
13 - c.GameId = gameId  
14 - c.Raw = configRaw  
15 -  
16 - c.Id = configRaw.Id  
17 - c.OpenLevel = configRaw.OpenLevel  
18 - c.PreviewTime = configRaw.PreviewTime  
19 - c.StartTime = configRaw.StartTime  
20 - c.EndTime = configRaw.EndTime  
21 - c.Round = configRaw.Round  
22 -  
23 - c.Awards = make(map[string]string)  
24 - c.AlbumConfig = make(map[int]AlbumConfig)  
25 - c.CardConfig = make(map[int]CardConfig)  
26 - c.CardholderConfig = make(map[string]OpenCardholderConfig)  
27 - c.NormalCardStarConfig = make(map[string]NormalCardStarConfig)  
28 - c.CardSequenceConfig = make(map[string]CardSequenceConfig)  
29 - c.StarShopConfig = make(map[int]StarShopConfig)  
30 - // 解析奖励  
31 - {  
32 - err := json.Unmarshal([]byte(configRaw.Awards), &c.Awards)  
33 - if err != nil {  
34 - lxalilog.Errors(err, configRaw.Awards, gameId, configRaw.Id)  
35 - return  
36 - }  
37 - }  
38 - // 卡组配置  
39 - {  
40 - configs := make([]AlbumConfig, 0)  
41 - err := json.Unmarshal([]byte(configRaw.AlbumConfig), &configs)  
42 - if err != nil {  
43 - lxalilog.Errors(err, configRaw.AlbumConfig, gameId, configRaw.Id)  
44 - return  
45 - }  
46 - for _, i2 := range configs {  
47 - c.AlbumConfig[i2.SetId] = i2  
48 - }  
49 - }  
50 - // 卡牌配置  
51 - {  
52 - configs := make([]CardConfig, 0)  
53 - err := json.Unmarshal([]byte(configRaw.CardConfig), &configs)  
54 - if err != nil {  
55 - lxalilog.Errors(err, configRaw.CardConfig, gameId, configRaw.Id)  
56 - return  
57 - }  
58 - for _, i2 := range configs {  
59 - c.CardConfig[i2.Id] = i2  
60 - }  
61 - }  
62 - // 卡包开卡规则  
63 - {  
64 - configs := make([]OpenCardholderConfig, 0)  
65 - err := json.Unmarshal([]byte(configRaw.CardHolderConfig), &configs)  
66 - if err != nil {  
67 - lxalilog.Errors(err, configRaw.CardHolderConfig, gameId, configRaw.Id)  
68 - return  
69 - }  
70 - for _, i2 := range configs {  
71 - c.CardholderConfig[i2.Id] = i2  
72 - }  
73 - }  
74 - // 卡片星级配置  
75 - {  
76 - configs := make([]NormalCardStarConfig, 0)  
77 - err := json.Unmarshal([]byte(configRaw.NormalCardStarSequence), &configs)  
78 - if err != nil {  
79 - lxalilog.Errors(err, configRaw.NormalCardStarSequence, gameId, configRaw.Id)  
80 - return  
81 - }  
82 - for _, i2 := range configs {  
83 - i2.NormalCardSequenceIds = strings.Split(i2.NormalCardSequenceId, ",")  
84 - combineId := CombineIdSequenceIdCohort(i2.Id, i2.SequenceId, i2.Cohort)  
85 - c.NormalCardStarConfig[combineId] = i2  
86 - }  
87 - }  
88 - // 卡片星级对应卡牌配置  
89 - {  
90 - configs := make([]CardSequenceConfig, 0)  
91 - err := json.Unmarshal([]byte(configRaw.CardSequenceConfig), &configs)  
92 - if err != nil {  
93 - lxalilog.Errors(err, configRaw.CardSequenceConfig, gameId, configRaw.Id)  
94 - return  
95 - }  
96 - for _, i2 := range configs {  
97 - i2.CardIdLists = strings.Split(i2.CardIdList, ",")  
98 - combineId := CombineIdSequenceIdCohort(i2.Id, i2.SequenceId, i2.Cohort)  
99 - c.CardSequenceConfig[combineId] = i2  
100 - }  
101 - }  
102 - // 星星商店配置  
103 - {  
104 - configs := make([]StarShopConfig, 0)  
105 - err := json.Unmarshal([]byte(configRaw.StarShopConfig), &configs)  
106 - if err != nil {  
107 - lxalilog.Errors(err, configRaw.StarShopConfig, gameId, configRaw.Id)  
108 - return  
109 - }  
110 - for _, i2 := range configs {  
111 - c.StarShopConfig[i2.Id] = i2  
112 - }  
113 - }  
114 -  
115 - c.GenerateConfigClient()  
116 -}  
117 -  
118 -// GenerateConfigClient 生成给客户端的配置  
119 -func (c *CardActivityConfig) GenerateConfigClient() {  
120 - configClient := &CardActivityConfigClient{  
121 - Id: c.Id,  
122 - RoundAwards: c.Awards,  
123 - Albums: make([]AlbumConfig, 0),  
124 - Cards: make([]CardConfig, 0),  
125 - Holders: make([]OpenCardholderConfig, 0),  
126 - StarShop: make([]StarShopConfig, 0),  
127 - }  
128 - for _, i2 := range c.AlbumConfig {  
129 - configClient.Albums = append(configClient.Albums, i2)  
130 - }  
131 - for _, i2 := range c.CardConfig {  
132 - configClient.Cards = append(configClient.Cards, i2)  
133 - }  
134 - for _, i2 := range c.CardholderConfig {  
135 - configClient.Holders = append(configClient.Holders, i2)  
136 - }  
137 - for _, i2 := range c.StarShopConfig {  
138 - configClient.StarShop = append(configClient.StarShop, i2)  
139 - }  
140 - c.Client = configClient  
141 -}  
142 -  
143 -// CombineIdSequenceIdCohort 组合ID k=ID_用户序列_用户分组  
144 -func CombineIdSequenceIdCohort(id, sequenceId, cohort string) string {  
145 - return fmt.Sprintf("%s_%s_%s", id, sequenceId, cohort)  
146 -}  
147 -  
148 -// FindNormalCardStarConfig 查找配置 非保底卡星级ID  
149 -func (c *CardActivityConfig) FindNormalCardStarConfig(id, sequenceId, cohort string) (conf NormalCardStarConfig, has bool) {  
150 - combineId := CombineIdSequenceIdCohort(id, sequenceId, cohort)  
151 - conf, has = c.NormalCardStarConfig[combineId]  
152 - if !has {  
153 - lxalilog.Errors(errors.New("ht_cardholder NormalCardStarConfig error"), id, sequenceId, cohort)  
154 - }  
155 - return  
156 -}  
157 -  
158 -// FindCardSequenceConfig 查找配置 星级ID对应的卡片  
159 -func (c *CardActivityConfig) FindCardSequenceConfig(id, sequenceId, cohort string) (conf CardSequenceConfig, has bool) {  
160 - combineId := CombineIdSequenceIdCohort(id, sequenceId, cohort)  
161 - conf, has = c.CardSequenceConfig[combineId]  
162 - if !has {  
163 - lxalilog.Errors(errors.New("ht_cardholder CardSequenceConfig error"), id, sequenceId, cohort)  
164 - fmt.Println(id)  
165 - fmt.Println(sequenceId)  
166 - fmt.Println(cohort)  
167 - }  
168 - return  
169 -}  
configs/conf-cardholder.go
@@ -1,137 +0,0 @@ @@ -1,137 +0,0 @@
1 -package configs  
2 -  
3 -import (  
4 - "apigame/service-common/svconst"  
5 - "apigame/service-common/svmysql"  
6 - "apigame/service-common/svredis"  
7 - "fmt"  
8 -)  
9 -  
10 -// CardActivityConfig 卡牌活动配置 分析后数据  
11 -type CardActivityConfig struct {  
12 - Raw *CardActivityConfigRaw `json:"-"`  
13 -  
14 - Id int64 // ID  
15 - OpenLevel int // 开启等级  
16 - PreviewTime int64 // 预告时间  
17 - StartTime int64 // 开始时间  
18 - EndTime int64 // 结束时间  
19 - Round int // 轮数  
20 -  
21 - Awards map[string]string // 奖励配置  
22 - AlbumConfig map[int]AlbumConfig // 卡组配置  
23 - CardConfig map[int]CardConfig // 卡牌配置  
24 - CardholderConfig map[string]OpenCardholderConfig // 卡包开卡规则  
25 - NormalCardStarConfig map[string]NormalCardStarConfig // k=ID_用户序列_用户分组 卡片星级配置  
26 - CardSequenceConfig map[string]CardSequenceConfig // k=ID_用户序列_用户分组 卡片星级对应卡牌配置  
27 - StarShopConfig map[int]StarShopConfig // 星星商店配置  
28 -  
29 - Client *CardActivityConfigClient  
30 - GameId string // 所属游戏ID  
31 -}  
32 -  
33 -func (c *CardActivityConfig) RedisInfo(suffix string) *svredis.RedisInfo {  
34 - tableName := svconst.MYSQL_TABLE_S_CARDHOLDER_CONFIG  
35 - return &svredis.RedisInfo{  
36 - CacheKey: fmt.Sprintf("%s:%s:%s", svconst.REDIS_CACHEP_REFIX, tableName, suffix),  
37 - CacheTime: 300,  
38 - }  
39 -}  
40 -  
41 -// CardActivityConfigRaw 卡牌活动配置 原始数据  
42 -type CardActivityConfigRaw struct {  
43 - Id int64 // ID  
44 - OpenLevel int // 开启等级  
45 - PreviewTime int64 // 预告时间  
46 - StartTime int64 // 开始时间  
47 - EndTime int64 // 结束时间  
48 - Round int // 轮数  
49 -  
50 - Awards string // 奖励配置  
51 - AlbumConfig string // 卡组配置  
52 - CardConfig string // 卡牌配置  
53 - CardHolderConfig string // 卡包开卡规则  
54 - NormalCardStarSequence string // 卡片星级配置  
55 - CardSequenceConfig string // 卡片星级对应卡牌配置  
56 - StarShopConfig string // 星星商店配置  
57 -  
58 - Ver string // 版本号  
59 - Status int // 状态 0=关闭 1=开启  
60 - UpdateTime int64 // 修改时间戳  
61 -}  
62 -  
63 -func (c *CardActivityConfigRaw) MysqlInfo(suffix string) *svmysql.MysqlInfo {  
64 - tableName := svconst.MYSQL_TABLE_S_CARDHOLDER_CONFIG  
65 - return &svmysql.MysqlInfo{  
66 - DbMysql: svconst.DbConfig.Where("status = ?", 1),  
67 - TableName: fmt.Sprintf("%s_%s", tableName, suffix),  
68 - }  
69 -}  
70 -  
71 -// CardActivityConfigClient 卡牌活动配置 给客户端数据  
72 -type CardActivityConfigClient struct {  
73 - Id int64 `form:"id" json:"id"` // ID  
74 - RoundAwards map[string]string `form:"round_awards" json:"round_awards"` // 轮次奖励配置  
75 - Albums []AlbumConfig `form:"albums" json:"albums"` // 卡组配置  
76 - Cards []CardConfig `form:"cards" json:"cards"` // 卡牌配置  
77 - Holders []OpenCardholderConfig `form:"holders" json:"holders"` // 卡包开卡规则  
78 - StarShop []StarShopConfig `form:"star_shop" json:"star_shop"` // 星星商店配置  
79 -}  
80 -  
81 -// AlbumConfig 卡组表  
82 -type AlbumConfig struct {  
83 - SetId int `json:"set_id"` // 卡组名  
84 - Name int `json:"name"` // 卡组图片  
85 - Icon string `json:"icon"` // 卡组id  
86 - Rewards map[string]string `json:"rewards"` // 集齐奖励 k=轮次  
87 - StartTime int64 `json:"start_time"` // 开始时间  
88 - EndTime int64 `json:"end_time"` // 结束时间  
89 -}  
90 -  
91 -// CardConfig 卡牌表  
92 -type CardConfig struct {  
93 - Id int `json:"id"` // ID  
94 - Name int `json:"name"` // 卡牌名字  
95 - Icon int `json:"icon"` // 卡牌图标  
96 - Desc int `json:"desc"` // 卡牌描述  
97 - SetId int `json:"album_setid"` // 卡组id  
98 - Star int `json:"star"` // 星级  
99 - IsGold int `json:"is_gold"` // 是否是金卡  
100 - IsSend int `json:"is_send"` // 卡片是否可赠送  
101 -}  
102 -  
103 -// OpenCardholderConfig 卡包开卡规则表  
104 -type OpenCardholderConfig struct {  
105 - Id string `json:"id"` // ID  
106 - IsGoldCardholder int `json:"is_gold_card_holder"` // 是否是金卡包  
107 - IsNew int `json:"is_new"` // 是否是新卡包  
108 - GuaranteedStarCardId string `json:"guaranteed_star_card_id"` // 保底卡星级序列ID  
109 - NormalCardNumber int `json:"normal_card_number"` // 非保底卡数量  
110 - MinimumGuaranteeCardId string `json:"minimum_guarantee_card_id"` // 非保底卡牌序列ID  
111 - ActivityId int `json:"activity_id"` // 对应活动ID  
112 -}  
113 -  
114 -// NormalCardStarConfig 非保底卡星级ID  
115 -type NormalCardStarConfig struct {  
116 - Id string `json:"id"` // ID  
117 - SequenceId string `json:"user_sequence_id"` // 用户序列组ID  
118 - Cohort string `json:"cohort"` // 用户分组  
119 - NormalCardSequenceId string `json:"normal_card_sequence_id"` // 非保底星级序列  
120 - NormalCardSequenceIds []string `json:"normal_card_sequence_ids"` // 非保底星级序列  
121 -}  
122 -  
123 -// CardSequenceConfig 星级ID对应的卡片  
124 -type CardSequenceConfig struct {  
125 - Id string `json:"id"` // ID  
126 - SequenceId string `json:"user_sequence_id"` // 用户序列组ID  
127 - Cohort string `json:"cohort"` // 用户分组  
128 - CardIdList string `json:"card_id_list"` // 卡牌抽取序列  
129 - CardIdLists []string `json:"card_id_lists"` // 卡牌抽取序列  
130 -}  
131 -  
132 -// StarShopConfig 星星商店配置  
133 -type StarShopConfig struct {  
134 - Id int `json:"id"` // ID  
135 - NeedStarNumber int `json:"need_star_number"` // 需求星星数  
136 - CardBagIds []int `json:"card_bag_ids"` // 可换取的卡包ID {卡包类型,卡包ID,卡包数量}  
137 -}  
configs/conf-roomrank.go
@@ -34,7 +34,7 @@ func (c *RoomRankConfig) RedisInfo(suffix string) *svredis.RedisInfo { @@ -34,7 +34,7 @@ func (c *RoomRankConfig) RedisInfo(suffix string) *svredis.RedisInfo {
34 34
35 // RoomRankConfigRaw 房间排行活动配置 原始数据 35 // RoomRankConfigRaw 房间排行活动配置 原始数据
36 type RoomRankConfigRaw struct { 36 type RoomRankConfigRaw struct {
37 - Id int64 // ID 37 + Id int64 `gorm:"column:id;primaryKey"` // ID
38 OpenLevel int // 开启等级 38 OpenLevel int // 开启等级
39 PreviewTime int64 // 预告时间 39 PreviewTime int64 // 预告时间
40 StartTime int64 // 开始时间 40 StartTime int64 // 开始时间
configs/confcardholder/config.go 0 → 100644
@@ -0,0 +1,137 @@ @@ -0,0 +1,137 @@
  1 +package confcardholder
  2 +
  3 +import (
  4 + "apigame/service-common/svconst"
  5 + "apigame/service-common/svmysql"
  6 + "apigame/service-common/svredis"
  7 + "fmt"
  8 +)
  9 +
  10 +// ActivityConfig 卡牌活动配置 分析后数据
  11 +type ActivityConfig struct {
  12 + Raw *ActivityConfigRaw `json:"-"`
  13 +
  14 + Id int64 // ID
  15 + OpenLevel int // 开启等级
  16 + PreviewTime int64 // 预告时间
  17 + StartTime int64 // 开始时间
  18 + EndTime int64 // 结束时间
  19 + Round int // 轮数
  20 +
  21 + Awards map[string]string // 奖励配置
  22 + AlbumConfig map[int]AlbumConfig // 卡组配置
  23 + CardConfig map[int]CardConfig // 卡牌配置
  24 + CardholderConfig map[string]OpenCardholderConfig // 卡包开卡规则
  25 + NormalCardStarConfig map[string]NormalCardStarConfig // k=ID_用户序列_用户分组 卡片星级配置
  26 + CardSequenceConfig map[string]CardSequenceConfig // k=ID_用户序列_用户分组 卡片星级对应卡牌配置
  27 + StarShopConfig map[int]StarShopConfig // 星星商店配置
  28 +
  29 + Client *CardActivityConfigClient
  30 + GameId string // 所属游戏ID
  31 +}
  32 +
  33 +func (c *ActivityConfig) RedisInfo(suffix string) *svredis.RedisInfo {
  34 + tableName := svconst.MYSQL_TABLE_S_CARDHOLDER_CONFIG
  35 + return &svredis.RedisInfo{
  36 + CacheKey: fmt.Sprintf("%s:%s:%s:%d", svconst.REDIS_CACHEP_REFIX, tableName, suffix, c.Id),
  37 + CacheTime: 300,
  38 + }
  39 +}
  40 +
  41 +// ActivityConfigRaw 卡牌活动配置 原始数据
  42 +type ActivityConfigRaw struct {
  43 + Id int64 `gorm:"column:id;primaryKey"` // ID
  44 + OpenLevel int // 开启等级
  45 + PreviewTime int64 // 预告时间
  46 + StartTime int64 // 开始时间
  47 + EndTime int64 // 结束时间
  48 + Round int // 轮数
  49 +
  50 + Awards string // 奖励配置
  51 + AlbumConfig string // 卡组配置
  52 + CardConfig string // 卡牌配置
  53 + CardHolderConfig string // 卡包开卡规则
  54 + NormalCardStarSequence string // 卡片星级配置
  55 + CardSequenceConfig string // 卡片星级对应卡牌配置
  56 + StarShopConfig string // 星星商店配置
  57 +
  58 + Ver string // 版本号
  59 + Status int // 状态 0=关闭 1=开启
  60 + UpdateTime int64 // 修改时间戳
  61 +}
  62 +
  63 +func (c *ActivityConfigRaw) MysqlInfo(suffix string) *svmysql.MysqlInfo {
  64 + tableName := svconst.MYSQL_TABLE_S_CARDHOLDER_CONFIG
  65 + return &svmysql.MysqlInfo{
  66 + DbMysql: svconst.DbConfig,
  67 + TableName: fmt.Sprintf("%s_%s", tableName, suffix),
  68 + }
  69 +}
  70 +
  71 +// CardActivityConfigClient 卡牌活动配置 给客户端数据
  72 +type CardActivityConfigClient struct {
  73 + Id int64 `form:"id" json:"id"` // ID
  74 + RoundAwards map[string]string `form:"round_awards" json:"round_awards"` // 轮次奖励配置
  75 + Albums []AlbumConfig `form:"albums" json:"albums"` // 卡组配置
  76 + Cards []CardConfig `form:"cards" json:"cards"` // 卡牌配置
  77 + Holders []OpenCardholderConfig `form:"holders" json:"holders"` // 卡包开卡规则
  78 + StarShop []StarShopConfig `form:"star_shop" json:"star_shop"` // 星星商店配置
  79 +}
  80 +
  81 +// AlbumConfig 卡组表
  82 +type AlbumConfig struct {
  83 + SetId int `json:"set_id"` // 卡组名
  84 + Name int `json:"name"` // 卡组图片
  85 + Icon string `json:"icon"` // 卡组id
  86 + Rewards map[string]string `json:"rewards"` // 集齐奖励 k=轮次
  87 + StartTime int64 `json:"start_time"` // 开始时间
  88 + EndTime int64 `json:"end_time"` // 结束时间
  89 +}
  90 +
  91 +// CardConfig 卡牌表
  92 +type CardConfig struct {
  93 + Id int `json:"id"` // ID
  94 + Name int `json:"name"` // 卡牌名字
  95 + Icon int `json:"icon"` // 卡牌图标
  96 + Desc int `json:"desc"` // 卡牌描述
  97 + SetId int `json:"album_setid"` // 卡组id
  98 + Star int `json:"star"` // 星级
  99 + IsGold int `json:"is_gold"` // 是否是金卡
  100 + IsSend int `json:"is_send"` // 卡片是否可赠送
  101 +}
  102 +
  103 +// OpenCardholderConfig 卡包开卡规则表
  104 +type OpenCardholderConfig struct {
  105 + Id string `json:"id"` // ID
  106 + IsGoldCardholder int `json:"is_gold_card_holder"` // 是否是金卡包
  107 + IsNew int `json:"is_new"` // 是否是新卡包
  108 + GuaranteedStarCardId string `json:"guaranteed_star_card_id"` // 保底卡星级序列ID
  109 + NormalCardNumber int `json:"normal_card_number"` // 非保底卡数量
  110 + MinimumGuaranteeCardId string `json:"minimum_guarantee_card_id"` // 非保底卡牌序列ID
  111 + ActivityId int `json:"activity_id"` // 对应活动ID
  112 +}
  113 +
  114 +// NormalCardStarConfig 非保底卡星级ID
  115 +type NormalCardStarConfig struct {
  116 + Id string `json:"id"` // ID
  117 + SequenceId string `json:"user_sequence_id"` // 用户序列组ID
  118 + Cohort string `json:"cohort"` // 用户分组
  119 + NormalCardSequenceId string `json:"normal_card_sequence_id"` // 非保底星级序列
  120 + NormalCardSequenceIds []string `json:"normal_card_sequence_ids"` // 非保底星级序列
  121 +}
  122 +
  123 +// CardSequenceConfig 星级ID对应的卡片
  124 +type CardSequenceConfig struct {
  125 + Id string `json:"id"` // ID
  126 + SequenceId string `json:"user_sequence_id"` // 用户序列组ID
  127 + Cohort string `json:"cohort"` // 用户分组
  128 + CardIdList string `json:"card_id_list"` // 卡牌抽取序列
  129 + CardIdLists []string `json:"card_id_lists"` // 卡牌抽取序列
  130 +}
  131 +
  132 +// StarShopConfig 星星商店配置
  133 +type StarShopConfig struct {
  134 + Id int `json:"id"` // ID
  135 + NeedStarNumber int `json:"need_star_number"` // 需求星星数
  136 + CardBagIds []int `json:"card_bag_ids"` // 可换取的卡包ID {卡包类型,卡包ID,卡包数量}
  137 +}
configs/confcardholder/decode.go 0 → 100644
@@ -0,0 +1,169 @@ @@ -0,0 +1,169 @@
  1 +package confcardholder
  2 +
  3 +import (
  4 + "apigame/util/util-lx/lxalilog"
  5 + "encoding/json"
  6 + "errors"
  7 + "fmt"
  8 + "strings"
  9 +)
  10 +
  11 +// Decode 解析配置原始数据
  12 +func (c *ActivityConfig) Decode(gameId string, configRaw *ActivityConfigRaw) {
  13 + c.GameId = gameId
  14 + c.Raw = configRaw
  15 +
  16 + c.Id = configRaw.Id
  17 + c.OpenLevel = configRaw.OpenLevel
  18 + c.PreviewTime = configRaw.PreviewTime
  19 + c.StartTime = configRaw.StartTime
  20 + c.EndTime = configRaw.EndTime
  21 + c.Round = configRaw.Round
  22 +
  23 + c.Awards = make(map[string]string)
  24 + c.AlbumConfig = make(map[int]AlbumConfig)
  25 + c.CardConfig = make(map[int]CardConfig)
  26 + c.CardholderConfig = make(map[string]OpenCardholderConfig)
  27 + c.NormalCardStarConfig = make(map[string]NormalCardStarConfig)
  28 + c.CardSequenceConfig = make(map[string]CardSequenceConfig)
  29 + c.StarShopConfig = make(map[int]StarShopConfig)
  30 + // 解析奖励
  31 + {
  32 + err := json.Unmarshal([]byte(configRaw.Awards), &c.Awards)
  33 + if err != nil {
  34 + lxalilog.Errors(err, configRaw.Awards, gameId, configRaw.Id)
  35 + return
  36 + }
  37 + }
  38 + // 卡组配置
  39 + {
  40 + configs := make([]AlbumConfig, 0)
  41 + err := json.Unmarshal([]byte(configRaw.AlbumConfig), &configs)
  42 + if err != nil {
  43 + lxalilog.Errors(err, configRaw.AlbumConfig, gameId, configRaw.Id)
  44 + return
  45 + }
  46 + for _, i2 := range configs {
  47 + c.AlbumConfig[i2.SetId] = i2
  48 + }
  49 + }
  50 + // 卡牌配置
  51 + {
  52 + configs := make([]CardConfig, 0)
  53 + err := json.Unmarshal([]byte(configRaw.CardConfig), &configs)
  54 + if err != nil {
  55 + lxalilog.Errors(err, configRaw.CardConfig, gameId, configRaw.Id)
  56 + return
  57 + }
  58 + for _, i2 := range configs {
  59 + c.CardConfig[i2.Id] = i2
  60 + }
  61 + }
  62 + // 卡包开卡规则
  63 + {
  64 + configs := make([]OpenCardholderConfig, 0)
  65 + err := json.Unmarshal([]byte(configRaw.CardHolderConfig), &configs)
  66 + if err != nil {
  67 + lxalilog.Errors(err, configRaw.CardHolderConfig, gameId, configRaw.Id)
  68 + return
  69 + }
  70 + for _, i2 := range configs {
  71 + c.CardholderConfig[i2.Id] = i2
  72 + }
  73 + }
  74 + // 卡片星级配置
  75 + {
  76 + configs := make([]NormalCardStarConfig, 0)
  77 + err := json.Unmarshal([]byte(configRaw.NormalCardStarSequence), &configs)
  78 + if err != nil {
  79 + lxalilog.Errors(err, configRaw.NormalCardStarSequence, gameId, configRaw.Id)
  80 + return
  81 + }
  82 + for _, i2 := range configs {
  83 + i2.NormalCardSequenceIds = strings.Split(i2.NormalCardSequenceId, ",")
  84 + combineId := CombineIdSequenceIdCohort(i2.Id, i2.SequenceId, i2.Cohort)
  85 + c.NormalCardStarConfig[combineId] = i2
  86 + }
  87 + }
  88 + // 卡片星级对应卡牌配置
  89 + {
  90 + configs := make([]CardSequenceConfig, 0)
  91 + err := json.Unmarshal([]byte(configRaw.CardSequenceConfig), &configs)
  92 + if err != nil {
  93 + lxalilog.Errors(err, configRaw.CardSequenceConfig, gameId, configRaw.Id)
  94 + return
  95 + }
  96 + for _, i2 := range configs {
  97 + i2.CardIdLists = strings.Split(i2.CardIdList, ",")
  98 + combineId := CombineIdSequenceIdCohort(i2.Id, i2.SequenceId, i2.Cohort)
  99 + c.CardSequenceConfig[combineId] = i2
  100 + }
  101 + }
  102 + // 星星商店配置
  103 + {
  104 + configs := make([]StarShopConfig, 0)
  105 + err := json.Unmarshal([]byte(configRaw.StarShopConfig), &configs)
  106 + if err != nil {
  107 + lxalilog.Errors(err, configRaw.StarShopConfig, gameId, configRaw.Id)
  108 + return
  109 + }
  110 + for _, i2 := range configs {
  111 + c.StarShopConfig[i2.Id] = i2
  112 + }
  113 + }
  114 +
  115 + c.GenerateConfigClient()
  116 +}
  117 +
  118 +// GenerateConfigClient 生成给客户端的配置
  119 +func (c *ActivityConfig) GenerateConfigClient() {
  120 + configClient := &CardActivityConfigClient{
  121 + Id: c.Id,
  122 + RoundAwards: c.Awards,
  123 + Albums: make([]AlbumConfig, 0),
  124 + Cards: make([]CardConfig, 0),
  125 + Holders: make([]OpenCardholderConfig, 0),
  126 + StarShop: make([]StarShopConfig, 0),
  127 + }
  128 + for _, i2 := range c.AlbumConfig {
  129 + configClient.Albums = append(configClient.Albums, i2)
  130 + }
  131 + for _, i2 := range c.CardConfig {
  132 + configClient.Cards = append(configClient.Cards, i2)
  133 + }
  134 + for _, i2 := range c.CardholderConfig {
  135 + configClient.Holders = append(configClient.Holders, i2)
  136 + }
  137 + for _, i2 := range c.StarShopConfig {
  138 + configClient.StarShop = append(configClient.StarShop, i2)
  139 + }
  140 + c.Client = configClient
  141 +}
  142 +
  143 +// CombineIdSequenceIdCohort 组合ID k=ID_用户序列_用户分组
  144 +func CombineIdSequenceIdCohort(id, sequenceId, cohort string) string {
  145 + return fmt.Sprintf("%s_%s_%s", id, sequenceId, cohort)
  146 +}
  147 +
  148 +// FindNormalCardStarConfig 查找配置 非保底卡星级ID
  149 +func (c *ActivityConfig) FindNormalCardStarConfig(id, sequenceId, cohort string) (conf NormalCardStarConfig, has bool) {
  150 + combineId := CombineIdSequenceIdCohort(id, sequenceId, cohort)
  151 + conf, has = c.NormalCardStarConfig[combineId]
  152 + if !has {
  153 + lxalilog.Errors(errors.New("ht_cardholder NormalCardStarConfig error"), id, sequenceId, cohort)
  154 + }
  155 + return
  156 +}
  157 +
  158 +// FindCardSequenceConfig 查找配置 星级ID对应的卡片
  159 +func (c *ActivityConfig) FindCardSequenceConfig(id, sequenceId, cohort string) (conf CardSequenceConfig, has bool) {
  160 + combineId := CombineIdSequenceIdCohort(id, sequenceId, cohort)
  161 + conf, has = c.CardSequenceConfig[combineId]
  162 + if !has {
  163 + lxalilog.Errors(errors.New("ht_cardholder CardSequenceConfig error"), id, sequenceId, cohort)
  164 + fmt.Println(id)
  165 + fmt.Println(sequenceId)
  166 + fmt.Println(cohort)
  167 + }
  168 + return
  169 +}
configs/confcardholder/get.go 0 → 100644
@@ -0,0 +1,81 @@ @@ -0,0 +1,81 @@
  1 +package confcardholder
  2 +
  3 +import (
  4 + "apigame/service-common/svconst"
  5 + "apigame/service-common/svmysql"
  6 + "apigame/service-common/svredis"
  7 + "apigame/util/util-lx/lxalilog"
  8 + "apigame/util/util-lx/lxtime"
  9 + "apigame/util/utstring"
  10 + "apigame/util/zredis"
  11 + "fmt"
  12 +)
  13 +
  14 +// GetCurrent 获取 当前配置
  15 +func GetCurrent(gameId string) (conf *ActivityConfig, has bool) {
  16 + currentKey := fmt.Sprintf("%s:%s:%s:current",
  17 + svconst.REDIS_CACHEP_REFIX,
  18 + svconst.MYSQL_TABLE_S_CARDHOLDER_CONFIG,
  19 + gameId)
  20 + currentId := zredis.GetInt64(zredis.GetConn(), currentKey)
  21 + timeNow := lxtime.NowUninx()
  22 + confRaw := new(ActivityConfigRaw)
  23 + hasFind := false
  24 + if currentId == 0 {
  25 + hasFind = FindCurrent(confRaw, gameId)
  26 + } else {
  27 + conf, has = GetConfig(gameId, currentId)
  28 + if has {
  29 + if timeNow < conf.StartTime || timeNow > conf.EndTime {
  30 + hasFind = FindCurrent(confRaw, gameId)
  31 + }
  32 + } else {
  33 + hasFind = FindCurrent(confRaw, gameId)
  34 + }
  35 + }
  36 + if hasFind {
  37 + conf = new(ActivityConfig)
  38 + conf.Decode(gameId, confRaw)
  39 + svredis.SaveData(gameId, conf)
  40 + has = true
  41 + currentId = conf.Id
  42 + _ = zredis.Set(zredis.GetConn(), currentKey, utstring.Int64ToString(currentId))
  43 + }
  44 + return
  45 +}
  46 +
  47 +func FindCurrent(confRaw *ActivityConfigRaw, gameId string) (has bool) {
  48 + info := confRaw.MysqlInfo(gameId)
  49 + db := info.DbMysql
  50 + timeNow := lxtime.NowUninx()
  51 + result := db.Table(info.TableName).Where("start_time <= ? AND end_time >= ?", timeNow, timeNow).First(confRaw)
  52 + has = result.RowsAffected != 0
  53 + return
  54 +}
  55 +
  56 +// GetConfig 获取 配置根据Id
  57 +func GetConfig(gameId string, confId int64) (conf *ActivityConfig, has bool) {
  58 + var err error
  59 + conf = &ActivityConfig{Id: confId}
  60 + has = svredis.LoadData(gameId, conf)
  61 + if has {
  62 + fmt.Println("dwjw confcardholder.GetConfig use cache")
  63 + return
  64 + }
  65 + confRaw := new(ActivityConfigRaw)
  66 + has, err = svmysql.First(confRaw, gameId)
  67 + if err != nil {
  68 + lxalilog.Errors(err, "confcardholder.GetConfig error", gameId)
  69 + return
  70 + }
  71 + if !has {
  72 + return
  73 + }
  74 +
  75 + conf.Decode(gameId, confRaw)
  76 +
  77 + fmt.Println("dwjw confcardholder.GetConfig save cache")
  78 + svredis.SaveData(gameId, conf)
  79 +
  80 + return
  81 +}
configs/init.go
@@ -2,6 +2,7 @@ package configs @@ -2,6 +2,7 @@ package configs
2 2
3 import ( 3 import (
4 "apigame/configs/confapi" 4 "apigame/configs/confapi"
  5 + "apigame/configs/confcardholder"
5 "apigame/service-common/svconst" 6 "apigame/service-common/svconst"
6 ) 7 )
7 8
@@ -12,7 +13,7 @@ func Init() bool { @@ -12,7 +13,7 @@ func Init() bool {
12 } 13 }
13 14
14 for _, gameId := range svconst.GameListCardHolder { 15 for _, gameId := range svconst.GameListCardHolder {
15 - _, _ = GetCardActivityConfig(gameId) 16 + _, _ = confcardholder.GetCurrent(gameId)
16 } 17 }
17 18
18 for _, gameId := range svconst.GameListRoomRank { 19 for _, gameId := range svconst.GameListRoomRank {
configs/registry.go
@@ -7,33 +7,6 @@ import ( @@ -7,33 +7,6 @@ import (
7 "fmt" 7 "fmt"
8 ) 8 )
9 9
10 -// GetCardActivityConfig 获取 卡牌活动配置  
11 -func GetCardActivityConfig(gameId string) (conf *CardActivityConfig, has bool) {  
12 - var err error  
13 - conf = new(CardActivityConfig)  
14 - has = svredis.LoadData(gameId, conf)  
15 - if has {  
16 - fmt.Println("dwjw GetCardActivityConfig use cache")  
17 - return  
18 - }  
19 - confRaw := new(CardActivityConfigRaw)  
20 - has, err = svmysql.First(confRaw, gameId)  
21 - if err != nil {  
22 - lxalilog.Errors(err, "configs.GetCardActivityConfig error", gameId)  
23 - return  
24 - }  
25 - if !has {  
26 - return  
27 - }  
28 -  
29 - conf.Decode(gameId, confRaw)  
30 -  
31 - fmt.Println("dwjw GetCardActivityConfig save cache")  
32 - svredis.SaveData(gameId, conf)  
33 -  
34 - return  
35 -}  
36 -  
37 // GetRoomRankConfig 获取 房间排行活动配置 10 // GetRoomRankConfig 获取 房间排行活动配置
38 func GetRoomRankConfig(gameId string) (conf *RoomRankConfig, has bool) { 11 func GetRoomRankConfig(gameId string) (conf *RoomRankConfig, has bool) {
39 var err error 12 var err error
service/cardholder/handle.go
1 package cardholder 1 package cardholder
2 2
3 import ( 3 import (
4 - "apigame/configs" 4 + "apigame/configs/confcardholder"
5 "apigame/models" 5 "apigame/models"
6 "apigame/service/code-msg" 6 "apigame/service/code-msg"
7 "apigame/util/util-lx/lxalilog" 7 "apigame/util/util-lx/lxalilog"
@@ -17,7 +17,7 @@ func HandleGetConfig(req *models.ReqCardHolderGetConfig) (code string, rsp model @@ -17,7 +17,7 @@ func HandleGetConfig(req *models.ReqCardHolderGetConfig) (code string, rsp model
17 gameId := req.GameID 17 gameId := req.GameID
18 18
19 // 尝试更新配置 19 // 尝试更新配置
20 - config, _ := configs.GetCardActivityConfig(gameId) 20 + config, _ := confcardholder.GetCurrent(gameId)
21 rsp.ActivityId = config.Id 21 rsp.ActivityId = config.Id
22 rsp.PrepareTime = config.PreviewTime 22 rsp.PrepareTime = config.PreviewTime
23 rsp.StartTime = config.StartTime 23 rsp.StartTime = config.StartTime
@@ -37,7 +37,7 @@ func HandleInfo(req *models.ReqCardHolderInfo) (code string, rsp models.RspCardH @@ -37,7 +37,7 @@ func HandleInfo(req *models.ReqCardHolderInfo) (code string, rsp models.RspCardH
37 playerUid := req.UID 37 playerUid := req.UID
38 38
39 // 尝试更新配置 39 // 尝试更新配置
40 - config, hasConfig := configs.GetCardActivityConfig(gameId) 40 + config, hasConfig := confcardholder.GetCurrent(gameId)
41 if !hasConfig { 41 if !hasConfig {
42 code = code_msg.RECODE_MERGE_CARDHOLDER_NOTOPEN_ERROR 42 code = code_msg.RECODE_MERGE_CARDHOLDER_NOTOPEN_ERROR
43 return 43 return
@@ -69,7 +69,7 @@ func HandleOpen(req *models.ReqCardHolderOpen) (code string, rsp models.RspCardH @@ -69,7 +69,7 @@ func HandleOpen(req *models.ReqCardHolderOpen) (code string, rsp models.RspCardH
69 playerUid := req.UID 69 playerUid := req.UID
70 70
71 // 尝试更新配置 71 // 尝试更新配置
72 - config, hasConfig := configs.GetCardActivityConfig(gameId) 72 + config, hasConfig := confcardholder.GetCurrent(gameId)
73 if !hasConfig { 73 if !hasConfig {
74 code = code_msg.RECODE_MERGE_CARDHOLDER_NOTOPEN_ERROR 74 code = code_msg.RECODE_MERGE_CARDHOLDER_NOTOPEN_ERROR
75 return 75 return
@@ -146,7 +146,7 @@ func HandleShopExchange(req *models.ReqStarShopExchange) (code string, rsp model @@ -146,7 +146,7 @@ func HandleShopExchange(req *models.ReqStarShopExchange) (code string, rsp model
146 playerUid := req.UID 146 playerUid := req.UID
147 147
148 // 尝试更新配置 148 // 尝试更新配置
149 - config, hasConfig := configs.GetCardActivityConfig(gameId) 149 + config, hasConfig := confcardholder.GetCurrent(gameId)
150 if !hasConfig { 150 if !hasConfig {
151 code = code_msg.RECODE_MERGE_CARDHOLDER_NOTOPEN_ERROR 151 code = code_msg.RECODE_MERGE_CARDHOLDER_NOTOPEN_ERROR
152 return 152 return
@@ -254,7 +254,7 @@ func HandleAutoExchangeInfo(req *models.ReqAutoExchangeInfo) (code string, rsp m @@ -254,7 +254,7 @@ func HandleAutoExchangeInfo(req *models.ReqAutoExchangeInfo) (code string, rsp m
254 playerUid := req.UID 254 playerUid := req.UID
255 255
256 // 尝试更新配置 256 // 尝试更新配置
257 - config, hasConfig := configs.GetCardActivityConfig(gameId) 257 + config, hasConfig := confcardholder.GetCurrent(gameId)
258 if !hasConfig { 258 if !hasConfig {
259 code = code_msg.RECODE_MERGE_CARDHOLDER_NOTOPEN_ERROR 259 code = code_msg.RECODE_MERGE_CARDHOLDER_NOTOPEN_ERROR
260 return 260 return
service/cardholder/logic.go
1 package cardholder 1 package cardholder
2 2
3 import ( 3 import (
4 - "apigame/configs" 4 + "apigame/configs/confcardholder"
5 "apigame/models" 5 "apigame/models"
6 "apigame/service-common/svmysql" 6 "apigame/service-common/svmysql"
7 "apigame/service/code-msg" 7 "apigame/service/code-msg"
@@ -16,7 +16,7 @@ import ( @@ -16,7 +16,7 @@ import (
16 ) 16 )
17 17
18 // CheckStatus 判断活动是否开启 18 // CheckStatus 判断活动是否开启
19 -func CheckStatus(conf *configs.CardActivityConfig) string { 19 +func CheckStatus(conf *confcardholder.ActivityConfig) string {
20 sec := lxtime.NowUninx() 20 sec := lxtime.NowUninx()
21 if conf.Id == 0 { 21 if conf.Id == 0 {
22 return code_msg.RECODE_MERGE_CARDHOLDER_NOTOPEN1_ERROR 22 return code_msg.RECODE_MERGE_CARDHOLDER_NOTOPEN1_ERROR
@@ -31,7 +31,7 @@ func CheckStatus(conf *configs.CardActivityConfig) string { @@ -31,7 +31,7 @@ func CheckStatus(conf *configs.CardActivityConfig) string {
31 } 31 }
32 32
33 // CheckGameData 检查游戏数据 轮次等 33 // CheckGameData 检查游戏数据 轮次等
34 -func CheckGameData(d *DataCardHolder, conf *configs.CardActivityConfig) string { 34 +func CheckGameData(d *DataCardHolder, conf *confcardholder.ActivityConfig) string {
35 if d.Details.Round > conf.Round { 35 if d.Details.Round > conf.Round {
36 return code_msg.RECODE_MERGE_CARDHOLDER_ROUNDFINISH_ERROR 36 return code_msg.RECODE_MERGE_CARDHOLDER_ROUNDFINISH_ERROR
37 } 37 }
@@ -74,7 +74,7 @@ func GetListFromArray(array []string, scale, count int) []string { @@ -74,7 +74,7 @@ func GetListFromArray(array []string, scale, count int) []string {
74 } 74 }
75 75
76 // GetNewCard 按顺序查找数目最少的一张卡抽取 76 // GetNewCard 按顺序查找数目最少的一张卡抽取
77 -func GetNewCard(player *DataCardHolder, conf *configs.CardActivityConfig) int { 77 +func GetNewCard(player *DataCardHolder, conf *confcardholder.ActivityConfig) int {
78 if len(conf.CardConfig) < 1 { 78 if len(conf.CardConfig) < 1 {
79 return 0 79 return 0
80 } 80 }
@@ -91,7 +91,7 @@ func GetNewCard(player *DataCardHolder, conf *configs.CardActivityConfig) int { @@ -91,7 +91,7 @@ func GetNewCard(player *DataCardHolder, conf *configs.CardActivityConfig) int {
91 } 91 }
92 92
93 // CheckAlbumFinish 判断卡组是否已集齐 93 // CheckAlbumFinish 判断卡组是否已集齐
94 -func CheckAlbumFinish(albumId int, player *DataCardHolder, config *configs.CardActivityConfig) bool { 94 +func CheckAlbumFinish(albumId int, player *DataCardHolder, config *confcardholder.ActivityConfig) bool {
95 for _, conf := range config.CardConfig { 95 for _, conf := range config.CardConfig {
96 if conf.SetId == albumId { 96 if conf.SetId == albumId {
97 count := player.Details.Cards[conf.Id] 97 count := player.Details.Cards[conf.Id]
@@ -104,7 +104,7 @@ func CheckAlbumFinish(albumId int, player *DataCardHolder, config *configs.CardA @@ -104,7 +104,7 @@ func CheckAlbumFinish(albumId int, player *DataCardHolder, config *configs.CardA
104 } 104 }
105 105
106 // CheckRoundFinish 判断轮次是否已集齐(所有卡组集齐) 106 // CheckRoundFinish 判断轮次是否已集齐(所有卡组集齐)
107 -func CheckRoundFinish(player *DataCardHolder, config *configs.CardActivityConfig) bool { 107 +func CheckRoundFinish(player *DataCardHolder, config *confcardholder.ActivityConfig) bool {
108 for _, conf := range config.AlbumConfig { 108 for _, conf := range config.AlbumConfig {
109 count := player.Details.Album[conf.SetId] 109 count := player.Details.Album[conf.SetId]
110 if count < 1 { 110 if count < 1 {
@@ -122,7 +122,7 @@ func HandleNextRound(player *DataCardHolder) { @@ -122,7 +122,7 @@ func HandleNextRound(player *DataCardHolder) {
122 } 122 }
123 123
124 // GetInfo 玩家卡牌活动信息 124 // GetInfo 玩家卡牌活动信息
125 -func GetInfo(player *DataCardHolder, conf *configs.CardActivityConfig) models.CardHolderInfo { 125 +func GetInfo(player *DataCardHolder, conf *confcardholder.ActivityConfig) models.CardHolderInfo {
126 info := models.CardHolderInfo{ 126 info := models.CardHolderInfo{
127 Cards: make(map[int]int), 127 Cards: make(map[int]int),
128 Album: make(map[int]int), 128 Album: make(map[int]int),
@@ -143,8 +143,8 @@ func GetInfo(player *DataCardHolder, conf *configs.CardActivityConfig) models.Ca @@ -143,8 +143,8 @@ func GetInfo(player *DataCardHolder, conf *configs.CardActivityConfig) models.Ca
143 // openMode:开包类型0客户端驱动1星星商店购买2剩余星星兑换 143 // openMode:开包类型0客户端驱动1星星商店购买2剩余星星兑换
144 func DoOpen(gameId string, 144 func DoOpen(gameId string,
145 player *DataCardHolder, 145 player *DataCardHolder,
146 - config *configs.CardActivityConfig,  
147 - confCardholder configs.OpenCardholderConfig, 146 + config *confcardholder.ActivityConfig,
  147 + confCardholder confcardholder.OpenCardholderConfig,
148 sequenceId, cohort string, 148 sequenceId, cohort string,
149 openMode int) (newCards []int) { 149 openMode int) (newCards []int) {
150 150
@@ -160,7 +160,7 @@ func DoOpen(gameId string, @@ -160,7 +160,7 @@ func DoOpen(gameId string,
160 getCardFunc := func(cardConfigId string) { 160 getCardFunc := func(cardConfigId string) {
161 confCardSequence, hasCardSequence := config.FindCardSequenceConfig(cardConfigId, sequenceId, cohort) 161 confCardSequence, hasCardSequence := config.FindCardSequenceConfig(cardConfigId, sequenceId, cohort)
162 if hasCardSequence { 162 if hasCardSequence {
163 - combineId := configs.CombineIdSequenceIdCohort(cardConfigId, sequenceId, cohort) 163 + combineId := confcardholder.CombineIdSequenceIdCohort(cardConfigId, sequenceId, cohort)
164 scale := player.Details.CardSequenceScales[combineId] 164 scale := player.Details.CardSequenceScales[combineId]
165 cardId := GetOneFromArray(confCardSequence.CardIdLists, scale) 165 cardId := GetOneFromArray(confCardSequence.CardIdLists, scale)
166 cardIdInt := utstring.StringToInt(cardId) 166 cardIdInt := utstring.StringToInt(cardId)
@@ -181,7 +181,7 @@ func DoOpen(gameId string, @@ -181,7 +181,7 @@ func DoOpen(gameId string,
181 count := confCardholder.NormalCardNumber 181 count := confCardholder.NormalCardNumber
182 confNormalCardStar, hasNormalCardStar := config.FindNormalCardStarConfig(confCardholder.MinimumGuaranteeCardId, sequenceId, cohort) 182 confNormalCardStar, hasNormalCardStar := config.FindNormalCardStarConfig(confCardholder.MinimumGuaranteeCardId, sequenceId, cohort)
183 if hasNormalCardStar { 183 if hasNormalCardStar {
184 - combineIdStar := configs.CombineIdSequenceIdCohort(confCardholder.MinimumGuaranteeCardId, sequenceId, cohort) 184 + combineIdStar := confcardholder.CombineIdSequenceIdCohort(confCardholder.MinimumGuaranteeCardId, sequenceId, cohort)
185 scaleStar := player.Details.StarSequenceScales[combineIdStar] 185 scaleStar := player.Details.StarSequenceScales[combineIdStar]
186 starIds := GetListFromArray(confNormalCardStar.NormalCardSequenceIds, scaleStar, count) 186 starIds := GetListFromArray(confNormalCardStar.NormalCardSequenceIds, scaleStar, count)
187 // 增加星级刻度 187 // 增加星级刻度
@@ -207,7 +207,7 @@ func DoOpen(gameId string, @@ -207,7 +207,7 @@ func DoOpen(gameId string,
207 // DoOpenCheckAward 封装的新卡判断是否出发卡组和轮次奖励的逻辑 207 // DoOpenCheckAward 封装的新卡判断是否出发卡组和轮次奖励的逻辑
208 func DoOpenCheckAward(gameId string, 208 func DoOpenCheckAward(gameId string,
209 player *DataCardHolder, 209 player *DataCardHolder,
210 - config *configs.CardActivityConfig, 210 + config *confcardholder.ActivityConfig,
211 sequenceId, cohort string, 211 sequenceId, cohort string,
212 newCards []int, 212 newCards []int,
213 openMode int) (awardAlbum map[int]string, awardRound string) { 213 openMode int) (awardAlbum map[int]string, awardRound string) {
@@ -270,7 +270,7 @@ func DoOpenCheckAward(gameId string, @@ -270,7 +270,7 @@ func DoOpenCheckAward(gameId string,
270 } 270 }
271 271
272 // CalculateStarCount 计算星星点数 272 // CalculateStarCount 计算星星点数
273 -func CalculateStarCount(player *DataCardHolder, config *configs.CardActivityConfig) { 273 +func CalculateStarCount(player *DataCardHolder, config *confcardholder.ActivityConfig) {
274 starCount := 0 274 starCount := 0
275 for cardId, cardCount := range player.Details.Cards { 275 for cardId, cardCount := range player.Details.Cards {
276 if cardCount <= 1 { 276 if cardCount <= 1 {
@@ -292,7 +292,7 @@ func CalculateStarCount(player *DataCardHolder, config *configs.CardActivityConf @@ -292,7 +292,7 @@ func CalculateStarCount(player *DataCardHolder, config *configs.CardActivityConf
292 } 292 }
293 293
294 // GetStarCardList 按照规则扣除星星数找到需要扣除的卡牌列表 294 // GetStarCardList 按照规则扣除星星数找到需要扣除的卡牌列表
295 -func GetStarCardList(player *DataCardHolder, config *configs.CardActivityConfig, needStar int) (enough bool, cardList map[int]int) { 295 +func GetStarCardList(player *DataCardHolder, config *confcardholder.ActivityConfig, needStar int) (enough bool, cardList map[int]int) {
296 enough = false 296 enough = false
297 cardList = make(map[int]int) 297 cardList = make(map[int]int)
298 starAmount := 0 298 starAmount := 0
@@ -361,10 +361,10 @@ func GetStarCardList(player *DataCardHolder, config *configs.CardActivityConfig, @@ -361,10 +361,10 @@ func GetStarCardList(player *DataCardHolder, config *configs.CardActivityConfig,
361 } 361 }
362 362
363 // NextActivityAutoExchange 活动切换时自动兑换卡包 363 // NextActivityAutoExchange 活动切换时自动兑换卡包
364 -func NextActivityAutoExchange(gameId string, player *DataCardHolder, config *configs.CardActivityConfig) { 364 +func NextActivityAutoExchange(gameId string, player *DataCardHolder, config *confcardholder.ActivityConfig) {
365 starCount := player.Details.LastStarCount 365 starCount := player.Details.LastStarCount
366 // 把星星的配置按照需要的星星数降序排列 366 // 把星星的配置按照需要的星星数降序排列
367 - list := lo.Values[int, configs.StarShopConfig](config.StarShopConfig) 367 + list := lo.Values[int, confcardholder.StarShopConfig](config.StarShopConfig)
368 sort.Slice(list, func(i, j int) bool { 368 sort.Slice(list, func(i, j int) bool {
369 return list[i].NeedStarNumber < list[j].NeedStarNumber 369 return list[i].NeedStarNumber < list[j].NeedStarNumber
370 }) 370 })
service/cardholder/player.go
1 package cardholder 1 package cardholder
2 2
3 import ( 3 import (
4 - "apigame/configs" 4 + "apigame/configs/confcardholder"
5 "apigame/service-common/svmysql" 5 "apigame/service-common/svmysql"
6 "apigame/util/util-lx/lxalilog" 6 "apigame/util/util-lx/lxalilog"
7 "apigame/util/util-lx/lxtime" 7 "apigame/util/util-lx/lxtime"
@@ -35,7 +35,7 @@ func _LoadPlayer(gameId string, playerUid int64) (d *DataCardHolder) { @@ -35,7 +35,7 @@ func _LoadPlayer(gameId string, playerUid int64) (d *DataCardHolder) {
35 } 35 }
36 36
37 // LoadPlayer 获取数据 外部接口 37 // LoadPlayer 获取数据 外部接口
38 -func LoadPlayer(gameId string, playerUid int64, config *configs.CardActivityConfig) (d *DataCardHolder) { 38 +func LoadPlayer(gameId string, playerUid int64, config *confcardholder.ActivityConfig) (d *DataCardHolder) {
39 configId := config.Id 39 configId := config.Id
40 d = _LoadPlayer(gameId, playerUid) 40 d = _LoadPlayer(gameId, playerUid)
41 // 如果当前有上线活动(活动ID不为0),且活动ID和玩家数据不同,说明活动已切换 需更新 41 // 如果当前有上线活动(活动ID不为0),且活动ID和玩家数据不同,说明活动已切换 需更新
util/zredis/kv.go
@@ -32,3 +32,11 @@ func SetEx(conn redis.Conn, key, value string, exTime int) (err error) { @@ -32,3 +32,11 @@ func SetEx(conn redis.Conn, key, value string, exTime int) (err error) {
32 _, err = conn.Do("Set", key, value, "EX", exTime) 32 _, err = conn.Do("Set", key, value, "EX", exTime)
33 return 33 return
34 } 34 }
  35 +
  36 +func GetInt64(conn redis.Conn, key string) int64 {
  37 + value, err := redis.Int64(conn.Do("Get", key))
  38 + if err == nil {
  39 + return value
  40 + }
  41 + return 0
  42 +}