Exemplo n.º 1
0
		internal override void OnLogEntryAdded(LogEntry entry)
		{
			StartTime = LogEntries.Min(e => e.Time);
			EndTime = LogEntries.Max(e => e.Time);

			if (entry.Who != Player)
				return;

			base.OnLogEntryAdded(entry);

			if (string.IsNullOrEmpty(entry.AbilityId))
				return;

			var ability = _abilitiesInternal.FirstOrDefault(a => a.Id == entry.AbilityId);
			if (ability == null)
			{
				ability = new CombatAbility
				{
					Id = entry.AbilityId,
					Name = entry.AbilityName
				};
				_abilitiesInternal.Add(ability);
			}

			ability.AddLogEntry(entry);
		}
Exemplo n.º 2
0
		internal virtual void AddLogEntry(LogEntry entry)
		{
			if (entry != null)
			{
				_logEntriesInternal.Add(entry);
				OnLogEntryAdded(entry);
			}
		}
Exemplo n.º 3
0
		internal override void OnLogEntryAdded(LogEntry entry)
		{
			base.OnLogEntryAdded(entry);

			if (entry.Type == EntryType.Event && entry.Action == LogEntry.AbilityActivateAction)
				_activationsInternal.Add(new AbilityActivation());

			var activation = _activationsInternal.LastOrDefault();

			if (activation != null && activation.TriggeredActivation
				&& entry.Type == EntryType.ApplyEffect && entry.Action == entry.AbilityName && entry.AbilityId == entry.ActionId)
			{
				activation = new AbilityActivation(true);
				_activationsInternal.Add(activation);
			}

			if (activation == null)
			{
				activation = new AbilityActivation(true);
				_activationsInternal.Add(activation);
			}

			activation.AddLogEntry(entry);
		}
Exemplo n.º 4
0
		public static LogEntry Parse(string input, DateTime day)
		{
			var match = LogEntryRegex.Match(input);
			if (!match.Success)
				throw new Exception($"Can't parse combat log string \"{input}\".");
			try
			{
				var entry = new LogEntry
				{
					Time = new DateTime
					(
						day.Year,
						day.Month,
						day.Day,
						int.Parse(match.Groups["Hour"].Value),
						int.Parse(match.Groups["Minute"].Value),
						int.Parse(match.Groups["Second"].Value),
						int.Parse(match.Groups["Millisecond"].Value)
					)
				};

				if (match.Groups["Who"].Success || match.Groups["WhoId"].Success)
				{
					entry.Who = new Character
					(
						match.Groups["Who"].Success ? match.Groups["Who"].Value : match.Groups["WhoId"].Value,
						match.Groups["IsPlayer"].Success
					);
				}

				if (match.Groups["Target"].Success || match.Groups["TargetId"].Success)
				{
					entry.Target = new Character
					(
						match.Groups["Target"].Success ? match.Groups["Target"].Value : match.Groups["TargetId"].Value,
						match.Groups["TargetIsPlayer"].Success
					);
				}

				if (match.Groups["AbilityName"].Success)
				{
					entry.AbilityName = match.Groups["AbilityName"].Value;
					entry.AbilityId = match.Groups["AbilityId"].Value;
				}

				EntryType type;
				entry.Type = Enum.TryParse(match.Groups["EntryType"].Value, true, out type) ? type : EntryType.Unknown;

				entry.Action = match.Groups["Action"].Value;
				entry.ActionId = match.Groups["ActionId"].Value;

				if (match.Groups["Amount"].Success)
				{
					AmountType amountType;
					AmountModifier amountModifier;
					entry.Amount = new Amount
					{
						Value = int.Parse(match.Groups["Amount"].Value),
						Type = match.Groups["AmountType"].Success && Enum.TryParse(match.Groups["AmountType"].Value, true, out amountType) ? amountType : AmountType.Generic,
						Modifier = match.Groups["AmountModifier"].Success && Enum.TryParse(match.Groups["AmountModifier"].Value, true, out amountModifier)
							? amountModifier
							: AmountModifier.None,
						IsCritical = match.Groups["IsCritical"].Success
					};
				}

				if (match.Groups["Mitigation"].Success)
				{
					MitigationType mitigationType;
					entry.Mitigation = new Mitigation
					{
						Value = int.Parse(match.Groups["Mitigation"].Value),
						Type = match.Groups["MitigationType"].Success && Enum.TryParse(match.Groups["MitigationType"].Value, true, out mitigationType)
							? mitigationType
							: MitigationType.Unknown
					};
				}

				return entry;
			}
			catch (Exception ex)
			{
				throw new Exception($"Can't parse combat log string \"{input}\".\nError message: \"{ex.Message}\".");
			}
		}
Exemplo n.º 5
0
		internal abstract void OnLogEntryAdded(LogEntry entry);
		internal override void OnLogEntryAdded(LogEntry entry)
		{
			DamageDone = LogEntries.Where(e => e.Type == EntryType.ApplyEffect && e.Action == LogEntry.DamageAction && e.Amount != null).Sum(e => e.Amount.Value);
			HealingDone = LogEntries.Where(e => e.Type == EntryType.ApplyEffect && e.Action == LogEntry.HealAction && e.Amount != null).Sum(e => e.Amount.Value);
		}