Compare commits
2 Commits
d29c485c87
...
c671da56e6
Author | SHA1 | Date |
---|---|---|
|
c671da56e6 | |
|
0484f1f47b |
|
@ -292,6 +292,7 @@ const (
|
||||||
GainWayPermitExchangeCost = 96 // 赛季通行证兑换消耗
|
GainWayPermitExchangeCost = 96 // 赛季通行证兑换消耗
|
||||||
GainWayPermitExchangeGain = 97 // 赛季通行证兑换获得
|
GainWayPermitExchangeGain = 97 // 赛季通行证兑换获得
|
||||||
GainWayItemTaskPermit = 98 // 赛季通行证任务
|
GainWayItemTaskPermit = 98 // 赛季通行证任务
|
||||||
|
GainWayDiamondLottery = 99 //钻石抽奖
|
||||||
)
|
)
|
||||||
|
|
||||||
// 后台选择 金币变化类型 的充值 类型id号起始
|
// 后台选择 金币变化类型 的充值 类型id号起始
|
||||||
|
@ -786,6 +787,7 @@ var PetIDs = []int32{PetIDChicken}
|
||||||
const (
|
const (
|
||||||
ChannelSwitchExchange = 1
|
ChannelSwitchExchange = 1
|
||||||
ChannelSwitchDropItem = 2
|
ChannelSwitchDropItem = 2
|
||||||
|
DiamondLottery = 4
|
||||||
)
|
)
|
||||||
|
|
||||||
// 特殊商品id
|
// 特殊商品id
|
||||||
|
|
|
@ -30,8 +30,10 @@ const (
|
||||||
ETCDKEY_PLAYERPOOL = "/game/plt/playerpool/" // 个人水池调控配置
|
ETCDKEY_PLAYERPOOL = "/game/plt/playerpool/" // 个人水池调控配置
|
||||||
ETCDKEY_GAME_CONFIG = "/game/plt/gameconfig/" // 游戏管理/全局配置
|
ETCDKEY_GAME_CONFIG = "/game/plt/gameconfig/" // 游戏管理/全局配置
|
||||||
ETCDKEY_ACT_PHONELOTTERY = "/game/act_phoneLottery"
|
ETCDKEY_ACT_PHONELOTTERY = "/game/act_phoneLottery"
|
||||||
ETCDKEY_ChannelSwitch = "/game/channel/switch" // 渠道开关
|
ETCDKEY_ChannelSwitch = "/game/channel/switch" // 渠道开关
|
||||||
ETCDKEY_ACT_Invite = "/game/act_invite" // 邀请活动配置
|
ETCDKEY_ACT_Invite = "/game/act_invite" // 邀请活动配置
|
||||||
ETCDKEY_ACT_Permit = "/game/act_permit" // 赛季通行证配置
|
ETCDKEY_ACT_Permit = "/game/act_permit" // 赛季通行证配置
|
||||||
ETCDKEY_Item = "/game/item" // 道具列表
|
ETCDKEY_DIAMOND_LOTTERY = "/game/diamond_lottery" // 钻石抽奖配置
|
||||||
|
ETCDKEY_Item = "/game/item" // 道具列表
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
|
@ -149,9 +149,9 @@
|
||||||
"SlowMS": 500
|
"SlowMS": 500
|
||||||
},
|
},
|
||||||
"etcd": {
|
"etcd": {
|
||||||
"Url": ["127.0.0.1:2379"],
|
"Url": ["47.105.78.29:2379"],
|
||||||
"UserName": "",
|
"UserName": "root",
|
||||||
"Password": "",
|
"Password": "win88",
|
||||||
"DialTimeout": 60
|
"DialTimeout": 60
|
||||||
},
|
},
|
||||||
"costum": {
|
"costum": {
|
||||||
|
|
|
@ -12,13 +12,14 @@ import (
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const (
|
const (
|
||||||
OpAll = 0
|
OpAll = 0
|
||||||
OpTurnplate = 1
|
OpTurnplate = 1
|
||||||
OpBlindBox = 2
|
OpBlindBox = 2
|
||||||
OpFirstPay = 3
|
OpFirstPay = 3
|
||||||
OpContinuousPay = 4
|
OpContinuousPay = 4
|
||||||
OpPhoneLottery = 5
|
OpPhoneLottery = 5
|
||||||
OpCollect = 6
|
OpCollect = 6
|
||||||
|
OpDiamondLottery = 7
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -123,6 +124,7 @@ type AllConfig struct {
|
||||||
*webapi.ActPermitConfig
|
*webapi.ActPermitConfig
|
||||||
PermitStartTs int64 // 开始时间戳
|
PermitStartTs int64 // 开始时间戳
|
||||||
PermitEndTs int64 // 结束时间戳
|
PermitEndTs int64 // 结束时间戳
|
||||||
|
*webapi.DiamondLotteryConfig
|
||||||
// 道具配置
|
// 道具配置
|
||||||
*webapi.ItemConfig
|
*webapi.ItemConfig
|
||||||
}
|
}
|
||||||
|
|
|
@ -478,6 +478,7 @@ type PlayerData struct {
|
||||||
IScoreTs time.Time // 邀请积分更新时间
|
IScoreTs time.Time // 邀请积分更新时间
|
||||||
Permit time.Time // 赛季通行证领取时间
|
Permit time.Time // 赛季通行证领取时间
|
||||||
PermitStartTs int64 // 赛季通行证开始时间戳
|
PermitStartTs int64 // 赛季通行证开始时间戳
|
||||||
|
DiamondLotteryScore int64 //钻石抽奖幸运值
|
||||||
}
|
}
|
||||||
|
|
||||||
// 七日签到数据
|
// 七日签到数据
|
||||||
|
|
|
@ -211,7 +211,14 @@ enum PlayerPacketID {
|
||||||
PACKET_SCExchangeChannel = 2826; // 开启兑换的渠道
|
PACKET_SCExchangeChannel = 2826; // 开启兑换的渠道
|
||||||
PACKET_CSSMSConfig = 2827; //获取运营商配置
|
PACKET_CSSMSConfig = 2827; //获取运营商配置
|
||||||
PACKET_SCSMSConfig = 2828; //返回运营商配置
|
PACKET_SCSMSConfig = 2828; //返回运营商配置
|
||||||
PACKET_SCItem = 2830; // 返回道具列表
|
PACKET_CS_DiamondLotteryInfo = 2829; //请求钻石抽奖信息
|
||||||
|
PACKET_SC_DiamondLotteryInfo = 2830; //返回钻石抽奖信息
|
||||||
|
PACKET_CS_DiamondLottery = 2831; //请求钻石抽奖
|
||||||
|
PACKET_SC_DiamondLottery = 2832; //钻石抽奖返回
|
||||||
|
PACKET_CSDiamondLotteryLuckyAward = 2833; //请求领取钻石抽奖幸运奖励
|
||||||
|
PACKET_SCDiamondLotteryLuckyAward = 2834; //返回领取钻石抽奖幸运奖励
|
||||||
|
PACKET_SCItem = 2835; // 返回道具列表
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 账变记录
|
// 账变记录
|
||||||
|
@ -1153,6 +1160,7 @@ message LotteryItem{
|
||||||
int32 Id = 1;
|
int32 Id = 1;
|
||||||
int32 ItemId = 2;
|
int32 ItemId = 2;
|
||||||
int64 ItemNum =3;
|
int64 ItemNum =3;
|
||||||
|
int32 TypeId = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
//通知抽奖剩余次数
|
//通知抽奖剩余次数
|
||||||
|
@ -1194,7 +1202,7 @@ message CSExchangeChannel{
|
||||||
|
|
||||||
message ChannelSwitch {
|
message ChannelSwitch {
|
||||||
repeated string OnChannelName = 1; // 开启渠道
|
repeated string OnChannelName = 1; // 开启渠道
|
||||||
int32 Tp = 2; // 开关类型 1:兑换 2:v卡掉落 3:邀请活动开关
|
int32 Tp = 2; // 开关类型 1:兑换 2:v卡掉落 3:邀请活动开关 4:钻石抽奖
|
||||||
}
|
}
|
||||||
|
|
||||||
// PACKET_SCExchangeChannel
|
// PACKET_SCExchangeChannel
|
||||||
|
@ -1215,6 +1223,39 @@ message SMSInfo{
|
||||||
string SmsName = 2;
|
string SmsName = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//钻石抽奖 请求抽奖数据
|
||||||
|
//PACKET_CS_DiamondLotteryInfo
|
||||||
|
message CSDiamondLotteryInfo{
|
||||||
|
|
||||||
|
}
|
||||||
|
//钻石抽奖 返回抽奖数据
|
||||||
|
//PACKET_SC_DiamondLotteryInfo
|
||||||
|
message SCDiamondLotteryInfo{
|
||||||
|
int64 LuckyScore = 1; //幸运积分
|
||||||
|
repeated LotteryItem Item = 2;//抽奖物品信息
|
||||||
|
int32 MaxScore = 3;//保底奖励最大值
|
||||||
|
int32 DiamondNum = 4; //单次抽奖消耗钻石数量
|
||||||
|
}
|
||||||
|
//请求钻石抽奖
|
||||||
|
//PACKET_CS_DiamondLottery
|
||||||
|
message CSDiamondLottery{
|
||||||
|
int32 LotteryType = 1; //1-单抽 2-十连抽
|
||||||
|
}
|
||||||
|
//请求钻石抽奖返回
|
||||||
|
//PACKET_SC_DiamondLottery
|
||||||
|
message SCDiamondLottery{
|
||||||
|
int64 LuckyScore = 1; //幸运积分
|
||||||
|
repeated LotteryItem Item = 2; //获得的物品
|
||||||
|
}
|
||||||
|
//请求领取保底奖励
|
||||||
|
//PACKET_CSDiamondLotteryLuckyAward
|
||||||
|
message CSDiamondLotteryLuckyAward{
|
||||||
|
}
|
||||||
|
////PACKET_SCDiamondLotteryLuckyAward
|
||||||
|
message SCDiamondLotteryLuckyAward{
|
||||||
|
int64 LuckyScore = 1; //幸运积分
|
||||||
|
repeated LotteryItem Item = 2; //获得的物品
|
||||||
|
|
||||||
// PACKET_SCItem
|
// PACKET_SCItem
|
||||||
message SCItem{
|
message SCItem{
|
||||||
repeated server.DB_GameItem Items = 1; // 道具列表
|
repeated server.DB_GameItem Items = 1; // 道具列表
|
||||||
|
|
|
@ -672,7 +672,7 @@ message WelfareCollectConfig{
|
||||||
|
|
||||||
// etcd /game/channel/switch
|
// etcd /game/channel/switch
|
||||||
message ChannelSwitchConfig{
|
message ChannelSwitchConfig{
|
||||||
int32 Tp = 1; // 开关类型 1.兑换 2.道具掉落 3.邀请活动开关
|
int32 Tp = 1; // 开关类型 1.兑换 2.道具掉落 3.邀请活动开关 4.钻石抽奖
|
||||||
string Platform = 2; // 平台id
|
string Platform = 2; // 平台id
|
||||||
repeated string OnChannelName = 3; // 开启渠道
|
repeated string OnChannelName = 3; // 开启渠道
|
||||||
}
|
}
|
||||||
|
@ -737,8 +737,38 @@ message ActPermitConfig{
|
||||||
repeated PermitChannelConfig Configs = 4; // 渠道配置
|
repeated PermitChannelConfig Configs = 4; // 渠道配置
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//钻石抽奖
|
||||||
|
message DiamondLotteryInfo{
|
||||||
|
int32 Id = 1;
|
||||||
|
int32 Type = 2;
|
||||||
|
string Name = 3;
|
||||||
|
int32 ItemId = 4;
|
||||||
|
int32 Grade = 5;
|
||||||
|
int32 Oddrate =6;
|
||||||
|
}
|
||||||
|
//钻石抽奖白名单
|
||||||
|
message DiamondLotteryPlayers{
|
||||||
|
int32 uid = 1;
|
||||||
|
int32 Count = 2; //抽奖次数
|
||||||
|
repeated int32 AwatdId = 3; //配置表里的奖励ID
|
||||||
|
}
|
||||||
|
message DiamondLotteryData{
|
||||||
|
string Channel = 1; //渠道
|
||||||
|
repeated DiamondLotteryInfo Info = 2;
|
||||||
|
int32 MaxScore = 3; //保底奖励最大值
|
||||||
|
int32 DiamondNum = 4; //单次抽奖消耗钻石数量
|
||||||
|
repeated DiamondLotteryPlayers Players = 5;//白名单
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// etcd /game/diamond_lottery
|
||||||
|
message DiamondLotteryConfig{
|
||||||
|
string Platform = 1; // 平台
|
||||||
|
repeated DiamondLotteryData LotteryData = 2;
|
||||||
|
}
|
||||||
|
|
||||||
// etcd /game/item
|
// etcd /game/item
|
||||||
message ItemConfig {
|
message ItemConfig {
|
||||||
string Platform = 1; // 平台
|
string Platform = 1; // 平台
|
||||||
repeated server.DB_GameItem Items = 2; // 道具列表
|
repeated server.DB_GameItem Items = 2; // 道具列表
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ import (
|
||||||
"mongo.games.com/game/common"
|
"mongo.games.com/game/common"
|
||||||
"mongo.games.com/game/model"
|
"mongo.games.com/game/model"
|
||||||
player_proto "mongo.games.com/game/protocol/player"
|
player_proto "mongo.games.com/game/protocol/player"
|
||||||
|
"mongo.games.com/game/protocol/webapi"
|
||||||
"mongo.games.com/game/srvdata"
|
"mongo.games.com/game/srvdata"
|
||||||
"mongo.games.com/goserver/core/logger"
|
"mongo.games.com/goserver/core/logger"
|
||||||
"mongo.games.com/goserver/core/netlib"
|
"mongo.games.com/goserver/core/netlib"
|
||||||
|
@ -24,7 +25,6 @@ func (this *CSPhoneLotteryInfoPacketFactory) CreatePacket() interface{} {
|
||||||
|
|
||||||
// 获取抽奖信息
|
// 获取抽奖信息
|
||||||
func (this *CSPhoneLotteryInfoHandler) Process(s *netlib.Session, packetid int, data interface{}, sid int64) error {
|
func (this *CSPhoneLotteryInfoHandler) Process(s *netlib.Session, packetid int, data interface{}, sid int64) error {
|
||||||
|
|
||||||
if _, ok := data.(*player_proto.CSPhoneLotteryInfo); ok {
|
if _, ok := data.(*player_proto.CSPhoneLotteryInfo); ok {
|
||||||
p := PlayerMgrSington.GetPlayer(sid)
|
p := PlayerMgrSington.GetPlayer(sid)
|
||||||
logger.Logger.Trace("客户端请求抽奖信息!snid = ", p.SnId)
|
logger.Logger.Trace("客户端请求抽奖信息!snid = ", p.SnId)
|
||||||
|
@ -80,7 +80,8 @@ func (this *CSPhoneLotteryHandler) Process(s *netlib.Session, packetid int, data
|
||||||
logger.Logger.Warn("CSPhoneLottery p == nil")
|
logger.Logger.Warn("CSPhoneLottery p == nil")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if WelfareMgrSington.GetPhoneLotteryStatus(p.Platform) == model.WelfareClose {
|
conf := PlatformMgrSingleton.GetConfig(p.Platform).ChannelSwitch[common.DiamondLottery]
|
||||||
|
if !model.GameParamData.CloseChannelSwitch && (conf == nil || !common.InSliceString(conf.OnChannelName, p.LastChannel)) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
countType := msg.GetLotteryType()
|
countType := msg.GetLotteryType()
|
||||||
|
@ -91,10 +92,6 @@ func (this *CSPhoneLotteryHandler) Process(s *netlib.Session, packetid int, data
|
||||||
count = 10
|
count = 10
|
||||||
}
|
}
|
||||||
logger.Logger.Tracef("玩家请求抽奖,snid =%d,count = %d ", p.SnId, count)
|
logger.Logger.Tracef("玩家请求抽奖,snid =%d,count = %d ", p.SnId, count)
|
||||||
if p == nil {
|
|
||||||
logger.Logger.Warn("CSPhoneLottery p == nil")
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
if p.LotteryCount < count {
|
if p.LotteryCount < count {
|
||||||
logger.Logger.Trace("剩余抽奖次数不足,无法抽奖 count = ", count)
|
logger.Logger.Trace("剩余抽奖次数不足,无法抽奖 count = ", count)
|
||||||
return nil
|
return nil
|
||||||
|
@ -209,6 +206,257 @@ func (this *CSPhoneLotteryHandler) Process(s *netlib.Session, packetid int, data
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type CSDiamondLotteryInfoPacketFactory struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
type CSDiamondLotteryInfoHandler struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *CSDiamondLotteryInfoPacketFactory) CreatePacket() interface{} {
|
||||||
|
pack := &player_proto.CSDiamondLotteryInfo{}
|
||||||
|
return pack
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取钻石抽奖信息
|
||||||
|
func (this *CSDiamondLotteryInfoHandler) Process(s *netlib.Session, packetid int, data interface{}, sid int64) error {
|
||||||
|
if _, ok := data.(*player_proto.CSPhoneLotteryInfo); ok {
|
||||||
|
p := PlayerMgrSington.GetPlayer(sid)
|
||||||
|
logger.Logger.Trace("客户端请求钻石抽奖信息!snid = ", p.SnId)
|
||||||
|
if p == nil {
|
||||||
|
logger.Logger.Warn("CSPhoneLotteryInfo p == nil")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// 渠道开关
|
||||||
|
conf := PlatformMgrSingleton.GetConfig(p.Platform).ChannelSwitch[common.DiamondLottery]
|
||||||
|
if !model.GameParamData.CloseChannelSwitch && (conf == nil || !common.InSliceString(conf.OnChannelName, p.LastChannel)) {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
pack := &player_proto.SCDiamondLotteryInfo{}
|
||||||
|
pack.LuckyScore = p.DiamondLotteryScore
|
||||||
|
info := WelfareMgrSington.GetConfig(p.Platform)
|
||||||
|
if info != nil && info.DiamondLotteryConfig != nil {
|
||||||
|
for _, data := range info.DiamondLotteryConfig.LotteryData {
|
||||||
|
if data.Channel == p.Channel {
|
||||||
|
pack.MaxScore = data.MaxScore
|
||||||
|
pack.DiamondNum = data.DiamondNum
|
||||||
|
for _, lotteryInfo := range data.Info {
|
||||||
|
item := &player_proto.LotteryItem{
|
||||||
|
Id: lotteryInfo.Id,
|
||||||
|
ItemId: lotteryInfo.ItemId,
|
||||||
|
ItemNum: int64(lotteryInfo.Grade),
|
||||||
|
TypeId: lotteryInfo.Type,
|
||||||
|
}
|
||||||
|
pack.Item = append(pack.Item, item)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
p.SendToClient(int(player_proto.PlayerPacketID_PACKET_SC_DiamondLotteryInfo), pack)
|
||||||
|
logger.Logger.Trace("返回钻石抽奖信息:", pack.String())
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type CSDiamondLotteryPacketFactory struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
type CSDiamondLotteryHandler struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *CSDiamondLotteryPacketFactory) CreatePacket() interface{} {
|
||||||
|
pack := &player_proto.CSDiamondLottery{}
|
||||||
|
return pack
|
||||||
|
}
|
||||||
|
|
||||||
|
// 玩家钻石抽奖
|
||||||
|
func (this *CSDiamondLotteryHandler) Process(s *netlib.Session, packetid int, data interface{}, sid int64) error {
|
||||||
|
if msg, ok := data.(*player_proto.CSDiamondLottery); ok {
|
||||||
|
p := PlayerMgrSington.GetPlayer(sid)
|
||||||
|
if p == nil {
|
||||||
|
logger.Logger.Warn("CSDiamondLottery p == nil")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
// 渠道开关
|
||||||
|
conf := PlatformMgrSingleton.GetConfig(p.Platform).ChannelSwitch[common.DiamondLottery]
|
||||||
|
if !model.GameParamData.CloseChannelSwitch && (conf == nil || !common.InSliceString(conf.OnChannelName, p.LastChannel)) {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
countType := msg.GetLotteryType()
|
||||||
|
count := int32(0)
|
||||||
|
if countType == 1 {
|
||||||
|
count = 1
|
||||||
|
} else {
|
||||||
|
count = 10
|
||||||
|
}
|
||||||
|
logger.Logger.Tracef("玩家请求钻石抽奖,snid =%d,count = %d ", p.SnId, count)
|
||||||
|
info := WelfareMgrSington.GetConfig(p.Platform)
|
||||||
|
var config *webapi.DiamondLotteryData
|
||||||
|
if info == nil && info.DiamondLotteryConfig != nil {
|
||||||
|
for _, data := range info.LotteryData {
|
||||||
|
if data.Channel == p.Channel {
|
||||||
|
config = data
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if config == nil {
|
||||||
|
logger.Logger.Error("钻石抽奖,未找到配置!p.Channel = ", p.Channel)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
//判断钻石数量
|
||||||
|
diamondNum := int64(config.DiamondNum * count)
|
||||||
|
if p.Diamond < diamondNum {
|
||||||
|
logger.Logger.Trace("钻石抽奖 ,钻石数量不足!")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
p.AddDiamond(-diamondNum, 0, common.GainWayDiamondLottery, "sys", "钻石抽奖")
|
||||||
|
pack := &player_proto.SCDiamondLottery{}
|
||||||
|
|
||||||
|
weight := 0
|
||||||
|
for _, lotteryInfo := range config.Info {
|
||||||
|
if lotteryInfo.Type == 1 {
|
||||||
|
weight += int(lotteryInfo.Oddrate)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var items []*Item
|
||||||
|
for i := 1; i <= int(count); i++ {
|
||||||
|
random := rand.Intn(weight) + 1
|
||||||
|
value := 0
|
||||||
|
p.DiamondLotteryScore += 1
|
||||||
|
//判断是否白名单用户
|
||||||
|
whiteList := config.Players
|
||||||
|
status := false
|
||||||
|
var playerData *webapi.DiamondLotteryPlayers
|
||||||
|
for _, players := range whiteList {
|
||||||
|
if players.Uid == p.SnId {
|
||||||
|
playerData = players
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if playerData != nil && p.DiamondLotteryScore%int64(playerData.Count) == 0 {
|
||||||
|
status = true
|
||||||
|
}
|
||||||
|
if status {
|
||||||
|
//白名单从列表里获取奖励
|
||||||
|
id := rand.Intn(len(playerData.AwatdId)) + 1
|
||||||
|
awardId := playerData.AwatdId[id]
|
||||||
|
for _, lotteryInfo := range config.Info {
|
||||||
|
if lotteryInfo.Id == awardId {
|
||||||
|
items = append(items, &Item{
|
||||||
|
ItemId: lotteryInfo.ItemId, // 物品id
|
||||||
|
ItemNum: int64(lotteryInfo.Grade), // 数量
|
||||||
|
})
|
||||||
|
itemData := &player_proto.LotteryItem{
|
||||||
|
Id: lotteryInfo.Id,
|
||||||
|
ItemId: lotteryInfo.ItemId,
|
||||||
|
ItemNum: int64(lotteryInfo.Grade),
|
||||||
|
}
|
||||||
|
pack.Item = append(pack.Item, itemData)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for _, lotteryInfo := range config.Info {
|
||||||
|
value += int(lotteryInfo.Oddrate)
|
||||||
|
if lotteryInfo.Type == 1 {
|
||||||
|
if random <= value {
|
||||||
|
items = append(items, &Item{
|
||||||
|
ItemId: lotteryInfo.ItemId, // 物品id
|
||||||
|
ItemNum: int64(lotteryInfo.Grade), // 数量
|
||||||
|
})
|
||||||
|
itemData := &player_proto.LotteryItem{
|
||||||
|
Id: lotteryInfo.Id,
|
||||||
|
ItemId: lotteryInfo.ItemId,
|
||||||
|
ItemNum: int64(lotteryInfo.Grade),
|
||||||
|
}
|
||||||
|
|
||||||
|
pack.Item = append(pack.Item, itemData)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
BagMgrSingleton.AddItems(p, items, 0, common.GainWayDiamondLottery, "system", "钻石抽奖", 0, 0, false)
|
||||||
|
pack.LuckyScore = p.DiamondLotteryScore
|
||||||
|
p.SendToClient(int(player_proto.PlayerPacketID_PACKET_SC_DiamondLottery), pack)
|
||||||
|
logger.Logger.Trace("返回钻石抽奖信息:", pack.String())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// 领取保底奖励
|
||||||
|
type CSDiamondLotteryLuckyAwardPacketFactory struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
type CSDiamondLotteryLuckyAwardHandler struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *CSDiamondLotteryLuckyAwardPacketFactory) CreatePacket() interface{} {
|
||||||
|
pack := &player_proto.CSDiamondLotteryLuckyAward{}
|
||||||
|
return pack
|
||||||
|
}
|
||||||
|
|
||||||
|
// 玩家钻石抽奖保底奖励
|
||||||
|
func (this *CSDiamondLotteryLuckyAwardHandler) Process(s *netlib.Session, packetid int, data interface{}, sid int64) error {
|
||||||
|
if _, ok := data.(*player_proto.CSDiamondLotteryLuckyAward); ok {
|
||||||
|
p := PlayerMgrSington.GetPlayer(sid)
|
||||||
|
if p == nil {
|
||||||
|
logger.Logger.Warn("CSDiamondLotteryLuckyAward p == nil")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
// 渠道开关
|
||||||
|
conf := PlatformMgrSingleton.GetConfig(p.Platform).ChannelSwitch[common.DiamondLottery]
|
||||||
|
if !model.GameParamData.CloseChannelSwitch && (conf == nil || !common.InSliceString(conf.OnChannelName, p.LastChannel)) {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
info := WelfareMgrSington.GetConfig(p.Platform)
|
||||||
|
|
||||||
|
var config *webapi.DiamondLotteryData
|
||||||
|
if info == nil && info.DiamondLotteryConfig != nil {
|
||||||
|
for _, data := range info.LotteryData {
|
||||||
|
if data.Channel == p.Channel {
|
||||||
|
config = data
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if config == nil {
|
||||||
|
logger.Logger.Error("钻石抽奖,未找到配置!p.Channel = ", p.Channel)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if p.DiamondLotteryScore < int64(config.MaxScore) {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
p.DiamondLotteryScore -= int64(config.MaxScore)
|
||||||
|
|
||||||
|
pack := &player_proto.SCDiamondLotteryLuckyAward{}
|
||||||
|
pack.LuckyScore = p.DiamondLotteryScore
|
||||||
|
//获取奖励
|
||||||
|
for _, lotteryInfo := range config.Info {
|
||||||
|
if lotteryInfo.Type == 2 {
|
||||||
|
var items []*Item
|
||||||
|
items = append(items, &Item{
|
||||||
|
ItemId: lotteryInfo.ItemId, // 物品id
|
||||||
|
ItemNum: int64(lotteryInfo.Grade), // 数量
|
||||||
|
})
|
||||||
|
itemData := &player_proto.LotteryItem{
|
||||||
|
Id: lotteryInfo.Id,
|
||||||
|
ItemId: lotteryInfo.ItemId,
|
||||||
|
ItemNum: int64(lotteryInfo.Grade),
|
||||||
|
}
|
||||||
|
BagMgrSingleton.AddItems(p, items, 0, common.GainWayDiamondLottery, "system", "钻石抽奖", 0, 0, false)
|
||||||
|
pack.Item = append(pack.Item, itemData)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
p.SendToClient(int(player_proto.PlayerPacketID_PACKET_SCDiamondLotteryLuckyAward), pack)
|
||||||
|
logger.Logger.Trace("返回钻石抽奖领取保底奖励信息:", pack.String())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
func init() {
|
func init() {
|
||||||
// 抽奖信息
|
// 抽奖信息
|
||||||
common.RegisterHandler(int(player_proto.PlayerPacketID_PACKET_CS_PhoneLotteryInfo), &CSPhoneLotteryInfoHandler{})
|
common.RegisterHandler(int(player_proto.PlayerPacketID_PACKET_CS_PhoneLotteryInfo), &CSPhoneLotteryInfoHandler{})
|
||||||
|
@ -216,4 +464,13 @@ func init() {
|
||||||
// 抽奖
|
// 抽奖
|
||||||
common.RegisterHandler(int(player_proto.PlayerPacketID_PACKET_CS_PhoneLottery), &CSPhoneLotteryHandler{})
|
common.RegisterHandler(int(player_proto.PlayerPacketID_PACKET_CS_PhoneLottery), &CSPhoneLotteryHandler{})
|
||||||
netlib.RegisterFactory(int(player_proto.PlayerPacketID_PACKET_CS_PhoneLottery), &CSPhoneLotteryPacketFactory{})
|
netlib.RegisterFactory(int(player_proto.PlayerPacketID_PACKET_CS_PhoneLottery), &CSPhoneLotteryPacketFactory{})
|
||||||
|
//钻石抽奖信息
|
||||||
|
common.RegisterHandler(int(player_proto.PlayerPacketID_PACKET_CS_DiamondLotteryInfo), &CSDiamondLotteryInfoHandler{})
|
||||||
|
netlib.RegisterFactory(int(player_proto.PlayerPacketID_PACKET_SC_DiamondLotteryInfo), &CSDiamondLotteryInfoPacketFactory{})
|
||||||
|
// 钻石抽奖
|
||||||
|
common.RegisterHandler(int(player_proto.PlayerPacketID_PACKET_CS_DiamondLottery), &CSDiamondLotteryHandler{})
|
||||||
|
netlib.RegisterFactory(int(player_proto.PlayerPacketID_PACKET_CS_DiamondLottery), &CSDiamondLotteryPacketFactory{})
|
||||||
|
//钻石抽奖保底奖励
|
||||||
|
common.RegisterHandler(int(player_proto.PlayerPacketID_PACKET_CSDiamondLotteryLuckyAward), &CSDiamondLotteryLuckyAwardHandler{})
|
||||||
|
netlib.RegisterFactory(int(player_proto.PlayerPacketID_PACKET_CSDiamondLotteryLuckyAward), &CSDiamondLotteryLuckyAwardPacketFactory{})
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,6 +78,8 @@ func init() {
|
||||||
etcd.Register(etcd.ETCDKEY_ACT_Invite, webapi.ActInviteConfig{}, platformConfigEvent)
|
etcd.Register(etcd.ETCDKEY_ACT_Invite, webapi.ActInviteConfig{}, platformConfigEvent)
|
||||||
// 赛季通行证
|
// 赛季通行证
|
||||||
etcd.Register(etcd.ETCDKEY_ACT_Permit, webapi.ActPermitConfig{}, platformConfigEvent)
|
etcd.Register(etcd.ETCDKEY_ACT_Permit, webapi.ActPermitConfig{}, platformConfigEvent)
|
||||||
|
// 钻石抽奖
|
||||||
|
etcd.Register(etcd.ETCDKEY_DIAMOND_LOTTERY, webapi.DiamondLotteryConfig{}, platformConfigEvent)
|
||||||
// 道具列表
|
// 道具列表
|
||||||
etcd.Register(etcd.ETCDKEY_Item, webapi.ItemConfig{}, platformConfigEvent)
|
etcd.Register(etcd.ETCDKEY_Item, webapi.ItemConfig{}, platformConfigEvent)
|
||||||
}
|
}
|
||||||
|
@ -209,6 +211,8 @@ func platformConfigEvent(ctx context.Context, completeKey string, isInit bool, e
|
||||||
ChessRankMgrSington.UpdateChessRankConfig(config)
|
ChessRankMgrSington.UpdateChessRankConfig(config)
|
||||||
case *webapi.WelfarePhoneLotteryStatus:
|
case *webapi.WelfarePhoneLotteryStatus:
|
||||||
WelfareMgrSington.UpdatePhoneLotteryStatus(config)
|
WelfareMgrSington.UpdatePhoneLotteryStatus(config)
|
||||||
|
case *webapi.DiamondLotteryConfig:
|
||||||
|
WelfareMgrSington.UpdateDiamondLotteryConfig(config)
|
||||||
case *webapi.ActInviteConfig:
|
case *webapi.ActInviteConfig:
|
||||||
PlatformMgrSingleton.GetConfig(config.Platform).ActInviteConfig = config
|
PlatformMgrSingleton.GetConfig(config.Platform).ActInviteConfig = config
|
||||||
case *webapi.ActPermitConfig:
|
case *webapi.ActPermitConfig:
|
||||||
|
|
|
@ -215,6 +215,12 @@ func (this *WelfareMgr) UpdatePhoneLotteryStatus(cfg *webapi_proto.WelfarePhoneL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 更新钻石抽奖配置
|
||||||
|
func (this *WelfareMgr) UpdateDiamondLotteryConfig(cfg *webapi_proto.DiamondLotteryConfig) {
|
||||||
|
info := this.GetConfig(cfg.Platform)
|
||||||
|
info.DiamondLotteryConfig = cfg
|
||||||
|
}
|
||||||
|
|
||||||
func (this *WelfareMgr) GetPhoneLotteryStatus(platform string) int32 {
|
func (this *WelfareMgr) GetPhoneLotteryStatus(platform string) int32 {
|
||||||
info := this.GetConfig(platform)
|
info := this.GetConfig(platform)
|
||||||
if info.WelfarePhoneLotteryStatus != nil {
|
if info.WelfarePhoneLotteryStatus != nil {
|
||||||
|
|
Loading…
Reference in New Issue