Merge branch 'dev' of http://git.legu.cc/liwei_3d/go_dreamfactory into dev
This commit is contained in:
commit
3946a383b2
@ -210,6 +210,9 @@ type (
|
||||
ChangeUserMoonLv(session IUserSession, lv int32) (errdata *pb.ErrorData)
|
||||
//GM创号
|
||||
GMCreatePlayer(session IUserSession, req *pb.UserCreateReq) (errdata *pb.ErrorData)
|
||||
|
||||
// 体力转经验
|
||||
PsConvertExp(ps int32) (res *cfg.Gameatn)
|
||||
}
|
||||
//武器模块
|
||||
IEquipment interface {
|
||||
|
@ -4,11 +4,15 @@ import (
|
||||
"context"
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/lego/core"
|
||||
"go_dreamfactory/lego/sys/event"
|
||||
"go_dreamfactory/lego/sys/mgo"
|
||||
"go_dreamfactory/modules"
|
||||
"go_dreamfactory/pb"
|
||||
"go_dreamfactory/sys/configure"
|
||||
"sync"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
"go.mongodb.org/mongo-driver/x/bsonx"
|
||||
)
|
||||
@ -34,6 +38,17 @@ func (this *modelHdList) Init(service core.IService, module core.IModule, comp c
|
||||
return
|
||||
}
|
||||
|
||||
func (this *modelHdList) Start() (err error) {
|
||||
err = this.MCompModel.Start()
|
||||
|
||||
// 临时数据 防止清库没有hd数据 后面删除
|
||||
event.RegisterGO(core.Event_ServiceStartEnd, func() {
|
||||
this.loadHdInfo()
|
||||
})
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (this *modelHdList) getHdInfo() (activity map[pb.HdType]*pb.DBHuodong) {
|
||||
this.hlock.RLock()
|
||||
defer this.hlock.RUnlock()
|
||||
@ -90,3 +105,36 @@ func (this *modelHdList) getHdInfoByType(itype pb.HdType) (activity *pb.DBHuodon
|
||||
}
|
||||
return
|
||||
}
|
||||
func (this *modelHdList) loadHdInfo() (err error) {
|
||||
if err = this.DB.FindOne(core.SqlTable(this.TableName), bson.M{}).Decode(&pb.DBHuodong{}); err == mgo.MongodbNil {
|
||||
var data []interface{}
|
||||
|
||||
for i := 1; i <= 9; i++ {
|
||||
data = append(data, &pb.DBHuodong{
|
||||
Id: primitive.NewObjectID().Hex(),
|
||||
Rtime: configure.Now().Unix(),
|
||||
Name: "",
|
||||
Itype: pb.HdType(i),
|
||||
Etime: configure.Now().Unix() + 30*24*3600,
|
||||
Stime: configure.Now().Unix(),
|
||||
Data: &pb.ActivityInfo{},
|
||||
})
|
||||
}
|
||||
for i := 1001; i <= 1005; i++ {
|
||||
data = append(data, &pb.DBHuodong{
|
||||
Id: primitive.NewObjectID().Hex(),
|
||||
Rtime: configure.Now().Unix(),
|
||||
Name: "",
|
||||
Itype: pb.HdType(i),
|
||||
Etime: configure.Now().Unix() + 30*24*3600,
|
||||
Stime: configure.Now().Unix(),
|
||||
Data: &pb.ActivityInfo{},
|
||||
})
|
||||
}
|
||||
if _, err = this.DB.InsertMany(core.SqlTable(this.TableName), data); err != nil {
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@ -1006,7 +1006,7 @@ func (this *Room) UserCardSkill(curPlayer *pb.PlayerData, color int32, skillid i
|
||||
Round: this.round,
|
||||
User1: this.player1,
|
||||
User2: this.player2,
|
||||
Itype: 1,
|
||||
Itype: skillid,
|
||||
Curid: oid1,
|
||||
Targetid: oid2,
|
||||
}, this.szSession...); err != nil {
|
||||
|
@ -151,6 +151,7 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.HuntingCha
|
||||
}
|
||||
}
|
||||
}
|
||||
res = append(res, this.module.ModuleUser.PsConvertExp(consumPs))
|
||||
if errdata, atno = this.module.DispenseAtno(session, res, true); errdata != nil {
|
||||
return
|
||||
}
|
||||
@ -170,9 +171,9 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.HuntingCha
|
||||
}
|
||||
|
||||
errdata = this.module.ModifyHuntingData(session.GetUserId(), mapData)
|
||||
if atno, errdata = this.module.ModuleUser.ConsumePsAddExp(session, consumPs); errdata != nil {
|
||||
return
|
||||
}
|
||||
// if atno, errdata = this.module.ModuleUser.ConsumePsAddExp(session, consumPs); errdata != nil {
|
||||
// return
|
||||
// }
|
||||
szAtno = append(szAtno, atno...)
|
||||
session.SendMsg(string(this.module.GetType()), HuntingChallengeOverResp, &pb.HuntingChallengeOverResp{
|
||||
Data: hunting,
|
||||
|
@ -42,15 +42,15 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.IntegralGetListR
|
||||
if curTime > list.Etime { // 更新赛季
|
||||
szConf := this.module.configure.GetIntegralITime()
|
||||
// 当前开服时间
|
||||
openTime := this.module.service.GetOpentime().Unix()
|
||||
//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
|
||||
}
|
||||
//if curTime >= int64(v.Openday)+openTime && curTime <= int64(v.Endday)+openTime { // 暂时不校验天数
|
||||
list.Hid = v.Endday
|
||||
list.Etime = int64(v.Endday) + curTime
|
||||
break
|
||||
//}
|
||||
}
|
||||
|
||||
var conf *cfg.GameIntegralBossData
|
||||
|
@ -22,16 +22,16 @@ func (this *apiComp) ChallengeOverCheck(session comm.IUserSession, req *pb.Mainl
|
||||
// /挑战主线关卡
|
||||
func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.MainlineChallengeOverReq) (errdata *pb.ErrorData) {
|
||||
var (
|
||||
conf *cfg.GameMainStageData
|
||||
info *pb.DBMainline
|
||||
atno []*pb.UserAtno
|
||||
reward []*pb.UserAtno = make([]*pb.UserAtno, 0)
|
||||
isWin bool
|
||||
first bool // 判断是否是首通
|
||||
star int32 // 评星
|
||||
tasks []*pb.BuriedParam = make([]*pb.BuriedParam, 0)
|
||||
err error
|
||||
consumPs int32
|
||||
conf *cfg.GameMainStageData
|
||||
info *pb.DBMainline
|
||||
atno []*pb.UserAtno
|
||||
isWin bool
|
||||
first bool // 判断是否是首通
|
||||
star int32 // 评星
|
||||
tasks []*pb.BuriedParam = make([]*pb.BuriedParam, 0)
|
||||
err error
|
||||
|
||||
res []*cfg.Gameatn
|
||||
)
|
||||
if errdata = this.ChallengeOverCheck(session, req); errdata != nil {
|
||||
return // 参数校验失败直接返回
|
||||
@ -135,18 +135,9 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.MainlineCh
|
||||
this.module.modelMline.updateprogress(info)
|
||||
|
||||
if first { // 发奖
|
||||
if errdata, atno = this.module.DispenseAtno(session, conf.Firstaward, true); errdata != nil {
|
||||
this.module.Debugf("Mline first DispenseRes err:+%v", conf.Firstaward)
|
||||
return
|
||||
}
|
||||
reward = append(reward, atno...)
|
||||
res = append(res, conf.Firstaward...)
|
||||
} else {
|
||||
if errdata, atno = this.module.DispenseAtno(session, conf.Commonaward, true); errdata != nil {
|
||||
this.module.Debugf("Mline Commonaward DispenseRes err:+%v", conf.Commonaward)
|
||||
return
|
||||
}
|
||||
reward = append(reward, atno...)
|
||||
|
||||
res = append(res, conf.Commonaward...)
|
||||
}
|
||||
user, err := this.module.ModuleUser.GetUser(session.GetUserId())
|
||||
if err != nil {
|
||||
@ -159,11 +150,12 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.MainlineCh
|
||||
}
|
||||
session.SetMate(comm.Session_User, user)
|
||||
if lotteryward := this.module.ModuleTools.GetGroupDataByLottery(conf.Lotteryward, user.Vip, user.Lv); len(lotteryward) > 0 {
|
||||
if errdata, atno = this.module.DispenseAtno(session, lotteryward, true); errdata != nil {
|
||||
this.module.Debugf("Mline lotteryward DispenseRes err:+%v", lotteryward)
|
||||
return
|
||||
}
|
||||
reward = append(reward, atno...)
|
||||
res = append(res, lotteryward...)
|
||||
}
|
||||
res = append(res, this.module.ModuleUser.PsConvertExp(info.Ps[req.Level]))
|
||||
if errdata, atno = this.module.DispenseAtno(session, res, true); errdata != nil {
|
||||
this.module.Debugf("Mline DispenseRes err:+%v", res)
|
||||
return
|
||||
}
|
||||
|
||||
// 加英雄经验
|
||||
@ -179,11 +171,6 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.MainlineCh
|
||||
this.module.ModuleHero.AddHerosExp(session, heroObjs, conf.HeroExp)
|
||||
}
|
||||
|
||||
consumPs = info.Ps[req.Level]
|
||||
if atno, errdata = this.module.ModuleUser.ConsumePsAddExp(session, consumPs); errdata != nil {
|
||||
return
|
||||
}
|
||||
reward = append(reward, atno...)
|
||||
if err = this.module.modelMline.updateMainlineData(session.GetUserId(), info); err != nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_DBError,
|
||||
@ -196,7 +183,7 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.MainlineCh
|
||||
Level: req.Level,
|
||||
Star: star,
|
||||
HeroExp: conf.HeroExp,
|
||||
Reward: reward,
|
||||
Reward: atno,
|
||||
})
|
||||
|
||||
tasks = append(tasks, comm.GetBuriedParam(comm.Rtype60, 1))
|
||||
@ -205,7 +192,7 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.MainlineCh
|
||||
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
|
||||
this.module.ModuleBuried.TriggerBuried(session, tasks...)
|
||||
this.module.ModuleSys.CheckOpenCond(session, comm.OpencondTypeMaxmapid, req.Level)
|
||||
this.module.WriteUserLog(session.GetUserId(), req, comm.GMResAddType, "MainlineChallengeOverReq", reward)
|
||||
this.module.WriteUserLog(session.GetUserId(), req, comm.GMResAddType, "MainlineChallengeOverReq", atno)
|
||||
})
|
||||
return
|
||||
}
|
||||
|
@ -1540,3 +1540,19 @@ func (this *User) GMCreatePlayer(session comm.IUserSession, req *pb.UserCreateRe
|
||||
errdata = this.api.Create(session, req)
|
||||
return
|
||||
}
|
||||
|
||||
// 体力转经验
|
||||
func (this *User) PsConvertExp(ps int32) (res *cfg.Gameatn) {
|
||||
res = &cfg.Gameatn{
|
||||
A: "attr",
|
||||
T: "exp",
|
||||
}
|
||||
if ggd := this.ModuleTools.GetGlobalConf(); ggd != nil {
|
||||
//体力消耗,增加玩家经验
|
||||
if addExp := ps * ggd.FightPs; addExp > 0 {
|
||||
res.N = addExp
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -33,7 +33,6 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.VikingChal
|
||||
bHelp bool
|
||||
oldDifficulty int32 // 记录通关之前的难度
|
||||
consumPs int32
|
||||
szAtno []*pb.UserAtno // atno 类型
|
||||
err error
|
||||
)
|
||||
changExp = make(map[string]int32, 0)
|
||||
@ -112,9 +111,6 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.VikingChal
|
||||
key := strconv.Itoa(int(req.BossId)) + "_" + strconv.Itoa(int(req.Difficulty))
|
||||
if viking.BossTime[key] == 0 { // 新关卡挑战通过 发放首通奖励
|
||||
res = append(res, vikingCfg.Firstprize...)
|
||||
// if errdata = this.module.DispenseAtno(session, vikingCfg.Firstprize, true); errdata != nil {
|
||||
// return
|
||||
// }
|
||||
}
|
||||
|
||||
if viking.BossTime[key] == 0 || viking.BossTime[key] > req.Report.Costtime {
|
||||
@ -186,14 +182,10 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.VikingChal
|
||||
}
|
||||
}
|
||||
|
||||
if atno, errdata = this.module.ModuleUser.ConsumePsAddExp(session, consumPs); errdata != nil {
|
||||
return
|
||||
}
|
||||
szAtno = append(szAtno, atno...)
|
||||
res = append(res, this.module.ModuleUser.PsConvertExp(consumPs))
|
||||
if errdata, atno = this.module.DispenseAtno(session, res, true); errdata != nil {
|
||||
return
|
||||
}
|
||||
szAtno = append(szAtno, atno...)
|
||||
if errdata = this.module.ModifyVikingData(session.GetUserId(), mapData); errdata != nil {
|
||||
return
|
||||
}
|
||||
@ -217,7 +209,7 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.VikingChal
|
||||
|
||||
session.SendMsg(string(this.module.GetType()), VikingChallengeOverResp, &pb.VikingChallengeOverResp{
|
||||
Data: viking,
|
||||
Asset: szAtno,
|
||||
Asset: atno,
|
||||
Sell: del,
|
||||
Heroexp: changExp,
|
||||
})
|
||||
@ -252,7 +244,7 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.VikingChal
|
||||
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
|
||||
this.chat.SendSysChatToWorld(session, comm.ChatSystem14, nil, req.BossId, req.Difficulty, user.Name)
|
||||
this.module.ModuleBuried.TriggerBuried(session, tasks...)
|
||||
this.module.WriteUserLog(session.GetUserId(), req, comm.GMResAddType, "VikingChallengeOverReq", szAtno)
|
||||
this.module.WriteUserLog(session.GetUserId(), req, comm.GMResAddType, "VikingChallengeOverReq", atno)
|
||||
})
|
||||
}
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user