Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public void HitWithOnBuildsToCorrectResult()
var result = sut.HitWith(damageTypeBuilder).On.Build();
var stat = result.StatConverter(InputStat).BuildToSingleStat();

Assert.AreEqual("stat.On(FireHit).By(Character)", stat.Identity);
Assert.AreEqual("stat.On(Hit.Fire).By(Character)", stat.Identity);
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ public void AttackWithHandConvertsStatsCorrectly()
var expected = Mock.Of<IDamageRelatedStatBuilder>();
var hand = AttackDamageHand.OffHand;
var inStat =
Mock.Of<IDamageRelatedStatBuilder>(b => b.WithSkills.With(DamageSource.Attack).With(hand) == expected);
Mock.Of<IDamageRelatedStatBuilder>(b => b.With(DamageSource.Attack).With(hand).WithSkills == expected);
var sut = CreateSut();

var statConverter = sut.AttackWith(hand).Build().StatConverter;
var statConverter = sut.AttackWithSkills(hand).Build().StatConverter;
var actual = statConverter(inStat);

Assert.AreEqual(expected, actual);
Expand All @@ -83,7 +83,7 @@ public void AttackWithHandThrowsWhenConvertingNonDamageRelatedStat()
var inStat = Mock.Of<IStatBuilder>();
var sut = CreateSut();

var statConverter = sut.AttackWith(AttackDamageHand.MainHand).Build().StatConverter;
var statConverter = sut.AttackWithSkills(AttackDamageHand.MainHand).Build().StatConverter;

Assert.Throws<ParseException>(() => statConverter(inStat));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ public class ActionBuilder : IActionBuilder

protected IStatFactory StatFactory { get; }
private readonly ICoreBuilder<string> _identity;
private readonly IEntityBuilder _entity;
protected IEntityBuilder Entity { get; }

public ActionBuilder(IStatFactory statFactory, ICoreBuilder<string> identity, IEntityBuilder entity)
{
StatFactory = statFactory;
_identity = identity;
_entity = entity;
Entity = entity;
}

public IActionBuilder Resolve(ResolveContext context) =>
new ActionBuilder(StatFactory, _identity.Resolve(context), _entity);
new ActionBuilder(StatFactory, _identity.Resolve(context), Entity);

