Skip to content

Commit

Permalink
Merge pull request #3 from PoESkillTree/poe3.8
Browse files Browse the repository at this point in the history
Update for PoE 3.8.0
  • Loading branch information
brather1ng authored Sep 11, 2019
2 parents b292098 + 9762c8a commit dbae6fc
Show file tree
Hide file tree
Showing 69 changed files with 1,683 additions and 976 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ public void AuraBuildsToCorrectResults()
[Test]
public void BuffsWithoutParametersCountBuildsToCorrectValue()
{
// Buff properties + conflux + dummy buff and aura + passed buff skills
var expected = 14 + 4 + 2 + 3;
// Buff properties + conflux + dummy buffs + passed buff skills
var expected = 14 + 4 + 3 + 3;
// For every source entity
expected *= Enums.GetMemberCount<Entity>();
var context = Mock.Of<IValueCalculationContext>(c =>
Expand All @@ -130,8 +130,8 @@ public void BuffsWithoutParametersCountBuildsToCorrectValue()
[Test]
public void BuffsWithParamtersCountBuildsToCorrectValue()
{
// Buff properties + conflux + dummy buff and aura + passed buff skills
var expected = 14 + 4 + 2 + 3;
// Buff properties + conflux + dummy buffs + passed buff skills
var expected = 14 + 4 + 3 + 3;
var source = new ModifierSourceEntityBuilder();
var target = new ModifierSourceEntityBuilder();
var context = Mock.Of<IValueCalculationContext>(c =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public BuffBuilders(IStatFactory statFactory, SkillDefinitions skills)
Impale = Create("Impale");
Infusion = Create("Infusion");
Conflux = new ConfluxBuffBuilders(statFactory);
GenericMine = Create("Mine");
CurseLimit = StatBuilderUtils.FromIdentity(statFactory, "CurseLimit", typeof(uint));

var allBuffs = new List<BuffBuilderWithKeywords>
Expand All @@ -65,6 +66,7 @@ public BuffBuilders(IStatFactory statFactory, SkillDefinitions skills)
new BuffBuilderWithKeywords(Create("Buff")),
// Aura effect increase (used for Aura())
new BuffBuilderWithKeywords(Create("Aura"), Keyword.Aura),
new BuffBuilderWithKeywords(GenericMine, Keyword.Aura, Keyword.Mine),
};
var skillBuffBuilders = skills.Skills
.Where(s => !s.IsSupport && s.ActiveSkill.ProvidesBuff)
Expand All @@ -90,6 +92,7 @@ private BuffBuilder Create(string buffIdentity) =>
public IBuffBuilder Innervation { get; }
public IBuffBuilder Impale { get; }
public IBuffBuilder Infusion { get; }
public IBuffBuilder GenericMine { get; }
public IConfluxBuffBuilders Conflux { get; }

public IStatBuilder Temporary(IStatBuilder gainedStat)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,14 @@ public IDamageTypeBuilder Except(IDamageTypeBuilder type) =>
new DamageStatBuilder(_statFactory, CoreStat(_statFactory.Damage));

public IDamageRelatedStatBuilder DamageMultiplier =>
DamageRelatedStatBuilder.Create(_statFactory, new CompositeCoreStatBuilder(
CoreStat(typeof(int), nameof(DamageMultiplierWithCrits)),
CoreStat(typeof(int), nameof(DamageMultiplierWithNonCrits))));

public IDamageRelatedStatBuilder DamageMultiplierWithCrits =>
DamageRelatedStatBuilder.Create(_statFactory, CoreStat(typeof(int)));

public IDamageRelatedStatBuilder DamageMultiplierWithNonCrits =>
DamageRelatedStatBuilder.Create(_statFactory, CoreStat(typeof(int)));

public IDamageTakenConversionBuilder DamageTakenFrom(IPoolStatBuilder pool)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class EntityBuilders : IEntityBuilders
public IEntityBuilder OpponentOfSelf => new ModifierSourceOpponentEntityBuilder();
public IEnemyBuilder Enemy => new EnemyBuilder(_statFactory);
public IEntityBuilder Character => new EntityBuilder(Entity.Character);
public IEntityBuilder Ally => new EntityBuilder(Entity.Minion, Entity.Totem);
public ICountableEntityBuilder Ally => new AllyBuilder(_statFactory);
public IEntityBuilder Totem => new EntityBuilder(Entity.Totem);
public IEntityBuilder Minion => new EntityBuilder(Entity.Minion);
public IEntityBuilder Any => EntityBuilder.AllEntities;
Expand All @@ -39,6 +39,10 @@ public ValueBuilder CountNearby
=> StatBuilderUtils.FromIdentity(_statFactory, "Enemy.CountNearby", typeof(uint),
ExplicitRegistrationTypes.UserSpecifiedValue(0)).Value;

public ValueBuilder CountRareOrUniqueNearby
=> StatBuilderUtils.FromIdentity(_statFactory, "Enemy.CountRareOrUniqueNearby", typeof(uint),
ExplicitRegistrationTypes.UserSpecifiedValue(0)).Value;

public IConditionBuilder IsRare => StatBuilderUtils.ConditionFromIdentity(_statFactory, "Enemy.IsRare",
ExplicitRegistrationTypes.UserSpecifiedValue(false));

Expand All @@ -50,5 +54,17 @@ public ValueBuilder CountNearby
public IConditionBuilder IsMoving => StatBuilderUtils.ConditionFromIdentity(_statFactory, "Enemy.IsMoving",
ExplicitRegistrationTypes.UserSpecifiedValue(false));
}

private class AllyBuilder : EntityBuilder, ICountableEntityBuilder
{
private readonly IStatFactory _statFactory;

public AllyBuilder(IStatFactory statFactory) : base(Entity.Minion, Entity.Totem) =>
_statFactory = statFactory;

public ValueBuilder CountNearby
=> StatBuilderUtils.FromIdentity(_statFactory, "Ally.CountNearby", typeof(uint),
ExplicitRegistrationTypes.UserSpecifiedValue(0)).Value;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public SkillBuilders(IStatFactory statFactory, SkillDefinitions skills)
private ISkillBuilderCollection CreateCollection(params IKeywordBuilder[] keywords)
=> new SkillBuilderCollection(_statFactory, keywords, _skills.Skills);

public ISkillBuilder SummonSkeleton => FromId("SummonSkeletons");
public ISkillBuilder SummonSkeletons => FromId("SummonSkeletons");
public ISkillBuilder VaalSummonSkeletons => FromId("VaalSummonSkeletons");
public ISkillBuilder RaiseSpectre => FromId("RaiseSpectre");
public ISkillBuilder RaiseZombie => FromId("RaiseZombie");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ public IDamageRelatedStatBuilder Range
public ValueBuilder UniqueAmount(string name)
=> FromIdentity(name, typeof(uint), UserSpecifiedValue(0)).Value;

public ValueBuilder UniqueEnum<T>(string name) where T : Enum
=> FromIdentity(name, typeof(T), UserSpecifiedValue(0)).Value;

public IStatBuilder IndependentMultiplier(string identity)
=> FromIdentity(identity, typeof(uint), IndependentResult(NodeType.Increase));

Expand Down Expand Up @@ -121,7 +124,7 @@ public MineStatBuilders(IStatFactory statFactory) : base(statFactory, "Mine")
{
}

public IStatBuilder Speed => FromIdentity("LayingSpeed", typeof(double));
public IStatBuilder Speed => FromIdentity("ThrowingSpeed", typeof(double));
public IStatBuilder Duration => FromIdentity(typeof(double));
public IStatBuilder DetonationAoE => FromIdentity(typeof(int));
}
Expand Down Expand Up @@ -250,6 +253,10 @@ public IStatBuilder IncreasesToSourceApplyToTarget(IStatBuilder source, IStatBui
=> new StatBuilder(StatFactory,
new ModifiersApplyToOtherStatCoreStatBuilder(source, target, Form.Increase, StatFactory));

public IStatBuilder BaseAddsToSourceApplyToTarget(IStatBuilder source, IStatBuilder target)
=> new StatBuilder(StatFactory,
new ModifiersApplyToOtherStatCoreStatBuilder(source, target, Form.BaseAdd, StatFactory));

private class ModifiersApplyToOtherStatCoreStatBuilder : ICoreStatBuilder
{
private readonly IStatBuilder _target;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ public interface IBuffBuilders
IBuffBuilder Impale { get; }
IBuffBuilder Infusion { get; }

IBuffBuilder GenericMine { get; }

/// <summary>
/// Gets a buff factory that creates Conflux buffs.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ public enum ChargeType
Intensity,
Challenger,
Blitz,
Inspiration,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ public interface IDamageTypeBuilder : IKeywordBuilder
/// Gets a stat representing the multiplier to damage of this type.
/// </summary>
IDamageRelatedStatBuilder DamageMultiplier { get; }
IDamageRelatedStatBuilder DamageMultiplierWithCrits { get; }
IDamageRelatedStatBuilder DamageMultiplierWithNonCrits { get; }

/// <summary>
/// Starts constructing a stat representing the percentage of damage of this stat's damage types that is taken
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using PoESkillTree.Engine.Computation.Common.Builders.Values;

namespace PoESkillTree.Engine.Computation.Common.Builders.Entities
{
public interface ICountableEntityBuilder : IEntityBuilder
{

ValueBuilder CountNearby { get; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ namespace PoESkillTree.Engine.Computation.Common.Builders.Entities
/// <summary>
/// Represents enemy entities.
/// </summary>
public interface IEnemyBuilder : IEntityBuilder
public interface IEnemyBuilder : ICountableEntityBuilder
{
/// <summary>
/// Gets a condition that is satisfied if this enemy is near Self.
/// </summary>
IConditionBuilder IsNearby { get; }

ValueBuilder CountNearby { get; }
ValueBuilder CountRareOrUniqueNearby { get; }

/// <summary>
/// Gets a condition that is satisfied if this enemy is Rare.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public interface IEntityBuilders
/// <summary>
/// Gets an entity representing the character's allies.
/// </summary>
IEntityBuilder Ally { get; }
ICountableEntityBuilder Ally { get; }

/// <summary>
/// Gets an entity representing the character's totems.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Collections.Generic;
using System.Linq;
using PoESkillTree.Engine.Computation.Common.Builders.Conditions;
using PoESkillTree.Engine.GameModel.Items;
Expand All @@ -18,6 +19,9 @@ public interface IEquipmentBuilderCollection : IBuilderCollection<IEquipmentBuil
public static class EquipmentBuilderCollectionExtensions
{
public static IConditionBuilder IsAnyFlaskActive(this IEquipmentBuilderCollection @this)
=> ItemSlotExtensions.Flasks.Select(s => @this[s].HasItem).Aggregate((l, r) => l.Or(r));
=> @this.Flasks().Select(s => s.HasItem).Aggregate((l, r) => l.Or(r));

public static IEnumerable<IEquipmentBuilder> Flasks(this IEquipmentBuilderCollection @this)
=> ItemSlotExtensions.Flasks.Select(s => @this[s]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public interface ISkillBuilders

// Single skills that need to be individually referenced

ISkillBuilder SummonSkeleton { get; }
ISkillBuilder SummonSkeletons { get; }
ISkillBuilder VaalSummonSkeletons { get; }
ISkillBuilder RaiseSpectre { get; }
ISkillBuilder RaiseZombie { get; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public interface IFlagStatBuilders
IStatBuilder FarShot { get; }

IStatBuilder IncreasesToSourceApplyToTarget(IStatBuilder source, IStatBuilder target);
IStatBuilder BaseAddsToSourceApplyToTarget(IStatBuilder source, IStatBuilder target);

IConditionBuilder AlwaysMoving { get; }
IConditionBuilder AlwaysStationary { get; }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using PoESkillTree.Engine.Computation.Common.Builders.Damage;
using PoESkillTree.Engine.Computation.Common.Builders.Skills;
using PoESkillTree.Engine.Computation.Common.Builders.Values;
Expand Down Expand Up @@ -145,6 +146,8 @@ public interface IStatBuilders
/// </summary>
ValueBuilder UniqueAmount(string name);

ValueBuilder UniqueEnum<T>(string name) where T : Enum;

IStatBuilder IndependentMultiplier(string identity);
IStatBuilder IndependentTotal(string identity);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public IConditionBuilder Eq(IValueBuilder other) =>
public IConditionBuilder Eq(double other) =>
_value.Eq(Create(other));

public static IConditionBuilder operator >(ValueBuilder left, ValueBuilder right) =>
public static IConditionBuilder operator >(ValueBuilder left, IValueBuilder right) =>
left._value.GreaterThan(right);

public static IConditionBuilder operator >=(ValueBuilder left, ValueBuilder right) =>
Expand All @@ -49,8 +49,8 @@ public IConditionBuilder Eq(double other) =>
public static IConditionBuilder operator <=(ValueBuilder left, ValueBuilder right) =>
right >= left;

public static IConditionBuilder operator <(ValueBuilder left, ValueBuilder right) =>
right > left;
public static IConditionBuilder operator <(ValueBuilder left, IValueBuilder right) =>
Wrap(right) > left;

public static IConditionBuilder operator >(ValueBuilder left, double right) =>
left > left.Create(right);
Expand Down Expand Up @@ -80,7 +80,7 @@ IConditionBuilder IValueBuilder.GreaterThan(IValueBuilder other) =>
_value.GreaterThan(other);


public static ValueBuilder operator *(ValueBuilder left, ValueBuilder right) =>
public static ValueBuilder operator *(ValueBuilder left, IValueBuilder right) =>
Wrap(left._value.Multiply(right));

public static ValueBuilder operator *(ValueBuilder left, double right) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public static ValueBuilder Floor(this ValueBuilder value)
public static ValueBuilder Ceiling(this ValueBuilder value)
=> value.Select(Math.Ceiling, o => "Ceiling(" + o + ")");

public static ValueBuilder Minimum(this IValueBuilders valueFactory, ValueBuilder left, ValueBuilder right)
public static ValueBuilder Minimum(this IValueBuilders valueFactory, ValueBuilder left, IValueBuilder right)
=> valueFactory.If(left > right).Then(right).Else(left);

public static ValueBuilder Minimum(this IValueBuilders valueFactory, ValueBuilder left, double right)
Expand Down
4 changes: 2 additions & 2 deletions PoESkillTree.Engine.Computation.Console/UniquesUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ internal class UniquesUpdater

private static readonly IReadOnlyList<string> RelevantWikiClasses = new[]
{
"One Hand Axes", "Two Hand Axes", "Bows", "Claws", "Daggers",
"One Hand Maces", "Sceptres", "Two Hand Maces", "Staves",
"One Hand Axes", "Two Hand Axes", "Bows", "Claws", "Daggers", "Rune Dagger",
"One Hand Maces", "Sceptres", "Two Hand Maces", "Staves", "Warstaff",
"One Hand Swords", "Thrusting One Hand Swords", "Two Hand Swords", "Wands",
"Amulets", "Belts", "Quivers", "Rings",
"Body Armours", "Boots", "Helmets", "Gloves", "Shields",
Expand Down
12 changes: 9 additions & 3 deletions PoESkillTree.Engine.Computation.Data/ActionConditionMatchers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,13 @@ protected override IReadOnlyList<MatcherData> CreateCollection() =>
"(when you|on) ({ActionMatchers}) a ({AilmentMatchers}) enemy",
And(References[1].AsAilment.IsOn(Enemy), References[0].AsAction.On)
},
{
"(when you|on) ({ActionMatchers}) a cursed enemy",
And(Buffs(targets: Enemy).With(Keyword.Curse).Any(), References[0].AsAction.On)
},
// kill
{ "if you or your totems kill an enemy", Or(Kill.On, Kill.By(Entity.Totem).On) },
{ "affecting enemies you kill", Kill.On },
// hit
{ "when hit", Hit.By(Enemy).On },
{ "when you are hit", Hit.By(Enemy).On },
Expand Down Expand Up @@ -89,6 +94,7 @@ protected override IReadOnlyList<MatcherData> CreateCollection() =>
{ "when you stun", Effect.Stun.InflictionAction.On },
// other
{ "after spending( a total of)? # mana", Action.SpendMana(Value).On },
{ "when you spend mana", Action.SpendMana(ValueFactory.Create(1)).On },
{ "when you focus", Action.Focus.On },
{ "when you gain a ({ChargeTypeMatchers})", Reference.AsChargeType.GainAction.On },
{ "you gain", Condition.True }, // may be left over at the end, does nothing
Expand All @@ -99,11 +105,11 @@ protected override IReadOnlyList<MatcherData> CreateCollection() =>
// unique
{
"when your trap is triggered by an enemy",
Action.Unique("When your Trap is triggered by an Enemy").On
Action.Unique("When a Trap is triggered by an Enemy").On
},
{
"when your mine is detonated targeting an enemy",
Action.Unique("When your Mine is detonated targeting an Enemy").On
"when (your|a) mine is detonated targeting an enemy",
Action.Unique("When a Mine is detonated targeting an Enemy").On
},
{ "on use", Action.Unique("When you use the Flask").On },
{ "when you use a flask", Action.Unique("When you use any Flask").On },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ protected UsesConditionBuilders(IBuilderFactories builderFactories)
protected IConditionBuilder With(ISkillBuilder skill) => Condition.With(skill);

protected IConditionBuilder WithSkeletonSkills
=> Or(With(Skills.SummonSkeleton), With(Skills.VaalSummonSkeletons));
=> Or(With(Skills.SummonSkeletons), With(Skills.VaalSummonSkeletons));

protected IConditionBuilder MainHandAttackWith(Tags tags) =>
MainHandAttack.And(MainHand.Has(tags));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ protected IBuffBuilderCollection Buffs(IEntityBuilder source = null, params IEnt

protected IEntityBuilder Self => Entity.Self;
protected IEnemyBuilder Enemy => Entity.Enemy;
protected IEntityBuilder Ally => Entity.Ally;
protected ICountableEntityBuilder Ally => Entity.Ally;

// Equipment

Expand Down
1 change: 1 addition & 0 deletions PoESkillTree.Engine.Computation.Data/ChargeTypeMatchers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ protected override IReadOnlyList<ReferencedMatcherData> CreateCollection() =>
{ "intensity", Charge.From(ChargeType.Intensity) },
{ "challenger charges?", Charge.From(ChargeType.Challenger) },
{ "blitz charges?", Charge.From(ChargeType.Blitz) },
{ "inspiration charges?", Charge.From(ChargeType.Inspiration) },
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ public ValueConversionMatcherCollection(IModifierBuilder modifierBuilder) : base
{
}

public void Add([RegexPattern] string regex, Func<ValueBuilder, ValueBuilder> func)
public void Add([RegexPattern] string regex, Func<ValueBuilder, ValueBuilder> func, string substitution = "")
{
Add(regex, ModifierBuilder.WithValueConverter(func.ToValueConverter()));
Add(regex, ModifierBuilder.WithValueConverter(func.ToValueConverter()), substitution);
}

public void Add([RegexPattern] string regex, ValueBuilder multiplier)
Expand Down
Loading

0 comments on commit dbae6fc

Please sign in to comment.