上传战斗模块表调整
This commit is contained in:
parent
ada9d59d29
commit
1b0c92ae7e
@ -175,6 +175,8 @@ type (
|
||||
|
||||
//战斗系统
|
||||
IBattle interface {
|
||||
//创建怪物阵营
|
||||
CreateMasterRoles(wheel int, fid int32) (captain int32, roles []*pb.BattleRole, code pb.ErrorCode)
|
||||
///创建pve战斗
|
||||
CreatePveBattle(session IUserSession, req *pb.BattlePVEReq) (code pb.ErrorCode, record *pb.DBBattleRecord)
|
||||
///创建pvb战斗
|
||||
|
@ -23,9 +23,11 @@ const (
|
||||
///竞技场配置管理组件
|
||||
type configureComp struct {
|
||||
modules.MCompConfigure
|
||||
module *Arena
|
||||
lock sync.RWMutex
|
||||
ais map[int32][]*cfg.GameArenaRobotData
|
||||
module *Arena
|
||||
lock sync.RWMutex
|
||||
ais map[int32][]*cfg.GameArenaRobotData
|
||||
mformatlock sync.RWMutex
|
||||
mformat map[int32][]*cfg.GameMonsterFormatData //怪物阵营表
|
||||
}
|
||||
|
||||
//组件初始化接口
|
||||
@ -38,7 +40,24 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp
|
||||
this.LoadConfigure(game_arenarankreward, cfg.NewGameArenaRankReward)
|
||||
this.LoadConfigure(game_arenachallengenpc, cfg.NewGameArenaChallengeNpc)
|
||||
|
||||
this.LoadConfigure(game_monsterformat, cfg.NewGameMonsterFormat)
|
||||
configure.RegisterConfigure(game_monsterformat, cfg.NewGameMonsterFormat, func() {
|
||||
this.mformatlock.Lock()
|
||||
if v, err := this.GetConfigure(game_monsterformat); err != nil {
|
||||
this.module.Errorf("err:%v", err)
|
||||
return
|
||||
} else {
|
||||
this.mformat = make(map[int32][]*cfg.GameMonsterFormatData)
|
||||
for _, v := range v.(*cfg.GameMonsterFormat).GetDataList() {
|
||||
if this.mformat[v.Id] == nil {
|
||||
this.mformat[v.Id] = make([]*cfg.GameMonsterFormatData, 5)
|
||||
}
|
||||
if v.Monster != -1 {
|
||||
this.mformat[v.Id][v.Pos-1] = v
|
||||
}
|
||||
}
|
||||
}
|
||||
this.mformatlock.Unlock()
|
||||
})
|
||||
this.LoadConfigure(game_monster, cfg.NewGameMonster)
|
||||
return
|
||||
}
|
||||
@ -124,19 +143,18 @@ func (this *configureComp) getArenaRobot(dan int32) (result []*cfg.GameArenaRobo
|
||||
}
|
||||
|
||||
//查询阵容表
|
||||
func (this *configureComp) getMonsterFormat(id int32) (result *cfg.GameMonsterFormatData, err error) {
|
||||
//查询阵容表
|
||||
func (this *configureComp) getMonsterFormat(id int32) (result []*cfg.GameMonsterFormatData, err error) {
|
||||
this.mformatlock.RLock()
|
||||
defer this.mformatlock.RUnlock()
|
||||
var (
|
||||
v interface{}
|
||||
ok bool
|
||||
)
|
||||
if v, err = this.GetConfigure(game_monsterformat); err != nil {
|
||||
this.module.Errorln(err)
|
||||
} else {
|
||||
if result, ok = v.(*cfg.GameMonsterFormat).GetDataMap()[id]; !ok {
|
||||
err = fmt.Errorf("on found MonsterFormat:%d", id)
|
||||
this.module.Errorln(err)
|
||||
}
|
||||
if result, ok = this.mformat[id]; ok {
|
||||
return
|
||||
}
|
||||
err = fmt.Errorf("GetMonsterFormat no found :%d", id)
|
||||
this.module.Errorln(err)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -173,7 +173,7 @@ func (this *modelArena) matcheAI(dan, num int32) (results []*pb.ArenaPlayer, err
|
||||
var (
|
||||
active *cfg.GameArenaActiveRewardData
|
||||
ais []*cfg.GameArenaRobotData
|
||||
mFormat *cfg.GameMonsterFormatData
|
||||
formats []*cfg.GameMonsterFormatData
|
||||
monst *cfg.GameMonsterData
|
||||
rank []int32
|
||||
targets []int32
|
||||
@ -198,7 +198,7 @@ func (this *modelArena) matcheAI(dan, num int32) (results []*pb.ArenaPlayer, err
|
||||
results = make([]*pb.ArenaPlayer, num)
|
||||
for i, v := range targets {
|
||||
aiconf := ais[v]
|
||||
if mFormat, err = this.module.configure.getMonsterFormat(aiconf.MonsterformatId); err != nil {
|
||||
if formats, err = this.module.configure.getMonsterFormat(aiconf.MonsterformatId); err != nil {
|
||||
this.module.Errorln(err)
|
||||
return
|
||||
}
|
||||
@ -210,25 +210,29 @@ func (this *modelArena) matcheAI(dan, num int32) (results []*pb.ArenaPlayer, err
|
||||
Isai: true,
|
||||
Mformatid: aiconf.MonsterformatId,
|
||||
Defend: &pb.DBPlayerBattleFormt{
|
||||
Leadpos: mFormat.CaptainId,
|
||||
Formt: make([]*pb.DBHero, len(mFormat.MonsterList)),
|
||||
Leadpos: 0,
|
||||
Formt: make([]*pb.DBHero, len(formats)),
|
||||
},
|
||||
}
|
||||
for i1, v1 := range mFormat.MonsterList {
|
||||
if v1 == -1 {
|
||||
|
||||
for i1, v1 := range formats {
|
||||
if v1 == nil {
|
||||
results[i].Defend.Formt[i1] = nil
|
||||
} else {
|
||||
if monst, err = this.module.configure.getMonster(v1); err != nil {
|
||||
if v1.CaptainId == 1 {
|
||||
results[i].Defend.Leadpos = int32(i1)
|
||||
}
|
||||
if monst, err = this.module.configure.getMonster(v1.Monster); err != nil {
|
||||
this.module.Errorln(err)
|
||||
}
|
||||
hero := &pb.DBHero{}
|
||||
if hero = this.module.ModuleHero.CreateMonster(monst.HeroId, monst.Star, mFormat.Lv); hero == nil {
|
||||
if hero = this.module.ModuleHero.CreateMonster(monst.HeroId, monst.Star, v1.Lv); hero == nil {
|
||||
err = fmt.Errorf("CreateMonster 失败")
|
||||
return
|
||||
}
|
||||
hero.Property[comm.Hp] = int32(float32(hero.Property[comm.Hp]) * mFormat.Hppro)
|
||||
hero.Property[comm.Atk] = int32(float32(hero.Property[comm.Atk]) * mFormat.Atkpro)
|
||||
hero.Property[comm.Def] = int32(float32(hero.Property[comm.Def]) * mFormat.Defpro)
|
||||
hero.Property[comm.Hp] = int32(float32(hero.Property[comm.Hp]) * v1.Hppro)
|
||||
hero.Property[comm.Atk] = int32(float32(hero.Property[comm.Atk]) * v1.Atkpro)
|
||||
hero.Property[comm.Def] = int32(float32(hero.Property[comm.Def]) * v1.Defpro)
|
||||
hero.SuiteId = monst.Equip4
|
||||
hero.SuiteExtId = monst.Equip2
|
||||
results[i].Defend.Formt[i1] = hero
|
||||
@ -293,10 +297,10 @@ func (this *modelArena) randUserName() string {
|
||||
|
||||
func (this *modelArena) getAI(mformatId int32) (ai *pb.ArenaPlayer, err error) {
|
||||
var (
|
||||
mFormat *cfg.GameMonsterFormatData
|
||||
formats []*cfg.GameMonsterFormatData
|
||||
monst *cfg.GameMonsterData
|
||||
)
|
||||
if mFormat, err = this.module.configure.getMonsterFormat(mformatId); err != nil {
|
||||
if formats, err = this.module.configure.getMonsterFormat(mformatId); err != nil {
|
||||
this.module.Errorln(err)
|
||||
return
|
||||
}
|
||||
@ -305,25 +309,25 @@ func (this *modelArena) getAI(mformatId int32) (ai *pb.ArenaPlayer, err error) {
|
||||
Isai: true,
|
||||
Mformatid: mformatId,
|
||||
Defend: &pb.DBPlayerBattleFormt{
|
||||
Leadpos: mFormat.CaptainId,
|
||||
Formt: make([]*pb.DBHero, len(mFormat.MonsterList)),
|
||||
Leadpos: 0,
|
||||
Formt: make([]*pb.DBHero, len(formats)),
|
||||
},
|
||||
}
|
||||
for i1, v1 := range mFormat.MonsterList {
|
||||
if v1 == -1 {
|
||||
for i1, v1 := range formats {
|
||||
if v1 == nil {
|
||||
ai.Defend.Formt[i1] = nil
|
||||
} else {
|
||||
if monst, err = this.module.configure.getMonster(v1); err != nil {
|
||||
if monst, err = this.module.configure.getMonster(v1.Monster); err != nil {
|
||||
this.module.Errorln(err)
|
||||
}
|
||||
hero := &pb.DBHero{}
|
||||
if hero = this.module.ModuleHero.CreateMonster(monst.HeroId, monst.Star, mFormat.Lv); hero == nil {
|
||||
if hero = this.module.ModuleHero.CreateMonster(monst.HeroId, monst.Star, v1.Lv); hero == nil {
|
||||
err = fmt.Errorf("CreateMonster 失败")
|
||||
return
|
||||
}
|
||||
hero.Property[comm.Hp] = int32(float32(hero.Property[comm.Hp]) * mFormat.Hppro)
|
||||
hero.Property[comm.Atk] = int32(float32(hero.Property[comm.Atk]) * mFormat.Atkpro)
|
||||
hero.Property[comm.Def] = int32(float32(hero.Property[comm.Def]) * mFormat.Defpro)
|
||||
hero.Property[comm.Hp] = int32(float32(hero.Property[comm.Hp]) * v1.Hppro)
|
||||
hero.Property[comm.Atk] = int32(float32(hero.Property[comm.Atk]) * v1.Atkpro)
|
||||
hero.Property[comm.Def] = int32(float32(hero.Property[comm.Def]) * v1.Defpro)
|
||||
hero.SuiteId = monst.Equip4
|
||||
hero.SuiteExtId = monst.Equip2
|
||||
ai.Defend.Formt[i1] = hero
|
||||
|
@ -23,6 +23,8 @@ const (
|
||||
type configureComp struct {
|
||||
modules.MCompConfigure
|
||||
module *Battle
|
||||
mformatlock sync.RWMutex
|
||||
mformat map[int32][]*cfg.GameMonsterFormatData //怪物阵营表
|
||||
skillatklock sync.RWMutex
|
||||
skillatk map[int32]map[int32]*cfg.GameSkillAtkData //主动技能表
|
||||
}
|
||||
@ -33,7 +35,24 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp
|
||||
this.module = module.(*Battle)
|
||||
this.LoadConfigure(game_equipsuit, cfg.NewGameEquipSuit)
|
||||
this.LoadConfigure(game_monster, cfg.NewGameMonster)
|
||||
this.LoadConfigure(game_monsterformat, cfg.NewGameMonsterFormat)
|
||||
configure.RegisterConfigure(game_monsterformat, cfg.NewGameMonsterFormat, func() {
|
||||
this.mformatlock.Lock()
|
||||
if v, err := this.GetConfigure(game_monsterformat); err != nil {
|
||||
this.module.Errorf("err:%v", err)
|
||||
return
|
||||
} else {
|
||||
this.mformat = make(map[int32][]*cfg.GameMonsterFormatData)
|
||||
for _, v := range v.(*cfg.GameMonsterFormat).GetDataList() {
|
||||
if this.mformat[v.Id] == nil {
|
||||
this.mformat[v.Id] = make([]*cfg.GameMonsterFormatData, 5)
|
||||
}
|
||||
if v.Monster != -1 {
|
||||
this.mformat[v.Id][v.Pos-1] = v
|
||||
}
|
||||
}
|
||||
}
|
||||
this.mformatlock.Unlock()
|
||||
})
|
||||
configure.RegisterConfigure(game_skillatk, cfg.NewGameSkillAtk, func() {
|
||||
this.skillatklock.Lock()
|
||||
if v, err := this.GetConfigure(game_skillatk); err != nil {
|
||||
@ -57,19 +76,17 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp
|
||||
}
|
||||
|
||||
//查询阵容表
|
||||
func (this *configureComp) GetMonsterFormat(id int32) (result *cfg.GameMonsterFormatData, err error) {
|
||||
func (this *configureComp) GetMonsterFormat(id int32) (result []*cfg.GameMonsterFormatData, err error) {
|
||||
this.mformatlock.RLock()
|
||||
defer this.mformatlock.RUnlock()
|
||||
var (
|
||||
v interface{}
|
||||
ok bool
|
||||
)
|
||||
if v, err = this.GetConfigure(game_monsterformat); err != nil {
|
||||
this.module.Errorln(err)
|
||||
} else {
|
||||
if result, ok = v.(*cfg.GameMonsterFormat).GetDataMap()[id]; !ok {
|
||||
err = fmt.Errorf("on found MonsterFormat:%d", id)
|
||||
this.module.Errorln(err)
|
||||
}
|
||||
if result, ok = this.mformat[id]; ok {
|
||||
return
|
||||
}
|
||||
err = fmt.Errorf("GetMonsterFormat no found :%d", id)
|
||||
this.module.Errorln(err)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@ import (
|
||||
"go_dreamfactory/lego/sys/log"
|
||||
"go_dreamfactory/modules"
|
||||
"go_dreamfactory/pb"
|
||||
cfg "go_dreamfactory/sys/configure/structs"
|
||||
"go_dreamfactory/sys/db"
|
||||
"time"
|
||||
|
||||
@ -55,63 +56,26 @@ func (this *modelBattleComp) createeve(session comm.IUserSession, conn *db.DBCon
|
||||
BlueCompId: "",
|
||||
Buleflist: make([]*pb.DBBattleFormt, len(req.Buleformat)),
|
||||
}
|
||||
|
||||
var (
|
||||
captain int32
|
||||
masters []*pb.BattleRole
|
||||
)
|
||||
for i, v := range req.Redformat {
|
||||
if mf, err := this.module.configure.GetMonsterFormat(v); err != nil {
|
||||
code = pb.ErrorCode_ConfigNoFound
|
||||
if captain, masters, code = this.createMasterRoles(i, v); code != pb.ErrorCode_Success {
|
||||
return
|
||||
} else {
|
||||
record.Buleflist[i] = &pb.DBBattleFormt{
|
||||
Leadpos: mf.CaptainId,
|
||||
Team: make([]*pb.BattleRole, len(mf.MonsterList)),
|
||||
}
|
||||
for i1, v1 := range mf.MonsterList {
|
||||
if v1 == -1 {
|
||||
record.Buleflist[i].Team[i1] = nil
|
||||
} else {
|
||||
if monst, err := this.module.configure.GetMonster(v1); err != nil {
|
||||
code = pb.ErrorCode_ConfigNoFound
|
||||
} else {
|
||||
hero := &pb.DBHero{}
|
||||
if hero = this.module.ModuleHero.CreateMonster(monst.HeroId, monst.Star, mf.Lv); hero == nil {
|
||||
log.Error("on found battle req data", log.Field{Key: "HeroId", Value: monst.HeroId})
|
||||
code = pb.ErrorCode_ReqParameterError
|
||||
return
|
||||
} else {
|
||||
record.Buleflist[i].Team[i1] = &pb.BattleRole{
|
||||
Tid: int32(200 + i*10 + i1),
|
||||
Oid: hero.Id,
|
||||
HeroID: hero.HeroID,
|
||||
Pos: int32(i1),
|
||||
Star: hero.Star,
|
||||
Lv: hero.Lv,
|
||||
CaptainSkill: hero.CaptainSkill,
|
||||
NormalSkill: hero.NormalSkill,
|
||||
Property: hero.Property,
|
||||
}
|
||||
if monst.Equip4 != 0 {
|
||||
if suit, err := this.module.configure.Getequipsuit(monst.Equip4); err != nil {
|
||||
code = pb.ErrorCode_ConfigNoFound
|
||||
return
|
||||
} else {
|
||||
record.Buleflist[i].Team[i1].MainSuitSkill = suit.Skill
|
||||
}
|
||||
}
|
||||
if monst.Equip2 != 0 {
|
||||
if suit, err := this.module.configure.Getequipsuit(monst.Equip2); err != nil {
|
||||
code = pb.ErrorCode_ConfigNoFound
|
||||
return
|
||||
} else {
|
||||
record.Buleflist[i].Team[i1].SubSuitSkill = suit.Skill
|
||||
}
|
||||
}
|
||||
record.Buleflist[i].Team[i1].Property[comm.Hp] = int32(float32(record.Buleflist[i].Team[i1].Property[comm.Hp]) * mf.Hppro)
|
||||
record.Buleflist[i].Team[i1].Property[comm.Atk] = int32(float32(record.Buleflist[i].Team[i1].Property[comm.Atk]) * mf.Atkpro)
|
||||
record.Buleflist[i].Team[i1].Property[comm.Def] = int32(float32(record.Buleflist[i].Team[i1].Property[comm.Def]) * mf.Defpro)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
record.Redflist[i] = &pb.DBBattleFormt{
|
||||
Leadpos: captain,
|
||||
Team: masters,
|
||||
}
|
||||
}
|
||||
for i, v := range req.Buleformat {
|
||||
if captain, masters, code = this.createMasterRoles(i, v); code != pb.ErrorCode_Success {
|
||||
return
|
||||
}
|
||||
record.Buleflist[i] = &pb.DBBattleFormt{
|
||||
Leadpos: captain,
|
||||
Team: masters,
|
||||
}
|
||||
}
|
||||
return
|
||||
@ -184,63 +148,17 @@ func (this *modelBattleComp) createpve(session comm.IUserSession, conn *db.DBCon
|
||||
record.Redflist[0].Team[i].Ishelp = true
|
||||
}
|
||||
}
|
||||
|
||||
var (
|
||||
captain int32
|
||||
masters []*pb.BattleRole
|
||||
)
|
||||
for i, v := range req.Mformat {
|
||||
if mf, err := this.module.configure.GetMonsterFormat(v); err != nil {
|
||||
code = pb.ErrorCode_ConfigNoFound
|
||||
if captain, masters, code = this.createMasterRoles(i, v); code != pb.ErrorCode_Success {
|
||||
return
|
||||
} else {
|
||||
record.Buleflist[i] = &pb.DBBattleFormt{
|
||||
Leadpos: mf.CaptainId,
|
||||
Team: make([]*pb.BattleRole, len(mf.MonsterList)),
|
||||
}
|
||||
for i1, v1 := range mf.MonsterList {
|
||||
if v1 == -1 {
|
||||
record.Buleflist[i].Team[i1] = nil
|
||||
} else {
|
||||
if monst, err := this.module.configure.GetMonster(v1); err != nil {
|
||||
code = pb.ErrorCode_ConfigNoFound
|
||||
} else {
|
||||
hero := &pb.DBHero{}
|
||||
if hero = this.module.ModuleHero.CreateMonster(monst.HeroId, monst.Star, mf.Lv); hero == nil {
|
||||
log.Error("on found battle req data", log.Field{Key: "HeroId", Value: monst.HeroId})
|
||||
code = pb.ErrorCode_ReqParameterError
|
||||
return
|
||||
} else {
|
||||
record.Buleflist[i].Team[i1] = &pb.BattleRole{
|
||||
Tid: int32(200 + i*10 + i1),
|
||||
Oid: hero.Id,
|
||||
HeroID: hero.HeroID,
|
||||
Pos: int32(i1),
|
||||
Star: hero.Star,
|
||||
Lv: hero.Lv,
|
||||
CaptainSkill: hero.CaptainSkill,
|
||||
NormalSkill: hero.NormalSkill,
|
||||
Property: hero.Property,
|
||||
}
|
||||
if monst.Equip4 != 0 {
|
||||
if suit, err := this.module.configure.Getequipsuit(monst.Equip4); err != nil {
|
||||
code = pb.ErrorCode_ConfigNoFound
|
||||
return
|
||||
} else {
|
||||
record.Buleflist[i].Team[i1].MainSuitSkill = suit.Skill
|
||||
}
|
||||
}
|
||||
if monst.Equip2 != 0 {
|
||||
if suit, err := this.module.configure.Getequipsuit(monst.Equip2); err != nil {
|
||||
code = pb.ErrorCode_ConfigNoFound
|
||||
return
|
||||
} else {
|
||||
record.Buleflist[i].Team[i1].SubSuitSkill = suit.Skill
|
||||
}
|
||||
}
|
||||
record.Buleflist[i].Team[i1].Property[comm.Hp] = int32(float32(record.Buleflist[i].Team[i1].Property[comm.Hp]) * mf.Hppro)
|
||||
record.Buleflist[i].Team[i1].Property[comm.Atk] = int32(float32(record.Buleflist[i].Team[i1].Property[comm.Atk]) * mf.Atkpro)
|
||||
record.Buleflist[i].Team[i1].Property[comm.Def] = int32(float32(record.Buleflist[i].Team[i1].Property[comm.Def]) * mf.Defpro)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
record.Buleflist[i] = &pb.DBBattleFormt{
|
||||
Leadpos: captain,
|
||||
Team: masters,
|
||||
}
|
||||
}
|
||||
return
|
||||
@ -341,3 +259,65 @@ func (this *modelBattleComp) createBattleRole(hero *pb.DBHero, tid, pos int) (ro
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
//创建怪物阵营
|
||||
func (this *modelBattleComp) createMasterRoles(wheel int, fid int32) (captain int32, roles []*pb.BattleRole, code pb.ErrorCode) {
|
||||
var (
|
||||
result []*cfg.GameMonsterFormatData
|
||||
err error
|
||||
)
|
||||
if result, err = this.module.configure.GetMonsterFormat(fid); err != nil {
|
||||
code = pb.ErrorCode_ConfigNoFound
|
||||
return
|
||||
}
|
||||
roles = make([]*pb.BattleRole, len(result))
|
||||
for i, v := range result {
|
||||
if v != nil {
|
||||
if v.CaptainId == 1 {
|
||||
captain = int32(i)
|
||||
}
|
||||
if monst, err := this.module.configure.GetMonster(v.Monster); err != nil {
|
||||
code = pb.ErrorCode_ConfigNoFound
|
||||
} else {
|
||||
hero := &pb.DBHero{}
|
||||
if hero = this.module.ModuleHero.CreateMonster(monst.HeroId, monst.Star, v.Lv); hero == nil {
|
||||
this.module.Error("on found battle req data", log.Field{Key: "HeroId", Value: monst.HeroId})
|
||||
code = pb.ErrorCode_ReqParameterError
|
||||
return
|
||||
} else {
|
||||
roles[i] = &pb.BattleRole{
|
||||
Tid: int32(200 + wheel*10 + i),
|
||||
Oid: hero.Id,
|
||||
HeroID: hero.HeroID,
|
||||
Pos: int32(i),
|
||||
Star: hero.Star,
|
||||
Lv: hero.Lv,
|
||||
CaptainSkill: hero.CaptainSkill,
|
||||
NormalSkill: hero.NormalSkill,
|
||||
Property: hero.Property,
|
||||
}
|
||||
if monst.Equip4 != 0 {
|
||||
if suit, err := this.module.configure.Getequipsuit(monst.Equip4); err != nil {
|
||||
code = pb.ErrorCode_ConfigNoFound
|
||||
return
|
||||
} else {
|
||||
roles[i].MainSuitSkill = suit.Skill
|
||||
}
|
||||
}
|
||||
if monst.Equip2 != 0 {
|
||||
if suit, err := this.module.configure.Getequipsuit(monst.Equip2); err != nil {
|
||||
code = pb.ErrorCode_ConfigNoFound
|
||||
return
|
||||
} else {
|
||||
roles[i].SubSuitSkill = suit.Skill
|
||||
}
|
||||
}
|
||||
roles[i].Property[comm.Hp] = int32(float32(roles[i].Property[comm.Hp]) * v.Hppro)
|
||||
roles[i].Property[comm.Atk] = int32(float32(roles[i].Property[comm.Atk]) * v.Atkpro)
|
||||
roles[i].Property[comm.Def] = int32(float32(roles[i].Property[comm.Def]) * v.Defpro)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@ -72,6 +72,10 @@ func (this *Battle) QueryBattleRecord(oid string) (code pb.ErrorCode, record *pb
|
||||
return
|
||||
}
|
||||
|
||||
func (this *Battle) CreateMasterRoles(wheel int, fid int32) (captain int32, roles []*pb.BattleRole, code pb.ErrorCode) {
|
||||
return this.modelBattle.createMasterRoles(wheel, fid)
|
||||
}
|
||||
|
||||
//创建pve战斗
|
||||
func (this *Battle) CreateEveBattle(session comm.IUserSession, req *pb.BattleEVEReq) (code pb.ErrorCode, record *pb.DBBattleRecord) {
|
||||
var (
|
||||
|
@ -9,34 +9,26 @@
|
||||
package cfg
|
||||
|
||||
type GameMonsterFormat struct {
|
||||
_dataMap map[int32]*GameMonsterFormatData
|
||||
_dataList []*GameMonsterFormatData
|
||||
}
|
||||
|
||||
func NewGameMonsterFormat(_buf []map[string]interface{}) (*GameMonsterFormat, error) {
|
||||
_dataList := make([]*GameMonsterFormatData, 0, len(_buf))
|
||||
dataMap := make(map[int32]*GameMonsterFormatData)
|
||||
for _, _ele_ := range _buf {
|
||||
if _v, err2 := DeserializeGameMonsterFormatData(_ele_); err2 != nil {
|
||||
return nil, err2
|
||||
} else {
|
||||
_dataList = append(_dataList, _v)
|
||||
dataMap[_v.Id] = _v
|
||||
}
|
||||
}
|
||||
return &GameMonsterFormat{_dataList:_dataList, _dataMap:dataMap}, nil
|
||||
}
|
||||
|
||||
func (table *GameMonsterFormat) GetDataMap() map[int32]*GameMonsterFormatData {
|
||||
return table._dataMap
|
||||
return &GameMonsterFormat{_dataList:_dataList}, nil
|
||||
}
|
||||
|
||||
func (table *GameMonsterFormat) GetDataList() []*GameMonsterFormatData {
|
||||
return table._dataList
|
||||
}
|
||||
|
||||
func (table *GameMonsterFormat) Get(key int32) *GameMonsterFormatData {
|
||||
return table._dataMap[key]
|
||||
func (table *GameMonsterFormat) Get(index int) *GameMonsterFormatData {
|
||||
return table._dataList[index]
|
||||
}
|
||||
|
||||
|
||||
|
@ -12,12 +12,14 @@ import "errors"
|
||||
|
||||
type GameMonsterFormatData struct {
|
||||
Id int32
|
||||
Pos int32
|
||||
CaptainId int32
|
||||
MonsterList []int32
|
||||
Monster int32
|
||||
Lv int32
|
||||
Hppro float32
|
||||
Atkpro float32
|
||||
Defpro float32
|
||||
Modelsize float32
|
||||
}
|
||||
|
||||
const TypeId_GameMonsterFormatData = 1141351615
|
||||
@ -28,25 +30,14 @@ func (*GameMonsterFormatData) GetTypeId() int32 {
|
||||
|
||||
func (_v *GameMonsterFormatData)Deserialize(_buf map[string]interface{}) (err error) {
|
||||
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["Id"].(float64); !_ok_ { err = errors.New("Id error"); return }; _v.Id = int32(_tempNum_) }
|
||||
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["pos"].(float64); !_ok_ { err = errors.New("pos error"); return }; _v.Pos = int32(_tempNum_) }
|
||||
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["captainId"].(float64); !_ok_ { err = errors.New("captainId error"); return }; _v.CaptainId = int32(_tempNum_) }
|
||||
{
|
||||
var _arr_ []interface{}
|
||||
var _ok_ bool
|
||||
if _arr_, _ok_ = _buf["monsterList"].([]interface{}); !_ok_ { err = errors.New("monsterList error"); return }
|
||||
|
||||
_v.MonsterList = make([]int32, 0, len(_arr_))
|
||||
|
||||
for _, _e_ := range _arr_ {
|
||||
var _list_v_ int32
|
||||
{ var _ok_ bool; var _x_ float64; if _x_, _ok_ = _e_.(float64); !_ok_ { err = errors.New("_list_v_ error"); return }; _list_v_ = int32(_x_) }
|
||||
_v.MonsterList = append(_v.MonsterList, _list_v_)
|
||||
}
|
||||
}
|
||||
|
||||
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["monster"].(float64); !_ok_ { err = errors.New("monster error"); return }; _v.Monster = int32(_tempNum_) }
|
||||
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["lv"].(float64); !_ok_ { err = errors.New("lv error"); return }; _v.Lv = int32(_tempNum_) }
|
||||
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["hppro"].(float64); !_ok_ { err = errors.New("hppro error"); return }; _v.Hppro = float32(_tempNum_) }
|
||||
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["atkpro"].(float64); !_ok_ { err = errors.New("atkpro error"); return }; _v.Atkpro = float32(_tempNum_) }
|
||||
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["defpro"].(float64); !_ok_ { err = errors.New("defpro error"); return }; _v.Defpro = float32(_tempNum_) }
|
||||
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["modelsize"].(float64); !_ok_ { err = errors.New("modelsize error"); return }; _v.Modelsize = float32(_tempNum_) }
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,10 @@ type GameMonsterData struct {
|
||||
Star int32
|
||||
Equip2 int32
|
||||
Equip4 int32
|
||||
Skill1 int32
|
||||
Skill2 int32
|
||||
Skill3 int32
|
||||
Speed int32
|
||||
}
|
||||
|
||||
const TypeId_GameMonsterData = 31965864
|
||||
@ -32,6 +36,10 @@ func (_v *GameMonsterData)Deserialize(_buf map[string]interface{}) (err error) {
|
||||
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["star"].(float64); !_ok_ { err = errors.New("star error"); return }; _v.Star = int32(_tempNum_) }
|
||||
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["equip2"].(float64); !_ok_ { err = errors.New("equip2 error"); return }; _v.Equip2 = int32(_tempNum_) }
|
||||
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["equip4"].(float64); !_ok_ { err = errors.New("equip4 error"); return }; _v.Equip4 = int32(_tempNum_) }
|
||||
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["skill1"].(float64); !_ok_ { err = errors.New("skill1 error"); return }; _v.Skill1 = int32(_tempNum_) }
|
||||
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["skill2"].(float64); !_ok_ { err = errors.New("skill2 error"); return }; _v.Skill2 = int32(_tempNum_) }
|
||||
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["skill3"].(float64); !_ok_ { err = errors.New("skill3 error"); return }; _v.Skill3 = int32(_tempNum_) }
|
||||
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["speed"].(float64); !_ok_ { err = errors.New("speed error"); return }; _v.Speed = int32(_tempNum_) }
|
||||
return
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user