fix(fight): 修复技能效果获取逻辑并调整伤害计算方式
-
This commit is contained in:
@@ -34,7 +34,8 @@ type OrderedMap[K comparable, V any] struct {
|
|||||||
// NewOrderedMap 创建一个新的泛型有序Map
|
// NewOrderedMap 创建一个新的泛型有序Map
|
||||||
func NewOrderedMap[K comparable, V any]() *OrderedMap[K, V] {
|
func NewOrderedMap[K comparable, V any]() *OrderedMap[K, V] {
|
||||||
return &OrderedMap[K, V]{
|
return &OrderedMap[K, V]{
|
||||||
hash: &maphash.Hash{},
|
hash: &maphash.Hash{},
|
||||||
|
|
||||||
hashTable: make(map[uint64]*MapEntry[K, V]),
|
hashTable: make(map[uint64]*MapEntry[K, V]),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -373,23 +373,19 @@ func (f *FightC) parseskill(attacker, defender *input.Input, id *SelectSkillActi
|
|||||||
temparg := id.Skill.SideEffectArgS
|
temparg := id.Skill.SideEffectArgS
|
||||||
for _, v := range id.Skill.SideEffectS {
|
for _, v := range id.Skill.SideEffectS {
|
||||||
|
|
||||||
t, ok := input.Geteffect(v + 1000000)
|
t := input.GetSkillEffect(v)
|
||||||
|
|
||||||
if ok { //获取成功
|
args := xmlres.EffectArgs[v]
|
||||||
|
|
||||||
args := xmlres.EffectArgs[v]
|
t.Effect.SetArgs(temparg[:args]...) //设置入参
|
||||||
|
|
||||||
t.SetArgs(temparg[:args]...) //设置入参
|
temparg = temparg[args:]
|
||||||
|
if t.Effect.GetOwner() { //如果取反,说明是给对方添加的回合效果
|
||||||
temparg = temparg[args:]
|
//实际上,owner永远为反,说明是对方给我添加的
|
||||||
if t.GetOwner() { //如果取反,说明是给对方添加的回合效果
|
|
||||||
//实际上,owner永远为反,说明是对方给我添加的
|
|
||||||
|
|
||||||
defender.AddEffect(defender.GetSkillEffect(v))
|
|
||||||
} else {
|
|
||||||
attacker.AddEffect(attacker.GetSkillEffect(v))
|
|
||||||
}
|
|
||||||
|
|
||||||
|
defender.AddEffect(t)
|
||||||
|
} else {
|
||||||
|
attacker.AddEffect(t)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,10 +27,11 @@ type Input struct {
|
|||||||
|
|
||||||
func NewInput(c common.FightI, p common.PlayerI) *Input {
|
func NewInput(c common.FightI, p common.PlayerI) *Input {
|
||||||
ret := &Input{FightC: c, Player: p}
|
ret := &Input{FightC: c, Player: p}
|
||||||
t := ret.GetDamageEffect(0)
|
ret.Effects = utils.NewOrderedMap[int, Effect]()
|
||||||
|
t := GetDamageEffect(0)
|
||||||
ret.AddEffect(t) //添加默认基类,实现继承
|
ret.AddEffect(t) //添加默认基类,实现继承
|
||||||
p.SetFightC(c) //给玩家设置战斗容器
|
p.SetFightC(c) //给玩家设置战斗容器
|
||||||
ret.Effects = utils.NewOrderedMap[int, Effect]()
|
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -72,7 +73,7 @@ func (i *Input) GetStatusBonus() float64 {
|
|||||||
maxBonus := 1.0 // 默认无状态倍率
|
maxBonus := 1.0 // 默认无状态倍率
|
||||||
|
|
||||||
for statusIdx := 0; statusIdx < 20; statusIdx++ {
|
for statusIdx := 0; statusIdx < 20; statusIdx++ {
|
||||||
t, ok := i.GetStatusEffect(statusIdx)
|
t, ok := GetStatusEffect(statusIdx)
|
||||||
|
|
||||||
// 检查状态是否存在(数组中值为1表示存在该状态)
|
// 检查状态是否存在(数组中值为1表示存在该状态)
|
||||||
if ok && t.Stack() > 0 {
|
if ok && t.Stack() > 0 {
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ var NodeM = make(map[int]Effect, 0)
|
|||||||
|
|
||||||
func InitSkillEffect(id int, t Effect) {
|
func InitSkillEffect(id int, t Effect) {
|
||||||
|
|
||||||
NodeM[id+1000000] = t
|
NodeM[id+1000000-1] = t
|
||||||
}
|
}
|
||||||
func Geteffect(id int) (Effect, bool) {
|
func Geteffect(id int) (Effect, bool) {
|
||||||
|
|
||||||
@@ -95,7 +95,7 @@ func Geteffect(id int) (Effect, bool) {
|
|||||||
|
|
||||||
func InitPropEffect(id int, t Effect) {
|
func InitPropEffect(id int, t Effect) {
|
||||||
|
|
||||||
NodeM[id+2000000] = t
|
NodeM[id+2000000-1] = t
|
||||||
}
|
}
|
||||||
|
|
||||||
// * battle_lv: atk(0), def(1), sp_atk(2), sp_def(3), spd(4), accuracy(5)
|
// * battle_lv: atk(0), def(1), sp_atk(2), sp_def(3), spd(4), accuracy(5)
|
||||||
@@ -125,11 +125,11 @@ func (c *Input) GetProp(id int, istue bool) int {
|
|||||||
}
|
}
|
||||||
func InitDamageEffect(id int, t Effect) {
|
func InitDamageEffect(id int, t Effect) {
|
||||||
|
|
||||||
NodeM[id+4000000] = t
|
NodeM[id+4000000-1] = t
|
||||||
}
|
}
|
||||||
|
|
||||||
// 1为红伤
|
// 1为红伤
|
||||||
func (c *Input) GetDamageEffect(id int) *EffectID {
|
func GetDamageEffect(id int) *EffectID {
|
||||||
id1 := id + 4000000
|
id1 := id + 4000000
|
||||||
ret, ok := Geteffect(id1)
|
ret, ok := Geteffect(id1)
|
||||||
if ok {
|
if ok {
|
||||||
@@ -142,7 +142,17 @@ func (c *Input) GetDamageEffect(id int) *EffectID {
|
|||||||
}
|
}
|
||||||
return &EffectID{}
|
return &EffectID{}
|
||||||
}
|
}
|
||||||
func (c *Input) GetSkillEffect(id int) *EffectID {
|
|
||||||
|
func (c *Input) GetDamageEffect(id int) int {
|
||||||
|
id1 := id + 4000000
|
||||||
|
rer, ok := c.Effects.Load(id1)
|
||||||
|
if ok {
|
||||||
|
return rer.Stack()
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
func GetSkillEffect(id int) *EffectID {
|
||||||
id1 := id + 1000000
|
id1 := id + 1000000
|
||||||
ret, ok := Geteffect(id1)
|
ret, ok := Geteffect(id1)
|
||||||
if ok {
|
if ok {
|
||||||
@@ -161,7 +171,7 @@ type EffectID struct {
|
|||||||
Effect Effect
|
Effect Effect
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Input) GetPropEffect(id int) Effect {
|
func GetPropEffect(id int) Effect {
|
||||||
|
|
||||||
ret, ok := Geteffect(id + 2000000)
|
ret, ok := Geteffect(id + 2000000)
|
||||||
if ok {
|
if ok {
|
||||||
@@ -173,10 +183,10 @@ func (c *Input) GetPropEffect(id int) Effect {
|
|||||||
}
|
}
|
||||||
func InitStatusEffect(id int, t Effect) {
|
func InitStatusEffect(id int, t Effect) {
|
||||||
|
|
||||||
NodeM[id+3000000] = t
|
NodeM[id+3000000-1] = t
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Input) GetStatusEffect(id int) (Effect, bool) {
|
func GetStatusEffect(id int) (Effect, bool) {
|
||||||
ret, ok := Geteffect(id + 3000000)
|
ret, ok := Geteffect(id + 3000000)
|
||||||
if ok {
|
if ok {
|
||||||
//todo 获取前GetEffect
|
//todo 获取前GetEffect
|
||||||
@@ -186,6 +196,11 @@ func (c *Input) GetStatusEffect(id int) (Effect, bool) {
|
|||||||
return nil, false
|
return nil, false
|
||||||
|
|
||||||
}
|
}
|
||||||
|
func (c *Input) GetStatusEffect(id int) (Effect, bool) {
|
||||||
|
rer, ok := c.Effects.Load(id + 3000000)
|
||||||
|
|
||||||
|
return rer, ok
|
||||||
|
}
|
||||||
func (c *Input) GetCurrAttr(id int) *model.PetInfo {
|
func (c *Input) GetCurrAttr(id int) *model.PetInfo {
|
||||||
|
|
||||||
//todo 获取前GetEffect
|
//todo 获取前GetEffect
|
||||||
|
|||||||
Reference in New Issue
Block a user