上传战斗流程代码

This commit is contained in:
liwei1dao 2022-09-06 19:09:59 +08:00
parent 42d1a3f6c2
commit 99f48b3e43
7 changed files with 408 additions and 368 deletions

View File

@ -7,9 +7,8 @@
"text": "阿宝" "text": "阿宝"
}, },
"star": 1, "star": 1,
"equip": [ "equip2": 101,
1 "equip4": 1
]
}, },
{ {
"monster_id": 250012, "monster_id": 250012,
@ -19,9 +18,8 @@
"text": "阿宝" "text": "阿宝"
}, },
"star": 2, "star": 2,
"equip": [ "equip2": 101,
1 "equip4": 1
]
}, },
{ {
"monster_id": 250013, "monster_id": 250013,
@ -31,9 +29,8 @@
"text": "阿宝" "text": "阿宝"
}, },
"star": 3, "star": 3,
"equip": [ "equip2": 101,
1 "equip4": 1
]
}, },
{ {
"monster_id": 250014, "monster_id": 250014,
@ -43,9 +40,8 @@
"text": "阿宝" "text": "阿宝"
}, },
"star": 4, "star": 4,
"equip": [ "equip2": 101,
1 "equip4": 1
]
}, },
{ {
"monster_id": 250015, "monster_id": 250015,
@ -55,9 +51,8 @@
"text": "阿宝" "text": "阿宝"
}, },
"star": 5, "star": 5,
"equip": [ "equip2": 101,
1 "equip4": 1
]
}, },
{ {
"monster_id": 340061, "monster_id": 340061,
@ -67,9 +62,8 @@
"text": "冰霜杰克" "text": "冰霜杰克"
}, },
"star": 1, "star": 1,
"equip": [ "equip2": 101,
1 "equip4": 1
]
}, },
{ {
"monster_id": 340062, "monster_id": 340062,
@ -79,9 +73,8 @@
"text": "冰霜杰克" "text": "冰霜杰克"
}, },
"star": 2, "star": 2,
"equip": [ "equip2": 101,
1 "equip4": 1
]
}, },
{ {
"monster_id": 340063, "monster_id": 340063,
@ -91,9 +84,8 @@
"text": "冰霜杰克" "text": "冰霜杰克"
}, },
"star": 3, "star": 3,
"equip": [ "equip2": 101,
1 "equip4": 1
]
}, },
{ {
"monster_id": 340064, "monster_id": 340064,
@ -103,9 +95,8 @@
"text": "冰霜杰克" "text": "冰霜杰克"
}, },
"star": 4, "star": 4,
"equip": [ "equip2": 101,
1 "equip4": 1
]
}, },
{ {
"monster_id": 340065, "monster_id": 340065,
@ -115,9 +106,8 @@
"text": "冰霜杰克" "text": "冰霜杰克"
}, },
"star": 5, "star": 5,
"equip": [ "equip2": 101,
1 "equip4": 1
]
}, },
{ {
"monster_id": 440051, "monster_id": 440051,
@ -127,9 +117,8 @@
"text": "小伊" "text": "小伊"
}, },
"star": 1, "star": 1,
"equip": [ "equip2": 101,
1 "equip4": 1
]
}, },
{ {
"monster_id": 440052, "monster_id": 440052,
@ -139,9 +128,8 @@
"text": "小伊" "text": "小伊"
}, },
"star": 2, "star": 2,
"equip": [ "equip2": 101,
1 "equip4": 1
]
}, },
{ {
"monster_id": 440053, "monster_id": 440053,
@ -151,9 +139,8 @@
"text": "小伊" "text": "小伊"
}, },
"star": 3, "star": 3,
"equip": [ "equip2": 101,
1 "equip4": 1
]
}, },
{ {
"monster_id": 440054, "monster_id": 440054,
@ -163,9 +150,8 @@
"text": "小伊" "text": "小伊"
}, },
"star": 4, "star": 4,
"equip": [ "equip2": 101,
1 "equip4": 1
]
}, },
{ {
"monster_id": 440055, "monster_id": 440055,
@ -175,9 +161,8 @@
"text": "小伊" "text": "小伊"
}, },
"star": 5, "star": 5,
"equip": [ "equip2": 101,
1 "equip4": 1
]
}, },
{ {
"monster_id": 240031, "monster_id": 240031,
@ -187,9 +172,8 @@
"text": "睡神沙人" "text": "睡神沙人"
}, },
"star": 1, "star": 1,
"equip": [ "equip2": 101,
1 "equip4": 1
]
}, },
{ {
"monster_id": 240032, "monster_id": 240032,
@ -199,9 +183,8 @@
"text": "睡神沙人" "text": "睡神沙人"
}, },
"star": 2, "star": 2,
"equip": [ "equip2": 101,
1 "equip4": 1
]
}, },
{ {
"monster_id": 240033, "monster_id": 240033,
@ -211,9 +194,8 @@
"text": "睡神沙人" "text": "睡神沙人"
}, },
"star": 3, "star": 3,
"equip": [ "equip2": 101,
1 "equip4": 1
]
}, },
{ {
"monster_id": 240034, "monster_id": 240034,
@ -223,9 +205,8 @@
"text": "睡神沙人" "text": "睡神沙人"
}, },
"star": 4, "star": 4,
"equip": [ "equip2": 101,
1 "equip4": 1
]
}, },
{ {
"monster_id": 240035, "monster_id": 240035,
@ -235,9 +216,8 @@
"text": "睡神沙人" "text": "睡神沙人"
}, },
"star": 5, "star": 5,
"equip": [ "equip2": 101,
1 "equip4": 1
]
}, },
{ {
"monster_id": 350021, "monster_id": 350021,
@ -247,9 +227,8 @@
"text": "希卡普" "text": "希卡普"
}, },
"star": 1, "star": 1,
"equip": [ "equip2": 101,
1 "equip4": 1
]
}, },
{ {
"monster_id": 350022, "monster_id": 350022,
@ -259,9 +238,8 @@
"text": "希卡普" "text": "希卡普"
}, },
"star": 2, "star": 2,
"equip": [ "equip2": 101,
1 "equip4": 1
]
}, },
{ {
"monster_id": 350023, "monster_id": 350023,
@ -271,9 +249,8 @@
"text": "希卡普" "text": "希卡普"
}, },
"star": 3, "star": 3,
"equip": [ "equip2": 101,
1 "equip4": 1
]
}, },
{ {
"monster_id": 350024, "monster_id": 350024,
@ -283,9 +260,8 @@
"text": "希卡普" "text": "希卡普"
}, },
"star": 4, "star": 4,
"equip": [ "equip2": 101,
1 "equip4": 1
]
}, },
{ {
"monster_id": 350025, "monster_id": 350025,
@ -295,9 +271,8 @@
"text": "希卡普" "text": "希卡普"
}, },
"star": 5, "star": 5,
"equip": [ "equip2": 101,
1 "equip4": 1
]
}, },
{ {
"monster_id": 350011, "monster_id": 350011,
@ -307,9 +282,8 @@
"text": "师父" "text": "师父"
}, },
"star": 1, "star": 1,
"equip": [ "equip2": 101,
1 "equip4": 1
]
}, },
{ {
"monster_id": 350012, "monster_id": 350012,
@ -319,9 +293,8 @@
"text": "师父" "text": "师父"
}, },
"star": 2, "star": 2,
"equip": [ "equip2": 101,
1 "equip4": 1
]
}, },
{ {
"monster_id": 350013, "monster_id": 350013,
@ -331,9 +304,8 @@
"text": "师父" "text": "师父"
}, },
"star": 3, "star": 3,
"equip": [ "equip2": 101,
1 "equip4": 1
]
}, },
{ {
"monster_id": 350014, "monster_id": 350014,
@ -343,9 +315,8 @@
"text": "师父" "text": "师父"
}, },
"star": 4, "star": 4,
"equip": [ "equip2": 101,
1 "equip4": 1
]
}, },
{ {
"monster_id": 350015, "monster_id": 350015,
@ -355,9 +326,8 @@
"text": "师父" "text": "师父"
}, },
"star": 5, "star": 5,
"equip": [ "equip2": 101,
1 "equip4": 1
]
}, },
{ {
"monster_id": 250041, "monster_id": 250041,
@ -367,9 +337,8 @@
"text": "波比" "text": "波比"
}, },
"star": 1, "star": 1,
"equip": [ "equip2": 101,
1 "equip4": 1
]
}, },
{ {
"monster_id": 250042, "monster_id": 250042,
@ -379,9 +348,8 @@
"text": "波比" "text": "波比"
}, },
"star": 1, "star": 1,
"equip": [ "equip2": 101,
1 "equip4": 1
]
}, },
{ {
"monster_id": 250043, "monster_id": 250043,
@ -391,9 +359,8 @@
"text": "波比" "text": "波比"
}, },
"star": 1, "star": 1,
"equip": [ "equip2": 101,
1 "equip4": 1
]
}, },
{ {
"monster_id": 250044, "monster_id": 250044,
@ -403,9 +370,8 @@
"text": "波比" "text": "波比"
}, },
"star": 1, "star": 1,
"equip": [ "equip2": 101,
1 "equip4": 1
]
}, },
{ {
"monster_id": 250045, "monster_id": 250045,
@ -415,8 +381,7 @@
"text": "波比" "text": "波比"
}, },
"star": 1, "star": 1,
"equip": [ "equip2": 101,
1 "equip4": 1
]
} }
] ]

