积分BOSS 代码上传
This commit is contained in:
parent
eed828add9
commit
fd82051612
@ -42,7 +42,14 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.IntegralChalle
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 校验门票 最大值等配置
|
||||
if list.Count >= 3 {
|
||||
errdata = &pb.ErrorData{ // 不能挑战了
|
||||
Code: pb.ErrorCode_TntegralDayMaxChallenge,
|
||||
Title: pb.ErrorCode_TntegralDayMaxChallenge.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
errdata, record := this.module.battle.CreatePveBattle(session, &pb.BattlePVEReq{
|
||||
Rulesid: cfgData.BattleReadyID,
|
||||
Ptype: pb.PlayType_enchant,
|
||||
|
@ -21,13 +21,12 @@ func (this *apiComp) ChallengeOverCheck(session comm.IUserSession, req *pb.Integ
|
||||
///挑战主线关卡
|
||||
func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.IntegralChallengeOverReq) (errdata *pb.ErrorData) {
|
||||
var (
|
||||
mapData map[string]interface{}
|
||||
res []*cfg.Gameatn
|
||||
update map[string]interface{}
|
||||
res []*cfg.Gameatn
|
||||
first bool // 是否是首通
|
||||
)
|
||||
mapData = make(map[string]interface{}, 0)
|
||||
// reward = make([]*cfg.Gameatn, 0)
|
||||
errdata = this.ChallengeOverCheck(session, req)
|
||||
if errdata != nil {
|
||||
update = make(map[string]interface{}, 0)
|
||||
if errdata = this.ChallengeOverCheck(session, req); errdata != nil {
|
||||
return // 参数校验失败直接返回
|
||||
}
|
||||
|
||||
@ -40,6 +39,11 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.IntegralCh
|
||||
return
|
||||
}
|
||||
|
||||
if _, ok := list.Score[req.Nandu]; !ok {
|
||||
list.Score[req.Nandu] = req.Score
|
||||
update["score"] = list.Score
|
||||
first = true
|
||||
}
|
||||
cfgData, err := this.module.configure.GetStageBoss(list.Hid, req.Nandu)
|
||||
if err != nil {
|
||||
errdata = &pb.ErrorData{
|
||||
@ -65,11 +69,25 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.IntegralCh
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 发放通关随机奖励
|
||||
for _, v := range cfgData.Firstprize {
|
||||
res = append(res, v)
|
||||
list.Count++
|
||||
update["count"] = list.Count
|
||||
// 更新积分数据
|
||||
if list.Score[req.Nandu] < req.Score {
|
||||
list.Score[req.Nandu] = req.Score
|
||||
update["score"] = list.Score
|
||||
}
|
||||
if list.Maxscore < req.Score { // 更新最大积分数据
|
||||
list.Maxscore = req.Score
|
||||
update["maxscore"] = list.Maxscore
|
||||
}
|
||||
list.Totalscore += req.Score
|
||||
update["totalscore"] = list.Totalscore
|
||||
if first {
|
||||
for _, v := range cfgData.Firstprize { // 发放通关随机奖励
|
||||
res = append(res, v)
|
||||
}
|
||||
}
|
||||
|
||||
reward := this.module.ModuleTools.GetGroupDataByLottery(cfgData.Drop, userinfo.Vip, userinfo.Lv)
|
||||
res = append(res, reward...)
|
||||
|
||||
@ -82,7 +100,7 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.IntegralCh
|
||||
})
|
||||
}
|
||||
|
||||
errdata = this.module.ModifyIntegralData(session.GetUserId(), mapData)
|
||||
err = this.module.modelIntegral.modifyIntegralData(session.GetUserId(), update)
|
||||
|
||||
session.SendMsg(string(this.module.GetType()), "challengeover", &pb.IntegralChallengeOverResp{
|
||||
Data: list,
|
||||
|
@ -2,10 +2,10 @@ package integral
|
||||
|
||||
import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/lego/sys/mgo"
|
||||
"go_dreamfactory/pb"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
"go_dreamfactory/sys/configure"
|
||||
cfg "go_dreamfactory/sys/configure/structs"
|
||||
"go_dreamfactory/utils"
|
||||
)
|
||||
|
||||
//参数校验
|
||||
@ -16,19 +16,75 @@ func (this *apiComp) GetListCheck(session comm.IUserSession, req *pb.IntegralGet
|
||||
|
||||
func (this *apiComp) GetList(session comm.IUserSession, req *pb.IntegralGetListReq) (errdata *pb.ErrorData) {
|
||||
|
||||
list, err := this.module.modelIntegral.getIntegralList(session.GetUserId())
|
||||
if mgo.MongodbNil == err {
|
||||
|
||||
list.Id = primitive.NewObjectID().Hex()
|
||||
list.Uid = session.GetUserId()
|
||||
|
||||
this.module.modelIntegral.Add(session.GetUserId(), list)
|
||||
var (
|
||||
list *pb.DBIntegralBoss
|
||||
err error
|
||||
)
|
||||
list, err = this.module.modelIntegral.getIntegralList(session.GetUserId())
|
||||
if err != nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_DBError,
|
||||
Title: pb.ErrorCode_DBError.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
update := make(map[string]interface{})
|
||||
curTime := configure.Now().Unix()
|
||||
if !utils.IsToday(list.CTime) { // 不是今天 重置
|
||||
|
||||
list.Count = 0
|
||||
update["count"] = list.Count
|
||||
|
||||
list.CTime = curTime
|
||||
update["cTime"] = list.CTime
|
||||
}
|
||||
|
||||
if curTime > list.Etime { // 更新赛季
|
||||
szConf := this.module.configure.GetIntegralITime()
|
||||
// 当前开服时间
|
||||
openTime := this.module.service.GetOpentime().Unix()
|
||||
list.Hid = 0 // 重置活动id
|
||||
list.Etime = 0
|
||||
for _, v := range szConf {
|
||||
if curTime >= int64(v.Openday)+openTime && curTime <= int64(v.Endday)+openTime {
|
||||
list.Hid = v.Endday
|
||||
list.Etime = int64(v.Endday) + openTime
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
var conf *cfg.GameIntegralBossData
|
||||
if conf, err = this.module.configure.GetStageBoss(list.Hid, 1); err == nil {
|
||||
list.Itype = conf.Itype // 获取类型
|
||||
update["itype"] = list.Itype
|
||||
list.Nandu = 1 // 初始难度1
|
||||
update["nandu"] = list.Nandu
|
||||
}
|
||||
// 相关数据重置
|
||||
list.Maxscore = 0
|
||||
list.Totalscore = 0
|
||||
list.Reward1 = 0
|
||||
list.Reward2 = 0
|
||||
list.Buff = make(map[int32]int32)
|
||||
list.Score = make(map[int32]int64)
|
||||
update["hid"] = list.Hid
|
||||
update["etime"] = list.Etime
|
||||
update["maxscore"] = list.Maxscore
|
||||
update["totalscore"] = list.Totalscore
|
||||
update["reward1"] = list.Reward1
|
||||
update["reward2"] = list.Reward2
|
||||
update["buff"] = list.Buff
|
||||
update["score"] = list.Score
|
||||
}
|
||||
if len(update) > 0 {
|
||||
if err = this.module.modelIntegral.modifyIntegralData(session.GetUserId(), update); err != nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_DBError,
|
||||
Title: pb.ErrorCode_DBError.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
// if session.GetUserId() != "" { // 恢复时间
|
||||
// if userexpand, err := this.module.ModuleUser.GetUserExpand(session.GetUserId()); err == nil {
|
||||
// list.RecoveryTime = userexpand.Recovertimeunifiedticket
|
||||
// }
|
||||
// }
|
||||
|
||||
session.SendMsg(string(this.module.GetType()), "getlist", &pb.IntegralGetListResp{Data: list})
|
||||
return
|
||||
|
@ -31,6 +31,7 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp
|
||||
game_integraltime: cfg.NewGameIntegralTime,
|
||||
})
|
||||
configure.RegisterConfigure(game_integralboss, cfg.NewGameIntegralBoss, this.LoadStageBoss)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -3,8 +3,11 @@ package integral
|
||||
import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/lego/core"
|
||||
"go_dreamfactory/lego/sys/mgo"
|
||||
"go_dreamfactory/modules"
|
||||
"go_dreamfactory/pb"
|
||||
"go_dreamfactory/sys/configure"
|
||||
cfg "go_dreamfactory/sys/configure/structs"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
@ -27,22 +30,43 @@ func (this *modelIntegral) Init(service core.IService, module core.IModule, comp
|
||||
return
|
||||
}
|
||||
|
||||
func (this *modelIntegral) modifyIntegralDataByObjId(uid string, data map[string]interface{}) error {
|
||||
// 修改基本数据
|
||||
func (this *modelIntegral) modifyIntegralData(uid string, data map[string]interface{}) error {
|
||||
return this.Change(uid, data)
|
||||
}
|
||||
|
||||
// 获取列表信息
|
||||
func (this *modelIntegral) getIntegralList(uid string) (result *pb.DBIntegralBoss, err error) {
|
||||
result = &pb.DBIntegralBoss{
|
||||
Id: primitive.NewObjectID().Hex(),
|
||||
Uid: uid,
|
||||
Buff: map[int32]int32{},
|
||||
Score: map[int32]int32{},
|
||||
}
|
||||
if err = this.Get(uid, result); err != nil {
|
||||
result = &pb.DBIntegralBoss{}
|
||||
if err = this.Get(uid, result); mgo.MongodbNil == err {
|
||||
result.Id = primitive.NewObjectID().Hex()
|
||||
result.Uid = uid
|
||||
result.Buff = make(map[int32]int32)
|
||||
result.Score = make(map[int32]int64)
|
||||
|
||||
// 获取当前的hid
|
||||
curTime := configure.Now().Unix()
|
||||
szConf := this.module.configure.GetIntegralITime()
|
||||
// 当前开服时间
|
||||
openTime := this.module.service.GetOpentime().Unix()
|
||||
for _, v := range szConf {
|
||||
if curTime >= int64(v.Openday)+openTime && curTime <= int64(v.Endday)+openTime {
|
||||
result.Hid = v.Endday
|
||||
|
||||
result.Etime = int64(v.Endday) + openTime
|
||||
result.CTime = curTime
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
var conf *cfg.GameIntegralBossData
|
||||
if conf, err = this.module.configure.GetStageBoss(result.Hid, 1); err == nil {
|
||||
result.Itype = conf.Itype // 获取类型
|
||||
result.Nandu = 1 // 初始难度1
|
||||
}
|
||||
|
||||
err = this.Add(uid, result) // 入库
|
||||
return
|
||||
}
|
||||
|
||||
err = nil
|
||||
return result, err
|
||||
}
|
||||
|
@ -2,9 +2,9 @@ package integral
|
||||
|
||||
import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/lego/base"
|
||||
"go_dreamfactory/lego/core"
|
||||
"go_dreamfactory/modules"
|
||||
"go_dreamfactory/pb"
|
||||
)
|
||||
|
||||
type Integral struct {
|
||||
@ -14,7 +14,7 @@ type Integral struct {
|
||||
configure *configureComp
|
||||
|
||||
battle comm.IBattle
|
||||
service core.IService
|
||||
service base.IRPCXService
|
||||
}
|
||||
|
||||
func NewModule() core.IModule {
|
||||
@ -29,7 +29,7 @@ func (this *Integral) Init(service core.IService, module core.IModule, options c
|
||||
if err = this.ModuleBase.Init(service, module, options); err != nil {
|
||||
return
|
||||
}
|
||||
this.service = service
|
||||
this.service = service.(base.IRPCXService)
|
||||
return
|
||||
}
|
||||
|
||||
@ -52,20 +52,3 @@ func (this *Integral) OnInstallComp() {
|
||||
this.modelIntegral = this.RegisterComp(new(modelIntegral)).(*modelIntegral)
|
||||
this.configure = this.RegisterComp(new(configureComp)).(*configureComp)
|
||||
}
|
||||
|
||||
// 接口信息
|
||||
func (this *Integral) ModifyIntegralData(uid string, data map[string]interface{}) (errdata *pb.ErrorData) {
|
||||
err := this.modelIntegral.modifyIntegralDataByObjId(uid, data)
|
||||
if err != nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_DBError,
|
||||
Title: pb.ErrorCode_DBError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (this *Integral) CheckRank(uid string, boosID int32, report *pb.BattleReport, userinfo *pb.DBUser, score int64) {
|
||||
|
||||
}
|
||||
|
@ -12,11 +12,12 @@ func (this *apiComp) AwardCheck(session comm.IUserSession, req *pb.MonkeyAwardRe
|
||||
|
||||
func (this *apiComp) Award(session comm.IUserSession, req *pb.MonkeyAwardReq) (errdata *pb.ErrorData) {
|
||||
var (
|
||||
err error
|
||||
info *pb.DBMonkey
|
||||
conf []*cfg.GameMonkeyRewardData
|
||||
res []*cfg.Gameatn
|
||||
atno []*pb.UserAtno
|
||||
err error
|
||||
info *pb.DBMonkey
|
||||
conf []*cfg.GameMonkeyRewardData
|
||||
res []*cfg.Gameatn
|
||||
atno []*pb.UserAtno
|
||||
totalstar int32 //
|
||||
)
|
||||
if errdata = this.AwardCheck(session, req); errdata != nil {
|
||||
return
|
||||
@ -37,8 +38,24 @@ func (this *apiComp) Award(session comm.IUserSession, req *pb.MonkeyAwardReq) (e
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if conf, err = this.module.configure.getGameMonkeyRewardData(req.ChapterId); err != nil {
|
||||
if _, ok := info.Data[req.ChapterId]; !ok {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_UserRepeadReward,
|
||||
Title: pb.ErrorCode_UserRepeadReward.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
for _, v := range info.Data[req.ChapterId].Award {
|
||||
totalstar += v
|
||||
}
|
||||
if totalstar < req.Starnum { // 星级不够 不能领奖
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_UserNoReward,
|
||||
Title: pb.ErrorCode_UserNoReward.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
if conf, err = this.module.configure.getGameMonkeyRewardData(req.ChapterId); err == nil {
|
||||
for _, v := range conf {
|
||||
if v.Starnum > info.Reward[req.ChapterId] && v.Starnum <= req.Starnum {
|
||||
res = append(res, v.Reward...)
|
||||
@ -49,6 +66,7 @@ func (this *apiComp) Award(session comm.IUserSession, req *pb.MonkeyAwardReq) (e
|
||||
if errdata, atno = this.module.DispenseAtno(session, res, true); errdata != nil {
|
||||
return
|
||||
}
|
||||
info.Reward[req.ChapterId] = req.Starnum
|
||||
if err = this.module.model.changeMonkeyData(session.GetUserId(), map[string]interface{}{ // 更新
|
||||
"reward": info.Reward,
|
||||
}); err != nil {
|
||||
@ -59,6 +77,12 @@ func (this *apiComp) Award(session comm.IUserSession, req *pb.MonkeyAwardReq) (e
|
||||
}
|
||||
return
|
||||
}
|
||||
} else {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_UserNoReward,
|
||||
Title: pb.ErrorCode_UserNoReward.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
session.SendMsg(string(this.module.GetType()), "award", &pb.MonkeyAwardResp{
|
||||
|
@ -46,10 +46,13 @@ func (this *apiComp) UpdateStar(session comm.IUserSession, req *pb.MonkeyUpdateS
|
||||
}
|
||||
return
|
||||
}
|
||||
if info.Data[conf.Chapter].Award == nil {
|
||||
info.Data[conf.Chapter].Award = map[int32]int32{
|
||||
req.Stage: req.Star,
|
||||
if info.Data[conf.Chapter] == nil {
|
||||
info.Data[conf.Chapter] = &pb.ChapterData{
|
||||
Award: map[int32]int32{
|
||||
req.Stage: req.Star,
|
||||
},
|
||||
}
|
||||
|
||||
update["data"] = info.Data
|
||||
} else {
|
||||
if info.Data[conf.Chapter].Award[req.Stage] < req.Star {
|
||||
|
1014
pb/errorcode.pb.go
1014
pb/errorcode.pb.go
File diff suppressed because it is too large
Load Diff
@ -38,7 +38,7 @@ type DBIntegralBoss struct {
|
||||
Reward2 int32 `protobuf:"varint,11,opt,name=reward2,proto3" json:"reward2"` // 类型2 奖励( Integralreward cid )
|
||||
Buff map[int32]int32 `protobuf:"bytes,12,rep,name=buff,proto3" json:"buff" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` // 激活的buff (key Integralcondition value :0 未激活) 注:事件类型 才有值
|
||||
Nandu int32 `protobuf:"varint,13,opt,name=nandu,proto3" json:"nandu"` // 已经解锁的难度
|
||||
Score map[int32]int32 `protobuf:"bytes,14,rep,name=score,proto3" json:"score" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` // key 难度 value 积分
|
||||
Score map[int32]int64 `protobuf:"bytes,14,rep,name=score,proto3" json:"score" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` // key 难度 value 积分
|
||||
}
|
||||
|
||||
func (x *DBIntegralBoss) Reset() {
|
||||
@ -164,7 +164,7 @@ func (x *DBIntegralBoss) GetNandu() int32 {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *DBIntegralBoss) GetScore() map[int32]int32 {
|
||||
func (x *DBIntegralBoss) GetScore() map[int32]int64 {
|
||||
if x != nil {
|
||||
return x.Score
|
||||
}
|
||||
@ -206,7 +206,7 @@ var file_integral_integral_db_proto_rawDesc = []byte{
|
||||
0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x38, 0x0a, 0x0a, 0x53,
|
||||
0x63, 0x6f, 0x72, 0x65, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79,
|
||||
0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 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,
|
||||
0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 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,
|
||||
}
|
||||
|
@ -38,6 +38,7 @@ import (
|
||||
"go_dreamfactory/modules/herotask"
|
||||
"go_dreamfactory/modules/horoscope"
|
||||
"go_dreamfactory/modules/hunting"
|
||||
"go_dreamfactory/modules/integral"
|
||||
"go_dreamfactory/modules/island"
|
||||
"go_dreamfactory/modules/items"
|
||||
"go_dreamfactory/modules/jielong"
|
||||
@ -192,6 +193,7 @@ func main() {
|
||||
moonlv.NewModule(),
|
||||
whackamole.NewModule(),
|
||||
monkey.NewModule(),
|
||||
integral.NewModule(),
|
||||
)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user