跨服排行数据显示区服id
This commit is contained in:
parent
52ae906373
commit
ec65a9d6a4
@ -340,12 +340,6 @@ type (
|
||||
CompleteAllLevel(session IUserSession) (errdata *pb.ErrorData)
|
||||
CheckUserBaseVikingInfo(uid string) (data []*pb.DBVikingRank) // 查询玩家最佳通关记录
|
||||
IGetReddot
|
||||
// 自动购买门票
|
||||
AutoBuyTicket(session IUserSession, bossId, difficulty int32) (errdata *pb.ErrorData)
|
||||
// 自动战斗 战斗信息
|
||||
AutoBattleInfo(session IUserSession, battle *pb.BattleFormation, bossId, difficulty int32) (errdata *pb.ErrorData, battleInfo *pb.BattleInfo)
|
||||
AutoBattleOver(session IUserSession, Report *pb.BattleReport, autoBattle *pb.DBAutoBattle) (errdata *pb.ErrorData, atno []*pb.UserAtno)
|
||||
CheckBattelParameter(session IUserSession, battle *pb.BattleFormation, bossid, difficulty int32) (errdata *pb.ErrorData)
|
||||
}
|
||||
IHunting interface {
|
||||
CompleteAllLevel(session IUserSession) (errdata *pb.ErrorData)
|
||||
|
@ -24,16 +24,18 @@ func (this *apiComp) SeasonRankCheck(session comm.IUserSession, req *pb.VikingSe
|
||||
|
||||
func (this *apiComp) SeasonRank(session comm.IUserSession, req *pb.VikingSeasonRankReq) (errdata *pb.ErrorData) {
|
||||
var (
|
||||
szRank []*pb.DBVSeasonRank
|
||||
rd *redis.StringSliceCmd
|
||||
conn *db.DBConn
|
||||
pipe *pipe.RedisPipe
|
||||
err error
|
||||
szRank []*pb.DBVSeasonRank
|
||||
rd *redis.StringSliceCmd
|
||||
conn *db.DBConn
|
||||
pipe *pipe.RedisPipe
|
||||
err error
|
||||
endSeasonTime int64
|
||||
bCross bool // 是否是跨服
|
||||
)
|
||||
if errdata = this.SeasonRankCheck(session, req); errdata != nil {
|
||||
return // 参数校验失败直接返回
|
||||
}
|
||||
if this.module.CheckCurSeasonData() {
|
||||
if bCross, endSeasonTime = this.module.CheckCurSeasonData(); bCross {
|
||||
conn, err = db.Local()
|
||||
if err != nil {
|
||||
errdata = &pb.ErrorData{
|
||||
@ -70,6 +72,9 @@ func (this *apiComp) SeasonRank(session comm.IUserSession, req *pb.VikingSeasonR
|
||||
}
|
||||
}
|
||||
|
||||
session.SendMsg(string(this.module.GetType()), VikingSeasonRankReq, &pb.VikingSeasonRankResp{Ranks: szRank})
|
||||
session.SendMsg(string(this.module.GetType()), VikingSeasonRankReq, &pb.VikingSeasonRankResp{
|
||||
Ranks: szRank,
|
||||
Etime: endSeasonTime,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
@ -232,158 +232,12 @@ func (this *Viking) CompleteAllLevel(session comm.IUserSession) (errdata *pb.Err
|
||||
return
|
||||
}
|
||||
|
||||
func (this *Viking) AutoBuyTicket(session comm.IUserSession, bossId, difficulty int32) (errdata *pb.ErrorData) {
|
||||
conf, _ := this.configure.GetVikingBossConfigData(bossId, difficulty)
|
||||
if errdata := this.CheckRes(session, conf.PsConsume); errdata != nil {
|
||||
amount := int32(this.ModuleItems.QueryItemAmount(session.GetUserId(), conf.PsConsume[0].T)) // 获取当前数量
|
||||
if amount < conf.PsConsume[0].N { // 数量不足直接购买
|
||||
errdata = this.api.Buy(session, &pb.VikingBuyReq{
|
||||
Count: conf.PsConsume[0].N - amount,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (this *Viking) AutoBattleInfo(session comm.IUserSession, battle *pb.BattleFormation, bossId, difficulty int32) (errdata *pb.ErrorData, battleInfo *pb.BattleInfo) {
|
||||
|
||||
cfgData, _ := this.configure.GetVikingBossConfigData(bossId, difficulty)
|
||||
if cfgData == nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ConfigNoFound,
|
||||
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
errdata, record := this.battle.CreatePveBattle(session, &pb.BattlePVEReq{
|
||||
Ptype: pb.PlayType_viking,
|
||||
Title: "",
|
||||
Format: battle,
|
||||
Mformat: cfgData.Boss,
|
||||
})
|
||||
if errdata == nil {
|
||||
battleInfo = &pb.BattleInfo{
|
||||
Id: record.Id,
|
||||
Title: record.Title,
|
||||
Rulesid: cfgData.BattleReadyID,
|
||||
Btype: record.Btype,
|
||||
Ptype: record.Ptype, RedCompId: record.RedCompId,
|
||||
Redflist: record.Redflist,
|
||||
BlueCompId: record.BlueCompId,
|
||||
Buleflist: record.Buleflist,
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// 自动战斗完成
|
||||
func (this *Viking) AutoBattleOver(session comm.IUserSession, Report *pb.BattleReport, autoBattle *pb.DBAutoBattle) (errdata *pb.ErrorData, atno []*pb.UserAtno) {
|
||||
bossId := autoBattle.BossId
|
||||
difficulty := autoBattle.Difficulty
|
||||
atno = make([]*pb.UserAtno, 0)
|
||||
conf, _ := this.configure.GetVikingBossConfigData(bossId, difficulty)
|
||||
tasks := make([]*pb.BuriedParam, 0)
|
||||
|
||||
if errdata = this.ConsumeRes(session, conf.PsConsume, true); errdata != nil {
|
||||
return
|
||||
}
|
||||
viking, err := this.modelViking.getVikingList(session.GetUserId())
|
||||
if err != nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_VikingBoosType,
|
||||
Title: pb.ErrorCode_VikingBoosType.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
errdata, bWin := this.battle.CheckBattleReport(session, Report)
|
||||
if !bWin { // 战斗失败了 直接返回
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_BattleNoWin,
|
||||
Title: pb.ErrorCode_BattleNoWin.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
if autoBattle != nil {
|
||||
if autoBattle.AutoBuy {
|
||||
errdata = this.AutoBuyTicket(session, bossId, difficulty)
|
||||
}
|
||||
}
|
||||
mapData := make(map[string]interface{}, 0)
|
||||
vikingCfg, _ := this.configure.GetVikingBossConfigData(bossId, difficulty)
|
||||
if vikingCfg == nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ConfigNoFound,
|
||||
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
key := strconv.Itoa(int(bossId)) + "_" + strconv.Itoa(int(difficulty))
|
||||
if viking.BossTime[key] == 0 { // 新关卡挑战通过 发放首通奖励
|
||||
viking.Boss[bossId]++
|
||||
mapData["boss"] = viking.Boss
|
||||
if c, res1 := this.DispenseAtno(session, vikingCfg.Firstprize, true); c == nil {
|
||||
atno = append(atno, res1...)
|
||||
} else {
|
||||
errdata = c
|
||||
return
|
||||
}
|
||||
}
|
||||
this.CheckRank(session.GetUserId(), bossId, difficulty, Report)
|
||||
reward := this.configure.GetDropReward(vikingCfg.Drop) // 获取掉落奖励
|
||||
if c, res1 := this.DispenseAtno(session, reward, true); c == nil {
|
||||
atno = append(atno, res1...)
|
||||
} else {
|
||||
errdata = c
|
||||
return
|
||||
}
|
||||
|
||||
mapData["bossTime"] = viking.BossTime // 更新时间
|
||||
|
||||
errdata = this.ModifyVikingData(session.GetUserId(), mapData)
|
||||
|
||||
if user := this.ModuleUser.GetUser(session.GetUserId()); user != nil {
|
||||
if module, err := this.service.GetModule(comm.ModuleChat); err == nil {
|
||||
module.(comm.IChat).SendSysChatToWorld(comm.ChatSystem14, nil, bossId, difficulty, user.Name)
|
||||
}
|
||||
}
|
||||
// 随机任务统计
|
||||
tasks = append(tasks, comm.GetBuriedParam(comm.Rtype73, 1, bossId, difficulty))
|
||||
tasks = append(tasks, comm.GetBuriedParam(comm.Rtype78, difficulty, bossId, Report.Costtime))
|
||||
if Report != nil && Report.Info != nil && len(Report.Info.Redflist) > 0 {
|
||||
for _, v := range Report.Info.Redflist[0].Team {
|
||||
if v.Ishelp { // 判断是否有助战
|
||||
// this.ModuleBuried.SendToRtask(session, comm.Rtype79, difficulty, bossId)
|
||||
tasks = append(tasks, comm.GetBuriedParam(comm.Rtype78, difficulty, bossId, Report.Costtime))
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.ModuleBuried.TriggerBuried(session.GetUserId(), tasks...)
|
||||
return
|
||||
}
|
||||
|
||||
func (this *Viking) CheckBattelParameter(session comm.IUserSession, battle *pb.BattleFormation, bossid, difficulty int32) (errdata *pb.ErrorData) {
|
||||
errdata = this.api.Challenge(session, &pb.VikingChallengeReq{
|
||||
BossId: bossid,
|
||||
Difficulty: difficulty,
|
||||
Battle: battle,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// 检查当前赛季是在本服还是在跨服
|
||||
func (this *Viking) CheckCurSeasonData() (bLocal bool) {
|
||||
func (this *Viking) CheckCurSeasonData() (bLocal bool, endSeasonTime int64) {
|
||||
openTime := this.service.GetOpentime().Unix()
|
||||
this.Debugf("%d", openTime)
|
||||
// 获取第一个赛季结束的时间
|
||||
endSeasonTime := utils.GetTodayZeroTime(openTime) //+ int64((6-d)*3600*24)
|
||||
endSeasonTime = utils.GetTodayZeroTime(openTime) //+ int64((6-d)*3600*24)
|
||||
this.Debugf("%d", endSeasonTime)
|
||||
|
||||
var c int32
|
||||
@ -396,9 +250,9 @@ func (this *Viking) CheckCurSeasonData() (bLocal bool) {
|
||||
// 只需判断当前时间是否大于第c个赛季即可
|
||||
endSeasonTime += 14 * 3600 * 24 * int64(c)
|
||||
if endSeasonTime <= configure.Now().Unix() {
|
||||
return false
|
||||
return false, endSeasonTime
|
||||
}
|
||||
return true
|
||||
return true, endSeasonTime
|
||||
}
|
||||
|
||||
// 检查上一个赛季实在本服还是在跨服
|
||||
@ -431,7 +285,7 @@ func (this *Viking) CheckSeasonRank(uid string, boosID int32, difficulty int32,
|
||||
err error
|
||||
bcross bool
|
||||
)
|
||||
bcross = this.CheckCurSeasonData()
|
||||
bcross, _ = this.CheckCurSeasonData()
|
||||
if bcross {
|
||||
conn_, err = db.Cross() // 获取跨服数据库对象
|
||||
if err != nil {
|
||||
@ -484,6 +338,7 @@ func (this *Viking) CheckSeasonRank(uid string, boosID int32, difficulty int32,
|
||||
Leadpos: leadpos,
|
||||
Line: szLine,
|
||||
Huihe: huihe,
|
||||
Sid: userinfo.Sid,
|
||||
}
|
||||
objID = new.Id
|
||||
model.AddList(uid, new.Id, new)
|
||||
|
@ -244,6 +244,7 @@ type DBVSeasonRank struct {
|
||||
Leadpos int32 `protobuf:"varint,8,opt,name=leadpos,proto3" json:"leadpos"` //队长位置
|
||||
Line []*LineUp `protobuf:"bytes,9,rep,name=line,proto3" json:"line"` // 阵容数据
|
||||
Huihe int32 `protobuf:"varint,10,opt,name=huihe,proto3" json:"huihe"` // 平均回合数 建议*10
|
||||
Sid string `protobuf:"bytes,11,opt,name=sid,proto3" json:"sid" bson:"sid"` //区服id
|
||||
}
|
||||
|
||||
func (x *DBVSeasonRank) Reset() {
|
||||
@ -348,6 +349,13 @@ func (x *DBVSeasonRank) GetHuihe() int32 {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *DBVSeasonRank) GetSid() string {
|
||||
if x != nil {
|
||||
return x.Sid
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
var File_viking_viking_db_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_viking_viking_db_proto_rawDesc = []byte{
|
||||
@ -398,7 +406,7 @@ var file_viking_viking_db_proto_rawDesc = []byte{
|
||||
0x04, 0x6c, 0x69, 0x6e, 0x65, 0x18, 0x09, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x07, 0x2e, 0x4c, 0x69,
|
||||
0x6e, 0x65, 0x55, 0x70, 0x52, 0x04, 0x6c, 0x69, 0x6e, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x6f,
|
||||
0x73, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x63, 0x6f,
|
||||
0x73, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x22, 0xfa, 0x01, 0x0a, 0x0d, 0x44, 0x42, 0x56, 0x53, 0x65,
|
||||
0x73, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x22, 0x8c, 0x02, 0x0a, 0x0d, 0x44, 0x42, 0x56, 0x53, 0x65,
|
||||
0x61, 0x73, 0x6f, 0x6e, 0x52, 0x61, 0x6e, 0x6b, 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, 0x1e, 0x0a, 0x0a, 0x64, 0x69,
|
||||
@ -414,8 +422,9 @@ var file_viking_viking_db_proto_rawDesc = []byte{
|
||||
0x12, 0x1b, 0x0a, 0x04, 0x6c, 0x69, 0x6e, 0x65, 0x18, 0x09, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x07,
|
||||
0x2e, 0x4c, 0x69, 0x6e, 0x65, 0x55, 0x70, 0x52, 0x04, 0x6c, 0x69, 0x6e, 0x65, 0x12, 0x14, 0x0a,
|
||||
0x05, 0x68, 0x75, 0x69, 0x68, 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x68, 0x75,
|
||||
0x69, 0x68, 0x65, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f,
|
||||
0x74, 0x6f, 0x33,
|
||||
0x69, 0x68, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x73, 0x69, 0x64, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x09,
|
||||
0x52, 0x03, 0x73, 0x69, 0x64, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70,
|
||||
0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
|
@ -651,6 +651,7 @@ type VikingSeasonRankResp struct {
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Ranks []*DBVSeasonRank `protobuf:"bytes,1,rep,name=ranks,proto3" json:"ranks"` // 排行数据 有序的 注意boss类型
|
||||
Etime int64 `protobuf:"varint,2,opt,name=etime,proto3" json:"etime"`
|
||||
}
|
||||
|
||||
func (x *VikingSeasonRankResp) Reset() {
|
||||
@ -692,6 +693,13 @@ func (x *VikingSeasonRankResp) GetRanks() []*DBVSeasonRank {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *VikingSeasonRankResp) GetEtime() int64 {
|
||||
if x != nil {
|
||||
return x.Etime
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
var File_viking_viking_msg_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_viking_viking_msg_proto_rawDesc = []byte{
|
||||
@ -764,12 +772,13 @@ var file_viking_viking_msg_proto_rawDesc = []byte{
|
||||
0x61, 0x6e, 0x6b, 0x73, 0x22, 0x31, 0x0a, 0x13, 0x56, 0x69, 0x6b, 0x69, 0x6e, 0x67, 0x53, 0x65,
|
||||
0x61, 0x73, 0x6f, 0x6e, 0x52, 0x61, 0x6e, 0x6b, 0x52, 0x65, 0x71, 0x12, 0x1a, 0x0a, 0x08, 0x62,
|
||||
0x6f, 0x6f, 0x73, 0x54, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x62,
|
||||
0x6f, 0x6f, 0x73, 0x54, 0x79, 0x70, 0x65, 0x22, 0x3c, 0x0a, 0x14, 0x56, 0x69, 0x6b, 0x69, 0x6e,
|
||||
0x6f, 0x6f, 0x73, 0x54, 0x79, 0x70, 0x65, 0x22, 0x52, 0x0a, 0x14, 0x56, 0x69, 0x6b, 0x69, 0x6e,
|
||||
0x67, 0x53, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x52, 0x61, 0x6e, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x12,
|
||||
0x24, 0x0a, 0x05, 0x72, 0x61, 0x6e, 0x6b, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0e,
|
||||
0x2e, 0x44, 0x42, 0x56, 0x53, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x52, 0x61, 0x6e, 0x6b, 0x52, 0x05,
|
||||
0x72, 0x61, 0x6e, 0x6b, 0x73, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70,
|
||||
0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x72, 0x61, 0x6e, 0x6b, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x02,
|
||||
0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x65, 0x74, 0x69, 0x6d, 0x65, 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