add search and rescue
This commit is contained in:
parent
bd50962794
commit
5f9634cd83
@ -9,8 +9,10 @@ using EliteBGS.BGS.LogGenerator;
|
|||||||
namespace EliteBGS.BGS {
|
namespace EliteBGS.BGS {
|
||||||
public class GenericDiscordLog : IDiscordLogGenerator {
|
public class GenericDiscordLog : IDiscordLogGenerator {
|
||||||
private List<LogFormatter> formatters = new List<LogFormatter>() {
|
private List<LogFormatter> formatters = new List<LogFormatter>() {
|
||||||
new VistaGenomics(),
|
new VistaGenomicsFormat(),
|
||||||
|
new SearchAndRescueFormat(),
|
||||||
};
|
};
|
||||||
|
|
||||||
private string FormatDate() {
|
private string FormatDate() {
|
||||||
DateTime today = DateTime.Now;
|
DateTime today = DateTime.Now;
|
||||||
return today.ToString("dd/MM/yyyy");
|
return today.ToString("dd/MM/yyyy");
|
||||||
|
27
BGS/LogGenerator/GenericFormat.cs
Normal file
27
BGS/LogGenerator/GenericFormat.cs
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace EliteBGS.BGS.LogGenerator {
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a generic log block, that is simply all LogEntries of type "Type"
|
||||||
|
/// per line
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="Type">LogEntry subtype to work on</typeparam>
|
||||||
|
public class GenericFormat<Type> : LogFormatter {
|
||||||
|
public string GenerateLog(Objective objective) {
|
||||||
|
IEnumerable<Type> logs = objective.LogEntries.OfType<Type>();
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
|
||||||
|
if (logs == null || logs.Count() <= 0) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (Type log in logs) {
|
||||||
|
builder.AppendLine(log.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
return builder.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
4
BGS/LogGenerator/SearchAndRescueFormat.cs
Normal file
4
BGS/LogGenerator/SearchAndRescueFormat.cs
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
namespace EliteBGS.BGS.LogGenerator {
|
||||||
|
public class SearchAndRescueFormat : GenericFormat<SearchAndRescue> {
|
||||||
|
}
|
||||||
|
}
|
@ -1,22 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace EliteBGS.BGS.LogGenerator {
|
|
||||||
class VistaGenomics : LogFormatter {
|
|
||||||
public string GenerateLog(Objective objective) {
|
|
||||||
IEnumerable<OrganicData> logs = objective.LogEntries.OfType<OrganicData>();
|
|
||||||
StringBuilder builder = new StringBuilder();
|
|
||||||
|
|
||||||
if (logs == null || logs.Count() < 0) {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach(OrganicData log in logs) {
|
|
||||||
builder.AppendLine(log.ToString());
|
|
||||||
}
|
|
||||||
|
|
||||||
return builder.ToString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
4
BGS/LogGenerator/VistaGenomicsFormat.cs
Normal file
4
BGS/LogGenerator/VistaGenomicsFormat.cs
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
namespace EliteBGS.BGS.LogGenerator {
|
||||||
|
class VistaGenomicsFormat : GenericFormat<VistaGenomicsFormat> {
|
||||||
|
}
|
||||||
|
}
|
@ -9,7 +9,8 @@ using EliteBGS.BGS.LogGenerator;
|
|||||||
namespace EliteBGS.BGS {
|
namespace EliteBGS.BGS {
|
||||||
public class NonaDiscordLog : IDiscordLogGenerator {
|
public class NonaDiscordLog : IDiscordLogGenerator {
|
||||||
private List<LogFormatter> formatters = new List<LogFormatter>() {
|
private List<LogFormatter> formatters = new List<LogFormatter>() {
|
||||||
new VistaGenomics(),
|
new VistaGenomicsFormat(),
|
||||||
|
new SearchAndRescueFormat(),
|
||||||
};
|
};
|
||||||
|
|
||||||
private string FormatDate() {
|
private string FormatDate() {
|
||||||
@ -346,7 +347,10 @@ namespace EliteBGS.BGS {
|
|||||||
entries.Append(sold);
|
entries.Append(sold);
|
||||||
|
|
||||||
foreach (LogFormatter formatter in formatters) {
|
foreach (LogFormatter formatter in formatters) {
|
||||||
entries.AppendFormat("{0}\n", formatter.GenerateLog(objective));
|
string text = formatter.GenerateLog(objective);
|
||||||
|
if (!string.IsNullOrEmpty(text)) {
|
||||||
|
entries.AppendFormat("{0}\n", text);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Append(entries.ToString().Trim());
|
log.Append(entries.ToString().Trim());
|
||||||
|
@ -36,6 +36,7 @@ namespace EliteBGS.BGS {
|
|||||||
e.Is(Events.FSDJump) ||
|
e.Is(Events.FSDJump) ||
|
||||||
e.Is(Events.Location) ||
|
e.Is(Events.Location) ||
|
||||||
e.Is(Events.MultiSellExplorationData) ||
|
e.Is(Events.MultiSellExplorationData) ||
|
||||||
|
e.Is(Events.SearchAndRescue) ||
|
||||||
e.Is(Events.SellExplorationData) ||
|
e.Is(Events.SellExplorationData) ||
|
||||||
e.Is(Events.SellMicroResources) ||
|
e.Is(Events.SellMicroResources) ||
|
||||||
e.Is(Events.SellOrganicData) ||
|
e.Is(Events.SellOrganicData) ||
|
||||||
@ -246,6 +247,14 @@ namespace EliteBGS.BGS {
|
|||||||
System = current_system,
|
System = current_system,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
collate = true;
|
||||||
|
} else if (e.Is(Events.SearchAndRescue)) {
|
||||||
|
results.Add(new SearchAndRescue(e as SearchAndRescueEntry) {
|
||||||
|
Faction = controlling_faction,
|
||||||
|
Station = current_station,
|
||||||
|
System = current_system,
|
||||||
|
});
|
||||||
|
|
||||||
collate = true;
|
collate = true;
|
||||||
} else if (e.Is(Events.MarketSell)) {
|
} else if (e.Is(Events.MarketSell)) {
|
||||||
MarketSellEntry sell = e as MarketSellEntry;
|
MarketSellEntry sell = e as MarketSellEntry;
|
||||||
|
49
BGS/SearchAndRescue.cs
Normal file
49
BGS/SearchAndRescue.cs
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using EDJournal;
|
||||||
|
|
||||||
|
namespace EliteBGS.BGS {
|
||||||
|
public class SearchAndRescue : LogEntry {
|
||||||
|
public SearchAndRescue (SearchAndRescueEntry e) {
|
||||||
|
Entries.Add(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
public long Count {
|
||||||
|
get {
|
||||||
|
return Entries.OfType<SearchAndRescueEntry>().Sum(x => x.Count);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string NameLocalised {
|
||||||
|
get {
|
||||||
|
return Entries.OfType<SearchAndRescueEntry>().First().NameLocalised;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override int CompareTo(LogEntry o) {
|
||||||
|
if (o == null || o.GetType() != typeof(SearchAndRescue)) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
SearchAndRescue other = o as SearchAndRescue;
|
||||||
|
|
||||||
|
if (other.System == System &&
|
||||||
|
other.Station == Station &&
|
||||||
|
other.Faction == Faction &&
|
||||||
|
other.NameLocalised == NameLocalised) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string ToString() {
|
||||||
|
return string.Format("Contributed {0} {1} to Search and Rescue", Count, NameLocalised);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool OnlyControllingFaction => true;
|
||||||
|
}
|
||||||
|
}
|
@ -85,12 +85,15 @@
|
|||||||
<Compile Include="BGS\FoulMurder.cs" />
|
<Compile Include="BGS\FoulMurder.cs" />
|
||||||
<Compile Include="BGS\GenericDiscordLog.cs" />
|
<Compile Include="BGS\GenericDiscordLog.cs" />
|
||||||
<Compile Include="BGS\InfluenceSupport.cs" />
|
<Compile Include="BGS\InfluenceSupport.cs" />
|
||||||
|
<Compile Include="BGS\LogGenerator\GenericFormat.cs" />
|
||||||
<Compile Include="BGS\LogGenerator\LogFormatter.cs" />
|
<Compile Include="BGS\LogGenerator\LogFormatter.cs" />
|
||||||
<Compile Include="BGS\LogGenerator\VistaGenomics.cs" />
|
<Compile Include="BGS\LogGenerator\SearchAndRescueFormat.cs" />
|
||||||
|
<Compile Include="BGS\LogGenerator\VistaGenomicsFormat.cs" />
|
||||||
<Compile Include="BGS\MissionFailed.cs" />
|
<Compile Include="BGS\MissionFailed.cs" />
|
||||||
<Compile Include="BGS\NonaDiscordLog.cs" />
|
<Compile Include="BGS\NonaDiscordLog.cs" />
|
||||||
<Compile Include="BGS\BuyCargo.cs" />
|
<Compile Include="BGS\BuyCargo.cs" />
|
||||||
<Compile Include="BGS\OrganicData.cs" />
|
<Compile Include="BGS\OrganicData.cs" />
|
||||||
|
<Compile Include="BGS\SearchAndRescue.cs" />
|
||||||
<Compile Include="BGS\SellCargo.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" />
|
||||||
|
Loading…
Reference in New Issue
Block a user