Merge branch 'dev' of http://git.legu.cc/liwei_3d/go_dreamfactory into dev
This commit is contained in:
commit
d53b0a057a
@ -321,7 +321,7 @@ type (
|
||||
CreateStoneBattle(session IUserSession, stoneBattle *pb.StroneBattleReq) (errdata *pb.ErrorData, record *pb.DBBattleRecord)
|
||||
|
||||
// 可以携带debuff 的战斗
|
||||
//CreateDebuffBattle(session IUserSession, req *pb.BattlePVEReq, webuff []int32, dibuff []int32) (errdata *pb.ErrorData, record *pb.DBBattleRecord)
|
||||
CreateDebuffBattle(session IUserSession, req *pb.BattlePVEReq, dibuff []int32) (errdata *pb.ErrorData, record *pb.DBBattleRecord)
|
||||
}
|
||||
IGm interface {
|
||||
CreateCmd(session IUserSession, cmd string) (errdata *pb.ErrorData)
|
||||
|
@ -1159,3 +1159,142 @@ func (this *modelBattleComp) creatStoneBattle(session comm.IUserSession, stoneBa
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 创建pve 战斗记录
|
||||
func (this *modelBattleComp) createAddDebuffPve(session comm.IUserSession, conn *db.DBConn, btype pb.BattleType, req *pb.BattlePVEReq, conf *cfg.GameBattleReadyData, dibuff []int32) (record *pb.DBBattleRecord, errdata *pb.ErrorData) {
|
||||
var (
|
||||
heros []*pb.DBHero = make([]*pb.DBHero, 5)
|
||||
captain int32
|
||||
masters []*pb.BattleRole
|
||||
user *pb.DBUserExpand
|
||||
err error
|
||||
)
|
||||
record = &pb.DBBattleRecord{
|
||||
Id: primitive.NewObjectID().Hex(),
|
||||
Title: req.Title,
|
||||
Btype: btype,
|
||||
Ptype: req.Ptype,
|
||||
State: pb.BBattleState_in,
|
||||
RedCompId: session.GetUserId(),
|
||||
Redflist: make([]*pb.DBBattleFormt, 1),
|
||||
BlueCompId: "",
|
||||
Buleflist: make([]*pb.DBBattleFormt, len(req.Mformat)),
|
||||
Tasks: conf.BattleEvents,
|
||||
}
|
||||
record.Redflist[0] = &pb.DBBattleFormt{
|
||||
Leadpos: req.Format.Leadpos,
|
||||
Team: make([]*pb.BattleRole, len(req.Format.Format)),
|
||||
}
|
||||
model := db.NewDBModel(comm.TableHero, conn)
|
||||
if user, err = this.module.ModuleUser.GetUserExpand(session.GetUserId()); err != nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_DBError,
|
||||
Title: pb.ErrorCode_DBError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
//自己的英雄阵营
|
||||
for i, v := range req.Format.Format {
|
||||
if v != "" {
|
||||
heros[i] = &pb.DBHero{}
|
||||
if err := model.GetListObj(session.GetUserId(), v, heros[i]); err != nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_HeroNoExist,
|
||||
Title: pb.ErrorCode_HeroNoExist.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
tid := 100 + i
|
||||
if record.Redflist[0].Team[i], errdata = this.createBattleRole(heros[i], user.Passonlv, tid, i); errdata != nil {
|
||||
return
|
||||
}
|
||||
} else {
|
||||
record.Redflist[0].Team[i] = nil
|
||||
}
|
||||
}
|
||||
//好友的英雄阵营
|
||||
for i, v := range req.Format.Friendformat {
|
||||
if v != "" {
|
||||
var (
|
||||
err error
|
||||
)
|
||||
// 获取好友英雄信息
|
||||
if this.module.IsCross() {
|
||||
if heros[i], err = this.module.friend.UseAssistHero(session.GetUserId(), v); err != nil {
|
||||
this.module.Errorln(err)
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_HeroNoExist,
|
||||
Title: pb.ErrorCode_HeroNoExist.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
} else { //获取跨服数据
|
||||
heros[i] = &pb.DBHero{}
|
||||
if err = this.module.service.AcrossClusterRpcCall(
|
||||
context.Background(),
|
||||
this.module.GetCrossTag(),
|
||||
comm.Service_Worker,
|
||||
string(comm.Rpc_ModuleFriendUseAssitHero),
|
||||
pb.RPCGeneralReqA2{Param1: session.GetUserId(), Param2: v},
|
||||
heros[i]); err != nil {
|
||||
this.module.Errorln(err)
|
||||
}
|
||||
}
|
||||
tid := 100 + i
|
||||
if record.Redflist[0].Team[i], errdata = this.createBattleRole(heros[i], 0, tid, i); errdata != nil {
|
||||
return
|
||||
}
|
||||
record.Redflist[0].Team[i].Ishelp = true
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if conf.DefaultHero != 0 {
|
||||
if captain, masters, errdata = this.createMasterRoles(1100, 0, conf.DefaultHero); errdata != nil {
|
||||
return
|
||||
}
|
||||
record.Redflist[0].Systeam = masters
|
||||
if record.Redflist[0].Leadpos == -1 && captain != -1 {
|
||||
record.Redflist[0].Leadpos = captain
|
||||
}
|
||||
}
|
||||
if conf.RedAssistTeam != 0 {
|
||||
if captain, masters, errdata = this.createMasterRoles(1200, 0, conf.RedAssistTeam); errdata != nil {
|
||||
return
|
||||
}
|
||||
record.Redflist[0].Backupteam = masters
|
||||
}
|
||||
for i, v := range req.Mformat {
|
||||
if captain, masters, errdata = this.createMasterRoles(2100, i, v); errdata != nil {
|
||||
return
|
||||
}
|
||||
for _, v1 := range masters {
|
||||
if v1 != nil {
|
||||
sz := make([]*pb.DySkillData, 0)
|
||||
for _, key := range dibuff {
|
||||
sz = append(sz, &pb.DySkillData{
|
||||
SkillID: key,
|
||||
SkillLv: 0,
|
||||
Param: 0,
|
||||
})
|
||||
}
|
||||
v1.BattleBeforeSkill = append(v1.BattleBeforeSkill)
|
||||
}
|
||||
|
||||
}
|
||||
record.Buleflist[i] = &pb.DBBattleFormt{
|
||||
Leadpos: captain,
|
||||
Team: masters,
|
||||
}
|
||||
}
|
||||
|
||||
if conf.BlueAssistTeam != 0 {
|
||||
if captain, masters, errdata = this.createMasterRoles(2200, 0, conf.BlueAssistTeam); errdata != nil {
|
||||
return
|
||||
}
|
||||
record.Buleflist[0].Backupteam = masters
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -604,3 +604,72 @@ func (this *Battle) CreateStoneBattle(session comm.IUserSession, stoneBattle *pb
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// 创建pve战斗
|
||||
func (this *Battle) CreateDebuffBattle(session comm.IUserSession, req *pb.BattlePVEReq, dibuff []int32) (errdata *pb.ErrorData, record *pb.DBBattleRecord) {
|
||||
var (
|
||||
conf *cfg.GameBattleReadyData
|
||||
conn *db.DBConn
|
||||
err error
|
||||
tasks []*pb.BuriedParam
|
||||
)
|
||||
if !this.IsCross() {
|
||||
conn, err = db.Local()
|
||||
} else {
|
||||
conn, err = db.ServerDBConn(session.GetServiecTag())
|
||||
}
|
||||
if err != nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_DBError,
|
||||
Title: pb.ErrorCode_DBError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
this.Errorf("session:%v err:", session, err)
|
||||
return
|
||||
}
|
||||
if conf, err = this.configure.GetBattleReady(req.Rulesid); err != nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ConfigNoFound,
|
||||
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
if req.Format == nil || req.Format.Format == nil || len(req.Format.Format) != 5 {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ReqParameterError,
|
||||
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
||||
Message: "Format data err!",
|
||||
}
|
||||
return
|
||||
}
|
||||
if req.Format.Friendformat != nil && len(req.Format.Friendformat) != 5 {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ReqParameterError,
|
||||
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
||||
}
|
||||
}
|
||||
var flag bool
|
||||
for _, v := range req.Format.Friendformat {
|
||||
if v != "" {
|
||||
flag = true
|
||||
tasks = append(tasks, comm.GetBuriedParam(comm.Rtype108, 1))
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if record, errdata = this.modelBattle.createAddDebuffPve(session, conn, pb.BattleType_pve, req, conf, dibuff); errdata != nil {
|
||||
return
|
||||
}
|
||||
if flag {
|
||||
tasks = append(tasks, comm.GetBuriedParam(comm.Rtype12, 1))
|
||||
|
||||
}
|
||||
if len(tasks) > 0 {
|
||||
go this.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
|
||||
this.ModuleBuried.TriggerBuried(session, tasks...)
|
||||
})
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/lego/core"
|
||||
"go_dreamfactory/modules"
|
||||
"go_dreamfactory/sys/db"
|
||||
)
|
||||
|
||||
type StoryLine struct {
|
||||
@ -40,6 +41,9 @@ func (this *StoryLine) Start() (err error) {
|
||||
return
|
||||
}
|
||||
this.battle = module.(comm.IBattle)
|
||||
this.modeltask.Add("", nil, db.SetDBMgoLog(false))
|
||||
this.modeltask.DBModel.Add("", nil)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -16,6 +16,7 @@ type GameIntegralBossData struct {
|
||||
Difficulty int32
|
||||
Itype int32
|
||||
Difficultytext string
|
||||
Coefficient string
|
||||
Unlock int32
|
||||
Unlockval int32
|
||||
Name string
|
||||
@ -43,6 +44,7 @@ func (_v *GameIntegralBossData)Deserialize(_buf map[string]interface{}) (err err
|
||||
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["difficulty"].(float64); !_ok_ { err = errors.New("difficulty error"); return }; _v.Difficulty = int32(_tempNum_) }
|
||||
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["itype"].(float64); !_ok_ { err = errors.New("itype error"); return }; _v.Itype = int32(_tempNum_) }
|
||||
{ var _ok_ bool; if _v.Difficultytext, _ok_ = _buf["difficultytext"].(string); !_ok_ { err = errors.New("difficultytext error"); return } }
|
||||
{ var _ok_ bool; if _v.Coefficient, _ok_ = _buf["coefficient"].(string); !_ok_ { err = errors.New("coefficient error"); return } }
|
||||
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["unlock"].(float64); !_ok_ { err = errors.New("unlock error"); return }; _v.Unlock = int32(_tempNum_) }
|
||||
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["unlockval"].(float64); !_ok_ { err = errors.New("unlockval error"); return }; _v.Unlockval = int32(_tempNum_) }
|
||||
{var _ok_ bool; var __json_text__ map[string]interface{}; if __json_text__, _ok_ = _buf["name"].(map[string]interface{}) ; !_ok_ { err = errors.New("_v.Name error"); return }; { var _ok_ bool; if _, _ok_ = __json_text__["key"].(string); !_ok_ { err = errors.New("key error"); return } }; { var _ok_ bool; if _v.Name, _ok_ = __json_text__["text"].(string); !_ok_ { err = errors.New("text error"); return } } }
|
||||
|
Loading…
Reference in New Issue
Block a user