引导功能实现
This commit is contained in:
parent
9f35e077f0
commit
cdc51a2eba
|
@ -811,10 +811,9 @@ var (
|
|||
)
|
||||
|
||||
const (
|
||||
AttributeGuideStep = 1 // 引导步骤
|
||||
AttributeGuideSkip = 2 // 跳过引导
|
||||
AttributeGuideTest = 3 // 测试引导
|
||||
AttributeGuideCustom = 4 // 竞技馆引导页
|
||||
AttributeGuideStep = 1 // 引导步骤
|
||||
AttributeGuideSkip = 2 // 跳过引导
|
||||
AttributeGuideTest = 3 // 测试引导
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
|
@ -513,6 +513,7 @@ type PlayerData struct {
|
|||
GuideStep int32 // tienlen游戏引导步骤;跳过引导后,该值会置为-1
|
||||
ClientVer int32 // 客户端版本号
|
||||
Guide []int // 引导步骤
|
||||
GuideData map[int32]int32 // 引导步骤 key:引导类型 value:步骤
|
||||
}
|
||||
|
||||
// 七日签到数据
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -353,10 +353,7 @@ message PlayerData {
|
|||
int32 UseSkinId = 50; // 皮肤id
|
||||
string ChannelID = 51; // 渠道ID
|
||||
int32 GuideStep = 52; // 引导步骤; 最小为0,-1表示跳过引导了
|
||||
// 引导步骤完成情况
|
||||
// 下标:0表示竞技馆引导
|
||||
// 值:最小为0,-1表示引导完成, 其余表示已引导步骤
|
||||
repeated int32 Guide = 53;
|
||||
map<int32,int32> GuideData = 53;//引导数据 key:引导类型 value:步骤
|
||||
}
|
||||
|
||||
//周卡数据
|
||||
|
@ -1347,20 +1344,28 @@ message WindowsInfo{
|
|||
|
||||
//PACKET_CSUpdateAttribute
|
||||
message CSUpdateAttribute{
|
||||
int32 Tp = 1; // 1.更新引导阶段 2.跳过引导 3.更新引导状态(测试用) 4.标记竞技馆引导页面已经显示过
|
||||
int32 Tp = 1; // 1.更新引导阶段 2.跳过引导 3.更新引导状态(测试用)
|
||||
repeated int64 Param = 2;
|
||||
int32 GuideId = 3; //引导ID 1-新手引导 2-竞技馆引导
|
||||
}
|
||||
//PACKET_SCUpdateAttribute
|
||||
message SCUpdateAttribute{
|
||||
OpResultCode OpRetCode = 1; //操作结果
|
||||
int32 Tp = 2;
|
||||
repeated int64 Param = 3;
|
||||
int32 GuideId =4;//引导ID 1-新手引导 2-竞技馆引导
|
||||
}
|
||||
|
||||
//PACKET_SCGuideConfig
|
||||
message SCGuideConfig{
|
||||
repeated GuideInfo Info = 1;
|
||||
}
|
||||
message GuideInfo {
|
||||
int32 On = 2; // 引导开关 1开启 2关闭
|
||||
int32 Skip = 3; // 引导跳过开关 1开启 2关闭
|
||||
int32 GuideId = 4; // 引导类型 1-新手引导 2-竞技馆引导
|
||||
repeated ItemInfo Awards = 5; // 进入房间消耗
|
||||
int32 MaxStep = 6; // 步骤长度
|
||||
}
|
||||
|
||||
message Config{
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -901,8 +901,15 @@ message AnnouncerLogInfo{
|
|||
// etcd /game/guide_config
|
||||
message GuideConfig {
|
||||
string Platform = 1; // 平台
|
||||
int32 On = 2; // 引导开关 1开启 2关闭
|
||||
int32 Skip = 3; // 引导跳过开关 1开启 2关闭
|
||||
repeated GuideInfo Info = 2;
|
||||
}
|
||||
message GuideInfo {
|
||||
int32 On = 1; // 引导开关 1开启 2关闭
|
||||
int32 Skip = 2; // 引导跳过开关 1开启 2关闭
|
||||
int32 GuideId = 3; // 引导类型 1-新手引导 2-竞技馆引导
|
||||
repeated ItemInfo Awards = 4; // 进入房间消耗
|
||||
int32 MaxStep = 5; // 步骤长度
|
||||
|
||||
}
|
||||
|
||||
//娃娃机配置视频
|
||||
|
|
|
@ -3093,12 +3093,15 @@ func CSUpdateAttribute(s *netlib.Session, packetId int, data interface{}, sid in
|
|||
if !ok {
|
||||
return nil
|
||||
}
|
||||
|
||||
if p.GuideData == nil {
|
||||
p.GuideData = make(map[int32]int32)
|
||||
}
|
||||
stepId := p.GuideStep + 1
|
||||
pack := &player_proto.SCUpdateAttribute{
|
||||
OpRetCode: player_proto.OpResultCode_OPRC_Error,
|
||||
Tp: msg.GetTp(),
|
||||
Param: msg.GetParam(),
|
||||
GuideId: msg.GuideId,
|
||||
}
|
||||
|
||||
send := func() {
|
||||
|
@ -3125,63 +3128,110 @@ func CSUpdateAttribute(s *netlib.Session, packetId int, data interface{}, sid in
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if msg.GuideId == 0 {
|
||||
return nil
|
||||
}
|
||||
if PlatformMgrSingleton.GetConfig(p.Platform).GuideConfig.Info[msg.GuideId] == nil {
|
||||
pack.OpRetCode = player_proto.OpResultCode_OPRC_Guide_Close
|
||||
send()
|
||||
return nil
|
||||
}
|
||||
cfg := PlatformMgrSingleton.GetConfig(p.Platform).GuideConfig.Info[msg.GuideId]
|
||||
switch msg.GetTp() {
|
||||
case common.AttributeGuideStep:
|
||||
if len(msg.GetParam()) == 0 || msg.GetParam()[0] == 0 || p.GuideStep < 0 {
|
||||
return nil
|
||||
}
|
||||
if PlatformMgrSingleton.GetConfig(p.Platform).GuideConfig.GetOn() != common.On {
|
||||
if cfg.GetOn() != common.On {
|
||||
pack.OpRetCode = player_proto.OpResultCode_OPRC_Guide_Close
|
||||
send()
|
||||
return nil
|
||||
}
|
||||
if p.GuideStep >= model.GameParamData.GuideStepMaxNum {
|
||||
pack.OpRetCode = player_proto.OpResultCode_OPRC_GuideStep_End
|
||||
if msg.GuideId == 1 {
|
||||
if p.GuideStep >= model.GameParamData.GuideStepMaxNum {
|
||||
pack.OpRetCode = player_proto.OpResultCode_OPRC_GuideStep_End
|
||||
send()
|
||||
return nil
|
||||
}
|
||||
if int64(p.GuideStep) >= msg.GetParam()[0] {
|
||||
pack.OpRetCode = player_proto.OpResultCode_OPRC_GuideStep_Finish
|
||||
send()
|
||||
return nil
|
||||
}
|
||||
if int64(p.GuideStep)+1 < msg.GetParam()[0] {
|
||||
pack.OpRetCode = player_proto.OpResultCode_OPRC_GuideStep_Front
|
||||
send()
|
||||
return nil
|
||||
}
|
||||
p.GuideStep = int32(msg.GetParam()[0])
|
||||
stepId = p.GuideStep
|
||||
pack.OpRetCode = player_proto.OpResultCode_OPRC_Sucess
|
||||
send()
|
||||
return nil
|
||||
}
|
||||
if int64(p.GuideStep) >= msg.GetParam()[0] {
|
||||
pack.OpRetCode = player_proto.OpResultCode_OPRC_GuideStep_Finish
|
||||
send()
|
||||
return nil
|
||||
}
|
||||
if int64(p.GuideStep)+1 < msg.GetParam()[0] {
|
||||
pack.OpRetCode = player_proto.OpResultCode_OPRC_GuideStep_Front
|
||||
send()
|
||||
return nil
|
||||
}
|
||||
p.GuideStep = int32(msg.GetParam()[0])
|
||||
stepId = p.GuideStep
|
||||
pack.OpRetCode = player_proto.OpResultCode_OPRC_Sucess
|
||||
send()
|
||||
// 获得10v卡
|
||||
if p.GuideStep == 2 {
|
||||
BagMgrSingleton.AddItems(&model.AddItemParam{
|
||||
Platform: p.Platform,
|
||||
SnId: p.SnId,
|
||||
Change: []*model.Item{
|
||||
{
|
||||
ItemId: common.ItemIDVCard,
|
||||
ItemNum: 10,
|
||||
// 获得10v卡
|
||||
if p.GuideStep == 2 {
|
||||
BagMgrSingleton.AddItems(&model.AddItemParam{
|
||||
Platform: p.Platform,
|
||||
SnId: p.SnId,
|
||||
Change: []*model.Item{
|
||||
{
|
||||
ItemId: common.ItemIDVCard,
|
||||
ItemNum: 10,
|
||||
},
|
||||
},
|
||||
},
|
||||
GainWay: common.GainWayGuide,
|
||||
Operator: "system",
|
||||
Remark: "新手引导奖励",
|
||||
})
|
||||
GainWay: common.GainWayGuide,
|
||||
Operator: "system",
|
||||
Remark: "新手引导奖励",
|
||||
})
|
||||
}
|
||||
} else {
|
||||
if p.GuideData[msg.GuideId] >= cfg.MaxStep {
|
||||
pack.OpRetCode = player_proto.OpResultCode_OPRC_GuideStep_End
|
||||
send()
|
||||
return nil
|
||||
}
|
||||
if int64(p.GuideData[msg.GuideId]) >= msg.GetParam()[0] {
|
||||
pack.OpRetCode = player_proto.OpResultCode_OPRC_GuideStep_Finish
|
||||
send()
|
||||
return nil
|
||||
}
|
||||
p.GuideData[msg.GuideId] = int32(msg.Param[0])
|
||||
if p.GuideData[msg.GuideId] == cfg.MaxStep {
|
||||
//发奖
|
||||
items := []*model.Item{}
|
||||
for _, award := range cfg.Awards {
|
||||
items = append(items, &model.Item{
|
||||
ItemId: award.ItemId,
|
||||
ItemNum: award.ItemNum,
|
||||
})
|
||||
}
|
||||
BagMgrSingleton.AddItems(&model.AddItemParam{
|
||||
Platform: p.Platform,
|
||||
SnId: p.SnId,
|
||||
Change: items,
|
||||
GainWay: common.GainWayGuide,
|
||||
Operator: "system",
|
||||
Remark: "新手引导奖励",
|
||||
})
|
||||
}
|
||||
}
|
||||
return nil
|
||||
case common.AttributeGuideSkip:
|
||||
if PlatformMgrSingleton.GetConfig(p.Platform).GuideConfig.GetSkip() != common.On {
|
||||
if cfg.GetSkip() != common.On {
|
||||
pack.OpRetCode = player_proto.OpResultCode_OPRC_Guide_SkipClose
|
||||
send()
|
||||
return nil
|
||||
}
|
||||
if p.GuideStep >= 0 && p.GuideStep < model.GameParamData.GuideStepMaxNum {
|
||||
p.GuideStep = -1 // 跳过引导为 -1
|
||||
if msg.GuideId == 1 {
|
||||
if p.GuideStep >= 0 && p.GuideStep < model.GameParamData.GuideStepMaxNum {
|
||||
p.GuideStep = -1 // 跳过引导为 -1
|
||||
pack.OpRetCode = player_proto.OpResultCode_OPRC_Sucess
|
||||
send()
|
||||
return nil
|
||||
}
|
||||
} else {
|
||||
pack.OpRetCode = player_proto.OpResultCode_OPRC_Sucess
|
||||
send()
|
||||
p.GuideData[msg.GuideId] = int32(msg.Param[0])
|
||||
return nil
|
||||
}
|
||||
case common.AttributeGuideTest:
|
||||
|
@ -3192,11 +3242,6 @@ func CSUpdateAttribute(s *netlib.Session, packetId int, data interface{}, sid in
|
|||
pack.OpRetCode = player_proto.OpResultCode_OPRC_Sucess
|
||||
send()
|
||||
return nil
|
||||
case common.AttributeGuideCustom:
|
||||
p.MarkFlag(common.PlayerFlagsGuideCustom)
|
||||
pack.OpRetCode = player_proto.OpResultCode_OPRC_Sucess
|
||||
send()
|
||||
return nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -321,7 +321,7 @@ func (this *Player) OnLogined() {
|
|||
if !this.IsRob {
|
||||
if isFirstLogin {
|
||||
cfg := PlatformMgrSingleton.GetConfig(this.Platform).GuideConfig
|
||||
if cfg == nil || cfg.GetOn() != common.On {
|
||||
if cfg == nil || cfg.Info[1] == nil || cfg.Info[1].GetOn() != common.On {
|
||||
this.GuideStep = -1
|
||||
}
|
||||
}
|
||||
|
@ -2743,6 +2743,7 @@ func (this *Player) SendPlayerInfo() {
|
|||
Signature: this.Signature,
|
||||
Age: this.Age,
|
||||
GuideStep: this.GuideStep,
|
||||
GuideData: this.GuideData,
|
||||
},
|
||||
}
|
||||
if this.Roles != nil {
|
||||
|
@ -4586,9 +4587,24 @@ func (this *Player) GetSkillAdd(id int32) int32 {
|
|||
|
||||
func (this *Player) SCGuide() {
|
||||
cfg := PlatformMgrSingleton.GetConfig(this.Platform).GuideConfig
|
||||
pack := &playerproto.SCGuideConfig{
|
||||
On: cfg.GetOn(),
|
||||
Skip: cfg.GetSkip(),
|
||||
pack := &playerproto.SCGuideConfig{}
|
||||
for _, data := range cfg.Info {
|
||||
var awards []*playerproto.ItemInfo
|
||||
for _, award := range data.Awards {
|
||||
item := &playerproto.ItemInfo{
|
||||
ItemId: award.GetItemId(),
|
||||
ItemNum: award.GetItemNum(),
|
||||
}
|
||||
awards = append(awards, item)
|
||||
}
|
||||
info := &playerproto.GuideInfo{
|
||||
On: data.GetOn(),
|
||||
Skip: data.GetSkip(),
|
||||
GuideId: data.GetGuideId(),
|
||||
Awards: awards,
|
||||
MaxStep: data.MaxStep,
|
||||
}
|
||||
pack.Info = append(pack.Info, info)
|
||||
}
|
||||
this.SendToClient(int(playerproto.PlayerPacketID_PACKET_SCGuideConfig), pack)
|
||||
logger.Logger.Tracef("SCGuideConfig: %v", pack)
|
||||
|
|
Loading…
Reference in New Issue