feat: 新增战斗效果和修复登录逻辑
Some checks failed
ci/woodpecker/push/my-first-workflow Pipeline failed

This commit is contained in:
xinian
2026-03-08 11:22:00 +08:00
committed by cnb
parent 3dd2d40c50
commit 73d7f7f062
13 changed files with 262 additions and 179 deletions

View File

@@ -52,7 +52,7 @@ func (h Controller) Login(data *user.MAIN_LOGIN_IN, c gnet.Conn) (result *user.L
currentPlayer.Hash = hashcode
currentPlayer.Service = service.NewUserService(data.Head.UserID)
currentPlayer.Info = currentPlayer.Service.Info.SetLogin()
currentPlayer.Info = currentPlayer.Service.Info.GetLogin()
if currentPlayer.Info == nil {
defer c.Close()
return

View File

@@ -1,14 +1,10 @@
package effect
import (
"blazing/common/data/xmlres"
element "blazing/common/data/Element"
"blazing/logic/service/fight/action"
"blazing/logic/service/fight/info"
"blazing/logic/service/fight/input"
"strings"
"github.com/gogf/gf/v2/util/gconv"
"github.com/samber/lo"
)
// 14. 若遇到天敌, 则战斗开始时连续害怕 n 回合;a1: n
@@ -23,11 +19,12 @@ func (e *NewSel14) TurnStart(fattack *action.SelectSkillAction, sattack *action.
if e.ID().GetCatchTime() != e.Ctx().Our.CurrentPet.Info.CatchTime {
return
}
evs := gconv.Uint32s(strings.Split(xmlres.PetMAP[int(e.Ctx().Our.CurrentPet.ID)].NaturalEnemy, " "))
_, ok := lo.Find(evs, func(t uint32) bool {
return t == uint32(e.Ctx().Opp.CurrentPet.ID)
})
if !ok {
t, _ := element.Calculator.GetOffensiveMultiplier(e.Ctx().Opp.CurrentPet.Type, e.Ctx().Our.CurrentPet.Type)
// evs := gconv.Uint32s(strings.Split(xmlres.PetMAP[int(e.Ctx().Our.CurrentPet.ID)].NaturalEnemy, " "))
// _, ok := lo.Find(evs, func(t uint32) bool {
// return t == uint32(e.Ctx().Opp.CurrentPet.ID)
// })
if t <= 1 {
return
}
// 5. 获取状态效果实例并设置参数

View File

@@ -0,0 +1,34 @@
package effect
import (
"blazing/logic/service/fight/input"
"blazing/logic/service/fight/node"
)
// 169 - n回合内每回合额外附加m%几率令对手XX
type Effect169 struct {
node.EffectNode
}
func (e *Effect169) OnSkill() bool {
chance := e.Args()[1].IntPart()
success, _, _ := e.Input.Player.Roll(int(chance), 100)
if success {
// 添加异常状态
statusEffect := e.Ctx().Our.InitEffect(input.EffectType.Status, int(e.Args()[2].IntPart())) // 以麻痹为例
if statusEffect != nil {
e.Ctx().Opp.AddEffect(e.Ctx().Our, statusEffect)
}
}
return true
}
func (e *Effect169) SetArgs(t *input.Input, a ...int) {
e.EffectNode.SetArgs(t, a...)
e.EffectNode.Duration(a[0]) // 持续n回合
}
func init() {
input.InitEffect(input.EffectType.Skill, 169, &Effect169{})
}

View File

@@ -0,0 +1,47 @@
package effect
import (
"blazing/logic/service/fight/action"
"blazing/logic/service/fight/input"
"blazing/logic/service/fight/node"
)
// 171 - n回合内自身使用属性技能时能较快出手
type Effect171 struct {
node.EffectNode
}
func (e *Effect171) ComparePre(fattack *action.SelectSkillAction, sattack *action.SelectSkillAction) bool {
if e.ID().GetCatchTime() != e.Ctx().Our.CurrentPet.Info.CatchTime {
return true
}
if fattack == nil {
return true
}
//先手是自己
if fattack.PlayerID == e.Ctx().Our.UserID {
return true
}
if sattack == nil {
return true
}
if sattack == nil {
return true
}
if sattack.SkillEntity == nil {
return true
}
//对调
sattack.SkillEntity.Priority += 1
return true
}
func (e *Effect171) SetArgs(t *input.Input, a ...int) {
e.EffectNode.SetArgs(t, a...)
e.EffectNode.Duration(a[0]) // 持续n回合
}
func init() {
input.InitEffect(input.EffectType.Skill, 171, &Effect171{})
}

View File

@@ -0,0 +1,31 @@
package effect
import (
"blazing/logic/service/fight/input"
"blazing/logic/service/fight/node"
)
// 173 - 先出手时n%概率令对方xx
type Effect173 struct {
node.EffectNode
}
func (e *Effect173) OnSkill() bool {
if e.Input.FightC.IsFirst(e.Input.Player) { // 先出手
chance := e.Args()[0].IntPart()
success, _, _ := e.Input.Player.Roll(int(chance), 100)
if success {
statusEffect := e.Ctx().Our.InitEffect(input.EffectType.Status, int(e.Args()[1].IntPart())) // 以麻痹为例
if statusEffect != nil {
e.Ctx().Opp.AddEffect(e.Ctx().Our, statusEffect)
}
}
}
return true
}
func init() {
input.InitEffect(input.EffectType.Skill, 173, &Effect173{})
}

View File

@@ -0,0 +1,29 @@
package effect
import (
"blazing/logic/service/fight/info"
"blazing/logic/service/fight/input"
"blazing/logic/service/fight/node"
)
// 193 - 若对手XX则必定致命一击
type Effect193 struct {
node.EffectNode
}
func (e *Effect193) SkillHit() bool {
if e.Ctx().SkillEntity == nil {
return true
}
if e.Ctx().Opp.StatEffect_Exist(info.EnumPetStatus(e.Args()[0].IntPart())) { // 对手处于异常状态
// 设定必定暴击
e.Ctx().SkillEntity.CritRate = 16
}
return true
}
func init() {
input.InitEffect(input.EffectType.Skill, 193, &Effect193{})
}

View File

@@ -0,0 +1,26 @@
package effect
import (
"blazing/logic/service/fight/info"
"blazing/logic/service/fight/input"
"blazing/logic/service/fight/node"
)
// 424 - n回合内对手每回合速度等级m
type Effect424 struct {
node.EffectNode
}
func (e *Effect424) Action_end() bool {
e.Ctx().Opp.SetProp(e.Ctx().Our, 4, int8(e.Args()[1].IntPart()), info.AbilityOpType.SUB)
return true
}
func (e *Effect424) SetArgs(t *input.Input, a ...int) {
e.EffectNode.SetArgs(t, a...)
e.EffectNode.Duration(a[0]) // 持续n回合
}
func init() {
input.InitEffect(input.EffectType.Skill, 424, &Effect424{})
}

View File

@@ -0,0 +1,14 @@
package effect
import "blazing/logic/service/fight/node"
// 445 - 使用后在战斗结束时可以获得500赛尔豆每日上限5000
type Effect445 struct {
node.EffectNode
}
// func (e *Effect445) OnSkill() bool {
// // 这个效果需要在战斗结束后执行,暂时记录奖励
// e.Ctx().Our.EndReward = 500
// return true
// }

View File

@@ -0,0 +1,36 @@
package effect
import (
element "blazing/common/data/Element"
"blazing/logic/service/fight/info"
"blazing/logic/service/fight/input"
"blazing/logic/service/fight/node"
)
// 464 - 遇到天敌时m%令对手烧伤
type Effect464 struct {
node.EffectNode
}
func (e *Effect464) OnSkill() bool {
t, _ := element.Calculator.GetOffensiveMultiplier(e.Ctx().Opp.CurrentPet.Type, e.Ctx().Our.CurrentPet.Type)
if t <= 1 {
return true
}
chance := e.Args()[0].IntPart()
success, _, _ := e.Input.Player.Roll(int(chance), 100)
if success {
burnEffect := e.Ctx().Our.InitEffect(input.EffectType.Status, int(info.PetStatus.Burned))
if burnEffect != nil {
e.Ctx().Opp.AddEffect(e.Ctx().Our, burnEffect)
}
}
return true
}
func init() {
input.InitEffect(input.EffectType.Skill, 464, &Effect464{})
}

View File

@@ -0,0 +1,30 @@
package effect
import (
"blazing/logic/service/fight/action"
"blazing/logic/service/fight/input"
"blazing/logic/service/fight/node"
)
// 489 - 若自身处于能力提升状态则每次攻击恢复自身体力的1/m
type Effect489 struct {
node.EffectNode
}
func (e *Effect489) SkillHit_ex() bool {
for _, v := range e.Ctx().Our.Prop[:] {
if v > 0 {
maxHp := e.Ctx().Our.CurrentPet.GetMaxHP()
healAmount := maxHp.Div(e.Args()[0]) // 1/m
e.Ctx().Our.Heal(e.Ctx().Our, &action.SelectSkillAction{}, healAmount)
return true
}
}
return true
}
func init() {
input.InitEffect(input.EffectType.Skill, 489, &Effect489{})
}

View File

@@ -78,64 +78,6 @@ func (e *Effect441) SetArgs(t *input.Input, a ...int) {
e.maxCritIncrease = a[1]
}
// 169 - n回合内每回合额外附加m%几率令对手XX
type Effect169 struct {
node.EffectNode
}
func (e *Effect169) OnSkill() bool {
if !e.Hit() {
return true
}
chance := e.Args()[1].IntPart()
success, _, _ := e.Input.Player.Roll(int(chance), 100)
if success {
// 添加异常状态
statusEffect := e.Ctx().Our.InitEffect(input.EffectType.Status, int(info.PetStatus.Paralysis)) // 以麻痹为例
if statusEffect != nil {
e.Ctx().Opp.AddEffect(e.Ctx().Our, statusEffect)
}
}
return true
}
func (e *Effect169) SetArgs(t *input.Input, a ...int) {
e.EffectNode.SetArgs(t, a...)
e.EffectNode.Duration(a[0]) // 持续n回合
}
// 464 - 遇到天敌时m%令对手烧伤
type Effect464 struct {
node.EffectNode
}
func (e *Effect464) OnSkill() bool {
if !e.Hit() {
return true
}
// 检查是否遇到天敌
if e.isDisadvantageousMatch() {
chance := e.Args()[0].IntPart()
success, _, _ := e.Input.Player.Roll(int(chance), 100)
if success {
burnEffect := e.Ctx().Our.InitEffect(input.EffectType.Status, int(info.PetStatus.Burned))
if burnEffect != nil {
e.Ctx().Opp.AddEffect(e.Ctx().Our, burnEffect)
}
}
}
return true
}
func (e *Effect464) isDisadvantageousMatch() bool {
// 这里需要根据具体的克制关系判断
// 暂时用伪代码实现
return e.Ctx().Our.CurrentPet.Type == element.ElementTypeFire &&
e.Ctx().Opp.CurrentPet.Type == element.ElementTypeWater
}
// 507 - 下回合若受到的伤害大于m则恢复自身所有体力
type Effect507 struct {
node.EffectNode
@@ -158,20 +100,6 @@ func (e *Effect507) Skill_Use_ex() bool {
return true
}
// 489 - 若自身处于能力提升状态则每次攻击恢复自身体力的1/m
type Effect489 struct {
node.EffectNode
}
func (e *Effect489) SkillHit_ex() bool {
if e.Ctx().Our.CurrentPet.HasPositiveBuff() { // 假设有检查能力提升的方法
maxHp := e.Ctx().Our.CurrentPet.GetMaxHP()
healAmount := maxHp.Div(e.Args()[0]) // 1/m
e.Ctx().Our.Heal(e.Ctx().Our, &action.SelectSkillAction{}, healAmount)
}
return true
}
// 477 - n回合内若受到攻击则对手攻击防御特攻特防速度命中等级降低
type Effect477 struct {
node.EffectNode
@@ -208,30 +136,6 @@ func (e *Effect477) SetArgs(t *input.Input, a ...int) {
e.EffectNode.Duration(a[0]) // 持续n回合
}
// 173 - 先出手时n%概率令对方xx
type Effect173 struct {
node.EffectNode
}
func (e *Effect173) OnSkill() bool {
if !e.Hit() {
return true
}
if e.Ctx().Our.Speed > e.Ctx().Opp.Speed { // 先出手
chance := e.Args()[0].IntPart()
success, _, _ := e.Input.Player.Roll(int(chance), 100)
if success {
statusEffect := e.Ctx().Our.InitEffect(input.EffectType.Status, int(info.PetStatus.Paralysis)) // 以麻痹为例
if statusEffect != nil {
e.Ctx().Opp.AddEffect(e.Ctx().Our, statusEffect)
}
}
}
return true
}
// 165 - n回合内每回合防御和特防等级+m
type Effect165 struct {
node.EffectNode
@@ -273,25 +177,6 @@ func (e *Effect483) OnSkill() bool {
return true
}
// 424 - n回合内对手每回合速度等级m
type Effect424 struct {
node.EffectNode
}
func (e *Effect424) OnSkill() bool {
speedEffect := e.Ctx().Our.InitEffect(input.EffectType.Status, int(info.PetStatus.SpeedDown))
if speedEffect != nil {
speedEffect.SetArgs(e.Ctx().Our, int(e.Args()[1].IntPart()))
e.Ctx().Opp.AddEffect(e.Ctx().Our, speedEffect)
}
return true
}
func (e *Effect424) SetArgs(t *input.Input, a ...int) {
e.EffectNode.SetArgs(t, a...)
e.EffectNode.Duration(a[0]) // 持续n回合
}
// 485 - 消除对手能力强化状态,若消除成功,则自身恢复所有体力
type Effect485 struct {
node.EffectNode
@@ -336,17 +221,6 @@ func (e *Effect188) SkillHit() bool {
return true
}
// 445 - 使用后在战斗结束时可以获得500赛尔豆每日上限5000
type Effect445 struct {
node.EffectNode
}
func (e *Effect445) OnSkill() bool {
// 这个效果需要在战斗结束后执行,暂时记录奖励
e.Ctx().Our.EndReward = 500
return true
}
// 420 - 使用了该技能后,若受到消除强化类技能攻击,则对方则对方攻击和特攻等级+/-n
type Effect420 struct {
node.EffectNode
@@ -420,24 +294,6 @@ func (e *Effect403) OnSkill() bool {
return true
}
// 193 - 若对手XX则必定致命一击
type Effect193 struct {
node.EffectNode
}
func (e *Effect193) SkillHit() bool {
if e.Ctx().SkillEntity == nil {
return true
}
if e.Ctx().Opp.CurrentPet.HasAnyStatus() { // 对手处于异常状态
// 设定必定暴击
e.Ctx().SkillEntity.MustCrit = true
}
return true
}
// 491 - 3回合内对手造成的伤害降低m%
type Effect491 struct {
node.EffectNode
@@ -543,23 +399,6 @@ func (e *Effect504) OnSkill() bool {
return true
}
// 171 - n回合内自身使用属性技能时能较快出手
type Effect171 struct {
node.EffectNode
}
func (e *Effect171) Skill_Pre() bool {
if e.Ctx().SkillEntity != nil && e.Ctx().SkillEntity.Category() == info.Category.STATUS {
// 提高速度,确保较快出手
e.Ctx().Our.TempSpeedBoost = true
}
return true
}
func (e *Effect171) SetArgs(t *input.Input, a ...int) {
e.EffectNode.SetArgs(t, a...)
e.EffectNode.Duration(a[0]) // 持续n回合
}
// 1044 - 吸取对手能力提升状态吸取成功则下n回合造成的伤害翻倍
type Effect1044 struct {

View File

@@ -329,9 +329,9 @@ func (f *FightC) enterturn(firstAttack, secondAttack *action.SelectSkillAction)
}
})
f.Switch = make(map[uint32]*action.ActiveSwitchAction)
if f.closefight && f.Info.Mode == info.BattleMode.PET_MELEE {
return
}
// if f.closefight && f.Info.Mode == info.BattleMode.PET_MELEE {
// return
// }
f.Broadcast(func(fighter *input.Input) {
fighter.Player.SendPackCmd(2505, &attackValueResult)
fighter.CanChange = 0

View File

@@ -56,7 +56,7 @@ func (s *InfoService) Person(userid uint32) (out *model.Player) {
}
func (s *InfoService) SetLogin() *model.PlayerInfo {
func (s *InfoService) GetLogin() *model.PlayerInfo {
var tt *model.Player
s.dbm_fix(s.Model).Scan(&tt)
@@ -93,7 +93,7 @@ func (s *InfoService) SetLogin() *model.PlayerInfo {
}
if !IsToday(tt.LastResetTime) { //判断是否是今天
if !IsToday(tt.LastResetTime) && cool.Config.ServerInfo.IsVip == 0 { //判断是否是今天
//每天login时候检查重置时间然后把电池任务挖矿重置
//挖矿需要单独存,因为防止多开挖矿
@@ -122,7 +122,7 @@ func (s *InfoService) SetLogin() *model.PlayerInfo {
panic(err)
}
}
if !IsWEEK(tt.WeekLastResetTime) {
if !IsWEEK(tt.WeekLastResetTime) && cool.Config.ServerInfo.IsVip == 0 {
for _, v := range service.NewTaskService().GetWeek() {