diff --git a/logic/controller/fight.go b/logic/controller/fight.go index e99bca94..0595a7fa 100644 --- a/logic/controller/fight.go +++ b/logic/controller/fight.go @@ -86,7 +86,7 @@ func (h Controller) OnReadyToFight(data *fight.ReadyToFightInboundInfo, c *playe func (h Controller) OnPlayerHandleFightInvite(data *fight.HandleFightInviteInboundInfo, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) { if ok, p1 := c.AgreeBattle(data.UserID, data.Flag, data.Mode); ok { - fight.NewFight(data.Mode, info.BattleStatus.FIGHT_WITH_PLAYER, p1, c) ///开始对战,房主方以及被邀请方 + fight.NewFight(data.Mode, info.BattleStatus.FIGHT_WITH_PLAYER, c, p1) ///开始对战,房主方以及被邀请方 } return nil, -1 } 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 4b6c4ef3..d8ed8036 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 @@ -51,19 +51,17 @@ func init() { } func (e *Effect10) OnHit(opp *input.Input, skill *info.SkillEntity) { - if e.Hit() { - t, _, _ := e.Input.Player.Roll(e.EffectNode.SideEffectArgs[0], 100) - if t { + t, _, _ := e.Input.Player.Roll(e.EffectNode.SideEffectArgs[0], 100) + if t { - t1 := e.Input.FightC.GetRand().Int31n(3) - - eff := input.Geteffect(input.EffectType.Status, int(e.Status)) - if eff.ID != 0 { - eff.Effect.Duration(int(t1 + 1)) - e.Input.AddEffect(eff) - } + t1 := e.Input.FightC.GetRand().Int31n(3) + eff := input.Geteffect(input.EffectType.Status, int(e.Status)) + if eff.ID != 0 { + eff.Effect.Duration(int(t1 + 1)) + opp.AddEffect(eff) } + } } diff --git a/logic/service/fight/fightc.go b/logic/service/fight/fightc.go index 8f697064..bf5ee4cc 100644 --- a/logic/service/fight/fightc.go +++ b/logic/service/fight/fightc.go @@ -165,6 +165,7 @@ func NewFight(mode, status info.EnumBattleMode, p1 common.PlayerI, p2 common.Pla f.Info.MAXPET = 1 default: } + f.StartTime = time.Now() seed := f.StartTime.UnixNano() ^ int64(p1.GetInfo().UserID) ^ int64(p2.GetInfo().UserID) // ^ int64(f.Round) // 用异或运算混合多维度信息 f.rand = rand.New(rand.NewSource(seed)) f.Info = info.NoteReadyToFightInfo{ @@ -225,7 +226,7 @@ func (f *FightC) Broadcast(t func(ff *input.Input)) { // 战斗回合循环 func (f *FightC) battleLoop() { - f.StartTime = time.Now() + f.actionChan = make(chan action.BattleActionI, 2) // 初始化全局操作通道 fmt.Println("战斗开始精灵", f.Our.Player.GetInfo().PetList[0].CatchTime) //战斗开始前操作 @@ -461,7 +462,9 @@ func (f *FightC) processSkillAttack(attacker, defender *input.Input, a *action.S //技能命中+效果失效 这里就是修改效果命中为false //技能miss+效果生效 这里属于强制改命中效果,但是正常来说,技能miss掉后效果也应该失效 //技能失效+效果失效 - if attacker.AttackValue.AttackTime > 0 { //如果命中 + // 记录技能信息 + attacker.AttackValue.SkillID = uint32(a.Skill.ID) //获取技能ID + if attacker.AttackValue.AttackTime > 0 { //如果命中 attacker.UseSkill(defender, a.Skill) //暴击计算 attacker.AttackValue.IsCritical = a.Skill.Crit attacker.Exec(func(t input.Effect) bool { //计算命中 miss改命中 @@ -474,8 +477,6 @@ func (f *FightC) processSkillAttack(attacker, defender *input.Input, a *action.S return true }) attacker.DamageZone.Damage = attacker.CalculatePower(defender, a.Skill) - // 记录技能信息 - attacker.AttackValue.SkillID = uint32(a.Skill.ID) //获取技能ID if attacker.AttackValue.IsCritical == 1 { @@ -725,7 +726,7 @@ func (f *FightC) enterturn(fattack, sattack *action.SelectSkillAction) { } t = f.Second.GetEffect(input.EffectType.Status, i) if t.ID != 0 { - ret.FAttack.Status[i] = int8(t.Effect.Duration()) + ret.SAttack.Status[i] = int8(t.Effect.Duration()) } } @@ -738,7 +739,6 @@ func (f *FightC) enterturn(fattack, sattack *action.SelectSkillAction) { } } - fmt.Println("得到用户", ff.Player.GetInfo().UserID) ff.Player.SendAttackValue(ret) }) diff --git a/logic/service/fight/input/node.go b/logic/service/fight/input/node.go index ab4d9904..6124e3ed 100644 --- a/logic/service/fight/input/node.go +++ b/logic/service/fight/input/node.go @@ -2,6 +2,7 @@ package input import ( "blazing/logic/service/fight/info" + "fmt" "blazing/modules/blazing/model" @@ -112,12 +113,12 @@ func (c *Input) AddEffect(e *EffectID) { //TODO 先激活 // 如果已有同 ID 的效果,尝试叠加 - eff, ok := c.Effects.Load(e.ID) - if !ok { - // 否则新加入 - c.Effects.Store(e.ID, e.Effect) + eff, ok := c.Effects.LoadOrStore(e.ID, e.Effect) + if ok { return + } + if !eff.Alive() { //如果不存活 c.Effects.Store(e.ID, e.Effect) return @@ -131,7 +132,7 @@ func (c *Input) AddEffect(e *EffectID) { } else { //这里,说明是延续回合效果 - + fmt.Println("回合数", value.Duration()) value.Duration(value.Duration()) } return false