diff --git a/common/socket/ServerEvent.go b/common/socket/ServerEvent.go index 85326db6..b127962f 100644 --- a/common/socket/ServerEvent.go +++ b/common/socket/ServerEvent.go @@ -168,7 +168,10 @@ func (s *Server) handleTcp(conn gnet.Conn) (action gnet.Action) { s.workerPool.Submit(func() { //TODO 这里可能存在顺序执行问题,待修复 //conn.Context().(*player.ClientData).OnEvent(data) - conn.Context().(*player.ClientData).LF.Producer().Write(data) + if t, ok := conn.Context().(*player.ClientData); ok { + t.LF.Producer().Write(data) + } + }) if conn.InboundBuffered() > 0 { diff --git a/logic/service/fight/effect/effect_10-16_94_99_114.go b/logic/service/fight/effect/effect_10-16_94_99_114.go index 1f0bef25..0ce70ce1 100644 --- a/logic/service/fight/effect/effect_10-16_94_99_114.go +++ b/logic/service/fight/effect/effect_10-16_94_99_114.go @@ -70,7 +70,8 @@ func (e *Effect10) OnSkill(ctx input.Ctx) bool { // 持续回合 if duration == 0 { - duration = int(rand.Int31n(3)) // 默认随机 1~3 回合 + duration = int(rand.Int31n(2)) // 默认随机 1~3 回合 + duration++ } // 获取状态效果 diff --git a/logic/service/fight/fightc.go b/logic/service/fight/fightc.go index 0a45b530..5712771c 100644 --- a/logic/service/fight/fightc.go +++ b/logic/service/fight/fightc.go @@ -388,9 +388,19 @@ func (f *FightC) enterturn(fattack, sattack *action.SelectSkillAction) { f.First.ResetAttackValue() f.Second.ResetAttackValue() - switch { - case sattack != nil: + if fattack != nil { + //是否miss都应该施加解析effect + f.First.Parseskill(f.Second, fattack) //解析到临时数据 + f.First.Exec(func(t input.Effect) bool { //回合开始前 + + //结算状态 + t.Compare_Pre(fattack, sattack) //先结算技能的优先级 + return true + }) + + } + if sattack != nil { f.Second.Parseskill(f.Second, sattack) //解析到临时数据 f.Second.Exec(func(t input.Effect) bool { //回合开始前 @@ -399,39 +409,24 @@ func (f *FightC) enterturn(fattack, sattack *action.SelectSkillAction) { t.Compare_Pre(fattack, sattack) //先结算技能的优先级 return true }) - switch { - case fattack != nil: //房主也放弃出手 - //是否miss都应该施加解析effect - f.First.Parseskill(f.Second, fattack) //解析到临时数据 - - f.First.Exec(func(t input.Effect) bool { //回合开始前 - - //结算状态 - t.Compare_Pre(fattack, sattack) //先结算技能的优先级 - return true - }) - switch { - - case fattack.SkillEntity.Priority < sattack.SkillEntity.Priority: - - fattack, sattack = sattack, fattack //互换先手权 - f.First, f.Second = f.Second, f.First - case fattack.SkillEntity.Priority == sattack.SkillEntity.Priority: - - if f.Second.GetProp(4, false) > f.First.GetProp(4, false) { - fattack, sattack = sattack, fattack //互换先手权 - f.First, f.Second = f.Second, f.First - } - - } - - default: //房主放弃出手 - fattack, sattack = sattack, fattack //互换先手权 - f.First, f.Second = f.Second, f.First - } } + if fattack != nil && sattack != nil { + switch { + case fattack.SkillEntity.Priority < sattack.SkillEntity.Priority: + + fattack, sattack = sattack, fattack //互换先手权 + f.First, f.Second = f.Second, f.First + case fattack.SkillEntity.Priority == sattack.SkillEntity.Priority: + + if f.Second.GetProp(4, false) > f.First.GetProp(4, false) { + fattack, sattack = sattack, fattack //互换先手权 + f.First, f.Second = f.Second, f.First + } + + } + } var attacker, defender *input.Input f.First.Exec(func(t input.Effect) bool { //回合开始前 diff --git a/logic/service/fight/input/node.go b/logic/service/fight/input/node.go index c9dc801b..4cdca3eb 100644 --- a/logic/service/fight/input/node.go +++ b/logic/service/fight/input/node.go @@ -22,7 +22,7 @@ var EffectType = enum.New[struct { var NodeM = make(map[int]Effect, 0) func InitEffect(etype EnumEffectType, id int, t Effect) { - t.ID(id) //设置ID + t.ID(id + int(etype)) //设置ID NodeM[id+int(etype)] = t } @@ -69,8 +69,10 @@ func (c *Input) GetProp(id int, istue bool) int { func (c *Input) GetEffect(etype EnumEffectType, id int) Effect { var ret []Effect + + eid := id + int(etype) for _, v := range c.Effects { - if v.ID() == id+int(etype) && v.Alive() { + if v.ID() == eid && v.Alive() { ret = append(ret, v) } diff --git a/logic/service/fight/loop.go b/logic/service/fight/loop.go index 3d14f3fd..ed62ce83 100644 --- a/logic/service/fight/loop.go +++ b/logic/service/fight/loop.go @@ -161,16 +161,15 @@ func (f *FightC) handleItemAction(a *action.UseItemAction, other action.BattleAc PetId: uint32(f.Opp.CurrentPet.ID), }) //f.WinnerId = 0 //捕捉成功不算胜利 - f.Reason = 6 f.closefight = true } else { our.CatchPetInfo(info.CatchMonsterOutboundInfo{}) } } - case a.ItemID == 300001: - fmt.Println("ItemID 是 300001") + default: + f.enterturn(nil, nil) fmt.Println("ItemID 不在指定范围内") } diff --git a/logic/service/pet/BargeList.go b/logic/service/pet/BargeList.go new file mode 100644 index 00000000..ef7020b6 --- /dev/null +++ b/logic/service/pet/BargeList.go @@ -0,0 +1,15 @@ +package pet + +// PetBargeListInboundInfo 对应Java的PetBargeListInboundInfo,实现InboundMessage接口 +type PetBargeListInboundInfo struct { + StartPetId uint64 `description:"开始精灵id" codec:"startPetId"` // @UInt long 对应Go的uint64(无符号64位) + EndPetId uint64 `description:"结束精灵id" codec:"endPetId"` // 字段标签模拟注解功能(描述、编解码标识) +} + +// PetBargeListInfo 对应Java的PetBargeListInfo类 +type PetBargeListInfo struct { + PetId uint64 `description:"精灵ID"` // @UInt long 对应Go的uint64(无符号64位整数) + EnCntCnt uint64 `description:"未知"` // public字段在Go中通过首字母大写导出 + IsCatched uint64 `description:"捕获记录"` // 结构体标签模拟@FieldDescription注解 + IsKilled uint64 `description:"击杀记录"` // 字段名采用帕斯卡命名法(首字母大写)以匹配Java的public访问权限 +}