File diff suppressed because it is too large Load Diff

View File

@ -6,6 +6,8 @@ import (
"go_dreamfactory/lego/sys/log" "go_dreamfactory/lego/sys/log"
"go_dreamfactory/modules" "go_dreamfactory/modules"
"go_dreamfactory/pb" "go_dreamfactory/pb"
"go_dreamfactory/sys/db"
"time"
"go.mongodb.org/mongo-driver/bson/primitive" "go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo"
@ -40,7 +42,7 @@ func (this *modelBattleComp) queryrecord(oid string) (record *pb.DBBattleRecord,
} }
//创建pve 战斗记录 //创建pve 战斗记录
func (this *modelBattleComp) createpve(session comm.IUserSession, btype pb.BattleType, req *pb.BattlePVEReq) (record *pb.DBBattleRecord, code pb.ErrorCode) { func (this *modelBattleComp) createpve(session comm.IUserSession, conn *db.DBConn, btype pb.BattleType, req *pb.BattlePVEReq) (record *pb.DBBattleRecord, code pb.ErrorCode) {
record = &pb.DBBattleRecord{ record = &pb.DBBattleRecord{
Id: primitive.NewObjectID().Hex(), Id: primitive.NewObjectID().Hex(),
Btype: btype, Btype: btype,
@ -55,9 +57,14 @@ func (this *modelBattleComp) createpve(session comm.IUserSession, btype pb.Battl
Leadpos: req.Leadpos, Leadpos: req.Leadpos,
Team: make([]*pb.DBHero, len(req.Teamids)), Team: make([]*pb.DBHero, len(req.Teamids)),
} }
model := db.NewDBModel(comm.TableHero, time.Hour, conn)
for i, v := range req.Teamids { for i, v := range req.Teamids {
if record.Redflist[0].Team[i], code = this.module.ModuleHero.GetHeroByObjID(session.GetUserId(), v); code != pb.ErrorCode_Success { if v != "" {
return hero := &pb.DBHero{}
if err := model.GetListObj(session.GetUserId(), v, hero); err != nil {
return
}
record.Redflist[0].Team[i] = hero
} }
} }

View File

@ -5,6 +5,7 @@ import (
"go_dreamfactory/lego/core" "go_dreamfactory/lego/core"
"go_dreamfactory/modules" "go_dreamfactory/modules"
"go_dreamfactory/pb" "go_dreamfactory/pb"
"go_dreamfactory/sys/db"
) )
/* /*
@ -19,6 +20,7 @@ func NewModule() core.IModule {
type Battle struct { type Battle struct {
modules.ModuleBase modules.ModuleBase
service core.IService
api_comp *apiComp api_comp *apiComp
configure *configureComp configure *configureComp
modelBattle *modelBattleComp modelBattle *modelBattleComp
@ -32,6 +34,7 @@ func (this *Battle) GetType() core.M_Modules {
//模块初始化接口 注册用户创建角色事件 //模块初始化接口 注册用户创建角色事件
func (this *Battle) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) { func (this *Battle) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) {
err = this.ModuleBase.Init(service, module, options) err = this.ModuleBase.Init(service, module, options)
this.service = service
return return
} }
@ -55,7 +58,18 @@ func (this *Battle) QueryBattleRecord(oid string) (code pb.ErrorCode, record *pb
//创建pve战斗 //创建pve战斗
func (this *Battle) CreatePveBattle(session comm.IUserSession, req *pb.BattlePVEReq) (code pb.ErrorCode, record *pb.DBBattleRecord) { func (this *Battle) CreatePveBattle(session comm.IUserSession, req *pb.BattlePVEReq) (code pb.ErrorCode, record *pb.DBBattleRecord) {
if record, code = this.modelBattle.createpve(session, pb.BattleType_pve, req); code != pb.ErrorCode_Success { var conn *db.DBConn
if this.service.GetTag() == session.GetServiecTag() {
conn = db.Local()
} else {
conn = db.ServerDBConn(session.GetServiecTag())
}
if req.Ptype < 0 || req.Ptype > 4 ||
req.Teamids == nil || len(req.Teamids) != 5 {
code = pb.ErrorCode_ReqParameterError
return
}
if record, code = this.modelBattle.createpve(session, conn, pb.BattleType_pve, req); code != pb.ErrorCode_Success {
return return
} }
return return
@ -63,7 +77,18 @@ func (this *Battle) CreatePveBattle(session comm.IUserSession, req *pb.BattlePVE
//创建pve战斗 //创建pve战斗
func (this *Battle) CreatePvbBattle(session comm.IUserSession, req *pb.BattlePVEReq) (code pb.ErrorCode, record *pb.DBBattleRecord) { func (this *Battle) CreatePvbBattle(session comm.IUserSession, req *pb.BattlePVEReq) (code pb.ErrorCode, record *pb.DBBattleRecord) {
if record, code = this.modelBattle.createpve(session, pb.BattleType_pvb, req); code != pb.ErrorCode_Success { var conn *db.DBConn
if this.service.GetTag() == session.GetServiecTag() {
conn = db.Local()
} else {
conn = db.ServerDBConn(session.GetServiecTag())
}
if req.Ptype < 0 || req.Ptype > 4 ||
req.Teamids == nil || len(req.Teamids) != 5 {
code = pb.ErrorCode_ReqParameterError
return
}
if record, code = this.modelBattle.createpve(session, conn, pb.BattleType_pvb, req); code != pb.ErrorCode_Success {
return return
} }
return return

View File

@ -23,7 +23,7 @@ func (this *apiComp) Ask(session comm.IUserSession, req *pb.MoonfantasyAskReq) (
err error err error
) )
defer func() { defer func() {
session.SendMsg(string(this.module.GetType()), "dare", &pb.MoonfantasyAskResp{Code: cd}) session.SendMsg(string(this.module.GetType()), "ask", &pb.MoonfantasyAskResp{Code: cd})
}() }()
if cd = this.AskCheck(session, req); cd != pb.ErrorCode_Success { if cd = this.AskCheck(session, req); cd != pb.ErrorCode_Success {
return return

View File

@ -20,29 +20,29 @@ func (this *apiComp) Battle(session comm.IUserSession, req *pb.MoonfantasyBattle
globalconf *cfg.GameGlobalData globalconf *cfg.GameGlobalData
boss *cfg.GameDreamlandBoosData boss *cfg.GameDreamlandBoosData
mdata *pb.DBMoonfantasy mdata *pb.DBMoonfantasy
// record *pb.DBBattleRecord record *pb.DBBattleRecord
cd pb.ErrorCode cd pb.ErrorCode
err error err error
) )
defer func() { defer func() {
// if cd == pb.ErrorCode_Success { if cd == pb.ErrorCode_Success {
// session.SendMsg(string(this.module.GetType()), "dare", &pb.MoonfantasyBattleResp{ session.SendMsg(string(this.module.GetType()), "battle", &pb.MoonfantasyBattleResp{
// Code: cd, Code: cd,
// Monster: mdata.Monster, Monster: mdata.Monster,
// Info: &pb.BattleInfo{ Info: &pb.BattleInfo{
// Id: record.Id, Id: record.Id,
// Btype: record.Btype, Btype: record.Btype,
// Ptype: record.Ptype, Ptype: record.Ptype,
// RedCompId: record.RedCompId, RedCompId: record.RedCompId,
// Redflist: record.Redflist, Redflist: record.Redflist,
// BlueCompId: record.BlueCompId, BlueCompId: record.BlueCompId,
// Buleflist: record.Buleflist, Buleflist: record.Buleflist,
// }, },
// }) })
// } else { } else {
session.SendMsg(string(this.module.GetType()), "dare", &pb.MoonfantasyBattleResp{Code: cd}) session.SendMsg(string(this.module.GetType()), "battle", &pb.MoonfantasyBattleResp{Code: cd})
// } }
}() }()
@ -84,7 +84,7 @@ func (this *apiComp) Battle(session comm.IUserSession, req *pb.MoonfantasyBattle
} else { } else {
mdata.Record[session.GetUserId()] = 1 mdata.Record[session.GetUserId()] = 1
} }
cd, _ = this.module.battle.CreatePvbBattle(session, &pb.BattlePVEReq{ cd, record = this.module.battle.CreatePvbBattle(session, &pb.BattlePVEReq{
Ptype: pb.PlayType_moonfantasy, Ptype: pb.PlayType_moonfantasy,
Leadpos: req.Leadpos, Leadpos: req.Leadpos,
Teamids: req.Teamids, Teamids: req.Teamids,

View File

@ -30,12 +30,12 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.MoonfantasyRecei
} }
if boss, err = this.module.configure.GetMonsterById(req.Monster); err != nil { if boss, err = this.module.configure.GetMonsterById(req.Monster); err != nil {
code = pb.ErrorCode_ConfigNoFound code = pb.ErrorCode_ConfigNoFound
return return
} }
if code, iswin = this.module.battle.CheckBattleReport(session, req.Report); code != pb.ErrorCode_Success { if code, iswin = this.module.battle.CheckBattleReport(session, req.Report); code != pb.ErrorCode_Success {
return return
} }
if iswin { if !iswin {
code = pb.ErrorCode_MoonfantasyBattleNoWin code = pb.ErrorCode_MoonfantasyBattleNoWin
return return
} }