上传月之秘境数据层优化
This commit is contained in:
parent
e1e6498215
commit
50fd39e1f0
@ -131,8 +131,8 @@ const (
|
||||
TableVikingRankList = "vikingranklist"
|
||||
|
||||
//月之秘境
|
||||
TableMoonfantasy = "moonfantasy"
|
||||
|
||||
TableMoonFantasy = "moonfantasy"
|
||||
TableUserMFantasy = "usermfantasy"
|
||||
//
|
||||
TableHunting = "hunting"
|
||||
// 维京远征排行榜
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 属性数值
|
||||
/// </summary>
|
||||
type AttributeNumeric struct {
|
||||
fixedValue FixedPoint
|
||||
/// <summary>
|
||||
/// 基础数值
|
||||
/// </summary>
|
||||
BaseValue FixedNumeric
|
||||
/// <summary>
|
||||
/// 附加数值
|
||||
/// </summary>
|
||||
AppendValue FixedNumeric
|
||||
/// <summary>
|
||||
/// 附加百分比数值
|
||||
/// </summary>
|
||||
ProValue FixedNumeric
|
||||
/// <summary>
|
||||
/// Buff附加数值
|
||||
/// </summary>
|
||||
BuffValue FixedNumeric
|
||||
/// <summary>
|
||||
/// Buff附加百分比数值
|
||||
/// </summary>
|
||||
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())
|
||||
}
|
@ -1,58 +0,0 @@
|
||||
package attribute
|
||||
|
||||
func NewFixedNumeric(pData float32) FixedNumeric {
|
||||
fixed := FixedNumeric{}
|
||||
fixed.SetFloat(pData)
|
||||
return fixed
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 浮点型数值
|
||||
/// </summary>
|
||||
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()
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 增加基本值
|
||||
/// </summary>
|
||||
func (this FixedNumeric) Add(value float32) float32 {
|
||||
this.baseValue.Add(value)
|
||||
return this.baseValue.Scalar()
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 减少基本值
|
||||
/// </summary>
|
||||
func (this FixedNumeric) Minus(value float32) float32 {
|
||||
this.baseValue.Reduce(value)
|
||||
if this.baseValue.Scalar() < 0 {
|
||||
this.baseValue.SetInt(0)
|
||||
}
|
||||
return this.baseValue.Scalar()
|
||||
}
|
@ -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))
|
||||
}
|
@ -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),
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 生命值实体
|
||||
/// </summary>
|
||||
type HealthPoint struct {
|
||||
/// <summary>
|
||||
/// 生命值
|
||||
/// </summary>
|
||||
Hp *FixedNumeric
|
||||
/// <summary>
|
||||
/// 最大生命值
|
||||
/// </summary>
|
||||
MaxHp *AttributeNumeric
|
||||
/// <summary>
|
||||
/// 当前最大生命值
|
||||
/// </summary>
|
||||
CurrMaxHp *AttributeNumeric
|
||||
/// <summary>
|
||||
/// 当前最大生命百分比加成
|
||||
/// </summary>
|
||||
CurrMaxHpPro *AttributeNumeric
|
||||
/// <summary>
|
||||
/// 当前最大生命加成
|
||||
/// </summary>
|
||||
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}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重置当前生命值为最大值
|
||||
/// </summary>
|
||||
func (this *HealthPoint) Reset() {
|
||||
this.Hp.SetFloat(this.CurrMaxHp.Value())
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 扣血
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
func (this *HealthPoint) Minus(value float32) {
|
||||
this.Hp.Minus(value)
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加血
|
||||
/// </summary>
|
||||
func (this *HealthPoint) Add(value float32) {
|
||||
if FixedPoint_Add(this.Hp.Fixed(), NewFixedPoint(value)) > this.CurrMaxHp.Fixed() {
|
||||
this.Reset()
|
||||
} else {
|
||||
this.Hp.Add(value)
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取治疗溢出值
|
||||
/// </summary>
|
||||
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
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 剩余血量百分比
|
||||
/// </summary>
|
||||
func (this *HealthPoint) Percent() float32 {
|
||||
return FixedPoint_Divide(this.Hp.Fixed(), this.CurrMaxHp.Fixed()).Scalar()
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 损失血量百分比
|
||||
/// </summary>
|
||||
func (this *HealthPoint) LostPercent() float32 {
|
||||
return FixedPoint_Divide((this.CurrMaxHp.Fixed() - this.Hp.Fixed()), this.CurrMaxHp.Fixed()).Scalar()
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 指定百分比血量
|
||||
/// </summary>
|
||||
func (this *HealthPoint) PercentHealth(pct float32) float32 {
|
||||
return FixedPoint_Multiply(this.CurrMaxHp.Fixed(), NewFixedPoint(pct)).Scalar()
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 扣除的血量
|
||||
/// </summary>
|
||||
func (this *HealthPoint) Deduct() float32 {
|
||||
return FixedPoint(this.CurrMaxHp.Fixed() - this.Hp.Fixed()).Scalar()
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否满血
|
||||
/// </summary>
|
||||
func (this *HealthPoint) IsFull() bool {
|
||||
return this.Hp.Fixed() == this.CurrMaxHp.Fixed()
|
||||
}
|
5
modules/battle/fight/buff/buffbase.go
Normal file
5
modules/battle/fight/buff/buffbase.go
Normal file
@ -0,0 +1,5 @@
|
||||
package buff
|
||||
|
||||
//基础buff
|
||||
type BuffBase struct {
|
||||
}
|
@ -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)
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 当前buff效果是否需要同步血量
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
func (this FightBuff) NeedHpSync() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 回合开始开始需要触发效果的
|
||||
/// </summary>
|
||||
func (this FightBuff) OnRoundStart() {
|
||||
|
||||
}
|
@ -1,125 +0,0 @@
|
||||
package buff
|
||||
|
||||
import "go_dreamfactory/modules/battle/fight/core"
|
||||
|
||||
type FightBuffBase struct {
|
||||
/// <summary>
|
||||
/// 所属子技能ID
|
||||
/// </summary>
|
||||
AfterSkillId int
|
||||
/// <summary>
|
||||
/// Buff投放者
|
||||
/// </summary>
|
||||
FromRole core.IFightRole
|
||||
/// <summary>
|
||||
/// Buff持有者
|
||||
/// </summary>
|
||||
OwnerRole core.IFightRole
|
||||
/// <summary>
|
||||
/// 剩余持续回合数
|
||||
/// </summary>
|
||||
duration int
|
||||
/// <summary>
|
||||
/// 叠加层数 [叠加Buff不立即叠加效果, 受BufParNum影响]
|
||||
/// </summary>
|
||||
OverlapNum int
|
||||
/// <summary>
|
||||
/// 叠加Buff当前效果次数
|
||||
/// </summary>
|
||||
EffectNum int
|
||||
/// <summary>
|
||||
/// 是否无限回合
|
||||
/// </summary>
|
||||
AlwaysExist bool
|
||||
BufParNum int
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// cd 回合数
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// -1 无限回合,0 回合结束后移除
|
||||
/// </remarks>
|
||||
func (this FightBuffBase) GetRound() int {
|
||||
return this.duration
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// cd 回合数
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// -1 无限回合,0 回合结束后移除
|
||||
/// </remarks>
|
||||
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) {
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 结束Buff
|
||||
/// </summary>
|
||||
func (this FightBuffBase) End(skill core.IAfterSkill) {
|
||||
this.Restore()
|
||||
this.OnEnd(skill)
|
||||
this.Clear()
|
||||
}
|
||||
|
||||
/// 战斗结束时的清理
|
||||
func (this FightBuffBase) Clear() {
|
||||
|
||||
}
|
||||
|
||||
//CD 处理--------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
/// <summary>
|
||||
/// 增加剩余回合数 v 默认:1
|
||||
/// </summary>
|
||||
/// <returns>新的回合数</returns>
|
||||
func (this FightBuffBase) AddDuration(v int) int {
|
||||
this.duration += v
|
||||
return this.duration
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 减少剩余回合数 v 默认:1
|
||||
/// </summary>
|
||||
/// <returns>新的回合数</returns>
|
||||
func (this FightBuffBase) MinusDuration(v int) int {
|
||||
this.duration -= v
|
||||
if this.duration < 0 {
|
||||
this.duration = 0
|
||||
}
|
||||
this.SetDuration(this.duration)
|
||||
return this.duration
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置剩余回合数为新的值
|
||||
/// </summary>
|
||||
/// <param name="newVal"></param>
|
||||
func (this FightBuffBase) SetDuration(newVal int) int {
|
||||
this.duration = newVal
|
||||
if this.duration == 0 && !this.AlwaysExist {
|
||||
this.End(nil)
|
||||
}
|
||||
return this.duration
|
||||
}
|
@ -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)
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
package buff
|
||||
|
||||
import (
|
||||
"go_dreamfactory/modules/battle/fight/core"
|
||||
)
|
||||
|
||||
func NewFightProPercentBuff(proType int, quaType bool) *FightProPercentBuff {
|
||||
return &FightProPercentBuff{}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改属性buff (百分比数值)
|
||||
/// </summary
|
||||
type FightProPercentBuff struct {
|
||||
FightBuff
|
||||
/// <summary>
|
||||
/// 属性类型
|
||||
/// </summary>
|
||||
ProType int
|
||||
/// <summary>
|
||||
/// 是否减法
|
||||
/// </summary>
|
||||
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)
|
||||
}
|
@ -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)
|
||||
}
|
@ -1,224 +0,0 @@
|
||||
package component
|
||||
|
||||
import (
|
||||
"go_dreamfactory/modules/battle/fight/buff"
|
||||
"go_dreamfactory/modules/battle/fight/core"
|
||||
)
|
||||
|
||||
type BuffStore struct {
|
||||
/// <summary>
|
||||
/// 已经添加的buff类型
|
||||
/// </summary>
|
||||
HasBuffTypes []int
|
||||
/// <summary>
|
||||
/// Buff列表 [BuffId, FightBuff]
|
||||
/// </summary>
|
||||
Buffs map[int][]core.IBuff
|
||||
temp []int
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找相同 BuffId 的Buff
|
||||
/// </summary>
|
||||
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
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找不是指定 BuffId 的Buff
|
||||
/// </summary>
|
||||
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
|
||||
}
|
||||
|
||||
/// <summary>获取指定buff列表</summary>
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 附加Buff
|
||||
/// 默认参数 param=0;shift=false
|
||||
/// </summary>
|
||||
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()
|
||||
}
|
@ -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)
|
||||
}
|
@ -1,162 +0,0 @@
|
||||
package core
|
||||
|
||||
type BuffType int
|
||||
|
||||
const (
|
||||
/// <summary>
|
||||
/// 无效类型
|
||||
/// </summary>
|
||||
BuffType_NONE = 0
|
||||
/// <summary>
|
||||
/// 攻击提升
|
||||
/// </summary>
|
||||
BuffType_ATKUP = 1
|
||||
/// <summary>
|
||||
/// 防御提升
|
||||
/// </summary>
|
||||
BuffType_DEFUP = 2
|
||||
/// <summary>
|
||||
/// 速度提升
|
||||
/// </summary>
|
||||
BuffType_SPDUP = 3
|
||||
/// <summary>
|
||||
/// 暴击提升
|
||||
/// </summary>
|
||||
BuffType_CRATEUP = 4
|
||||
/// <summary>
|
||||
/// 暴击抵抗
|
||||
/// </summary>
|
||||
BuffType_CRITRESIST = 5
|
||||
/// <summary>
|
||||
/// 攻击下降
|
||||
/// </summary>
|
||||
BuffType_ATKDOWN = 6
|
||||
/// <summary>
|
||||
/// 防御下降
|
||||
/// </summary>
|
||||
BuffType_DEFDOWN = 7
|
||||
/// <summary>
|
||||
/// 速度下降
|
||||
/// </summary>
|
||||
BuffType_SPDDOWN = 8
|
||||
/// <summary>
|
||||
/// 暴击下降
|
||||
/// </summary>
|
||||
BuffType_CRATEDOWN = 9
|
||||
/// <summary>
|
||||
/// 烙印
|
||||
/// </summary>
|
||||
BuffType_SEAR = 10
|
||||
/// <summary>
|
||||
/// 失手率提升
|
||||
/// </summary>
|
||||
BuffType_MISSRATEUP = 11
|
||||
/// <summary>
|
||||
/// 无敌
|
||||
/// </summary>
|
||||
BuffType_INVINCIBILITY = 12
|
||||
/// <summary>
|
||||
/// 对峙
|
||||
/// </summary>
|
||||
BuffType_STANDOFF = 13
|
||||
/// <summary>
|
||||
/// 眩晕
|
||||
/// </summary>
|
||||
BuffType_STUN = 14
|
||||
/// <summary>
|
||||
/// 冰冻
|
||||
/// </summary>
|
||||
BuffType_FREEZE = 15
|
||||
/// <summary>
|
||||
/// 禁疗
|
||||
/// </summary>
|
||||
BuffType_DISEASED = 16
|
||||
/// <summary>
|
||||
/// 石化
|
||||
/// </summary>
|
||||
BuffType_PETRIFICATION = 17
|
||||
/// <summary>
|
||||
/// 沉默
|
||||
/// </summary>
|
||||
BuffType_SILENCE = 18
|
||||
/// <summary>
|
||||
/// 挑衅
|
||||
/// </summary>
|
||||
BuffType_TAUNT = 19
|
||||
/// <summary>
|
||||
/// 免疫
|
||||
/// </summary>
|
||||
BuffType_IMMUNITY = 20
|
||||
/// <summary>
|
||||
/// 护盾
|
||||
/// </summary>
|
||||
BuffType_SHIELD = 21
|
||||
/// <summary>
|
||||
/// 不可移动
|
||||
/// </summary>
|
||||
BuffType_NOTSPEED = 22
|
||||
/// <summary>
|
||||
/// 受到伤害降低
|
||||
/// </summary>
|
||||
BuffType_DAMREUP = 23
|
||||
/// <summary>
|
||||
/// 血量提升
|
||||
/// </summary>
|
||||
BuffType_HPUP = 24
|
||||
/// <summary>
|
||||
/// 效果命中提升
|
||||
/// </summary>
|
||||
BuffType_EFFHITUP = 25
|
||||
/// <summary>
|
||||
/// 效果抵抗提升
|
||||
/// </summary>
|
||||
BuffType_EFFREUP = 26
|
||||
/// <summary>
|
||||
/// 血量下降
|
||||
/// </summary>
|
||||
BuffType_HPDOWN = 27
|
||||
/// <summary>
|
||||
/// 效果命中下降
|
||||
/// </summary>
|
||||
BuffType_EFFHITDOWN = 28
|
||||
/// <summary>
|
||||
/// 效果抵抗下降
|
||||
/// </summary>
|
||||
BuffType_EFFREDOWN = 29
|
||||
/// <summary>
|
||||
/// 伤害提升增加
|
||||
/// </summary>
|
||||
BuffType_CAUSEDAMUP = 30
|
||||
/// <summary>
|
||||
/// 中毒
|
||||
/// </summary>
|
||||
BuffType_POISON = 31
|
||||
/// <summary>
|
||||
/// 属性转换
|
||||
/// </summary>
|
||||
BuffType_ATTRTRANS = 32
|
||||
/// <summary>
|
||||
/// 不死
|
||||
/// </summary>
|
||||
BuffType_UNDEAD = 33
|
||||
/// <summary>
|
||||
/// 吞噬
|
||||
/// </summary>
|
||||
BuffType_DEVOUR = 34
|
||||
/// <summary>
|
||||
/// 不会失手
|
||||
/// </summary>
|
||||
BuffType_DONTMISS = 35
|
||||
/// <summary>
|
||||
/// 不能获得增益buff
|
||||
/// </summary>
|
||||
BuffType_NOTGAIN = 36
|
||||
/// <summary>
|
||||
/// 免疫控制
|
||||
/// </summary>
|
||||
BuffType_NOTCONTROL = 37
|
||||
/// <summary>
|
||||
/// 睡眠
|
||||
/// </summary>
|
||||
BuffType_SLEEP = 38
|
||||
)
|
42
modules/battle/fight/core/cmd.go
Normal file
42
modules/battle/fight/core/cmd.go
Normal file
@ -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
|
||||
}
|
@ -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()
|
||||
/// <summary>
|
||||
/// 获取行动角色
|
||||
/// 计算当前可以行动的角色,没有时返回null
|
||||
/// </summary>
|
||||
GetActionRole() IFightRole
|
||||
|
||||
/// 增加一个参战角色
|
||||
AddRole(role IFightRole)
|
||||
/// 触发队长技,队长技配置在atk表中,触发顺序无所谓
|
||||
EmitCaptainSkill()
|
||||
/// <summary>
|
||||
/// LastActionRole触发SkillId技能,选择的目标是TargetRid
|
||||
/// 手动时,表现层在玩家操作后,调用本方法
|
||||
/// 自动战斗或服务端里,通过FightAI逻辑来自动触发
|
||||
/// </summary>
|
||||
/// <param name="skillid">技能ID</param>
|
||||
/// <param name="targetRid">选择的目标rid</param>
|
||||
EmitSkill(skillId int32, targetRid []int32)
|
||||
/// <summary>
|
||||
/// 触发的释放主技能添加到这边(出手角色主技能执行完了,再执行)
|
||||
/// </summary>
|
||||
AddPassiveMainSkill(role IFightRole, skillId int32)
|
||||
/// <summary>
|
||||
/// 生成随机数
|
||||
/// </summary>
|
||||
/// <param name="minNum">最小值(含)</param>
|
||||
/// <param name="maxNum">最大值(含)</param>
|
||||
/// <returns></returns>
|
||||
Rand(min, max int) int
|
||||
}
|
||||
//战斗角色
|
||||
IFightRole interface {
|
||||
/// <summary>
|
||||
/// 战斗实例
|
||||
/// </summary>
|
||||
GetFightBase() IFight
|
||||
/// <summary>
|
||||
/// 角色数据
|
||||
/// </summary>
|
||||
GetData() *FightRoleData
|
||||
GetCurrentHealth() *attribute.HealthPoint
|
||||
/// <summary>
|
||||
/// 增加一个主技能
|
||||
/// </summary>
|
||||
/// <param name="skillId">技能id</param>
|
||||
/// <param name="skillLv">技能等级</param>
|
||||
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
|
||||
/// <summary>
|
||||
/// 当前是否能进行攻击行为
|
||||
/// 如果有行动类控制buff,如昏迷,冰冻等,则不能攻击
|
||||
/// </summary>
|
||||
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 {
|
||||
/// <summary>
|
||||
/// 获取技能配置信息
|
||||
/// </summary>
|
||||
GetSkillConf() *cfg.GameSkillAtkData
|
||||
GetSourceSkillId() int32
|
||||
SetSourceSkillId(skillid int32)
|
||||
GetSkillLog() *ComSkillAfterAtk
|
||||
/// <summary>
|
||||
/// 触发
|
||||
/// 遍历所有ChildSkills,生成对应的实例,并Emit触发
|
||||
/// </summary>
|
||||
Emit() bool
|
||||
/// <summary>
|
||||
/// 减少CD回合数
|
||||
/// </summary>
|
||||
/// <returns>新的回合数</returns>
|
||||
MinusCD(val int32) int32
|
||||
/// <summary>
|
||||
/// 增加CD回合数
|
||||
/// </summary>
|
||||
/// <returns>新的回合数</returns>
|
||||
ResetCD() int32
|
||||
/// <summary>
|
||||
/// 设置CD回合数为新的值
|
||||
/// </summary>
|
||||
/// <param name="newVal"></param>
|
||||
/// <returns></returns>
|
||||
SetCD(newVal int32) int32
|
||||
/// <summary>
|
||||
/// 战斗结束时的清理
|
||||
/// </summary>
|
||||
Clear()
|
||||
/// <summary>
|
||||
///发送技能日志
|
||||
///</summary>
|
||||
SendSkillLog()
|
||||
}
|
||||
IAfterSkill interface {
|
||||
GetOwnerRole() IFightRole
|
||||
GetAfterSkillConf() cfg.GameSkillAfteratkData
|
||||
GetSkillArgs() []int
|
||||
GetSourceSkillId() int
|
||||
AddLog(pCom IComEffectSkill)
|
||||
AddSkillLog(afterAtk *ComSkillAfterAtk)
|
||||
/// <summary>
|
||||
/// 战斗结束时的清理
|
||||
/// </summary>
|
||||
Clear()
|
||||
}
|
||||
//Buff对象
|
||||
IBuff interface {
|
||||
GetBuffConf() *cfg.GameSkillBuffData
|
||||
/// 激活Buff
|
||||
Activate(param float32)
|
||||
/// 结束Buff
|
||||
OnEnd(skill IAfterSkill)
|
||||
/// <summary>
|
||||
/// 战斗结束时的清理
|
||||
/// </summary>
|
||||
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)
|
||||
}
|
||||
|
@ -1,7 +1,5 @@
|
||||
package core
|
||||
|
||||
import "fmt"
|
||||
|
||||
/// <summary>
|
||||
/// 战斗类型枚举
|
||||
/// </summary>
|
||||
@ -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
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 主技能命令集合
|
||||
/// </summary>
|
||||
type ComSkillAtk struct {
|
||||
AniName string
|
||||
Skillid int
|
||||
From byte
|
||||
comList []*ComSkillAfterAtk
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 回收到对象池时重设数据
|
||||
/// </summary>
|
||||
func (this *ComSkillAtk) Recycle() {
|
||||
this.AniName = ""
|
||||
this.Skillid = 0
|
||||
this.From = 0
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 子技能命令集合
|
||||
/// </summary>
|
||||
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 修改
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 回收到对象池时重设数据
|
||||
/// </summary>
|
||||
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
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 生命值修改命令
|
||||
/// </summary>
|
||||
type ComModifyHealth struct {
|
||||
ComEffectSkill
|
||||
HideDmg bool
|
||||
From int
|
||||
Baoji bool
|
||||
Miss bool
|
||||
Num float32
|
||||
Nhp int32
|
||||
Mhp int32
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 回收到对象池时重设数据
|
||||
/// </summary>
|
||||
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
|
||||
}
|
||||
|
@ -1,12 +0,0 @@
|
||||
package core
|
||||
|
||||
const StepNum int = 10
|
||||
|
||||
/// <summary>
|
||||
/// 效果触发概率判断
|
||||
/// </summary>
|
||||
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
|
||||
}
|
@ -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
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取真实属性值
|
||||
/// </summary>
|
||||
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
|
||||
}
|
||||
|
||||
/// <summary>尝试设置属性</summary>
|
||||
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
|
||||
}
|
@ -1,157 +0,0 @@
|
||||
package core
|
||||
|
||||
import (
|
||||
"go_dreamfactory/modules/battle/fight/attribute"
|
||||
)
|
||||
|
||||
type FightRoleData struct {
|
||||
/// <summary>
|
||||
/// 角色名
|
||||
/// </summary>
|
||||
Name string
|
||||
/// <summary>
|
||||
/// 阵营 1=我 2=敌
|
||||
/// </summary>
|
||||
Side byte
|
||||
/// <summary>
|
||||
/// 种族 1灼热, 2涌动, 3呼啸, 4闪耀
|
||||
/// </summary>
|
||||
Race byte
|
||||
/// <summary>
|
||||
/// 站位 1~5
|
||||
/// </summary>
|
||||
Pos byte
|
||||
/// <summary>
|
||||
/// 唯一标记,同时也是List FightBase.Roles的索引
|
||||
/// </summary>
|
||||
Rid int
|
||||
/// <summary>
|
||||
/// 唯一id, 用于调试打日志
|
||||
/// </summary>
|
||||
UniqueId string
|
||||
/// <summary>
|
||||
/// 是否活着
|
||||
/// </summary>
|
||||
ALive bool
|
||||
/// <summary>
|
||||
/// 是否队长
|
||||
/// </summary>
|
||||
Captain bool
|
||||
/// <summary>
|
||||
/// 队长技 id
|
||||
/// </summary>
|
||||
CaptainSkillId int32
|
||||
|
||||
//region 战斗属性-----------------------------------------------------------------------
|
||||
/// <summary>
|
||||
/// 行动值
|
||||
/// </summary>
|
||||
Operate *attribute.AttributeNumeric
|
||||
/// <summary>
|
||||
/// 最大生命
|
||||
/// </summary>
|
||||
MaxHp *attribute.AttributeNumeric
|
||||
|
||||
/// <summary>
|
||||
/// 当前生命
|
||||
/// </summary>
|
||||
Hp *attribute.AttributeNumeric
|
||||
|
||||
/// <summary>
|
||||
/// 攻击
|
||||
/// </summary>
|
||||
Atk *attribute.AttributeNumeric
|
||||
|
||||
/// <summary>
|
||||
/// 防御
|
||||
/// </summary>
|
||||
Def *attribute.AttributeNumeric
|
||||
|
||||
/// <summary>
|
||||
/// 速度
|
||||
/// </summary>
|
||||
Speed *attribute.AttributeNumeric
|
||||
|
||||
/// <summary>
|
||||
/// 暴击率
|
||||
/// </summary>
|
||||
Critical *attribute.AttributeNumeric
|
||||
|
||||
/// <summary>
|
||||
/// 暴击伤害
|
||||
/// </summary>
|
||||
CriticalPower *attribute.AttributeNumeric
|
||||
|
||||
/// <summary>
|
||||
/// 效果命中
|
||||
/// </summary>
|
||||
EffectHit *attribute.AttributeNumeric
|
||||
|
||||
/// <summary>
|
||||
/// 效果抵抗
|
||||
/// </summary>
|
||||
EfectResist *attribute.AttributeNumeric
|
||||
|
||||
/// <summary>
|
||||
/// 失手率
|
||||
/// </summary>
|
||||
LostHold *attribute.AttributeNumeric
|
||||
|
||||
/// <summary>
|
||||
/// 会心率
|
||||
/// </summary>
|
||||
UnderStand *attribute.AttributeNumeric
|
||||
/// <summary>
|
||||
/// 伤害减免
|
||||
/// </summary>
|
||||
DamRe *attribute.AttributeNumeric
|
||||
/// <summary>
|
||||
/// 伤害提升
|
||||
/// </summary>
|
||||
CauseDam *attribute.AttributeNumeric
|
||||
|
||||
/// <summary>
|
||||
/// 治疗加成
|
||||
/// </summary>
|
||||
TreAdd *attribute.AttributeNumeric
|
||||
|
||||
/// <summary>
|
||||
/// 受疗加成
|
||||
/// </summary>
|
||||
BeTreAdd *attribute.AttributeNumeric
|
||||
|
||||
///region 技能相关-----------------------------------------------------------------------
|
||||
/// <summary>
|
||||
/// 技能信息 id:lv
|
||||
/// </summary>
|
||||
SkillsInfo []ISkill
|
||||
/// <summary>
|
||||
/// 最后一次选择的skillAtk类技能
|
||||
/// </summary>
|
||||
LastSkillId int32
|
||||
/// <summary>
|
||||
/// 最后一次skillAtk技能选择的目标
|
||||
/// </summary>
|
||||
LastChooseTarget []int
|
||||
/// <summary>
|
||||
/// 可执行技能列表
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 在角色初始化时,会根据SkillsInfo实例化对应的技能保存于此
|
||||
/// </remarks>
|
||||
Skills map[int32]ISkill
|
||||
/// <summary>
|
||||
/// AfterAtk集合
|
||||
/// </summary>
|
||||
AfterSkills map[int]IAfterSkill
|
||||
|
||||
/// <summary>
|
||||
/// BUFF集合
|
||||
/// </summary>
|
||||
BuffStore IBuffStore
|
||||
|
||||
/// <summary>
|
||||
/// 被动技能集合
|
||||
/// </summary>
|
||||
PassiveStore IPassiveStore
|
||||
}
|
15
modules/battle/fight/core/iafterskill.go
Normal file
15
modules/battle/fight/core/iafterskill.go
Normal file
@ -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()
|
||||
}
|
5
modules/battle/fight/core/iai.go
Normal file
5
modules/battle/fight/core/iai.go
Normal file
@ -0,0 +1,5 @@
|
||||
package core
|
||||
|
||||
//战斗AI
|
||||
type IFightAI interface {
|
||||
}
|
5
modules/battle/fight/core/ibuff.go
Normal file
5
modules/battle/fight/core/ibuff.go
Normal file
@ -0,0 +1,5 @@
|
||||
package core
|
||||
|
||||
//buff
|
||||
type IBuff interface {
|
||||
}
|
5
modules/battle/fight/core/ievent.go
Normal file
5
modules/battle/fight/core/ievent.go
Normal file
@ -0,0 +1,5 @@
|
||||
package core
|
||||
|
||||
type IFightEvent interface {
|
||||
Emit(eventNumber int, args ...interface{})
|
||||
}
|
13
modules/battle/fight/core/ifight.go
Normal file
13
modules/battle/fight/core/ifight.go
Normal file
@ -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
|
||||
}
|
6
modules/battle/fight/core/ilog.go
Normal file
6
modules/battle/fight/core/ilog.go
Normal file
@ -0,0 +1,6 @@
|
||||
package core
|
||||
|
||||
//战报
|
||||
type IFightLog interface {
|
||||
AddCommand(log ICmd)
|
||||
}
|
11
modules/battle/fight/core/irole.go
Normal file
11
modules/battle/fight/core/irole.go
Normal file
@ -0,0 +1,11 @@
|
||||
package core
|
||||
|
||||
//战斗角色
|
||||
type IFightRole interface {
|
||||
GetFight() IFight
|
||||
GetData() *FightRoleData
|
||||
///添加主技能
|
||||
AddSkill(skillId int32, skillLv int32) ISkill
|
||||
///获取子技能 不存在时会初始化
|
||||
GetAfterAtk(skillId int32) IAfterSkill
|
||||
}
|
13
modules/battle/fight/core/iskill.go
Normal file
13
modules/battle/fight/core/iskill.go
Normal file
@ -0,0 +1,13 @@
|
||||
package core
|
||||
|
||||
import cfg "go_dreamfactory/sys/configure/structs"
|
||||
|
||||
//主技能
|
||||
type ISkill interface {
|
||||
///获取技能配置
|
||||
GetSkillConf() *cfg.GameSkillAtkData
|
||||
/// 触发
|
||||
Emit()
|
||||
///发送技能日志
|
||||
SendSkillLog()
|
||||
}
|
@ -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
|
||||
}
|
||||
|
@ -1,174 +0,0 @@
|
||||
package core
|
||||
|
||||
type PropertyType int
|
||||
|
||||
const (
|
||||
/// <summary>
|
||||
/// 总生命
|
||||
/// </summary>
|
||||
PropertyType_Total_Hp PropertyType = 1
|
||||
/// <summary>
|
||||
/// 当前总生命
|
||||
/// </summary>
|
||||
PropertyType_NowTotal_Hp PropertyType = 2
|
||||
/// <summary>
|
||||
/// 当前生命
|
||||
/// </summary>
|
||||
PropertyType_NowHp PropertyType = 3
|
||||
/// <summary>
|
||||
/// 总攻击
|
||||
/// </summary>
|
||||
PropertyType_Total_Atk PropertyType = 4
|
||||
/// <summary>
|
||||
/// 总防御
|
||||
/// </summary>
|
||||
PropertyType_Total_Def PropertyType = 5
|
||||
/// <summary>
|
||||
/// 总速度
|
||||
/// </summary>
|
||||
PropertyType_Total_Agi PropertyType = 6
|
||||
/// <summary>
|
||||
/// 总暴击率
|
||||
/// </summary>
|
||||
PropertyType_Total_Cri PropertyType = 7
|
||||
/// <summary>
|
||||
/// 总暴击伤害
|
||||
/// </summary>
|
||||
PropertyType_Total_CriDam PropertyType = 8
|
||||
/// <summary>
|
||||
/// 总效果命中
|
||||
/// </summary>
|
||||
PropertyType_Total_EffHit PropertyType = 9
|
||||
/// <summary>
|
||||
/// 总效果抵抗
|
||||
/// </summary>
|
||||
PropertyType_Total_EffRe PropertyType = 10
|
||||
/// <summary>
|
||||
/// 已损失生命值
|
||||
/// </summary>
|
||||
PropertyType_LostHp PropertyType = 11
|
||||
/// <summary>
|
||||
/// 已损失生命值百分比
|
||||
/// </summary>
|
||||
PropertyType_LostPerHp PropertyType = 12
|
||||
/// <summary>
|
||||
/// 当前生命百分比
|
||||
/// </summary>
|
||||
PropertyType_NowHp_Per PropertyType = 13
|
||||
/// <summary>
|
||||
/// 附加生命(修改属性类型从这里开始)
|
||||
/// </summary>
|
||||
PropertyType_Add_Hp PropertyType = 14
|
||||
/// <summary>
|
||||
/// 附加百分比生命
|
||||
/// </summary>
|
||||
PropertyType_Add_Per_Hp PropertyType = 15
|
||||
/// <summary>
|
||||
/// BUFF附加生命
|
||||
/// </summary>
|
||||
PropertyType_Buff_Hp PropertyType = 16
|
||||
/// <summary>
|
||||
/// BUFF附加百分比生命
|
||||
/// </summary>
|
||||
PropertyType_Buff_Per_Hp PropertyType = 17
|
||||
/// <summary>
|
||||
/// 附加攻击
|
||||
/// </summary>
|
||||
PropertyType_Add_Atk PropertyType = 18
|
||||
/// <summary>
|
||||
/// 附加百分比攻击
|
||||
/// </summary>
|
||||
PropertyType_Add_Per_Atk PropertyType = 19
|
||||
/// <summary>
|
||||
/// BUFF附加攻击
|
||||
/// </summary>
|
||||
PropertyType_Buff_Atk PropertyType = 20
|
||||
/// <summary>
|
||||
/// BUFF附加百分比攻击
|
||||
/// </summary>
|
||||
PropertyType_Buff_Per_Atk PropertyType = 21
|
||||
/// <summary>
|
||||
/// 附加防御
|
||||
/// </summary>
|
||||
PropertyType_Add_Def PropertyType = 22
|
||||
/// <summary>
|
||||
/// 附加百分比防御
|
||||
/// </summary>
|
||||
PropertyType_Add_Per_Def PropertyType = 23
|
||||
/// <summary>
|
||||
/// BUFF附加防御
|
||||
/// </summary>
|
||||
PropertyType_Buff_Def PropertyType = 24
|
||||
/// <summary>
|
||||
/// BUFF附加百分比防御
|
||||
/// </summary>
|
||||
PropertyType_Buff_Per_Def PropertyType = 25
|
||||
/// <summary>
|
||||
/// 附加速度
|
||||
/// </summary>
|
||||
PropertyType_Add_Agi PropertyType = 26
|
||||
/// <summary>
|
||||
/// 附加百分比速度
|
||||
/// </summary>
|
||||
PropertyType_Add_Per_Agi PropertyType = 27
|
||||
/// <summary>
|
||||
/// BUFF附加速度
|
||||
/// </summary>
|
||||
PropertyType_Buff_Agi PropertyType = 28
|
||||
/// <summary>
|
||||
/// BUFF附加百分比速度
|
||||
/// </summary>
|
||||
PropertyType_Buff_Per_Agi PropertyType = 29
|
||||
/// <summary>
|
||||
/// 附加暴击率
|
||||
/// </summary>
|
||||
PropertyType_Add_Cri PropertyType = 30
|
||||
/// <summary>
|
||||
/// 附加暴击伤害
|
||||
/// </summary>
|
||||
PropertyType_Add_CriDam PropertyType = 31
|
||||
/// <summary>
|
||||
/// 附加效果命中
|
||||
/// </summary>
|
||||
PropertyType_Add_EffHit PropertyType = 32
|
||||
/// <summary>
|
||||
/// 附加效果抵抗
|
||||
/// </summary>
|
||||
PropertyType_Add_EffRe PropertyType = 33
|
||||
/// <summary>
|
||||
/// 行动值
|
||||
/// </summary>
|
||||
PropertyType_ActValue PropertyType = 34
|
||||
/// <summary>
|
||||
/// 伤害减免(buff附加百分比)
|
||||
/// </summary>
|
||||
PropertyType_DamRe_Per PropertyType = 35
|
||||
/// <summary>
|
||||
/// 伤害提升(buff附加百分比)
|
||||
/// </summary>
|
||||
PropertyType_CauseDam_Per PropertyType = 36
|
||||
/// <summary>
|
||||
/// 伤害减免(固定值)
|
||||
/// </summary>
|
||||
PropertyType_DamRe PropertyType = 37
|
||||
/// <summary>
|
||||
/// 伤害提升(固定值)
|
||||
/// </summary>
|
||||
PropertyType_CauseDam PropertyType = 38
|
||||
/// <summary>
|
||||
/// 失手率buff增加百分比
|
||||
/// </summary>
|
||||
PropertyType_LostHold_per PropertyType = 39
|
||||
/// <summary>
|
||||
/// 会心率buff增加百分比
|
||||
/// </summary>
|
||||
PropertyType_UnderStand_per PropertyType = 40
|
||||
/// <summary>
|
||||
/// 治疗加成
|
||||
/// </summary>
|
||||
PropertyType_TreAdd PropertyType = 41
|
||||
/// <summary>
|
||||
/// 受疗加成
|
||||
/// </summary>
|
||||
PropertyType_BeTreAdd PropertyType = 42
|
||||
)
|
18
modules/battle/fight/core/roledata.go
Normal file
18
modules/battle/fight/core/roledata.go
Normal file
@ -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
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
package fight
|
||||
|
||||
import "go_dreamfactory/modules/battle/fight/core"
|
||||
|
||||
type FightAI struct {
|
||||
fight core.IFight
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 自动触发技能
|
||||
/// </summary>
|
||||
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)})
|
||||
}
|
@ -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 {
|
||||
/// <summary>
|
||||
/// 战斗类型
|
||||
/// </summary>
|
||||
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
|
||||
/// <summary>
|
||||
/// 随机数种子
|
||||
/// </summary>
|
||||
RandSeed int64
|
||||
///事件系统
|
||||
FightEvent core.IFightEvent
|
||||
/// <summary>
|
||||
/// 战报
|
||||
/// </summary>
|
||||
FightLog core.IFightLog
|
||||
/// <summary>
|
||||
/// 触发释放主技能,需要在当前出手角色技能释放完成之后再执行
|
||||
/// </summary>
|
||||
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() {
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 触发队长技,队长技配置在atk表中,触发顺序无所谓
|
||||
/// </summary>
|
||||
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()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 触发被动技,队长技配置在atk表中,触发顺序无所谓
|
||||
/// </summary>
|
||||
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()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 初始化所有角色的行动值
|
||||
/// </summary>
|
||||
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 {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 排序所有角色
|
||||
/// </summary>
|
||||
/// <param name="orderBy">排序方式</param>
|
||||
/// <param name="orderType">升序还是降序:asc/desc </param>
|
||||
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)
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算当前可以行动的角色,没有时返回null
|
||||
/// </summary>
|
||||
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]
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// LastActionRole触发SkillId技能,选择的目标是TargetRid
|
||||
/// 手动时,表现层在玩家操作后,调用本方法
|
||||
/// 自动战斗或服务端里,通过FightAI逻辑来自动触发
|
||||
/// </summary>
|
||||
/// <param name="skillId">技能ID</param>
|
||||
/// <param name="targetRid">选择的目标rid</param>
|
||||
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()
|
||||
}
|
||||
|
||||
/// <summary>执行被动触发的主技能技能</summary>
|
||||
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)
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 表现层在角色表现结束后,调用本方法
|
||||
/// </summary>
|
||||
func (this *FightBase) OnLastActionRoleActionStop() {
|
||||
this.LastActionRole.StopAction()
|
||||
this.FightEvent.EmitForInt(int(core.EventType_OnStopAction))
|
||||
//检测战斗是否结束
|
||||
this.CheckFightEnd()
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 生成随机数
|
||||
/// </summary>
|
||||
/// <param name="minNum">最小值(含)</param>
|
||||
/// <param name="maxNum">最大值(含)</param>
|
||||
/// <returns></returns>
|
||||
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...)
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 发送消息
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="args"></param>
|
||||
func (this *FightEvent) Emit(key string, params ...interface{}) {
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 监听消息
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="callback"></param>
|
||||
func (this *FightEvent) On(key string, f interface{}) {
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 监听一次消息
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="callback"></param>
|
||||
func (this *FightEvent) Once(key string, f interface{}) {
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 移除监听消息
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="callback"></param>
|
||||
func (this *FightEvent) Off(key string, f interface{}) {
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 移除监听消息
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
func (this *FightEvent) OffKey(key string) {
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重置事件中心
|
||||
/// </summary>
|
||||
func (this *FightEvent) Clear() {
|
||||
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
package fight
|
||||
|
||||
import "go_dreamfactory/modules/battle/fight/core"
|
||||
|
||||
//战报
|
||||
type FightLog struct {
|
||||
FightBase core.IFight
|
||||
Commands []interface{}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 增加战报日志
|
||||
/// </summary>
|
||||
/// <param name="log"></param>
|
||||
func (this *FightLog) AddCommand(object interface{}) {
|
||||
this.Commands = append(this.Commands, object)
|
||||
}
|
@ -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 {
|
||||
/// <summary>
|
||||
/// 战斗实例
|
||||
/// </summary>
|
||||
fight core.IFight
|
||||
/// <summary>
|
||||
/// 角色数据
|
||||
/// </summary>
|
||||
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
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 接收伤害
|
||||
/// </summary>
|
||||
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
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 战斗结束时的清理
|
||||
/// </summary>
|
||||
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
|
||||
}
|
||||
|
@ -1,213 +0,0 @@
|
||||
package fight
|
||||
|
||||
import "go_dreamfactory/modules/battle/fight/core"
|
||||
|
||||
//From-------------------------------------------------------------------------------------------------------
|
||||
/// <summary>
|
||||
/// 从roles里,过滤出符合From设定的对象List
|
||||
/// </summary>
|
||||
/// <param name="roles">筛选前List<FightRole></param>
|
||||
/// <param name="skill">用哪个技能来筛选</param>
|
||||
/// <returns>筛选后List<FightRole></returns>
|
||||
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
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从roles里,过滤出符合设定的对象List
|
||||
/// </summary>
|
||||
/// <param name="roles">筛选前List<FightRole></param>
|
||||
/// <param name="actionRole">当前行动role</param>
|
||||
/// <param name="from">afterSkill里设置的From</param>
|
||||
/// <returns></returns>
|
||||
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{}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从roles里,过滤出符合设定的对象List
|
||||
/// </summary>
|
||||
/// <param name="roles">筛选前List<FightRole></param>
|
||||
/// <param name="actionRole">当前行动role</param>
|
||||
/// <param name="from">afterSkill里设置的From</param>
|
||||
/// <returns></returns>
|
||||
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{}
|
||||
}
|
46
modules/battle/fight/options.go
Normal file
46
modules/battle/fight/options.go
Normal file
@ -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
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
package passive
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"go_dreamfactory/modules/battle/fight/core"
|
||||
)
|
||||
|
||||
func NewFightCallSkillPas() core.IFightPassive {
|
||||
return &FightCallSkillPas{}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 通用调用技能和子技能
|
||||
/// </summary>
|
||||
type FightCallSkillPas struct {
|
||||
FightPassive
|
||||
}
|
||||
|
||||
func (this *FightCallSkillPas) OnEvent(argu []interface{}) {
|
||||
this.FightPassive.OnEvent(argu)
|
||||
this.ApplyAfterAtk()
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 执行子技能
|
||||
/// </summary>
|
||||
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()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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
|
||||
/// <summary>
|
||||
/// skillPassive 配置
|
||||
/// </summary>
|
||||
PassiveConf cfg.GameSkillPassiveData
|
||||
/// <summary>
|
||||
/// 这个被动是哪个角色给我施加的
|
||||
/// </summary>
|
||||
FromRole core.IFightRole
|
||||
/// <summary>
|
||||
/// 被动持有者
|
||||
/// </summary>
|
||||
OwnerRole core.IFightRole
|
||||
/// <summary>
|
||||
/// 触发被动的发起者(该角色触发了被动执行此子技能)
|
||||
/// </summary>
|
||||
TriggerPassiveRole core.IFightRole
|
||||
/// <summary>
|
||||
/// 触发被动的角色目标(该角色触发了被动执行此子技能)
|
||||
/// </summary>
|
||||
TriggerPassiveTarget core.IFightRole
|
||||
/// <summary>
|
||||
/// 条件检测参数
|
||||
/// </summary>
|
||||
AddConArgs core.MapString
|
||||
/// <summary>
|
||||
/// 触发此被动的子技能Id
|
||||
/// </summary>
|
||||
EmitAfterSkillId int32
|
||||
EventType core.EventType
|
||||
/// <summary>
|
||||
/// 触发此被动的子技能(需要把战报输入到这个子技能中)
|
||||
/// </summary>
|
||||
EmitAfterSkill core.IAfterSkill
|
||||
/// <summary>
|
||||
/// 被动CD
|
||||
/// </summary>
|
||||
CD int
|
||||
/// <summary>
|
||||
/// 当前CD =0 才能触发
|
||||
/// </summary>
|
||||
CurrentCD int
|
||||
/// <summary>
|
||||
/// 每回合累计触发次数
|
||||
/// </summary>
|
||||
TotalEmitTimes int
|
||||
}
|
||||
|
||||
func (this *FightPassive) GetTriggerPassiveRole() core.IFightRole {
|
||||
return this.TriggerPassiveRole
|
||||
}
|
||||
|
||||
func (this *FightPassive) OnActivate(param float32) {
|
||||
this.EventType = this.CurEvent()
|
||||
this.InitEvent()
|
||||
}
|
||||
|
||||
//绑定被动-------------------------
|
||||
/// <summary>
|
||||
/// 初始化事件
|
||||
/// </summary>
|
||||
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
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 接收到事件
|
||||
/// </summary>
|
||||
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
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检测目标
|
||||
/// </summary>
|
||||
/// <param name="pLaunch">发起者</param>
|
||||
/// <param name="pRole">目标者</param>
|
||||
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
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检测暴击
|
||||
/// </summary>
|
||||
func (this *FightPassive) CheckCriCal(pCriCal int) bool {
|
||||
if CriRely, ok := this.AddConArgs.TryGetInt("CriRely"); !ok {
|
||||
return true
|
||||
} else {
|
||||
return CriRely == pCriCal
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检测是否致死伤害
|
||||
/// </summary>
|
||||
func (this *FightPassive) CheckDeadDmg(pDead int) bool {
|
||||
if LetDmg, ok := this.AddConArgs.TryGetInt("LetDmg"); !ok {
|
||||
return true
|
||||
} else {
|
||||
return LetDmg == pDead
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 条件检测
|
||||
/// </summary>
|
||||
/// <param name="form">发起者</param>
|
||||
/// <param name="to">目标者</param>
|
||||
/// <param name="afterSkill">afterSkill</param>
|
||||
/// <returns></returns>
|
||||
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() {
|
||||
|
||||
}
|
@ -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"
|
||||
)
|
||||
|
||||
/// <summary>
|
||||
/// 修改目标行动值
|
||||
/// </summary>
|
||||
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
|
||||
}
|
||||
|
@ -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"
|
||||
)
|
||||
|
||||
/// <summary>
|
||||
/// 添加buff
|
||||
/// </summary>
|
||||
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
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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"
|
||||
)
|
||||
|
||||
/// <summary>
|
||||
/// BUFF回合类操作
|
||||
/// </summary>
|
||||
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
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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"
|
||||
)
|
||||
|
||||
/// <summary>
|
||||
/// 添加buff(从之前技能的效果值中取参数)
|
||||
/// </summary>
|
||||
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
|
||||
}
|
||||
|
@ -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"
|
||||
)
|
||||
|
||||
/// <summary>
|
||||
/// 吸收目标行动值
|
||||
/// </summary>
|
||||
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
|
||||
}
|
||||
|
@ -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"
|
||||
)
|
||||
|
||||
/// <summary>
|
||||
/// 随机buff
|
||||
/// </summary>
|
||||
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
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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"
|
||||
)
|
||||
|
||||
/// <summary>
|
||||
/// 抢夺目标属性
|
||||
/// </summary>
|
||||
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
|
||||
}
|
||||
|
@ -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"
|
||||
)
|
||||
|
||||
/// <summary>
|
||||
/// 立即获得回合
|
||||
/// </summary>
|
||||
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
|
||||
}
|
||||
|
@ -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"
|
||||
)
|
||||
|
||||
/// <summary>
|
||||
/// 转嫁buff
|
||||
/// </summary>
|
||||
func NewFightShiftBuffSkill(role core.IFightRole, skillConf *cfg.GameSkillAfteratkData) (skill *FightShiftBuffSkill) {
|
||||
skill = &FightShiftBuffSkill{}
|
||||
skill.Init(skill, role, skillConf)
|
||||
return
|
||||
}
|
||||
|
||||
///Buff
|
||||
type FightShiftBuffSkill struct {
|
||||
skill.FightAfterSkill
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 执行技能逻辑
|
||||
/// </summary>
|
||||
func (this *FightShiftBuffSkill) DoLogic() {
|
||||
|
||||
skill.FightlEffectSkill
|
||||
}
|
||||
|
@ -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"
|
||||
)
|
||||
|
||||
/// <summary>
|
||||
/// Skill回合类操作
|
||||
/// </summary>
|
||||
func NewFightSkillCDSkill(role core.IFightRole, skillConf *cfg.GameSkillAfteratkData) (skill *FightSkillCDSkill) {
|
||||
skill = &FightSkillCDSkill{}
|
||||
skill.Init(skill, role, skillConf)
|
||||
return
|
||||
}
|
||||
|
||||
///Passive类
|
||||
type FightSkillCDSkill struct {
|
||||
skill.FightAfterSkill
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 执行技能逻辑
|
||||
/// </summary>
|
||||
func (this *FightSkillCDSkill) DoLogic() {
|
||||
|
||||
skill.FightlEffectSkill
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 执行技能逻辑
|
||||
/// </summary>
|
||||
func (this *FightTreSkill) DoLogic() {
|
||||
|
||||
}
|
||||
|
||||
func (this *FightTreSkill) Clear() {
|
||||
this.FightlEffectSkill.Clear()
|
||||
this.EffectValue = 0
|
||||
}
|
||||
|
@ -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 {
|
||||
/// <summary>
|
||||
/// 技能效果是否生效
|
||||
/// </summary>
|
||||
TakeEffect bool
|
||||
|
||||
/// <summary>
|
||||
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
|
||||
/// 子技能效果列表
|
||||
/// </summary>
|
||||
ComList []*core.ComEffectSkill
|
||||
///执行次数
|
||||
DoVal int32
|
||||
/// 技能效果是否生效
|
||||
TakeEffect bool
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 子技能增加战报日志
|
||||
/// </summary>
|
||||
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())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 战斗结束时的清理
|
||||
/// </summary>
|
||||
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
|
||||
}
|
||||
|
@ -1,11 +1,8 @@
|
||||
package skill
|
||||
|
||||
/// 效果类子技能
|
||||
type FightlEffectSkill struct {
|
||||
FightAfterSkill
|
||||
/// 效果值
|
||||
EffectValue float32
|
||||
}
|
||||
|
||||
func (this *FightlEffectSkill) Clear() {
|
||||
this.FightAfterSkill.Clear()
|
||||
this.EffectValue = 0
|
||||
}
|
||||
|
@ -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,
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 主动/队长技能
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 遍历触发子技能
|
||||
/// </remarks>
|
||||
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
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 触发
|
||||
/// 遍历所有ChildSkills,生成对应的实例,并Emit触发
|
||||
/// </summary>
|
||||
func (this *FightSkill) Emit() {
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 减少CD回合数
|
||||
/// </summary>
|
||||
/// <returns>新的回合数</returns>
|
||||
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
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 增加CD回合数
|
||||
/// </summary>
|
||||
/// <returns>新的回合数</returns>
|
||||
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)
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置CD回合数为新的值
|
||||
/// </summary>
|
||||
/// <param name="newVal"></param>
|
||||
/// <returns></returns>
|
||||
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
|
||||
}
|
||||
|
||||
/// <summary>发送技能日志</summary>
|
||||
func (this *FightSkill) Clear() {
|
||||
|
||||
}
|
||||
|
||||
/// <summary>发送技能日志</summary>
|
||||
/// 发送技能日志
|
||||
func (this *FightSkill) SendSkillLog() {
|
||||
|
||||
}
|
||||
|
7
modules/battle/fight/skill/skillbase.go
Normal file
7
modules/battle/fight/skill/skillbase.go
Normal file
@ -0,0 +1,7 @@
|
||||
package skill
|
||||
|
||||
import "go_dreamfactory/modules/battle/fight/core"
|
||||
|
||||
type SkillBase struct {
|
||||
AfterSkillList []*core.ComSkillAfterAtk
|
||||
}
|
@ -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
|
||||
|
||||
}
|
@ -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...)
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
34
modules/moonfantasy/api_getlist.go
Normal file
34
modules/moonfantasy/api_getlist.go
Normal file
@ -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
|
||||
}
|
@ -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
|
||||
}
|
||||
|
@ -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})
|
||||
|
@ -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)
|
||||
}
|
||||
|
49
modules/moonfantasy/modelUserMF.go
Normal file
49
modules/moonfantasy/modelUserMF.go
Normal file
@ -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
|
||||
}
|
@ -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)
|
||||
}
|
||||
|
@ -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))
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
@ -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))
|
||||
}
|
||||
|
||||
// 在线玩家列表
|
||||
|
@ -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 (
|
||||
|
@ -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,
|
||||
},
|
||||
|
@ -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,
|
||||
},
|
||||
|
211
sys/db/dbconn.go
211
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 {
|
||||
|
Loading…
Reference in New Issue
Block a user