public IActionBuilder By(IEntityBuilder source) =>
new ActionBuilder(StatFactory, _identity, source);
Expand All @@ -46,7 +46,7 @@ public IActionBuilder By(IEntityBuilder source) =>
private IEnumerable<IStat> ConvertStat(BuildParameters parameters, ICoreBuilder<string> identity, IStat stat)
{
var builtIdentity = identity.Build(parameters);
return from e in _entity.Build(stat.Entity)
return from e in Entity.Build(stat.Entity)
let i = $"On({builtIdentity}).By({e})"
let registrationType = GainOnAction(stat, builtIdentity, e)
select StatFactory.CopyWithSuffix(stat, i, stat.DataType, registrationType);
Expand All @@ -58,7 +58,7 @@ public IConditionBuilder InPastXSeconds(IValueBuilder seconds) =>

private IValue BuildInPastXSecondsValue(BuildParameters parameters, IValueBuilder seconds)
{
var builtEntity = BuildEntity(parameters, _entity);
var builtEntity = BuildEntity(parameters, Entity);
var recentOccurrencesStat = BuildRecentOccurrencesStat(parameters, builtEntity);
var lastOccurenceStat = BuildLastOccurrenceStat(parameters, builtEntity);
var secondsValue = seconds.Build(parameters);
Expand All @@ -82,7 +82,7 @@ bool Calculate(IValueCalculationContext context)
new ValueBuilder(new ValueBuilderImpl(BuildCountRecentlyValue, c => Resolve(c).CountRecently));

private IValue BuildCountRecentlyValue(BuildParameters parameters)
=> new StatValue(BuildRecentOccurrencesStat(parameters, BuildEntity(parameters, _entity)));
=> new StatValue(BuildRecentOccurrencesStat(parameters, BuildEntity(parameters, Entity)));

private IStat BuildLastOccurrenceStat(BuildParameters parameters, Entity entity)
=> StatFactory.FromIdentity($"{Build(parameters)}.LastOccurrence", entity, typeof(uint),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,12 @@ private static string BuildHitWithIdentity(BuildParameters parameters, IKeywordB
throw new ParseException(
$"IDamageTypeBuilders passed to {nameof(HitWith)} must build to exactly one damage type." +
$" {string.Join(",", damageTypes)} given");
return damageTypes.Single() + "Hit";
return $"Hit.{damageTypes.Single()}";
}

public IActionBuilder HitWith(AttackDamageHand hand) =>
new ActionBuilder(_statFactory, CoreBuilder.Create($"Hit.{hand}"), _entity);

public IActionBuilder SavageHit => Create();
public ICriticalStrikeActionBuilder CriticalStrike => new CriticalStrikeActionBuilder(_statFactory, _entity);
public IActionBuilder NonCriticalStrike => Create();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using PoESkillTree.Engine.Computation.Builders.Stats;
using System.Runtime.CompilerServices;
using PoESkillTree.Engine.Computation.Builders.Stats;
using PoESkillTree.Engine.Computation.Common.Builders.Actions;
using PoESkillTree.Engine.Computation.Common.Builders.Entities;
using PoESkillTree.Engine.Computation.Common.Builders.Stats;
Expand All @@ -20,5 +21,11 @@ public BlockActionBuilder(IStatFactory statFactory, IEntityBuilder entity)

public IStatBuilder SpellChance =>
StatBuilderUtils.FromIdentity(StatFactory, "Block.ChanceAgainstSpells", typeof(uint));

public IActionBuilder Attack => Create();
public IActionBuilder Spell => Create();

private IActionBuilder Create([CallerMemberName] string identity = "") =>
new ActionBuilder(StatFactory, CoreBuilder.Create("Block." + identity), Entity);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,21 @@ public IConditionBuilder With(ISkillBuilder skill)
.And(activeSkillIdStat.Value.Eq(skill.SkillId));
}

public IConditionBuilder AttackWithSkills(AttackDamageHand hand) =>
AttackWith(hand)
.And(new StatConvertingConditionBuilder(IfIsDamageStat(d => d.WithSkills)));

public IConditionBuilder AttackWith(AttackDamageHand hand) =>
With(DamageSource.Attack)
.And(new StatConvertingConditionBuilder(IfIsDamageStat(d => d.With(hand))));

public IConditionBuilder WithSkills(DamageSource damageSource) =>
With(damageSource)
.And(new StatConvertingConditionBuilder(IfIsDamageStat(d => d.WithSkills)));

public IConditionBuilder With(DamageSource damageSource) =>
new StatConvertingConditionBuilder(IfIsDamageStat(
d => d.WithSkills(damageSource),
d => d.With(damageSource),
_ => throw new ParseException(
$"IConditionBuilders.{nameof(With)} only works with damage related stats")));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ public IDamageTypeBuilder Except(IDamageTypeBuilder type) =>
public IStatBuilder Resistance =>
new StatBuilder(_statFactory, CoreStat(typeof(int)));

public IStatBuilder ResistanceAgainstHits =>
new StatBuilder(_statFactory, CoreStat(typeof(double)));

public IStatBuilder ResistanceAgainstDoTs =>
new StatBuilder(_statFactory, CoreStat(typeof(double)));

public IDamageStatBuilder Damage =>
new DamageStatBuilder(_statFactory, CoreStat(_statFactory.Damage));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Linq;
using EnumsNET;
using PoESkillTree.Engine.Computation.Builders.Stats;
using PoESkillTree.Engine.Computation.Common;
using PoESkillTree.Engine.Computation.Common.Builders.Effects;
using PoESkillTree.Engine.Computation.Common.Builders.Stats;

Expand All @@ -16,8 +17,13 @@ public AilmentBuilders(IStatFactory statFactory)
_allAilments = new AilmentBuilderCollection(statFactory, Enums.GetValues<Ailment>().ToList());
Elemental = new AilmentBuilderCollection(statFactory,
new[] { Ailment.Ignite, Ailment.Shock, Ailment.Chill, Ailment.Freeze });

ShockEffect = StatBuilderUtils.FromIdentity(statFactory, "Shock.Effect", typeof(double));
IncreasedDamageTakenFromShocks = StatBuilderUtils.FromIdentity(statFactory,
"Shock.IncreasedDamageTaken", typeof(uint), ExplicitRegistrationTypes.UserSpecifiedValue(15));
ChillEffect = StatBuilderUtils.FromIdentity(statFactory, "Chill.Effect", typeof(double));
ReducedActionSpeedFromChill = StatBuilderUtils.FromIdentity(statFactory,
"Chill.ReducedActionSpeed", typeof(uint), ExplicitRegistrationTypes.UserSpecifiedValue(10));
}

public IAilmentBuilder Ignite => _allAilments[Ailment.Ignite];
Expand All @@ -28,8 +34,11 @@ public AilmentBuilders(IStatFactory statFactory)
public IAilmentBuilder Poison => _allAilments[Ailment.Poison];
public IAilmentBuilder From(Ailment ailment) => _allAilments[ailment];
public IAilmentBuilderCollection Elemental { get; }
public IAilmentBuilderCollection All => _allAilments;
public IStatBuilder ShockEffect { get; }
public IStatBuilder IncreasedDamageTakenFromShocks { get; }
public IStatBuilder ChillEffect { get; }
public IStatBuilder ReducedActionSpeedFromChill { get; }
}

internal class AilmentBuilderCollection
Expand Down
11 changes: 0 additions & 11 deletions PoESkillTree.Engine.Computation.Builders/Stats/MetaStatBuilders.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,21 +137,10 @@ public IStatBuilder AilmentCombinedEffectiveChance(Ailment ailment)
public IStatBuilder AilmentEffectiveInstances(Ailment ailment)
=> FromIdentity($"{ailment}.EffectiveInstances", typeof(double));

