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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
//设置本服
|
|
||||||
func (this *ModelRank) SetNormalPagodaRankList(tableName string, score int32, uid string) {
|
func (this *ModelRank) SetNormalPagodaRankList(tableName string, score int32, uid string) {
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -5,6 +5,7 @@ import (
|
|||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
"go_dreamfactory/sys/configure"
|
"go_dreamfactory/sys/configure"
|
||||||
cfg "go_dreamfactory/sys/configure/structs"
|
cfg "go_dreamfactory/sys/configure/structs"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
@ -25,6 +26,7 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.VikingChal
|
|||||||
newChallenge bool // 新的关卡
|
newChallenge bool // 新的关卡
|
||||||
reward []*cfg.Gameatn
|
reward []*cfg.Gameatn
|
||||||
asset []*pb.UserAssets
|
asset []*pb.UserAssets
|
||||||
|
costTime int32 // 战斗花费的时间
|
||||||
)
|
)
|
||||||
mapData = make(map[string]interface{}, 0)
|
mapData = make(map[string]interface{}, 0)
|
||||||
reward = make([]*cfg.Gameatn, 0)
|
reward = make([]*cfg.Gameatn, 0)
|
||||||
@ -69,7 +71,8 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.VikingChal
|
|||||||
mapData["boss"] = viking.Boss
|
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)
|
sz := make([]*pb.LineUp, 5)
|
||||||
for i, v := range req.Report.Info.Redflist[0].Team {
|
for i, v := range req.Report.Info.Redflist[0].Team {
|
||||||
if v != nil {
|
if v != nil {
|
||||||
@ -99,8 +102,22 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.VikingChal
|
|||||||
mapData["leftCount"] = viking.LeftCount
|
mapData["leftCount"] = viking.LeftCount
|
||||||
viking.ChallengeCount++
|
viking.ChallengeCount++
|
||||||
mapData["challengeCount"] = 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 {
|
if code = this.module.DispenseRes(session, cfg.Firstprize, true); code != pb.ErrorCode_Success {
|
||||||
return
|
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{
|
session.SendMsg(string(this.module.GetType()), VikingChallengeOverResp, &pb.VikingChallengeOverResp{
|
||||||
Data: viking,
|
Data: viking,
|
||||||
|
@ -1,9 +1,14 @@
|
|||||||
package viking
|
package viking
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
|
"go_dreamfactory/lego/sys/redis/pipe"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
|
"go_dreamfactory/sys/db"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"github.com/go-redis/redis/v8"
|
||||||
"google.golang.org/protobuf/proto"
|
"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) {
|
func (this *apiComp) RankList(session comm.IUserSession, req *pb.VikingRankListReq) (code pb.ErrorCode, data proto.Message) {
|
||||||
var (
|
var (
|
||||||
ranks []*pb.DBVikingRank
|
szRank []*pb.DBVikingRank
|
||||||
err error
|
rd *redis.StringSliceCmd
|
||||||
)
|
)
|
||||||
code = this.RankListCheck(session, req)
|
code = this.RankListCheck(session, req)
|
||||||
if code != pb.ErrorCode_Success {
|
if code != pb.ErrorCode_Success {
|
||||||
return // 参数校验失败直接返回
|
return // 参数校验失败直接返回
|
||||||
}
|
}
|
||||||
if !req.Friend {
|
if !req.Friend {
|
||||||
ranks, err = this.module.modulerank.GetRankData(req.BoosType)
|
if !this.module.IsCross() {
|
||||||
if err != nil {
|
if conn, err := db.Local(); err == nil {
|
||||||
code = pb.ErrorCode_DBError
|
var (
|
||||||
}
|
pipe *pipe.RedisPipe = conn.Redis.RedisPipe(context.TODO())
|
||||||
} else {
|
)
|
||||||
uids := this.friend.GetFriendList(session.GetUserId())
|
|
||||||
for _, id := range uids {
|
rd = pipe.ZRange("vikingRank"+strconv.Itoa(int(req.BoosType)), 0, -1)
|
||||||
rankData := this.module.modulerank.getVikingRankListByBossType(id, req.BoosType)
|
|
||||||
if rankData != nil {
|
if _, err = pipe.Exec(); err != nil {
|
||||||
ranks = append(ranks, rankData)
|
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
|
return
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
package viking
|
package viking
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/lego/core"
|
"go_dreamfactory/lego/core"
|
||||||
"go_dreamfactory/lego/sys/redis"
|
"go_dreamfactory/lego/sys/redis/pipe"
|
||||||
"go_dreamfactory/modules"
|
"go_dreamfactory/modules"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
|
|
||||||
|
"github.com/go-redis/redis/v8"
|
||||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
"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) {
|
func (this *ModelRank) GetUserRandData(uid string) (result *pb.DBVikingRank, err error) {
|
||||||
result = &pb.DBVikingRank{}
|
result = &pb.DBVikingRank{}
|
||||||
if err = this.Get(uid, result); err != nil && redis.RedisNil != err {
|
if err = this.Get(uid, result); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err = nil
|
err = nil
|
||||||
@ -119,3 +121,25 @@ func (this *ModelRank) getVikingRankListByBossType(uid string, bossType int32) *
|
|||||||
}
|
}
|
||||||
return nil
|
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()
|
_cfg := this.module.configure.GetVikingBossTypeConfigData()
|
||||||
for k := range _cfg {
|
for k := range _cfg {
|
||||||
result.Boss[k] = 0
|
result.Boss[k] = 0
|
||||||
str := strconv.Itoa(int(k)) + "_0"
|
str := strconv.Itoa(int(k)) + "_1"
|
||||||
result.BossTime[str] = 0
|
result.BossTime[str] = 0
|
||||||
}
|
}
|
||||||
conf := this.module.configure.GetGlobalConf()
|
conf := this.module.configure.GetGlobalConf()
|
||||||
|
Loading…
Reference in New Issue
Block a user