Skip to content

Commit

Permalink
small refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
ontrigger committed Aug 23, 2020
1 parent 719d025 commit 96351ff
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 33 deletions.
5 changes: 2 additions & 3 deletions ItemStats/ItemStats.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,17 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs"/>
<Compile Include="src\Api\ProvidesItemStats.cs"/>
<Compile Include="src\ContextProvider.cs"/>
<Compile Include="src\ItemStatDef.cs"/>
<Compile Include="src\ItemStatDefinitions.cs"/>
<Compile Include="src\ItemStatProvider.cs"/>
<Compile Include="src\ItemStatsMod.cs"/>
<Compile Include="src\Modifiers.cs"/>
<Compile Include="src\StatCalculation\DefaultStatCalculationStrategy.cs"/>
<Compile Include="src\StatCalculation\IStatCalculationStrategy.cs"/>
<Compile Include="src\StatContext.cs"/>
<Compile Include="src\Stat\IStat.cs"/>
<Compile Include="src\Stat\ItemStat.cs"/>
<Compile Include="src\Stat\ItemStatDef.cs"/>
<Compile Include="src\Stat\StatContext.cs"/>
<Compile Include="src\ValueFormatters\Colors.cs"/>
<Compile Include="src\ValueFormatters\Extensions.cs"/>
<Compile Include="src\ValueFormatters\IStatFormatter.cs"/>
Expand Down
11 changes: 0 additions & 11 deletions ItemStats/src/Api/ProvidesItemStats.cs

This file was deleted.

17 changes: 0 additions & 17 deletions ItemStats/src/ItemStatDef.cs

This file was deleted.

1 change: 1 addition & 0 deletions ItemStats/src/ItemStatsMod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace ItemStats
{
[BepInDependency("com.bepis.r2api")]
[BepInPlugin("dev.ontrigger.itemstats", "ItemStats", "1.5.0")]
[NetworkCompatibility(CompatibilityLevel.NoNeedForSync, VersionStrictness.DifferentModVersionsAreOk)]
public class ItemStatsMod : BaseUnityPlugin
{
private readonly Dictionary<ItemInventoryDisplay, CharacterMaster> _displayToMasterRef =
Expand Down
21 changes: 21 additions & 0 deletions ItemStats/src/Stat/ItemStatDef.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System.Collections.Generic;
using ItemStats.Stat;
using ItemStats.StatCalculation;

namespace ItemStats
{
public class ItemStatDef
{
public IStatCalculationStrategy StatCalculationStrategy = new DefaultStatCalculationStrategy();

public List<ItemStat> Stats;

// additional text that only appears on stat tooltip and not the logbook
public string AdditionalText;

public string ProcessItem(int count, StatContext context)
{
return StatCalculationStrategy.ProcessItem(Stats, count, context, AdditionalText);
}
}
}
File renamed without changes.
10 changes: 9 additions & 1 deletion ItemStats/src/StatCalculation/DefaultStatCalculationStrategy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,24 @@
using System.Collections.Generic;
using System.Text;
using ItemStats.Stat;
using JetBrains.Annotations;

namespace ItemStats.StatCalculation
{
public class DefaultStatCalculationStrategy : IStatCalculationStrategy
{
public string ProcessItem(List<ItemStat> stats, int count, StatContext context)
public string ProcessItem(List<ItemStat> stats, int count, StatContext context,
[CanBeNull] string additionalText)
{
var fullStatText = new StringBuilder();
fullStatText.Append("\n\n");

if (additionalText != null)
{
fullStatText.Append(additionalText);
fullStatText.Append("\n\n");
}

foreach (var stat in stats)
{
var m = stat.GetInitialStat(count, context);
Expand Down
2 changes: 1 addition & 1 deletion ItemStats/src/StatCalculation/IStatCalculationStrategy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ namespace ItemStats.StatCalculation
{
public interface IStatCalculationStrategy
{
string ProcessItem(List<ItemStat> stats, int count, StatContext context);
string ProcessItem(List<ItemStat> stats, int count, StatContext context, string additionalText);
}
}

0 comments on commit 96351ff

Please sign in to comment.