This commit is contained in:
昔念
2026-04-23 00:39:29 +08:00
parent b46a1f442b
commit 7fd89800fa
5 changed files with 78 additions and 32 deletions

View File

@@ -3,8 +3,6 @@ package effect
import (
"blazing/logic/service/fight/input"
"blazing/logic/service/fight/node"
"fmt"
"runtime"
)
// Effect 85: 使对手的能力提升效果转化到自己身上
@@ -16,26 +14,22 @@ type Effect85 struct {
// 执行时逻辑
// ----------------------
func (e *Effect85) OnSkill() bool {
fmt.Printf("[Effect85] OnSkill START: Our.Prop=%v, Opp.Prop=%v\n", e.Ctx().Our.Prop, e.Ctx().Opp.Prop)
for i, v := range e.Ctx().Opp.Prop[:] {
if v > 0 {
fmt.Printf("[Effect85] stealing index=%d, value=%d\n", i, v)
e.Ctx().Our.SetProp(e.Ctx().Our, int8(i), v)
e.Ctx().Opp.SetProp(e.Ctx().Our, int8(i), 0)
}
carrier := e.CarrierInput()
opp := e.OpponentInput()
if carrier == nil || opp == nil {
return true
}
fmt.Printf("[Effect85] OnSkill END: Our.Prop=%v, Opp.Prop=%v\n", e.Ctx().Our.Prop, e.Ctx().Opp.Prop)
e.transferPositiveProps(carrier, opp)
return true
}
func init() {
// 打印 SetProp(level==0) 的调用栈,用于追踪 Prop 被重置的时机
input.OnSetPropReset = func(target *input.Input, index int8) {
_, file, line, _ := runtime.Caller(2)
fmt.Printf("[SetProp RESET] target.Prop=%v, index=%d, caller=%s:%d\n", target.Prop, index, file, line)
// transferPositiveProps 使用显式入参执行业务逻辑,避免嵌套结算时再从 Ctx 取到漂移后的对象。
func (e *Effect85) transferPositiveProps(carrier, opp *input.Input) {
for i, v := range opp.Prop[:] {
if v > 0 {
carrier.SetProp(carrier, int8(i), v)
opp.SetProp(carrier, int8(i), 0)
}
}
}

View File

@@ -96,13 +96,13 @@ type ContinuousDamage struct {
isheal bool //是否回血
}
// 回合开始触发持续伤害,保证吃药/空过回合时也会正常结算。
func (e *ContinuousDamage) TurnStart(attacker, defender *action.SelectSkillAction) {
// 行动开始触发持续伤害:当中招方轮到自己行动时结算。
func (e *ContinuousDamage) ActionStart(attacker, defender *action.SelectSkillAction) bool {
carrier := e.CarrierInput()
source := e.SourceInput()
opp := e.TargetInput()
if carrier == nil {
return
return true
}
damage := e.calculateDamage()
@@ -111,7 +111,7 @@ func (e *ContinuousDamage) TurnStart(attacker, defender *action.SelectSkillActio
Damage: damage,
})
if len(e.SideEffectArgs) == 0 {
return
return true
}
// 额外效果
carrier.Damage(source, &info.DamageZone{
@@ -119,11 +119,12 @@ func (e *ContinuousDamage) TurnStart(attacker, defender *action.SelectSkillActio
Damage: damage,
})
if opp == nil || opp.CurPet[0].GetHP().IntPart() == 0 {
return
return true
}
// 给对方回血(不受回血限制影响)
opp.Heal(carrier, nil, damage)
return true
}
// 计算伤害最大生命值的1/8

View File

@@ -102,7 +102,11 @@ func (f *FightC) processSkillAttack(attacker, defender *input.Input, skill *info
// 扣减防御方血量
attacker.ExecWithOpponent(defender, func(effect input.Effect) bool {
f.setEffectSkillContext(effect, skill, defender)
fmt.Printf("[processSkillAttack] Before OnSkill: outerAttacker=%p outerDefender=%p ctx.Our=%p ctx.Opp=%p effect=%T attacker.Prop=%v defender.Prop=%v\n",
attacker, defender, effect.Ctx().Our, effect.Ctx().Opp, effect, attacker.Prop, defender.Prop)
effect.OnSkill() //调用伤害计算
fmt.Printf("[processSkillAttack] After OnSkill Hook: outerAttacker=%p outerDefender=%p ctx.Our=%p ctx.Opp=%p effect=%T attacker.Prop=%v defender.Prop=%v ctx.Our.Prop=%v ctx.Opp.Prop=%v\n",
attacker, defender, effect.Ctx().Our, effect.Ctx().Opp, effect, attacker.Prop, defender.Prop, effect.Ctx().Our.Prop, effect.Ctx().Opp.Prop)
return true
})
fmt.Printf("[processSkillAttack] After OnSkill: attacker.Prop=%v, defender.Prop=%v, attacker.SkillID=%d\n", attacker.Prop, defender.Prop, attacker.SkillID)
@@ -383,10 +387,29 @@ func (f *FightC) enterturn(firstAttack, secondAttack *action.SelectSkillAction)
f.setEffectSkillContext(effect, currentSkill, defender)
return effect.ActionStartEx(firstAttack, secondAttack)
})
fmt.Printf("[enterturn] Before ActionStart: round=%d attacker=%p defender=%p attackerSkill=%v attackerStatus(paralysis=%v fear=%v sleep=%v tired=%v petrified=%v) defenderStatus(paralysis=%v fear=%v sleep=%v tired=%v petrified=%v)\n",
i, attacker, defender, currentSkill != nil,
attacker.StatEffect_Exist(info.PetStatus.Paralysis),
attacker.StatEffect_Exist(info.PetStatus.Fear),
attacker.StatEffect_Exist(info.PetStatus.Sleep),
attacker.StatEffect_Exist(info.PetStatus.Tired),
attacker.StatEffect_Exist(info.PetStatus.Petrified),
defender.StatEffect_Exist(info.PetStatus.Paralysis),
defender.StatEffect_Exist(info.PetStatus.Fear),
defender.StatEffect_Exist(info.PetStatus.Sleep),
defender.StatEffect_Exist(info.PetStatus.Tired),
defender.StatEffect_Exist(info.PetStatus.Petrified))
canUseSkill := attacker.ExecWithOpponent(defender, func(effect input.Effect) bool { //这个是能否使用技能
f.setEffectSkillContext(effect, currentSkill, defender)
return effect.ActionStart(firstAttack, secondAttack)
})
fmt.Printf("[enterturn] After ActionStart: round=%d attacker=%p defender=%p canUseSkill=%v attackerStatus(paralysis=%v fear=%v sleep=%v tired=%v petrified=%v)\n",
i, attacker, defender, canUseSkill,
attacker.StatEffect_Exist(info.PetStatus.Paralysis),
attacker.StatEffect_Exist(info.PetStatus.Fear),
attacker.StatEffect_Exist(info.PetStatus.Sleep),
attacker.StatEffect_Exist(info.PetStatus.Tired),
attacker.StatEffect_Exist(info.PetStatus.Petrified))
attackerPet := attacker.CurrentPet()
defenderPet := defender.CurrentPet()

View File

@@ -226,6 +226,13 @@ func (our *Input) SetOPP(t *Input) {
}
func (our *Input) RecoverEffect() {
//println("恢复效果",our.UserID)
fmt.Printf("[RecoverEffect] input=%p effects=%d cache=%d lost=%d paralysis=%v fear=%v sleep=%v tired=%v petrified=%v\n",
our, len(our.Effects), len(our.EffectCache), len(our.EffectLost),
our.StatEffect_Exist(info.PetStatus.Paralysis),
our.StatEffect_Exist(info.PetStatus.Fear),
our.StatEffect_Exist(info.PetStatus.Sleep),
our.StatEffect_Exist(info.PetStatus.Tired),
our.StatEffect_Exist(info.PetStatus.Petrified))
//根本没释放技能,这些效果全部失效
for _, e := range our.EffectCache {
@@ -242,9 +249,23 @@ func (our *Input) RecoverEffect() {
}
}
fmt.Printf("[RecoverEffect] done input=%p effects=%d cache=%d lost=%d paralysis=%v fear=%v sleep=%v tired=%v petrified=%v\n",
our, len(our.Effects), len(our.EffectCache), len(our.EffectLost),
our.StatEffect_Exist(info.PetStatus.Paralysis),
our.StatEffect_Exist(info.PetStatus.Fear),
our.StatEffect_Exist(info.PetStatus.Sleep),
our.StatEffect_Exist(info.PetStatus.Tired),
our.StatEffect_Exist(info.PetStatus.Petrified))
}
func (our *Input) ReactvieEffect() {
fmt.Printf("[ReactvieEffect] input=%p effects=%d cache=%d lost=%d paralysis=%v fear=%v sleep=%v tired=%v petrified=%v\n",
our, len(our.Effects), len(our.EffectCache), len(our.EffectLost),
our.StatEffect_Exist(info.PetStatus.Paralysis),
our.StatEffect_Exist(info.PetStatus.Fear),
our.StatEffect_Exist(info.PetStatus.Sleep),
our.StatEffect_Exist(info.PetStatus.Tired),
our.StatEffect_Exist(info.PetStatus.Petrified))
//根本没释放技能,这些效果全部失效
for _, e := range our.EffectLost {
@@ -261,6 +282,13 @@ func (our *Input) ReactvieEffect() {
our.AddEffect(e.GetInput(), e)
}
fmt.Printf("[ReactvieEffect] done input=%p effects=%d cache=%d lost=%d paralysis=%v fear=%v sleep=%v tired=%v petrified=%v\n",
our, len(our.Effects), len(our.EffectCache), len(our.EffectLost),
our.StatEffect_Exist(info.PetStatus.Paralysis),
our.StatEffect_Exist(info.PetStatus.Fear),
our.StatEffect_Exist(info.PetStatus.Sleep),
our.StatEffect_Exist(info.PetStatus.Tired),
our.StatEffect_Exist(info.PetStatus.Petrified))
}
func (our *Input) GenSataus() {
our.Status = [20]int8{}

View File

@@ -437,15 +437,15 @@ func (s *BaseSysUserService) ServiceUpdate(ctx context.Context, req *cool.Update
}
}
}
// 如果请求的password不为空并且密码加密后的值有变动说明要修改密码
var rPassword = r.Get("password", "").String()
if rPassword != "" && rPassword != userInfo["password"].String() {
rMap["password"], _ = gmd5.Encrypt(rPassword)
rMap["passwordV"] = userInfo["passwordV"].Int() + 1
cool.CacheManager.Set(ctx, fmt.Sprintf("admin:passwordVersion:%d", userId), rMap["passwordV"], 0)
} else {
delete(rMap, "password")
}
// // 如果请求的password不为空并且密码加密后的值有变动说明要修改密码
// var rPassword = r.Get("password", "").String()
// if rPassword != "" && rPassword != userInfo["password"].String() {
// rMap["password"], _ = gmd5.Encrypt(rPassword)
// rMap["passwordV"] = userInfo["passwordV"].Int() + 1
// cool.CacheManager.Set(ctx, fmt.Sprintf("admin:passwordVersion:%d", userId), rMap["passwordV"], 0)
// } else {
// delete(rMap, "password")
// }
delete(rMap, "goldbean")
err = g.DB().Transaction(ctx, func(ctx context.Context, tx gdb.TX) (err error) {