This commit is contained in:
1
2025-09-25 14:08:40 +00:00
18 changed files with 115 additions and 105 deletions

View File

@@ -17,7 +17,7 @@ func init() {
input.InitEffect(input.EffectType.Skill, 1, &Effect1{})
}
func (e *Effect1) OnHit(opp *input.Input, skill *info.SkillEntity) {
func (e *Effect1) AfterSkill(opp *input.Input, skill *info.SkillEntity) {
t := e.Input.GetEffect(input.EffectType.Damage, 0).Stack()
e.Input.CurrentPet.Info.Hp += uint32(t / 2)

View File

@@ -41,7 +41,7 @@ func init() {
})
}
func (e *Effect10) OnHit(opp *input.Input, skill *info.SkillEntity) {
func (e *Effect10) AfterSkill(opp *input.Input, skill *info.SkillEntity) {
if e.Hit() {
t, _, _ := e.Input.Player.Roll(e.EffectNode.SideEffectArgs[0], 100)
if t {

View File

@@ -21,7 +21,7 @@ type Effect2 struct {
node.EffectNode
}
func (e *Effect2) BeforeSkill(opp *input.Input, skill *info.SkillEntity) {
func (e *Effect2) PreSkill(opp *input.Input, skill *info.SkillEntity) {
opp.Prop(e.Input, func() { //我方取敌方防御
if opp.CurrentPet.Info.Hp < (opp.CurrentPet.Info.MaxHp / 2) {
skill.Power *= 2

View File

@@ -39,7 +39,7 @@ type EffectStat struct {
// addrA := unsafe.Pointer(baseAddr + 4) //根据攻击算其他字段
// *(*uint32)(addrA) = 100
// }
func (e *EffectStat) OnHit(opp *input.Input, skill *info.SkillEntity) {
func (e *EffectStat) AfterSkill(opp *input.Input, skill *info.SkillEntity) {
t, _, _ := e.Input.Player.Roll(e.EffectNode.SideEffectArgs[1], 100)
if t {

View File

@@ -24,7 +24,7 @@ func init() {
}
func (e *Effect62) AfterHit(*input.Input, *info.SkillEntity) {
func (e *Effect62) AfterSkill(*input.Input, *info.SkillEntity) {
if e.Duration() != 1 { //说明还没到生效节点
e.Hide = true //隐藏效果
} else {

View File

@@ -24,7 +24,7 @@ type Effect9 struct {
UseSkillCount int //技能使用了多少次切换后置0
}
func (e *Effect9) BeforeSkill(opp *input.Input, skill *info.SkillEntity) {
func (e *Effect9) PreSkill(opp *input.Input, skill *info.SkillEntity) {
if e.Skillid != 0 && skill.ID != e.Skillid {
e.NotALive()
e.UseSkillCount = 0

View File

@@ -12,6 +12,15 @@ type Effect0 struct {
node.EffectNode
}
func (e *Effect0) OnSwitchOut() bool {
return true
}
func (e *Effect0) OnOwnerSwitchIn() bool {
return true
}
func (e *Effect0) TurnEnd(opp *input.Input) {
e.Input.AttackValue.RemainHp = int32(e.Input.CurrentPet.Info.Hp)
@@ -29,46 +38,50 @@ func (e *Effect0) OnSkill(opp *input.Input, skill *info.SkillEntity) {
e.Input.AttackValue.IsCritical = skill.Crit
return e.Input.AttackValue.IsCritical == 0
})
e.Input.Exec(func(t input.Effect) bool { //加伤
t.AddZone(e.Input, &input.EffectID{
ID: 1,
Effect: e,
})
return true
})
e.Input.Exec(func(t input.Effect) bool { //乘伤
t.MulZone(e.Input, &input.EffectID{
ID: 1,
Effect: e,
})
return true
})
if e.Input.AttackValue.IsCritical == 1 {
e.Input.Exec(func(t input.Effect) bool { //加伤
t.AddZone(e.Input, &input.EffectID{
ID: 1,
Effect: e,
})
return true
})
e.Input.Exec(func(t input.Effect) bool { //乘伤
t.MulZone(e.Input, &input.EffectID{
ID: 1,
Effect: e,
})
return true
})
e.Stack(e.Stack() * 2)
if e.MaxStack != 0 && e.Stack() > e.MaxStack { //限制最大伤害
e.Stack(e.MaxStack)
}
}
}
if e.MaxStack != 0 && e.Stack() > e.MaxStack { //限制最大伤害
e.Stack(e.MaxStack)
}
e.Input.AttackValue.LostHp = uint32(e.Stack())
}
func (this *Effect0) BeforHit(opp *input.Input, skill *info.SkillEntity) {
func (e *Effect0) BeforeSkill(opp *input.Input, skill *info.SkillEntity) {
skill.AttackTimeC(int(opp.GetProp(5, true))) //计算命中
skill.Crit = 0
if skill.Category() == info.Category.STATUS { //属性技能不用算暴击
return
}
CritRate := utils.Max(skill.CritRate, 1)
//CritAtkFirst: 先出手时必定致命一击; 默认: 0
if skill.CritAtkFirst != 0 && this.Input.First {
if skill.CritAtkFirst != 0 && e.Input.First {
CritRate = 16
}
//CritAtkSecond: 后出手时必定致命一击; 默认: 0
if skill.CritAtkSecond != 0 && !this.Input.First {
if skill.CritAtkSecond != 0 && !e.Input.First {
CritRate = 16
}
// CritSelfHalfHp: 自身体力低于一半时必定致命一击; 默认: 0
if skill.CritSelfHalfHp != 0 && (this.Input.CurrentPet.HP < int(this.Input.CurrentPet.Info.MaxHp)/2) {
if skill.CritSelfHalfHp != 0 && (e.Input.CurrentPet.HP < int(e.Input.CurrentPet.Info.MaxHp)/2) {
CritRate = 16
}
// CritFoeHalfHp: 对方体力低于一半时必定致命一击; 默认: 0
@@ -77,14 +90,14 @@ func (this *Effect0) BeforHit(opp *input.Input, skill *info.SkillEntity) {
}
//todo 暴击伤害
if t, _, _ := this.Input.Player.Roll(625*CritRate, 10000); t {
if t, _, _ := e.Input.Player.Roll(625*CritRate, 10000); t {
skill.Crit = 1
}
}
// 受击触发
func (e *Effect0) AfterAttacked(opp *input.Input, skill *info.SkillEntity) {
func (e *Effect0) Attacked(opp *input.Input, skill *info.SkillEntity) {
e.Input.Exec(func(t input.Effect) bool { //加伤
@@ -113,6 +126,7 @@ func (e *Effect0) AfterAttacked(opp *input.Input, skill *info.SkillEntity) {
} else {
e.Input.CurrentPet.Info.Hp = e.Input.CurrentPet.Info.Hp - opp.AttackValue.LostHp
}
}
func init() {

View File

@@ -16,7 +16,7 @@ type EffectStatusNotSkill struct {
EffectStatus
}
func (e *EffectStatusNotSkill) UseSkill(opp *input.Input) bool {
func (e *EffectStatusNotSkill) CanSkill(opp *input.Input) bool {
return false
}

View File

@@ -107,7 +107,7 @@ func (f *FightC) initplayer(c common.PlayerI, opp bool) {
f.Info.OpponentPetList = make([]info.ReadyFightPetInfo, len(temp.AllPet))
for i := 0; i < len(temp.AllPet); i++ {
err := copier.CopyWithOption(&f.Info.OpponentPetList[i], temp.AllPet[i].Info, copier.Option{IgnoreEmpty: true, DeepCopy: true})
err := copier.CopyWithOption(&f.Info.OpponentPetList[i], &temp.AllPet[i].Info, copier.Option{IgnoreEmpty: true, DeepCopy: true})
if err != nil {
panic(err)
}
@@ -325,8 +325,9 @@ func (f *FightC) battleLoop() {
if ok && ism && mo.CanCapture { //如果获取玩家
ok, _ := f.Our.Capture(f.Opp.CurrentPet, faction.ItemID, -1)
ok, res := f.Our.Capture(f.Opp.CurrentPet, faction.ItemID, -1)
if ok { //todo 待补充
fmt.Println(res)
tt.Service.PetAdd(*f.Opp.CurrentPet.Info)
tt.CatchPetInfo(info.CatchMonsterOutboundInfo{
CatchTime: uint32(f.Opp.CurrentPet.Info.CatchTime),
@@ -416,12 +417,12 @@ func (f *FightC) processSkillAttack(attacker, defender *input.Input, a *SelectSk
attacker.Exec(func(t input.Effect) bool { //计算命中
t.BeforHit(defender, a.Skill) //相当于先调整基础命中,不光调整命中,这里还能调整技能属性,暴击率
t.PreSkill(defender, a.Skill) //相当于先调整基础命中,不光调整命中,这里还能调整技能属性,暴击率
return true
})
defender.Exec(func(t input.Effect) bool { //计算闪避
t.BeforHit(attacker, a.Skill)
t.BeforeSkill(attacker, a.Skill)
return true
})
@@ -449,14 +450,14 @@ func (f *FightC) processSkillAttack(attacker, defender *input.Input, a *SelectSk
} //todo 处理未命中效果
defender.Exec(func(t input.Effect) bool {
t.AfterAttacked(attacker, a.Skill) //红伤落实
t.Attacked(attacker, a.Skill) //红伤落实
return true
})
attacker.Exec(func(t input.Effect) bool {
t.AfterHit(defender, a.Skill) //技能使用完毕后结算
t.AfterSkill(defender, a.Skill) //技能使用完毕后结算
return true
})
@@ -487,24 +488,25 @@ func (f *FightC) enterturn(fattack, sattack BattleActionI) {
attacker.First = false //先手技能
}
skill, ok := attackeraction.(*SelectSkillAction)
if !ok || attacker.CurrentPet.Info.Hp <= 0 { //还有系统选择放弃出手的
continue
}
attacker.Exec(func(t input.Effect) bool { //回合开始前
//结算状态
t.OnTurnStart(defender)
return true
})
canuseskill := attacker.Exec(func(t input.Effect) bool { //这个是能否使用技能
//结算状态
return t.UseSkill(defender) //返回本身结算,如果false,说明不能使用技能了
return t.CanSkill(defender) //返回本身结算,如果false,说明不能使用技能了
})
skill, ok := attackeraction.(*SelectSkillAction)
if !ok || attacker.CurrentPet.Info.Hp <= 0 { //还有系统选择放弃出手的
attacker.AttackValue.SkillID = 0
canuseskill = false
}
if canuseskill { //可以使用技能
f.processSkillAttack(attacker, defender, skill)
@@ -517,6 +519,7 @@ func (f *FightC) enterturn(fattack, sattack BattleActionI) {
"对手剩余血量:", defender.CurrentPet.Info.Hp,
)
if defender.CurrentPet.Info.Hp == 0 {
defender.AttackValue.SkillID = 0
defender.CanChange = true //被打死就可以切精灵了
if f.IsWin(attacker, defender.CurrentPet.Info.CatchTime) { //然后检查是否战斗结束
var WinnerId uint32
@@ -559,9 +562,14 @@ func (f *FightC) enterturn(fattack, sattack BattleActionI) {
for i := 0; i < 20; i++ { //堆叠状态剩余回合
ret.FAttack.Status[i] = int8(f.First.GetEffect(input.EffectType.Status, i).Duration())
ret.SAttack.Status[i] = int8(f.Second.GetEffect(input.EffectType.Status, i).Duration())
t := f.First.GetEffect(input.EffectType.Status, i)
if t != nil {
ret.FAttack.Status[i] = int8(t.Duration())
}
t = f.Second.GetEffect(input.EffectType.Status, i)
if t != nil {
ret.FAttack.Status[i] = int8(t.Duration())
}
}

View File

@@ -59,14 +59,14 @@ func (i *Input) Prop(in *Input, f func()) {
//opp.CurrentPet = oldouo //恢复
}
func (i *Input) Skill(in *info.SkillEntity, f func()) {
oldour := deepcopy.Copy(i.CurrentPet).(*info.SkillEntity)
oldour := deepcopy.Copy(in).(*info.SkillEntity)
//oldouo := deepcopy.Copy(opp.CurrentPet).(*info.BattlePetEntity)
i.Exec(func(t Effect) bool { //属性获取前
t.BeforeSkill(i,in) //使XX为XX
t.BeforeSkill(i, in) //使XX为XX
return true
})
f()
in = oldour //恢复
}
@@ -74,7 +74,6 @@ func (i *Input) Skill(in *info.SkillEntity, f func()) {
// 计算技能威力
func (i *Input) CalculatePower(deftype *Input, skill *info.SkillEntity) decimal.Decimal {
// 1. 计算等级因子 (level * 0.4 + 2)
levelFactor := decimal.NewFromInt(int64(i.CurrentPet.Info.Level)).
Mul(decimal.NewFromFloat(0.4)).Add(decimal.NewFromInt(2))
@@ -88,20 +87,20 @@ func (i *Input) CalculatePower(deftype *Input, skill *info.SkillEntity) decimal.
switch skill.Category() { //判断技能类型
case info.Category.PHYSICAL:
i.Prop(i, func() { //我方取我方攻击
attackDec = decimal.NewFromInt(int64(i.CurrentPet.Info.Prop[0]))
attackDec = decimal.NewFromInt(int64(i.GetProp(0, false)))
})
deftype.Prop(i, func() { //我方取敌方防御
defenseDec = decimal.NewFromInt(int64(deftype.CurrentPet.Info.Prop[1]))
defenseDec = decimal.NewFromInt(int64(deftype.GetProp(1, false)))
})
case info.Category.SPECIAL:
i.Prop(i, func() { //我方取我方攻击
attackDec = decimal.NewFromInt(int64(i.CurrentPet.Info.Prop[2]))
attackDec = decimal.NewFromInt(int64(i.GetProp(2, false)))
})
deftype.Prop(i, func() { //我方取敌方防御
defenseDec = decimal.NewFromInt(int64(deftype.CurrentPet.Info.Prop[3]))
defenseDec = decimal.NewFromInt(int64(deftype.GetProp(3, false)))
})

View File

@@ -9,16 +9,13 @@ type Effect interface {
OnTurnStart(opp *Input) //回合开始
UseSkill(opp *Input) bool //使用技能 可以取消用技能节点
BeforeSkill(opp *Input, skill *info.SkillEntity) //对技能修改,比如变威力
CanSkill(opp *Input) bool //使用技能 可以取消用技能节点
PreSkill(opp *Input, skill *info.SkillEntity) //对技能修改,比如变威力
BeforeSkill(opp *Input, skill *info.SkillEntity) // 技能命中前触发
OnSkill(opp *Input, skill *info.SkillEntity) //闪避率计算,,实际上是修改命中的判断
// OnSkillPP() bool //技能PP减少节点
AfterSkill(opp *Input, skill *info.SkillEntity) // 技能命中后触发
// OnCritPreDamage() bool //暴击判定成功且伤害计算前触发
// PreDamage() bool // 技能伤害计算前触发(增伤 / 减伤等)
// OnBeforeCalculateDamage() bool // 最终伤害计算前触发
// OnDamage() bool // 造成伤害时触发
//使用技能 可以取消用技能节点
// OnSkillPP() bool //技能PP减少节点
AfterAttr(t *info.BattlePetEntity) //在获取属性前,比如重写对方属性AfterAttr
BeferAttr(t *info.BattlePetEntity) //在获取属性后,比如视为对方属性
@@ -27,13 +24,10 @@ type Effect interface {
CalculateDamage(opp *Input, skill *info.SkillEntity) //击判定成功且伤害计算前触发
BeforeCalculateDamage(opp *Input, skill *info.SkillEntity) // 最终伤害计算前触发
BeforHit(opp *Input, skill *info.SkillEntity) // 技能命中前触发
AfterHit(opp *Input, skill *info.SkillEntity) // 技能命中后触发
AddZone(opp *Input, skill *EffectID) //加区
MulZone(opp *Input, skill *EffectID) //乘区
AfterAttacked(opp *Input, skill *info.SkillEntity) // 受击触发
AddZone(opp *Input, skill *EffectID) //加区
MulZone(opp *Input, skill *EffectID) //乘区
BeforeAttacked(opp *Input, skill *info.SkillEntity) // 受击前触发
Attacked(opp *Input, skill *info.SkillEntity) // 受击触发
// Shield() bool // 护盾值变化时触发
// PostDamage() bool // 伤害结算后触发(血量扣除后)

View File

@@ -29,6 +29,7 @@ func NewInput(c common.FightI, p common.PlayerI) *Input {
ret := &Input{FightC: c, Player: p}
ret.Effects = utils.NewOrderedMap[int, Effect]()
t := Geteffect(EffectType.Damage, 0)
t.Effect.SetArgs(ret)
ret.AddEffect(t) //添加默认基类,实现继承
p.SetFightC(c) //给玩家设置战斗容器
@@ -76,7 +77,7 @@ func (i *Input) GetStatusBonus() float64 {
t := Geteffect(EffectType.Status, statusIdx)
// 检查状态是否存在数组中值为1表示存在该状态
if t.Effect.Stack() > 0 {
if t.ID != 0 && t.Effect.Stack() > 0 {
if bonus, exists := statusBonuses[info.EnumBattleStatus(statusIdx)]; exists && bonus > maxBonus {
maxBonus = bonus
}

View File

@@ -3,12 +3,12 @@ package node
// 切精灵返回false重写change方法来实现切换效果
// 精灵切换相关触发
func (e *EffectNode) OnSwitchIn() bool {
panic("not implemented") // TODO: Implement
return true
}
func (e *EffectNode) OnSwitchOut() bool {
//下场默认清除effect
if e.Owner {//清除对方的我方施加uff
if e.Owner { //清除对方的我方施加uff
e.NotALive()
}
return true
@@ -22,5 +22,5 @@ func (e *EffectNode) OnOwnerSwitchIn() bool {
}
func (e *EffectNode) OnOwnerSwitchOut() bool {
panic("not implemented") // TODO: Implement
return true
}

View File

@@ -5,35 +5,20 @@ import (
"blazing/logic/service/fight/input"
)
// 命中前 攻击伤害结算
func (e *EffectNode) BeforHit(opp *input.Input, skill *info.SkillEntity) {
}
// 命中前 攻击伤害结算
func (e *EffectNode) AfterHit(opp *input.Input, skill *info.SkillEntity) {
}
// 命中时
func (e *EffectNode) OnHit(opp *input.Input, skill *info.SkillEntity) {
}
// miss触发
func (e *EffectNode) OnMiss(opp *input.Input, skill *info.SkillEntity) {
}
// 加算区
func (e *EffectNode) AddZone(opp *input.Input, skill *input.EffectID) {
}
//乘算区
// 乘算区
func (e *EffectNode) MulZone(opp *input.Input, skill *input.EffectID) {
}
// 受击触发
func (this *EffectNode) AfterAttacked(opp *input.Input, skill *info.SkillEntity) {
func (this *EffectNode) Attacked(opp *input.Input, skill *info.SkillEntity) {
}
// 受击触发
func (this *EffectNode) BeforeAttacked(opp *input.Input, skill *info.SkillEntity) {
}

View File

@@ -5,19 +5,29 @@ import (
"blazing/logic/service/fight/input"
)
func (e *EffectNode) OnSkillPP() bool {
return true
}
// 使用技能前
func (e *EffectNode) UseSkill(opp *input.Input) bool {
func (e *EffectNode) CanSkill(opp *input.Input) bool {
return e.Input.CurrentPet.HP != 0
}
// 命中前 攻击伤害结算
func (e *EffectNode) PreSkill(opp *input.Input, skill *info.SkillEntity) {
}
func (e *EffectNode) BeforeSkill(opp *input.Input, skill *info.SkillEntity) {
}
// 使用技能时
func (e *EffectNode) OnSkill(opp *input.Input, skill *info.SkillEntity) {
}
func (e *EffectNode) OnSkillPP() bool {
return true
}
func (e *EffectNode) BeforeSkill(opp *input.Input, skill *info.SkillEntity) {
func (e *EffectNode) AfterSkill(opp *input.Input, skill *info.SkillEntity) {
}

View File

@@ -58,7 +58,6 @@ type Pet struct {
type PetEX struct {
Pet
Data PetInfo `orm:"data" json:"data"`
}
type PetS struct {
@@ -96,8 +95,6 @@ func GenPetInfo(id int, dv, natureId, abilityTypeEnum, shinyid, level int) *PetI
if shinyid != -1 {
p.Shiny = uint32(shinyid)
} else {
}
if natureId != -1 {
p.Nature = uint32(natureId)

View File

@@ -13,6 +13,7 @@ func (s *UserService) Item(t func(map[uint32]model.SingleItemInfo) bool) {
err := m1.Scan(&player)
if err != nil {
player.PlayerID = uint64(s.userid)
player.Data = make(map[uint32]model.SingleItemInfo)
_, err := m1.Insert(player)
if err != nil {

View File

@@ -36,6 +36,7 @@ func (s *UserService) PetAdd(y model.PetInfo) {
m1 := cool.DBM(s.pet.Model).Where("player_id", s.userid)
var player model.PetEX
player.PlayerID = s.userid
player.Data = y
player.CatchTime = y.CatchTime
player.InBag = 0