implement selling cargo to controlling faction

This commit is contained in:
Florian Stinglmayr 2021-09-28 14:41:09 +02:00
parent 3b1fc79dba
commit 1d747756ac
4 changed files with 67 additions and 2 deletions

View File

@ -43,6 +43,26 @@ namespace NonaBGS.BGS {
"(Total value: {1} CR)\n", pages, sum); "(Total value: {1} CR)\n", pages, sum);
} }
private string BuildCargoSold(Objective objective) {
StringBuilder builder = new StringBuilder();
SellCargo[] sold = objective.LogEntries
.OfType<SellCargo>()
.ToArray()
;
if (sold == null && sold.Length > 0) {
return builder.ToString();
}
foreach (SellCargo sell in sold) {
builder.AppendFormat("{0}\n", sell.ToString());
}
builder.AppendFormat("\n");
return builder.ToString();
}
private string BuildMicroResourcesSold(Objective objective) { private string BuildMicroResourcesSold(Objective objective) {
var total = from entries in objective.LogEntries var total = from entries in objective.LogEntries
where entries.GetType() == typeof(SellMicroResources) where entries.GetType() == typeof(SellMicroResources)
@ -199,6 +219,9 @@ namespace NonaBGS.BGS {
var micro = BuildMicroResourcesSold(objective); var micro = BuildMicroResourcesSold(objective);
entries.Append(micro); entries.Append(micro);
var sold = BuildCargoSold(objective);
entries.Append(sold);
log.Append(entries.ToString().Trim()); log.Append(entries.ToString().Trim());
log.Append("\n```\n"); log.Append("\n```\n");
} }

View File

@ -35,7 +35,8 @@ namespace NonaBGS.BGS {
e.Is(Events.MultiSellExplorationData) || e.Is(Events.MultiSellExplorationData) ||
e.Is(Events.SellMicroResources) || e.Is(Events.SellMicroResources) ||
e.Is(Events.RedeemVoucher) || e.Is(Events.RedeemVoucher) ||
e.Is(Events.FactionKillBond) e.Is(Events.FactionKillBond) ||
e.Is(Events.MarketSell)
; ;
} }
@ -105,6 +106,14 @@ namespace NonaBGS.BGS {
collate = true; collate = true;
} else if (e.Is(Events.SellMicroResources)) { } else if (e.Is(Events.SellMicroResources)) {
entry = new SellMicroResources(current_system, current_station); entry = new SellMicroResources(current_system, current_station);
entry.Entries.Add(e);
} else if (e.Is(Events.MarketSell)) {
entry = new SellCargo() {
Faction = controlling_faction,
Station = current_station,
System = current_system
};
entry.Entries.Add(e); entry.Entries.Add(e);
} }

31
BGS/SellCargo.cs Normal file
View File

@ -0,0 +1,31 @@
using System.Text;
using System.Linq;
using EDJournal;
namespace NonaBGS.BGS {
public class SellCargo : LogEntry {
public override string ToString() {
StringBuilder builder = new StringBuilder();
var sold = Entries.OfType<MarketSellEntry>().ToArray();
if (sold == null || sold.Length == 0) {
return builder.ToString();
}
foreach (MarketSellEntry sell in sold) {
builder.AppendFormat("Sold {0} {1} to the {2}\n",
sell.Count,
sell.Type,
sell.BlackMarket ? "Black Market" : "Commodity Market"
);
}
return builder.ToString().Trim();
}
/// <summary>
/// Selling resources to a market only helps the controlling faction
/// </summary>
public override bool OnlyControllingFaction => true;
}
}

View File

@ -41,7 +41,8 @@
<Reference Include="AutoCompleteTextBox, Version=1.1.1.0, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="AutoCompleteTextBox, Version=1.1.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\AutoCompleteTextBox.1.1.1\lib\net472\AutoCompleteTextBox.dll</HintPath> <HintPath>packages\AutoCompleteTextBox.1.1.1\lib\net472\AutoCompleteTextBox.dll</HintPath>
</Reference> </Reference>
<Reference Include="EDJournal"> <Reference Include="EDJournal, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\edjournal\bin\Debug\EDJournal.dll</HintPath> <HintPath>..\edjournal\bin\Debug\EDJournal.dll</HintPath>
</Reference> </Reference>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> <Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
@ -75,6 +76,7 @@
</ApplicationDefinition> </ApplicationDefinition>
<Compile Include="BGS\DiscordLogGenerator.cs" /> <Compile Include="BGS\DiscordLogGenerator.cs" />
<Compile Include="BGS\NonaDiscordLog.cs" /> <Compile Include="BGS\NonaDiscordLog.cs" />
<Compile Include="BGS\SellCargo.cs" />
<Compile Include="BGS\SellMicroResources.cs" /> <Compile Include="BGS\SellMicroResources.cs" />
<Compile Include="BGS\FactionKillBonds.cs" /> <Compile Include="BGS\FactionKillBonds.cs" />
<Compile Include="EDDB\PopulatedSystems.cs" /> <Compile Include="EDDB\PopulatedSystems.cs" />