public MechanicLog(long time, Mechanic mechanic, DummyActor actor) { Time = time; _mechanic = mechanic; Actor = actor; }
public void DependencyResolverAdder_Add_ResultOfFactoryIsUsedToCreateActors() { //arrange DependencyResolverAdder sut = CreateDependencyResolverAdder(); DummyActor actor = new DummyActor(); //act sut.Add(this, type => actor); //assert TestActorRef <ActorBase> result = ActorOfAsTestActorRef <ActorBase>(Sys.DI().Props <ActorBase>()); result.UnderlyingActor.Should().BeSameAs(actor); }
public void DependencyResolverAdder_Add_FactoryIsGivenCorrectType() { //arrange DependencyResolverAdder sut = CreateDependencyResolverAdder(); DummyActor actor = new DummyActor(); Type actual = null; //act sut.Add(this, type => { actual = type; return(actor); }); //assert ActorOfAsTestActorRef <ActorBase>(Sys.DI().Props <DummyActor>()); actual.Should().Be <DummyActor>(); }
public void DependencyResolverAdder_Add_LatestFactoryIsUsed() { //arrange DependencyResolverAdder sut = CreateDependencyResolverAdder(); List <DummyActor> actors = TestUtils.CreateMany <DummyActor>(); foreach (DummyActor actor in actors.Take(actors.Count)) { sut.Add(this, type => actor); } DummyActor expected = new DummyActor(); //act sut.Add(this, type => expected); //assert TestActorRef <ActorBase> result = ActorOfAsTestActorRef <ActorBase>(Sys.DI().Props <DummyActor>()); result.UnderlyingActor.Should().BeSameAs(expected); }
public static List <int[]> GetMechanicData(HashSet <Mechanic> presMech, ParsedLog log, DummyActor actor, PhaseData phase) { List <int[]> res = new List <int[]>(); foreach (Mechanic mech in presMech) { long timeFilter = 0; int filterCount = 0; List <MechanicEvent> mls = log.MechanicData.GetMechanicLogs(log, mech).Where(x => x.Actor.InstID == actor.InstID && phase.InInterval(x.Time)).ToList(); int count = mls.Count; foreach (MechanicEvent ml in mls) { if (mech.InternalCooldown != 0 && ml.Time - timeFilter < mech.InternalCooldown)//ICD check { filterCount++; } timeFilter = ml.Time; } res.Add(new int[] { count - filterCount, count }); } return(res); }
public BaseDummyTest() : base("https://www.google.com/") { User = new DummyActor(); }
public MechanicEvent(long time, Mechanic mech, DummyActor actor) : base(time, 0) { Actor = actor; _mechanic = mech; }
public void ComputeMechanics(ParsedLog log) { MechanicData mechData = log.MechanicData; CombatData combatData = log.CombatData; Mechanic.CheckSpecialCondition condition; HashSet <ushort> playersIds = log.PlayerIDs; Dictionary <ushort, DummyActor> regroupedMobs = new Dictionary <ushort, DummyActor>(); foreach (Mechanic mech in MechanicList) { switch (mech.MechanicType) { case Mechanic.MechType.PlayerStatus: foreach (Player p in log.PlayerList) { List <CombatItem> cList = new List <CombatItem>(); switch (mech.SkillId) { case SkillItem.DeathId: cList = combatData.GetStatesData(p.InstID, ParseEnum.StateChange.ChangeDead, log.FightData.FightStart, log.FightData.FightEnd); break; case SkillItem.DownId: cList = combatData.GetStatesData(p.InstID, ParseEnum.StateChange.ChangeDown, log.FightData.FightStart, log.FightData.FightEnd); List <CombatItem> downByVaporForm = combatData.GetBoonData(5620).Where(x => x.SrcInstid == p.InstID && x.IsBuffRemove == ParseEnum.BuffRemove.All).ToList(); foreach (CombatItem c in downByVaporForm) { cList.RemoveAll(x => Math.Abs(x.Time - c.Time) < 20); } break; case SkillItem.ResurrectId: cList = log.GetCastData(p.InstID, log.FightData.FightStart, log.FightData.FightEnd).Where(x => x.SkillID == SkillItem.ResurrectId && x.IsActivation.StartCasting()).ToList(); break; } foreach (CombatItem mechItem in cList) { mechData[mech].Add(new MechanicLog(log.FightData.ToFightSpace(mechItem.Time), mech, p)); } } break; case Mechanic.MechType.SkillOnPlayer: foreach (Player p in log.PlayerList) { List <DamageLog> dls = p.GetDamageTakenLogs(null, log, 0, log.FightData.FightDuration); condition = mech.SpecialCondition; foreach (DamageLog dLog in dls) { if (condition != null && !condition(new SpecialConditionItem(dLog))) { continue; } if (dLog.SkillId == mech.SkillId && dLog.Result.IsHit()) { mechData[mech].Add(new MechanicLog(dLog.Time, mech, p)); } } } break; case Mechanic.MechType.PlayerBoon: case Mechanic.MechType.PlayerOnPlayer: case Mechanic.MechType.PlayerBoonRemove: foreach (Player p in log.PlayerList) { condition = mech.SpecialCondition; foreach (CombatItem c in log.GetBoonData(mech.SkillId)) { if (condition != null && !condition(new SpecialConditionItem(c))) { continue; } if (mech.MechanicType == Mechanic.MechType.PlayerBoonRemove) { if (c.IsBuffRemove == ParseEnum.BuffRemove.Manual && p.InstID == c.SrcInstid) { mechData[mech].Add(new MechanicLog(log.FightData.ToFightSpace(c.Time), mech, p)); } } else { if (c.IsBuffRemove == ParseEnum.BuffRemove.None && p.InstID == c.DstInstid) { mechData[mech].Add(new MechanicLog(log.FightData.ToFightSpace(c.Time), mech, p)); if (mech.MechanicType == Mechanic.MechType.PlayerOnPlayer) { mechData[mech].Add(new MechanicLog(log.FightData.ToFightSpace(c.Time), mech, log.PlayerList.FirstOrDefault(x => x.InstID == c.SrcInstid))); } } } } } break; case Mechanic.MechType.HitOnEnemy: foreach (Player p in log.PlayerList) { condition = mech.SpecialCondition; IEnumerable <AgentItem> agents = log.AgentData.GetAgentsByID((ushort)mech.SkillId); foreach (AgentItem a in agents) { foreach (DamageLog dl in p.GetDamageLogs(null, log, 0, log.FightData.FightDuration)) { if (dl.DstInstId != a.InstID || dl.IsIndirectDamage || dl.Time < log.FightData.ToFightSpace(a.FirstAware) || dl.Time > log.FightData.ToFightSpace(a.LastAware) || (condition != null && !condition(new SpecialConditionItem(dl)))) { continue; } mechData[mech].Add(new MechanicLog(dl.Time, mech, p)); } } } break; case Mechanic.MechType.PlayerSkill: foreach (Player p in log.PlayerList) { condition = mech.SpecialCondition; foreach (CombatItem c in log.GetCastDataById(mech.SkillId)) { if (condition != null && !condition(new SpecialConditionItem(c))) { continue; } if (c.IsActivation.StartCasting() && c.SrcInstid == p.InstID) { mechData[mech].Add(new MechanicLog(log.FightData.ToFightSpace(c.Time), mech, p)); } } } break; case Mechanic.MechType.EnemyBoon: case Mechanic.MechType.EnemyBoonStrip: condition = mech.SpecialCondition; foreach (CombatItem c in log.GetBoonData(mech.SkillId)) { if (condition != null && !condition(new SpecialConditionItem(c))) { continue; } DummyActor amp = null; if (mech.MechanicType == Mechanic.MechType.EnemyBoon && c.IsBuffRemove == ParseEnum.BuffRemove.None) { Target target = Targets.Find(x => x.InstID == c.DstInstid && x.FirstAware <= c.Time && x.LastAware >= c.Time); if (target != null) { amp = target; } else { AgentItem a = log.AgentData.GetAgent(c.DstAgent, c.Time); if (playersIds.Contains(a.InstID)) { continue; } else if (a.MasterAgent != 0) { AgentItem m = log.AgentData.GetAgent(a.MasterAgent, c.Time); if (playersIds.Contains(m.InstID)) { continue; } } if (!regroupedMobs.TryGetValue(a.ID, out amp)) { amp = new DummyActor(a); regroupedMobs.Add(a.ID, amp); } } } else if (mech.MechanicType == Mechanic.MechType.EnemyBoonStrip && c.IsBuffRemove == ParseEnum.BuffRemove.Manual) { Target target = Targets.Find(x => x.InstID == c.SrcInstid && x.FirstAware <= c.Time && x.LastAware >= c.Time); if (target != null) { amp = target; } else { AgentItem a = log.AgentData.GetAgent(c.SrcAgent, c.Time); if (playersIds.Contains(a.InstID)) { continue; } else if (a.MasterAgent != 0) { AgentItem m = log.AgentData.GetAgent(a.MasterAgent, c.Time); if (playersIds.Contains(m.InstID)) { continue; } } if (!regroupedMobs.TryGetValue(a.ID, out amp)) { amp = new DummyActor(a); regroupedMobs.Add(a.ID, amp); } } } if (amp != null) { mechData[mech].Add(new MechanicLog(log.FightData.ToFightSpace(c.Time), mech, amp)); } } break; case Mechanic.MechType.EnemyCastEnd: case Mechanic.MechType.EnemyCastStart: condition = mech.SpecialCondition; foreach (CombatItem c in log.GetCastDataById(mech.SkillId)) { if (condition != null && !condition(new SpecialConditionItem(c))) { continue; } DummyActor amp = null; if ((mech.MechanicType == Mechanic.MechType.EnemyCastStart && c.IsActivation.StartCasting()) || (mech.MechanicType == Mechanic.MechType.EnemyCastEnd && !c.IsActivation.StartCasting())) { Target target = Targets.Find(x => x.InstID == c.SrcInstid && x.FirstAware <= c.Time && x.LastAware >= c.Time); if (target != null) { amp = target; } else { AgentItem a = log.AgentData.GetAgent(c.SrcAgent, c.Time); if (playersIds.Contains(a.InstID)) { continue; } else if (a.MasterAgent != 0) { AgentItem m = log.AgentData.GetAgent(a.MasterAgent, c.Time); if (playersIds.Contains(m.InstID)) { continue; } } if (!regroupedMobs.TryGetValue(a.ID, out amp)) { amp = new DummyActor(a); regroupedMobs.Add(a.ID, amp); } } } if (amp != null) { mechData[mech].Add(new MechanicLog(log.FightData.ToFightSpace(c.Time), mech, amp)); } } break; case Mechanic.MechType.Spawn: foreach (AgentItem a in log.AgentData.GetAgentByType(AgentItem.AgentType.NPC).Where(x => x.ID == mech.SkillId)) { if (!regroupedMobs.TryGetValue(a.ID, out DummyActor amp)) { amp = new DummyActor(a); regroupedMobs.Add(a.ID, amp); } mechData[mech].Add(new MechanicLog(log.FightData.ToFightSpace(a.FirstAware), mech, amp)); } break; } } mechData.ComputePresentMechanics(log); }