Merge branch 'meixiongfeng' of http://git.legu.cc/liwei_3d/go_dreamfactory into dev
This commit is contained in:
commit
4310615605
@ -62,7 +62,6 @@ func (this *ModelRank) getPagodaRankListByFloorid(uid string, floorid int32) *pb
|
||||
return nil
|
||||
}
|
||||
|
||||
//设置本服
|
||||
func (this *ModelRank) SetNormalPagodaRankList(tableName string, score int32, uid string) {
|
||||
|
||||
var (
|
||||
|
@ -5,6 +5,7 @@ import (
|
||||
"go_dreamfactory/pb"
|
||||
"go_dreamfactory/sys/configure"
|
||||
cfg "go_dreamfactory/sys/configure/structs"
|
||||
"strconv"
|
||||
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
@ -25,6 +26,7 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.VikingChal
|
||||
newChallenge bool // 新的关卡
|
||||
reward []*cfg.Gameatn
|
||||
asset []*pb.UserAssets
|
||||
costTime int32 // 战斗花费的时间
|
||||
)
|
||||
mapData = make(map[string]interface{}, 0)
|
||||
reward = make([]*cfg.Gameatn, 0)
|
||||
@ -69,7 +71,8 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.VikingChal
|
||||
mapData["boss"] = viking.Boss
|
||||
}
|
||||
|
||||
if req.Report != nil && req.Report.Info != nil && len(req.Report.Info.Redflist) > 0 && value == req.Difficulty {
|
||||
if req.Report != nil && req.Report.Info != nil && len(req.Report.Info.Redflist) > 0 {
|
||||
costTime = req.Report.Costtime
|
||||
sz := make([]*pb.LineUp, 5)
|
||||
for i, v := range req.Report.Info.Redflist[0].Team {
|
||||
if v != nil {
|
||||
@ -99,8 +102,22 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.VikingChal
|
||||
mapData["leftCount"] = viking.LeftCount
|
||||
viking.ChallengeCount++
|
||||
mapData["challengeCount"] = viking.ChallengeCount
|
||||
code = this.module.ModifyVikingData(session.GetUserId(), mapData)
|
||||
if newChallenge { // 新关卡挑战通过 发放首通奖励
|
||||
|
||||
// 写入排行榜
|
||||
if newChallenge {
|
||||
this.module.modulerank.SetRankListData("vikingRank"+strconv.Itoa(int(req.BossId)), req.Difficulty<<16+costTime, session.GetUserId())
|
||||
}
|
||||
// 时间写入
|
||||
key := strconv.Itoa(int(req.BossId)) + "_" + strconv.Itoa(int(req.Difficulty))
|
||||
if t, ok := viking.BossTime[key]; ok {
|
||||
if t < req.Report.Costtime {
|
||||
viking.BossTime[key] = t
|
||||
}
|
||||
} else {
|
||||
viking.BossTime[key] = req.Report.Costtime
|
||||
}
|
||||
mapData["bossTime"] = viking.BossTime // 更新时间
|
||||
if newChallenge { // 新关卡挑战通过 发放首通奖励
|
||||
if code = this.module.DispenseRes(session, cfg.Firstprize, true); code != pb.ErrorCode_Success {
|
||||
return
|
||||
}
|
||||
@ -126,6 +143,7 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.VikingChal
|
||||
})
|
||||
}
|
||||
}
|
||||
code = this.module.ModifyVikingData(session.GetUserId(), mapData)
|
||||
// 发放通关随机奖励
|
||||
session.SendMsg(string(this.module.GetType()), VikingChallengeOverResp, &pb.VikingChallengeOverResp{
|
||||
Data: viking,
|
||||
|
@ -1,9 +1,14 @@
|
||||
package viking
|
||||
|
||||
import (
|
||||
"context"
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/lego/sys/redis/pipe"
|
||||
"go_dreamfactory/pb"
|
||||
"go_dreamfactory/sys/db"
|
||||
"strconv"
|
||||
|
||||
"github.com/go-redis/redis/v8"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
@ -17,28 +22,37 @@ func (this *apiComp) RankListCheck(session comm.IUserSession, req *pb.VikingRank
|
||||
|
||||
func (this *apiComp) RankList(session comm.IUserSession, req *pb.VikingRankListReq) (code pb.ErrorCode, data proto.Message) {
|
||||
var (
|
||||
ranks []*pb.DBVikingRank
|
||||
err error
|
||||
szRank []*pb.DBVikingRank
|
||||
rd *redis.StringSliceCmd
|
||||
)
|
||||
code = this.RankListCheck(session, req)
|
||||
if code != pb.ErrorCode_Success {
|
||||
return // 参数校验失败直接返回
|
||||
}
|
||||
if !req.Friend {
|
||||
ranks, err = this.module.modulerank.GetRankData(req.BoosType)
|
||||
if err != nil {
|
||||
code = pb.ErrorCode_DBError
|
||||
}
|
||||
} else {
|
||||
uids := this.friend.GetFriendList(session.GetUserId())
|
||||
for _, id := range uids {
|
||||
rankData := this.module.modulerank.getVikingRankListByBossType(id, req.BoosType)
|
||||
if rankData != nil {
|
||||
ranks = append(ranks, rankData)
|
||||
if !this.module.IsCross() {
|
||||
if conn, err := db.Local(); err == nil {
|
||||
var (
|
||||
pipe *pipe.RedisPipe = conn.Redis.RedisPipe(context.TODO())
|
||||
)
|
||||
|
||||
rd = pipe.ZRange("vikingRank"+strconv.Itoa(int(req.BoosType)), 0, -1)
|
||||
|
||||
if _, err = pipe.Exec(); err != nil {
|
||||
this.module.Errorln(err)
|
||||
return
|
||||
}
|
||||
_data3 := rd.Val()
|
||||
for _, v := range _data3 {
|
||||
result := &pb.DBVikingRank{}
|
||||
if err = this.module.modulerank.GetListObj(session.GetUserId(), v, result); err == nil {
|
||||
szRank = append(szRank, result)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
session.SendMsg(string(this.module.GetType()), VikingRankListResp, &pb.VikingRankListResp{Ranks: ranks})
|
||||
session.SendMsg(string(this.module.GetType()), VikingRankListResp, &pb.VikingRankListResp{Ranks: szRank})
|
||||
return
|
||||
}
|
||||
|
@ -1,12 +1,14 @@
|
||||
package viking
|
||||
|
||||
import (
|
||||
"context"
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/lego/core"
|
||||
"go_dreamfactory/lego/sys/redis"
|
||||
"go_dreamfactory/lego/sys/redis/pipe"
|
||||
"go_dreamfactory/modules"
|
||||
"go_dreamfactory/pb"
|
||||
|
||||
"github.com/go-redis/redis/v8"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
)
|
||||
|
||||
@ -30,7 +32,7 @@ func (this *ModelRank) AddRank(uId string, data *pb.DBVikingRank) (err error) {
|
||||
|
||||
func (this *ModelRank) GetUserRandData(uid string) (result *pb.DBVikingRank, err error) {
|
||||
result = &pb.DBVikingRank{}
|
||||
if err = this.Get(uid, result); err != nil && redis.RedisNil != err {
|
||||
if err = this.Get(uid, result); err != nil {
|
||||
return
|
||||
}
|
||||
err = nil
|
||||
@ -119,3 +121,25 @@ func (this *ModelRank) getVikingRankListByBossType(uid string, bossType int32) *
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (this *ModelRank) SetRankListData(tableName string, score int32, uid string) {
|
||||
|
||||
var (
|
||||
pipe *pipe.RedisPipe = this.DBModel.Redis.RedisPipe(context.TODO())
|
||||
menbers *redis.Z
|
||||
)
|
||||
|
||||
menbers = &redis.Z{Score: float64(score), Member: uid}
|
||||
|
||||
if cmd := pipe.ZAdd(tableName, menbers); cmd != nil {
|
||||
|
||||
dock, err1 := cmd.Result()
|
||||
if err1 != nil {
|
||||
this.moduleViking.Errorln(dock, err1)
|
||||
}
|
||||
}
|
||||
if _, err := pipe.Exec(); err != nil {
|
||||
this.moduleViking.Errorln(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ func (this *modelViking) getVikingList(uid string) (result *pb.DBViking, err err
|
||||
_cfg := this.module.configure.GetVikingBossTypeConfigData()
|
||||
for k := range _cfg {
|
||||
result.Boss[k] = 0
|
||||
str := strconv.Itoa(int(k)) + "_0"
|
||||
str := strconv.Itoa(int(k)) + "_1"
|
||||
result.BossTime[str] = 0
|
||||
}
|
||||
conf := this.module.configure.GetGlobalConf()
|
||||
|
Loading…
Reference in New Issue
Block a user