Skip to content

Commit

Permalink
handle engineer contribution
Browse files Browse the repository at this point in the history
  • Loading branch information
msarilar committed Jun 27, 2017
1 parent aac5dbb commit c70ff46
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 26 deletions.
2 changes: 1 addition & 1 deletion EDEngineer.Models/EDEngineer.Models.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
<Compile Include="Operations\DataOperation.cs" />
<Compile Include="Operations\DeathOperation.cs" />
<Compile Include="Operations\EngineerOperation.cs" />
<Compile Include="Operations\EngineerProgressOperation.cs" />
<Compile Include="Operations\EngineerContributionOperation.cs" />
<Compile Include="Operations\JournalOperation.cs" />
<Compile Include="Operations\ManualChangeOperation.cs" />
<Compile Include="Operations\MaterialOperation.cs" />
Expand Down
2 changes: 1 addition & 1 deletion EDEngineer.Models/JournalEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public enum JournalEvent
CollectCargo,
EjectCargo,
Synthesis,
EngineerProgress,
EngineerContribution,
ScientificResearch,
LoadGame,
Died,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@

namespace EDEngineer.Models.Operations
{
public class EngineerProgressOperation : JournalOperation
public class EngineerContributionOperation : JournalOperation
{
public string Engineer { get; }
public JournalOperation Operation { get; }

public EngineerProgressOperation(string engineer)
{
public string Engineer { get; }
public JournalOperation Operation { get; }

public EngineerContributionOperation(string engineer)
{
Engineer = engineer;
JournalOperation operation;
engineersProgressOperation.TryGetValue(Engineer, out operation);
Operation = operation;
}

public override void Mutate(State state)
{
{
Operation?.Mutate(state);
}

Expand All @@ -32,16 +32,16 @@ public override void Mutate(State state)
["Hera Tani"] = new NoOperation(),
["Juri Ishmaak"] = new NoOperation(),
["Selene Jean"] = new NoOperation(),
["Marco Qwent"] = new CargoOperation() { CommodityName = "Modular Terminals", Size = -25, JournalEvent = JournalEvent.EngineerProgress },
["Ram Tah"] = new DataOperation() { DataName = "Classified Scan Databanks", Size = -50, JournalEvent = JournalEvent.EngineerProgress },
["Marco Qwent"] = new CargoOperation() { CommodityName = "Modular Terminals", Size = -25, JournalEvent = JournalEvent.EngineerContribution },
["Ram Tah"] = new DataOperation() { DataName = "Classified Scan Databanks", Size = -50, JournalEvent = JournalEvent.EngineerContribution },
["Broo Tarquin"] = new NoOperation(),
["Colonel Bris Dekker"] = new NoOperation(),
["Didi Vatermann"] = new NoOperation(),
["Professor Palin"] = new MaterialOperation() { MaterialName = "Unknown Fragment" , Size = -25, JournalEvent = JournalEvent.EngineerProgress },
["Professor Palin"] = new MaterialOperation() { MaterialName = "Unknown Fragment" , Size = -25, JournalEvent = JournalEvent.EngineerContribution },
["Lori Jameson"] = new NoOperation(),
["Tiana Fortune"] = new DataOperation() { DataName = "Decoded Emission Data", Size = -50, JournalEvent = JournalEvent.EngineerProgress },
["The Sarge"] = new DataOperation() { DataName = "Aberrant Shield Pattern Analysis", Size = -50, JournalEvent = JournalEvent.EngineerProgress },
["Bill Turner"] = new CargoOperation() { CommodityName = "Bromellite", Size = -50, JournalEvent = JournalEvent.EngineerProgress }
};
["Tiana Fortune"] = new DataOperation() { DataName = "Decoded Emission Data", Size = -50, JournalEvent = JournalEvent.EngineerContribution },
["The Sarge"] = new DataOperation() { DataName = "Aberrant Shield Pattern Analysis", Size = -50, JournalEvent = JournalEvent.EngineerContribution },
["Bill Turner"] = new CargoOperation() { CommodityName = "Bromellite", Size = -50, JournalEvent = JournalEvent.EngineerContribution }
};
}
}
1 change: 0 additions & 1 deletion EDEngineer/Resources/Data/entryData.json
Original file line number Diff line number Diff line change
Expand Up @@ -1035,7 +1035,6 @@
"Kind": "Commodity",
"OriginDetails": [ "Markets (Kongga, Laplace Ring)", "Needed for Lori Jameson (25)" ]
},

{
"Name": "Unknown Material Composition Data",
"Rarity": "Standard",
Expand Down
39 changes: 30 additions & 9 deletions EDEngineer/Utils/JournalEntryConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ private JournalOperation ExtractOperation(JObject data, JournalEvent journalEven
return ExtractEjectCargo(data);
case JournalEvent.Synthesis:
return ExtractSynthesis(data);
case JournalEvent.EngineerProgress:
return ExtractEngineerProgress(data);
case JournalEvent.EngineerContribution:
return ExtractEngineerContribution(data);
case JournalEvent.ScientificResearch:
return ExtractMaterialDiscarded(data);
case JournalEvent.Died:
Expand Down Expand Up @@ -212,17 +212,38 @@ private JournalOperation ExtractCargoDump(JObject data)
return dump;
}

private JournalOperation ExtractEngineerProgress(JObject data)
private JournalOperation ExtractEngineerContribution(JObject data)
{
var engineer = (string) data["Engineer"];
var progressInfo = (string) data["Progress"];

if (progressInfo == "Unlocked")
string name;
if (!converter.TryGet((string)data["Commodity"], out name) &&
!converter.TryGet((string)data["Encoded"], out name) &&
!converter.TryGet((string)data["Raw"], out name) &&
!converter.TryGet((string)data["Manufactured"], out name) &&
!converter.TryGet((string)data["Data"], out name) &&
!converter.TryGet((string)data["Commodity"], out name) &&
!converter.TryGet((string)data["Name"], out name))
{
return new EngineerProgressOperation(engineer);
return null;
}

return null;
var type = ((string) data["Type"]).ToLowerInvariant();
switch (type)
{
case "encoded":
return new DataOperation()
{
DataName = name,
Size = -1 * data["Quantity"]?.ToObject<int>() ?? 1
};
case "commodity":
return null; // ignore commodity
default:
return new MaterialOperation
{
MaterialName = name,
Size = -1 * data["Quantity"]?.ToObject<int>() ?? 1
};
}
}

private JournalOperation ExtractMarketSell(JObject data)
Expand Down

0 comments on commit c70ff46

Please sign in to comment.