同步套装id信息
This commit is contained in:
parent
257e044e08
commit
36c74e2323
@ -664,6 +664,7 @@ func (this *MCompModel) GetUserRecord(uid string) (result *pb.DBUserRecord, err
|
||||
|
||||
//修改用户扩展数据
|
||||
func (this *MCompModel) ChangeUserRecord(uid string, value map[string]interface{}) (err error) {
|
||||
value["mtime"] = time.Now().Unix() // 更新时间
|
||||
key := fmt.Sprintf("userrecord:%s", uid)
|
||||
if err = this.Redis.HMSet(key, value); err != nil && err != redis.RedisNil {
|
||||
return
|
||||
|
@ -20,17 +20,17 @@ func (this *apiComp) DrawCardCheck(session comm.IUserSession, req *pb.HeroDrawCa
|
||||
//抽卡
|
||||
func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq) (code pb.ErrorCode, data proto.Message) {
|
||||
var (
|
||||
szCards []int32 // 最终抽到的卡牌
|
||||
totalWeight int64 // 总权重
|
||||
curWeigth int64 // 临时随机获得的权重
|
||||
drawTimes int32 // 抽卡次数
|
||||
hitStar4 int32 // 抽了多少次还没获得4星英雄
|
||||
hitStar5 int32 // 抽了多少次还没获得5星英雄
|
||||
hitStar int32 // 抽中几星
|
||||
curStar4Count int32 // 当前4星没抽到的次数
|
||||
curStar5Count int32 // 当前5星没抽到的次数
|
||||
floor4Count int32 // 4星保底次数
|
||||
floor5Count int32 // 5星保底次数
|
||||
szCards []int32 // 最终抽到的卡牌
|
||||
totalWeight int64 // 总权重
|
||||
curWeigth int64 // 临时随机获得的权重
|
||||
drawTimes int32 // 抽卡次数
|
||||
hitStar4 int32 // 抽了多少次还没获得4星英雄
|
||||
hitStar5 int32 // 抽了多少次还没获得5星英雄
|
||||
//hitStar int32 // 抽中几星
|
||||
curStar4Count int32 // 当前4星没抽到的次数
|
||||
curStar5Count int32 // 当前5星没抽到的次数
|
||||
floor4Count int32 // 4星保底次数
|
||||
floor5Count int32 // 5星保底次数
|
||||
|
||||
)
|
||||
szCards = make([]int32, 0)
|
||||
@ -39,6 +39,44 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq
|
||||
//curStar5Count = this.GetFloorStarData(req.DrawType, session.GetUserId(), 5)
|
||||
this.module.Debugf("当前4星抽卡没中次数:%d, 当前5星抽卡没中次数:%d", curStar4Count, curStar5Count)
|
||||
|
||||
rst, err := this.module.modelHero.GetUserRecord(session.GetUserId())
|
||||
if err != nil {
|
||||
|
||||
}
|
||||
for k, v := range rst.Floors {
|
||||
if req.DrawType == 1 || req.DrawType == 2 {
|
||||
if k == "p4" {
|
||||
curStar4Count = v
|
||||
} else if k == "p5" {
|
||||
curStar5Count = v
|
||||
}
|
||||
} else if req.DrawType == 3 || req.DrawType == 4 {
|
||||
if k == "o4" {
|
||||
curStar4Count = v
|
||||
} else if k == "o5" {
|
||||
curStar5Count = v
|
||||
}
|
||||
} else if req.DrawType == 5 || req.DrawType == 6 {
|
||||
if k == "t4" {
|
||||
curStar4Count = v
|
||||
} else if k == "t5" {
|
||||
curStar5Count = v
|
||||
}
|
||||
} else if req.DrawType == 7 || req.DrawType == 8 {
|
||||
if k == "th4" {
|
||||
curStar4Count = v
|
||||
} else if k == "th5" {
|
||||
curStar5Count = v
|
||||
}
|
||||
} else if req.DrawType == 9 || req.DrawType == 10 {
|
||||
if k == "f4" {
|
||||
curStar4Count = v
|
||||
} else if k == "f5" {
|
||||
curStar5Count = v
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
// 抽卡相关
|
||||
// 获取配置文件的权重信息
|
||||
_conf, err := this.module.configure.GetHeroDrawConfig()
|
||||
@ -85,12 +123,12 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq
|
||||
if _getCardCfg.Star == 4 { // 当抽取到的英雄是4星的时候 清除 该类型的保底次数
|
||||
//SetFloorStarData(req.DrawType, session.GetUserId(), 4)
|
||||
hitStar4 = 0
|
||||
hitStar = 4
|
||||
//hitStar = 4
|
||||
break
|
||||
} else if _getCardCfg.Star == 5 { // 当抽取到的英雄是5星的时候 清除 该类型的保底次数
|
||||
//SetFloorStarData(req.DrawType, session.GetUserId(), 5)
|
||||
hitStar5 = 0 // 清0
|
||||
hitStar = 5
|
||||
//hitStar = 5
|
||||
break
|
||||
}
|
||||
hitStar4++
|
||||
@ -106,11 +144,16 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq
|
||||
break
|
||||
}
|
||||
}
|
||||
if hitStar != 0 {
|
||||
hitStar = 0
|
||||
//ModifyFloorStarData(req.DrawType, session.GetUserId(), hitStar) // 重置该星级保底
|
||||
}
|
||||
// if hitStar != 0 {
|
||||
// hitStar = 0
|
||||
// //ModifyFloorStarData(req.DrawType, session.GetUserId(), hitStar) // 重置该星级保底
|
||||
// }
|
||||
}
|
||||
// 更新record 配置信息
|
||||
update := map[string]interface{}{
|
||||
"floors": nil,
|
||||
}
|
||||
this.module.modelHero.ChangeUserRecord(session.GetUserId(), update)
|
||||
if hitStar4 != 0 {
|
||||
//AddFloorStarData(req.DrawType, session.GetUserId(), 4, hitStar4) // 增加4星保底次数
|
||||
}
|
||||
@ -129,25 +172,3 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq
|
||||
session.SendMsg(string(this.module.GetType()), DrawCard, rsp)
|
||||
return
|
||||
}
|
||||
|
||||
// // 获取当前卡牌类型保底次数
|
||||
// func GetFloorStarData(drawType int32, uid string, star int32) (count int32) {
|
||||
// return
|
||||
// }
|
||||
|
||||
// // 清除保底信息(drawType 抽卡类型)
|
||||
// func SetFloorStarData(drawType int32, uid string, star int32) {
|
||||
// return
|
||||
// }
|
||||
|
||||
// // 当前没有抽中 增加保底次数
|
||||
// func AddFloorStarData(drawType int32, uid string, star int32, count int32) {
|
||||
|
||||
// return
|
||||
// }
|
||||
|
||||
// // 当前有抽中 修改保底次数
|
||||
// func ModifyFloorStarData(drawType int32, uid string, star int32) {
|
||||
|
||||
// return
|
||||
// }
|
||||
|
@ -293,7 +293,6 @@ func (this *ModelHero) setEquipment(hero *pb.DBHero) (newHero *pb.DBHero, err er
|
||||
this.moduleHero.Errorf("%v", err)
|
||||
return
|
||||
}
|
||||
|
||||
//创建新卡
|
||||
newHero, err = this.createOneHero(hero.Uid, hero.HeroID)
|
||||
if err != nil {
|
||||
@ -301,18 +300,22 @@ func (this *ModelHero) setEquipment(hero *pb.DBHero) (newHero *pb.DBHero, err er
|
||||
return
|
||||
}
|
||||
newHero.EquipID = hero.EquipID
|
||||
hero = newHero
|
||||
update["suiteId"] = hero.SuiteId
|
||||
update["suiteExtId"] = hero.SuiteExtId
|
||||
update["equipID"] = hero.EquipID
|
||||
update["isoverlying"] = false
|
||||
this.modifyHeroData(newHero.Uid, newHero.Id, update)
|
||||
return
|
||||
} else {
|
||||
update["equipID"] = hero.EquipID
|
||||
update["isoverlying"] = false
|
||||
update["suiteId"] = hero.SuiteId
|
||||
update["suiteExtId"] = hero.SuiteExtId
|
||||
this.modifyHeroData(hero.Uid, hero.Id, update)
|
||||
}
|
||||
// 打印
|
||||
for _, v := range hero.EquipID {
|
||||
this.moduleHero.Debugf("设置装备%s\n", v)
|
||||
}
|
||||
this.modifyHeroData(hero.Uid, hero.Id, update)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -59,29 +59,35 @@ func (this *Hero) GetHero(uid, heroId string) (*pb.DBHero, pb.ErrorCode) {
|
||||
|
||||
//佩戴装备
|
||||
func (this *Hero) UpdateEquipment(session comm.IUserSession, hero *pb.DBHero, equip []*pb.DB_Equipment) (code pb.ErrorCode) {
|
||||
var (
|
||||
tagHero *pb.DBHero // 目标英雄 有可能是创建了新的英雄对象
|
||||
)
|
||||
if hero == nil {
|
||||
code = pb.ErrorCode_HeroNoExist
|
||||
return
|
||||
}
|
||||
tagHero = hero
|
||||
list := make([]*pb.DBHero, 0)
|
||||
if newHero, err := this.modelHero.setEquipment(hero); err != nil {
|
||||
code = pb.ErrorCode_HeroEquipUpdate
|
||||
return
|
||||
} else {
|
||||
|
||||
if newHero != nil {
|
||||
list = append(list, newHero)
|
||||
tagHero = newHero
|
||||
}
|
||||
}
|
||||
m, err1 := this.modelHero.PushHeroProperty(session, hero.Id) // 推送属性变化
|
||||
list = append(list, hero)
|
||||
|
||||
m, err1 := this.modelHero.PushHeroProperty(session, tagHero.Id) // 推送属性变化
|
||||
if err1 != nil {
|
||||
code = pb.ErrorCode_Unknown
|
||||
this.Errorf("PushHeroProperty err!")
|
||||
}
|
||||
hero.Property = m
|
||||
list = append(list, hero)
|
||||
tagHero.Property = m
|
||||
|
||||
session.SendMsg("hero", "change", &pb.HeroChangePush{List: list})
|
||||
this.modelHero.setEquipProperty(hero, equip)
|
||||
this.modelHero.setEquipProperty(tagHero, equip)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -5,9 +5,9 @@ option go_package = ".;pb";
|
||||
//用户扩展数据
|
||||
message DBUserRecord {
|
||||
string id = 1; //@go_tags(`bson:"_id"`) ID 主键id
|
||||
string uid = 2; // 用户id
|
||||
string uid = 2; //@go_tags(`bson:"uid"`) 用户ID
|
||||
map<string,int32> floors = 3; // 保底信息
|
||||
int32 triggernum = 4; // 没有触发次数
|
||||
int64 mtime = 5; // 修改时间
|
||||
int64 ctime = 6; // 创建时间
|
||||
int32 triggernum = 4; // 活动数据 存放没有触发次数
|
||||
int32 activityid = 5; // 活动id
|
||||
int64 mtime = 6; // 修改时间
|
||||
}
|
@ -27,11 +27,11 @@ type DBUserRecord struct {
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id" bson:"_id"` //ID 主键id
|
||||
Uid string `protobuf:"bytes,2,opt,name=uid,proto3" json:"uid"` // 用户id
|
||||
Uid string `protobuf:"bytes,2,opt,name=uid,proto3" json:"uid" bson:"uid"` //用户ID
|
||||
Floors map[string]int32 `protobuf:"bytes,3,rep,name=floors,proto3" json:"floors" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` // 保底信息
|
||||
Triggernum int32 `protobuf:"varint,4,opt,name=triggernum,proto3" json:"triggernum"` // 没有触发次数
|
||||
Mtime int64 `protobuf:"varint,5,opt,name=mtime,proto3" json:"mtime"` // 修改时间
|
||||
Ctime int64 `protobuf:"varint,6,opt,name=ctime,proto3" json:"ctime"` // 创建时间
|
||||
Triggernum int32 `protobuf:"varint,4,opt,name=triggernum,proto3" json:"triggernum"` // 活动数据 存放没有触发次数
|
||||
Activityid int32 `protobuf:"varint,5,opt,name=activityid,proto3" json:"activityid"` // 活动id
|
||||
Mtime int64 `protobuf:"varint,6,opt,name=mtime,proto3" json:"mtime"` // 修改时间
|
||||
}
|
||||
|
||||
func (x *DBUserRecord) Reset() {
|
||||
@ -94,16 +94,16 @@ func (x *DBUserRecord) GetTriggernum() int32 {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *DBUserRecord) GetMtime() int64 {
|
||||
func (x *DBUserRecord) GetActivityid() int32 {
|
||||
if x != nil {
|
||||
return x.Mtime
|
||||
return x.Activityid
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *DBUserRecord) GetCtime() int64 {
|
||||
func (x *DBUserRecord) GetMtime() int64 {
|
||||
if x != nil {
|
||||
return x.Ctime
|
||||
return x.Mtime
|
||||
}
|
||||
return 0
|
||||
}
|
||||
@ -112,7 +112,7 @@ var File_userrecord_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_userrecord_proto_rawDesc = []byte{
|
||||
0x0a, 0x10, 0x75, 0x73, 0x65, 0x72, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x2e, 0x70, 0x72, 0x6f,
|
||||
0x74, 0x6f, 0x22, 0xea, 0x01, 0x0a, 0x0c, 0x44, 0x42, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x63,
|
||||
0x74, 0x6f, 0x22, 0xf4, 0x01, 0x0a, 0x0c, 0x44, 0x42, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x63,
|
||||
0x6f, 0x72, 0x64, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
|
||||
0x02, 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09,
|
||||
0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x31, 0x0a, 0x06, 0x66, 0x6c, 0x6f, 0x6f, 0x72, 0x73, 0x18,
|
||||
@ -120,14 +120,15 @@ var file_userrecord_proto_rawDesc = []byte{
|
||||
0x63, 0x6f, 0x72, 0x64, 0x2e, 0x46, 0x6c, 0x6f, 0x6f, 0x72, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79,
|
||||
0x52, 0x06, 0x66, 0x6c, 0x6f, 0x6f, 0x72, 0x73, 0x12, 0x1e, 0x0a, 0x0a, 0x74, 0x72, 0x69, 0x67,
|
||||
0x67, 0x65, 0x72, 0x6e, 0x75, 0x6d, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x74, 0x72,
|
||||
0x69, 0x67, 0x67, 0x65, 0x72, 0x6e, 0x75, 0x6d, 0x12, 0x14, 0x0a, 0x05, 0x6d, 0x74, 0x69, 0x6d,
|
||||
0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x6d, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x14,
|
||||
0x0a, 0x05, 0x63, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x63,
|
||||
0x74, 0x69, 0x6d, 0x65, 0x1a, 0x39, 0x0a, 0x0b, 0x46, 0x6c, 0x6f, 0x6f, 0x72, 0x73, 0x45, 0x6e,
|
||||
0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
|
||||
0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02,
|
||||
0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42,
|
||||
0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x69, 0x67, 0x67, 0x65, 0x72, 0x6e, 0x75, 0x6d, 0x12, 0x1e, 0x0a, 0x0a, 0x61, 0x63, 0x74, 0x69,
|
||||
0x76, 0x69, 0x74, 0x79, 0x69, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x61, 0x63,
|
||||
0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x6d, 0x74, 0x69, 0x6d,
|
||||
0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x6d, 0x74, 0x69, 0x6d, 0x65, 0x1a, 0x39,
|
||||
0x0a, 0x0b, 0x46, 0x6c, 0x6f, 0x6f, 0x72, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a,
|
||||
0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12,
|
||||
0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05,
|
||||
0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70,
|
||||
0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
|
Loading…
Reference in New Issue
Block a user