diff --git a/logic/service/fight/fightc.go b/logic/service/fight/fightc.go index d0b0461f9..8f6970648 100644 --- a/logic/service/fight/fightc.go +++ b/logic/service/fight/fightc.go @@ -96,7 +96,7 @@ func (f *FightC) initplayer(c common.PlayerI, opp bool) { temp := input.NewInput(f, c) temp.AllPet = make([]*info.BattlePetEntity, 0) - temp.InitAttackValue() + for i := 0; i < len(c.GetInfo().PetList); i++ { if f.Info.MAXPET == 0 || i < int(f.Info.MAXPET) { @@ -185,7 +185,7 @@ func NewFight(mode, status info.EnumBattleMode, p1 common.PlayerI, p2 common.Pla ff.Player.SendNoteReadyToFightInfo(f.Info) }) }() - //go f.battleLoop() // 起战斗循环 + return f } @@ -239,7 +239,7 @@ func (f *FightC) battleLoop() { f.Round++ //回合数自增 actions := make(map[uint32]action.BattleActionI) // 每个玩家一条记录 - timeout := time.After(30 * time.Second) + timeout := time.After(60 * time.Second) for len(actions) < 2 { select { @@ -322,22 +322,32 @@ func (f *FightC) battleLoop() { f.closefight = true case *action.ActiveSwitchAction: // 切换上场的, 切换方放弃出手 - leftAction := BattleActionI[0] - rightAction := BattleActionI[1] // 如果后手不是技能,替换成空技能(放弃出手) - if _, ok := rightAction.(*action.SelectSkillAction); !ok { - rightAction = &action.SelectSkillAction{ + if _, ok := BattleActionI[1].(*action.SelectSkillAction); !ok { + BattleActionI[1] = &action.SelectSkillAction{ ID: 0, - BaseAction: action.NewBaseAction(rightAction.GetPlayerID()), + BaseAction: action.NewBaseAction(BattleActionI[1].GetPlayerID()), } - } - f.enterturn(rightAction.(*action.SelectSkillAction), - &action.SelectSkillAction{ + f.enterturn(&action.SelectSkillAction{ //双方均放弃出手 ID: 0, - BaseAction: action.NewBaseAction(leftAction.GetPlayerID()), - }) + BaseAction: action.NewBaseAction(BattleActionI[1].GetPlayerID()), + }, + &action.SelectSkillAction{ + ID: 0, + BaseAction: action.NewBaseAction(BattleActionI[0].GetPlayerID()), + }) + + } else { + + f.enterturn(BattleActionI[1].(*action.SelectSkillAction), //后手方先手,先手方放弃出手 + &action.SelectSkillAction{ + ID: 0, + BaseAction: action.NewBaseAction(BattleActionI[0].GetPlayerID()), + }) + + } case *action.UseItemAction: // 使用道具 switch { @@ -474,6 +484,8 @@ func (f *FightC) processSkillAttack(attacker, defender *input.Input, a *action.S } + } else { + } for _, e := range attacker.EffectCache { //这里实现应该参考本地技能是否命中,然后 @@ -536,8 +548,9 @@ func (f *FightC) enterturn(fattack, sattack *action.SelectSkillAction) { f.First, f.Second = f.Opp, f.Our // 攻击方为对方时,主攻击方是对方 } - - fmt.Println("房主", f.First.CurrentPet.Info.CatchTime, "挑战者", f.Second.CurrentPet.Info.CatchTime) + f.First.InitAttackValue() + f.Second.InitAttackValue() + fmt.Println("房主", fattack.ID, "挑战者", sattack.ID) switch { case sattack.ID != 0: @@ -719,13 +732,15 @@ func (f *FightC) enterturn(fattack, sattack *action.SelectSkillAction) { f.Broadcast(func(ff *input.Input) { for _, v := range f.Switch { + if ff.Player.GetInfo().UserID != v.PlayerID { ff.Player.SendChangePet(v.Reason) } } - f.Switch = []*action.ActiveSwitchAction{} + fmt.Println("得到用户", ff.Player.GetInfo().UserID) + ff.Player.SendAttackValue(ret) }) - + f.Switch = []*action.ActiveSwitchAction{} } diff --git a/logic/service/fight/playeraction.go b/logic/service/fight/playeraction.go index 5b149067c..a5c4eebf6 100644 --- a/logic/service/fight/playeraction.go +++ b/logic/service/fight/playeraction.go @@ -7,7 +7,6 @@ import ( "blazing/logic/service/fight/info" "blazing/logic/service/fight/input" "blazing/logic/service/player" - "fmt" "math" "github.com/gogf/gf/v2/util/gconv" @@ -138,8 +137,6 @@ func (f *FightC) ReadyFight(c common.PlayerI) { rrsult() case info.BattleStatus.FIGHT_WITH_NPC: // 野怪战斗 - //判断捕捉率大于0 - fmt.Println("CatchRate", xmlres.PetMAP[int(f.Info.OpponentPetList[0].ID)].CatchRate) if gconv.Int(xmlres.PetMAP[int(f.Info.OpponentPetList[0].ID)].CatchRate) > 0 { rett.Info2.Catchable = 1 t, _ := f.Opp.Player.(*player.AI_player) diff --git a/logic/service/player/player.go b/logic/service/player/player.go index c77bcf0e5..ca8aa974f 100644 --- a/logic/service/player/player.go +++ b/logic/service/player/player.go @@ -231,7 +231,7 @@ func (p *Player) ItemAdd(t []model.SingleItemInfo) { } func (p *Player) SendPack(b []byte) error { - if p.MainConn == nil { + if _, ok := p.MainConn.Context().(*ClientData); !ok { return fmt.Errorf("链接错误,取消发包") }