diff --git a/comm/const.go b/comm/const.go
index 59f46eff6..8c3dd88a3 100644
--- a/comm/const.go
+++ b/comm/const.go
@@ -131,8 +131,8 @@ const (
TableVikingRankList = "vikingranklist"
//月之秘境
- TableMoonfantasy = "moonfantasy"
-
+ TableMoonFantasy = "moonfantasy"
+ TableUserMFantasy = "usermfantasy"
//
TableHunting = "hunting"
// 维京远征排行榜
diff --git a/modules/battle/configure.go b/modules/battle/configure.go
index f7a8c0f06..c678e4501 100644
--- a/modules/battle/configure.go
+++ b/modules/battle/configure.go
@@ -4,19 +4,27 @@ import (
"fmt"
"go_dreamfactory/lego/core"
"go_dreamfactory/modules"
+ "go_dreamfactory/sys/configure"
cfg "go_dreamfactory/sys/configure/structs"
+ "sync"
)
const (
game_equipsuit = "game_equipsuit.json" //套装技能表
game_monsterformat = "game_monsterformat.json" //整容表
game_monster = "game_monster.json" //怪物表
+ game_skillatk = "game_skillatk" //主技能表
+ game_skillafteratk = "game_skillafteratk" //子技能表
+ game_skillbuff = "game_skillbuff" //技能buff表
+ game_skillpassive = "game_skillpassive" //被动技能表
)
///背包配置管理组件
type configureComp struct {
modules.MCompConfigure
- module *Battle
+ module *Battle
+ skillatklock sync.RWMutex
+ skillatk map[int32]map[int32]*cfg.GameSkillAtkData //主动技能表
}
//组件初始化接口
@@ -26,6 +34,25 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp
this.LoadConfigure(game_equipsuit, cfg.NewGameEquipSuit)
this.LoadConfigure(game_monster, cfg.NewGameMonster)
this.LoadConfigure(game_monsterformat, cfg.NewGameMonsterFormat)
+ configure.RegisterConfigure(game_skillatk, cfg.NewGameSkillAtk, func() {
+ this.skillatklock.Lock()
+ if v, err := this.GetConfigure(game_skillatk); err != nil {
+ this.module.Errorf("err:%v", err)
+ return
+ } else {
+ this.skillatk = make(map[int32]map[int32]*cfg.GameSkillAtkData)
+ for _, v := range v.(*cfg.GameSkillAtk).GetDataList() {
+ if this.skillatk[v.Id] == nil {
+ this.skillatk[v.Id] = make(map[int32]*cfg.GameSkillAtkData)
+ }
+ this.skillatk[v.Id][v.Level] = v
+ }
+ }
+ this.skillatklock.Unlock()
+ })
+ this.LoadConfigure(game_skillafteratk, cfg.NewGameSkillAfteratk)
+ this.LoadConfigure(game_skillbuff, cfg.NewGameSkillBuff)
+ this.LoadConfigure(game_skillpassive, cfg.NewGameSkillPassive)
return
}
@@ -79,3 +106,66 @@ func (this *configureComp) Getequipsuit(id int32) (result *cfg.GameEquipSuitData
}
return
}
+
+///获取主动技能配置表
+func (this *configureComp) GetSkillAtk(skillId int32, skillLv int32) (result *cfg.GameSkillAtkData, err error) {
+ if skills, ok := this.skillatk[skillId]; ok {
+ if result, ok = skills[skillLv]; ok {
+ return
+ }
+ }
+ err = fmt.Errorf("no found SkillAtk skillId:%d skillLv%d", skillId, skillLv)
+ this.module.Error(err.Error())
+ return
+}
+
+//获取子技能配置表
+func (this *configureComp) GetSkillAfteratk(skillId int32) (result *cfg.GameSkillAfteratkData, err error) {
+ var (
+ v interface{}
+ ok bool
+ )
+ if v, err = this.GetConfigure(game_skillafteratk); err != nil {
+ this.module.Errorln(err)
+ } else {
+ if result, ok = v.(*cfg.GameSkillAfteratk).GetDataMap()[skillId]; !ok {
+ err = fmt.Errorf("on found SkillAfteratk skillId:%d", skillId)
+ this.module.Error(err.Error())
+ }
+ }
+ return
+}
+
+//获取buff表
+func (this *configureComp) GetSkillBuff(skillId int32) (result *cfg.GameSkillBuffData, err error) {
+ var (
+ v interface{}
+ ok bool
+ )
+ if v, err = this.GetConfigure(game_skillbuff); err != nil {
+ this.module.Errorln(err)
+ } else {
+ if result, ok = v.(*cfg.GameSkillBuff).GetDataMap()[skillId]; !ok {
+ err = fmt.Errorf("on found SkillAfteratk skillId:%d", skillId)
+ this.module.Error(err.Error())
+ }
+ }
+ return
+}
+
+//获取被动技能表
+func (this *configureComp) GetSkillPassive(skillId int32) (result *cfg.GameSkillPassiveData, err error) {
+ var (
+ v interface{}
+ ok bool
+ )
+ if v, err = this.GetConfigure(game_skillpassive); err != nil {
+ this.module.Errorln(err)
+ } else {
+ if result, ok = v.(*cfg.GameSkillPassive).GetDataMap()[skillId]; !ok {
+ err = fmt.Errorf("on found SkillAfteratk skillId:%d", skillId)
+ this.module.Error(err.Error())
+ }
+ }
+ return
+}
diff --git a/modules/battle/fight/attribute/attributenumeric.go b/modules/battle/fight/attribute/attributenumeric.go
deleted file mode 100644
index c5425bbd9..000000000
--- a/modules/battle/fight/attribute/attributenumeric.go
+++ /dev/null
@@ -1,141 +0,0 @@
-package attribute
-
-func NewAttributeNumeric(pData float32) *AttributeNumeric {
- attribute := &AttributeNumeric{
- BaseValue: NewFixedNumeric(pData),
- ProValue: NewFixedNumeric(pData),
- AppendValue: NewFixedNumeric(pData),
- BuffProValue: NewFixedNumeric(pData),
- BuffValue: NewFixedNumeric(pData),
- }
-
- attribute.SetBase(pData)
- return attribute
-}
-
-///
-/// 属性数值
-///
-type AttributeNumeric struct {
- fixedValue FixedPoint
- ///
- /// 基础数值
- ///
- BaseValue FixedNumeric
- ///
- /// 附加数值
- ///
- AppendValue FixedNumeric
- ///
- /// 附加百分比数值
- ///
- ProValue FixedNumeric
- ///
- /// Buff附加数值
- ///
- BuffValue FixedNumeric
- ///
- /// Buff附加百分比数值
- ///
- BuffProValue FixedNumeric
-}
-
-func (this *AttributeNumeric) Fixed() FixedPoint {
- return this.fixedValue
-}
-func (this *AttributeNumeric) Value() float32 {
- return this.fixedValue.Scalar()
-}
-
-///基础数值
-func (this *AttributeNumeric) SetBase(value float32) float32 {
- this.BaseValue.SetFloat(value)
- this.OnChange()
- return this.BaseValue.Value()
-}
-
-func (this *AttributeNumeric) AddBase(value float32) float32 {
- this.BaseValue.Add(value)
- this.OnChange()
- return this.BaseValue.Value()
-}
-
-func (this *AttributeNumeric) MinusBase(value float32) float32 {
- this.BaseValue.Minus(value)
- this.OnChange()
- return this.BaseValue.Value()
-}
-
-///附加数值
-func (this *AttributeNumeric) SetAppend(value float32) float32 {
- this.AppendValue.SetFloat(value)
- this.OnChange()
- return this.AppendValue.Value()
-}
-
-func (this *AttributeNumeric) AddAppend(value float32) float32 {
- this.AppendValue.Add(value)
- this.OnChange()
- return this.AppendValue.Value()
-}
-
-func (this *AttributeNumeric) MinusAppend(value float32) float32 {
- this.AppendValue.Minus(value)
- this.OnChange()
- return this.AppendValue.Value()
-}
-
-///附加百分比数值
-func (this *AttributeNumeric) SetPro(value float32) float32 {
- this.ProValue.SetFloat(value)
- this.OnChange()
- return this.ProValue.Value()
-}
-func (this *AttributeNumeric) AddPro(value float32) float32 {
- this.ProValue.Add(value)
- this.OnChange()
- return this.ProValue.Value()
-}
-func (this *AttributeNumeric) MinusPro(value float32) float32 {
- this.ProValue.Minus(value)
- this.OnChange()
- return this.ProValue.Value()
-}
-
-/// Buff附加数值
-func (this *AttributeNumeric) SetBuff(value float32) float32 {
- this.BuffValue.SetFloat(value)
- this.OnChange()
- return this.BuffValue.Value()
-}
-func (this *AttributeNumeric) AddBuff(value float32) float32 {
- this.BuffValue.Add(value)
- this.OnChange()
- return this.BuffValue.Value()
-}
-func (this *AttributeNumeric) MinusBuff(value float32) float32 {
- this.BuffValue.Minus(value)
- this.OnChange()
- return this.BuffValue.Value()
-}
-
-/// Buff附加百分比数值
-func (this *AttributeNumeric) SetBuffPro(value float32) float32 {
- this.BuffProValue.SetFloat(value)
- this.OnChange()
- return this.BuffProValue.Value()
-}
-func (this *AttributeNumeric) AddBuffPro(value float32) float32 {
- this.BuffProValue.Add(value)
- this.OnChange()
- return this.BuffProValue.Value()
-}
-func (this *AttributeNumeric) MinusBuffPro(value float32) float32 {
- this.BuffProValue.Minus(value)
- this.OnChange()
- return this.BuffProValue.Value()
-}
-
-func (this *AttributeNumeric) OnChange() {
- this.fixedValue = (FixedPoint_Multiply(this.BaseValue.Fixed(), (NewFixedPoint(1)+this.ProValue.Fixed())) + FixedPoint_Multiply(this.AppendValue.Fixed(), (NewFixedPoint(1)+this.BuffProValue.Fixed())) + this.BuffValue.Fixed())
-}
diff --git a/modules/battle/fight/attribute/fixednumeric.go b/modules/battle/fight/attribute/fixednumeric.go
deleted file mode 100644
index af7ba0cce..000000000
--- a/modules/battle/fight/attribute/fixednumeric.go
+++ /dev/null
@@ -1,58 +0,0 @@
-package attribute
-
-func NewFixedNumeric(pData float32) FixedNumeric {
- fixed := FixedNumeric{}
- fixed.SetFloat(pData)
- return fixed
-}
-
-///
-/// 浮点型数值
-///
-type FixedNumeric struct {
- baseValue FixedPoint
-}
-
-func (this FixedNumeric) Fixed() FixedPoint {
- return this.baseValue
-}
-
-func (this FixedNumeric) Value() float32 {
- return this.baseValue.Scalar()
-}
-
-func (this FixedNumeric) GetValue(pDefault float32) float32 {
- if this.Value() != 0 {
- return this.Value()
- } else {
- return pDefault
- }
-}
-func (this FixedNumeric) SetFloat(value float32) float32 {
- this.baseValue = NewFixedPoint(value)
- return this.baseValue.Scalar()
-}
-
-func (this FixedNumeric) Set(value FixedPoint) float32 {
- this.baseValue = value
- return this.baseValue.Scalar()
-}
-
-///
-/// 增加基本值
-///
-func (this FixedNumeric) Add(value float32) float32 {
- this.baseValue.Add(value)
- return this.baseValue.Scalar()
-}
-
-///
-/// 减少基本值
-///
-func (this FixedNumeric) Minus(value float32) float32 {
- this.baseValue.Reduce(value)
- if this.baseValue.Scalar() < 0 {
- this.baseValue.SetInt(0)
- }
- return this.baseValue.Scalar()
-}
diff --git a/modules/battle/fight/attribute/fixedpoint.go b/modules/battle/fight/attribute/fixedpoint.go
deleted file mode 100644
index 1d9da5b17..000000000
--- a/modules/battle/fight/attribute/fixedpoint.go
+++ /dev/null
@@ -1,65 +0,0 @@
-package attribute
-
-import (
- "fmt"
- "math"
-)
-
-//基准倍数
-const CARDINAL_NUMBER int = 10000
-
-func NewFixedPoint(value float32) FixedPoint {
- return FixedPoint(math.Round(float64(value * float32(CARDINAL_NUMBER))))
-}
-
-type FixedPoint int
-
-func (this FixedPoint) SetInt(v int) {
- this = FixedPoint(v)
-}
-
-func (this FixedPoint) Scalar() float32 {
- return float32(this) * 0.0001
-}
-
-func (this FixedPoint) ToInt() int {
- return int(this) / CARDINAL_NUMBER
-}
-func (this FixedPoint) ToFloat() float32 {
- return this.Scalar()
-}
-func (this FixedPoint) ToString() string {
- return fmt.Sprintf("%f", this.Scalar())
-}
-
-/// -
-func (this FixedPoint) Add(v float32) {
- y := NewFixedPoint(v)
- this = FixedPoint(int(this) + int(y))
-}
-
-/// -
-func (this FixedPoint) Reduce(v float32) {
- y := NewFixedPoint(v)
- this = FixedPoint(int(this) - int(y))
-}
-
-/// +
-func FixedPoint_Add(x, y FixedPoint) FixedPoint {
- return FixedPoint(x + y)
-}
-
-/// -
-func FixedPoint_Reduce(x, y FixedPoint) FixedPoint {
- return FixedPoint(x - y)
-}
-
-/// *
-func FixedPoint_Multiply(x, y FixedPoint) FixedPoint {
- return FixedPoint((int(x) * int(y)) / CARDINAL_NUMBER)
-}
-
-/// /
-func FixedPoint_Divide(x, y FixedPoint) FixedPoint {
- return FixedPoint((int(x) * CARDINAL_NUMBER) / int(y))
-}
diff --git a/modules/battle/fight/attribute/healthpoint.go b/modules/battle/fight/attribute/healthpoint.go
deleted file mode 100644
index c9fcb237b..000000000
--- a/modules/battle/fight/attribute/healthpoint.go
+++ /dev/null
@@ -1,127 +0,0 @@
-package attribute
-
-func NewHealthPoint(pHp *FixedNumeric) *HealthPoint {
- return &HealthPoint{
- Hp: pHp,
- MaxHp: NewAttributeNumeric(pHp.Value()),
- CurrMaxHp: NewAttributeNumeric(pHp.Value()),
- CurrMaxHpPro: NewAttributeNumeric(0),
- CurrMaxHpAppend: NewAttributeNumeric(0),
- }
-}
-
-///
-/// 生命值实体
-///
-type HealthPoint struct {
- ///
- /// 生命值
- ///
- Hp *FixedNumeric
- ///
- /// 最大生命值
- ///
- MaxHp *AttributeNumeric
- ///
- /// 当前最大生命值
- ///
- CurrMaxHp *AttributeNumeric
- ///
- /// 当前最大生命百分比加成
- ///
- CurrMaxHpPro *AttributeNumeric
- ///
- /// 当前最大生命加成
- ///
- CurrMaxHpAppend *AttributeNumeric
-}
-
-func (this *HealthPoint) Value() int32 {
- return int32(this.Hp.Value())
-}
-func (this *HealthPoint) MaxValue() int32 {
- return int32(this.CurrMaxHp.Value())
-}
-
-func (this *HealthPoint) OnChange() {
- //先计算当前血量百分比
- var per = this.Percent()
- // 当前最大生命值 = 总生命 * ( 1 + 当前最大生命百分比加成 )+ 当前最大生命加成
- //FightDebug.Log($"增加前属性{(MaxHp.Fixed)}----- {(1 + CurrMaxHpPro.Fixed)}----- {CurrMaxHpAppend.Fixed}");
- this.CurrMaxHp.SetBase((FixedPoint_Multiply(this.MaxHp.Fixed(), (NewFixedPoint(1)+this.CurrMaxHpPro.Fixed())) + this.CurrMaxHpAppend.Fixed()).Scalar())
- //计算变化之后的当前血量
- var curHp = FixedPoint_Multiply(this.CurrMaxHp.Fixed(), NewFixedPoint(per))
- this.Hp.Set(curHp)
- //FightDebug.Log($"增加后属性{(MaxHp.Fixed)}----- {(1 + CurrMaxHpPro.Fixed)}----- {CurrMaxHpAppend.Fixed}");
-}
-
-///
-/// 重置当前生命值为最大值
-///
-func (this *HealthPoint) Reset() {
- this.Hp.SetFloat(this.CurrMaxHp.Value())
-}
-
-///
-/// 扣血
-///
-///
-func (this *HealthPoint) Minus(value float32) {
- this.Hp.Minus(value)
-}
-
-///
-/// 加血
-///
-func (this *HealthPoint) Add(value float32) {
- if FixedPoint_Add(this.Hp.Fixed(), NewFixedPoint(value)) > this.CurrMaxHp.Fixed() {
- this.Reset()
- } else {
- this.Hp.Add(value)
- }
-}
-
-///
-/// 获取治疗溢出值
-///
-func (this *HealthPoint) Overflow(value float32) float32 {
- if FixedPoint_Add(this.Hp.Fixed(), NewFixedPoint(value)) > this.CurrMaxHp.Fixed() {
- return FixedPoint_Divide(FixedPoint_Add(this.Hp.Fixed(), NewFixedPoint(value)), this.CurrMaxHp.Fixed()).Scalar()
- }
- return 0
-}
-
-///
-/// 剩余血量百分比
-///
-func (this *HealthPoint) Percent() float32 {
- return FixedPoint_Divide(this.Hp.Fixed(), this.CurrMaxHp.Fixed()).Scalar()
-}
-
-///
-/// 损失血量百分比
-///
-func (this *HealthPoint) LostPercent() float32 {
- return FixedPoint_Divide((this.CurrMaxHp.Fixed() - this.Hp.Fixed()), this.CurrMaxHp.Fixed()).Scalar()
-}
-
-///
-/// 指定百分比血量
-///
-func (this *HealthPoint) PercentHealth(pct float32) float32 {
- return FixedPoint_Multiply(this.CurrMaxHp.Fixed(), NewFixedPoint(pct)).Scalar()
-}
-
-///
-/// 扣除的血量
-///
-func (this *HealthPoint) Deduct() float32 {
- return FixedPoint(this.CurrMaxHp.Fixed() - this.Hp.Fixed()).Scalar()
-}
-
-///
-/// 是否满血
-///
-func (this *HealthPoint) IsFull() bool {
- return this.Hp.Fixed() == this.CurrMaxHp.Fixed()
-}
diff --git a/modules/battle/fight/buff/buffbase.go b/modules/battle/fight/buff/buffbase.go
new file mode 100644
index 000000000..ba3d76a6b
--- /dev/null
+++ b/modules/battle/fight/buff/buffbase.go
@@ -0,0 +1,5 @@
+package buff
+
+//基础buff
+type BuffBase struct {
+}
diff --git a/modules/battle/fight/buff/fightbuff.go b/modules/battle/fight/buff/fightbuff.go
deleted file mode 100644
index 27ca656b3..000000000
--- a/modules/battle/fight/buff/fightbuff.go
+++ /dev/null
@@ -1,73 +0,0 @@
-package buff
-
-import (
- "go_dreamfactory/modules/battle/fight/core"
- cfg "go_dreamfactory/sys/configure/structs"
-)
-
-var id int64 = 0
-
-func NewFightBuff() *FightBuff {
- id++
- return &FightBuff{
- GId: id,
- }
-}
-
-type FightBuff struct {
- FightBuffBase
- BuffConf *cfg.GameSkillBuffData
- GId int64
-}
-
-func (this FightBuff) GetBuffConf() *cfg.GameSkillBuffData {
- return this.BuffConf
-}
-
-func (this FightBuff) Activate(param float32) {
- this.FightBuffBase.Activate(param)
-}
-
-func (this FightBuff) OnEnd(skill core.IAfterSkill) {
- this.FromRole.GetFightBase().Debugf("%d 准备移除Buff:%d 类型=%d ", this.OwnerRole.GetData().UniqueId, this.BuffConf.Id, this.BuffConf.BuffType)
- if this.BuffConf.BuffIcon != "" {
- var com = new(core.ComMondifyBuff)
- com.To = this.OwnerRole.GetData().Rid
- com.Gid = this.GId
- com.BuffId = this.BuffConf.Id
- com.Operate = 0
- if skill != nil {
- skill.AddLog(com)
- } else {
- this.OwnerRole.GetFightBase().GetFightLog().AddCommand(com)
- }
- if this.NeedHpSync() {
- var hpCmd = new(core.ComModifyHealth)
- hpCmd.To = this.OwnerRole.GetData().Rid
- hpCmd.Nhp = this.OwnerRole.GetCurrentHealth().Value()
- hpCmd.Mhp = this.OwnerRole.GetCurrentHealth().MaxValue()
- hpCmd.HideDmg = true
- if skill != nil {
- skill.AddLog(hpCmd)
- } else {
- this.OwnerRole.GetFightBase().GetFightLog().AddCommand(hpCmd)
- }
- }
- }
- this.OwnerRole.GetData().BuffStore.RemoveBuff(this)
-}
-
-///
-/// 当前buff效果是否需要同步血量
-///
-///
-func (this FightBuff) NeedHpSync() bool {
- return false
-}
-
-///
-/// 回合开始开始需要触发效果的
-///
-func (this FightBuff) OnRoundStart() {
-
-}
diff --git a/modules/battle/fight/buff/fightbuffbase.go b/modules/battle/fight/buff/fightbuffbase.go
deleted file mode 100644
index 20483f2b6..000000000
--- a/modules/battle/fight/buff/fightbuffbase.go
+++ /dev/null
@@ -1,125 +0,0 @@
-package buff
-
-import "go_dreamfactory/modules/battle/fight/core"
-
-type FightBuffBase struct {
- ///
- /// 所属子技能ID
- ///
- AfterSkillId int
- ///
- /// Buff投放者
- ///
- FromRole core.IFightRole
- ///
- /// Buff持有者
- ///
- OwnerRole core.IFightRole
- ///
- /// 剩余持续回合数
- ///
- duration int
- ///
- /// 叠加层数 [叠加Buff不立即叠加效果, 受BufParNum影响]
- ///
- OverlapNum int
- ///
- /// 叠加Buff当前效果次数
- ///
- EffectNum int
- ///
- /// 是否无限回合
- ///
- AlwaysExist bool
- BufParNum int
-}
-
-///
-/// cd 回合数
-///
-///
-/// -1 无限回合,0 回合结束后移除
-///
-func (this FightBuffBase) GetRound() int {
- return this.duration
-}
-
-///
-/// cd 回合数
-///
-///
-/// -1 无限回合,0 回合结束后移除
-///
-func (this FightBuffBase) SetRound(value int) {
- this.AlwaysExist = value == -1
- this.duration = value
-}
-
-/// 激活Buff
-func (this FightBuffBase) Activate(param float32) {
- this.Restore()
- this.EffectNum = this.OverlapNum / this.BufParNum
- this.OnActivate(param)
-}
-
-func (this FightBuffBase) OnActivate(param float32) {
-
-}
-
-/// 结束Buff
-func (this FightBuffBase) Restore() {
-
-}
-func (this FightBuffBase) OnEnd(skill core.IAfterSkill) {
-
-}
-
-///
-/// 结束Buff
-///
-func (this FightBuffBase) End(skill core.IAfterSkill) {
- this.Restore()
- this.OnEnd(skill)
- this.Clear()
-}
-
-/// 战斗结束时的清理
-func (this FightBuffBase) Clear() {
-
-}
-
-//CD 处理--------------------------------------------------------------------------------------------------------------------
-
-///
-/// 增加剩余回合数 v 默认:1
-///
-/// 新的回合数
-func (this FightBuffBase) AddDuration(v int) int {
- this.duration += v
- return this.duration
-}
-
-///
-/// 减少剩余回合数 v 默认:1
-///
-/// 新的回合数
-func (this FightBuffBase) MinusDuration(v int) int {
- this.duration -= v
- if this.duration < 0 {
- this.duration = 0
- }
- this.SetDuration(this.duration)
- return this.duration
-}
-
-///
-/// 设置剩余回合数为新的值
-///
-///
-func (this FightBuffBase) SetDuration(newVal int) int {
- this.duration = newVal
- if this.duration == 0 && !this.AlwaysExist {
- this.End(nil)
- }
- return this.duration
-}
diff --git a/modules/battle/fight/buff/fightpoisonbuff.go b/modules/battle/fight/buff/fightpoisonbuff.go
deleted file mode 100644
index 0df8e3b6d..000000000
--- a/modules/battle/fight/buff/fightpoisonbuff.go
+++ /dev/null
@@ -1,25 +0,0 @@
-package buff
-
-import "go_dreamfactory/modules/battle/fight/core"
-
-func NewFightPoisonBuff() *FightPoisonBuff {
- return &FightPoisonBuff{}
-}
-
-type FightPoisonBuff struct {
- FightBuff
-}
-
-func (this FightPoisonBuff) OnRoundStart() {
- this.FromRole.GetFightBase().Debugf("{%d}中毒buff触发", this.OwnerRole.GetData().Rid)
- num := this.OwnerRole.GetCurrentHealth().CurrMaxHp.Value() * (float32(this.BuffConf.EffectArgu[0]) / 1000.0)
- this.OwnerRole.ReceiveDamage(this.FromRole, num, nil)
- var com = new(core.ComModifyHealth)
- com.From = this.FromRole.GetData().Rid
- com.To = this.OwnerRole.GetData().Rid
- com.Num = num * -1
- com.Nhp = this.OwnerRole.GetCurrentHealth().Value()
- com.Mhp = this.OwnerRole.GetCurrentHealth().MaxValue()
- com.Baoji = false
- this.OwnerRole.GetFightBase().GetFightLog().AddCommand(com)
-}
diff --git a/modules/battle/fight/buff/fightpropercentbuff.go b/modules/battle/fight/buff/fightpropercentbuff.go
deleted file mode 100644
index accdae1d9..000000000
--- a/modules/battle/fight/buff/fightpropercentbuff.go
+++ /dev/null
@@ -1,46 +0,0 @@
-package buff
-
-import (
- "go_dreamfactory/modules/battle/fight/core"
-)
-
-func NewFightProPercentBuff(proType int, quaType bool) *FightProPercentBuff {
- return &FightProPercentBuff{}
-}
-
-///
-/// 修改属性buff (百分比数值)
-///
- /// 属性类型
- ///
- ProType int
- ///
- /// 是否减法
- ///
- BufQuaType bool
- BuffValue float32
-}
-
-func (this FightProPercentBuff) OnActivate(param float32) {
- var effectArgu = this.BuffConf.EffectArgu
- if len(effectArgu) < 1 { // 参数列属性值
- this.FromRole.GetFightBase().Errorf("buff效果参数配置错误 ID={%d},参数[ 属性值]", this.BuffConf.Id)
- return
- }
- value := effectArgu[0]
- perc := float32(value) / 1000.0
- this.BuffValue = perc * float32(this.EffectNum)
- core.TrySetValue(this.OwnerRole, this.ProType, this.BuffValue, !this.BufQuaType)
-}
-
-func (this FightProPercentBuff) Restore() {
- core.TrySetValue(this.OwnerRole, this.ProType, this.BuffValue, this.BufQuaType)
- this.BuffValue = 0
-}
-
-func (this FightProPercentBuff) NeedHpSync() bool {
- return this.ProType == int(core.PropertyType_Add_Per_Hp) || this.ProType == int(core.PropertyType_Add_Hp)
-}
diff --git a/modules/battle/fight/buff/fightshieldbuff.go b/modules/battle/fight/buff/fightshieldbuff.go
deleted file mode 100644
index 3326b78c3..000000000
--- a/modules/battle/fight/buff/fightshieldbuff.go
+++ /dev/null
@@ -1,43 +0,0 @@
-package buff
-
-import (
- "go_dreamfactory/modules/battle/fight/attribute"
- "go_dreamfactory/modules/battle/fight/core"
-)
-
-func NewFightShieldBuff() *FightShieldBuff {
- return &FightShieldBuff{}
-}
-
-type FightShieldBuff struct {
- FightBuff
- ShieldValue attribute.FixedNumeric
- tmepDamage attribute.FixedNumeric
-}
-
-func (this FightShieldBuff) OnActivate(param float32) {
- var val float32 = 0
- if param > 0 {
- val = param
- } else {
- args := this.BuffConf.EffectArgu
- var pValue float32 = 0
- for i := 0; i < len(args); i += 3 {
- source := args[i] //[属性来源]
- proType := args[i+1] //[属性类型]
- proValue := args[i+2] //[属性值]
- var target core.IFightRole
- if source == 1 {
- target = this.OwnerRole
- } else {
- target = this.FromRole
- }
- // var target = source == 1 ? OwnerRole : FromRole; // 1 取自身属性 2 取目标属性
- if !core.TryGetValue(target, int(proType), &pValue) {
- continue
- }
- val += pValue * float32(proValue) / 1000.0
- }
- }
- this.ShieldValue.Add(val)
-}
diff --git a/modules/battle/fight/component/buffstore.go b/modules/battle/fight/component/buffstore.go
deleted file mode 100644
index 389697962..000000000
--- a/modules/battle/fight/component/buffstore.go
+++ /dev/null
@@ -1,224 +0,0 @@
-package component
-
-import (
- "go_dreamfactory/modules/battle/fight/buff"
- "go_dreamfactory/modules/battle/fight/core"
-)
-
-type BuffStore struct {
- ///
- /// 已经添加的buff类型
- ///
- HasBuffTypes []int
- ///
- /// Buff列表 [BuffId, FightBuff]
- ///
- Buffs map[int][]core.IBuff
- temp []int
-}
-
-///
-/// 查找相同 BuffId 的Buff
-///
-func (this *BuffStore) GetBuffList(pBuffId int) []core.IBuff {
- if v, ok := this.Buffs[pBuffId]; ok {
- return v
- }
- return nil
-}
-
-func (this *BuffStore) TryGetBuffList(pBuffId int, pBuffList *[]core.IBuff) bool {
- if v, ok := this.Buffs[pBuffId]; ok {
- *pBuffList = v
- return true
- }
- *pBuffList = nil
- return false
-}
-
-///
-/// 查找不是指定 BuffId 的Buff
-///
-func (this *BuffStore) GetBuffListNon(pBuffId int) []core.IBuff {
- tResult := make([]core.IBuff, 0)
- iskeep := false
- for k, v := range this.Buffs {
- if k != pBuffId {
- for _, v1 := range v {
- iskeep = false
- for _, v2 := range tResult {
- if v1 == v2 {
- iskeep = true
- }
- }
- if !iskeep {
- tResult = append(tResult, v1)
- }
- }
- }
- }
- return tResult
-}
-
-/// 获取指定buff列表
-func (this *BuffStore) GetBuffListByFilter(filter func(buff core.IBuff) bool) []core.IBuff {
- tResult := make([]core.IBuff, 0)
- iskeep := false
- this.ForEach(func(buff core.IBuff) {
- if filter(buff) {
- iskeep = false
- for _, v2 := range tResult {
- if buff == v2 {
- iskeep = true
- }
- }
- if !iskeep {
- tResult = append(tResult, buff)
- }
- }
- })
- return tResult
-}
-
-func (this *BuffStore) GetBuffListByTypes(pType []core.BuffType) []core.IBuff {
- tResult := make([]core.IBuff, 0)
- iskeep := false
- this.ForEach(func(buff core.IBuff) {
- for _, tTag := range pType {
- if buff.GetBuffConf().BuffType == int32(tTag) {
- iskeep = false
- for _, v2 := range tResult {
- if buff == v2 {
- iskeep = true
- }
- }
- if !iskeep {
- tResult = append(tResult, buff)
- }
- break
- }
- }
- })
- return tResult
-}
-
-func (this *BuffStore) ForEach(action func(core.IBuff)) {
- this.temp = this.temp[:0]
- for k, _ := range this.Buffs {
- this.temp = append(this.temp, k)
- }
- for _, v := range this.temp {
- list := this.Buffs[v]
- for _, v1 := range list {
- action(v1)
- }
- }
-}
-
-///
-/// 附加Buff
-/// 默认参数 param=0;shift=false
-///
-func (this *BuffStore) Attach(pSkill core.IAfterSkill, id int, randVal int, numVal int, round int, param float32, shift bool) bool {
-
- return true
-}
-
-func (this *BuffStore) HasBuff(judge func(core.IBuff) bool) bool {
- for _, v := range this.Buffs {
- for _, buff := range v {
- if judge(buff) {
- return true
- }
- }
- }
- return false
-}
-
-func (this *BuffStore) Clear() {
- this.Buffs = make(map[int][]core.IBuff)
-}
-
-func (this *BuffStore) CreateBuff(pType core.BuffType) core.IBuff {
- switch pType {
- case core.BuffType_NONE:
- break
- case core.BuffType_ATKUP:
- return buff.NewFightProPercentBuff(int(core.PropertyType_Buff_Per_Atk), false)
- case core.BuffType_DEFUP:
- return buff.NewFightProPercentBuff(int(core.PropertyType_Buff_Per_Def), false)
- case core.BuffType_SPDUP:
- return buff.NewFightProPercentBuff(int(core.PropertyType_Buff_Per_Agi), false)
- case core.BuffType_CRATEUP:
- return buff.NewFightProPercentBuff(int(core.PropertyType_Add_Cri), false)
- case core.BuffType_CRITRESIST:
- break
- case core.BuffType_ATKDOWN:
- return buff.NewFightProPercentBuff(int(core.PropertyType_Buff_Per_Atk), true)
- case core.BuffType_DEFDOWN:
- return buff.NewFightProPercentBuff(int(core.PropertyType_Buff_Per_Def), true)
- case core.BuffType_SPDDOWN:
- return buff.NewFightProPercentBuff(int(core.PropertyType_Buff_Per_Agi), true)
- case core.BuffType_CRATEDOWN:
- return buff.NewFightProPercentBuff(int(core.PropertyType_Add_Cri), true)
- case core.BuffType_MISSRATEUP:
- return buff.NewFightProPercentBuff(int(core.PropertyType_LostHold_per), false)
- case core.BuffType_SEAR:
- break
- case core.BuffType_INVINCIBILITY:
- return buff.NewFightBuff()
- case core.BuffType_STANDOFF:
- break
- case core.BuffType_STUN:
- return buff.NewFightBuff()
- case core.BuffType_FREEZE:
- return buff.NewFightBuff()
- case core.BuffType_DISEASED:
- return buff.NewFightBuff()
- case core.BuffType_PETRIFICATION:
- return buff.NewFightBuff()
- case core.BuffType_SILENCE:
- return buff.NewFightBuff()
- case core.BuffType_TAUNT:
- break
- case core.BuffType_IMMUNITY:
- return buff.NewFightBuff()
- case core.BuffType_SHIELD:
- return buff.NewFightShieldBuff()
- case core.BuffType_NOTSPEED:
- return buff.NewFightBuff()
- case core.BuffType_DAMREUP:
- return buff.NewFightProPercentBuff(int(core.PropertyType_DamRe_Per), true)
- case core.BuffType_HPUP:
- return buff.NewFightProPercentBuff(int(core.PropertyType_Add_Per_Hp), false)
- case core.BuffType_EFFHITUP:
- return buff.NewFightProPercentBuff(int(core.PropertyType_Add_EffHit), false)
- case core.BuffType_EFFREUP:
- return buff.NewFightProPercentBuff(int(core.PropertyType_Add_EffRe), false)
- case core.BuffType_HPDOWN:
- break
- case core.BuffType_EFFHITDOWN:
- return buff.NewFightProPercentBuff(int(core.PropertyType_Add_EffHit), true)
- case core.BuffType_EFFREDOWN:
- return buff.NewFightProPercentBuff(int(core.PropertyType_Add_EffRe), true)
- case core.BuffType_CAUSEDAMUP:
- return buff.NewFightProPercentBuff(int(core.PropertyType_CauseDam_Per), false)
- case core.BuffType_POISON:
- return buff.NewFightPoisonBuff()
- case core.BuffType_ATTRTRANS:
- break
- case core.BuffType_UNDEAD:
- break
- case core.BuffType_DEVOUR:
- break
- case core.BuffType_DONTMISS:
- break
- case core.BuffType_NOTGAIN:
- break
- case core.BuffType_NOTCONTROL:
- break
- case core.BuffType_SLEEP:
- break
- }
- return buff.NewFightBuff()
-}
diff --git a/modules/battle/fight/component/passivestore.go b/modules/battle/fight/component/passivestore.go
deleted file mode 100644
index af0592aed..000000000
--- a/modules/battle/fight/component/passivestore.go
+++ /dev/null
@@ -1,34 +0,0 @@
-package component
-
-import (
- "go_dreamfactory/modules/battle/fight/core"
- "go_dreamfactory/modules/battle/fight/passive"
-)
-
-type PassiveStore struct {
- Passives map[int]core.IFightPassive
- temp []int
-}
-
-func (this *PassiveStore) CreatePassive(pType string) core.IFightPassive {
- switch pType {
- case "CallSkillPas":
- return passive.NewFightCallSkillPas()
- }
- return nil
-}
-func (this *PassiveStore) ForEach(action func(fp core.IFightPassive)) {
- this.temp = make([]int, 0)
- for k, _ := range this.Passives {
- this.temp = append(this.temp, k)
- }
- for _, v := range this.temp {
- action(this.Passives[v])
- }
-}
-func (this *PassiveStore) RemovePassive(id int) {
-
-}
-func (this *PassiveStore) Clear() {
- this.Passives = make(map[int]core.IFightPassive)
-}
diff --git a/modules/battle/fight/core/bufftype.go b/modules/battle/fight/core/bufftype.go
deleted file mode 100644
index 749e0d60f..000000000
--- a/modules/battle/fight/core/bufftype.go
+++ /dev/null
@@ -1,162 +0,0 @@
-package core
-
-type BuffType int
-
-const (
- ///
- /// 无效类型
- ///
- BuffType_NONE = 0
- ///
- /// 攻击提升
- ///
- BuffType_ATKUP = 1
- ///
- /// 防御提升
- ///
- BuffType_DEFUP = 2
- ///
- /// 速度提升
- ///
- BuffType_SPDUP = 3
- ///
- /// 暴击提升
- ///
- BuffType_CRATEUP = 4
- ///
- /// 暴击抵抗
- ///
- BuffType_CRITRESIST = 5
- ///
- /// 攻击下降
- ///
- BuffType_ATKDOWN = 6
- ///
- /// 防御下降
- ///
- BuffType_DEFDOWN = 7
- ///
- /// 速度下降
- ///
- BuffType_SPDDOWN = 8
- ///
- /// 暴击下降
- ///
- BuffType_CRATEDOWN = 9
- ///
- /// 烙印
- ///
- BuffType_SEAR = 10
- ///
- /// 失手率提升
- ///
- BuffType_MISSRATEUP = 11
- ///
- /// 无敌
- ///
- BuffType_INVINCIBILITY = 12
- ///
- /// 对峙
- ///
- BuffType_STANDOFF = 13
- ///
- /// 眩晕
- ///
- BuffType_STUN = 14
- ///
- /// 冰冻
- ///
- BuffType_FREEZE = 15
- ///
- /// 禁疗
- ///
- BuffType_DISEASED = 16
- ///
- /// 石化
- ///
- BuffType_PETRIFICATION = 17
- ///
- /// 沉默
- ///
- BuffType_SILENCE = 18
- ///
- /// 挑衅
- ///
- BuffType_TAUNT = 19
- ///
- /// 免疫
- ///
- BuffType_IMMUNITY = 20
- ///
- /// 护盾
- ///
- BuffType_SHIELD = 21
- ///
- /// 不可移动
- ///
- BuffType_NOTSPEED = 22
- ///
- /// 受到伤害降低
- ///
- BuffType_DAMREUP = 23
- ///
- /// 血量提升
- ///
- BuffType_HPUP = 24
- ///
- /// 效果命中提升
- ///
- BuffType_EFFHITUP = 25
- ///
- /// 效果抵抗提升
- ///
- BuffType_EFFREUP = 26
- ///
- /// 血量下降
- ///
- BuffType_HPDOWN = 27
- ///
- /// 效果命中下降
- ///
- BuffType_EFFHITDOWN = 28
- ///
- /// 效果抵抗下降
- ///
- BuffType_EFFREDOWN = 29
- ///
- /// 伤害提升增加
- ///
- BuffType_CAUSEDAMUP = 30
- ///
- /// 中毒
- ///
- BuffType_POISON = 31
- ///
- /// 属性转换
- ///
- BuffType_ATTRTRANS = 32
- ///
- /// 不死
- ///
- BuffType_UNDEAD = 33
- ///
- /// 吞噬
- ///
- BuffType_DEVOUR = 34
- ///
- /// 不会失手
- ///
- BuffType_DONTMISS = 35
- ///
- /// 不能获得增益buff
- ///
- BuffType_NOTGAIN = 36
- ///
- /// 免疫控制
- ///
- BuffType_NOTCONTROL = 37
- ///
- /// 睡眠
- ///
- BuffType_SLEEP = 38
-)
diff --git a/modules/battle/fight/core/cmd.go b/modules/battle/fight/core/cmd.go
new file mode 100644
index 000000000..e35ddab1d
--- /dev/null
+++ b/modules/battle/fight/core/cmd.go
@@ -0,0 +1,42 @@
+package core
+
+//指令
+type ICmd interface {
+ Recycle()
+ ToString() string
+}
+
+///战斗开始指令
+type ComStartFight struct {
+ CurWave int
+}
+
+func (this *ComStartFight) Recycle() {
+
+}
+
+/// 校验战斗结束
+func (this *ComStartFight) ToString() string {
+ var str = "战斗开始"
+ return str
+}
+
+func NewComSkillAfterAtk() *ComSkillAfterAtk {
+ return &ComSkillAfterAtk{}
+}
+
+/// 子技能命令集合
+type ComSkillAfterAtk struct {
+ Skillid int32
+ From int32
+ ///技能的目标
+ Targets []int32
+ ComList []*ComEffectSkill
+ //后续子技能
+ FollowSkills []*ComSkillAfterAtk
+}
+
+type ComEffectSkill struct {
+ To int32
+ MainEffect bool
+}
diff --git a/modules/battle/fight/core/core.go b/modules/battle/fight/core/core.go
index cfa1649a4..dd64dec2e 100644
--- a/modules/battle/fight/core/core.go
+++ b/modules/battle/fight/core/core.go
@@ -1,205 +1,14 @@
package core
import (
- "go_dreamfactory/lego/sys/log"
- "go_dreamfactory/modules/battle/fight/attribute"
+ "go_dreamfactory/lego/core"
cfg "go_dreamfactory/sys/configure/structs"
)
-type (
- ///战斗控制器
- IFight interface {
- log.ILogger
- GetRoles() []IFightRole
- GetFightLog() IFightLog
- GetFightEvent() IFightEvent
- GetSkillConfig(SkillId int, skillLv int) interface{}
- /// 战前逻辑
- BeforeStart()
- ///开始战斗
- StartFight()
- /// 开始一个回合
- TurnRound()
- /// 校验战斗结束
- CheckFightEnd()
- ///
- /// 获取行动角色
- /// 计算当前可以行动的角色,没有时返回null
- ///
- GetActionRole() IFightRole
-
- /// 增加一个参战角色
- AddRole(role IFightRole)
- /// 触发队长技,队长技配置在atk表中,触发顺序无所谓
- EmitCaptainSkill()
- ///
- /// LastActionRole触发SkillId技能,选择的目标是TargetRid
- /// 手动时,表现层在玩家操作后,调用本方法
- /// 自动战斗或服务端里,通过FightAI逻辑来自动触发
- ///
- /// 技能ID
- /// 选择的目标rid
- EmitSkill(skillId int32, targetRid []int32)
- ///
- /// 触发的释放主技能添加到这边(出手角色主技能执行完了,再执行)
- ///
- AddPassiveMainSkill(role IFightRole, skillId int32)
- ///
- /// 生成随机数
- ///
- /// 最小值(含)
- /// 最大值(含)
- ///
- Rand(min, max int) int
- }
- //战斗角色
- IFightRole interface {
- ///
- /// 战斗实例
- ///
- GetFightBase() IFight
- ///
- /// 角色数据
- ///
- GetData() *FightRoleData
- GetCurrentHealth() *attribute.HealthPoint
- ///
- /// 增加一个主技能
- ///
- /// 技能id
- /// 技能等级
- AddSkill(skillId int32, skillLv int32) ISkill
- /// 获取行动令牌
- StartAction()
- /// 结束行动令牌
- StopAction()
- /// 修改行动值
- ModifyOperateValue(newNum float32)
- ///接收伤害
- ReceiveDamage(from IFightRole, DamageValue float32, skill IAfterSkill)
- /// 是否致死伤害
- WillDead(damageValue float32) bool
- /// 接收治疗
- ReceiveCure(cureValue float32) int
- ///
- /// 当前是否能进行攻击行为
- /// 如果有行动类控制buff,如昏迷,冰冻等,则不能攻击
- ///
- CanAtk() bool
- /// 是否死亡
- IsDead() bool
- /// 获取下一个技能id
- GetNextSkillId() int32
- /// 获取后续子技能
- GetAfterAtk(skillId int32) ISkill
- /// 触发SkillId技能,选择的目标是TargetRid
- EmitSkill(skillId int32, targetRid []int32)
- /// 自身的 Buff 和 被动 是否有指定标签
- HasTag(pTag string) bool
- ///战斗结束清理
- Clear()
- }
- //AI
- IFightAI interface {
- /// 自动触发技能
- AutoEmitSkill(pFightRole IFightRole)
- }
- //技能对象
- ISkill interface {
- ///
- /// 获取技能配置信息
- ///
- GetSkillConf() *cfg.GameSkillAtkData
- GetSourceSkillId() int32
- SetSourceSkillId(skillid int32)
- GetSkillLog() *ComSkillAfterAtk
- ///
- /// 触发
- /// 遍历所有ChildSkills,生成对应的实例,并Emit触发
- ///
- Emit() bool
- ///
- /// 减少CD回合数
- ///
- /// 新的回合数
- MinusCD(val int32) int32
- ///
- /// 增加CD回合数
- ///
- /// 新的回合数
- ResetCD() int32
- ///
- /// 设置CD回合数为新的值
- ///
- ///
- ///
- SetCD(newVal int32) int32
- ///
- /// 战斗结束时的清理
- ///
- Clear()
- ///
- ///发送技能日志
- ///
- SendSkillLog()
- }
- IAfterSkill interface {
- GetOwnerRole() IFightRole
- GetAfterSkillConf() cfg.GameSkillAfteratkData
- GetSkillArgs() []int
- GetSourceSkillId() int
- AddLog(pCom IComEffectSkill)
- AddSkillLog(afterAtk *ComSkillAfterAtk)
- ///
- /// 战斗结束时的清理
- ///
- Clear()
- }
- //Buff对象
- IBuff interface {
- GetBuffConf() *cfg.GameSkillBuffData
- /// 激活Buff
- Activate(param float32)
- /// 结束Buff
- OnEnd(skill IAfterSkill)
- ///
- /// 战斗结束时的清理
- ///
- Clear()
- }
- //buff集合
- IBuffStore interface {
- GetHasBuffTypes() []int
- ForEach(action func(buff IBuff))
- RemoveBuff(buff IBuff)
- Clear()
- }
- //被动技集合
- IPassiveStore interface {
- TryGetPassive(pPassId int) (v IFightPassive, ok bool)
- ForEach(action func(fp IFightPassive))
- Clear()
- }
- IFightPassive interface {
- GetTriggerPassiveRole() IFightRole
- Clear()
- }
- //战报
- IFightLog interface {
- AddCommand(log interface{})
- }
- IFightEvent interface {
- //发送事件
- EmitForInt(eventNumber int, args ...interface{})
- //发送事件
- EmitForStr(eventName string, args ...interface{})
- /// 监听消息
- OnForStr(eventName string, f interface{})
- /// 监听消息
- OnForInt(eventNumber int, f interface{})
- /// 移除监听消息
- OffForStr(eventName string, f interface{})
- /// 移除监听消息
- OffForInt(eventNumber int, f interface{})
- }
-)
+type IBattle interface {
+ core.IModule
+ GetSkillAtk(skillId int32, skillLv int32) (result *cfg.GameSkillAtkData, err error)
+ GetSkillAfteratk(skillId int32) (result *cfg.GameSkillAfteratkData, err error)
+ GetSkillBuff(skillId int32) (result *cfg.GameSkillBuffData, err error)
+ GetSkillPassive(skillId int32) (result *cfg.GameSkillPassiveData, err error)
+}
diff --git a/modules/battle/fight/core/enum.go b/modules/battle/fight/core/enum.go
index 0e2f6eafc..9fb1a0478 100644
--- a/modules/battle/fight/core/enum.go
+++ b/modules/battle/fight/core/enum.go
@@ -1,7 +1,5 @@
package core
-import "fmt"
-
///
/// 战斗类型枚举
///
@@ -121,6 +119,7 @@ const (
AferSkillFromType_TriggerPassiveTarget = 12
)
+//事件类型
type EventType int8
const (
@@ -231,179 +230,10 @@ const (
EventType_OnAddBuff
)
+//排序类型
type EOrderType int8
const (
EOrderType_Asc EOrderType = iota
EOrderType_Desc
)
-
-type ComModifyOperate struct {
- From byte
- Nv float32
-}
-
-func (this *ComModifyOperate) Recycle() {
- this.From = 0
- this.Nv = 0
-}
-
-func (this *ComModifyOperate) ToString() string {
- str := fmt.Sprintf("修改行动值 rid={%d},nv={%f}", this.From, this.Nv)
- return str
-}
-
-type ComSetSkillCD struct {
- From int
- Skillid int32
- Nv byte
-}
-
-func (this *ComSetSkillCD) Recycle() {
- this.From = 0
- this.Nv = 0
- this.Skillid = 0
-}
-
-func (this *ComSetSkillCD) ToString() string {
- str := fmt.Sprintf("修改行动值 rid={%d},skillid={%d},nv={%d}", this.From, this.Skillid, this.Nv)
- return str
-}
-
-type ComStartFight struct{}
-
-func (this *ComStartFight) Recycle() {}
-func (this *ComStartFight) ToString() string {
- str := "战斗开始"
- return str
-}
-
-type ComEndFight struct {
- FightId string
- Win bool
-}
-
-func (this *ComEndFight) Recycle() {}
-func (this *ComEndFight) ToString() string {
- var str = "战斗结束"
- return str
-}
-
-type ComStartAction struct {
- From byte
-}
-
-func (this *ComStartAction) Recycle() {
- this.From = 0
-}
-func (this *ComStartAction) ToString() string {
- var str = "回合开始 rid={from}"
- return str
-}
-
-type ComStopAction struct {
- From byte
-}
-
-func (this *ComStopAction) Recycle() {
- this.From = 0
-}
-func (this *ComStopAction) ToString() string {
- var str = fmt.Sprintf("回合结束 rid={%d}", this.From)
- return str
-}
-
-///
-/// 主技能命令集合
-///
-type ComSkillAtk struct {
- AniName string
- Skillid int
- From byte
- comList []*ComSkillAfterAtk
-}
-
-///
-/// 回收到对象池时重设数据
-///
-func (this *ComSkillAtk) Recycle() {
- this.AniName = ""
- this.Skillid = 0
- this.From = 0
-}
-
-///
-/// 子技能命令集合
-///
-type ComSkillAfterAtk struct {
- //public int skillid;
- ComList []*ComEffectSkill
-}
-
-//技能指令
-type IComEffectSkill interface {
-}
-
-type ComEffectSkill struct {
- To int
-}
-
-type ComMondifyBuff struct {
- ComEffectSkill
- Gid int64 //唯一实体id
- BuffId int32 //配置id
- OverlapNum int //叠加层数
- Param float32 //参数 - 护盾量
- Operate byte // 0 移除 1 添加 2 修改
-}
-
-///
-/// 回收到对象池时重设数据
-///
-func (this *ComMondifyBuff) Recycle() {
- this.BuffId = 0
- this.Operate = 0
- this.To = 0
-}
-func (this *ComMondifyBuff) ToString() string {
- var operateStr string
- if this.Operate == 0 {
- operateStr = "移除"
- } else if this.Operate == 1 {
- operateStr = "添加"
- } else {
- operateStr = "修改"
- }
- var str = fmt.Sprintf("Buff变化 to={%d}gid={%d} buffId={%d} overlapNum={%d} operate={%s}", this.To, this.Gid, this.BuffId, this.OverlapNum, operateStr)
- return str
-}
-
-///
-/// 生命值修改命令
-///
-type ComModifyHealth struct {
- ComEffectSkill
- HideDmg bool
- From int
- Baoji bool
- Miss bool
- Num float32
- Nhp int32
- Mhp int32
-}
-
-///
-/// 回收到对象池时重设数据
-///
-func (this *ComModifyHealth) Recycle() {
- this.Baoji = false
- this.Miss = false
- this.Num = 0
- this.Nhp = 0
- this.Mhp = 0
- this.To = 0
-}
-func (this *ComModifyHealth) ToString() string {
- var str = fmt.Sprintf("血量修改 to={%d} num={%f} nhp={%d} mhp={%d}", this.To, this.Num, this.Nhp, this.Mhp)
- return str
-}
diff --git a/modules/battle/fight/core/fightargu.go b/modules/battle/fight/core/fightargu.go
deleted file mode 100644
index 368dff6b3..000000000
--- a/modules/battle/fight/core/fightargu.go
+++ /dev/null
@@ -1,12 +0,0 @@
-package core
-
-const StepNum int = 10
-
-///
-/// 效果触发概率判断
-///
-func Exec_Pr(pSkill IAfterSkill, pr int) bool {
- randVal := pSkill.GetOwnerRole().GetFightBase().Rand(1, 1000)
- // FightDebug.Log($"子技能 {pSkill.AfterSkillConf.Id} 效果触发概率判断:{randVal}, Bool: {randVal <= pr}");
- return randVal <= pr
-}
diff --git a/modules/battle/fight/core/fightproperty.go b/modules/battle/fight/core/fightproperty.go
deleted file mode 100644
index 4a802042c..000000000
--- a/modules/battle/fight/core/fightproperty.go
+++ /dev/null
@@ -1,260 +0,0 @@
-package core
-
-import "go_dreamfactory/modules/battle/fight/attribute"
-
-func Get(role IFightRole, attributeType int) *attribute.FixedNumeric {
- switch PropertyType(attributeType) {
- case PropertyType_Add_Hp: // 附加生命
- return &role.GetCurrentHealth().CurrMaxHpAppend.BaseValue
- case PropertyType_Add_Per_Hp: // 附加百分比生命
- return &role.GetCurrentHealth().CurrMaxHpPro.BaseValue
- case PropertyType_Add_Atk: // 附加攻击
- return &role.GetData().Atk.AppendValue
- case PropertyType_Add_Per_Atk: // 附加百分比攻击
- return &role.GetData().Atk.ProValue
- case PropertyType_Buff_Atk: // BUFF附加攻击
- return &role.GetData().Atk.BuffValue
- case PropertyType_Buff_Per_Atk: // BUFF附加百分比攻击
- return &role.GetData().Atk.BuffProValue
-
- case PropertyType_Add_Def: // 附加防御
- return &role.GetData().Def.AppendValue
- case PropertyType_Add_Per_Def: // 附加百分比防御
- return &role.GetData().Def.ProValue
- case PropertyType_Buff_Def: // BUFF附加防御
- return &role.GetData().Def.BuffValue
- case PropertyType_Buff_Per_Def: // BUFF附加百分比防御
- return &role.GetData().Def.BuffProValue
- case PropertyType_Add_Agi: // 附加速度
- return &role.GetData().Speed.AppendValue
- case PropertyType_Add_Per_Agi: // 附加百分比速度
- return &role.GetData().Speed.ProValue
- case PropertyType_Buff_Agi: // BUFF附加速度
- return &role.GetData().Speed.BuffValue
- case PropertyType_Buff_Per_Agi: // BUFF附加百分比速度
- return &role.GetData().Speed.BuffProValue
- case PropertyType_Add_Cri: // 附加暴击率
- return &role.GetData().Critical.BuffProValue
- case PropertyType_Add_CriDam: // 附加暴击伤害
- return &role.GetData().CriticalPower.BuffProValue
- case PropertyType_Add_EffHit: // 附加效果命中
- return &role.GetData().EffectHit.BuffProValue
- case PropertyType_Add_EffRe: // 附加效果抵抗
- return &role.GetData().EfectResist.BuffProValue
- case PropertyType_ActValue: // 行动值
- return &role.GetData().Operate.BaseValue
- case PropertyType_DamRe: // 伤害减免
- return &role.GetData().DamRe.BaseValue
- //30 DamRe 伤害减免
- //31 CauseDam 造成伤害参数
- //32 SufferDam 受到伤害参数
- //33 MissPr 失手率
- //34 KnowPr 会心率
- //35 KnowPrDam 会心伤害
- //36 AddEffPr 附加效果触发概率
- //37 HpShield 生命护盾
- //38 CauseHpShieldPer 护盾量百分比加成
- //39 SufferHpShieldPer 受到护盾量百分比加成
- //40 CauseAddHp 治疗量百分比加成
- //41 SufferAddHp 受到治疗量百分比加成
- //42 IgnoreDefPer 无视防御百分比
- //43 SucHp 吸血百分比
- //44 Add_SufCri 附加暴击抵抗
- }
- role.GetFightBase().Debugf("属性暂未绑定:%d", attributeType)
- return nil
-}
-
-///
-/// 获取真实属性值
-///
-func TryGetValue(role IFightRole, attributeType int, pValue *float32) bool {
- var (
- numeric *attribute.FixedNumeric
- )
- switch PropertyType(attributeType) {
- case PropertyType_Total_Hp: // 总生命
- *pValue = role.GetCurrentHealth().MaxHp.Value()
- return true
- case PropertyType_NowTotal_Hp: // 当前总生命
- *pValue = role.GetCurrentHealth().CurrMaxHp.Value()
- return true
- case PropertyType_NowHp: // 当前生命
- *pValue = role.GetCurrentHealth().Hp.Value()
- return true
- case PropertyType_Total_Atk: // 总攻击
- *pValue = role.GetData().Atk.Value()
- return true
- case PropertyType_Total_Def: // 总防御
- *pValue = role.GetData().Def.Value()
- return true
- case PropertyType_Total_Agi: // 总速度
- *pValue = role.GetData().Speed.Value()
- return true
- case PropertyType_Total_Cri: // 总暴击率
- *pValue = role.GetData().Critical.Value()
- return true
- case PropertyType_Total_CriDam: // 总暴击伤害
- *pValue = role.GetData().CriticalPower.Value()
- return true
- case PropertyType_Total_EffHit: // 总效果命中
- *pValue = role.GetData().EffectHit.Value()
- return true
- case PropertyType_Total_EffRe: // 总效果抵抗
- *pValue = role.GetData().EfectResist.Value()
- return true
- case PropertyType_LostHp: // 已损失生命值
- *pValue = role.GetCurrentHealth().Deduct()
- return true
- case PropertyType_LostPerHp: // 已损失生命值百分比
- *pValue = role.GetCurrentHealth().LostPercent() * 1000
- return true
- case PropertyType_NowHp_Per: // 当前生命百分比
- *pValue = role.GetCurrentHealth().Percent() * 1000
- return true
- }
-
- numeric = Get(role, attributeType)
- if numeric != nil {
- *pValue = numeric.Value()
- return true
- }
-
- *pValue = 0
- return false
-}
-
-/// 尝试设置属性
-func TrySetValue(role IFightRole, attributeType int, pValue float32, add bool) bool {
- var (
- numeric *attribute.AttributeNumeric
- attr attribute.FixedNumeric
- value float32
- f float32
- )
- switch PropertyType(attributeType) {
- case PropertyType_Add_Hp: // 附加生命
- var attri = role.GetCurrentHealth().CurrMaxHpAppend.BaseValue
- if add {
- value = attri.Add(pValue)
- } else {
- value = attri.Minus(pValue)
- }
- role.GetCurrentHealth().CurrMaxHpAppend.OnChange()
- role.GetCurrentHealth().OnChange()
- return true
- case PropertyType_Add_Per_Hp: // 附加百分比生命
- var attri = role.GetCurrentHealth().CurrMaxHpPro.BaseValue
- if add {
- value = attri.Add(pValue)
- } else {
- value = attri.Minus(pValue)
- }
- role.GetCurrentHealth().CurrMaxHpPro.OnChange()
- role.GetCurrentHealth().OnChange()
- return true
- case PropertyType_Add_Atk: // 附加攻击
- numeric = role.GetData().Atk
- attr = role.GetData().Atk.AppendValue
- break
- case PropertyType_Add_Per_Atk: // 附加百分比攻击
- numeric = role.GetData().Atk
- attr = role.GetData().Atk.ProValue
- break
- case PropertyType_Buff_Atk: // BUFF附加攻击
- numeric = role.GetData().Atk
- attr = role.GetData().Atk.BuffValue
- break
- case PropertyType_Buff_Per_Atk: // BUFF附加百分比攻击
- numeric = role.GetData().Atk
- attr = role.GetData().Atk.BuffProValue
- break
- case PropertyType_Add_Def: // 附加防御
- numeric = role.GetData().Def
- attr = role.GetData().Def.AppendValue
- break
- case PropertyType_Add_Per_Def: // 附加百分比防御
- numeric = role.GetData().Def
- attr = role.GetData().Def.ProValue
- break
- case PropertyType_Buff_Def: // BUFF附加防御
- numeric = role.GetData().Def
- attr = role.GetData().Def.BuffValue
- break
- case PropertyType_Buff_Per_Def: // BUFF附加百分比防御
- numeric = role.GetData().Def
- attr = role.GetData().Def.BuffProValue
- break
- case PropertyType_Add_Agi: // 附加速度
- numeric = role.GetData().Speed
- attr = role.GetData().Speed.AppendValue
- break
- case PropertyType_Add_Per_Agi: // 附加百分比速度
- numeric = role.GetData().Speed
- attr = role.GetData().Speed.ProValue
- break
- case PropertyType_Buff_Agi: // BUFF附加速度
- numeric = role.GetData().Speed
- attr = role.GetData().Speed.BuffValue
- break
- case PropertyType_Buff_Per_Agi: // BUFF附加百分比速度
- numeric = role.GetData().Speed
- attr = role.GetData().Speed.BuffProValue
- break
- case PropertyType_Add_Cri: // 附加暴击率
- numeric = role.GetData().Critical
- attr = role.GetData().Critical.BuffProValue
- break
- case PropertyType_Add_CriDam: // 附加暴击伤害
- numeric = role.GetData().CriticalPower
- attr = role.GetData().CriticalPower.BuffProValue
- break
- case PropertyType_Add_EffHit: // 附加效果命中
- numeric = role.GetData().EffectHit
- attr = role.GetData().EffectHit.BuffProValue
- break
- case PropertyType_Add_EffRe: // 附加效果抵抗
- numeric = role.GetData().EfectResist
- attr = role.GetData().EfectResist.BuffProValue
- break
- case PropertyType_ActValue: // 行动值
- numeric = role.GetData().Operate
- attr = role.GetData().Operate.BaseValue
- break
- case PropertyType_DamRe: // 伤害减免
- numeric = role.GetData().DamRe
- attr = role.GetData().DamRe.BuffValue
- break
- case PropertyType_DamRe_Per: // 伤害减免(百分比)
- numeric = role.GetData().DamRe
- attr = role.GetData().DamRe.BuffProValue
- break
- case PropertyType_CauseDam: // 伤害提升
- numeric = role.GetData().CauseDam
- attr = role.GetData().DamRe.BuffValue
- break
- case PropertyType_CauseDam_Per: // 伤害提升(百分比)
- numeric = role.GetData().CauseDam
- attr = role.GetData().CauseDam.BuffProValue
- break
- case PropertyType_LostHold_per: // 失手率(百分比)
- numeric = role.GetData().LostHold
- attr = role.GetData().LostHold.BuffProValue
- break
- case PropertyType_UnderStand_per: // 会心率(百分比)
- numeric = role.GetData().UnderStand
- attr = role.GetData().UnderStand.BuffProValue
- break
- }
- if numeric == nil {
- role.GetFightBase().Debugf("属性暂未绑定:%d value:%f f:%f", attributeType, value, f)
- return false
- }
- if add {
- f = attr.Add(pValue)
- } else {
- f = attr.Minus(pValue)
- }
- numeric.OnChange()
- return true
-}
diff --git a/modules/battle/fight/core/fightroledata.go b/modules/battle/fight/core/fightroledata.go
deleted file mode 100644
index 4e90a3fba..000000000
--- a/modules/battle/fight/core/fightroledata.go
+++ /dev/null
@@ -1,157 +0,0 @@
-package core
-
-import (
- "go_dreamfactory/modules/battle/fight/attribute"
-)
-
-type FightRoleData struct {
- ///
- /// 角色名
- ///
- Name string
- ///
- /// 阵营 1=我 2=敌
- ///
- Side byte
- ///
- /// 种族 1灼热, 2涌动, 3呼啸, 4闪耀
- ///
- Race byte
- ///
- /// 站位 1~5
- ///
- Pos byte
- ///
- /// 唯一标记,同时也是List FightBase.Roles的索引
- ///
- Rid int
- ///
- /// 唯一id, 用于调试打日志
- ///
- UniqueId string
- ///
- /// 是否活着
- ///
- ALive bool
- ///
- /// 是否队长
- ///
- Captain bool
- ///
- /// 队长技 id
- ///
- CaptainSkillId int32
-
- //region 战斗属性-----------------------------------------------------------------------
- ///
- /// 行动值
- ///
- Operate *attribute.AttributeNumeric
- ///
- /// 最大生命
- ///
- MaxHp *attribute.AttributeNumeric
-
- ///
- /// 当前生命
- ///
- Hp *attribute.AttributeNumeric
-
- ///
- /// 攻击
- ///
- Atk *attribute.AttributeNumeric
-
- ///
- /// 防御
- ///
- Def *attribute.AttributeNumeric
-
- ///
- /// 速度
- ///
- Speed *attribute.AttributeNumeric
-
- ///
- /// 暴击率
- ///
- Critical *attribute.AttributeNumeric
-
- ///
- /// 暴击伤害
- ///
- CriticalPower *attribute.AttributeNumeric
-
- ///
- /// 效果命中
- ///
- EffectHit *attribute.AttributeNumeric
-
- ///
- /// 效果抵抗
- ///
- EfectResist *attribute.AttributeNumeric
-
- ///
- /// 失手率
- ///
- LostHold *attribute.AttributeNumeric
-
- ///
- /// 会心率
- ///
- UnderStand *attribute.AttributeNumeric
- ///
- /// 伤害减免
- ///
- DamRe *attribute.AttributeNumeric
- ///
- /// 伤害提升
- ///
- CauseDam *attribute.AttributeNumeric
-
- ///
- /// 治疗加成
- ///
- TreAdd *attribute.AttributeNumeric
-
- ///
- /// 受疗加成
- ///
- BeTreAdd *attribute.AttributeNumeric
-
- ///region 技能相关-----------------------------------------------------------------------
- ///
- /// 技能信息 id:lv
- ///
- SkillsInfo []ISkill
- ///
- /// 最后一次选择的skillAtk类技能
- ///
- LastSkillId int32
- ///
- /// 最后一次skillAtk技能选择的目标
- ///
- LastChooseTarget []int
- ///
- /// 可执行技能列表
- ///
- ///
- /// 在角色初始化时,会根据SkillsInfo实例化对应的技能保存于此
- ///
- Skills map[int32]ISkill
- ///
- /// AfterAtk集合
- ///
- AfterSkills map[int]IAfterSkill
-
- ///
- /// BUFF集合
- ///
- BuffStore IBuffStore
-
- ///
- /// 被动技能集合
- ///
- PassiveStore IPassiveStore
-}
diff --git a/modules/battle/fight/core/iafterskill.go b/modules/battle/fight/core/iafterskill.go
new file mode 100644
index 000000000..4b2755ea6
--- /dev/null
+++ b/modules/battle/fight/core/iafterskill.go
@@ -0,0 +1,15 @@
+package core
+
+import cfg "go_dreamfactory/sys/configure/structs"
+
+//子技能效果
+type IAfterSkill interface {
+ SetSourceSkillId(skillid int32)
+ GetDoVal() int32
+ Init(askill IAfterSkill, role IFightRole, skillConf *cfg.GameSkillAfteratkData)
+ CheckEmit() bool
+ Emit() bool
+ DoLogic()
+ GetSkillLog() *ComSkillAfterAtk
+ Clear()
+}
diff --git a/modules/battle/fight/core/iai.go b/modules/battle/fight/core/iai.go
new file mode 100644
index 000000000..a65f0d3c7
--- /dev/null
+++ b/modules/battle/fight/core/iai.go
@@ -0,0 +1,5 @@
+package core
+
+//战斗AI
+type IFightAI interface {
+}
diff --git a/modules/battle/fight/core/ibuff.go b/modules/battle/fight/core/ibuff.go
new file mode 100644
index 000000000..678f7a2d6
--- /dev/null
+++ b/modules/battle/fight/core/ibuff.go
@@ -0,0 +1,5 @@
+package core
+
+//buff
+type IBuff interface {
+}
diff --git a/modules/battle/fight/core/ievent.go b/modules/battle/fight/core/ievent.go
new file mode 100644
index 000000000..2ca9fa745
--- /dev/null
+++ b/modules/battle/fight/core/ievent.go
@@ -0,0 +1,5 @@
+package core
+
+type IFightEvent interface {
+ Emit(eventNumber int, args ...interface{})
+}
diff --git a/modules/battle/fight/core/ifight.go b/modules/battle/fight/core/ifight.go
new file mode 100644
index 000000000..7c0f2cde5
--- /dev/null
+++ b/modules/battle/fight/core/ifight.go
@@ -0,0 +1,13 @@
+package core
+
+import "go_dreamfactory/lego/sys/log"
+
+//战斗控制器
+type IFight interface {
+ log.ILogger
+ GetFightEvent() IFightEvent
+ ///获取技能配置
+ GetSkillConfig(skillId int32, skillLv int32) (conf interface{})
+ ///随机数
+ Rand(min, max int32) int32
+}
diff --git a/modules/battle/fight/core/ilog.go b/modules/battle/fight/core/ilog.go
new file mode 100644
index 000000000..76680fe96
--- /dev/null
+++ b/modules/battle/fight/core/ilog.go
@@ -0,0 +1,6 @@
+package core
+
+//战报
+type IFightLog interface {
+ AddCommand(log ICmd)
+}
diff --git a/modules/battle/fight/core/irole.go b/modules/battle/fight/core/irole.go
new file mode 100644
index 000000000..fbd92e63f
--- /dev/null
+++ b/modules/battle/fight/core/irole.go
@@ -0,0 +1,11 @@
+package core
+
+//战斗角色
+type IFightRole interface {
+ GetFight() IFight
+ GetData() *FightRoleData
+ ///添加主技能
+ AddSkill(skillId int32, skillLv int32) ISkill
+ ///获取子技能 不存在时会初始化
+ GetAfterAtk(skillId int32) IAfterSkill
+}
diff --git a/modules/battle/fight/core/iskill.go b/modules/battle/fight/core/iskill.go
new file mode 100644
index 000000000..cda1ba34a
--- /dev/null
+++ b/modules/battle/fight/core/iskill.go
@@ -0,0 +1,13 @@
+package core
+
+import cfg "go_dreamfactory/sys/configure/structs"
+
+//主技能
+type ISkill interface {
+ ///获取技能配置
+ GetSkillConf() *cfg.GameSkillAtkData
+ /// 触发
+ Emit()
+ ///发送技能日志
+ SendSkillLog()
+}
diff --git a/modules/battle/fight/core/map.go b/modules/battle/fight/core/map.go
index 52b16d290..9a8bc9592 100644
--- a/modules/battle/fight/core/map.go
+++ b/modules/battle/fight/core/map.go
@@ -1,33 +1 @@
package core
-
-import "strconv"
-
-type MapString map[string]string
-
-func (this MapString) TryGetInt(pKey string) (result int, ok bool) {
- var (
- err error
- v string
- )
- if v, ok = this[pKey]; ok {
- if result, err = strconv.Atoi(v); err == nil {
- return
- }
- }
- result = 0
- return
-}
-func (this MapString) TryGetFloat(pKey string, pResult *float32) bool {
- var err error
- var value float64
- if v, ok := this[pKey]; ok {
- if value, err = strconv.ParseFloat(v, 32); err == nil {
- *pResult = 0
- return false
- } else {
- *pResult = float32(value)
- return true
- }
- }
- return false
-}
diff --git a/modules/battle/fight/core/propertytype.go b/modules/battle/fight/core/propertytype.go
deleted file mode 100644
index bfd613562..000000000
--- a/modules/battle/fight/core/propertytype.go
+++ /dev/null
@@ -1,174 +0,0 @@
-package core
-
-type PropertyType int
-
-const (
- ///
- /// 总生命
- ///
- PropertyType_Total_Hp PropertyType = 1
- ///
- /// 当前总生命
- ///
- PropertyType_NowTotal_Hp PropertyType = 2
- ///
- /// 当前生命
- ///
- PropertyType_NowHp PropertyType = 3
- ///
- /// 总攻击
- ///
- PropertyType_Total_Atk PropertyType = 4
- ///
- /// 总防御
- ///
- PropertyType_Total_Def PropertyType = 5
- ///
- /// 总速度
- ///
- PropertyType_Total_Agi PropertyType = 6
- ///
- /// 总暴击率
- ///
- PropertyType_Total_Cri PropertyType = 7
- ///
- /// 总暴击伤害
- ///
- PropertyType_Total_CriDam PropertyType = 8
- ///
- /// 总效果命中
- ///
- PropertyType_Total_EffHit PropertyType = 9
- ///
- /// 总效果抵抗
- ///
- PropertyType_Total_EffRe PropertyType = 10
- ///
- /// 已损失生命值
- ///
- PropertyType_LostHp PropertyType = 11
- ///
- /// 已损失生命值百分比
- ///
- PropertyType_LostPerHp PropertyType = 12
- ///
- /// 当前生命百分比
- ///
- PropertyType_NowHp_Per PropertyType = 13
- ///
- /// 附加生命(修改属性类型从这里开始)
- ///
- PropertyType_Add_Hp PropertyType = 14
- ///
- /// 附加百分比生命
- ///
- PropertyType_Add_Per_Hp PropertyType = 15
- ///
- /// BUFF附加生命
- ///
- PropertyType_Buff_Hp PropertyType = 16
- ///
- /// BUFF附加百分比生命
- ///
- PropertyType_Buff_Per_Hp PropertyType = 17
- ///
- /// 附加攻击
- ///
- PropertyType_Add_Atk PropertyType = 18
- ///
- /// 附加百分比攻击
- ///
- PropertyType_Add_Per_Atk PropertyType = 19
- ///
- /// BUFF附加攻击
- ///
- PropertyType_Buff_Atk PropertyType = 20
- ///
- /// BUFF附加百分比攻击
- ///
- PropertyType_Buff_Per_Atk PropertyType = 21
- ///
- /// 附加防御
- ///
- PropertyType_Add_Def PropertyType = 22
- ///
- /// 附加百分比防御
- ///
- PropertyType_Add_Per_Def PropertyType = 23
- ///
- /// BUFF附加防御
- ///
- PropertyType_Buff_Def PropertyType = 24
- ///
- /// BUFF附加百分比防御
- ///
- PropertyType_Buff_Per_Def PropertyType = 25
- ///
- /// 附加速度
- ///
- PropertyType_Add_Agi PropertyType = 26
- ///
- /// 附加百分比速度
- ///
- PropertyType_Add_Per_Agi PropertyType = 27
- ///
- /// BUFF附加速度
- ///
- PropertyType_Buff_Agi PropertyType = 28
- ///
- /// BUFF附加百分比速度
- ///
- PropertyType_Buff_Per_Agi PropertyType = 29
- ///
- /// 附加暴击率
- ///
- PropertyType_Add_Cri PropertyType = 30
- ///
- /// 附加暴击伤害
- ///
- PropertyType_Add_CriDam PropertyType = 31
- ///
- /// 附加效果命中
- ///
- PropertyType_Add_EffHit PropertyType = 32
- ///
- /// 附加效果抵抗
- ///
- PropertyType_Add_EffRe PropertyType = 33
- ///
- /// 行动值
- ///
- PropertyType_ActValue PropertyType = 34
- ///
- /// 伤害减免(buff附加百分比)
- ///
- PropertyType_DamRe_Per PropertyType = 35
- ///
- /// 伤害提升(buff附加百分比)
- ///
- PropertyType_CauseDam_Per PropertyType = 36
- ///
- /// 伤害减免(固定值)
- ///
- PropertyType_DamRe PropertyType = 37
- ///
- /// 伤害提升(固定值)
- ///
- PropertyType_CauseDam PropertyType = 38
- ///
- /// 失手率buff增加百分比
- ///
- PropertyType_LostHold_per PropertyType = 39
- ///
- /// 会心率buff增加百分比
- ///
- PropertyType_UnderStand_per PropertyType = 40
- ///
- /// 治疗加成
- ///
- PropertyType_TreAdd PropertyType = 41
- ///
- /// 受疗加成
- ///
- PropertyType_BeTreAdd PropertyType = 42
-)
diff --git a/modules/battle/fight/core/roledata.go b/modules/battle/fight/core/roledata.go
new file mode 100644
index 000000000..e4ca5e8ee
--- /dev/null
+++ b/modules/battle/fight/core/roledata.go
@@ -0,0 +1,18 @@
+package core
+
+type FightRoleData struct {
+ /// 唯一标记,同时也是List FightBase.Roles的索引
+ Rid int32
+ /// 唯一id, 用于调试打日志
+ UniqueId string
+ /// 是否队长
+ Captain bool
+ /// 队长技 id
+ CaptainSkillId int32
+
+ //技能相关-----------------------------------------------------------------------------------
+ ///主技能集合
+ Skills map[int32]ISkill
+ ///子技能集合
+ AfterSkills map[int32]IAfterSkill
+}
diff --git a/modules/battle/fight/fightai.go b/modules/battle/fight/fightai.go
deleted file mode 100644
index 72da27824..000000000
--- a/modules/battle/fight/fightai.go
+++ /dev/null
@@ -1,20 +0,0 @@
-package fight
-
-import "go_dreamfactory/modules/battle/fight/core"
-
-type FightAI struct {
- fight core.IFight
-}
-
-///
-/// 自动触发技能
-///
-func (this *FightAI) AutoEmitSkill(pFightRole core.IFightRole) {
- //todo...根据规则,设置对应技能和目标
- skillid := pFightRole.GetNextSkillId() // fightRole.Data.SkillsInfo.Keys.ToArray()[0];
- //临时,随机取一个敌人
- targets := FightTargetFrom(this.fight.GetRoles(), pFightRole, int32(core.AferSkillFromType_Enemy))
-
- // FightBase.EmitSkill(skillid, new int[] { targets[0].Data.Rid }) ;
- this.fight.EmitSkill(skillid, []int32{int32(targets[0].GetData().Rid)})
-}
diff --git a/modules/battle/fight/fightbase.go b/modules/battle/fight/fightbase.go
index 939f3c934..63e1ada52 100644
--- a/modules/battle/fight/fightbase.go
+++ b/modules/battle/fight/fightbase.go
@@ -1,217 +1,196 @@
package fight
import (
+ "fmt"
+ "go_dreamfactory/lego/sys/log"
"go_dreamfactory/modules/battle/fight/core"
"math"
+ "math/rand"
+ "time"
)
+/*
+基础战斗控制器
+*/
type FightBase struct {
- ///
/// 战斗类型
- ///
- FightId string
+ fightId string
/// 战斗是否进行中
fightIng bool
- /// 战斗控制器
- fight core.IFight
/// 战斗类型
fightType core.FightType
-
+ /// 是否自动战斗
+ autoFight bool
+ /// 战斗配置参数
+ options *Options
/// 所有参战角色集合
- Roles []core.IFightRole
+ roles []core.IFightRole
/// 当前回合满足行动值大于等于100的所有角色
- CanAtkRoles []core.IFightRole
+ canAtkRoles []core.IFightRole
/// 最后一次攻击的角色
- LastActionRole core.IFightRole
- /// 战斗AI
- FightAI core.IFightAI
- ///
- /// 随机数种子
- ///
- RandSeed int64
- ///事件系统
- FightEvent core.IFightEvent
- ///
- /// 战报
- ///
- FightLog core.IFightLog
- ///
- /// 触发释放主技能,需要在当前出手角色技能释放完成之后再执行
- ///
- readyEmitSkills map[core.IFightRole]int32
+ lastActionRole core.IFightRole
/// 下一个行动角色
nextAtkRole core.IFightRole
+ /// 战斗AI
+ rightAI core.IFightAI
+ /// 战斗事件
+ fightEvent core.IFightEvent
+ /// 战报
+ fightLog core.IFightLog
+ /// 随机数种子
+ randSeed int64
+}
+
+func (this *FightBase) Init() {
+
}
/// 开始战斗
func (this *FightBase) StartFight() {
- //战斗开始事件触发
- this.FightEvent.EmitForInt(int(core.EventType_OnFightStart))
- ///战斗开始触发
- this.fight.BeforeStart()
- ///触发队长技
- this.fight.EmitCaptainSkill()
- ///初始化参战角色行动值
- this.InitRoleOperateValue()
- ///开始新的回合
- this.fight.TurnRound()
+ this.fightIng = true
+ this.Debug("=========开始战斗=========")
+ //记录战报
+ com := new(core.ComStartFight)
+ com.CurWave = 1
+ this.fightLog.AddCommand(com)
+ //发送开始事件
+ this.fightEvent.Emit(int(core.EventType_OnFightStart))
+
+ this.BeforeStart()
}
+/// 校验战斗结束
func (this *FightBase) CheckFightEnd() {
- lives := []int{0, 0}
- for _, role := range this.Roles {
- dead := role.IsDead()
- if !dead {
- lives[role.GetData().Side-1] += 1
- }
- }
- if lives[0] == 0 || lives[1] == 0 {
- this.fightIng = false
- com := new(core.ComEndFight)
- com.FightId = this.FightId
- com.Win = lives[1] == 0
- // FightLog.AddCommand(com)
- // FightDebug.Log("=========战斗结束=========")
- }
+
+}
+
+//初始化相关-----------------------------------------------------------------------------------------------------------------------
+/// 战前逻辑
+func (this *FightBase) BeforeStart() {
+
}
-///
/// 触发队长技,队长技配置在atk表中,触发顺序无所谓
-///
func (this *FightBase) EmitCaptainSkill() {
- for _, role := range this.Roles {
- if fskill := role.AddSkill(role.GetData().CaptainSkillId, 1); fskill.GetSkillConf().Type == int32(core.SkillType_Captain) {
- fskill.Emit()
- fskill.SendSkillLog()
- }
- }
-}
-
-///
-/// 触发被动技,队长技配置在atk表中,触发顺序无所谓
-///
-func (this *FightBase) EmitPassiveSkillSkill() {
- for _, role := range this.Roles {
- for _, curskill := range role.GetData().Skills {
- if curskill.GetSkillConf().Type == int32(core.SkillType_Passive) {
- curskill.Emit()
- curskill.SendSkillLog()
+ this.Debug("计算队长技...")
+ for _, role := range this.roles {
+ if role.GetData().Captain && role.GetData().CaptainSkillId != 0 {
+ _skill := role.AddSkill(role.GetData().CaptainSkillId, 1)
+ if _skill != nil && _skill.GetSkillConf().Type == int32(core.SkillType_Captain) {
+ _skill.Emit()
+ _skill.SendSkillLog()
}
}
}
}
-///
-/// 初始化所有角色的行动值
-///
-func (this *FightBase) InitRoleOperateValue() {
- roles := this.Order("Speed", core.EOrderType_Desc)
- for _, role := range roles {
- role.ModifyOperateValue(role.GetData().Speed.Value() / roles[0].GetData().Speed.Value() * 100.0)
+/// 获取技能配置
+func (this *FightBase) GetSkillConfig(skillId int32, skillLv int32) (conf interface{}) {
+ skillIdStr := fmt.Sprintf("%d", skillId)
+ switch skillIdStr[0] {
+ case '1':
+ conf, _ = this.options.battle.GetSkillAtk(skillId, skillLv)
+ break
+ case '2':
+ conf, _ = this.options.battle.GetSkillAfteratk(skillId)
+ break
+ case '3':
+ conf, _ = this.options.battle.GetSkillBuff(skillId)
+ break
+ case '4':
+ conf, _ = this.options.battle.GetSkillPassive(skillId)
+ break
}
+ if conf == nil {
+ this.Debugln("GetSkillConfig 时候配置获取失败 SkillId:%d skillLv:%d", skillId, skillLv)
+ }
+ return conf
}
+//回合-----------------------------------------------------------------------------------------------------------------------
/// 开始一个回合
func (this *FightBase) TurnRound() {
- //获取当前出手的角色
- actionRole := this.fight.GetActionRole()
- if actionRole != nil {
- //开始行动
- actionRole.StartAction()
- if actionRole.CanAtk() {
- this.FightEvent.EmitForInt((int)(core.EventType_OnRoundStart), actionRole)
- //自动战斗逻辑
- this.FightAI.AutoEmitSkill(actionRole)
- }
- } else {
- }
}
-///
-/// 排序所有角色
-///
-/// 排序方式
-/// 升序还是降序:asc/desc
-func (this *FightBase) Order(orderBy string, pOrder core.EOrderType) []core.IFightRole {
- if len(this.Roles) <= 1 {
- return this.Roles
- }
- this.Roles = FightRoleSort(this.Roles, orderBy, pOrder)
- return this.Roles
+//随机-----------------------------------------------------------------------------------------------------------------------
+/// 初始化随机种子,以便服务端能生成相同随机数
+func (this *FightBase) InitRandSeed() {
+ rand.Seed(time.Now().UnixNano())
+ this.randSeed = rand.Int63n(100000 + 1)
}
-///
-/// 计算当前可以行动的角色,没有时返回null
-///
-func (this *FightBase) GetActionRole() core.IFightRole {
- if this.nextAtkRole != nil {
- return this.nextAtkRole
- }
-
- this.CanAtkRoles = this.CanAtkRoles[:0]
- for _, v := range this.Roles {
- if v.GetData().ALive && v.GetData().Operate.Value() >= 100 {
- this.CanAtkRoles = append(this.CanAtkRoles, v)
- }
- }
-
- if len(this.CanAtkRoles) == 0 {
- return nil
- } else if len(this.CanAtkRoles) == 1 {
- return this.CanAtkRoles[0]
- } else {
- FightRoleSort(this.CanAtkRoles, "OperateValue", core.EOrderType_Asc)
- return this.CanAtkRoles[0]
- }
-}
-
-///
-/// LastActionRole触发SkillId技能,选择的目标是TargetRid
-/// 手动时,表现层在玩家操作后,调用本方法
-/// 自动战斗或服务端里,通过FightAI逻辑来自动触发
-///
-/// 技能ID
-/// 选择的目标rid
-func (this *FightBase) EmitSkill(skillId int32, targetRid []int32, toNextRound bool) {
- // FightDebug.Log($">>>>>>>> {LastActionRole.Data.UniqueId} 使用技能 skillid={skillId} 选择了Rid: {targetRid[0].ToString()}");
- this.FightEvent.EmitForInt(int(skillId), this.LastActionRole)
- this.LastActionRole.EmitSkill(skillId, targetRid)
- this.FightEvent.EmitForInt(int(core.EventType_OnRoundEnd), this.LastActionRole)
- //主动技能触发所有带动作的子技能需要在主动技能释放完成之后执行
- this.EmitPassiveMainSkill()
- this.OnLastActionRoleActionStop()
-}
-
-/// 执行被动触发的主技能技能
-func (this *FightBase) EmitPassiveMainSkill() {
- for k, v := range this.readyEmitSkills {
- if !k.CanAtk() {
- continue
- }
- k.EmitSkill(v, []int32{})
- }
- this.readyEmitSkills = make(map[core.IFightRole]int32)
-}
-
-///
-/// 表现层在角色表现结束后,调用本方法
-///
-func (this *FightBase) OnLastActionRoleActionStop() {
- this.LastActionRole.StopAction()
- this.FightEvent.EmitForInt(int(core.EventType_OnStopAction))
- //检测战斗是否结束
- this.CheckFightEnd()
-}
-
-///
/// 生成随机数
-///
-/// 最小值(含)
-/// 最大值(含)
-///
-func (this *FightBase) Rand(min, max int) int {
- RandSeed := (this.RandSeed*9301 + 49297) % 233280
- num := int(math.Floor(float64(RandSeed/233280.0)*float64(max-min+1) + float64(min)))
+func (this *FightBase) Rand(min, max int32) int32 {
+ RandSeed := (this.randSeed*9301 + 49297) % 233280
+ num := int32(math.Floor(float64(RandSeed/233280.0)*float64(max-min+1) + float64(min)))
return num
}
+
+//Log-----------------------------------------------------------------------------------------------------------------------
+//日志接口
+func (this *FightBase) Debug(msg string, args ...log.Field) {
+ this.options.Log.Debug(msg, args...)
+}
+func (this *FightBase) Info(msg string, args ...log.Field) {
+ this.options.Log.Info(msg, args...)
+}
+func (this *FightBase) Print(msg string, args ...log.Field) {
+ this.options.Log.Print(msg, args...)
+}
+func (this *FightBase) Warn(msg string, args ...log.Field) {
+ this.options.Log.Warn(msg, args...)
+}
+func (this *FightBase) Error(msg string, args ...log.Field) {
+ this.options.Log.Error(msg, args...)
+}
+func (this *FightBase) Panic(msg string, args ...log.Field) {
+ this.options.Log.Panic(msg, args...)
+}
+func (this *FightBase) Fatal(msg string, args ...log.Field) {
+ this.options.Log.Fatal(msg, args...)
+}
+
+func (this *FightBase) Debugf(format string, args ...interface{}) {
+ this.options.Log.Debugf(format, args...)
+}
+func (this *FightBase) Infof(format string, args ...interface{}) {
+ this.options.Log.Infof(format, args...)
+}
+func (this *FightBase) Printf(format string, args ...interface{}) {
+ this.options.Log.Printf(format, args...)
+}
+func (this *FightBase) Warnf(format string, args ...interface{}) {
+ this.options.Log.Warnf(format, args...)
+}
+func (this *FightBase) Errorf(format string, args ...interface{}) {
+ this.options.Log.Errorf(format, args...)
+}
+func (this *FightBase) Fatalf(format string, args ...interface{}) {
+ this.options.Log.Fatalf(format, args...)
+}
+func (this *FightBase) Panicf(format string, args ...interface{}) {
+ this.options.Log.Panicf(format, args...)
+}
+
+func (this *FightBase) Debugln(args ...interface{}) {
+ this.options.Log.Debugln(args...)
+}
+func (this *FightBase) Infoln(args ...interface{}) {
+ this.options.Log.Infoln(args...)
+}
+func (this *FightBase) Println(args ...interface{}) {
+ this.options.Log.Println(args...)
+}
+func (this *FightBase) Warnln(args ...interface{}) {
+ this.options.Log.Warnln(args...)
+}
+func (this *FightBase) Errorln(args ...interface{}) {
+ this.options.Log.Errorln(args...)
+}
+func (this *FightBase) Fatalln(args ...interface{}) {
+ this.options.Log.Fatalln(args...)
+}
+func (this *FightBase) Panicln(args ...interface{}) {
+ this.options.Log.Panicln(args...)
+}
diff --git a/modules/battle/fight/fightevent.go b/modules/battle/fight/fightevent.go
deleted file mode 100644
index 6518dfbb2..000000000
--- a/modules/battle/fight/fightevent.go
+++ /dev/null
@@ -1,65 +0,0 @@
-package fight
-
-import "reflect"
-
-func NewFightEvent() *FightEvent {
- return &FightEvent{
- events: make(map[string][]reflect.Value),
- }
-}
-
-type FightEvent struct {
- events map[string][]reflect.Value
- onceevents map[string][]reflect.Value
-}
-
-///
-/// 发送消息
-///
-///
-///
-func (this *FightEvent) Emit(key string, params ...interface{}) {
-
-}
-
-///
-/// 监听消息
-///
-///
-///
-func (this *FightEvent) On(key string, f interface{}) {
-
-}
-
-///
-/// 监听一次消息
-///
-///
-///
-func (this *FightEvent) Once(key string, f interface{}) {
-
-}
-
-///
-/// 移除监听消息
-///
-///
-///
-func (this *FightEvent) Off(key string, f interface{}) {
-
-}
-
-///
-/// 移除监听消息
-///
-///
-func (this *FightEvent) OffKey(key string) {
-
-}
-
-///
-/// 重置事件中心
-///
-func (this *FightEvent) Clear() {
-
-}
diff --git a/modules/battle/fight/fightlog.go b/modules/battle/fight/fightlog.go
deleted file mode 100644
index 9f066928c..000000000
--- a/modules/battle/fight/fightlog.go
+++ /dev/null
@@ -1,17 +0,0 @@
-package fight
-
-import "go_dreamfactory/modules/battle/fight/core"
-
-//战报
-type FightLog struct {
- FightBase core.IFight
- Commands []interface{}
-}
-
-///
-/// 增加战报日志
-///
-///
-func (this *FightLog) AddCommand(object interface{}) {
- this.Commands = append(this.Commands, object)
-}
diff --git a/modules/battle/fight/fightrole.go b/modules/battle/fight/fightrole.go
index 305897dad..0642c6b82 100644
--- a/modules/battle/fight/fightrole.go
+++ b/modules/battle/fight/fightrole.go
@@ -1,92 +1,123 @@
package fight
import (
- "fmt"
- "go_dreamfactory/modules/battle/fight/attribute"
"go_dreamfactory/modules/battle/fight/core"
+ "go_dreamfactory/modules/battle/fight/skill"
+ "go_dreamfactory/modules/battle/fight/skill/afteratk"
cfg "go_dreamfactory/sys/configure/structs"
)
///战斗角色
type FightRole struct {
- ///
- /// 战斗实例
- ///
fight core.IFight
- ///
- /// 角色数据
- ///
- data core.FightRoleData
- currentHealth *attribute.HealthPoint
+ data *core.FightRoleData
}
-func (this *FightRole) GetCurrentHealth() *attribute.HealthPoint {
- return this.currentHealth
+///获取战斗控制器
+func (this *FightRole) GetFight() core.IFight {
+ return this.fight
}
-func (this *FightRole) Initialize(pData core.FightRoleData) {
- // this.data = pData
- // this.currentHealth = attribute.NewHealthPoint(this.data.Hp)
- // this.currentHealth.Reset()
- // this.data.BuffStore.OwnerRole = this
- // this.data.PassiveStore.OwnerRole = this
+///获取战斗控制器
+func (this *FightRole) GetData() *core.FightRoleData {
+ return this.data
}
-///
-/// 接收伤害
-///
-func (this *FightRole) ReceiveDamage(DamageValue float32) {
- this.currentHealth.Minus(DamageValue)
- // FightDebug.Log($"========接收伤害:{Data.UniqueId} 变化值={DamageValue} 当前血量={currentHealth.Value}");
- if this.IsDead() {
- //有不死buff生命值设置为1
- for _, v := range this.data.BuffStore.GetHasBuffTypes() {
- if v == cfg.GameBuffType_UNDEAD {
- this.currentHealth.Hp.SetFloat(1)
- break
- }
+/// 增加一个主技能
+func (this *FightRole) AddSkill(skillId int32, skillLv int32) core.ISkill {
+ var (
+ skillConf *cfg.GameSkillAtkData
+ _skill core.ISkill
+ ok bool
+ )
+ skillConf = this.fight.GetSkillConfig(skillId, skillLv).(*cfg.GameSkillAtkData)
+ if skillConf == nil {
+ this.fight.Errorf("找不到技能配置 ID={%d},Lv={%d}", skillId, skillLv)
+ return _skill
+ }
+ if _skill, ok = this.data.Skills[skillId]; !ok {
+ _skill = skill.NewFightSkill(this, skillConf, skillLv)
+ this.data.Skills[skillId] = _skill
+ }
+ return _skill
+}
+
+/// 获取一个AfterSkill,不存在时会初始化
+func (this *FightRole) GetAfterAtk(skillId int32) core.IAfterSkill {
+ var (
+ _skill core.IAfterSkill
+ conf *cfg.GameSkillAfteratkData
+ ok bool
+ )
+ if _skill, ok = this.data.AfterSkills[skillId]; !ok {
+ conf = this.fight.GetSkillConfig(skillId, 1).(*cfg.GameSkillAfteratkData)
+ if conf == nil {
+ this.fight.Errorf("子技能配置未null ID={%d}", skillId)
+ return nil
}
-
- this.Dead()
+ switch conf.Type {
+ /// 伤害类
+ case cfg.GameSkillEffectType_Dmg:
+ case cfg.GameSkillEffectType_NowHpDps:
+ case cfg.GameSkillEffectType_MaxDmg:
+ case cfg.GameSkillEffectType_FrontDmg:
+ _skill = afteratk.NewFightDmgSkill(this, conf)
+ break
+ /// 治疗
+ case cfg.GameSkillEffectType_Tre:
+ _skill = afteratk.NewFightTreSkill(this, conf)
+ break
+ case cfg.GameSkillEffectType_AveTre:
+ _skill = afteratk.NewFightAveTreSkill(this, conf)
+ break
+ ///属性类
+ case cfg.GameSkillEffectType_RobPro:
+ _skill = afteratk.NewFightAveTreSkill(this, conf)
+ break
+ ///Buff类
+ case cfg.GameSkillEffectType_AddBuff:
+ _skill = afteratk.NewFightAddBuffSkill(this, conf)
+ break
+ case cfg.GameSkillEffectType_BuffCD:
+ _skill = afteratk.NewFightBuffCDSkill(this, conf)
+ break
+ case cfg.GameSkillEffectType_RemoveDebuff:
+ _skill = afteratk.NewFightRemoveDebuffSkill(this, conf)
+ break
+ case cfg.GameSkillEffectType_ShiftBuff:
+ _skill = afteratk.NewFightShiftBuffSkill(this, conf)
+ break
+ ///Passive类
+ case cfg.GameSkillEffectType_AddPas:
+ _skill = afteratk.NewFightAddPasSkill(this, conf)
+ break
+ case cfg.GameSkillEffectType_SkillCD:
+ _skill = afteratk.NewFightSkillCDSkill(this, conf)
+ break
+ case cfg.GameSkillEffectType_AddActValue:
+ _skill = afteratk.NewFightAddActValueSkill(this, conf)
+ break
+ case cfg.GameSkillEffectType_DrawActValue:
+ _skill = afteratk.NewFightDrawActValueSkill(this, conf)
+ break
+ case cfg.GameSkillEffectType_RandBuff:
+ _skill = afteratk.NewFightRandBuffSkill(this, conf)
+ break
+ case cfg.GameSkillEffectType_DpsByAddBuff:
+ _skill = afteratk.NewFightDpsByAddBuffSkill(this, conf)
+ break
+ case cfg.GameSkillEffectType_Round:
+ _skill = afteratk.NewFightRoundSkill(this, conf)
+ break
+ case cfg.GameSkillEffectType_TreBeyondByAddBuff:
+ _skill = afteratk.NewFightDpsByAddBuffSkill(this, conf)
+ break
+ // 通用类
+ default:
+ _skill = skill.NewFightAfterSkill(this, conf)
+ break
+ }
+ this.data.AfterSkills[skillId] = _skill
}
-}
-
-func (this *FightRole) IsDead() bool {
- return this.currentHealth.Value() <= 0
-}
-func (this *FightRole) Dead() {
- this.data.ALive = false
-}
-
-///
-/// 战斗结束时的清理
-///
-func (this *FightRole) Clear() {
- //清理所有技能
- for _, v := range this.data.Skills {
- v.Clear()
- }
-
- //清理所有攻击后技能
- for _, v := range this.data.AfterSkills {
- v.Clear()
- }
-
- //清理所有buff
- this.data.BuffStore.ForEach(func(buff core.IBuff) {
- buff.Clear()
- })
- // //清理所有被动就能
- this.data.PassiveStore.ForEach(func(fp core.IFightPassive) {
- fp.Clear()
- })
-
- //清空
- this.data.Skills = make(map[int32]core.ISkill)
- this.data.AfterSkills = make(map[int]core.IAfterSkill)
- this.data.BuffStore.Clear()
- this.data.PassiveStore.Clear()
-}
-func (this *FightRole) ToString() string {
- return fmt.Sprintf("[%s]", this.data.Name)
+ return _skill
}
diff --git a/modules/battle/fight/fighttarget.go b/modules/battle/fight/fighttarget.go
deleted file mode 100644
index 66412fb20..000000000
--- a/modules/battle/fight/fighttarget.go
+++ /dev/null
@@ -1,213 +0,0 @@
-package fight
-
-import "go_dreamfactory/modules/battle/fight/core"
-
-//From-------------------------------------------------------------------------------------------------------
-///
-/// 从roles里,过滤出符合From设定的对象List
-///
-/// 筛选前List
-/// 用哪个技能来筛选
-/// 筛选后List
-func From(roles []core.IFightRole, skill core.IAfterSkill) []core.IFightRole {
- from := skill.GetAfterSkillConf().From
- if from == int32(core.AferSkillFromType_TriggerPassiveFrom) {
- if source, ok := skill.GetOwnerRole().GetData().PassiveStore.TryGetPassive(skill.GetSourceSkillId()); ok && source.GetTriggerPassiveRole() != nil {
- return []core.IFightRole{source.GetTriggerPassiveRole()}
- } else {
- // FightDebug.Error("没有找到该子技能的SourceSkill 或者 该被动的触发者为null")
- }
- return []core.IFightRole{}
- }
- return nil
-}
-
-///
-/// 从roles里,过滤出符合设定的对象List
-///
-/// 筛选前List
-/// 当前行动role
-/// afterSkill里设置的From
-///
-func FromByType(roles []core.IFightRole, actionRole core.IFightRole, from int) []core.IFightRole {
- switch core.AferSkillFromType(from) {
- case core.AferSkillFromType_All:
- // 选所有
- return roles
- case core.AferSkillFromType_Friend: // 只选友方
- result := make([]core.IFightRole, 0)
- for _, role := range roles {
- if role.GetData().ALive && role.GetData().Side == actionRole.GetData().Side {
- result = append(result, role)
- }
- }
- return result
- case core.AferSkillFromType_Enemy: // 只选敌方
- result := make([]core.IFightRole, 0)
- for _, role := range roles {
- if role.GetData().ALive && role.GetData().Side != actionRole.GetData().Side {
- result = append(result, role)
- }
- }
- return result
- case core.AferSkillFromType_Self: // 只选自己
- return []core.IFightRole{actionRole}
- case core.AferSkillFromType_PlayerChoose:
- // 只选skillAtk里选择的目标
- if actionRole.GetData().LastChooseTarget == nil {
- // 如果主技能是个被动, 则此值会为空
- actionRole.GetData().LastChooseTarget = make([]int, 0)
- }
- result := make([]core.IFightRole, 0)
- for _, role := range roles {
- if role.GetData().ALive {
- for _, v := range actionRole.GetData().LastChooseTarget {
- if v == role.GetData().Rid {
- result = append(result, role)
- }
- }
- }
- }
- return result
- case core.AferSkillFromType_FriendExceptSelf:
- result := make([]core.IFightRole, 0)
- for _, role := range roles {
- if role.GetData().ALive && role.GetData().Side == actionRole.GetData().Side && role != actionRole {
- result = append(result, role)
- }
- }
- return result
- case core.AferSkillFromType_EnemyExceptChoose: // 除选定目标外的其他敌方
- result := make([]core.IFightRole, 0)
- for _, role := range roles {
- if role.GetData().ALive && role.GetData().Side != actionRole.GetData().Side {
- iskeep := false
- for _, v := range actionRole.GetData().LastChooseTarget {
- if v == role.GetData().Rid {
- iskeep = true
- }
- }
- if iskeep {
- result = append(result, role)
- }
- }
- }
- return result
- case core.AferSkillFromType_FriendExceptChoose: // 除选定目标外的其他友方
- result := make([]core.IFightRole, 0)
- for _, role := range roles {
- if role.GetData().ALive && role.GetData().Side == actionRole.GetData().Side {
- iskeep := false
- for _, v := range actionRole.GetData().LastChooseTarget {
- if v == role.GetData().Rid {
- iskeep = true
- }
- }
- if iskeep {
- result = append(result, role)
- }
- }
- }
- return result
- }
- return []core.IFightRole{}
-}
-
-///
-/// 从roles里,过滤出符合设定的对象List
-///
-/// 筛选前List
-/// 当前行动role
-/// afterSkill里设置的From
-///
-func FightTargetFrom(roles []core.IFightRole, actionRole core.IFightRole, from int32) []core.IFightRole {
- switch from {
- case int32(core.AferSkillFromType_All):
- // 选所有
- return roles
- case int32(core.AferSkillFromType_Friend):
- // 只选友方
- result := make([]core.IFightRole, 0)
- // roles.FindAll(role => role.Data.Side == actionRole.Data.Side);
- for _, v := range roles {
- if v.GetData().Side == actionRole.GetData().Side {
- result = append(result, v)
- }
- }
- return result
- case int32(core.AferSkillFromType_Enemy):
- // 只选敌方
- // return roles.FindAll(role => role.Data.Side != actionRole.Data.Side);
- // 只选友方
- result := make([]core.IFightRole, 0)
- // roles.FindAll(role => role.Data.Side == actionRole.Data.Side);
- for _, v := range roles {
- if v.GetData().Side != actionRole.GetData().Side {
- result = append(result, v)
- }
- }
- return result
- case int32(core.AferSkillFromType_Self):
- // 只选自己
- return []core.IFightRole{actionRole}
- case int32(core.AferSkillFromType_PlayerChoose):
- // 只选skillAtk里选择的目标
- // return roles.FindAll(role => actionRole.Data.LastChooseTarget.Contains(role.Data.Rid));
- result := make([]core.IFightRole, 0)
- // roles.FindAll(role => role.Data.Side == actionRole.Data.Side);
- for _, v := range roles {
- for _, v1 := range actionRole.GetData().LastChooseTarget {
- if v.GetData().Rid == v1 {
- result = append(result, v)
- break
- }
- }
- }
- return result
-
- case int32(core.AferSkillFromType_FriendExceptSelf):
- // 除自己外的友方
- // return roles.FindAll(role => role.Data.Side == actionRole.Data.Side && role != actionRole);
- result := make([]core.IFightRole, 0)
- // roles.FindAll(role => role.Data.Side == actionRole.Data.Side);
- for _, v := range roles {
- if v.GetData().Side == actionRole.GetData().Side && v != actionRole {
- result = append(result, v)
- }
- }
- return result
- case int32(core.AferSkillFromType_EnemyExceptChoose):
- // 除选定目标外的其他敌方
- // return roles.FindAll(role => role.Data.Side != actionRole.Data.Side && !actionRole.Data.LastChooseTarget.Contains(role.Data.Rid));
- result := make([]core.IFightRole, 0)
- for _, v := range roles {
- if v.GetData().Side != actionRole.GetData().Side {
- for _, v1 := range actionRole.GetData().LastChooseTarget {
- if v.GetData().Rid == v1 {
- result = append(result, v)
- break
- }
- }
- }
- }
- return result
- case int32(core.AferSkillFromType_FriendExceptChoose):
- // 除选定目标外的其他敌方
- // return roles.FindAll(role => role.Data.Side != actionRole.Data.Side && !actionRole.Data.LastChooseTarget.Contains(role.Data.Rid));
- result := make([]core.IFightRole, 0)
- for _, v := range roles {
- if v.GetData().Side != actionRole.GetData().Side {
- for _, v1 := range actionRole.GetData().LastChooseTarget {
- if v.GetData().Rid == v1 {
- result = append(result, v)
- break
- }
- }
- }
- }
- return result
- // 除选定目标外的其他友方
- // return roles.FindAll(role => role.Data.Side == actionRole.Data.Side && !actionRole.Data.LastChooseTarget.Contains(role.Data.Rid));
- }
- return []core.IFightRole{}
-}
diff --git a/modules/battle/fight/options.go b/modules/battle/fight/options.go
new file mode 100644
index 000000000..d553e9346
--- /dev/null
+++ b/modules/battle/fight/options.go
@@ -0,0 +1,46 @@
+package fight
+
+import (
+ "go_dreamfactory/lego/sys/log"
+ "go_dreamfactory/modules/battle/fight/core"
+)
+
+type Option func(*Options)
+type Options struct {
+ Debug bool //日志是否开启
+ Log log.ILogger
+ battle core.IBattle //战斗模块对象
+}
+
+func Set_Battle(v core.IBattle) Option {
+ return func(o *Options) {
+ o.battle = v
+ }
+}
+func Set_Debug(v bool) Option {
+ return func(o *Options) {
+ o.Debug = v
+ }
+}
+
+func Set_Log(v log.ILogger) Option {
+ return func(o *Options) {
+ o.Log = v
+ }
+}
+
+func newOptionsByOption(opts ...Option) (options *Options, err error) {
+ options = &Options{}
+ for _, o := range opts {
+ o(options)
+ }
+ if options.Log == nil {
+ if options.Debug {
+ options.Log = log.NewTurnlog(options.Debug, log.Clone("fight", 4))
+ } else {
+ options.Log = log.NewTurnlog(options.Debug, nil)
+ }
+ }
+
+ return options, nil
+}
diff --git a/modules/battle/fight/passive/fightcallskillpas.go b/modules/battle/fight/passive/fightcallskillpas.go
deleted file mode 100644
index af8b981ac..000000000
--- a/modules/battle/fight/passive/fightcallskillpas.go
+++ /dev/null
@@ -1,50 +0,0 @@
-package passive
-
-import (
- "fmt"
- "go_dreamfactory/modules/battle/fight/core"
-)
-
-func NewFightCallSkillPas() core.IFightPassive {
- return &FightCallSkillPas{}
-}
-
-///
-/// 通用调用技能和子技能
-///
-type FightCallSkillPas struct {
- FightPassive
-}
-
-func (this *FightCallSkillPas) OnEvent(argu []interface{}) {
- this.FightPassive.OnEvent(argu)
- this.ApplyAfterAtk()
-}
-
-///
-/// 执行子技能
-///
-func (this *FightCallSkillPas) ApplyAfterAtk() {
- // FightDebug.Log("触发被动执行子技能")
- for _, skillId := range this.PassiveConf.Callback {
- if fmt.Sprintf("%d", skillId)[0] == '1' {
- this.OwnerRole.GetFightBase().AddPassiveMainSkill(this.OwnerRole, skillId)
- } else {
- afterSkill := this.OwnerRole.GetAfterAtk(skillId)
- if afterSkill == nil {
- continue
- }
- // 当前子技能的技能来源为当前被动
- afterSkill.SetSourceSkillId(this.PassiveConf.Id)
- //直接执行(执行成功才写入日志)
- if afterSkill.Emit() {
- //如果是其他子技能触发的就把日志写入该子技能中 不是就直接发送日志
- if this.EmitAfterSkill != nil {
- this.EmitAfterSkill.AddSkillLog(afterSkill.GetSkillLog())
- return
- }
- afterSkill.SendSkillLog()
- }
- }
- }
-}
diff --git a/modules/battle/fight/passive/fightpassive.go b/modules/battle/fight/passive/fightpassive.go
deleted file mode 100644
index 0a0a7a2a0..000000000
--- a/modules/battle/fight/passive/fightpassive.go
+++ /dev/null
@@ -1,424 +0,0 @@
-package passive
-
-import (
- "fmt"
- "go_dreamfactory/modules/battle/fight"
- "go_dreamfactory/modules/battle/fight/buff"
- "go_dreamfactory/modules/battle/fight/core"
- cfg "go_dreamfactory/sys/configure/structs"
- "strconv"
-)
-
-type FightPassive struct {
- buff.FightBuffBase
- ///
- /// skillPassive 配置
- ///
- PassiveConf cfg.GameSkillPassiveData
- ///
- /// 这个被动是哪个角色给我施加的
- ///
- FromRole core.IFightRole
- ///
- /// 被动持有者
- ///
- OwnerRole core.IFightRole
- ///
- /// 触发被动的发起者(该角色触发了被动执行此子技能)
- ///
- TriggerPassiveRole core.IFightRole
- ///
- /// 触发被动的角色目标(该角色触发了被动执行此子技能)
- ///
- TriggerPassiveTarget core.IFightRole
- ///
- /// 条件检测参数
- ///
- AddConArgs core.MapString
- ///
- /// 触发此被动的子技能Id
- ///
- EmitAfterSkillId int32
- EventType core.EventType
- ///
- /// 触发此被动的子技能(需要把战报输入到这个子技能中)
- ///
- EmitAfterSkill core.IAfterSkill
- ///
- /// 被动CD
- ///
- CD int
- ///
- /// 当前CD =0 才能触发
- ///
- CurrentCD int
- ///
- /// 每回合累计触发次数
- ///
- TotalEmitTimes int
-}
-
-func (this *FightPassive) GetTriggerPassiveRole() core.IFightRole {
- return this.TriggerPassiveRole
-}
-
-func (this *FightPassive) OnActivate(param float32) {
- this.EventType = this.CurEvent()
- this.InitEvent()
-}
-
-//绑定被动-------------------------
-///
-/// 初始化事件
-///
-func (this *FightPassive) InitEvent() {
- eventIndex := int(this.EventType)
- if eventIndex != -1 {
- this.OwnerRole.GetFightBase().GetFightEvent().OnForInt(
- eventIndex,
- this.OnReceiveEvent,
- )
- }
-}
-func (this *FightPassive) OnReceiveEvent(argu []interface{}) {
- if !this.CheckEmit() {
- return
- }
- if !this.CheckWhere(argu) {
- return
- }
- this.FromRole.GetFightBase().Debugf("角色 %d 被动技能 %d 执行, 触发子技能: %d", this.OwnerRole.GetData().UniqueId, this.PassiveConf.Id, this.EmitAfterSkillId)
- this.OnEvent(argu)
- this.TotalEmitTimes++
- this.EmitAfterSkill = nil
- this.EmitAfterSkillId = 0
- this.TriggerPassiveRole = nil
- this.TriggerPassiveTarget = nil
-}
-
-///
-/// 接收到事件
-///
-func (this *FightPassive) OnEvent(argu []interface{}) {
-}
-
-//触发被动---------------------------------------------------------------------------
-func (this *FightPassive) CheckEmit() bool {
- //需要先检查cd 再判断当前回合是否触发达上限
- // FightDebug.Log($"{OwnerRole.Data.Rid}被动{PassiveConf.Id}当前CD={CurrentCD}TotalEmitTimes ={TotalEmitTimes},触发事件={EventType}");
- if this.CurrentCD != 0 || int32(this.TotalEmitTimes) >= this.PassiveConf.MaxEmitTimes {
- return false
- }
- randVal := int32(this.OwnerRole.GetFightBase().Rand(1, 1000))
- // FightDebug.Log($"{OwnerRole.Data.Rid}被动技能 {PassiveConf.Id} 触发几率判断:{randVal}");
- return randVal <= this.PassiveConf.PasPr
-}
-
-//检测逻辑----------------------------------------------------------------------------
-func (this *FightPassive) CheckWhere(argu []interface{}) bool {
- switch this.EventType {
- case core.EventType_OnRoundStart: // 角色回合行动前
- case core.EventType_OnRoundEnd: // 角色回合结束后
- case core.EventType_OnSkillStart: // 行动结束前
- case core.EventType_OnSkillEnd: // 行动结束后
- // 参数 [发起者, ]
- if !this.CheckTarget(argu[0].(core.IFightRole)) {
- return false
- }
- break
- case core.EventType_OnPreEffect: // 准备执行效果前
- // 参数 [发起者, afterSkill]
- if !this.CheckTarget(argu[0].(core.IFightRole)) {
- return false
- }
- if !this.CheckCondition(argu[1].(core.IAfterSkill)) {
- return false
- }
- this.EmitAfterSkill = argu[1].(core.IAfterSkill)
- this.EmitAfterSkillId = this.EmitAfterSkill.GetAfterSkillConf().Id
- break
- case core.EventType_OnPostGiveEffect: // 施加效果时
- case core.EventType_OnPreReceiveEffect: // 受到效果执行前
- case core.EventType_OnPostReceiveEffect: // 受到效果时
- case core.EventType_OnPostGiveLostShield: // 击破护盾时
- case core.EventType_OnPostReceiveLostShield: // 护盾被击破时
- case core.EventType_OnDamage: // 造成伤害
- case core.EventType_OnBeDamage: // 受到伤害
- case core.EventType_OnPreTre: // 造成治疗前
- case core.EventType_OnTreEnd: // 造成治疗后
- case core.EventType_OnPreBeTre: // 受到治疗前
- case core.EventType_OnBeTreEnd: // 受到治疗后
- // 参数 [发起者, 目标者, afterSkill]
- if !this.CheckTarget(argu[0].(core.IFightRole)) {
- return false // , argu[1] as FightRole
- }
- if !this.CheckCondition(argu[2].(core.IAfterSkill)) {
- return false
- }
- this.EmitAfterSkill = argu[2].(core.IAfterSkill)
- this.EmitAfterSkillId = this.EmitAfterSkill.GetAfterSkillConf().Id
- this.TriggerPassiveTarget = argu[1].(core.IFightRole)
- break
- case core.EventType_OnPostGiveCriCal: // 暴击时
- case core.EventType_OnPostReceiveCriCal: // 被暴击时
- // 参数 [发起者, 目标者, 是否暴击, afterSkill]
- if !this.CheckTarget(argu[0].(core.IFightRole)) {
- return false // , argu[1] as FightRole
- }
- if !this.CheckCriCal(argu[2].(int)) {
- return false
- }
- this.EmitAfterSkill = argu[3].(core.IAfterSkill)
- this.EmitAfterSkillId = this.EmitAfterSkill.GetAfterSkillConf().Id
- this.TriggerPassiveTarget = argu[1].(core.IFightRole)
- break
- case core.EventType_OnCalcDmgEffect: // 受到伤害计算后
- // 参数 [发起者, 目标者, 是否致死, afterSkill]
- if !this.CheckTarget(argu[0].(core.IFightRole)) {
- return false // , argu[1] as FightRole
- }
- if !this.CheckDeadDmg(argu[2].(int)) {
- return false
- }
- this.EmitAfterSkill = argu[3].(core.IAfterSkill)
- this.EmitAfterSkillId = this.EmitAfterSkill.GetAfterSkillConf().Id
- this.TriggerPassiveTarget = argu[1].(core.IFightRole)
- break
- case core.EventType_OnDeathDmg: // 受致死伤害后
- // 参数 [发起者, 目标者]
- if !this.CheckTarget(argu[0].(core.IFightRole)) {
- return false // , argu[1] as FightRole
- }
- if !this.CheckDeadDmg(argu[2].(int)) {
- return false
- }
- this.TriggerPassiveTarget = argu[1].(core.IFightRole)
- break
- case core.EventType_OnKill:
- // 参数 [发起者, 目标者, afterSkill]
- if !this.CheckTarget(argu[0].(core.IFightRole)) {
- return false // , argu[1] as FightRole
- }
- if !this.CheckKillCondition(argu[2].(core.IAfterSkill)) {
- return false
- }
- this.TriggerPassiveTarget = argu[1].(core.IFightRole)
- break
- case core.EventType_OnRemoveBuffEnd:
- case core.EventType_OnAddBuff:
- // 参数 [发起者, 目标者, buff效果类型,是否成功,afterSkill]
- if !this.CheckTarget(argu[0].(core.IFightRole)) {
- return false // , argu[1] as FightRole
- }
- if !this.CheckBuffCondition(argu[2].(int), argu[3].(bool)) {
- return false
- }
- this.TriggerPassiveTarget = argu[1].(core.IFightRole)
- break
- }
- this.TriggerPassiveRole = argu[0].(core.IFightRole)
- return true
-}
-
-func (this *FightPassive) CheckKillCondition(skill core.IAfterSkill) bool {
- for key, vlaue := range this.AddConArgs {
- switch key {
- case "SkillID": //死于某技能
- if skill == nil {
- return false
- }
- return fmt.Sprintf("%d", skill.GetAfterSkillConf().Id) == vlaue
- }
- }
- return true
-}
-
-func (this *FightPassive) CheckBuffCondition(effect int, succ bool) bool {
- for key, vlaue := range this.AddConArgs {
- switch key {
- case "EffType": //buff效果类型
- if fmt.Sprintf("%d", effect) != vlaue {
- return false
- }
- if result, ok := this.AddConArgs.TryGetInt("Result"); !ok {
- // FightDebug.Error($"{PassiveConf.Id}参数配置错误EffType后面必须指定目标Result");
- return false
- } else {
- if succ {
- return result == 1
- } else {
- return result == 0
- }
- }
- }
- }
- return true
-}
-
-///
-/// 检测目标
-///
-/// 发起者
-/// 目标者
-func (this *FightPassive) CheckTarget(pLaunch core.IFightRole) bool {
- // FightDebug.Log("开始目标检测-++++++++++++");
- switch this.PassiveConf.TargetCheck {
- case 0: // 全体
- return true
- case 1: // 友方
- // 检测所有友军身上有没有目标为友军,施加效果时检测,并且效果标签为治疗的被动
- return this.OwnerRole.GetData().Side == pLaunch.GetData().Side
- case 2: // 敌方
- // 检测敌方所有角色身上有没有目标为敌军,施加效果时检测,并且效果标签为治疗的被动
- return pLaunch.GetData().Side != this.OwnerRole.GetData().Side
- case 3: // 自身
- // 检测自身身上有没有目标为自身,施加效果时检测,并且效果标签为治疗的被动
- return this.OwnerRole.GetData().Rid == pLaunch.GetData().Rid
- case 4: // 不包含自身的友方
- // 不包含自身友军
- return this.OwnerRole.GetData().Side == pLaunch.GetData().Side && this.OwnerRole.GetData().Rid != pLaunch.GetData().Rid
- }
- // FightDebug.Log("目标检测不通过-++++++++++++");
- return false
-}
-
-///
-/// 检测暴击
-///
-func (this *FightPassive) CheckCriCal(pCriCal int) bool {
- if CriRely, ok := this.AddConArgs.TryGetInt("CriRely"); !ok {
- return true
- } else {
- return CriRely == pCriCal
- }
-}
-
-///
-/// 检测是否致死伤害
-///
-func (this *FightPassive) CheckDeadDmg(pDead int) bool {
- if LetDmg, ok := this.AddConArgs.TryGetInt("LetDmg"); !ok {
- return true
- } else {
- return LetDmg == pDead
- }
-}
-
-///
-/// 条件检测
-///
-/// 发起者
-/// 目标者
-/// afterSkill
-///
-func (this *FightPassive) CheckCondition(afterSkill core.IAfterSkill) bool {
- // FightDebug.Log("开始条件检测-++++++++++++");
- for key, vlaue := range this.AddConArgs {
- vint, _ := strconv.Atoi(vlaue)
- switch key {
- case "Hpproless": //目标血量低于多少
- if target, ok := this.AddConArgs.TryGetInt("Target"); !ok {
- // FightDebug.Error($"{PassiveConf.Id}参数配置错误Hpproless后面必须指定目标Target");
- return false
- } else {
- var list = fight.FromByType(this.OwnerRole.GetFightBase().GetRoles(), this.OwnerRole, target)
- conform := false
- for _, v := range list {
- var pre float32 = 0
- if core.TryGetValue(v, int(core.PropertyType_NowHp_Per), &pre) && pre < float32(vint) {
- conform = true
- }
- }
- if !conform {
- return false
- }
- }
- break
- case "EffID":
- if afterSkill.GetAfterSkillConf().Type != cfg.GameSkillEffectType_AddBuff {
- return false
- }
- if afterSkill.GetSkillArgs()[0] != vint {
- return false
- }
- break
- case "EffType":
- if afterSkill.GetAfterSkillConf().Type != cfg.GameSkillEffectType_AddBuff {
- return false
- }
- var buffId = afterSkill.GetSkillArgs()[0]
- var buffConf = this.OwnerRole.GetFightBase().GetSkillConfig(buffId, 1).(*cfg.GameSkillBuffData)
- if buffConf == nil {
- // FightDebug.Error($"子技能{afterSkill.AfterSkillConf.Id}参数配置添加buffID={buffId}没有配置");
- return false
- }
- if int(buffConf.BuffType) != vint {
- return false
- }
- break
- }
- }
- // FightDebug.Log("条件检测通过-++++++++++++");
- return true
-}
-
-func (this *FightPassive) CurEvent() core.EventType {
- switch this.PassiveConf.When {
- // 全局事件
- case "RouFro":
- return core.EventType_OnRoundStart
- case "RouEnd":
- return core.EventType_OnRoundEnd
-
- // 角色事件
- case "EffFro":
- return core.EventType_OnPreEffect
- case "ImpEff":
- return core.EventType_OnPostGiveEffect
- case "SufEffFro":
- return core.EventType_OnPreReceiveEffect
- case "SufDmg":
- return core.EventType_OnCalcDmgEffect
- case "SufEff":
- return core.EventType_OnPostReceiveEffect
- case "CriCal":
- return core.EventType_OnPostGiveCriCal
- case "CovCriCal":
- return core.EventType_OnPostReceiveCriCal
- case "ActEndFro":
- case "SkillStart":
- return core.EventType_OnSkillStart
- case "ActEnd":
- return core.EventType_OnSkillEnd
- case "ShieldBro":
- return core.EventType_OnPostReceiveLostShield
- case "BreShield":
- return core.EventType_OnPostGiveLostShield
- case "Damage":
- return core.EventType_OnDamage
- case "BeDamage":
- return core.EventType_OnBeDamage
-
- case "Kill":
- return core.EventType_OnKill
- case "TreStart":
- return core.EventType_OnPreTre
- case "TreEnd":
- return core.EventType_OnTreEnd
- case "PreBeTre":
- return core.EventType_OnPreBeTre
- case "BeTreEnd":
- return core.EventType_OnBeTreEnd
- case "RemoveBuffEnd":
- return core.EventType_OnRemoveBuffEnd
- case "AddBuff":
- return core.EventType_OnAddBuff
- }
-
- // FightDebug.Log($"被动技能触发时机{PassiveConf.When}配置错误");
- return core.EventType_None
-}
-
-func (this *FightPassive) Clear() {
-
-}
diff --git a/modules/battle/fight/skill/afteratk/fightaddactvalueskill.go b/modules/battle/fight/skill/afteratk/fightaddactvalueskill.go
index 564c9c792..a026f437f 100644
--- a/modules/battle/fight/skill/afteratk/fightaddactvalueskill.go
+++ b/modules/battle/fight/skill/afteratk/fightaddactvalueskill.go
@@ -1,10 +1,18 @@
package afteratk
-import "go_dreamfactory/modules/battle/fight/skill"
+import (
+ "go_dreamfactory/modules/battle/fight/core"
+ "go_dreamfactory/modules/battle/fight/skill"
+ cfg "go_dreamfactory/sys/configure/structs"
+)
-///
-/// 修改目标行动值
-///
-type FightAddActValueSkill struct {
- skill.FightAfterSkill
+func NewFightAddActValueSkill(role core.IFightRole, skillConf *cfg.GameSkillAfteratkData) (skill *FightAddActValueSkill) {
+ skill = &FightAddActValueSkill{}
+ skill.Init(skill, role, skillConf)
+ return
+}
+
+///Passive类
+type FightAddActValueSkill struct {
+ skill.FightlEffectSkill
}
diff --git a/modules/battle/fight/skill/afteratk/fightaddbuffskill.go b/modules/battle/fight/skill/afteratk/fightaddbuffskill.go
index f68bbe181..724231f1c 100644
--- a/modules/battle/fight/skill/afteratk/fightaddbuffskill.go
+++ b/modules/battle/fight/skill/afteratk/fightaddbuffskill.go
@@ -1,10 +1,18 @@
package afteratk
-import "go_dreamfactory/modules/battle/fight/skill"
+import (
+ "go_dreamfactory/modules/battle/fight/core"
+ "go_dreamfactory/modules/battle/fight/skill"
+ cfg "go_dreamfactory/sys/configure/structs"
+)
-///
-/// 添加buff
-///
-type FightAddBuffSkill struct {
- skill.FightAfterSkill
+func NewFightAddBuffSkill(role core.IFightRole, skillConf *cfg.GameSkillAfteratkData) (skill *FightAddBuffSkill) {
+ skill = &FightAddBuffSkill{}
+ skill.Init(skill, role, skillConf)
+ return
+}
+
+///Buff
+type FightAddBuffSkill struct {
+ skill.FightlEffectSkill
}
diff --git a/modules/battle/fight/skill/afteratk/fightaddpasskill.go b/modules/battle/fight/skill/afteratk/fightaddpasskill.go
index b1ce37a93..87341939b 100644
--- a/modules/battle/fight/skill/afteratk/fightaddpasskill.go
+++ b/modules/battle/fight/skill/afteratk/fightaddpasskill.go
@@ -1,7 +1,18 @@
package afteratk
-import "go_dreamfactory/modules/battle/fight/skill"
+import (
+ "go_dreamfactory/modules/battle/fight/core"
+ "go_dreamfactory/modules/battle/fight/skill"
+ cfg "go_dreamfactory/sys/configure/structs"
+)
-type FightAddPasSkill struct {
- skill.FightAfterSkill
+func NewFightAddPasSkill(role core.IFightRole, skillConf *cfg.GameSkillAfteratkData) (skill *FightAddPasSkill) {
+ skill = &FightAddPasSkill{}
+ skill.Init(skill, role, skillConf)
+ return
+}
+
+///Passive类
+type FightAddPasSkill struct {
+ skill.FightlEffectSkill
}
diff --git a/modules/battle/fight/skill/afteratk/fightavetreskill.go b/modules/battle/fight/skill/afteratk/fightavetreskill.go
index 4d1b7a1b3..6d71ecfe1 100644
--- a/modules/battle/fight/skill/afteratk/fightavetreskill.go
+++ b/modules/battle/fight/skill/afteratk/fightavetreskill.go
@@ -1,7 +1,18 @@
package afteratk
-import "go_dreamfactory/modules/battle/fight/skill"
+import (
+ "go_dreamfactory/modules/battle/fight/core"
+ "go_dreamfactory/modules/battle/fight/skill"
+ cfg "go_dreamfactory/sys/configure/structs"
+)
-type FightAveTreSkill struct {
- skill.FightAfterSkill
+func NewFightAveTreSkill(role core.IFightRole, skillConf *cfg.GameSkillAfteratkData) (skill *FightAveTreSkill) {
+ skill = &FightAveTreSkill{}
+ skill.Init(skill, role, skillConf)
+ return
+}
+
+///伤害
+type FightAveTreSkill struct {
+ skill.FightlEffectSkill
}
diff --git a/modules/battle/fight/skill/afteratk/fightbuffcdskill.go b/modules/battle/fight/skill/afteratk/fightbuffcdskill.go
index 030800be8..3791ca090 100644
--- a/modules/battle/fight/skill/afteratk/fightbuffcdskill.go
+++ b/modules/battle/fight/skill/afteratk/fightbuffcdskill.go
@@ -1,10 +1,18 @@
package afteratk
-import "go_dreamfactory/modules/battle/fight/skill"
+import (
+ "go_dreamfactory/modules/battle/fight/core"
+ "go_dreamfactory/modules/battle/fight/skill"
+ cfg "go_dreamfactory/sys/configure/structs"
+)
-///
-/// BUFF回合类操作
-///
-type FightBuffCDSkill struct {
- skill.FightAfterSkill
+func NewFightBuffCDSkill(role core.IFightRole, skillConf *cfg.GameSkillAfteratkData) (skill *FightBuffCDSkill) {
+ skill = &FightBuffCDSkill{}
+ skill.Init(skill, role, skillConf)
+ return
+}
+
+///Buff
+type FightBuffCDSkill struct {
+ skill.FightlEffectSkill
}
diff --git a/modules/battle/fight/skill/afteratk/fightdmgskill.go b/modules/battle/fight/skill/afteratk/fightdmgskill.go
index db75b4e7c..bc0ee8948 100644
--- a/modules/battle/fight/skill/afteratk/fightdmgskill.go
+++ b/modules/battle/fight/skill/afteratk/fightdmgskill.go
@@ -1,7 +1,18 @@
package afteratk
-import "go_dreamfactory/modules/battle/fight/skill"
+import (
+ "go_dreamfactory/modules/battle/fight/core"
+ "go_dreamfactory/modules/battle/fight/skill"
+ cfg "go_dreamfactory/sys/configure/structs"
+)
-type FightDmgSkill struct {
- skill.FightAfterSkill
+func NewFightDmgSkill(role core.IFightRole, skillConf *cfg.GameSkillAfteratkData) (skill *FightDmgSkill) {
+ skill = &FightDmgSkill{}
+ skill.Init(skill, role, skillConf)
+ return
+}
+
+///伤害
+type FightDmgSkill struct {
+ skill.FightlEffectSkill
}
diff --git a/modules/battle/fight/skill/afteratk/fightdpsbyaddbuffskill.go b/modules/battle/fight/skill/afteratk/fightdpsbyaddbuffskill.go
index 17dcbd302..ee97ce318 100644
--- a/modules/battle/fight/skill/afteratk/fightdpsbyaddbuffskill.go
+++ b/modules/battle/fight/skill/afteratk/fightdpsbyaddbuffskill.go
@@ -1,10 +1,18 @@
package afteratk
-import "go_dreamfactory/modules/battle/fight/skill"
+import (
+ "go_dreamfactory/modules/battle/fight/core"
+ "go_dreamfactory/modules/battle/fight/skill"
+ cfg "go_dreamfactory/sys/configure/structs"
+)
-///
-/// 添加buff(从之前技能的效果值中取参数)
-///
-type FightDpsByAddBuffSkill struct {
- skill.FightAfterSkill
+func NewFightDpsByAddBuffSkill(role core.IFightRole, skillConf *cfg.GameSkillAfteratkData) (skill *FightDpsByAddBuffSkill) {
+ skill = &FightDpsByAddBuffSkill{}
+ skill.Init(skill, role, skillConf)
+ return
+}
+
+///Passive类
+type FightDpsByAddBuffSkill struct {
+ skill.FightlEffectSkill
}
diff --git a/modules/battle/fight/skill/afteratk/fightdrawactvalueskill.go b/modules/battle/fight/skill/afteratk/fightdrawactvalueskill.go
index 05274c056..678b92ee4 100644
--- a/modules/battle/fight/skill/afteratk/fightdrawactvalueskill.go
+++ b/modules/battle/fight/skill/afteratk/fightdrawactvalueskill.go
@@ -1,10 +1,18 @@
package afteratk
-import "go_dreamfactory/modules/battle/fight/skill"
+import (
+ "go_dreamfactory/modules/battle/fight/core"
+ "go_dreamfactory/modules/battle/fight/skill"
+ cfg "go_dreamfactory/sys/configure/structs"
+)
-///
-/// 吸收目标行动值
-///
-type FightDrawActValueSkill struct {
- skill.FightAfterSkill
+func NewFightDrawActValueSkill(role core.IFightRole, skillConf *cfg.GameSkillAfteratkData) (skill *FightDrawActValueSkill) {
+ skill = &FightDrawActValueSkill{}
+ skill.Init(skill, role, skillConf)
+ return
+}
+
+///Passive类
+type FightDrawActValueSkill struct {
+ skill.FightlEffectSkill
}
diff --git a/modules/battle/fight/skill/afteratk/fightrandbuffskill.go b/modules/battle/fight/skill/afteratk/fightrandbuffskill.go
index 0cac80620..c42cfdb48 100644
--- a/modules/battle/fight/skill/afteratk/fightrandbuffskill.go
+++ b/modules/battle/fight/skill/afteratk/fightrandbuffskill.go
@@ -1,10 +1,18 @@
package afteratk
-import "go_dreamfactory/modules/battle/fight/skill"
+import (
+ "go_dreamfactory/modules/battle/fight/core"
+ "go_dreamfactory/modules/battle/fight/skill"
+ cfg "go_dreamfactory/sys/configure/structs"
+)
-///
-/// 随机buff
-///
-type FightRandBuffSkill struct {
- skill.FightAfterSkill
+func NewFightRandBuffSkill(role core.IFightRole, skillConf *cfg.GameSkillAfteratkData) (skill *FightRandBuffSkill) {
+ skill = &FightRandBuffSkill{}
+ skill.Init(skill, role, skillConf)
+ return
+}
+
+///Passive类
+type FightRandBuffSkill struct {
+ skill.FightlEffectSkill
}
diff --git a/modules/battle/fight/skill/afteratk/fightremovedebuffskill.go b/modules/battle/fight/skill/afteratk/fightremovedebuffskill.go
index 93449f6a1..5ab0dc1f0 100644
--- a/modules/battle/fight/skill/afteratk/fightremovedebuffskill.go
+++ b/modules/battle/fight/skill/afteratk/fightremovedebuffskill.go
@@ -1,7 +1,18 @@
package afteratk
-import "go_dreamfactory/modules/battle/fight/skill"
+import (
+ "go_dreamfactory/modules/battle/fight/core"
+ "go_dreamfactory/modules/battle/fight/skill"
+ cfg "go_dreamfactory/sys/configure/structs"
+)
-type FightRemoveDebuffSkill struct {
- skill.FightAfterSkill
+func NewFightRemoveDebuffSkill(role core.IFightRole, skillConf *cfg.GameSkillAfteratkData) (skill *FightRemoveDebuffSkill) {
+ skill = &FightRemoveDebuffSkill{}
+ skill.Init(skill, role, skillConf)
+ return
+}
+
+///Buff
+type FightRemoveDebuffSkill struct {
+ skill.FightlEffectSkill
}
diff --git a/modules/battle/fight/skill/afteratk/fightrobproskill.go b/modules/battle/fight/skill/afteratk/fightrobproskill.go
index 23033936e..ee28aac5f 100644
--- a/modules/battle/fight/skill/afteratk/fightrobproskill.go
+++ b/modules/battle/fight/skill/afteratk/fightrobproskill.go
@@ -1,10 +1,18 @@
package afteratk
-import "go_dreamfactory/modules/battle/fight/skill"
+import (
+ "go_dreamfactory/modules/battle/fight/core"
+ "go_dreamfactory/modules/battle/fight/skill"
+ cfg "go_dreamfactory/sys/configure/structs"
+)
-///
-/// 抢夺目标属性
-///
-type FightRobProSkill struct {
- skill.FightAfterSkill
+func NewFightRobProSkill(role core.IFightRole, skillConf *cfg.GameSkillAfteratkData) (skill *FightRobProSkill) {
+ skill = &FightRobProSkill{}
+ skill.Init(skill, role, skillConf)
+ return
+}
+
+///伤害
+type FightRobProSkill struct {
+ skill.FightlEffectSkill
}
diff --git a/modules/battle/fight/skill/afteratk/fightroundskill.go b/modules/battle/fight/skill/afteratk/fightroundskill.go
index eaf0e58b1..2f9227911 100644
--- a/modules/battle/fight/skill/afteratk/fightroundskill.go
+++ b/modules/battle/fight/skill/afteratk/fightroundskill.go
@@ -1,10 +1,18 @@
package afteratk
-import "go_dreamfactory/modules/battle/fight/skill"
+import (
+ "go_dreamfactory/modules/battle/fight/core"
+ "go_dreamfactory/modules/battle/fight/skill"
+ cfg "go_dreamfactory/sys/configure/structs"
+)
-///
-/// 立即获得回合
-///
-type FightRoundSkill struct {
- skill.FightAfterSkill
+func NewFightRoundSkill(role core.IFightRole, skillConf *cfg.GameSkillAfteratkData) (skill *FightRoundSkill) {
+ skill = &FightRoundSkill{}
+ skill.Init(skill, role, skillConf)
+ return
+}
+
+///Passive类
+type FightRoundSkill struct {
+ skill.FightlEffectSkill
}
diff --git a/modules/battle/fight/skill/afteratk/fightshiftbuffskill.go b/modules/battle/fight/skill/afteratk/fightshiftbuffskill.go
index caf9e2a8b..3a9e25dba 100644
--- a/modules/battle/fight/skill/afteratk/fightshiftbuffskill.go
+++ b/modules/battle/fight/skill/afteratk/fightshiftbuffskill.go
@@ -1,17 +1,18 @@
package afteratk
-import "go_dreamfactory/modules/battle/fight/skill"
+import (
+ "go_dreamfactory/modules/battle/fight/core"
+ "go_dreamfactory/modules/battle/fight/skill"
+ cfg "go_dreamfactory/sys/configure/structs"
+)
-///
-/// 转嫁buff
-///
+func NewFightShiftBuffSkill(role core.IFightRole, skillConf *cfg.GameSkillAfteratkData) (skill *FightShiftBuffSkill) {
+ skill = &FightShiftBuffSkill{}
+ skill.Init(skill, role, skillConf)
+ return
+}
+
+///Buff
type FightShiftBuffSkill struct {
- skill.FightAfterSkill
-}
-
-///
-/// 执行技能逻辑
-///
-func (this *FightShiftBuffSkill) DoLogic() {
-
+ skill.FightlEffectSkill
}
diff --git a/modules/battle/fight/skill/afteratk/fightskillcdskill.go b/modules/battle/fight/skill/afteratk/fightskillcdskill.go
index c29994d8b..190c1c997 100644
--- a/modules/battle/fight/skill/afteratk/fightskillcdskill.go
+++ b/modules/battle/fight/skill/afteratk/fightskillcdskill.go
@@ -1,17 +1,18 @@
package afteratk
-import "go_dreamfactory/modules/battle/fight/skill"
+import (
+ "go_dreamfactory/modules/battle/fight/core"
+ "go_dreamfactory/modules/battle/fight/skill"
+ cfg "go_dreamfactory/sys/configure/structs"
+)
-///
-/// Skill回合类操作
-///
+func NewFightSkillCDSkill(role core.IFightRole, skillConf *cfg.GameSkillAfteratkData) (skill *FightSkillCDSkill) {
+ skill = &FightSkillCDSkill{}
+ skill.Init(skill, role, skillConf)
+ return
+}
+
+///Passive类
type FightSkillCDSkill struct {
- skill.FightAfterSkill
-}
-
-///
-/// 执行技能逻辑
-///
-func (this *FightSkillCDSkill) DoLogic() {
-
+ skill.FightlEffectSkill
}
diff --git a/modules/battle/fight/skill/afteratk/fighttreskill.go b/modules/battle/fight/skill/afteratk/fighttreskill.go
index 9b62b663d..655e3c26b 100644
--- a/modules/battle/fight/skill/afteratk/fighttreskill.go
+++ b/modules/battle/fight/skill/afteratk/fighttreskill.go
@@ -1,19 +1,18 @@
package afteratk
-import "go_dreamfactory/modules/battle/fight/skill"
+import (
+ "go_dreamfactory/modules/battle/fight/core"
+ "go_dreamfactory/modules/battle/fight/skill"
+ cfg "go_dreamfactory/sys/configure/structs"
+)
+func NewFightTreSkill(role core.IFightRole, skillConf *cfg.GameSkillAfteratkData) (skill *FightTreSkill) {
+ skill = &FightTreSkill{}
+ skill.Init(skill, role, skillConf)
+ return
+}
+
+///治疗
type FightTreSkill struct {
skill.FightlEffectSkill
}
-
-///
-/// 执行技能逻辑
-///
-func (this *FightTreSkill) DoLogic() {
-
-}
-
-func (this *FightTreSkill) Clear() {
- this.FightlEffectSkill.Clear()
- this.EffectValue = 0
-}
diff --git a/modules/battle/fight/skill/fightafterskill.go b/modules/battle/fight/skill/fightafterskill.go
index 975ab88fb..0388c11de 100644
--- a/modules/battle/fight/skill/fightafterskill.go
+++ b/modules/battle/fight/skill/fightafterskill.go
@@ -1,29 +1,158 @@
package skill
-import "go_dreamfactory/modules/battle/fight/core"
+import (
+ "go_dreamfactory/modules/battle/fight/core"
+ cfg "go_dreamfactory/sys/configure/structs"
+)
+func NewFightAfterSkill(role core.IFightRole, skillConf *cfg.GameSkillAfteratkData) (skill *FightAfterSkill) {
+ skill = &FightAfterSkill{}
+ skill.Init(skill, role, skillConf)
+ return
+}
+
+/// 子技能
type FightAfterSkill struct {
- ///
- /// 技能效果是否生效
- ///
- TakeEffect bool
-
- ///
+ SkillBase
+ /// 当前技能对象
+ skill core.IAfterSkill
+ fight core.IFight
+ /// 从哪个角色的技能
+ OwnerRole core.IFightRole
+ /// 子技能配置
+ AfterSkillConf *cfg.GameSkillAfteratkData
+ ///技能目标
+ Targets []core.IFightRole
+ /// 技能来源ID
+ /// skillAtk id 主技能id
+ /// skillAfterat id 子技能的后续子技能, 表示父技能
+ SourceSkillId int32
+ /// 技能参数
+ SkillArgs []int32
/// 子技能效果列表
- ///
ComList []*core.ComEffectSkill
+ ///执行次数
+ DoVal int32
+ /// 技能效果是否生效
+ TakeEffect bool
}
-///
-/// 子技能增加战报日志
-///
-func (this *FightAfterSkill) AddLog(pCom *core.ComEffectSkill) {
- this.ComList = append(this.ComList, pCom)
+func (this *FightAfterSkill) SetSourceSkillId(skill int32) {
+ this.SourceSkillId = skill
+}
+
+func (this *FightAfterSkill) GetDoVal() int32 {
+ return this.DoVal
+}
+
+/// 发送技能日志
+func (this *FightAfterSkill) Init(askill core.IAfterSkill, role core.IFightRole, skillConf *cfg.GameSkillAfteratkData) {
+ this.skill = askill
+ this.fight = role.GetFight()
+ this.OwnerRole = role
+ this.AfterSkillConf = skillConf
+ this.SkillArgs = skillConf.Argu
+}
+
+/// 触发技能
+func (this *FightAfterSkill) Emit() bool {
+ if this.skill.CheckEmit() {
+ this.fight.Debugf("{%s}.{%d} 触发子技能:{%d}", this.OwnerRole.GetData().UniqueId, this.SourceSkillId, this.AfterSkillConf.Id)
+ // 每个子技能执行前触发
+ this.fight.GetFightEvent().Emit(int(core.EventType_OnPreEffect), this.OwnerRole, this)
+ this.skill.DoLogic()
+ if this.TakeEffect {
+ this.DoTakeEffectSK()
+ } else {
+ this.DoLoseEfficacySK()
+ }
+ this.skill.Clear()
+ return true
+ }
+ return false
+}
+
+/// 检查是否符合释放条件
+func (this *FightAfterSkill) CheckEmit() bool {
+ randVal := this.fight.Rand(1, 1000)
+ this.fight.Debugf("{%d} 的子技能 {%d} 触发几率判断:{%d}", this.SourceSkillId, this.AfterSkillConf.Id, randVal)
+ if randVal > this.AfterSkillConf.EmitPR {
+ return false
+ }
+ return true
+}
+
+func (this *FightAfterSkill) DoLogic() {
+ this.fight.Debugf("子技能通用逻辑:{%d}", this.AfterSkillConf.Id)
+}
+
+///技能效果生效之后触发调用
+func (this *FightAfterSkill) DoTakeEffectSK() {
+ this.fight.Debugf("技能效果生效成功触发:{%d}, SucFollowSK: {%d}", this.AfterSkillConf.Id, len(this.AfterSkillConf.SucFollowSK))
+ var (
+ askill core.IAfterSkill
+ )
+ for _, v := range this.AfterSkillConf.SucFollowSK {
+ askill = this.OwnerRole.GetAfterAtk(v)
+ askill.SetSourceSkillId(this.AfterSkillConf.Id)
+ if askill.Emit() {
+ this.AddSkillLog(askill.GetSkillLog())
+ }
+ }
+}
+
+///技能效果失败之后触发调用
+func (this *FightAfterSkill) DoLoseEfficacySK() {
+ this.fight.Debugf("技能效果生效失败触发:{%d}, FailFollowSK: {%d}", this.AfterSkillConf.Id, len(this.AfterSkillConf.FailFollowSK))
+ var (
+ askill core.IAfterSkill
+ )
+ for _, v := range this.AfterSkillConf.FailFollowSK {
+ askill = this.OwnerRole.GetAfterAtk(v)
+ askill.SetSourceSkillId(this.AfterSkillConf.Id)
+ if askill.Emit() {
+ this.AddSkillLog(askill.GetSkillLog())
+ }
+ }
+}
+
+/// 释放成功后续子技能(有目标且满足概率)
+func (this *FightAfterSkill) DoFollowSK() {
+ this.fight.Debugf("释放成功<后续子技能>触发:{%d}, FollowSK: {%d}", this.AfterSkillConf.Id, len(this.AfterSkillConf.FollowSK))
+ var (
+ askill core.IAfterSkill
+ )
+ for _, v := range this.AfterSkillConf.FollowSK {
+ askill = this.OwnerRole.GetAfterAtk(v)
+ askill.SetSourceSkillId(this.AfterSkillConf.Id)
+ if askill.Emit() {
+ this.AddSkillLog(askill.GetSkillLog())
+ }
+ }
}
-///
-/// 战斗结束时的清理
-///
func (this *FightAfterSkill) Clear() {
this.TakeEffect = false
}
+
+///添加子技能日志
+func (this *FightAfterSkill) AddSkillLog(afterAtk *core.ComSkillAfterAtk) {
+ this.AfterSkillList = append(this.AfterSkillList, afterAtk)
+}
+
+///获取自己的技能日志(子技能使用)
+func (this *FightAfterSkill) GetSkillLog() *core.ComSkillAfterAtk {
+ afterAtk := core.NewComSkillAfterAtk()
+ afterAtk.ComList = append(afterAtk.ComList, this.ComList...)
+ if this.Targets != nil {
+ for _, v := range this.Targets {
+ afterAtk.Targets = append(afterAtk.Targets, v.GetData().Rid)
+ }
+ }
+ afterAtk.FollowSkills = append(afterAtk.FollowSkills, this.AfterSkillList...)
+ afterAtk.Skillid = this.AfterSkillConf.Id
+ afterAtk.From = this.OwnerRole.GetData().Rid
+ this.ComList = this.ComList[:0]
+ this.AfterSkillList = this.AfterSkillList[:0]
+ return afterAtk
+}
diff --git a/modules/battle/fight/skill/fightleffectskill.go b/modules/battle/fight/skill/fightleffectskill.go
index 80371e173..bc4ce164d 100644
--- a/modules/battle/fight/skill/fightleffectskill.go
+++ b/modules/battle/fight/skill/fightleffectskill.go
@@ -1,11 +1,8 @@
package skill
+/// 效果类子技能
type FightlEffectSkill struct {
FightAfterSkill
+ /// 效果值
EffectValue float32
}
-
-func (this *FightlEffectSkill) Clear() {
- this.FightAfterSkill.Clear()
- this.EffectValue = 0
-}
diff --git a/modules/battle/fight/skill/fightskill.go b/modules/battle/fight/skill/fightskill.go
index 5fa8f08bf..6218323df 100644
--- a/modules/battle/fight/skill/fightskill.go
+++ b/modules/battle/fight/skill/fightskill.go
@@ -5,74 +5,61 @@ import (
cfg "go_dreamfactory/sys/configure/structs"
)
+func NewFightSkill(role core.IFightRole, skillConf *cfg.GameSkillAtkData, skillLv int32) *FightSkill {
+ return &FightSkill{
+ fight: role.GetFight(),
+ ownerRole: role,
+ skillConf: skillConf,
+ skillLv: skillLv,
+ childSkillsId: skillConf.ChildSkill.Id,
+ }
+}
+
///
/// 主动/队长技能
///
-///
-/// 遍历触发子技能
-///
type FightSkill struct {
- OwnerRole core.IFightRole
- CD int32
- SkillConf *cfg.GameSkillAtkData
+ SkillBase
+ fight core.IFight
+ /// 本技能归属于哪个Role
+ ownerRole core.IFightRole
+ /// skillAtk 技能配置
+ skillConf *cfg.GameSkillAtkData
+ /// 技能等级
+ skillLv int32
+ /// 子技能id
+ childSkillsId []int32
+}
+
+/// 发送技能日志
+func (this *FightSkill) GetSkillConf() *cfg.GameSkillAtkData {
+ return this.skillConf
}
-///
/// 触发
/// 遍历所有ChildSkills,生成对应的实例,并Emit触发
-///
func (this *FightSkill) Emit() {
-
-}
-
-///
-/// 减少CD回合数
-///
-/// 新的回合数
-func (this *FightSkill) MinusCD(val int32) int32 {
- if this.CD > 0 {
- this.CD -= val
- if this.CD < 0 {
- this.CD = 0
+ this.fight.Debugf("主技能触发:%d", this.skillConf.Id)
+ var (
+ askill core.IAfterSkill
+ )
+ for _, v := range this.childSkillsId {
+ askill = this.ownerRole.GetAfterAtk(v)
+ askill.SetSourceSkillId(this.skillConf.Id)
+ for i := 0; i < int(askill.GetDoVal()); i++ {
+ askill.Emit()
+ //不管有没有释放成功都需要推送日志
+ this.AddSkillLog(askill.GetSkillLog())
}
- this.SetCD(this.CD)
}
- return this.CD
}
-///
-/// 增加CD回合数
-///
-/// 新的回合数
-func (this *FightSkill) ResetCD() int32 {
- this.CD = this.SkillConf.CD
- this.SetCD(this.CD)
- return this.CD
+///添加子技能日志
+func (this *FightSkill) AddSkillLog(afterAtk *core.ComSkillAfterAtk) {
+ this.AfterSkillList = append(this.AfterSkillList, afterAtk)
}
-///
-/// 设置CD回合数为新的值
-///
-///
-///
-func (this *FightSkill) SetCD(newVal int32) int32 {
- this.CD = newVal
- //记录战报
- com := new(core.ComSetSkillCD)
- com.From = this.OwnerRole.GetData().Rid
- com.Skillid = this.SkillConf.Id
- com.Nv = byte(newVal)
- // this.OwnerRole.GetFightBase().FightLog.AddCommand(com)
-
- return this.CD
-}
-
-/// 发送技能日志
-func (this *FightSkill) Clear() {
-
-}
-
-/// 发送技能日志
+/// 发送技能日志
func (this *FightSkill) SendSkillLog() {
}
diff --git a/modules/battle/fight/skill/skillbase.go b/modules/battle/fight/skill/skillbase.go
new file mode 100644
index 000000000..f8c76ab96
--- /dev/null
+++ b/modules/battle/fight/skill/skillbase.go
@@ -0,0 +1,7 @@
+package skill
+
+import "go_dreamfactory/modules/battle/fight/core"
+
+type SkillBase struct {
+ AfterSkillList []*core.ComSkillAfterAtk
+}
diff --git a/modules/battle/fight/utils.go b/modules/battle/fight/utils.go
deleted file mode 100644
index b98513ba2..000000000
--- a/modules/battle/fight/utils.go
+++ /dev/null
@@ -1,70 +0,0 @@
-package fight
-
-import (
- "go_dreamfactory/modules/battle/fight/core"
- "math/rand"
-)
-
-//战斗角色排序
-func FightRoleSort(arr []core.IFightRole, pType string, pOrder core.EOrderType) []core.IFightRole {
- if len(arr) <= 1 {
- return arr
- }
- pivot := arr[rand.Intn(len(arr))]
- lowPart := make([]core.IFightRole, 0, len(arr))
- highPart := make([]core.IFightRole, 0, len(arr))
- middlePart := make([]core.IFightRole, 0, len(arr))
- for _, v := range arr {
- switch pType {
- case "OperateValue":
- switch {
- case v.GetData().Operate.Value() < pivot.GetData().Operate.Value():
- if pOrder == core.EOrderType_Asc {
- lowPart = append(lowPart, v)
- } else {
- highPart = append(highPart, v)
- }
- break
- case v.GetData().Operate.Value() == pivot.GetData().Operate.Value():
- middlePart = append(middlePart, v)
- break
- case v.GetData().Operate.Value() > pivot.GetData().Operate.Value():
- if pOrder == core.EOrderType_Asc {
- highPart = append(highPart, v)
- } else {
- lowPart = append(lowPart, v)
- }
- break
- }
- break
- case "Speed":
- switch {
- case v.GetData().Speed.Value() < pivot.GetData().Speed.Value():
- if pOrder == core.EOrderType_Asc {
- lowPart = append(lowPart, v)
- } else {
- highPart = append(highPart, v)
- }
- break
- case v.GetData().Speed.Value() == pivot.GetData().Speed.Value():
- middlePart = append(middlePart, v)
- break
- case v.GetData().Speed.Value() > pivot.GetData().Speed.Value():
- if pOrder == core.EOrderType_Asc {
- highPart = append(highPart, v)
- } else {
- lowPart = append(lowPart, v)
- }
- break
- }
- break
- }
- }
- lowPart = FightRoleSort(lowPart, pType, pOrder)
- highPart = FightRoleSort(highPart, pType, pOrder)
-
- lowPart = append(lowPart, middlePart...)
- lowPart = append(lowPart, highPart...)
- return lowPart
-
-}
diff --git a/modules/comp_model.go b/modules/comp_model.go
index 5b7193ea9..b2de5dc30 100644
--- a/modules/comp_model.go
+++ b/modules/comp_model.go
@@ -86,8 +86,13 @@ func (this *MCompModel) ChangeList(uid string, _id string, data map[string]inter
}
//读取全部数据
-func (this *MCompModel) Get(uid string, data interface{}, opt ...db.DBOption) (err error) {
- return this.DBModel.Get(uid, data, opt...)
+func (this *MCompModel) Get(id string, data interface{}, opt ...db.DBOption) (err error) {
+ return this.DBModel.Get(id, data, opt...)
+}
+
+//读取多个数据对象
+func (this *MCompModel) Gets(ids []string, data interface{}, opt ...db.DBOption) (err error) {
+ return this.DBModel.Gets(ids, data, opt...)
}
//获取列表数据 注意 data 必须是 切片的指针 *[]type
@@ -120,11 +125,16 @@ func (this *MCompModel) GetListObjs(uid string, ids []string, data interface{})
return this.DBModel.GetListObjs(uid, ids, data)
}
-//删除用户数据
+//删除目标数据
func (this *MCompModel) Del(uid string, opt ...db.DBOption) (err error) {
return this.DBModel.Del(uid, opt...)
}
+//删除用户数据
+func (this *MCompModel) DelByUId(uid string, opt ...db.DBOption) (err error) {
+ return this.DBModel.DelByUId(uid, opt...)
+}
+
//删除多条数据
func (this *MCompModel) DelListlds(uid string, ids ...string) (err error) {
return this.DBModel.DelListlds(uid, ids...)
diff --git a/modules/moonfantasy/api_ask.go b/modules/moonfantasy/api_ask.go
index 75950619a..12160f77b 100644
--- a/modules/moonfantasy/api_ask.go
+++ b/modules/moonfantasy/api_ask.go
@@ -18,17 +18,19 @@ func (this *apiComp) AskCheck(session comm.IUserSession, req *pb.MoonfantasyAskR
func (this *apiComp) Ask(session comm.IUserSession, req *pb.MoonfantasyAskReq) (code pb.ErrorCode, data proto.Message) {
var (
globalconf *cfg.GameGlobalData
- mdata *pb.DBMoonfantasy
+ mdata *pb.DBMoonFantasy
+ umfantasy *pb.DBUserMFantasy
+ user *pb.DBUser
cd pb.ErrorCode
err error
)
defer func() {
- session.SendMsg(string(this.module.GetType()), "ask", &pb.MoonfantasyAskResp{Code: cd})
+ session.SendMsg(string(this.module.GetType()), "ask", &pb.MoonfantasyAskResp{Code: cd, Info: mdata})
}()
if cd = this.AskCheck(session, req); cd != pb.ErrorCode_Success {
return
}
- if mdata, err = this.module.modelDream.queryDreamData(req.Uid, req.Mid); err != nil {
+ if mdata, err = this.module.modelDream.querymfantasy(req.Mid); err != nil {
cd = pb.ErrorCode_DBError
return
}
@@ -36,7 +38,7 @@ func (this *apiComp) Ask(session comm.IUserSession, req *pb.MoonfantasyAskReq) (
cd = pb.ErrorCode_MoonfantasyHasExpired
return
}
- if mdata.Joinnum >= mdata.Numup {
+ if len(mdata.Join) >= int(mdata.Numup) {
cd = pb.ErrorCode_MoonfantasyJoinUp
return
}
@@ -44,6 +46,7 @@ func (this *apiComp) Ask(session comm.IUserSession, req *pb.MoonfantasyAskReq) (
globalconf = this.module.configure.GetGlobalConf()
if time.Now().Sub(time.Unix(mdata.Ctime, 0)).Seconds() >= float64(globalconf.DreamlandLimit) {
+ this.module.modelDream.Del(mdata.Id)
cd = pb.ErrorCode_MoonfantasyHasExpired
return
}
@@ -53,5 +56,28 @@ func (this *apiComp) Ask(session comm.IUserSession, req *pb.MoonfantasyAskReq) (
return
}
}
+ if umfantasy, err = this.module.modelUserMF.QueryUsermfantasy(session.GetUserId()); err != nil {
+ code = pb.ErrorCode_CacheReadError
+ return
+ }
+ umfantasy.Mfantasys = append(umfantasy.Mfantasys, mdata.Id)
+ this.module.modelUserMF.Change(session.GetUserId(), map[string]interface{}{
+ "mfantasys": umfantasy.Mfantasys,
+ })
+
+ for _, v := range mdata.Join {
+ if v.Uid == session.GetUserId() {
+ return
+ }
+ }
+ if user = this.module.ModuleUser.GetUser(session.GetUserId()); user == nil {
+ this.module.Errorf("no found uer:%d", session.GetUserId())
+ code = pb.ErrorCode_DBError
+ return
+ }
+ mdata.Join = append(mdata.Join, &pb.UserInfo{Uid: user.Uid, Name: user.Name, Avatar: user.Avatar})
+ this.module.modelDream.Change(mdata.Id, map[string]interface{}{
+ "join": mdata.Join,
+ })
return
}
diff --git a/modules/moonfantasy/api_battle.go b/modules/moonfantasy/api_battle.go
index e2ce3f1a6..3782cdf59 100644
--- a/modules/moonfantasy/api_battle.go
+++ b/modules/moonfantasy/api_battle.go
@@ -19,17 +19,18 @@ func (this *apiComp) Battle(session comm.IUserSession, req *pb.MoonfantasyBattle
var (
globalconf *cfg.GameGlobalData
boss *cfg.GameDreamlandBoosData
- mdata *pb.DBMoonfantasy
+ mdata *pb.DBMoonFantasy
record *pb.DBBattleRecord
cd pb.ErrorCode
+ isjoin bool
err error
)
defer func() {
if cd == pb.ErrorCode_Success {
session.SendMsg(string(this.module.GetType()), "battle", &pb.MoonfantasyBattleResp{
- Code: cd,
- Monster: mdata.Monster,
+ Code: cd,
+ Mid: mdata.Monster,
Info: &pb.BattleInfo{
Id: record.Id,
Title: record.Title,
@@ -50,7 +51,7 @@ func (this *apiComp) Battle(session comm.IUserSession, req *pb.MoonfantasyBattle
if cd = this.BattleCheck(session, req); cd != pb.ErrorCode_Success {
return
}
- if mdata, err = this.module.modelDream.queryDreamData(req.Uid, req.Mid); err != nil {
+ if mdata, err = this.module.modelDream.querymfantasy(req.Mid); err != nil {
cd = pb.ErrorCode_DBError
return
}
@@ -59,12 +60,22 @@ func (this *apiComp) Battle(session comm.IUserSession, req *pb.MoonfantasyBattle
return
}
+ for _, v := range mdata.Join {
+ if v.Uid == session.GetUserId() {
+ isjoin = true
+ }
+ }
+ if !isjoin {
+ cd = pb.ErrorCode_MoonfantasyNoJoin
+ return
+ }
+
if boss, err = this.module.configure.GetMonsterById(mdata.Monster); err != nil {
cd = pb.ErrorCode_ConfigNoFound
return
}
- if mdata.Joinnum >= mdata.Numup {
+ if len(mdata.Join) >= int(mdata.Numup) {
cd = pb.ErrorCode_MoonfantasyJoinUp
return
}
diff --git a/modules/moonfantasy/api_getlist.go b/modules/moonfantasy/api_getlist.go
new file mode 100644
index 000000000..09ef3c2d1
--- /dev/null
+++ b/modules/moonfantasy/api_getlist.go
@@ -0,0 +1,34 @@
+package moonfantasy
+
+import (
+ "go_dreamfactory/comm"
+ "go_dreamfactory/lego/sys/mgo"
+ "go_dreamfactory/pb"
+
+ "google.golang.org/protobuf/proto"
+)
+
+//参数校验
+func (this *apiComp) GetlistCheck(session comm.IUserSession, req *pb.MoonfantasyGetListReq) (code pb.ErrorCode) {
+
+ return
+}
+
+///获取用户装备列表
+func (this *apiComp) Getlist(session comm.IUserSession, req *pb.MoonfantasyGetListReq) (code pb.ErrorCode, data proto.Message) {
+ var (
+ err error
+ umfantasy *pb.DBUserMFantasy
+ mfantasys []*pb.DBMoonFantasy = make([]*pb.DBMoonFantasy, 0)
+ )
+ if umfantasy, err = this.module.modelUserMF.QueryUsermfantasy(session.GetUserId()); err != nil && err != mgo.MongodbNil {
+ code = pb.ErrorCode_CacheReadError
+ return
+ }
+ if len(umfantasy.Mfantasys) > 0 {
+ mfantasys, err = this.module.modelDream.querymfantasys(umfantasy.Mfantasys)
+ }
+
+ session.SendMsg(string(this.module.GetType()), "getlist", &pb.MoonfantasyGetListResp{Dfantasys: mfantasys})
+ return
+}
diff --git a/modules/moonfantasy/api_receive.go b/modules/moonfantasy/api_receive.go
index ff5a74d29..98849ee4d 100644
--- a/modules/moonfantasy/api_receive.go
+++ b/modules/moonfantasy/api_receive.go
@@ -10,7 +10,7 @@ import (
//参数校验
func (this *apiComp) ReceiveCheck(session comm.IUserSession, req *pb.MoonfantasyReceiveReq) (code pb.ErrorCode) {
- if req.Bid == "" || req.Monster == "" {
+ if req.Bid == "" || req.Mid == "" {
code = pb.ErrorCode_ReqParameterError
}
return
@@ -28,7 +28,7 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.MoonfantasyRecei
if code = this.ReceiveCheck(session, req); code != pb.ErrorCode_Success {
return
}
- if boss, err = this.module.configure.GetMonsterById(req.Monster); err != nil {
+ if boss, err = this.module.configure.GetMonsterById(req.Mid); err != nil {
code = pb.ErrorCode_ConfigNoFound
return
}
diff --git a/modules/moonfantasy/api_trigger.go b/modules/moonfantasy/api_trigger.go
index 339b34ad3..e629b897e 100644
--- a/modules/moonfantasy/api_trigger.go
+++ b/modules/moonfantasy/api_trigger.go
@@ -19,16 +19,17 @@ func (this *apiComp) TriggerCheck(session comm.IUserSession, req *pb.Moonfantasy
///获取本服聊天消息记录
func (this *apiComp) Trigger(session comm.IUserSession, req *pb.MoonfantasyTriggerReq) (code pb.ErrorCode, data proto.Message) {
var (
+ user *pb.DBUser
+ umfantasy *pb.DBUserMFantasy
globalconf *cfg.GameGlobalData
uexpand *pb.DBUserExpand
boss *cfg.GameDreamlandBoosData
- mdata *pb.DBMoonfantasy
+ mdata *pb.DBMoonFantasy
chat *pb.DBChat
issucc bool
err error
)
-
if code = this.TriggerCheck(session, req); code != pb.ErrorCode_Success {
return
}
@@ -57,12 +58,23 @@ func (this *apiComp) Trigger(session comm.IUserSession, req *pb.MoonfantasyTrigg
code = pb.ErrorCode_ConfigNoFound
return
}
-
- if mdata, err = this.module.modelDream.addDreamData(session.GetUserId(), boss); err != nil {
+ if user = this.module.ModuleUser.GetUser(session.GetUserId()); user == nil {
+ this.module.Errorf("no found uer:%d", session.GetUserId())
code = pb.ErrorCode_DBError
return
}
-
+ if umfantasy, err = this.module.modelUserMF.QueryUsermfantasy(session.GetUserId()); err != nil {
+ code = pb.ErrorCode_CacheReadError
+ return
+ }
+ if mdata, err = this.module.modelDream.addDreamData(&pb.UserInfo{Uid: user.Uid, Name: user.Name, Avatar: user.Avatar}, boss); err != nil {
+ code = pb.ErrorCode_DBError
+ return
+ }
+ umfantasy.Mfantasys = append(umfantasy.Mfantasys, mdata.Id)
+ this.module.modelUserMF.Change(session.GetUserId(), map[string]interface{}{
+ "mfantasys": umfantasy.Mfantasys,
+ })
this.module.ModuleUser.ChangeUserExpand(session.GetUserId(), map[string]interface{}{
"moonfantasyTriggerNum": uexpand.MoonfantasyTriggerNum + 1,
"moonfantasyLastTrigger": time.Now().Unix(),
@@ -77,7 +89,7 @@ func (this *apiComp) Trigger(session comm.IUserSession, req *pb.MoonfantasyTrigg
Content: mdata.Monster,
AppendStr: mdata.Id,
}
- this.module.modelDream.noticeuserfriend(session.GetServiecTag(), session.GetUserId(), chat)
+ this.module.modelDream.noticeuserfriend(session.GetServiecTag(), session.GetUserId(), mdata.Id, chat)
session.SendMsg(string(this.module.GetType()), "trigger", &pb.MoonfantasyTriggerResp{Issucc: true, Mid: mdata.Id, Monster: mdata.Monster})
} else {
session.SendMsg(string(this.module.GetType()), "trigger", &pb.MoonfantasyTriggerResp{Issucc: false})
diff --git a/modules/moonfantasy/modelDream.go b/modules/moonfantasy/modelDream.go
index 9704a2d25..d0ce2856c 100644
--- a/modules/moonfantasy/modelDream.go
+++ b/modules/moonfantasy/modelDream.go
@@ -26,7 +26,8 @@ type modelDreamComp struct {
func (this *modelDreamComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, opt core.IModuleOptions) (err error) {
this.MCompModel.Init(service, module, comp, opt)
this.module = module.(*Moonfantasy)
- this.TableName = comm.TableMoonfantasy
+ this.TableName = comm.TableMoonFantasy
+ this.Expired = 0
//创建uid索引
this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{
Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}},
@@ -35,34 +36,43 @@ func (this *modelDreamComp) Init(service core.IService, module core.IModule, com
}
///添加月之秘境记录
-func (this *modelDreamComp) queryDreamData(uid string, mid string) (result *pb.DBMoonfantasy, err error) {
- result = &pb.DBMoonfantasy{}
- if err = this.GetListObj(uid, mid, result); err != nil && err != mongo.ErrNilDocument {
+func (this *modelDreamComp) querymfantasy(mid string) (result *pb.DBMoonFantasy, err error) {
+ result = &pb.DBMoonFantasy{}
+ if err = this.Get(mid, result); err != nil && err != mongo.ErrNilDocument {
this.module.Errorln(err)
}
return
}
+///插叙用户秘境列表
+func (this *modelDreamComp) querymfantasys(mids []string) (fantasys []*pb.DBMoonFantasy, err error) {
+ fantasys = make([]*pb.DBMoonFantasy, 0)
+ if err = this.Gets(mids, fantasys); err != nil {
+ this.module.Errorf("err:%v", err)
+ }
+ return
+}
+
///添加月之秘境记录
-func (this *modelDreamComp) addDreamData(uid string, boss *cfg.GameDreamlandBoosData) (result *pb.DBMoonfantasy, err error) {
- result = &pb.DBMoonfantasy{
+func (this *modelDreamComp) addDreamData(user *pb.UserInfo, boss *cfg.GameDreamlandBoosData) (result *pb.DBMoonFantasy, err error) {
+ result = &pb.DBMoonFantasy{
Id: primitive.NewObjectID().Hex(),
- Uid: uid,
+ Uid: user.Uid,
Monster: boss.Bossid,
Ctime: time.Now().Unix(),
- Joinnum: 0,
+ Join: []*pb.UserInfo{user},
Numup: boss.Challengenum,
Unitmup: boss.Fightnum,
Record: make(map[string]int32),
}
- if err = this.AddList(uid, result.Id, result); err != nil {
+ if err = this.Add(result.Id, result); err != nil {
this.module.Errorln(err)
}
return
}
///查询好友数据
-func (this *modelDreamComp) noticeuserfriend(stag, uid string, chat *pb.DBChat) (code pb.ErrorCode) {
+func (this *modelDreamComp) noticeuserfriend(stag, uid, mid string, chat *pb.DBChat) (code pb.ErrorCode) {
var (
err error
)
@@ -82,14 +92,22 @@ func (this *modelDreamComp) noticeuserfriend(stag, uid string, chat *pb.DBChat)
chat.Id = primitive.NewObjectID().Hex()
chat.Channel = pb.ChatChannel_World
// code = this.module.chat.SendWorldChat(stag, chat)
- this.delaynoticeWorld(stag, chat)
+ this.delaynoticeWorld(stag, mid, chat)
return
}
//延迟推送到 世界聊天频道
-func (this *modelDreamComp) delaynoticeWorld(stag string, chat *pb.DBChat) {
+func (this *modelDreamComp) delaynoticeWorld(stag, mid string, chat *pb.DBChat) {
timewheel.Add(time.Minute*15, func(t *timewheel.Task, i ...interface{}) {
- _chat := i[0].(*pb.DBChat)
+ _mid := i[0].(string)
+ _chat := i[1].(*pb.DBChat)
+ if mdata, err := this.querymfantasy(_mid); err != nil {
+ return
+ } else {
+ if len(mdata.Join) >= int(mdata.Numup) { //参与人数已达上限 不予推送
+ return
+ }
+ }
this.module.chat.SendWorldChat(_chat)
- }, chat)
+ }, mid, chat)
}
diff --git a/modules/moonfantasy/modelUserMF.go b/modules/moonfantasy/modelUserMF.go
new file mode 100644
index 000000000..9244451d6
--- /dev/null
+++ b/modules/moonfantasy/modelUserMF.go
@@ -0,0 +1,49 @@
+package moonfantasy
+
+import (
+ "go_dreamfactory/comm"
+ "go_dreamfactory/lego/core"
+ "go_dreamfactory/lego/sys/mgo"
+ "go_dreamfactory/modules"
+ "go_dreamfactory/pb"
+
+ "go.mongodb.org/mongo-driver/bson/primitive"
+ "go.mongodb.org/mongo-driver/mongo"
+ "go.mongodb.org/mongo-driver/x/bsonx"
+)
+
+///论坛 数据组件
+type modelUserMF struct {
+ modules.MCompModel
+ module *Moonfantasy
+}
+
+//组件初始化接口
+func (this *modelUserMF) Init(service core.IService, module core.IModule, comp core.IModuleComp, opt core.IModuleOptions) (err error) {
+ this.MCompModel.Init(service, module, comp, opt)
+ this.module = module.(*Moonfantasy)
+ this.TableName = comm.TableUserMFantasy
+ //创建uid索引
+ this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{
+ Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}},
+ })
+ return
+}
+
+///查询用户秘境列表
+func (this *modelUserMF) QueryUsermfantasy(uId string) (fantasy *pb.DBUserMFantasy, err error) {
+ fantasy = &pb.DBUserMFantasy{}
+ if err = this.Get(uId, &fantasy); err != nil && err != mgo.MongodbNil {
+ this.module.Errorf("err:%v", err)
+ }
+ if err == mgo.MongodbNil {
+ fantasy.Id = primitive.NewObjectID().Hex()
+ fantasy.Uid = uId
+ fantasy.Mfantasys = make([]string, 0)
+ if err = this.Add(uId, fantasy); err != nil {
+ this.module.Errorf("err:%v", err)
+ }
+ err = nil
+ }
+ return
+}
diff --git a/modules/moonfantasy/module.go b/modules/moonfantasy/module.go
index f6c4d3b99..3d635b96f 100644
--- a/modules/moonfantasy/module.go
+++ b/modules/moonfantasy/module.go
@@ -19,12 +19,13 @@ func NewModule() core.IModule {
type Moonfantasy struct {
modules.ModuleBase
- service base.IRPCXService
- chat comm.IChat
- battle comm.IBattle
- api_comp *apiComp
- configure *configureComp
- modelDream *modelDreamComp
+ service base.IRPCXService
+ chat comm.IChat
+ battle comm.IBattle
+ api_comp *apiComp
+ configure *configureComp
+ modelDream *modelDreamComp
+ modelUserMF *modelUserMF
}
//模块名
@@ -59,4 +60,5 @@ func (this *Moonfantasy) OnInstallComp() {
this.api_comp = this.RegisterComp(new(apiComp)).(*apiComp)
this.modelDream = this.RegisterComp(new(modelDreamComp)).(*modelDreamComp)
this.configure = this.RegisterComp(new(configureComp)).(*configureComp)
+ this.modelUserMF = this.RegisterComp(new(modelUserMF)).(*modelUserMF)
}
diff --git a/modules/shop/module.go b/modules/shop/module.go
index c8c23b5e4..95aaaa71d 100644
--- a/modules/shop/module.go
+++ b/modules/shop/module.go
@@ -45,5 +45,5 @@ func (this *Shop) OnInstallComp() {
//Event------------------------------------------------------------------------------------------------------------
func (this *Shop) EventUserOffline(session comm.IUserSession) {
- this.modelShop.Del(session.GetUserId(), db.SetDBMgoLog(false))
+ this.modelShop.DelByUId(session.GetUserId(), db.SetDBMgoLog(false))
}
diff --git a/modules/user/model_setting.go b/modules/user/model_setting.go
index 43aacb743..33df5a5e9 100644
--- a/modules/user/model_setting.go
+++ b/modules/user/model_setting.go
@@ -80,7 +80,7 @@ func (this *ModelSetting) checkInitCount(uid string) bool {
return false
}
ue.InitdataCount++
- }
+ }
}
@@ -122,7 +122,7 @@ func (this *ModelSetting) refresh(uid string) (code int32) {
// 清空设置
func (this *ModelSetting) cleanData(uid string) {
- if err := this.module.modelSetting.Del(uid); err != nil {
+ if err := this.module.modelSetting.DelByUId(uid); err != nil {
this.module.Errorf("cleanData err:%v", err)
}
}
diff --git a/modules/user/model_user.go b/modules/user/model_user.go
index 361476666..7f809d41f 100644
--- a/modules/user/model_user.go
+++ b/modules/user/model_user.go
@@ -102,7 +102,7 @@ func (this *ModelUser) isLoginFirst(timestamp int64) bool {
//删除用户数据
func (this *ModelUser) delete(uid string) {
- if err := this.Del(uid); err != nil {
+ if err := this.DelByUId(uid); err != nil {
log.Errorf("%v", err)
}
}
diff --git a/modules/user/module.go b/modules/user/module.go
index 0aab830e1..7facee8ff 100644
--- a/modules/user/module.go
+++ b/modules/user/module.go
@@ -75,9 +75,9 @@ func (this *User) CleanSession(session comm.IUserSession) {
sId := fmt.Sprintf("%s-%s", comm.RDS_SESSION, session.GetUserId())
this.modelSession.Del(sId, db.SetDBMgoLog(false))
this.modelSession.DelListlds(comm.RDS_SESSION, session.GetUserId())
- this.modelUser.Del(session.GetUserId(), db.SetDBMgoLog(false))
- this.modelExpand.Del(session.GetUserId(), db.SetDBMgoLog(false))
- this.modelSetting.Del(session.GetUserId(), db.SetDBMgoLog(false))
+ this.modelUser.DelByUId(session.GetUserId(), db.SetDBMgoLog(false))
+ this.modelExpand.DelByUId(session.GetUserId(), db.SetDBMgoLog(false))
+ this.modelSetting.DelByUId(session.GetUserId(), db.SetDBMgoLog(false))
}
// 在线玩家列表
diff --git a/pb/errorcode.pb.go b/pb/errorcode.pb.go
index a05fba2a9..94b0253bb 100644
--- a/pb/errorcode.pb.go
+++ b/pb/errorcode.pb.go
@@ -177,6 +177,7 @@ const (
ErrorCode_MoonfantasyDareUp ErrorCode = 2403 // boos 挑战次数已达上限
ErrorCode_MoonfantasyBattleNoEnd ErrorCode = 2404 // boos 战斗未结束
ErrorCode_MoonfantasyBattleNoWin ErrorCode = 2405 // boos 战斗魏未胜利
+ ErrorCode_MoonfantasyNoJoin ErrorCode = 2406 // boos 未加入战斗序列
ErrorCode_BattleNoFoundRecord ErrorCode = 2501 // 未找到记录
ErrorCode_LinestoryTaskFinished ErrorCode = 2601 //任务已完成
ErrorCode_LinestorySubTaskFinished ErrorCode = 2602 //子任务已完成
@@ -331,6 +332,7 @@ var (
2403: "MoonfantasyDareUp",
2404: "MoonfantasyBattleNoEnd",
2405: "MoonfantasyBattleNoWin",
+ 2406: "MoonfantasyNoJoin",
2501: "BattleNoFoundRecord",
2601: "LinestoryTaskFinished",
2602: "LinestorySubTaskFinished",
@@ -481,6 +483,7 @@ var (
"MoonfantasyDareUp": 2403,
"MoonfantasyBattleNoEnd": 2404,
"MoonfantasyBattleNoWin": 2405,
+ "MoonfantasyNoJoin": 2406,
"BattleNoFoundRecord": 2501,
"LinestoryTaskFinished": 2601,
"LinestorySubTaskFinished": 2602,
@@ -524,7 +527,7 @@ var File_errorcode_proto protoreflect.FileDescriptor
var file_errorcode_proto_rawDesc = []byte{
0x0a, 0x0f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74,
- 0x6f, 0x2a, 0xd6, 0x19, 0x0a, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12,
+ 0x6f, 0x2a, 0xee, 0x19, 0x0a, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12,
0x0b, 0x0a, 0x07, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x10, 0x00, 0x12, 0x11, 0x0a, 0x0d,
0x4e, 0x6f, 0x46, 0x69, 0x6e, 0x64, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x10, 0x0a, 0x12,
0x1b, 0x0a, 0x17, 0x4e, 0x6f, 0x46, 0x69, 0x6e, 0x64, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65,
@@ -714,23 +717,25 @@ var file_errorcode_proto_rawDesc = []byte{
0x66, 0x61, 0x6e, 0x74, 0x61, 0x73, 0x79, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x4e, 0x6f, 0x45,
0x6e, 0x64, 0x10, 0xe4, 0x12, 0x12, 0x1b, 0x0a, 0x16, 0x4d, 0x6f, 0x6f, 0x6e, 0x66, 0x61, 0x6e,
0x74, 0x61, 0x73, 0x79, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x4e, 0x6f, 0x57, 0x69, 0x6e, 0x10,
- 0xe5, 0x12, 0x12, 0x18, 0x0a, 0x13, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x4e, 0x6f, 0x46, 0x6f,
- 0x75, 0x6e, 0x64, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x10, 0xc5, 0x13, 0x12, 0x1a, 0x0a, 0x15,
- 0x4c, 0x69, 0x6e, 0x65, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x54, 0x61, 0x73, 0x6b, 0x46, 0x69, 0x6e,
- 0x69, 0x73, 0x68, 0x65, 0x64, 0x10, 0xa9, 0x14, 0x12, 0x1d, 0x0a, 0x18, 0x4c, 0x69, 0x6e, 0x65,
- 0x73, 0x74, 0x6f, 0x72, 0x79, 0x53, 0x75, 0x62, 0x54, 0x61, 0x73, 0x6b, 0x46, 0x69, 0x6e, 0x69,
- 0x73, 0x68, 0x65, 0x64, 0x10, 0xaa, 0x14, 0x12, 0x1f, 0x0a, 0x1a, 0x4c, 0x69, 0x6e, 0x65, 0x73,
- 0x74, 0x6f, 0x72, 0x79, 0x54, 0x61, 0x73, 0x6b, 0x44, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x64,
- 0x45, 0x6e, 0x74, 0x65, 0x72, 0x10, 0xab, 0x14, 0x12, 0x1f, 0x0a, 0x1a, 0x4c, 0x69, 0x6e, 0x65,
- 0x73, 0x74, 0x6f, 0x72, 0x79, 0x50, 0x72, 0x65, 0x54, 0x61, 0x73, 0x6b, 0x4e, 0x6f, 0x46, 0x69,
- 0x6e, 0x69, 0x73, 0x68, 0x65, 0x64, 0x10, 0xac, 0x14, 0x12, 0x11, 0x0a, 0x0c, 0x48, 0x75, 0x6e,
- 0x74, 0x69, 0x6e, 0x67, 0x4c, 0x76, 0x45, 0x72, 0x72, 0x10, 0x8d, 0x15, 0x12, 0x14, 0x0a, 0x0f,
- 0x48, 0x75, 0x6e, 0x74, 0x69, 0x6e, 0x67, 0x42, 0x6f, 0x6f, 0x73, 0x54, 0x79, 0x70, 0x65, 0x10,
- 0x8e, 0x15, 0x12, 0x17, 0x0a, 0x12, 0x48, 0x75, 0x6e, 0x74, 0x69, 0x6e, 0x67, 0x42, 0x75, 0x79,
- 0x4d, 0x61, 0x78, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x10, 0x8f, 0x15, 0x12, 0x1d, 0x0a, 0x18, 0x48,
- 0x75, 0x6e, 0x74, 0x69, 0x6e, 0x67, 0x4d, 0x61, 0x78, 0x43, 0x68, 0x61, 0x6c, 0x6c, 0x65, 0x6e,
- 0x67, 0x65, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x10, 0x90, 0x15, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b,
- 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
+ 0xe5, 0x12, 0x12, 0x16, 0x0a, 0x11, 0x4d, 0x6f, 0x6f, 0x6e, 0x66, 0x61, 0x6e, 0x74, 0x61, 0x73,
+ 0x79, 0x4e, 0x6f, 0x4a, 0x6f, 0x69, 0x6e, 0x10, 0xe6, 0x12, 0x12, 0x18, 0x0a, 0x13, 0x42, 0x61,
+ 0x74, 0x74, 0x6c, 0x65, 0x4e, 0x6f, 0x46, 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, 0x63, 0x6f, 0x72,
+ 0x64, 0x10, 0xc5, 0x13, 0x12, 0x1a, 0x0a, 0x15, 0x4c, 0x69, 0x6e, 0x65, 0x73, 0x74, 0x6f, 0x72,
+ 0x79, 0x54, 0x61, 0x73, 0x6b, 0x46, 0x69, 0x6e, 0x69, 0x73, 0x68, 0x65, 0x64, 0x10, 0xa9, 0x14,
+ 0x12, 0x1d, 0x0a, 0x18, 0x4c, 0x69, 0x6e, 0x65, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x53, 0x75, 0x62,
+ 0x54, 0x61, 0x73, 0x6b, 0x46, 0x69, 0x6e, 0x69, 0x73, 0x68, 0x65, 0x64, 0x10, 0xaa, 0x14, 0x12,
+ 0x1f, 0x0a, 0x1a, 0x4c, 0x69, 0x6e, 0x65, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x54, 0x61, 0x73, 0x6b,
+ 0x44, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x45, 0x6e, 0x74, 0x65, 0x72, 0x10, 0xab, 0x14,
+ 0x12, 0x1f, 0x0a, 0x1a, 0x4c, 0x69, 0x6e, 0x65, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x50, 0x72, 0x65,
+ 0x54, 0x61, 0x73, 0x6b, 0x4e, 0x6f, 0x46, 0x69, 0x6e, 0x69, 0x73, 0x68, 0x65, 0x64, 0x10, 0xac,
+ 0x14, 0x12, 0x11, 0x0a, 0x0c, 0x48, 0x75, 0x6e, 0x74, 0x69, 0x6e, 0x67, 0x4c, 0x76, 0x45, 0x72,
+ 0x72, 0x10, 0x8d, 0x15, 0x12, 0x14, 0x0a, 0x0f, 0x48, 0x75, 0x6e, 0x74, 0x69, 0x6e, 0x67, 0x42,
+ 0x6f, 0x6f, 0x73, 0x54, 0x79, 0x70, 0x65, 0x10, 0x8e, 0x15, 0x12, 0x17, 0x0a, 0x12, 0x48, 0x75,
+ 0x6e, 0x74, 0x69, 0x6e, 0x67, 0x42, 0x75, 0x79, 0x4d, 0x61, 0x78, 0x43, 0x6f, 0x75, 0x6e, 0x74,
+ 0x10, 0x8f, 0x15, 0x12, 0x1d, 0x0a, 0x18, 0x48, 0x75, 0x6e, 0x74, 0x69, 0x6e, 0x67, 0x4d, 0x61,
+ 0x78, 0x43, 0x68, 0x61, 0x6c, 0x6c, 0x65, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x10,
+ 0x90, 0x15, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
+ 0x6f, 0x33,
}
var (
diff --git a/pb/moonfantasy_db.pb.go b/pb/moonfantasy_db.pb.go
index a7da27966..d13255428 100644
--- a/pb/moonfantasy_db.pb.go
+++ b/pb/moonfantasy_db.pb.go
@@ -20,23 +20,18 @@ const (
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
-type DBMoonfantasy struct {
+type UserInfo struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
- Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id" bson:"_id"` //ID
- Uid string `protobuf:"bytes,2,opt,name=uid,proto3" json:"uid"` //用户id
- Monster string `protobuf:"bytes,3,opt,name=monster,proto3" json:"monster"` //英雄id
- Ctime int64 `protobuf:"varint,4,opt,name=ctime,proto3" json:"ctime"` //创建时间
- Joinnum int32 `protobuf:"varint,5,opt,name=joinnum,proto3" json:"joinnum"` //参与人数
- Numup int32 `protobuf:"varint,6,opt,name=numup,proto3" json:"numup"` //人数上限
- Unitmup int32 `protobuf:"varint,7,opt,name=unitmup,proto3" json:"unitmup"` //单人可挑战次数
- Record map[string]int32 `protobuf:"bytes,8,rep,name=record,proto3" json:"record" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` //挑战记录
+ Uid string `protobuf:"bytes,1,opt,name=uid,proto3" json:"uid"` //用户id
+ Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name"` //昵称
+ Avatar string `protobuf:"bytes,12,opt,name=avatar,proto3" json:"avatar"` // 头像
}
-func (x *DBMoonfantasy) Reset() {
- *x = DBMoonfantasy{}
+func (x *UserInfo) Reset() {
+ *x = UserInfo{}
if protoimpl.UnsafeEnabled {
mi := &file_moonfantasy_moonfantasy_db_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
@@ -44,13 +39,13 @@ func (x *DBMoonfantasy) Reset() {
}
}
-func (x *DBMoonfantasy) String() string {
+func (x *UserInfo) String() string {
return protoimpl.X.MessageStringOf(x)
}
-func (*DBMoonfantasy) ProtoMessage() {}
+func (*UserInfo) ProtoMessage() {}
-func (x *DBMoonfantasy) ProtoReflect() protoreflect.Message {
+func (x *UserInfo) ProtoReflect() protoreflect.Message {
mi := &file_moonfantasy_moonfantasy_db_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
@@ -62,91 +57,234 @@ func (x *DBMoonfantasy) ProtoReflect() protoreflect.Message {
return mi.MessageOf(x)
}
-// Deprecated: Use DBMoonfantasy.ProtoReflect.Descriptor instead.
-func (*DBMoonfantasy) Descriptor() ([]byte, []int) {
+// Deprecated: Use UserInfo.ProtoReflect.Descriptor instead.
+func (*UserInfo) Descriptor() ([]byte, []int) {
return file_moonfantasy_moonfantasy_db_proto_rawDescGZIP(), []int{0}
}
-func (x *DBMoonfantasy) GetId() string {
- if x != nil {
- return x.Id
- }
- return ""
-}
-
-func (x *DBMoonfantasy) GetUid() string {
+func (x *UserInfo) GetUid() string {
if x != nil {
return x.Uid
}
return ""
}
-func (x *DBMoonfantasy) GetMonster() string {
+func (x *UserInfo) GetName() string {
+ if x != nil {
+ return x.Name
+ }
+ return ""
+}
+
+func (x *UserInfo) GetAvatar() string {
+ if x != nil {
+ return x.Avatar
+ }
+ return ""
+}
+
+//月之秘境
+type DBMoonFantasy struct {
+ state protoimpl.MessageState
+ sizeCache protoimpl.SizeCache
+ unknownFields protoimpl.UnknownFields
+
+ Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id" bson:"_id"` //ID
+ Uid string `protobuf:"bytes,2,opt,name=uid,proto3" json:"uid"` //用户id
+ Monster string `protobuf:"bytes,3,opt,name=monster,proto3" json:"monster"` //怪物id
+ Ctime int64 `protobuf:"varint,4,opt,name=ctime,proto3" json:"ctime"` //创建时间
+ Join []*UserInfo `protobuf:"bytes,5,rep,name=join,proto3" json:"join"` //参与人数
+ Numup int32 `protobuf:"varint,6,opt,name=numup,proto3" json:"numup"` //人数上限
+ Unitmup int32 `protobuf:"varint,7,opt,name=unitmup,proto3" json:"unitmup"` //单人可挑战次数
+ Record map[string]int32 `protobuf:"bytes,8,rep,name=record,proto3" json:"record" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` //挑战记录
+}
+
+func (x *DBMoonFantasy) Reset() {
+ *x = DBMoonFantasy{}
+ if protoimpl.UnsafeEnabled {
+ mi := &file_moonfantasy_moonfantasy_db_proto_msgTypes[1]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+ }
+}
+
+func (x *DBMoonFantasy) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*DBMoonFantasy) ProtoMessage() {}
+
+func (x *DBMoonFantasy) ProtoReflect() protoreflect.Message {
+ mi := &file_moonfantasy_moonfantasy_db_proto_msgTypes[1]
+ if protoimpl.UnsafeEnabled && x != nil {
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ if ms.LoadMessageInfo() == nil {
+ ms.StoreMessageInfo(mi)
+ }
+ return ms
+ }
+ return mi.MessageOf(x)
+}
+
+// Deprecated: Use DBMoonFantasy.ProtoReflect.Descriptor instead.
+func (*DBMoonFantasy) Descriptor() ([]byte, []int) {
+ return file_moonfantasy_moonfantasy_db_proto_rawDescGZIP(), []int{1}
+}
+
+func (x *DBMoonFantasy) GetId() string {
+ if x != nil {
+ return x.Id
+ }
+ return ""
+}
+
+func (x *DBMoonFantasy) GetUid() string {
+ if x != nil {
+ return x.Uid
+ }
+ return ""
+}
+
+func (x *DBMoonFantasy) GetMonster() string {
if x != nil {
return x.Monster
}
return ""
}
-func (x *DBMoonfantasy) GetCtime() int64 {
+func (x *DBMoonFantasy) GetCtime() int64 {
if x != nil {
return x.Ctime
}
return 0
}
-func (x *DBMoonfantasy) GetJoinnum() int32 {
+func (x *DBMoonFantasy) GetJoin() []*UserInfo {
if x != nil {
- return x.Joinnum
+ return x.Join
}
- return 0
+ return nil
}
-func (x *DBMoonfantasy) GetNumup() int32 {
+func (x *DBMoonFantasy) GetNumup() int32 {
if x != nil {
return x.Numup
}
return 0
}
-func (x *DBMoonfantasy) GetUnitmup() int32 {
+func (x *DBMoonFantasy) GetUnitmup() int32 {
if x != nil {
return x.Unitmup
}
return 0
}
-func (x *DBMoonfantasy) GetRecord() map[string]int32 {
+func (x *DBMoonFantasy) GetRecord() map[string]int32 {
if x != nil {
return x.Record
}
return nil
}
+//用户参与的月之秘境列表
+type DBUserMFantasy struct {
+ state protoimpl.MessageState
+ sizeCache protoimpl.SizeCache
+ unknownFields protoimpl.UnknownFields
+
+ Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id" bson:"_id"` //ID
+ Uid string `protobuf:"bytes,2,opt,name=uid,proto3" json:"uid"` //用户id
+ Mfantasys []string `protobuf:"bytes,3,rep,name=mfantasys,proto3" json:"mfantasys"` //月之秘境列表
+}
+
+func (x *DBUserMFantasy) Reset() {
+ *x = DBUserMFantasy{}
+ if protoimpl.UnsafeEnabled {
+ mi := &file_moonfantasy_moonfantasy_db_proto_msgTypes[2]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+ }
+}
+
+func (x *DBUserMFantasy) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*DBUserMFantasy) ProtoMessage() {}
+
+func (x *DBUserMFantasy) ProtoReflect() protoreflect.Message {
+ mi := &file_moonfantasy_moonfantasy_db_proto_msgTypes[2]
+ if protoimpl.UnsafeEnabled && x != nil {
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ if ms.LoadMessageInfo() == nil {
+ ms.StoreMessageInfo(mi)
+ }
+ return ms
+ }
+ return mi.MessageOf(x)
+}
+
+// Deprecated: Use DBUserMFantasy.ProtoReflect.Descriptor instead.
+func (*DBUserMFantasy) Descriptor() ([]byte, []int) {
+ return file_moonfantasy_moonfantasy_db_proto_rawDescGZIP(), []int{2}
+}
+
+func (x *DBUserMFantasy) GetId() string {
+ if x != nil {
+ return x.Id
+ }
+ return ""
+}
+
+func (x *DBUserMFantasy) GetUid() string {
+ if x != nil {
+ return x.Uid
+ }
+ return ""
+}
+
+func (x *DBUserMFantasy) GetMfantasys() []string {
+ if x != nil {
+ return x.Mfantasys
+ }
+ return nil
+}
+
var File_moonfantasy_moonfantasy_db_proto protoreflect.FileDescriptor
var file_moonfantasy_moonfantasy_db_proto_rawDesc = []byte{
0x0a, 0x20, 0x6d, 0x6f, 0x6f, 0x6e, 0x66, 0x61, 0x6e, 0x74, 0x61, 0x73, 0x79, 0x2f, 0x6d, 0x6f,
0x6f, 0x6e, 0x66, 0x61, 0x6e, 0x74, 0x61, 0x73, 0x79, 0x5f, 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f,
- 0x74, 0x6f, 0x22, 0x9a, 0x02, 0x0a, 0x0d, 0x44, 0x42, 0x4d, 0x6f, 0x6f, 0x6e, 0x66, 0x61, 0x6e,
- 0x74, 0x61, 0x73, 0x79, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
- 0x52, 0x02, 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28,
- 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x6f, 0x6e, 0x73, 0x74, 0x65,
- 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x6f, 0x6e, 0x73, 0x74, 0x65, 0x72,
- 0x12, 0x14, 0x0a, 0x05, 0x63, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52,
- 0x05, 0x63, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6a, 0x6f, 0x69, 0x6e, 0x6e, 0x75,
- 0x6d, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x6a, 0x6f, 0x69, 0x6e, 0x6e, 0x75, 0x6d,
- 0x12, 0x14, 0x0a, 0x05, 0x6e, 0x75, 0x6d, 0x75, 0x70, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52,
- 0x05, 0x6e, 0x75, 0x6d, 0x75, 0x70, 0x12, 0x18, 0x0a, 0x07, 0x75, 0x6e, 0x69, 0x74, 0x6d, 0x75,
- 0x70, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x75, 0x6e, 0x69, 0x74, 0x6d, 0x75, 0x70,
- 0x12, 0x32, 0x0a, 0x06, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x18, 0x08, 0x20, 0x03, 0x28, 0x0b,
- 0x32, 0x1a, 0x2e, 0x44, 0x42, 0x4d, 0x6f, 0x6f, 0x6e, 0x66, 0x61, 0x6e, 0x74, 0x61, 0x73, 0x79,
- 0x2e, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x06, 0x72, 0x65,
- 0x63, 0x6f, 0x72, 0x64, 0x1a, 0x39, 0x0a, 0x0b, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x45, 0x6e,
- 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
- 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02,
- 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42,
- 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
+ 0x74, 0x6f, 0x22, 0x48, 0x0a, 0x08, 0x55, 0x73, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x10,
+ 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64,
+ 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04,
+ 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x18, 0x0c,
+ 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x22, 0x9f, 0x02, 0x0a,
+ 0x0d, 0x44, 0x42, 0x4d, 0x6f, 0x6f, 0x6e, 0x46, 0x61, 0x6e, 0x74, 0x61, 0x73, 0x79, 0x12, 0x0e,
+ 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x10,
+ 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64,
+ 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x6f, 0x6e, 0x73, 0x74, 0x65, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28,
+ 0x09, 0x52, 0x07, 0x6d, 0x6f, 0x6e, 0x73, 0x74, 0x65, 0x72, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x74,
+ 0x69, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x63, 0x74, 0x69, 0x6d, 0x65,
+ 0x12, 0x1d, 0x0a, 0x04, 0x6a, 0x6f, 0x69, 0x6e, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x09,
+ 0x2e, 0x55, 0x73, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x04, 0x6a, 0x6f, 0x69, 0x6e, 0x12,
+ 0x14, 0x0a, 0x05, 0x6e, 0x75, 0x6d, 0x75, 0x70, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05,
+ 0x6e, 0x75, 0x6d, 0x75, 0x70, 0x12, 0x18, 0x0a, 0x07, 0x75, 0x6e, 0x69, 0x74, 0x6d, 0x75, 0x70,
+ 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x75, 0x6e, 0x69, 0x74, 0x6d, 0x75, 0x70, 0x12,
+ 0x32, 0x0a, 0x06, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x18, 0x08, 0x20, 0x03, 0x28, 0x0b, 0x32,
+ 0x1a, 0x2e, 0x44, 0x42, 0x4d, 0x6f, 0x6f, 0x6e, 0x46, 0x61, 0x6e, 0x74, 0x61, 0x73, 0x79, 0x2e,
+ 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x06, 0x72, 0x65, 0x63,
+ 0x6f, 0x72, 0x64, 0x1a, 0x39, 0x0a, 0x0b, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x45, 0x6e, 0x74,
+ 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
+ 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20,
+ 0x01, 0x28, 0x05, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x50,
+ 0x0a, 0x0e, 0x44, 0x42, 0x55, 0x73, 0x65, 0x72, 0x4d, 0x46, 0x61, 0x6e, 0x74, 0x61, 0x73, 0x79,
+ 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64,
+ 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75,
+ 0x69, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x6d, 0x66, 0x61, 0x6e, 0x74, 0x61, 0x73, 0x79, 0x73, 0x18,
+ 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x09, 0x6d, 0x66, 0x61, 0x6e, 0x74, 0x61, 0x73, 0x79, 0x73,
+ 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
@@ -161,18 +299,21 @@ func file_moonfantasy_moonfantasy_db_proto_rawDescGZIP() []byte {
return file_moonfantasy_moonfantasy_db_proto_rawDescData
}
-var file_moonfantasy_moonfantasy_db_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
+var file_moonfantasy_moonfantasy_db_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
var file_moonfantasy_moonfantasy_db_proto_goTypes = []interface{}{
- (*DBMoonfantasy)(nil), // 0: DBMoonfantasy
- nil, // 1: DBMoonfantasy.RecordEntry
+ (*UserInfo)(nil), // 0: UserInfo
+ (*DBMoonFantasy)(nil), // 1: DBMoonFantasy
+ (*DBUserMFantasy)(nil), // 2: DBUserMFantasy
+ nil, // 3: DBMoonFantasy.RecordEntry
}
var file_moonfantasy_moonfantasy_db_proto_depIdxs = []int32{
- 1, // 0: DBMoonfantasy.record:type_name -> DBMoonfantasy.RecordEntry
- 1, // [1:1] is the sub-list for method output_type
- 1, // [1:1] is the sub-list for method input_type
- 1, // [1:1] is the sub-list for extension type_name
- 1, // [1:1] is the sub-list for extension extendee
- 0, // [0:1] is the sub-list for field type_name
+ 0, // 0: DBMoonFantasy.join:type_name -> UserInfo
+ 3, // 1: DBMoonFantasy.record:type_name -> DBMoonFantasy.RecordEntry
+ 2, // [2:2] is the sub-list for method output_type
+ 2, // [2:2] is the sub-list for method input_type
+ 2, // [2:2] is the sub-list for extension type_name
+ 2, // [2:2] is the sub-list for extension extendee
+ 0, // [0:2] is the sub-list for field type_name
}
func init() { file_moonfantasy_moonfantasy_db_proto_init() }
@@ -182,7 +323,31 @@ func file_moonfantasy_moonfantasy_db_proto_init() {
}
if !protoimpl.UnsafeEnabled {
file_moonfantasy_moonfantasy_db_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
- switch v := v.(*DBMoonfantasy); i {
+ switch v := v.(*UserInfo); i {
+ case 0:
+ return &v.state
+ case 1:
+ return &v.sizeCache
+ case 2:
+ return &v.unknownFields
+ default:
+ return nil
+ }
+ }
+ file_moonfantasy_moonfantasy_db_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
+ switch v := v.(*DBMoonFantasy); i {
+ case 0:
+ return &v.state
+ case 1:
+ return &v.sizeCache
+ case 2:
+ return &v.unknownFields
+ default:
+ return nil
+ }
+ }
+ file_moonfantasy_moonfantasy_db_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
+ switch v := v.(*DBUserMFantasy); i {
case 0:
return &v.state
case 1:
@@ -200,7 +365,7 @@ func file_moonfantasy_moonfantasy_db_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_moonfantasy_moonfantasy_db_proto_rawDesc,
NumEnums: 0,
- NumMessages: 2,
+ NumMessages: 4,
NumExtensions: 0,
NumServices: 0,
},
diff --git a/pb/moonfantasy_msg.pb.go b/pb/moonfantasy_msg.pb.go
index 04265dbcb..6d0be3a25 100644
--- a/pb/moonfantasy_msg.pb.go
+++ b/pb/moonfantasy_msg.pb.go
@@ -20,6 +20,93 @@ const (
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
+//获取装备列表请求
+type MoonfantasyGetListReq struct {
+ state protoimpl.MessageState
+ sizeCache protoimpl.SizeCache
+ unknownFields protoimpl.UnknownFields
+}
+
+func (x *MoonfantasyGetListReq) Reset() {
+ *x = MoonfantasyGetListReq{}
+ if protoimpl.UnsafeEnabled {
+ mi := &file_moonfantasy_moonfantasy_msg_proto_msgTypes[0]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+ }
+}
+
+func (x *MoonfantasyGetListReq) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*MoonfantasyGetListReq) ProtoMessage() {}
+
+func (x *MoonfantasyGetListReq) ProtoReflect() protoreflect.Message {
+ mi := &file_moonfantasy_moonfantasy_msg_proto_msgTypes[0]
+ if protoimpl.UnsafeEnabled && x != nil {
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ if ms.LoadMessageInfo() == nil {
+ ms.StoreMessageInfo(mi)
+ }
+ return ms
+ }
+ return mi.MessageOf(x)
+}
+
+// Deprecated: Use MoonfantasyGetListReq.ProtoReflect.Descriptor instead.
+func (*MoonfantasyGetListReq) Descriptor() ([]byte, []int) {
+ return file_moonfantasy_moonfantasy_msg_proto_rawDescGZIP(), []int{0}
+}
+
+//获取装备列表请求 回应
+type MoonfantasyGetListResp struct {
+ state protoimpl.MessageState
+ sizeCache protoimpl.SizeCache
+ unknownFields protoimpl.UnknownFields
+
+ Dfantasys []*DBMoonFantasy `protobuf:"bytes,1,rep,name=dfantasys,proto3" json:"dfantasys"` //秘境列表
+}
+
+func (x *MoonfantasyGetListResp) Reset() {
+ *x = MoonfantasyGetListResp{}
+ if protoimpl.UnsafeEnabled {
+ mi := &file_moonfantasy_moonfantasy_msg_proto_msgTypes[1]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+ }
+}
+
+func (x *MoonfantasyGetListResp) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*MoonfantasyGetListResp) ProtoMessage() {}
+
+func (x *MoonfantasyGetListResp) ProtoReflect() protoreflect.Message {
+ mi := &file_moonfantasy_moonfantasy_msg_proto_msgTypes[1]
+ if protoimpl.UnsafeEnabled && x != nil {
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ if ms.LoadMessageInfo() == nil {
+ ms.StoreMessageInfo(mi)
+ }
+ return ms
+ }
+ return mi.MessageOf(x)
+}
+
+// Deprecated: Use MoonfantasyGetListResp.ProtoReflect.Descriptor instead.
+func (*MoonfantasyGetListResp) Descriptor() ([]byte, []int) {
+ return file_moonfantasy_moonfantasy_msg_proto_rawDescGZIP(), []int{1}
+}
+
+func (x *MoonfantasyGetListResp) GetDfantasys() []*DBMoonFantasy {
+ if x != nil {
+ return x.Dfantasys
+ }
+ return nil
+}
+
///触发秘境
type MoonfantasyTriggerReq struct {
state protoimpl.MessageState
@@ -34,7 +121,7 @@ type MoonfantasyTriggerReq struct {
func (x *MoonfantasyTriggerReq) Reset() {
*x = MoonfantasyTriggerReq{}
if protoimpl.UnsafeEnabled {
- mi := &file_moonfantasy_moonfantasy_msg_proto_msgTypes[0]
+ mi := &file_moonfantasy_moonfantasy_msg_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -47,7 +134,7 @@ func (x *MoonfantasyTriggerReq) String() string {
func (*MoonfantasyTriggerReq) ProtoMessage() {}
func (x *MoonfantasyTriggerReq) ProtoReflect() protoreflect.Message {
- mi := &file_moonfantasy_moonfantasy_msg_proto_msgTypes[0]
+ mi := &file_moonfantasy_moonfantasy_msg_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -60,7 +147,7 @@ func (x *MoonfantasyTriggerReq) ProtoReflect() protoreflect.Message {
// Deprecated: Use MoonfantasyTriggerReq.ProtoReflect.Descriptor instead.
func (*MoonfantasyTriggerReq) Descriptor() ([]byte, []int) {
- return file_moonfantasy_moonfantasy_msg_proto_rawDescGZIP(), []int{0}
+ return file_moonfantasy_moonfantasy_msg_proto_rawDescGZIP(), []int{2}
}
func (x *MoonfantasyTriggerReq) GetAvatar() string {
@@ -98,7 +185,7 @@ type MoonfantasyTriggerResp struct {
func (x *MoonfantasyTriggerResp) Reset() {
*x = MoonfantasyTriggerResp{}
if protoimpl.UnsafeEnabled {
- mi := &file_moonfantasy_moonfantasy_msg_proto_msgTypes[1]
+ mi := &file_moonfantasy_moonfantasy_msg_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -111,7 +198,7 @@ func (x *MoonfantasyTriggerResp) String() string {
func (*MoonfantasyTriggerResp) ProtoMessage() {}
func (x *MoonfantasyTriggerResp) ProtoReflect() protoreflect.Message {
- mi := &file_moonfantasy_moonfantasy_msg_proto_msgTypes[1]
+ mi := &file_moonfantasy_moonfantasy_msg_proto_msgTypes[3]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -124,7 +211,7 @@ func (x *MoonfantasyTriggerResp) ProtoReflect() protoreflect.Message {
// Deprecated: Use MoonfantasyTriggerResp.ProtoReflect.Descriptor instead.
func (*MoonfantasyTriggerResp) Descriptor() ([]byte, []int) {
- return file_moonfantasy_moonfantasy_msg_proto_rawDescGZIP(), []int{1}
+ return file_moonfantasy_moonfantasy_msg_proto_rawDescGZIP(), []int{3}
}
func (x *MoonfantasyTriggerResp) GetIssucc() bool {
@@ -148,20 +235,19 @@ func (x *MoonfantasyTriggerResp) GetMonster() string {
return ""
}
-///挑战秘境
+///询问秘境
type MoonfantasyAskReq struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
- Uid string `protobuf:"bytes,1,opt,name=uid,proto3" json:"uid"` //发布者用户id
- Mid string `protobuf:"bytes,2,opt,name=mid,proto3" json:"mid"` //唯一id
+ Mid string `protobuf:"bytes,1,opt,name=mid,proto3" json:"mid"` //唯一id
}
func (x *MoonfantasyAskReq) Reset() {
*x = MoonfantasyAskReq{}
if protoimpl.UnsafeEnabled {
- mi := &file_moonfantasy_moonfantasy_msg_proto_msgTypes[2]
+ mi := &file_moonfantasy_moonfantasy_msg_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -174,7 +260,7 @@ func (x *MoonfantasyAskReq) String() string {
func (*MoonfantasyAskReq) ProtoMessage() {}
func (x *MoonfantasyAskReq) ProtoReflect() protoreflect.Message {
- mi := &file_moonfantasy_moonfantasy_msg_proto_msgTypes[2]
+ mi := &file_moonfantasy_moonfantasy_msg_proto_msgTypes[4]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -187,14 +273,7 @@ func (x *MoonfantasyAskReq) ProtoReflect() protoreflect.Message {
// Deprecated: Use MoonfantasyAskReq.ProtoReflect.Descriptor instead.
func (*MoonfantasyAskReq) Descriptor() ([]byte, []int) {
- return file_moonfantasy_moonfantasy_msg_proto_rawDescGZIP(), []int{2}
-}
-
-func (x *MoonfantasyAskReq) GetUid() string {
- if x != nil {
- return x.Uid
- }
- return ""
+ return file_moonfantasy_moonfantasy_msg_proto_rawDescGZIP(), []int{4}
}
func (x *MoonfantasyAskReq) GetMid() string {
@@ -209,13 +288,14 @@ type MoonfantasyAskResp struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
- Code ErrorCode `protobuf:"varint,1,opt,name=code,proto3,enum=ErrorCode" json:"code"` //是否成功
+ Code ErrorCode `protobuf:"varint,1,opt,name=code,proto3,enum=ErrorCode" json:"code"` //是否成功
+ Info *DBMoonFantasy `protobuf:"bytes,2,opt,name=info,proto3" json:"info"` //秘境信息 可能为空
}
func (x *MoonfantasyAskResp) Reset() {
*x = MoonfantasyAskResp{}
if protoimpl.UnsafeEnabled {
- mi := &file_moonfantasy_moonfantasy_msg_proto_msgTypes[3]
+ mi := &file_moonfantasy_moonfantasy_msg_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -228,7 +308,7 @@ func (x *MoonfantasyAskResp) String() string {
func (*MoonfantasyAskResp) ProtoMessage() {}
func (x *MoonfantasyAskResp) ProtoReflect() protoreflect.Message {
- mi := &file_moonfantasy_moonfantasy_msg_proto_msgTypes[3]
+ mi := &file_moonfantasy_moonfantasy_msg_proto_msgTypes[5]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -241,7 +321,7 @@ func (x *MoonfantasyAskResp) ProtoReflect() protoreflect.Message {
// Deprecated: Use MoonfantasyAskResp.ProtoReflect.Descriptor instead.
func (*MoonfantasyAskResp) Descriptor() ([]byte, []int) {
- return file_moonfantasy_moonfantasy_msg_proto_rawDescGZIP(), []int{3}
+ return file_moonfantasy_moonfantasy_msg_proto_rawDescGZIP(), []int{5}
}
func (x *MoonfantasyAskResp) GetCode() ErrorCode {
@@ -251,22 +331,28 @@ func (x *MoonfantasyAskResp) GetCode() ErrorCode {
return ErrorCode_Success
}
+func (x *MoonfantasyAskResp) GetInfo() *DBMoonFantasy {
+ if x != nil {
+ return x.Info
+ }
+ return nil
+}
+
///挑战秘境
type MoonfantasyBattleReq struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
- Uid string `protobuf:"bytes,1,opt,name=uid,proto3" json:"uid"` //发布者用户id
- Mid string `protobuf:"bytes,2,opt,name=mid,proto3" json:"mid"` //唯一id
- Leadpos int32 `protobuf:"varint,3,opt,name=leadpos,proto3" json:"leadpos"` //队长位置
- Teamids []string `protobuf:"bytes,4,rep,name=teamids,proto3" json:"teamids"` //阵容信息
+ Mid string `protobuf:"bytes,1,opt,name=mid,proto3" json:"mid"` //唯一id
+ Leadpos int32 `protobuf:"varint,2,opt,name=leadpos,proto3" json:"leadpos"` //队长位置
+ Teamids []string `protobuf:"bytes,3,rep,name=teamids,proto3" json:"teamids"` //阵容信息
}
func (x *MoonfantasyBattleReq) Reset() {
*x = MoonfantasyBattleReq{}
if protoimpl.UnsafeEnabled {
- mi := &file_moonfantasy_moonfantasy_msg_proto_msgTypes[4]
+ mi := &file_moonfantasy_moonfantasy_msg_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -279,7 +365,7 @@ func (x *MoonfantasyBattleReq) String() string {
func (*MoonfantasyBattleReq) ProtoMessage() {}
func (x *MoonfantasyBattleReq) ProtoReflect() protoreflect.Message {
- mi := &file_moonfantasy_moonfantasy_msg_proto_msgTypes[4]
+ mi := &file_moonfantasy_moonfantasy_msg_proto_msgTypes[6]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -292,14 +378,7 @@ func (x *MoonfantasyBattleReq) ProtoReflect() protoreflect.Message {
// Deprecated: Use MoonfantasyBattleReq.ProtoReflect.Descriptor instead.
func (*MoonfantasyBattleReq) Descriptor() ([]byte, []int) {
- return file_moonfantasy_moonfantasy_msg_proto_rawDescGZIP(), []int{4}
-}
-
-func (x *MoonfantasyBattleReq) GetUid() string {
- if x != nil {
- return x.Uid
- }
- return ""
+ return file_moonfantasy_moonfantasy_msg_proto_rawDescGZIP(), []int{6}
}
func (x *MoonfantasyBattleReq) GetMid() string {
@@ -328,15 +407,15 @@ type MoonfantasyBattleResp struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
- Code ErrorCode `protobuf:"varint,1,opt,name=code,proto3,enum=ErrorCode" json:"code"` //是否成功
- Monster string `protobuf:"bytes,2,opt,name=monster,proto3" json:"monster"` //怪物id
- Info *BattleInfo `protobuf:"bytes,3,opt,name=info,proto3" json:"info"`
+ Code ErrorCode `protobuf:"varint,1,opt,name=code,proto3,enum=ErrorCode" json:"code"` //是否成功
+ Mid string `protobuf:"bytes,2,opt,name=mid,proto3" json:"mid"` //怪物id
+ Info *BattleInfo `protobuf:"bytes,3,opt,name=info,proto3" json:"info"`
}
func (x *MoonfantasyBattleResp) Reset() {
*x = MoonfantasyBattleResp{}
if protoimpl.UnsafeEnabled {
- mi := &file_moonfantasy_moonfantasy_msg_proto_msgTypes[5]
+ mi := &file_moonfantasy_moonfantasy_msg_proto_msgTypes[7]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -349,7 +428,7 @@ func (x *MoonfantasyBattleResp) String() string {
func (*MoonfantasyBattleResp) ProtoMessage() {}
func (x *MoonfantasyBattleResp) ProtoReflect() protoreflect.Message {
- mi := &file_moonfantasy_moonfantasy_msg_proto_msgTypes[5]
+ mi := &file_moonfantasy_moonfantasy_msg_proto_msgTypes[7]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -362,7 +441,7 @@ func (x *MoonfantasyBattleResp) ProtoReflect() protoreflect.Message {
// Deprecated: Use MoonfantasyBattleResp.ProtoReflect.Descriptor instead.
func (*MoonfantasyBattleResp) Descriptor() ([]byte, []int) {
- return file_moonfantasy_moonfantasy_msg_proto_rawDescGZIP(), []int{5}
+ return file_moonfantasy_moonfantasy_msg_proto_rawDescGZIP(), []int{7}
}
func (x *MoonfantasyBattleResp) GetCode() ErrorCode {
@@ -372,9 +451,9 @@ func (x *MoonfantasyBattleResp) GetCode() ErrorCode {
return ErrorCode_Success
}
-func (x *MoonfantasyBattleResp) GetMonster() string {
+func (x *MoonfantasyBattleResp) GetMid() string {
if x != nil {
- return x.Monster
+ return x.Mid
}
return ""
}
@@ -392,15 +471,15 @@ type MoonfantasyReceiveReq struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
- Bid string `protobuf:"bytes,2,opt,name=bid,proto3" json:"bid"` //战斗id 后续需要这个id来领取奖励
- Monster string `protobuf:"bytes,3,opt,name=monster,proto3" json:"monster"` //怪物id
- Report *BattleReport `protobuf:"bytes,4,opt,name=report,proto3" json:"report"` //战报
+ Bid string `protobuf:"bytes,2,opt,name=bid,proto3" json:"bid"` //战斗id 后续需要这个id来领取奖励
+ Mid string `protobuf:"bytes,3,opt,name=mid,proto3" json:"mid"` //怪物id
+ Report *BattleReport `protobuf:"bytes,4,opt,name=report,proto3" json:"report"` //战报
}
func (x *MoonfantasyReceiveReq) Reset() {
*x = MoonfantasyReceiveReq{}
if protoimpl.UnsafeEnabled {
- mi := &file_moonfantasy_moonfantasy_msg_proto_msgTypes[6]
+ mi := &file_moonfantasy_moonfantasy_msg_proto_msgTypes[8]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -413,7 +492,7 @@ func (x *MoonfantasyReceiveReq) String() string {
func (*MoonfantasyReceiveReq) ProtoMessage() {}
func (x *MoonfantasyReceiveReq) ProtoReflect() protoreflect.Message {
- mi := &file_moonfantasy_moonfantasy_msg_proto_msgTypes[6]
+ mi := &file_moonfantasy_moonfantasy_msg_proto_msgTypes[8]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -426,7 +505,7 @@ func (x *MoonfantasyReceiveReq) ProtoReflect() protoreflect.Message {
// Deprecated: Use MoonfantasyReceiveReq.ProtoReflect.Descriptor instead.
func (*MoonfantasyReceiveReq) Descriptor() ([]byte, []int) {
- return file_moonfantasy_moonfantasy_msg_proto_rawDescGZIP(), []int{6}
+ return file_moonfantasy_moonfantasy_msg_proto_rawDescGZIP(), []int{8}
}
func (x *MoonfantasyReceiveReq) GetBid() string {
@@ -436,9 +515,9 @@ func (x *MoonfantasyReceiveReq) GetBid() string {
return ""
}
-func (x *MoonfantasyReceiveReq) GetMonster() string {
+func (x *MoonfantasyReceiveReq) GetMid() string {
if x != nil {
- return x.Monster
+ return x.Mid
}
return ""
}
@@ -462,7 +541,7 @@ type MoonfantasyReceiveResp struct {
func (x *MoonfantasyReceiveResp) Reset() {
*x = MoonfantasyReceiveResp{}
if protoimpl.UnsafeEnabled {
- mi := &file_moonfantasy_moonfantasy_msg_proto_msgTypes[7]
+ mi := &file_moonfantasy_moonfantasy_msg_proto_msgTypes[9]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -475,7 +554,7 @@ func (x *MoonfantasyReceiveResp) String() string {
func (*MoonfantasyReceiveResp) ProtoMessage() {}
func (x *MoonfantasyReceiveResp) ProtoReflect() protoreflect.Message {
- mi := &file_moonfantasy_moonfantasy_msg_proto_msgTypes[7]
+ mi := &file_moonfantasy_moonfantasy_msg_proto_msgTypes[9]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -488,7 +567,7 @@ func (x *MoonfantasyReceiveResp) ProtoReflect() protoreflect.Message {
// Deprecated: Use MoonfantasyReceiveResp.ProtoReflect.Descriptor instead.
func (*MoonfantasyReceiveResp) Descriptor() ([]byte, []int) {
- return file_moonfantasy_moonfantasy_msg_proto_rawDescGZIP(), []int{7}
+ return file_moonfantasy_moonfantasy_msg_proto_rawDescGZIP(), []int{9}
}
func (x *MoonfantasyReceiveResp) GetIssucc() bool {
@@ -504,52 +583,59 @@ var file_moonfantasy_moonfantasy_msg_proto_rawDesc = []byte{
0x0a, 0x21, 0x6d, 0x6f, 0x6f, 0x6e, 0x66, 0x61, 0x6e, 0x74, 0x61, 0x73, 0x79, 0x2f, 0x6d, 0x6f,
0x6f, 0x6e, 0x66, 0x61, 0x6e, 0x74, 0x61, 0x73, 0x79, 0x5f, 0x6d, 0x73, 0x67, 0x2e, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x1a, 0x0f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x70,
- 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x17, 0x62, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x2f, 0x62, 0x61, 0x74,
- 0x74, 0x6c, 0x65, 0x5f, 0x6d, 0x73, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x57, 0x0a,
- 0x15, 0x4d, 0x6f, 0x6f, 0x6e, 0x66, 0x61, 0x6e, 0x74, 0x61, 0x73, 0x79, 0x54, 0x72, 0x69, 0x67,
- 0x67, 0x65, 0x72, 0x52, 0x65, 0x71, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72,
- 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x12, 0x14,
- 0x0a, 0x05, 0x75, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x75,
- 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x6c, 0x76, 0x18, 0x03, 0x20, 0x01, 0x28,
- 0x05, 0x52, 0x03, 0x75, 0x6c, 0x76, 0x22, 0x5c, 0x0a, 0x16, 0x4d, 0x6f, 0x6f, 0x6e, 0x66, 0x61,
- 0x6e, 0x74, 0x61, 0x73, 0x79, 0x54, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70,
+ 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x20, 0x6d, 0x6f, 0x6f, 0x6e, 0x66, 0x61, 0x6e, 0x74, 0x61, 0x73,
+ 0x79, 0x2f, 0x6d, 0x6f, 0x6f, 0x6e, 0x66, 0x61, 0x6e, 0x74, 0x61, 0x73, 0x79, 0x5f, 0x64, 0x62,
+ 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x17, 0x62, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x2f, 0x62,
+ 0x61, 0x74, 0x74, 0x6c, 0x65, 0x5f, 0x6d, 0x73, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22,
+ 0x17, 0x0a, 0x15, 0x4d, 0x6f, 0x6f, 0x6e, 0x66, 0x61, 0x6e, 0x74, 0x61, 0x73, 0x79, 0x47, 0x65,
+ 0x74, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x22, 0x46, 0x0a, 0x16, 0x4d, 0x6f, 0x6f, 0x6e,
+ 0x66, 0x61, 0x6e, 0x74, 0x61, 0x73, 0x79, 0x47, 0x65, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65,
+ 0x73, 0x70, 0x12, 0x2c, 0x0a, 0x09, 0x64, 0x66, 0x61, 0x6e, 0x74, 0x61, 0x73, 0x79, 0x73, 0x18,
+ 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x44, 0x42, 0x4d, 0x6f, 0x6f, 0x6e, 0x46, 0x61,
+ 0x6e, 0x74, 0x61, 0x73, 0x79, 0x52, 0x09, 0x64, 0x66, 0x61, 0x6e, 0x74, 0x61, 0x73, 0x79, 0x73,
+ 0x22, 0x57, 0x0a, 0x15, 0x4d, 0x6f, 0x6f, 0x6e, 0x66, 0x61, 0x6e, 0x74, 0x61, 0x73, 0x79, 0x54,
+ 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x52, 0x65, 0x71, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x76, 0x61,
+ 0x74, 0x61, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x61, 0x76, 0x61, 0x74, 0x61,
+ 0x72, 0x12, 0x14, 0x0a, 0x05, 0x75, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09,
+ 0x52, 0x05, 0x75, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x6c, 0x76, 0x18, 0x03,
+ 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x75, 0x6c, 0x76, 0x22, 0x5c, 0x0a, 0x16, 0x4d, 0x6f, 0x6f,
+ 0x6e, 0x66, 0x61, 0x6e, 0x74, 0x61, 0x73, 0x79, 0x54, 0x72, 0x69, 0x67, 0x67, 0x65, 0x72, 0x52,
+ 0x65, 0x73, 0x70, 0x12, 0x16, 0x0a, 0x06, 0x69, 0x73, 0x73, 0x75, 0x63, 0x63, 0x18, 0x01, 0x20,
+ 0x01, 0x28, 0x08, 0x52, 0x06, 0x69, 0x73, 0x73, 0x75, 0x63, 0x63, 0x12, 0x10, 0x0a, 0x03, 0x6d,
+ 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6d, 0x69, 0x64, 0x12, 0x18, 0x0a,
+ 0x07, 0x6d, 0x6f, 0x6e, 0x73, 0x74, 0x65, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07,
+ 0x6d, 0x6f, 0x6e, 0x73, 0x74, 0x65, 0x72, 0x22, 0x25, 0x0a, 0x11, 0x4d, 0x6f, 0x6f, 0x6e, 0x66,
+ 0x61, 0x6e, 0x74, 0x61, 0x73, 0x79, 0x41, 0x73, 0x6b, 0x52, 0x65, 0x71, 0x12, 0x10, 0x0a, 0x03,
+ 0x6d, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6d, 0x69, 0x64, 0x22, 0x58,
+ 0x0a, 0x12, 0x4d, 0x6f, 0x6f, 0x6e, 0x66, 0x61, 0x6e, 0x74, 0x61, 0x73, 0x79, 0x41, 0x73, 0x6b,
+ 0x52, 0x65, 0x73, 0x70, 0x12, 0x1e, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01,
+ 0x28, 0x0e, 0x32, 0x0a, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x04,
+ 0x63, 0x6f, 0x64, 0x65, 0x12, 0x22, 0x0a, 0x04, 0x69, 0x6e, 0x66, 0x6f, 0x18, 0x02, 0x20, 0x01,
+ 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x44, 0x42, 0x4d, 0x6f, 0x6f, 0x6e, 0x46, 0x61, 0x6e, 0x74, 0x61,
+ 0x73, 0x79, 0x52, 0x04, 0x69, 0x6e, 0x66, 0x6f, 0x22, 0x5c, 0x0a, 0x14, 0x4d, 0x6f, 0x6f, 0x6e,
+ 0x66, 0x61, 0x6e, 0x74, 0x61, 0x73, 0x79, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x52, 0x65, 0x71,
+ 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6d,
+ 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x6c, 0x65, 0x61, 0x64, 0x70, 0x6f, 0x73, 0x18, 0x02, 0x20,
+ 0x01, 0x28, 0x05, 0x52, 0x07, 0x6c, 0x65, 0x61, 0x64, 0x70, 0x6f, 0x73, 0x12, 0x18, 0x0a, 0x07,
+ 0x74, 0x65, 0x61, 0x6d, 0x69, 0x64, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x07, 0x74,
+ 0x65, 0x61, 0x6d, 0x69, 0x64, 0x73, 0x22, 0x6a, 0x0a, 0x15, 0x4d, 0x6f, 0x6f, 0x6e, 0x66, 0x61,
+ 0x6e, 0x74, 0x61, 0x73, 0x79, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x12,
+ 0x1e, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0a, 0x2e,
+ 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x12,
+ 0x10, 0x0a, 0x03, 0x6d, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6d, 0x69,
+ 0x64, 0x12, 0x1f, 0x0a, 0x04, 0x69, 0x6e, 0x66, 0x6f, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32,
+ 0x0b, 0x2e, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x04, 0x69, 0x6e,
+ 0x66, 0x6f, 0x22, 0x62, 0x0a, 0x15, 0x4d, 0x6f, 0x6f, 0x6e, 0x66, 0x61, 0x6e, 0x74, 0x61, 0x73,
+ 0x79, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x52, 0x65, 0x71, 0x12, 0x10, 0x0a, 0x03, 0x62,
+ 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x62, 0x69, 0x64, 0x12, 0x10, 0x0a,
+ 0x03, 0x6d, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6d, 0x69, 0x64, 0x12,
+ 0x25, 0x0a, 0x06, 0x72, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32,
+ 0x0d, 0x2e, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x52, 0x06,
+ 0x72, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x22, 0x30, 0x0a, 0x16, 0x4d, 0x6f, 0x6f, 0x6e, 0x66, 0x61,
+ 0x6e, 0x74, 0x61, 0x73, 0x79, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x52, 0x65, 0x73, 0x70,
0x12, 0x16, 0x0a, 0x06, 0x69, 0x73, 0x73, 0x75, 0x63, 0x63, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08,
- 0x52, 0x06, 0x69, 0x73, 0x73, 0x75, 0x63, 0x63, 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x69, 0x64, 0x18,
- 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6d, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x6f,
- 0x6e, 0x73, 0x74, 0x65, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x6f, 0x6e,
- 0x73, 0x74, 0x65, 0x72, 0x22, 0x37, 0x0a, 0x11, 0x4d, 0x6f, 0x6f, 0x6e, 0x66, 0x61, 0x6e, 0x74,
- 0x61, 0x73, 0x79, 0x41, 0x73, 0x6b, 0x52, 0x65, 0x71, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64,
- 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x6d,
- 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6d, 0x69, 0x64, 0x22, 0x34, 0x0a,
- 0x12, 0x4d, 0x6f, 0x6f, 0x6e, 0x66, 0x61, 0x6e, 0x74, 0x61, 0x73, 0x79, 0x41, 0x73, 0x6b, 0x52,
- 0x65, 0x73, 0x70, 0x12, 0x1e, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28,
- 0x0e, 0x32, 0x0a, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x04, 0x63,
- 0x6f, 0x64, 0x65, 0x22, 0x6e, 0x0a, 0x14, 0x4d, 0x6f, 0x6f, 0x6e, 0x66, 0x61, 0x6e, 0x74, 0x61,
- 0x73, 0x79, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x12, 0x10, 0x0a, 0x03, 0x75,
- 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x10, 0x0a,
- 0x03, 0x6d, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6d, 0x69, 0x64, 0x12,
- 0x18, 0x0a, 0x07, 0x6c, 0x65, 0x61, 0x64, 0x70, 0x6f, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05,
- 0x52, 0x07, 0x6c, 0x65, 0x61, 0x64, 0x70, 0x6f, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x74, 0x65, 0x61,
- 0x6d, 0x69, 0x64, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x09, 0x52, 0x07, 0x74, 0x65, 0x61, 0x6d,
- 0x69, 0x64, 0x73, 0x22, 0x72, 0x0a, 0x15, 0x4d, 0x6f, 0x6f, 0x6e, 0x66, 0x61, 0x6e, 0x74, 0x61,
- 0x73, 0x79, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1e, 0x0a, 0x04,
- 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0a, 0x2e, 0x45, 0x72, 0x72,
- 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x18, 0x0a, 0x07,
- 0x6d, 0x6f, 0x6e, 0x73, 0x74, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d,
- 0x6f, 0x6e, 0x73, 0x74, 0x65, 0x72, 0x12, 0x1f, 0x0a, 0x04, 0x69, 0x6e, 0x66, 0x6f, 0x18, 0x03,
- 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x49, 0x6e, 0x66,
- 0x6f, 0x52, 0x04, 0x69, 0x6e, 0x66, 0x6f, 0x22, 0x6a, 0x0a, 0x15, 0x4d, 0x6f, 0x6f, 0x6e, 0x66,
- 0x61, 0x6e, 0x74, 0x61, 0x73, 0x79, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x52, 0x65, 0x71,
- 0x12, 0x10, 0x0a, 0x03, 0x62, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x62,
- 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x6f, 0x6e, 0x73, 0x74, 0x65, 0x72, 0x18, 0x03, 0x20,
- 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x6f, 0x6e, 0x73, 0x74, 0x65, 0x72, 0x12, 0x25, 0x0a, 0x06,
- 0x72, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x42,
- 0x61, 0x74, 0x74, 0x6c, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x52, 0x06, 0x72, 0x65, 0x70,
- 0x6f, 0x72, 0x74, 0x22, 0x30, 0x0a, 0x16, 0x4d, 0x6f, 0x6f, 0x6e, 0x66, 0x61, 0x6e, 0x74, 0x61,
- 0x73, 0x79, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x52, 0x65, 0x73, 0x70, 0x12, 0x16, 0x0a,
- 0x06, 0x69, 0x73, 0x73, 0x75, 0x63, 0x63, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x69,
- 0x73, 0x73, 0x75, 0x63, 0x63, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70,
- 0x72, 0x6f, 0x74, 0x6f, 0x33,
+ 0x52, 0x06, 0x69, 0x73, 0x73, 0x75, 0x63, 0x63, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62,
+ 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
@@ -564,30 +650,35 @@ func file_moonfantasy_moonfantasy_msg_proto_rawDescGZIP() []byte {
return file_moonfantasy_moonfantasy_msg_proto_rawDescData
}
-var file_moonfantasy_moonfantasy_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 8)
+var file_moonfantasy_moonfantasy_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 10)
var file_moonfantasy_moonfantasy_msg_proto_goTypes = []interface{}{
- (*MoonfantasyTriggerReq)(nil), // 0: MoonfantasyTriggerReq
- (*MoonfantasyTriggerResp)(nil), // 1: MoonfantasyTriggerResp
- (*MoonfantasyAskReq)(nil), // 2: MoonfantasyAskReq
- (*MoonfantasyAskResp)(nil), // 3: MoonfantasyAskResp
- (*MoonfantasyBattleReq)(nil), // 4: MoonfantasyBattleReq
- (*MoonfantasyBattleResp)(nil), // 5: MoonfantasyBattleResp
- (*MoonfantasyReceiveReq)(nil), // 6: MoonfantasyReceiveReq
- (*MoonfantasyReceiveResp)(nil), // 7: MoonfantasyReceiveResp
- (ErrorCode)(0), // 8: ErrorCode
- (*BattleInfo)(nil), // 9: BattleInfo
- (*BattleReport)(nil), // 10: BattleReport
+ (*MoonfantasyGetListReq)(nil), // 0: MoonfantasyGetListReq
+ (*MoonfantasyGetListResp)(nil), // 1: MoonfantasyGetListResp
+ (*MoonfantasyTriggerReq)(nil), // 2: MoonfantasyTriggerReq
+ (*MoonfantasyTriggerResp)(nil), // 3: MoonfantasyTriggerResp
+ (*MoonfantasyAskReq)(nil), // 4: MoonfantasyAskReq
+ (*MoonfantasyAskResp)(nil), // 5: MoonfantasyAskResp
+ (*MoonfantasyBattleReq)(nil), // 6: MoonfantasyBattleReq
+ (*MoonfantasyBattleResp)(nil), // 7: MoonfantasyBattleResp
+ (*MoonfantasyReceiveReq)(nil), // 8: MoonfantasyReceiveReq
+ (*MoonfantasyReceiveResp)(nil), // 9: MoonfantasyReceiveResp
+ (*DBMoonFantasy)(nil), // 10: DBMoonFantasy
+ (ErrorCode)(0), // 11: ErrorCode
+ (*BattleInfo)(nil), // 12: BattleInfo
+ (*BattleReport)(nil), // 13: BattleReport
}
var file_moonfantasy_moonfantasy_msg_proto_depIdxs = []int32{
- 8, // 0: MoonfantasyAskResp.code:type_name -> ErrorCode
- 8, // 1: MoonfantasyBattleResp.code:type_name -> ErrorCode
- 9, // 2: MoonfantasyBattleResp.info:type_name -> BattleInfo
- 10, // 3: MoonfantasyReceiveReq.report:type_name -> BattleReport
- 4, // [4:4] is the sub-list for method output_type
- 4, // [4:4] is the sub-list for method input_type
- 4, // [4:4] is the sub-list for extension type_name
- 4, // [4:4] is the sub-list for extension extendee
- 0, // [0:4] is the sub-list for field type_name
+ 10, // 0: MoonfantasyGetListResp.dfantasys:type_name -> DBMoonFantasy
+ 11, // 1: MoonfantasyAskResp.code:type_name -> ErrorCode
+ 10, // 2: MoonfantasyAskResp.info:type_name -> DBMoonFantasy
+ 11, // 3: MoonfantasyBattleResp.code:type_name -> ErrorCode
+ 12, // 4: MoonfantasyBattleResp.info:type_name -> BattleInfo
+ 13, // 5: MoonfantasyReceiveReq.report:type_name -> BattleReport
+ 6, // [6:6] is the sub-list for method output_type
+ 6, // [6:6] is the sub-list for method input_type
+ 6, // [6:6] is the sub-list for extension type_name
+ 6, // [6:6] is the sub-list for extension extendee
+ 0, // [0:6] is the sub-list for field type_name
}
func init() { file_moonfantasy_moonfantasy_msg_proto_init() }
@@ -596,10 +687,11 @@ func file_moonfantasy_moonfantasy_msg_proto_init() {
return
}
file_errorcode_proto_init()
+ file_moonfantasy_moonfantasy_db_proto_init()
file_battle_battle_msg_proto_init()
if !protoimpl.UnsafeEnabled {
file_moonfantasy_moonfantasy_msg_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
- switch v := v.(*MoonfantasyTriggerReq); i {
+ switch v := v.(*MoonfantasyGetListReq); i {
case 0:
return &v.state
case 1:
@@ -611,7 +703,7 @@ func file_moonfantasy_moonfantasy_msg_proto_init() {
}
}
file_moonfantasy_moonfantasy_msg_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
- switch v := v.(*MoonfantasyTriggerResp); i {
+ switch v := v.(*MoonfantasyGetListResp); i {
case 0:
return &v.state
case 1:
@@ -623,7 +715,7 @@ func file_moonfantasy_moonfantasy_msg_proto_init() {
}
}
file_moonfantasy_moonfantasy_msg_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
- switch v := v.(*MoonfantasyAskReq); i {
+ switch v := v.(*MoonfantasyTriggerReq); i {
case 0:
return &v.state
case 1:
@@ -635,7 +727,7 @@ func file_moonfantasy_moonfantasy_msg_proto_init() {
}
}
file_moonfantasy_moonfantasy_msg_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
- switch v := v.(*MoonfantasyAskResp); i {
+ switch v := v.(*MoonfantasyTriggerResp); i {
case 0:
return &v.state
case 1:
@@ -647,7 +739,7 @@ func file_moonfantasy_moonfantasy_msg_proto_init() {
}
}
file_moonfantasy_moonfantasy_msg_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
- switch v := v.(*MoonfantasyBattleReq); i {
+ switch v := v.(*MoonfantasyAskReq); i {
case 0:
return &v.state
case 1:
@@ -659,7 +751,7 @@ func file_moonfantasy_moonfantasy_msg_proto_init() {
}
}
file_moonfantasy_moonfantasy_msg_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
- switch v := v.(*MoonfantasyBattleResp); i {
+ switch v := v.(*MoonfantasyAskResp); i {
case 0:
return &v.state
case 1:
@@ -671,7 +763,7 @@ func file_moonfantasy_moonfantasy_msg_proto_init() {
}
}
file_moonfantasy_moonfantasy_msg_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
- switch v := v.(*MoonfantasyReceiveReq); i {
+ switch v := v.(*MoonfantasyBattleReq); i {
case 0:
return &v.state
case 1:
@@ -683,6 +775,30 @@ func file_moonfantasy_moonfantasy_msg_proto_init() {
}
}
file_moonfantasy_moonfantasy_msg_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} {
+ switch v := v.(*MoonfantasyBattleResp); i {
+ case 0:
+ return &v.state
+ case 1:
+ return &v.sizeCache
+ case 2:
+ return &v.unknownFields
+ default:
+ return nil
+ }
+ }
+ file_moonfantasy_moonfantasy_msg_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} {
+ switch v := v.(*MoonfantasyReceiveReq); i {
+ case 0:
+ return &v.state
+ case 1:
+ return &v.sizeCache
+ case 2:
+ return &v.unknownFields
+ default:
+ return nil
+ }
+ }
+ file_moonfantasy_moonfantasy_msg_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*MoonfantasyReceiveResp); i {
case 0:
return &v.state
@@ -701,7 +817,7 @@ func file_moonfantasy_moonfantasy_msg_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_moonfantasy_moonfantasy_msg_proto_rawDesc,
NumEnums: 0,
- NumMessages: 8,
+ NumMessages: 10,
NumExtensions: 0,
NumServices: 0,
},
diff --git a/sys/db/dbconn.go b/sys/db/dbconn.go
index ba8698277..736dde47d 100644
--- a/sys/db/dbconn.go
+++ b/sys/db/dbconn.go
@@ -89,10 +89,10 @@ type DBModel struct {
}
func (this *DBModel) ukey(uid string) string {
- return fmt.Sprintf("%s:%s{%s}", this.TableName, uid, this.TableName)
+ return fmt.Sprintf("%s:%s", this.TableName, uid)
}
func (this *DBModel) ukeylist(uid string, id string) string {
- return fmt.Sprintf("%s:%s-%s{%s}", this.TableName, uid, id, this.TableName)
+ return fmt.Sprintf("%s:%s-%s", this.TableName, uid, id)
}
func (this *DBModel) InsertModelLogs(table string, uID string, target interface{}) (err error) {
@@ -326,6 +326,116 @@ func (this *DBModel) Get(uid string, data interface{}, opt ...DBOption) (err err
return
}
+//读取多个数据对象
+func (this *DBModel) Gets(ids []string, data interface{}, opt ...DBOption) (err error) {
+ //defer log.Debug("DBModel GetListObjs", log.Field{Key: "TableName", Value: this.TableName}, log.Field{Key: "uid", Value: uid}, log.Field{Key: "ids", Value: ids}, log.Field{Key: "data", Value: data})
+ var (
+ dtype reflect2.Type
+ dkind reflect.Kind
+ sType reflect2.Type
+ sliceType *reflect2.UnsafeSliceType
+ sliceelemType reflect2.Type
+ decoder codecore.IDecoderMapJson
+ encoder codecore.IEncoderMapJson
+ dptr unsafe.Pointer
+ elemPtr unsafe.Pointer
+ n int
+ ok bool
+ keys map[string]string = make(map[string]string)
+ tempdata map[string]string
+ onfound []string = make([]string, 0, len(ids))
+ pipe *pipe.RedisPipe = this.Redis.RedisPipe(context.TODO())
+ result []*redis.StringStringMapCmd = make([]*redis.StringStringMapCmd, len(ids))
+ c *mongo.Cursor
+ )
+ dptr = reflect2.PtrOf(data)
+ dtype = reflect2.TypeOf(data)
+ dkind = dtype.Kind()
+ if dkind != reflect.Ptr {
+ err = fmt.Errorf("MCompModel: GetList(non-pointer %T)", data)
+ return
+ }
+ sType = dtype.(*reflect2.UnsafePtrType).Elem()
+ if sType.Kind() != reflect.Slice {
+ err = fmt.Errorf("MCompModel: GetList(data no slice %T)", data)
+ return
+ }
+ sliceType = sType.(*reflect2.UnsafeSliceType)
+ sliceelemType = sliceType.Elem()
+ if sliceelemType.Kind() != reflect.Ptr {
+ err = fmt.Errorf("MCompModel: GetList(sliceelemType non-pointer %T)", data)
+ return
+ }
+ if decoder, ok = codec.DecoderOf(sliceelemType, defconf).(codecore.IDecoderMapJson); !ok {
+ err = fmt.Errorf("MCompModel: GetList(data not support MarshalMapJson %T)", data)
+ return
+ }
+ sliceelemType = sliceelemType.(*reflect2.UnsafePtrType).Elem()
+ for i, v := range ids {
+ result[i] = pipe.HGetAllToMapString(this.ukey(v))
+ }
+ if _, err = pipe.Exec(); err == nil {
+ for i, v := range result {
+ if tempdata, err = v.Result(); err == nil {
+ sliceType.UnsafeGrow(dptr, n+1)
+ elemPtr = sliceType.UnsafeGetIndex(dptr, n)
+ if *((*unsafe.Pointer)(elemPtr)) == nil {
+ newPtr := sliceelemType.UnsafeNew()
+ if err = decoder.DecodeForMapJson(newPtr, json.GetReader([]byte{}), tempdata); err != nil {
+ log.Errorf("err:%v", err)
+ return
+ }
+ *((*unsafe.Pointer)(elemPtr)) = newPtr
+ } else {
+ decoder.DecodeForMapJson(*((*unsafe.Pointer)(elemPtr)), json.GetReader([]byte{}), tempdata)
+ }
+ n++
+ } else {
+ onfound = append(onfound, ids[i])
+ }
+ }
+ } else {
+ onfound = ids
+ }
+
+ if err == lgredis.RedisNil {
+ if c, err = this.DB.Find(core.SqlTable(this.TableName), bson.M{"_id": bson.M{"$in": onfound}}); err != nil {
+ return err
+ } else {
+ pipe := this.Redis.RedisPipe(context.TODO())
+ for c.Next(context.Background()) {
+ _id := c.Current.Lookup("_id").StringValue()
+ sliceType.UnsafeGrow(dptr, n+1)
+ elemPtr = sliceType.UnsafeGetIndex(dptr, n)
+ if *((*unsafe.Pointer)(elemPtr)) == nil {
+ newPtr := sliceelemType.UnsafeNew()
+ *((*unsafe.Pointer)(elemPtr)) = newPtr
+ }
+ elem := sliceType.GetIndex(data, n)
+ if err = c.Decode(elem); err != nil {
+ return
+ }
+ if tempdata, err = encoder.EncodeToMapJson(*((*unsafe.Pointer)(elemPtr)), json.GetWriter()); err != nil {
+ return
+ }
+ key := this.ukey(_id)
+ pipe.HMSetForMap(key, tempdata)
+ keys[_id] = key
+ n++
+ }
+ if len(keys) > 0 {
+ _, err = pipe.Exec()
+ }
+ }
+ }
+ if this.Expired > 0 {
+ for _, v := range ids {
+ UpDateModelExpired(this.ukey(v), nil, this.Expired)
+ }
+ }
+ return
+}
+
//获取列表数据 注意 data 必须是 切片的指针 *[]type
func (this *DBModel) GetList(uid string, data interface{}) (err error) {
//defer log.Debug("DBModel GetList", log.Field{Key: "TableName", Value: this.TableName}, log.Field{Key: "uid", Value: uid}, log.Field{Key: "data", Value: data})
@@ -537,7 +647,6 @@ func (this *DBModel) GetFields(uid string, data interface{}, fields ...string) (
func (this *DBModel) GetListFields(uid string, id string, data interface{}, fields ...string) (err error) {
//defer log.Debug("DBModel GetListFields", log.Field{Key: "TableName", Value: this.TableName}, log.Field{Key: "uid", Value: uid}, log.Field{Key: "id", Value: id}, log.Field{Key: "data", Value: data})
var (
- c *mongo.Cursor
keys map[string]string
tempdata map[string]string
)
@@ -545,36 +654,16 @@ func (this *DBModel) GetListFields(uid string, id string, data interface{}, fiel
return
}
if err == lgredis.RedisNil {
- if c, err = this.DB.Find(core.SqlTable(this.TableName), bson.M{"uid": uid}); err != nil {
+ if err = this.DB.FindOne(core.SqlTable(this.TableName), bson.M{"_id": id}).Decode(data); err != nil {
return err
} else {
pipe := this.Redis.RedisPipe(context.TODO())
- dtype := reflect2.TypeOf(data).(*reflect2.UnsafeStructType)
- for c.Next(context.Background()) {
- _id := c.Current.Lookup("_id").StringValue()
- if _id != id {
- temp := dtype.New()
- if err = c.Decode(temp); err != nil {
- return
- }
- if tempdata, err = json.MarshalMap(temp); err != nil {
- return
- }
- } else {
- if err = c.Decode(data); err != nil {
- return
- }
- if tempdata, err = json.MarshalMap(data); err != nil {
- return
- }
- }
- key := this.ukeylist(uid, _id)
- pipe.HMSetForMap(key, tempdata)
- keys[_id] = key
- }
- if len(keys) > 0 {
- pipe.HMSetForMap(this.ukey(uid), keys)
- _, err = pipe.Exec()
+ key := this.ukeylist(uid, id)
+ pipe.HMSetForMap(key, tempdata)
+ keys[id] = key
+ pipe.HMSetForMap(this.ukey(uid), keys)
+ if _, err = pipe.Exec(); err != nil {
+ return
}
}
}
@@ -592,57 +681,27 @@ func (this *DBModel) GetListFields(uid string, id string, data interface{}, fiel
func (this *DBModel) GetListObj(uid string, id string, data interface{}) (err error) {
//defer log.Debug("DBModel GetListObj", log.Field{Key: "TableName", Value: this.TableName}, log.Field{Key: "uid", Value: uid}, log.Field{Key: "id", Value: id}, log.Field{Key: "data", Value: data})
var (
- c *mongo.Cursor
keys map[string]string
tempdata map[string]string
- isfound bool
)
keys = make(map[string]string)
if err = this.Redis.HGetAll(this.ukeylist(uid, id), data); err != nil && err != lgredis.RedisNil {
return
}
- isfound = true
if err == lgredis.RedisNil {
- isfound = false
- if c, err = this.DB.Find(core.SqlTable(this.TableName), bson.M{"uid": uid}); err != nil {
+ if err = this.DB.FindOne(core.SqlTable(this.TableName), bson.M{"_id": id}).Decode(data); err != nil {
return err
} else {
pipe := this.Redis.RedisPipe(context.TODO())
- // dtype := reflect2.TypeOf(data).(*reflect2.UnsafeStructType)
- dtype := reflect2.TypeOf(data).(*reflect2.UnsafePtrType).Elem().(*reflect2.UnsafeStructType)
- for c.Next(context.Background()) {
- _id := c.Current.Lookup("_id").StringValue()
- if _id != id {
- temp := dtype.New()
- if err = c.Decode(temp); err != nil {
- return
- }
- if tempdata, err = json.MarshalMap(temp); err != nil {
- return
- }
- } else {
- if err = c.Decode(data); err != nil {
- return
- }
- if tempdata, err = json.MarshalMap(data); err != nil {
- return
- }
- isfound = true
- }
- key := this.ukeylist(uid, _id)
- pipe.HMSetForMap(key, tempdata)
- keys[_id] = key
- }
- if len(keys) > 0 {
- pipe.HMSetForMap(this.ukey(uid), keys)
- _, err = pipe.Exec()
+ key := this.ukeylist(uid, id)
+ pipe.HMSetForMap(key, tempdata)
+ keys[id] = key
+ pipe.HMSetForMap(this.ukey(uid), keys)
+ if _, err = pipe.Exec(); err != nil {
+ return
}
}
}
- if !isfound {
- err = fmt.Errorf("no found data table:%s uid:%s id:%s", this.TableName, uid, id)
- return
- }
if this.Expired > 0 {
childs := make(map[string]struct{}, len(keys))
for _, v := range keys {
@@ -726,7 +785,7 @@ func (this *DBModel) GetListObjs(uid string, ids []string, data interface{}) (er
}
if err == lgredis.RedisNil {
- if c, err = this.DB.Find(core.SqlTable(this.TableName), bson.M{"uid": uid}); err != nil {
+ if c, err = this.DB.Find(core.SqlTable(this.TableName), bson.M{"_id": bson.M{"$in": ids}}); err != nil {
return err
} else {
pipe := this.Redis.RedisPipe(context.TODO())
@@ -766,8 +825,22 @@ func (this *DBModel) GetListObjs(uid string, ids []string, data interface{}) (er
return
}
+//删除目标数据
+func (this *DBModel) Del(id string, opt ...DBOption) (err error) {
+ //defer log.Debug("DBModel Del", log.Field{Key: "TableName", Value: this.TableName}, log.Field{Key: "uid", Value: uid})
+ err = this.Redis.Delete(this.ukey(id))
+ if err != nil {
+ return err
+ }
+ option := newDBOption(opt...)
+ if option.IsMgoLog {
+ err = this.DeleteModelLogs(this.TableName, "", bson.M{"_id": id})
+ }
+ return nil
+}
+
//删除用户数据
-func (this *DBModel) Del(uid string, opt ...DBOption) (err error) {
+func (this *DBModel) DelByUId(uid string, opt ...DBOption) (err error) {
//defer log.Debug("DBModel Del", log.Field{Key: "TableName", Value: this.TableName}, log.Field{Key: "uid", Value: uid})
err = this.Redis.Delete(this.ukey(uid))
if err != nil {