public IStatBuilder IncreasedDamageTakenFromShocks
=> FromIdentity("Shock.IncreasedDamageTaken", typeof(uint),
ExplicitRegistrationTypes.UserSpecifiedValue(15));

public IStatBuilder ReducedActionSpeedFromChill
=> FromIdentity("Chill.ReducedActionSpeed", typeof(uint),
ExplicitRegistrationTypes.UserSpecifiedValue(10));

public IDamageRelatedStatBuilder EffectiveCritChance
=> DamageRelatedFromIdentity("CriticalStrike.EffectiveChance", typeof(double)).WithHits;


public IStatBuilder ResistanceAgainstHits(DamageType damageType)
=> FromIdentity($"{damageType}.ResistanceAgainstHits", typeof(double));

public IStatBuilder MitigationAgainstHits(DamageType damageType)
=> FromIdentity($"{damageType}.MitigationAgainstHits", typeof(double));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ private enum RuthlessBlowBonusCalculation

public IStatBuilder CursesLinkedToBane => FromIdentity(typeof(uint));

public IStatBuilder SealGainFrequency => FromIdentity(typeof(double));

public IStatBuilder DamageTakenGainedAsMana => FromIdentity(typeof(uint));

public ValueBuilder UniqueAmount(string name, double defaultValue = 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public interface IActionBuilders
/// </summary>
IActionBuilder HitWith(IDamageTypeBuilder damageType);

IActionBuilder HitWith(AttackDamageHand hand);

/// <summary>
/// Gets an action that occurs when Self savagely hits any entity.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,8 @@ public interface IBlockActionBuilder : IActionBuilder
/// Gets a stat representing block chance against spells.
/// </summary>
IStatBuilder SpellChance { get; }

IActionBuilder Attack { get; }
IActionBuilder Spell { get; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ public interface IConditionBuilders
/// </summary>
IConditionBuilder With(ISkillBuilder skill);

/// <summary>
/// Returns a condition that is satisfied if the damage related stat or action is done as an attack with
/// the given hand with a skill (not ailments).
/// </summary>
IConditionBuilder AttackWithSkills(AttackDamageHand hand);

/// <summary>
/// Returns a condition that is satisfied if the damage related stat or action is done as an attack with
/// the given hand.
Expand All @@ -33,7 +39,12 @@ public interface IConditionBuilders

/// <summary>
/// Returns a condition that is satisfied if the damage related stat or action is done as the given source
/// with a skill.
/// with a skill (not ailments).
/// </summary>
IConditionBuilder WithSkills(DamageSource damageSource);

/// <summary>
/// Returns a condition that is satisfied if the damage related stat or action is done as the given source.
/// </summary>
IConditionBuilder With(DamageSource damageSource);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ public interface IDamageTypeBuilder : IKeywordBuilder
/// Gets a stat representing the resistances to the damage types in this collection.
/// </summary>
IStatBuilder Resistance { get; }
IStatBuilder ResistanceAgainstHits { get; }
IStatBuilder ResistanceAgainstDoTs { get; }

/// <summary>
/// Gets a damage stat representing the damage of the damage types in this collection.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ public interface IAilmentBuilders
/// </summary>
IAilmentBuilderCollection Elemental { get; }

IAilmentBuilderCollection All { get; }

IStatBuilder ShockEffect { get; }
IStatBuilder IncreasedDamageTakenFromShocks { get; }
IStatBuilder ChillEffect { get; }
IStatBuilder ReducedActionSpeedFromChill { get; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using PoESkillTree.Engine.Computation.Common.Builders.Damage;
using PoESkillTree.Engine.Computation.Common.Builders.Effects;
using PoESkillTree.Engine.Computation.Common.Builders.Values;
using PoESkillTree.Engine.GameModel.Items;
using PoESkillTree.Engine.GameModel.Skills;

namespace PoESkillTree.Engine.Computation.Common.Builders.Stats
Expand Down Expand Up @@ -70,12 +69,9 @@ public interface IMetaStatBuilders
IDamageRelatedStatBuilder AilmentEffectiveChance(Ailment ailment);
IStatBuilder AilmentCombinedEffectiveChance(Ailment ailment);
IStatBuilder AilmentEffectiveInstances(Ailment ailment);
IStatBuilder IncreasedDamageTakenFromShocks { get; }
IStatBuilder ReducedActionSpeedFromChill { get; }

IDamageRelatedStatBuilder EffectiveCritChance { get; }

IStatBuilder ResistanceAgainstHits(DamageType damageType);
IStatBuilder MitigationAgainstHits(DamageType damageType);
IStatBuilder MitigationAgainstDoTs(DamageType damageType);
IStatBuilder ChanceToAvoidMeleeAttacks { get; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ public interface IStatBuilders

IStatBuilder CursesLinkedToBane { get; }

IStatBuilder SealGainFrequency { get; }

/// <summary>
/// Returns the value of a stat with type uint that can only be specified by the user.
/// </summary>
Expand Down
Loading