public BattleCalculator(LogBattle battle) : base(battle) { Heals = new HealCalculator(Battle); Damage = new DamageCalculator(Battle); DamageTaken = new DamageTakenCalculator(Battle); Threat = new ThreatCalculator(Battle); }
public LogBattle SimBattle() { var logBattle = new LogBattle(); AttackHands.ForEach(p => p.ResetArmor()); DefenceHands.ForEach(p => p.ResetArmor()); DefenceTurrelsGroups.ForEach(p => p.ResetArmor()); logBattle.StartWeight = AttackHands.Sum(p => p.UnitGroups.Sum(pp => pp.TotalWeight)); logBattle.StartDefendedWeight = DefenceHands.Sum(p => p.UnitGroups.Sum(pp => pp.TotalWeight)); while (AttackHands.Any(p => p.AnyBattleUnitAlive) && (DefenceHands.Any(p => p.AnyAlive) || DefenceTurrelsGroups.Any(p => p.IsAnyAlive))) { // Раунд Атакующего var values = SelectAttackUnits(AttackHands); var attackHand = values.Hand; var attackUnitsGroup = values.Group; var defenceHand = DefenceHands.Where(p => p.AnyAlive).OrderBy(p => p.AttackOrder).FirstOrDefault() ?? new Hand { UnitGroups = DefenceTurrelsGroups }; var defenceHandForLog = DefenceHands.Where(p => p.AnyAlive).OrderBy(p => p.AttackOrder).FirstOrDefault()?.UnitGroups; defenceHandForLog = defenceHandForLog?.Concat(DefenceTurrelsGroups).ToList() ?? DefenceTurrelsGroups; var logRound = ExecuteRoundWithLog(attackUnitsGroup, defenceHand.UnitGroups, true, attackHand.UnitGroups, defenceHandForLog); logRound.RoundType = RoundType.AgressorFleet; logBattle.Rounds.Add(logRound); // Раунд кораблей Обороняющегося values = SelectAttackUnits(DefenceHands); attackHand = values.Hand; attackUnitsGroup = values.Group; defenceHand = AttackHands.Where(p => p.AnyAlive).OrderBy(p => p.AttackOrder).FirstOrDefault(); if (defenceHand?.AnyAlive == true && attackHand?.AnyAlive == true) { logRound = ExecuteRoundWithLog(attackUnitsGroup, defenceHand.UnitGroups, true, attackHand.UnitGroups.Concat(DefenceTurrelsGroups).ToList(), defenceHand.UnitGroups); logRound.RoundType = RoundType.DefenceFleet; logBattle.Rounds.Add(logRound); } // Раунд пушек Обороняющегося values = SelectAttackUnits(DefenceTurrelsGroups); attackHand = values.Hand; attackUnitsGroup = values.Group; defenceHand = AttackHands.Where(p => p.AnyAlive).OrderBy(p => p.AttackOrder).FirstOrDefault(); if (defenceHand?.AnyAlive == true && attackHand?.AnyAlive == true) { var isDefenceTakeDamage = DefenceHands.Any(p => p.AnyAlive); logRound = ExecuteRoundWithLog(attackUnitsGroup, defenceHand.UnitGroups, isDefenceTakeDamage, attackHand.UnitGroups, defenceHand.UnitGroups); logRound.RoundType = RoundType.DefenceTurrels; logBattle.Rounds.Add(logRound); } } logBattle.EndWeight = AttackHands.Sum(p => p.UnitGroups.Sum(pp => pp.TotalWeight)); logBattle.EndDefendedWeight = DefenceHands.Sum(p => p.UnitGroups.Sum(pp => pp.TotalWeight)); return(logBattle); }
private void ShowBattleLog(LogBattle battle) { if (battle == null) { LogText.Document = new FlowDocument(); LogText.IsEnabled = false; return; } SummaryVisitor summaryVisitor = new SummaryVisitor(); HealVisitor healVisitor = new HealVisitor(); DamageVisitor damageVisitor = new DamageVisitor(); battle.Visit(summaryVisitor,healVisitor,damageVisitor); LogText.IsEnabled = true; LogText.Document = new FlowDocument(new Paragraph(new Run(summaryVisitor.Summary))); LogHeal.Document = new FlowDocument(new Paragraph(new Run(healVisitor.Summary))); LogHeal.Document.Blocks.Add(healVisitor.Table); LogDamageDealt.Document = new FlowDocument(new Paragraph(new Run(damageVisitor.Summary))); LogDamageTaken.Document = new FlowDocument(new Paragraph(new Run(battle.Statistics.DamageTaken.GetLog()))); LogThreat.Document = new FlowDocument(new Paragraph(new Run(battle.Statistics.Threat.GetLog()))); LogThreat.Document.Blocks.Add(battle.Statistics.Threat.GetThreatTable()); }
public HealCalculator(LogBattle battle) : base(battle) { }
internal Calculator(LogBattle battle) { _battle = battle; InitProperties(); }
public DamageTakenCalculator(LogBattle battle) : base(battle) { }
public ThreatCalculator(LogBattle battle) : base(battle) { }
public static List<LogBattle> DivideIntoBattlesAndApplyGuards(List<LogRecord> log) { string logOwner = log.First(rec => rec.Effect.Type == LogEffectType.Event).Source.Name; var battles = new List<LogBattle>(); LogBattle currentBattle = null; bool guarded = false; IEnumerable<LogRecord> heals = log.Where(rec => rec.Source.Name == logOwner && rec.Effect.Name == LogEffect.HealString); var healRecords = heals as IList<LogRecord> ?? heals.ToList(); double healMultiplier = healRecords.Any() ? healRecords.Max(rec => { var d = ((double) rec.Threat*2/(rec.Guarded ? 0.75 : 1))/ rec.Quantity.Value; return d < 0.95 ? d : 0; }) : 1; if (healMultiplier == 0) healMultiplier = 1; foreach (var record in log) { switch (record.Effect.Name) { case LogEffect.GuardString: { switch (record.Effect.Type) { case LogEffectType.ApplyEffect: guarded = true; break; case LogEffectType.RemoveEffect: guarded = false; break; } } break; case LogEffect.ExitCombatString: if (currentBattle != null) { currentBattle.Add(record); battles.Add(currentBattle); currentBattle = null; } break; case LogEffect.DeathString: if (currentBattle != null) { currentBattle.Add(record); if (record.Target.Name == logOwner) { battles.Add(currentBattle); currentBattle = null; guarded = false; } } break; case LogEffect.EnterCombatString: currentBattle = new LogBattle(logOwner) {record}; break; default: if (currentBattle != null) { record.Guarded = guarded; record.HealThreatMultiplier = healMultiplier; currentBattle.Add(record); } break; } } return battles; }