引导功能实现

This commit is contained in:
by 2024-11-01 13:59:06 +08:00
parent 9f35e077f0
commit cdc51a2eba
8 changed files with 2195 additions and 1906 deletions

View File

@ -811,10 +811,9 @@ var (
)
const (
AttributeGuideStep = 1 // 引导步骤
AttributeGuideSkip = 2 // 跳过引导
AttributeGuideTest = 3 // 测试引导
AttributeGuideCustom = 4 // 竞技馆引导页
AttributeGuideStep = 1 // 引导步骤
AttributeGuideSkip = 2 // 跳过引导
AttributeGuideTest = 3 // 测试引导
)
const (

View File

@ -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

View File

@ -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

View File

@ -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; //
}
//

View File

@ -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
}

View File

@ -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)