Skip to content

Commit

Permalink
converter
Browse files Browse the repository at this point in the history
  • Loading branch information
msarilar committed May 1, 2018
1 parent 61a8c0a commit 3fa0de4
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
1 change: 1 addition & 0 deletions EDEngineer.Models/MaterialTrading/MaterialTrader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ private static IEnumerable<MaterialTrade> AllTrades(Dictionary<Entry, int> missi
}

var willBeEnough = needed + deduced.GetOrDefault(otherGroup.Data) <= otherGroup.Count;

yield return new MaterialTrade(otherGroup, ingredient, needed, missingSize, willBeEnough, deduced.GetOrDefault(otherGroup.Data));
}
// ReSharper restore PossibleInvalidOperationException
Expand Down
47 changes: 47 additions & 0 deletions EDEngineer/Converters/EntryDataToMaterialTraderLocation.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using System;
using System.Globalization;
using System.Windows.Data;
using System.Windows.Media;
using EDEngineer.Localization;
using EDEngineer.Models;
using EDEngineer.Models.Loadout;

namespace EDEngineer.Converters
{
public class EntryDataToMaterialTraderLocation : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value == null)
{
return null;
}

var entryData = (EntryData) value;

switch (entryData.Subkind)
{
case Subkind.Manufactured:
return Languages.Instance.Translate(
"Materials Trader found at industrial economies, only trades in manufactured materials.");
case Subkind.Raw:
return Languages.Instance.Translate(
"Materials Trader found at extraction and refinery economies, only trades in raw material found on planet surfaces and planetary rings.");
default:
switch (entryData.Kind)
{
case Kind.Data:
return Languages.Instance.Translate(
"Materials Trader found at High Tech and Military economies, only trades in encoded materials.");
default:
return null;
}
}
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}

0 comments on commit 3fa0de4

Please sign in to comment.