From 5e3d558d30cb01b1b8f5a7667635472590e3c66f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=94=E5=BF=B5?= <1@72wo.cn> Date: Thu, 13 Nov 2025 21:36:18 +0800 Subject: [PATCH] =?UTF-8?q?```=20feat(player):=20=E6=B7=BB=E5=8A=A0=20UseC?= =?UTF-8?q?oins=20=E6=96=B9=E6=B3=95=E7=BB=9F=E4=B8=80=E5=A4=84=E7=90=86?= =?UTF-8?q?=E7=8E=A9=E5=AE=B6=E9=87=91=E5=B8=81=E6=B6=88=E8=80=97=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 重构购买物品和变更外观功能,使用 UseCoins 方法替代手动操作 Coins 字段, 确保金币扣除的安全性和一致性。同时修复可能因并发导致的金币超扣问题。 此外,调整部分战斗系统接口参数传递方式,将 DamageZone 指 --- logic/controller/item.go | 22 ++++----- logic/controller/user.go | 10 ++++- logic/service/fight/effect/effect_1605.go | 50 +++++++++++++++++++++ logic/service/fight/effect/effect_31.go | 4 +- logic/service/fight/effect/effect_32.go | 37 +++++++++++++++ logic/service/fight/effect/effect_58.go | 44 ++++++++++++++++++ logic/service/fight/effect/effect_7.go | 13 +++--- logic/service/fight/effect/effect_776.go | 41 +++++++++++++++++ logic/service/fight/effect/effect_8.go | 10 ++--- logic/service/fight/effect/effect_status.go | 27 +++++------ logic/service/fight/fightc.go | 41 +++++++++-------- logic/service/fight/info/info.go | 3 +- logic/service/fight/input/ctx.go | 10 ++--- logic/service/fight/input/effect.go | 2 +- logic/service/fight/input/fight.go | 22 +++++---- logic/service/fight/input/input.go | 4 ++ logic/service/fight/input/interface.go | 29 ++++++------ logic/service/fight/loop.go | 7 +++ logic/service/fight/node/Turn.go | 11 +++-- logic/service/fight/node/dagame.go | 18 ++++---- logic/service/fight/node/skill.go | 3 -- logic/service/player/player.go | 8 ++++ manifest/config/config.yaml | 2 +- modules/blazing/service/pet.go | 2 +- 24 files changed, 306 insertions(+), 114 deletions(-) create mode 100644 logic/service/fight/effect/effect_1605.go create mode 100644 logic/service/fight/effect/effect_32.go create mode 100644 logic/service/fight/effect/effect_58.go create mode 100644 logic/service/fight/effect/effect_776.go diff --git a/logic/controller/item.go b/logic/controller/item.go index bb93493ff..5778ba405 100644 --- a/logic/controller/item.go +++ b/logic/controller/item.go @@ -46,20 +46,16 @@ func (h Controller) PlayerExp(data *item.ExpTotalRemainInboundInfo, c *player.Pl func (h Controller) BuyItem(data *item.BuyInboundInfo, c *player.Player) (result *item.BuyOutboundInfo, err errorcode.ErrorCode) { tt, ok := xmlres.ItemsMAP[int(data.ItemId)] - if ok && tt.Price != 0 { - if (data.Count * uint32(tt.Price)) <= c.Info.Coins { - c.Info.Coins -= data.Count * uint32(tt.Price) - - r := c.ItemAdd(model.SingleItemInfo{ItemId: data.ItemId, ItemCnt: data.Count}) - if len(r) != 0 { - return &item.BuyOutboundInfo{ - ItemId: data.ItemId, - Level: 1, - Count: data.Count, - Coins: c.Info.Coins, - }, 0 - } + if ok && tt.Price != 0 && c.UseCoins(data.Count*uint32(tt.Price)) { + r := c.ItemAdd(model.SingleItemInfo{ItemId: data.ItemId, ItemCnt: data.Count}) + if len(r) != 0 { + return &item.BuyOutboundInfo{ + ItemId: data.ItemId, + Level: 1, + Count: data.Count, + Coins: c.Info.Coins, + }, 0 } } diff --git a/logic/controller/user.go b/logic/controller/user.go index f306d56ba..a76c112be 100644 --- a/logic/controller/user.go +++ b/logic/controller/user.go @@ -69,8 +69,12 @@ func (h Controller) Chat(data *user.ChatInboundInfo, c *player.Player) (result * return nil, -1 } func (h Controller) ChangePlayerColor(data *user.ChangeColorInboundInfo, c *player.Player) (result *user.ChangeColorOutboundInfo, err errorcode.ErrorCode) { - c.Info.Coins -= 200 + + if !c.UseCoins(200) { //如果花不了200,直接返回 + return + } c.Info.Color = data.Color + c.Info.Texture = 0 defer space.GetSpace(c.Info.MapID).User.IterCb(func(playerID uint32, v common.PlayerI) { data.Head.Result = 0 @@ -86,7 +90,9 @@ func (h Controller) ChangePlayerColor(data *user.ChangeColorInboundInfo, c *play return nil, -1 } func (h Controller) ChangePlayerDoodle(data *user.ChangeDoodleInboundInfo, c *player.Player) (result *user.ChangeDoodleOutboundInfo, err errorcode.ErrorCode) { - c.Info.Coins -= 200 + if !c.UseCoins(200) { //如果花不了200,直接返回 + return + } c.Info.Texture = data.Id c.Info.Color = data.Color defer space.GetSpace(c.Info.MapID).User.IterCb(func(playerID uint32, v common.PlayerI) { diff --git a/logic/service/fight/effect/effect_1605.go b/logic/service/fight/effect/effect_1605.go new file mode 100644 index 000000000..0ec4b5ff1 --- /dev/null +++ b/logic/service/fight/effect/effect_1605.go @@ -0,0 +1,50 @@ +package effect + +import ( + "blazing/logic/service/fight/info" + "blazing/logic/service/fight/input" + "blazing/logic/service/fight/node" +) + +// ----------------------------------------------------------- +// 通用状态效果(例如 麻痹 / 中毒 / 疲惫 / 混乱 等) +// ----------------------------------------------------------- +type Effect1605 struct { + node.EffectNode + Status info.EnumBattleStatus // 要施加的状态类型 + +} + +func init() { + input.InitEffect(input.EffectType.Skill, 1605, &Effect1605{}) +} + +// ----------------------------------------------------------- +// 技能触发时调用 +// ----------------------------------------------------------- +func (e *Effect1605) OnSkill() bool { + if !e.Hit() { + return true + } + + // n% 触发概率(默认 SideEffectArgs[0]) + chance := e.SideEffectArgs[0] + success, _, _ := e.Input.Player.Roll(chance, 100) + if !success { + return true + } + + duration := int(e.Input.FightC.GetRand().Int31n(2)) // 默认随机 2~3 回合 + duration++ + + // 获取状态效果 + eff := input.Geteffect(input.EffectType.Status, int(e.SideEffectArgs[1])) + if eff == nil { + return true + } + + eff.Duration(duration) + eff.SetArgs(e.Ctx().Our) //输入参数是对方 + e.Ctx().Opp.AddEffect(eff) + return true +} diff --git a/logic/service/fight/effect/effect_31.go b/logic/service/fight/effect/effect_31.go index 12db80957..6c17f6faf 100644 --- a/logic/service/fight/effect/effect_31.go +++ b/logic/service/fight/effect/effect_31.go @@ -23,12 +23,12 @@ type Effect31 struct { node.EffectNode } -func (e *Effect31) Damage_Mul() bool { +func (e *Effect31) Damage_Mul(t *info.DamageZone) bool { if !e.Hit() { return true } - if e.Ctx().DamageZone.Type == info.DamageType.Red { + if t.Type == info.DamageType.Red { n := int(e.Input.FightC.GetRand().Int31n(int32(e.SideEffectArgs[1]-e.SideEffectArgs[0]+1))) + e.SideEffectArgs[0] e.Ctx().Our.DamageZone.Damage = e.Ctx().Our.DamageZone.Damage.Mul(decimal.NewFromInt(int64(n))) diff --git a/logic/service/fight/effect/effect_32.go b/logic/service/fight/effect/effect_32.go new file mode 100644 index 000000000..138635e98 --- /dev/null +++ b/logic/service/fight/effect/effect_32.go @@ -0,0 +1,37 @@ +package effect + +import ( + "blazing/logic/service/fight/action" + "blazing/logic/service/fight/input" + "blazing/logic/service/fight/node" +) + +/** + * 使用后n回合攻击击中对象要害概率增加1/16 + */ + +func init() { + input.InitEffect(input.EffectType.Skill, 32, &Effect32{ + EffectNode: node.EffectNode{}, + }) + +} + +type Effect32 struct { + node.EffectNode +} + +func (e *Effect32) Skill_Hit_Pre(a, b *action.SelectSkillAction) bool { + if !e.Hit() { + return true + } + e.Ctx().SkillEntity.Crit += 1 + + return true +} +func (e *Effect32) SetArgs(t *input.Input, a ...int) { + + e.EffectNode.SetArgs(t, a...) + e.EffectNode.Duration(e.EffectNode.SideEffectArgs[0]) + +} diff --git a/logic/service/fight/effect/effect_58.go b/logic/service/fight/effect/effect_58.go new file mode 100644 index 000000000..67bf208cb --- /dev/null +++ b/logic/service/fight/effect/effect_58.go @@ -0,0 +1,44 @@ +package effect + +import ( + "blazing/logic/service/fight/action" + "blazing/logic/service/fight/input" + "blazing/logic/service/fight/node" +) + +/** + * 下n回合自身攻击技能必定打出致命一击 + */ + +func init() { + input.InitEffect(input.EffectType.Skill, 58, &Effect58{ + EffectNode: node.EffectNode{}, + }) + +} + +type Effect58 struct { + node.EffectNode + can bool +} + +func (e *Effect58) OnSkill() bool { + if !e.Hit() { + return true + } + e.can = true + + return true +} + +func (e *Effect58) Skill_Hit_Pre(a, b *action.SelectSkillAction) bool { + if !e.Hit() { + return true + } + if !e.can { + return true + } + e.Ctx().SkillEntity.Crit = 16 + + return true +} diff --git a/logic/service/fight/effect/effect_7.go b/logic/service/fight/effect/effect_7.go index 3c05d5804..6d608a7d1 100644 --- a/logic/service/fight/effect/effect_7.go +++ b/logic/service/fight/effect/effect_7.go @@ -1,6 +1,7 @@ package effect import ( + "blazing/logic/service/fight/action" "blazing/logic/service/fight/info" "blazing/logic/service/fight/input" "blazing/logic/service/fight/node" @@ -24,26 +25,26 @@ type Effect7 struct { node.EffectNode } -func (e *Effect7) Skill_Hit_Pre() bool { +func (e *Effect7) Skill_Hit_Pre(a, b *action.SelectSkillAction) bool { if e.Ctx().Opp.CurrentPet.Info.Hp <= e.Ctx().Our.CurrentPet.Info.Hp { e.Ctx().SkillEntity.Accuracy = 0 } return true } -func (e *Effect7) Damage_Floor() bool { +func (e *Effect7) Damage_Floor(t *info.DamageZone) bool { if !e.Hit() { return true } - fmt.Println("Effect7_old", e.Ctx().DamageZone.Damage.IntPart()) - if e.Ctx().DamageZone.Type == info.DamageType.Red { + fmt.Println("Effect7_old", t.Damage.IntPart()) + if t.Type == info.DamageType.Red { if e.Ctx().Our.CurrentPet.Info.Hp <= e.Ctx().Opp.CurrentPet.Info.Hp { - e.Ctx().DamageZone.Damage = decimal.NewFromInt(int64(e.Ctx().Opp.CurrentPet.Info.Hp - e.Ctx().Our.CurrentPet.Info.Hp)) + t.Damage = decimal.NewFromInt(int64(e.Ctx().Opp.CurrentPet.Info.Hp - e.Ctx().Our.CurrentPet.Info.Hp)) } } - fmt.Println("Effect7_new", e.Ctx().DamageZone.Damage.IntPart()) + fmt.Println("Effect7_new", t.Damage.IntPart()) return true } diff --git a/logic/service/fight/effect/effect_776.go b/logic/service/fight/effect/effect_776.go new file mode 100644 index 000000000..72d2bb77b --- /dev/null +++ b/logic/service/fight/effect/effect_776.go @@ -0,0 +1,41 @@ +package effect + +import ( + "blazing/logic/service/fight/info" + "blazing/logic/service/fight/input" + "blazing/logic/service/fight/node" + "fmt" + + "github.com/shopspring/decimal" +) + +// ---- Effect776 ---- +type Effect776 struct { + node.EffectNode + StatusID int +} + +func (e *Effect776) Damage_Mul(t *info.DamageZone) bool { + if !e.Hit() { + return true + } + fmt.Println("Effect776_o", t.Damage) + if t.Type == info.DamageType.Red { + + t.Damage = t.Damage.Mul(decimal.NewFromInt(2)) + + } + fmt.Println("Effect776_n", t.Damage) + return true +} +func (e *Effect776) SetArgs(t *input.Input, a ...int) { + + e.EffectNode.SetArgs(t, a...) + e.EffectNode.Duration(e.EffectNode.SideEffectArgs[0]) + +} + +// ---- 注册所有效果 ---- +func init() { + input.InitEffect(input.EffectType.Skill, 776, &Effect776{}) +} diff --git a/logic/service/fight/effect/effect_8.go b/logic/service/fight/effect/effect_8.go index a82c819eb..9ee682e7f 100644 --- a/logic/service/fight/effect/effect_8.go +++ b/logic/service/fight/effect/effect_8.go @@ -14,9 +14,7 @@ import ( */ func init() { - input.InitEffect(input.EffectType.Skill, 8, &Effect8{ - EffectNode: node.EffectNode{}, - }) + input.InitEffect(input.EffectType.Skill, 8, &Effect8{}) } @@ -25,9 +23,9 @@ type Effect8 struct { } // 伤害落实前触发,限制最大伤害 -func (e *Effect8) Damage_Floor() bool { - if e.Ctx().DamageZone.Type == info.DamageType.Red { - e.Ctx().DamageZone.Damage = decimal.NewFromInt(utils.Min(e.Ctx().DamageZone.Damage.IntPart(), +func (e *Effect8) Damage_Floor(t *info.DamageZone) bool { + if t.Type == info.DamageType.Red { + t.Damage = decimal.NewFromInt(utils.Min(t.Damage.IntPart(), int64(e.Ctx().Opp.CurrentPet.Info.Hp)-1)) } diff --git a/logic/service/fight/effect/effect_status.go b/logic/service/fight/effect/effect_status.go index dba92b498..0a1a5ee2d 100644 --- a/logic/service/fight/effect/effect_status.go +++ b/logic/service/fight/effect/effect_status.go @@ -1,6 +1,7 @@ package effect import ( + "blazing/logic/service/fight/action" "blazing/logic/service/fight/info" "blazing/logic/service/fight/input" "blazing/logic/service/fight/node" @@ -11,6 +12,7 @@ import ( type BaseSataus struct { node.EffectNode + Status info.EnumBattleStatus } // /重写切换事件 @@ -27,33 +29,26 @@ func (e *BaseSataus) Switch(in *input.Input, outpet, inpet *info.BattlePetEntity return true } -// 施加一个基类effect -type EffectStatus struct { - BaseSataus - Status info.EnumBattleStatus -} - type StatusNotSkill struct { - EffectStatus + BaseSataus } // 不能出手 -func (e *StatusNotSkill) Skill_Hit_Pre() bool { +func (e *StatusNotSkill) Skill_Hit_Pre(a, b *action.SelectSkillAction) bool { return false } type StatusSleep struct { //睡眠不能出手 ,这个挂载到对面来实现对方攻击后解除睡眠效果 - BaseSataus StatusNotSkill can bool } -func (e *StatusSleep) Skill_Hit_Pre() bool { - e.StatusNotSkill.Skill_Hit_Pre() +func (e *StatusSleep) Skill_Hit_Pre(a, b *action.SelectSkillAction) bool { + e.can = true - return false + return e.StatusNotSkill.Skill_Hit_Pre(a, b) } func (e *StatusSleep) Skill_Use_ex() bool { @@ -71,12 +66,12 @@ func (e *StatusSleep) Skill_Use_ex() bool { // 扣血类 type DrainHP struct { - EffectStatus + BaseSataus damage decimal.Decimal } -func (e *DrainHP) Skill_Hit_Pre() bool { +func (e *DrainHP) Skill_Hit_Pre(a, b *action.SelectSkillAction) bool { e.damage = decimal.NewFromUint64(uint64(e.Ctx().Our.CurrentPet.Info.MaxHp)). Div(decimal.NewFromInt(8)) @@ -94,12 +89,12 @@ type DrainedHP struct { DrainHP } -func (e *DrainedHP) Skill_Hit_Pre() bool { +func (e *DrainedHP) Skill_Hit_Pre(a, b *action.SelectSkillAction) bool { if gconv.Int(e.Input.CurrentPet.Type) == 1 { return true } - e.DrainHP.Skill_Hit_Pre() //先调用父类扣血 + e.DrainHP.Skill_Hit_Pre(a, b) //先调用父类扣血 //TODO 寄生种子 给对面回血,待实现回血buff //这个回血不属于任何类型,所以不会被阻止回血 diff --git a/logic/service/fight/fightc.go b/logic/service/fight/fightc.go index ff5d1431b..9b0bedda7 100644 --- a/logic/service/fight/fightc.go +++ b/logic/service/fight/fightc.go @@ -123,7 +123,23 @@ func (f *FightC) copypet(t *info.BattlePetEntity) *info.BattlePetEntity { //回合有先手方和后手方,同时有攻击方和被攻击方 func (f *FightC) enterturn(fattack, sattack *action.SelectSkillAction) { + //双方首发精灵登场时,依挑战方机制:房主方先判定,挑战方后判定 + //双方非首发精灵登场时,根据切换先后判定(看手速) + // 神罗、圣华登场时魂免,“登场时xx”等效果 + //阿枫的效果也在这里判断 + f.Our.Exec(func(t input.Effect) bool { //回合开始前 + + //结算状态 + t.Turn_Start(fattack, sattack) + return true + }) + f.Opp.Exec(func(t input.Effect) bool { //回合开始前 + + //结算状态 + t.Turn_Start(fattack, sattack) + return true + }) // 伤害值 // 根据攻击方归属设置当前战斗的主/次攻击方属性 @@ -141,7 +157,6 @@ func (f *FightC) enterturn(fattack, sattack *action.SelectSkillAction) { f.First.ResetAttackValue() f.Second.ResetAttackValue() - if fattack != nil { //是否miss都应该施加解析effect f.First.Parseskill(f.Second, fattack) //解析到临时数据 @@ -182,18 +197,7 @@ func (f *FightC) enterturn(fattack, sattack *action.SelectSkillAction) { } } var attacker, defender *input.Input - f.First.Exec(func(t input.Effect) bool { //回合开始前 - //结算状态 - t.Turn_Start() - return true - }) - f.Second.Exec(func(t input.Effect) bool { //回合开始前 - - //结算状态 - t.Turn_Start() - return true - }) //开始回合操作 for i := 0; i < 2; i++ { var oldskill *info.SkillEntity //原始技能 @@ -214,13 +218,16 @@ func (f *FightC) enterturn(fattack, sattack *action.SelectSkillAction) { if oldskill != nil { fmt.Println("开始攻击威力", oldskill.Power) } + //是否miss都应该施加解析effect + canuseskill := attacker.Exec(func(t input.Effect) bool { //这个是能否使用技能 //结算状态 //然后这里还可以处理自爆类 t.Ctx().SkillEntity = currentskill - return t.Skill_Hit_Pre() //返回本身结算,如果false,说明不能使用技能了 + return t.Skill_Hit_Pre(fattack, sattack) //返回本身结算,如果false,说明不能使用技能了 }) + // 结算状态 // 然后这里还可以处理自爆类 if canuseskill && // @@ -260,9 +267,7 @@ func (f *FightC) enterturn(fattack, sattack *action.SelectSkillAction) { //技能使用后 defender.Exec(func(t input.Effect) bool { t.Ctx().SkillEntity = currentskill - t.Ctx().DamageZone = &info.DamageZone{ - Damage: attacker.DamageZone.Damage, - } + t.Skill_Use_ex() return true @@ -271,9 +276,7 @@ func (f *FightC) enterturn(fattack, sattack *action.SelectSkillAction) { //技能使用后 attacker.Exec(func(t input.Effect) bool { //技能使用后的我方效果 t.Ctx().SkillEntity = currentskill - t.Ctx().DamageZone = &info.DamageZone{ - Damage: attacker.DamageZone.Damage, - } + t.Skill_Useed() return true diff --git a/logic/service/fight/info/info.go b/logic/service/fight/info/info.go index d8b83791f..db79cfd34 100644 --- a/logic/service/fight/info/info.go +++ b/logic/service/fight/info/info.go @@ -125,8 +125,7 @@ type WeakenedS struct { // 定义战斗状态枚举 var PetStatus = enum.New[struct { - // 麻痹 - Paralysis EnumBattleStatus `enum:"0"` + Paralysis EnumBattleStatus `enum:"0"` // 麻痹 Poisoned EnumBattleStatus `enum:"1"` // 中毒 Burned EnumBattleStatus `enum:"2"` // 烧伤 DrainHP EnumBattleStatus `enum:"3"` // 吸取对方的体力 diff --git a/logic/service/fight/input/ctx.go b/logic/service/fight/input/ctx.go index b51155235..c9a5197ed 100644 --- a/logic/service/fight/input/ctx.go +++ b/logic/service/fight/input/ctx.go @@ -5,10 +5,10 @@ import ( ) type Ctx struct { - Our *Input //施加方 - Opp *Input //被施加方 - - *info.SkillEntity //action本身 + Our *Input //施加方 + Opp *Input //被施加方 - *info.DamageZone //伤害 + *info.SkillEntity //action本身 + + // *info.DamageZone //伤害 } diff --git a/logic/service/fight/input/effect.go b/logic/service/fight/input/effect.go index 873c0b1db..b332c1505 100644 --- a/logic/service/fight/input/effect.go +++ b/logic/service/fight/input/effect.go @@ -180,7 +180,7 @@ func (our *Input) Exec(fn func(Effect) bool) bool { if value.Alive() { value.Ctx().Our = our value.Ctx().Opp = our.Opp - value.Ctx().DamageZone = &info.DamageZone{} + //value.Ctx().DamageZone = &info.DamageZone{} if !fn(value) { //存在false,但是仍然要向下执行 result = false //如果是false,说明存在阻止向下执行的effect,比如免疫能力提升效果 } diff --git a/logic/service/fight/input/fight.go b/logic/service/fight/input/fight.go index 0d9bc7518..47c7908dc 100644 --- a/logic/service/fight/input/fight.go +++ b/logic/service/fight/input/fight.go @@ -105,9 +105,8 @@ func (our *Input) Damage(in *Input, sub *info.DamageZone) { var ok bool if our != in { ok = our.Opp.Exec(func(t Effect) bool { - t.Ctx().DamageZone = sub - t.Damage_ADD() //红伤落实前,我方增伤 + t.Damage_ADD(sub) //红伤落实前,我方增伤 return true }) @@ -115,8 +114,8 @@ func (our *Input) Damage(in *Input, sub *info.DamageZone) { //sub.BeforeMul = sub.Damage if ok { ok = our.Opp.Exec(func(t Effect) bool { - t.Ctx().DamageZone = sub - t.Damage_Mul() //红伤落实前,我方增伤 + + t.Damage_Mul(sub) //红伤落实前,我方增伤 return true }) @@ -124,8 +123,8 @@ func (our *Input) Damage(in *Input, sub *info.DamageZone) { //sub.BeforeFloor = sub.Damage if ok { ok = our.Opp.Exec(func(t Effect) bool { - t.Ctx().DamageZone = sub - t.Damage_Floor() //红伤落实,内部有befer + + t.Damage_Floor(sub) //红伤落实,内部有befer return true }) @@ -135,8 +134,8 @@ func (our *Input) Damage(in *Input, sub *info.DamageZone) { // sub.BeforeMul = sub.Damage if ok { ok = our.Exec(func(t Effect) bool { - t.Ctx().DamageZone = sub - t.Damage_DIV_ex() //红伤落实,内部有befer + + t.Damage_DIV_ex(sub) //红伤落实,内部有befer return true }) @@ -145,9 +144,8 @@ func (our *Input) Damage(in *Input, sub *info.DamageZone) { //sub.BeforeSUB = sub.Damage if ok { ok = our.Exec(func(t Effect) bool { - t.Ctx().DamageZone = sub - t.Damage_SUB_ex() + t.Damage_SUB_ex(sub) return true }) @@ -157,7 +155,7 @@ func (our *Input) Damage(in *Input, sub *info.DamageZone) { if ok && in != our { ok = our.Opp.Exec(func(t Effect) bool { - t.Damage_Lock() + t.Damage_Lock(sub) return true }) @@ -166,7 +164,7 @@ func (our *Input) Damage(in *Input, sub *info.DamageZone) { if ok { our.Exec(func(t Effect) bool { - t.Damage_Lock_ex() + t.Damage_Lock_ex(sub) return true }) diff --git a/logic/service/fight/input/input.go b/logic/service/fight/input/input.go index d753e3c68..8c8fa7736 100644 --- a/logic/service/fight/input/input.go +++ b/logic/service/fight/input/input.go @@ -24,6 +24,8 @@ type Input struct { Effects []Effect //effects 实际上全局就是effect无限回合 //effects容器 技能的 EffectCache []Effect //这里是命中前执行的容器,也就是命中前执行的所有逻辑相关,理论上一个effect被激活,就应该同时将其他的effect取消激活 Effect_Lost []Effect + //CanUseSkill bool + //Effect_Lost []Effect //NewEffects []Effect DamageZone struct { @@ -96,6 +98,7 @@ func (our *Input) ResetAttackValue() { our.AttackValue.GainHp = 0 our.AttackValue.LostHp = 0 our.DamageZone.Damage = decimal.NewFromInt(0) + //our.CanUseSkill = true } // 这个每回合都会调用 @@ -145,6 +148,7 @@ func (our *Input) GetStatusBonus() float64 { // 解析并 施加effect func (our *Input) Parseskill(defender *Input, skill *action.SelectSkillAction) { + our.EffectCache = make([]Effect, 0) //先把上一回合数据清空,但是应该把本身延续类效果集成过来 our.Effect_Lost = make([]Effect, 0) // our.Initeffectcache() //这里说明是延续的效果,每次复制出来一个新的就好了 diff --git a/logic/service/fight/input/interface.go b/logic/service/fight/input/interface.go index 430d58e12..276edff1f 100644 --- a/logic/service/fight/input/interface.go +++ b/logic/service/fight/input/interface.go @@ -6,28 +6,29 @@ import ( ) type Effect interface { - Compare_Pre(fattack, sattack *action.SelectSkillAction) bool //比较前对优先级的修改 Fight_Start() bool //战斗开始 - Turn_Start() //回合开始,注入特性 - + Turn_Start(fattack, sattack *action.SelectSkillAction) //回合开始,注入特性 + Compare_Pre(fattack, sattack *action.SelectSkillAction) bool //比较前对优先级的修改 //技能命中前的返回值代表是否可以出手 ,对命中本身的修改应该是对上下文本身的修改 - Skill_Hit_Pre() bool //对技能修改 行动开始前,注入视为等参数在这里实现 - Skill_Hit() bool //这是是命中后的对技能的修改,比如变威力 - Skill_Hit_ex() bool // 技能命中前触发//预处理受击技能 被攻击方效果,比如受击时无效技能这样 + //对技能修改 行动开始前,注入视为等参数在这里实现 + + Skill_Hit_Pre(fattack, sattack *action.SelectSkillAction) bool //比较前对优先级的修改 + Skill_Hit() bool //这是是命中后的对技能的修改,比如变威力 + Skill_Hit_ex() bool // 技能命中前触发//预处理受击技能 被攻击方效果,比如受击时无效技能这样 Calculate_Pre() bool //视为 无视效果,相当于这里对敌方的修改 OnSkill() bool // 触发on miss onhit //Skill_Can() bool //使用技能 可以取消用技能节点 技能无效节点锁定伤害加上 - Damage_ADD() bool // 攻击前触发 ,这时候就是+区间 - Damage_Mul() bool // 攻击触发 + Damage_ADD(*info.DamageZone) bool // 攻击前触发 ,这时候就是+区间 + Damage_Mul(*info.DamageZone) bool // 攻击触发 - Damage_Floor() bool // 保底伤害 - Damage_DIV_ex() bool //受击前触发 这时候就是百分比减伤区间 - Damage_SUB_ex() bool // 受击触发 这时候就是点数减伤 - Damage_Lock() bool //锁定伤害 - Damage_Lock_ex() bool //被动方锁定伤害 - Damage_Shield() bool // 护盾值变化时触发 + Damage_Floor(*info.DamageZone) bool // 保底伤害 + Damage_DIV_ex(*info.DamageZone) bool //受击前触发 这时候就是百分比减伤区间 + Damage_SUB_ex(*info.DamageZone) bool // 受击触发 这时候就是点数减伤 + Damage_Lock(*info.DamageZone) bool //锁定伤害 + Damage_Lock_ex(*info.DamageZone) bool //被动方锁定伤害 + Damage_Shield(*info.DamageZone) bool // 护盾值变化时触发 //Damage_Use() bool // 伤害作用 Skill_Use_ex() bool //技能PP减少节点 Skill_Useed() bool //技能PP减少节点 diff --git a/logic/service/fight/loop.go b/logic/service/fight/loop.go index f2b2ea762..09fa32780 100644 --- a/logic/service/fight/loop.go +++ b/logic/service/fight/loop.go @@ -145,6 +145,10 @@ func (f *FightC) resolveRound(p1Action, p2Action action.BattleActionI) { switch a := b1.(type) { case *action.ActiveSwitchAction: + + if f.GetInputByAction(a, false).CurrentPet.Info.Hp <= 0 { + f.GetInputByAction(a, false).CurrentPet.Info.Hp = 1 + } if b2k, ok := b2.(*action.SelectSkillAction); ok { f.waittime = b2k.CD f.enterturn(b2.(*action.SelectSkillAction), nil) @@ -155,6 +159,9 @@ func (f *FightC) resolveRound(p1Action, p2Action action.BattleActionI) { case *action.UseItemAction: f.handleItemAction(a) + if f.GetInputByAction(a, false).CurrentPet.Info.Hp <= 0 { + f.GetInputByAction(a, false).CurrentPet.Info.Hp = 1 + } if b2k, ok := b2.(*action.SelectSkillAction); ok { f.waittime = b2k.CD f.enterturn(b2.(*action.SelectSkillAction), nil) diff --git a/logic/service/fight/node/Turn.go b/logic/service/fight/node/Turn.go index 2b3963b2b..0ca418748 100644 --- a/logic/service/fight/node/Turn.go +++ b/logic/service/fight/node/Turn.go @@ -6,10 +6,15 @@ import ( "blazing/logic/service/fight/input" ) -func (e *EffectNode) Compare_Pre(fattack, sattack *action.SelectSkillAction) bool { - return false +func (e *EffectNode) Skill_Hit_Pre(fattack, sattack *action.SelectSkillAction) bool { + return true } -func (e *EffectNode) Turn_Start() { + +func (e *EffectNode) Compare_Pre(fattack, sattack *action.SelectSkillAction) bool { //比较前对优先级的修改 { + return true +} + +func (e *EffectNode) Turn_Start(fattack, sattack *action.SelectSkillAction) { //panic("not implemented") // TODO: Implement } func (e *EffectNode) Turn_End() { diff --git a/logic/service/fight/node/dagame.go b/logic/service/fight/node/dagame.go index 1050a2898..eee398554 100644 --- a/logic/service/fight/node/dagame.go +++ b/logic/service/fight/node/dagame.go @@ -1,34 +1,36 @@ package node -func (e *EffectNode) Damage_ADD() bool { +import "blazing/logic/service/fight/info" + +func (e *EffectNode) Damage_ADD(_ *info.DamageZone) bool { return true } -func (e *EffectNode) Damage_Mul() bool { +func (e *EffectNode) Damage_Mul(_ *info.DamageZone) bool { return true } -func (e *EffectNode) Damage_Floor() bool { +func (e *EffectNode) Damage_Floor(_ *info.DamageZone) bool { return true } -func (e *EffectNode) Damage_DIV_ex() bool { +func (e *EffectNode) Damage_DIV_ex(_ *info.DamageZone) bool { return true } -func (e *EffectNode) Damage_SUB_ex() bool { +func (e *EffectNode) Damage_SUB_ex(_ *info.DamageZone) bool { return true } -func (e *EffectNode) Damage_Lock() bool { +func (e *EffectNode) Damage_Lock(_ *info.DamageZone) bool { return true } -func (e *EffectNode) Damage_Lock_ex() bool { +func (e *EffectNode) Damage_Lock_ex(_ *info.DamageZone) bool { return true } -func (e *EffectNode) Damage_Shield() bool { +func (e *EffectNode) Damage_Shield(_ *info.DamageZone) bool { return true } diff --git a/logic/service/fight/node/skill.go b/logic/service/fight/node/skill.go index 08b76cf95..ea09463f0 100644 --- a/logic/service/fight/node/skill.go +++ b/logic/service/fight/node/skill.go @@ -12,9 +12,6 @@ func (e *EffectNode) Calculate_Pre() bool { return true } -func (e *EffectNode) Skill_Hit_Pre() bool { - return true -} func (e *EffectNode) Skill_Hit() bool { return true } diff --git a/logic/service/player/player.go b/logic/service/player/player.go index 0755b1089..4468569c8 100644 --- a/logic/service/player/player.go +++ b/logic/service/player/player.go @@ -75,7 +75,15 @@ func WithConn(c gnet.Conn) PlayerOption { p.MainConn = c } } +func (p *Player) UseCoins(t uint32) bool { + if p.Info.Coins < t { + return false + } + p.Info.Coins = p.Info.Coins - t + return true + +} func (p *Player) GetAction() { } diff --git a/manifest/config/config.yaml b/manifest/config/config.yaml index 24ed3db38..3937a3921 100644 --- a/manifest/config/config.yaml +++ b/manifest/config/config.yaml @@ -3,7 +3,7 @@ server: address: ":8080" #前台服务器地址 port: 53388 #后台服务器端口 rpc: 56409 #rpc服务端口 - game: [27777, 27778] + game: [27000, 27778] openapiPath: "/api.json" swaggerPath: "/swagger" clientMaxBodySize: diff --git a/modules/blazing/service/pet.go b/modules/blazing/service/pet.go index 5f24357ca..ee02efb6c 100644 --- a/modules/blazing/service/pet.go +++ b/modules/blazing/service/pet.go @@ -55,7 +55,7 @@ func (s *UserService) PetAdd(y model.PetInfo) { player.PlayerID = s.userid player.Data = y player.CatchTime = y.CatchTime - //player.InBag = 0 + player.Free = 0 _, err := m1.Insert(player) if err != nil {