Merge branch 'dev' of http://git.legu.cc/liwei_3d/go_dreamfactory into dev
This commit is contained in:
commit
64e3110284
@ -59,13 +59,22 @@ func (this *modelBattleComp) createeve(session comm.IUserSession, conn *db.DBCon
|
||||
battletas *cfg.GameBattletasktestingData
|
||||
captain int32
|
||||
masters []*pb.BattleRole
|
||||
user *pb.DBUserExpand
|
||||
err error
|
||||
// buff *cfg.GamePandamasBuffData
|
||||
)
|
||||
// buff, _ = this.getGlobalBuff(session.GetUserId())
|
||||
if battletas, _ = this.module.configure.GetBattleTask(int32(req.Ptype)); battletas != nil {
|
||||
record.Tasks = battletas.BattletaskTestingId
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
if req.Format != nil {
|
||||
model := db.NewDBModel(comm.TableHero, time.Hour, conn)
|
||||
record.Redflist = make([]*pb.DBBattleFormt, 1)
|
||||
@ -85,7 +94,7 @@ func (this *modelBattleComp) createeve(session comm.IUserSession, conn *db.DBCon
|
||||
return
|
||||
}
|
||||
tid := 100 + i
|
||||
if record.Redflist[0].Team[i], errdata = this.createBattleRole(hero, tid, i); errdata != nil {
|
||||
if record.Redflist[0].Team[i], errdata = this.createBattleRole(hero, user.Passonlv, tid, i); errdata != nil {
|
||||
return
|
||||
}
|
||||
} else {
|
||||
@ -122,7 +131,7 @@ func (this *modelBattleComp) createeve(session comm.IUserSession, conn *db.DBCon
|
||||
}
|
||||
}
|
||||
tid := 100 + i
|
||||
if record.Redflist[0].Team[i], errdata = this.createBattleRole(hero, tid, i); errdata != nil {
|
||||
if record.Redflist[0].Team[i], errdata = this.createBattleRole(hero, 0, tid, i); errdata != nil {
|
||||
return
|
||||
}
|
||||
record.Redflist[0].Team[i].Ishelp = true
|
||||
@ -189,6 +198,8 @@ func (this *modelBattleComp) createpve(session comm.IUserSession, conn *db.DBCon
|
||||
heros []*pb.DBHero = make([]*pb.DBHero, 5)
|
||||
captain int32
|
||||
masters []*pb.BattleRole
|
||||
user *pb.DBUserExpand
|
||||
err error
|
||||
)
|
||||
record = &pb.DBBattleRecord{
|
||||
Id: primitive.NewObjectID().Hex(),
|
||||
@ -207,6 +218,14 @@ func (this *modelBattleComp) createpve(session comm.IUserSession, conn *db.DBCon
|
||||
Team: make([]*pb.BattleRole, len(req.Format.Format)),
|
||||
}
|
||||
model := db.NewDBModel(comm.TableHero, time.Hour, 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 != "" {
|
||||
@ -219,7 +238,7 @@ func (this *modelBattleComp) createpve(session comm.IUserSession, conn *db.DBCon
|
||||
return
|
||||
}
|
||||
tid := 100 + i
|
||||
if record.Redflist[0].Team[i], errdata = this.createBattleRole(heros[i], tid, i); errdata != nil {
|
||||
if record.Redflist[0].Team[i], errdata = this.createBattleRole(heros[i], user.Passonlv, tid, i); errdata != nil {
|
||||
return
|
||||
}
|
||||
} else {
|
||||
@ -255,7 +274,7 @@ func (this *modelBattleComp) createpve(session comm.IUserSession, conn *db.DBCon
|
||||
}
|
||||
}
|
||||
tid := 100 + i
|
||||
if record.Redflist[0].Team[i], errdata = this.createBattleRole(heros[i], tid, i); errdata != nil {
|
||||
if record.Redflist[0].Team[i], errdata = this.createBattleRole(heros[i], 0, tid, i); errdata != nil {
|
||||
return
|
||||
}
|
||||
record.Redflist[0].Team[i].Ishelp = true
|
||||
@ -308,7 +327,9 @@ func (this *modelBattleComp) createpve(session comm.IUserSession, conn *db.DBCon
|
||||
// 创建pve 战斗记录
|
||||
func (this *modelBattleComp) createpvb(session comm.IUserSession, conn *db.DBConn, btype pb.BattleType, req *pb.BattlePVBReq, conf *cfg.GameBattleReadyData) (record *pb.DBBattleRecord, errdata *pb.ErrorData) {
|
||||
var (
|
||||
// buff *cfg.GamePandamasBuffData
|
||||
// buff *cfg.GamePandamasBuffData
|
||||
user *pb.DBUserExpand
|
||||
err error
|
||||
)
|
||||
record = &pb.DBBattleRecord{
|
||||
Id: primitive.NewObjectID().Hex(),
|
||||
@ -321,6 +342,14 @@ func (this *modelBattleComp) createpvb(session comm.IUserSession, conn *db.DBCon
|
||||
BlueCompId: "",
|
||||
Buleflist: make([]*pb.DBBattleFormt, len(req.Mformat)),
|
||||
}
|
||||
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
|
||||
}
|
||||
// buff, _ = this.getGlobalBuff(session.GetUserId())
|
||||
for ii, v := range req.Format {
|
||||
heros := make([]*pb.DBHero, 5)
|
||||
@ -341,7 +370,7 @@ func (this *modelBattleComp) createpvb(session comm.IUserSession, conn *db.DBCon
|
||||
return
|
||||
}
|
||||
tid := 100 + i
|
||||
if record.Redflist[ii].Team[i], errdata = this.createBattleRole(heros[i], tid, i); errdata != nil {
|
||||
if record.Redflist[ii].Team[i], errdata = this.createBattleRole(heros[i], user.Passonlv, tid, i); errdata != nil {
|
||||
return
|
||||
}
|
||||
// if buff != nil {
|
||||
@ -384,7 +413,7 @@ func (this *modelBattleComp) createpvb(session comm.IUserSession, conn *db.DBCon
|
||||
}
|
||||
}
|
||||
tid := 100 + i
|
||||
if record.Redflist[ii].Team[i], errdata = this.createBattleRole(heros[i], tid, i); errdata != nil {
|
||||
if record.Redflist[ii].Team[i], errdata = this.createBattleRole(heros[i], 0, tid, i); errdata != nil {
|
||||
return
|
||||
}
|
||||
record.Redflist[ii].Team[i].Ishelp = true
|
||||
@ -424,6 +453,7 @@ func (this *modelBattleComp) createpvb(session comm.IUserSession, conn *db.DBCon
|
||||
|
||||
// 创建pvp 战斗请求
|
||||
func (this *modelBattleComp) createpvp(session comm.IUserSession, conn *db.DBConn, btype pb.BattleType, req *pb.BattlePVPReq, conf *cfg.GameBattleReadyData) (record *pb.DBBattleRecord, errdata *pb.ErrorData) {
|
||||
|
||||
record = &pb.DBBattleRecord{
|
||||
Id: primitive.NewObjectID().Hex(),
|
||||
Title: req.Title,
|
||||
@ -439,11 +469,12 @@ func (this *modelBattleComp) createpvp(session comm.IUserSession, conn *db.DBCon
|
||||
Leadpos: req.Redformat.Leadpos,
|
||||
Team: make([]*pb.BattleRole, len(req.Redformat.Format)),
|
||||
}
|
||||
|
||||
//自己的英雄阵营
|
||||
for i, v := range req.Redformat.Format {
|
||||
if v != nil {
|
||||
tid := 100 + i
|
||||
if record.Redflist[0].Team[i], errdata = this.createBattleRole(v, tid, i); errdata != nil {
|
||||
if record.Redflist[0].Team[i], errdata = this.createBattleRole(v, 0, tid, i); errdata != nil {
|
||||
return
|
||||
}
|
||||
} else {
|
||||
@ -466,7 +497,7 @@ func (this *modelBattleComp) createpvp(session comm.IUserSession, conn *db.DBCon
|
||||
for i, v := range req.Buleformat.Format {
|
||||
if v != nil {
|
||||
tid := 200 + i
|
||||
if record.Buleflist[0].Team[i], errdata = this.createBattleRole(v, tid, i); errdata != nil {
|
||||
if record.Buleflist[0].Team[i], errdata = this.createBattleRole(v, 0, tid, i); errdata != nil {
|
||||
return
|
||||
}
|
||||
} else {
|
||||
@ -513,7 +544,7 @@ func (this *modelBattleComp) creatertpvp(redmodel, bluemodel *db.DBModel, btype
|
||||
return
|
||||
}
|
||||
tid := 100 + i
|
||||
if record.Redflist[ii].Team[i], errdata = this.createBattleRole(heros[i], tid, i); errdata != nil {
|
||||
if record.Redflist[ii].Team[i], errdata = this.createBattleRole(heros[i], 0, tid, i); errdata != nil {
|
||||
return
|
||||
}
|
||||
} else {
|
||||
@ -545,7 +576,7 @@ func (this *modelBattleComp) creatertpvp(redmodel, bluemodel *db.DBModel, btype
|
||||
return
|
||||
}
|
||||
tid := 200 + i
|
||||
if record.Buleflist[ii].Team[i], errdata = this.createBattleRole(heros[i], tid, i); errdata != nil {
|
||||
if record.Buleflist[ii].Team[i], errdata = this.createBattleRole(heros[i], 0, tid, i); errdata != nil {
|
||||
return
|
||||
}
|
||||
} else {
|
||||
@ -567,7 +598,8 @@ func (this *modelBattleComp) creatertpvp(redmodel, bluemodel *db.DBModel, btype
|
||||
func (this *modelBattleComp) createlpve(session comm.IUserSession, conn *db.DBConn, btype pb.BattleType, req *pb.BattleLPVEReq, conf *cfg.GameBattleReadyData) (record *pb.DBBattleRecord, errdata *pb.ErrorData) {
|
||||
var (
|
||||
heros []*pb.DBHero = make([]*pb.DBHero, 5)
|
||||
// buff *cfg.GamePandamasBuffData
|
||||
user *pb.DBUserExpand
|
||||
err error
|
||||
)
|
||||
record = &pb.DBBattleRecord{
|
||||
Id: primitive.NewObjectID().Hex(),
|
||||
@ -585,7 +617,14 @@ func (this *modelBattleComp) createlpve(session comm.IUserSession, conn *db.DBCo
|
||||
Team: make([]*pb.BattleRole, len(req.Format.Format)),
|
||||
}
|
||||
model := db.NewDBModel(comm.TableHero, time.Hour, conn)
|
||||
// buff, _ = this.getGlobalBuff(session.GetUserId())
|
||||
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 != "" {
|
||||
@ -598,7 +637,7 @@ func (this *modelBattleComp) createlpve(session comm.IUserSession, conn *db.DBCo
|
||||
return
|
||||
}
|
||||
tid := 100 + i
|
||||
if record.Redflist[0].Team[i], errdata = this.createBattleRole(heros[i], tid, i); errdata != nil {
|
||||
if record.Redflist[0].Team[i], errdata = this.createBattleRole(heros[i], user.Passonlv, tid, i); errdata != nil {
|
||||
return
|
||||
}
|
||||
// if buff != nil {
|
||||
@ -641,7 +680,7 @@ func (this *modelBattleComp) createlpve(session comm.IUserSession, conn *db.DBCo
|
||||
}
|
||||
}
|
||||
tid := 100 + i
|
||||
if record.Redflist[0].Team[i], errdata = this.createBattleRole(heros[i], tid, i); errdata != nil {
|
||||
if record.Redflist[0].Team[i], errdata = this.createBattleRole(heros[i], 0, tid, i); errdata != nil {
|
||||
return
|
||||
}
|
||||
record.Redflist[0].Team[i].Ishelp = true
|
||||
@ -668,7 +707,7 @@ func (this *modelBattleComp) createlpve(session comm.IUserSession, conn *db.DBCo
|
||||
return
|
||||
}
|
||||
|
||||
func (this *modelBattleComp) createBattleRole(hero *pb.DBHero, tid, pos int) (role *pb.BattleRole, errdata *pb.ErrorData) {
|
||||
func (this *modelBattleComp) createBattleRole(hero *pb.DBHero, vlv int32, tid, pos int) (role *pb.BattleRole, errdata *pb.ErrorData) {
|
||||
role = &pb.BattleRole{
|
||||
Tid: int32(tid),
|
||||
Oid: hero.Id,
|
||||
@ -681,6 +720,11 @@ func (this *modelBattleComp) createBattleRole(hero *pb.DBHero, tid, pos int) (ro
|
||||
EquipSkill: make([]*pb.SkillData, 0),
|
||||
Property: make(map[int32]int32),
|
||||
}
|
||||
|
||||
if hero.Ispasson && vlv > 0 {
|
||||
hero = this.module.ModuleHero.GetVirtualHero(hero, vlv)
|
||||
}
|
||||
|
||||
for k, v := range hero.Property {
|
||||
arrt := AttributesTransBase(k)
|
||||
role.Property[arrt] += v
|
||||
|
@ -384,7 +384,7 @@ func (this *Battle) CreateRolesByHeros(heros []*pb.DBHero) (roles []*pb.BattleRo
|
||||
roles = make([]*pb.BattleRole, len(heros))
|
||||
for i, v := range heros {
|
||||
if v != nil {
|
||||
if roles[i], errdata = this.modelBattle.createBattleRole(v, 200+i, i); errdata != nil {
|
||||
if roles[i], errdata = this.modelBattle.createBattleRole(v, 0, 200+i, i); errdata != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
@ -28,14 +28,14 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.DreamWarorderRec
|
||||
return
|
||||
}
|
||||
|
||||
if conf, err = this.module.configure.getGameVenturegiftsTask(req.Id); err != nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_DBError,
|
||||
Title: pb.ErrorCode_DBError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
// if conf, err = this.module.configure.getGameVenturegiftsTask(req.Id); err != nil {
|
||||
// errdata = &pb.ErrorData{
|
||||
// Code: pb.ErrorCode_DBError,
|
||||
// Title: pb.ErrorCode_DBError.ToString(),
|
||||
// Message: err.Error(),
|
||||
// }
|
||||
// return
|
||||
// }
|
||||
// if info, err = this.module.model.getUserDreamwarorder(session.GetUserId()); err != nil {
|
||||
// errdata = &pb.ErrorData{
|
||||
// Code: pb.ErrorCode_DBError,
|
||||
|
@ -1,7 +1,7 @@
|
||||
package dreamwarorder
|
||||
|
||||
import (
|
||||
"go_dreamfactory/comm"
|
||||
"fmt"
|
||||
"go_dreamfactory/lego/core"
|
||||
"go_dreamfactory/modules"
|
||||
"go_dreamfactory/sys/configure"
|
||||
@ -10,75 +10,77 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
game_venturegiftstask = "game_venturegiftstask.json"
|
||||
game_passcheck = "game_passcheck.json"
|
||||
)
|
||||
|
||||
type configureComp struct {
|
||||
modules.MCompConfigure
|
||||
module *DreamWarorder
|
||||
lock sync.RWMutex
|
||||
tasks map[int32]struct{}
|
||||
groupTasks map[int32][]*cfg.GameVenturegiftsTaskData //key 条件ID
|
||||
module *DreamWarorder
|
||||
lock sync.RWMutex
|
||||
product map[string]int32 //商品id
|
||||
order map[int32][]*cfg.GamePassCheckData //战令
|
||||
}
|
||||
|
||||
func (this *configureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
||||
err = this.MCompConfigure.Init(service, module, comp, options)
|
||||
this.module = module.(*DreamWarorder)
|
||||
configure.RegisterConfigure(game_venturegiftstask, cfg.NewGameVenturegiftsTask, this.updateconfigure)
|
||||
configure.RegisterConfigure(game_passcheck, cfg.NewGamePassCheck, this.updateconfigure)
|
||||
return
|
||||
}
|
||||
|
||||
func (this *configureComp) gettasks() map[int32]struct{} {
|
||||
func (this *configureComp) getproduct() map[string]int32 {
|
||||
this.lock.RLock()
|
||||
defer this.lock.RUnlock()
|
||||
return this.tasks
|
||||
return this.product
|
||||
}
|
||||
func (this *configureComp) getorder(wtype int32) (results []*cfg.GamePassCheckData, err error) {
|
||||
this.lock.RLock()
|
||||
defer this.lock.RUnlock()
|
||||
var ok bool
|
||||
if results, ok = this.order[wtype]; !ok {
|
||||
err = fmt.Errorf("no found wtype:%d", wtype)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 更新任务配置表
|
||||
func (this *configureComp) updateconfigure() {
|
||||
var (
|
||||
v interface{}
|
||||
conf *cfg.GameVenturegiftsTask
|
||||
ok bool
|
||||
err error
|
||||
)
|
||||
if v, err = this.GetConfigure(game_venturegiftstask); err != nil {
|
||||
return
|
||||
}
|
||||
if conf, ok = v.(*cfg.GameVenturegiftsTask); !ok {
|
||||
this.module.Error("日常任务配置异常!")
|
||||
return
|
||||
}
|
||||
tasks := make(map[int32]struct{})
|
||||
groupTasksConf := make(map[int32][]*cfg.GameVenturegiftsTaskData)
|
||||
|
||||
for _, v := range conf.GetDataList() {
|
||||
|
||||
if _, ok := groupTasksConf[v.Openday]; !ok {
|
||||
groupTasksConf[v.Openday] = make([]*cfg.GameVenturegiftsTaskData, 0)
|
||||
}
|
||||
groupTasksConf[v.Openday] = append(groupTasksConf[v.Openday], v)
|
||||
tasks[v.Venturetask] = struct{}{}
|
||||
}
|
||||
|
||||
this.lock.Lock()
|
||||
this.groupTasks = groupTasksConf
|
||||
this.tasks = tasks
|
||||
this.lock.Unlock()
|
||||
}
|
||||
|
||||
func (this *configureComp) getGameVenturegiftsTask(id int32) (conf *cfg.GameVenturegiftsTaskData, err error) {
|
||||
// 读取任务配置表
|
||||
func (this *configureComp) getPassCheckCfg() (data *cfg.GamePassCheck, err error) {
|
||||
var (
|
||||
v interface{}
|
||||
ok bool
|
||||
)
|
||||
if v, err = this.GetConfigure(game_venturegiftstask); err != nil {
|
||||
return
|
||||
}
|
||||
if conf, ok = v.(*cfg.GameVenturegiftsTask).GetDataMap()[id]; !ok {
|
||||
err = comm.NewNotFoundConfErr(string(this.module.GetType()), game_venturegiftstask, id)
|
||||
this.module.Errorln(err)
|
||||
if v, err = this.GetConfigure(game_passcheck); err != nil {
|
||||
return
|
||||
} else {
|
||||
if data, ok = v.(*cfg.GamePassCheck); !ok {
|
||||
err = fmt.Errorf("%T is *cfg.GameWorldTask", v)
|
||||
return
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 更新任务配置表
|
||||
func (this *configureComp) updateconfigure() {
|
||||
gwt, err := this.getPassCheckCfg()
|
||||
if err != nil {
|
||||
this.module.Error("世界任务配置表异常!")
|
||||
return
|
||||
}
|
||||
productConf := make(map[string]int32)
|
||||
orderConf := make(map[int32][]*cfg.GamePassCheckData)
|
||||
for _, v := range gwt.GetDataList() {
|
||||
if _, ok := productConf[v.PayId]; !ok {
|
||||
productConf[v.PayId] = v.PasscheckType
|
||||
}
|
||||
if _, ok := orderConf[v.PasscheckType]; !ok {
|
||||
orderConf[v.PasscheckType] = make([]*cfg.GamePassCheckData, 0)
|
||||
}
|
||||
orderConf[v.PasscheckType] = append(orderConf[v.PasscheckType], v)
|
||||
}
|
||||
|
||||
this.lock.Lock()
|
||||
this.product = productConf
|
||||
this.order = orderConf
|
||||
this.lock.Unlock()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user