添加邮件测试功能,修复堆叠英雄bug
This commit is contained in:
parent
d5de595b59
commit
a943ca337a
@ -110,3 +110,9 @@ const (
|
||||
TASK_ACHIEVE TaskTag = 3 //成就
|
||||
TASK_STRATEGY TaskTag = 4 // 攻略
|
||||
)
|
||||
|
||||
const (
|
||||
MailLineEasy string = "mainline_data_easy" // 简单
|
||||
MailLineHard string = "mainline_data_hard" // 困难
|
||||
MailLinePurgatory string = "mainline_data_purgatory" // 炼狱
|
||||
)
|
||||
|
@ -17,7 +17,7 @@ type (
|
||||
|
||||
//邮件业务模块对外接口定义 提供给其他模块使用的
|
||||
Imail interface {
|
||||
CreateNewMail(uId string, mail *pb.DBMailData) bool
|
||||
CreateNewMail(session IUserSession, mail *pb.DBMailData) bool
|
||||
}
|
||||
//道具背包接口
|
||||
IItems interface {
|
||||
|
@ -269,10 +269,9 @@ func (this *ModelHero) setEquipment(hero *pb.DBHero) (newHero *pb.DBHero, err er
|
||||
}
|
||||
|
||||
update := make(map[string]interface{})
|
||||
if hero.IsOverlying {
|
||||
if hero.SameCount-1 > 0 {
|
||||
update["sameCount"] = hero.SameCount - 1
|
||||
}
|
||||
if hero.IsOverlying && hero.SameCount > 1 {
|
||||
hero.SameCount -= 1
|
||||
update["sameCount"] = hero.SameCount
|
||||
update["isOverlying"] = false
|
||||
if err = this.modifyHeroData(hero.Uid, hero.Id, update); err != nil {
|
||||
this.moduleHero.Errorf("%v", err)
|
||||
@ -291,6 +290,7 @@ func (this *ModelHero) setEquipment(hero *pb.DBHero) (newHero *pb.DBHero, err er
|
||||
return
|
||||
} else {
|
||||
update["equipID"] = hero.EquipID
|
||||
update["isoverlying"] = false
|
||||
}
|
||||
|
||||
this.modifyHeroData(hero.Uid, hero.Id, update)
|
||||
|
@ -34,7 +34,7 @@ func (this *modelMail) Init(service core.IService, module core.IModule, comp cor
|
||||
|
||||
func (this *modelMail) Mail_QueryUserMail(uId string) (mail []*pb.DBMailData, err error) {
|
||||
|
||||
if _data, err := this.DB.Find(DB_MailTable, bson.M{"userid": uId}); err == nil {
|
||||
if _data, err := this.DB.Find(DB_MailTable, bson.M{"uid": uId}); err == nil {
|
||||
for _data.Next(context.TODO()) {
|
||||
temp := &pb.DBMailData{}
|
||||
if err = _data.Decode(temp); err == nil {
|
||||
|
@ -46,7 +46,7 @@ func (this *Mail) OnInstallComp() {
|
||||
// Check: false,
|
||||
// Reward: false,
|
||||
// }
|
||||
func (this *Mail) CreateNewMail(uId string, mail *pb.DBMailData) bool {
|
||||
func (this *Mail) CreateNewMail(session comm.IUserSession, mail *pb.DBMailData) bool {
|
||||
|
||||
if mail == nil {
|
||||
return false
|
||||
@ -56,16 +56,13 @@ func (this *Mail) CreateNewMail(uId string, mail *pb.DBMailData) bool {
|
||||
this.ModuleBase.Errorf("create mail failed")
|
||||
}
|
||||
// 通知玩家
|
||||
this.AddNewMailPush(uId, mail)
|
||||
this.AddNewMailPush(session, mail)
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// 获得新邮件 推送给玩家
|
||||
func (this *Mail) AddNewMailPush(uid string, mail *pb.DBMailData) (err error) {
|
||||
if session, ok := this.GetUserSession(uid); ok {
|
||||
session.SendMsg(string(this.GetType()), "getnewmail", &pb.MailGetNewMailPush{Mail: mail})
|
||||
err = session.Push()
|
||||
}
|
||||
func (this *Mail) AddNewMailPush(session comm.IUserSession, mail *pb.DBMailData) (err error) {
|
||||
session.SendMsg(string(this.GetType()), "getnewmail", &pb.MailGetNewMailPush{Mail: mail})
|
||||
return
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.MainlineChalle
|
||||
var (
|
||||
curChapter *pb.DBMainline // 当前章节信息
|
||||
bBranch bool // 当前挑战关卡是不是分支
|
||||
bCheck bool
|
||||
)
|
||||
bBranch = false
|
||||
code = this.ChallengeCheck(session, req)
|
||||
@ -48,6 +49,16 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.MainlineChalle
|
||||
code = pb.ErrorCode_ConfigNoFound
|
||||
return
|
||||
}
|
||||
for _, v := range chaptConfig.Episode { // 校验是不是当前章节的关卡
|
||||
if v == int32(req.MainlineId) {
|
||||
bCheck = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !bCheck {
|
||||
code = pb.ErrorCode_ReqParameterError // 不是该章节的关卡
|
||||
return
|
||||
}
|
||||
if curChapter == nil {
|
||||
if len(chaptConfig.Episode) <= 0 {
|
||||
code = pb.ErrorCode_ConfigNoFound
|
||||
@ -69,7 +80,7 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.MainlineChalle
|
||||
//curChapter.MainlineId = chaptConfig.Fubendata[0] // 第一次挑战
|
||||
}
|
||||
// 根据难度找对应的配置文件
|
||||
if chaptConfig.Intensity == "1" { // 这里按临时配置读取 后面会修改
|
||||
if chaptConfig.Intensity == comm.MailLineEasy {
|
||||
con := this.module.configure.GetMainlineEasyChapter(int32(req.MainlineId)) // 根据配置文件找
|
||||
if con == nil {
|
||||
code = pb.ErrorCode_ConfigNoFound
|
||||
@ -86,7 +97,7 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.MainlineChalle
|
||||
}
|
||||
// TODO 调用战斗逻辑
|
||||
// 挑战成功
|
||||
curChapter.MainlineId += 1 // 临时数据 后面配置表完善查找
|
||||
curChapter.MainlineId = int32(req.MainlineId)
|
||||
if bBranch {
|
||||
curChapter.BranchID = append(curChapter.BranchID, int32(req.ChapterId)) // 记录分支关卡
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ type apiComp struct {
|
||||
service base.IRPCXService
|
||||
module *User
|
||||
hero comm.IHero
|
||||
mail comm.Imail
|
||||
}
|
||||
|
||||
func (this *apiComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
||||
@ -42,5 +43,10 @@ func (this *apiComp) Start() (err error) {
|
||||
return
|
||||
}
|
||||
this.hero = module.(comm.IHero)
|
||||
|
||||
if module, err = this.service.GetModule(comm.ModuleMail); err != nil {
|
||||
return
|
||||
}
|
||||
this.mail = module.(comm.Imail)
|
||||
return
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import (
|
||||
"go_dreamfactory/utils"
|
||||
"time"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
@ -114,6 +115,30 @@ func (this *apiComp) Login(session comm.IUserSession, req *pb.UserLoginReq) (cod
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
mail := &pb.DBMailData{
|
||||
ObjId: primitive.NewObjectID().Hex(),
|
||||
Uid: user.Uid,
|
||||
Title: "系统邮件",
|
||||
Contex: "恭喜获得专属礼包一份",
|
||||
CreateTime: uint64(time.Now().Unix()),
|
||||
DueTime: uint64(time.Now().Unix()) + 30*24*3600, // 30天需要走配置文件
|
||||
Check: false,
|
||||
Reward: false,
|
||||
}
|
||||
fj := make([]*pb.UserAssets, 0)
|
||||
atn1 := &pb.UserAssets{
|
||||
A: "hero",
|
||||
T: "25001",
|
||||
N: 1,
|
||||
}
|
||||
atn2 := &pb.UserAssets{
|
||||
A: "item",
|
||||
T: "10001",
|
||||
N: 100,
|
||||
}
|
||||
fj = append(fj, atn1)
|
||||
fj = append(fj, atn2)
|
||||
mail.Items = fj
|
||||
this.mail.CreateNewMail(session, mail)
|
||||
return
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user