new separate REPO for EDPlayerJournal
This commit is contained in:
commit
d7b407db78
363
.gitignore
vendored
Normal file
363
.gitignore
vendored
Normal file
@ -0,0 +1,363 @@
|
|||||||
|
## Ignore Visual Studio temporary files, build results, and
|
||||||
|
## files generated by popular Visual Studio add-ons.
|
||||||
|
##
|
||||||
|
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
|
||||||
|
|
||||||
|
# User-specific files
|
||||||
|
*.rsuser
|
||||||
|
*.suo
|
||||||
|
*.user
|
||||||
|
*.userosscache
|
||||||
|
*.sln.docstates
|
||||||
|
|
||||||
|
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||||
|
*.userprefs
|
||||||
|
|
||||||
|
# Mono auto generated files
|
||||||
|
mono_crash.*
|
||||||
|
|
||||||
|
# Build results
|
||||||
|
[Dd]ebug/
|
||||||
|
[Dd]ebugPublic/
|
||||||
|
[Rr]elease/
|
||||||
|
[Rr]eleases/
|
||||||
|
x64/
|
||||||
|
x86/
|
||||||
|
[Ww][Ii][Nn]32/
|
||||||
|
[Aa][Rr][Mm]/
|
||||||
|
[Aa][Rr][Mm]64/
|
||||||
|
bld/
|
||||||
|
[Bb]in/
|
||||||
|
[Oo]bj/
|
||||||
|
[Oo]ut/
|
||||||
|
[Ll]og/
|
||||||
|
[Ll]ogs/
|
||||||
|
|
||||||
|
# Visual Studio 2015/2017 cache/options directory
|
||||||
|
.vs/
|
||||||
|
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||||
|
#wwwroot/
|
||||||
|
|
||||||
|
# Visual Studio 2017 auto generated files
|
||||||
|
Generated\ Files/
|
||||||
|
|
||||||
|
# MSTest test Results
|
||||||
|
[Tt]est[Rr]esult*/
|
||||||
|
[Bb]uild[Ll]og.*
|
||||||
|
|
||||||
|
# NUnit
|
||||||
|
*.VisualState.xml
|
||||||
|
TestResult.xml
|
||||||
|
nunit-*.xml
|
||||||
|
|
||||||
|
# Build Results of an ATL Project
|
||||||
|
[Dd]ebugPS/
|
||||||
|
[Rr]eleasePS/
|
||||||
|
dlldata.c
|
||||||
|
|
||||||
|
# Benchmark Results
|
||||||
|
BenchmarkDotNet.Artifacts/
|
||||||
|
|
||||||
|
# .NET Core
|
||||||
|
project.lock.json
|
||||||
|
project.fragment.lock.json
|
||||||
|
artifacts/
|
||||||
|
|
||||||
|
# ASP.NET Scaffolding
|
||||||
|
ScaffoldingReadMe.txt
|
||||||
|
|
||||||
|
# StyleCop
|
||||||
|
StyleCopReport.xml
|
||||||
|
|
||||||
|
# Files built by Visual Studio
|
||||||
|
*_i.c
|
||||||
|
*_p.c
|
||||||
|
*_h.h
|
||||||
|
*.ilk
|
||||||
|
*.meta
|
||||||
|
*.obj
|
||||||
|
*.iobj
|
||||||
|
*.pch
|
||||||
|
*.pdb
|
||||||
|
*.ipdb
|
||||||
|
*.pgc
|
||||||
|
*.pgd
|
||||||
|
*.rsp
|
||||||
|
*.sbr
|
||||||
|
*.tlb
|
||||||
|
*.tli
|
||||||
|
*.tlh
|
||||||
|
*.tmp
|
||||||
|
*.tmp_proj
|
||||||
|
*_wpftmp.csproj
|
||||||
|
*.log
|
||||||
|
*.vspscc
|
||||||
|
*.vssscc
|
||||||
|
.builds
|
||||||
|
*.pidb
|
||||||
|
*.svclog
|
||||||
|
*.scc
|
||||||
|
|
||||||
|
# Chutzpah Test files
|
||||||
|
_Chutzpah*
|
||||||
|
|
||||||
|
# Visual C++ cache files
|
||||||
|
ipch/
|
||||||
|
*.aps
|
||||||
|
*.ncb
|
||||||
|
*.opendb
|
||||||
|
*.opensdf
|
||||||
|
*.sdf
|
||||||
|
*.cachefile
|
||||||
|
*.VC.db
|
||||||
|
*.VC.VC.opendb
|
||||||
|
|
||||||
|
# Visual Studio profiler
|
||||||
|
*.psess
|
||||||
|
*.vsp
|
||||||
|
*.vspx
|
||||||
|
*.sap
|
||||||
|
|
||||||
|
# Visual Studio Trace Files
|
||||||
|
*.e2e
|
||||||
|
|
||||||
|
# TFS 2012 Local Workspace
|
||||||
|
$tf/
|
||||||
|
|
||||||
|
# Guidance Automation Toolkit
|
||||||
|
*.gpState
|
||||||
|
|
||||||
|
# ReSharper is a .NET coding add-in
|
||||||
|
_ReSharper*/
|
||||||
|
*.[Rr]e[Ss]harper
|
||||||
|
*.DotSettings.user
|
||||||
|
|
||||||
|
# TeamCity is a build add-in
|
||||||
|
_TeamCity*
|
||||||
|
|
||||||
|
# DotCover is a Code Coverage Tool
|
||||||
|
*.dotCover
|
||||||
|
|
||||||
|
# AxoCover is a Code Coverage Tool
|
||||||
|
.axoCover/*
|
||||||
|
!.axoCover/settings.json
|
||||||
|
|
||||||
|
# Coverlet is a free, cross platform Code Coverage Tool
|
||||||
|
coverage*.json
|
||||||
|
coverage*.xml
|
||||||
|
coverage*.info
|
||||||
|
|
||||||
|
# Visual Studio code coverage results
|
||||||
|
*.coverage
|
||||||
|
*.coveragexml
|
||||||
|
|
||||||
|
# NCrunch
|
||||||
|
_NCrunch_*
|
||||||
|
.*crunch*.local.xml
|
||||||
|
nCrunchTemp_*
|
||||||
|
|
||||||
|
# MightyMoose
|
||||||
|
*.mm.*
|
||||||
|
AutoTest.Net/
|
||||||
|
|
||||||
|
# Web workbench (sass)
|
||||||
|
.sass-cache/
|
||||||
|
|
||||||
|
# Installshield output folder
|
||||||
|
[Ee]xpress/
|
||||||
|
|
||||||
|
# DocProject is a documentation generator add-in
|
||||||
|
DocProject/buildhelp/
|
||||||
|
DocProject/Help/*.HxT
|
||||||
|
DocProject/Help/*.HxC
|
||||||
|
DocProject/Help/*.hhc
|
||||||
|
DocProject/Help/*.hhk
|
||||||
|
DocProject/Help/*.hhp
|
||||||
|
DocProject/Help/Html2
|
||||||
|
DocProject/Help/html
|
||||||
|
|
||||||
|
# Click-Once directory
|
||||||
|
publish/
|
||||||
|
|
||||||
|
# Publish Web Output
|
||||||
|
*.[Pp]ublish.xml
|
||||||
|
*.azurePubxml
|
||||||
|
# Note: Comment the next line if you want to checkin your web deploy settings,
|
||||||
|
# but database connection strings (with potential passwords) will be unencrypted
|
||||||
|
*.pubxml
|
||||||
|
*.publishproj
|
||||||
|
|
||||||
|
# Microsoft Azure Web App publish settings. Comment the next line if you want to
|
||||||
|
# checkin your Azure Web App publish settings, but sensitive information contained
|
||||||
|
# in these scripts will be unencrypted
|
||||||
|
PublishScripts/
|
||||||
|
|
||||||
|
# NuGet Packages
|
||||||
|
*.nupkg
|
||||||
|
# NuGet Symbol Packages
|
||||||
|
*.snupkg
|
||||||
|
# The packages folder can be ignored because of Package Restore
|
||||||
|
**/[Pp]ackages/*
|
||||||
|
# except build/, which is used as an MSBuild target.
|
||||||
|
!**/[Pp]ackages/build/
|
||||||
|
# Uncomment if necessary however generally it will be regenerated when needed
|
||||||
|
#!**/[Pp]ackages/repositories.config
|
||||||
|
# NuGet v3's project.json files produces more ignorable files
|
||||||
|
*.nuget.props
|
||||||
|
*.nuget.targets
|
||||||
|
|
||||||
|
# Microsoft Azure Build Output
|
||||||
|
csx/
|
||||||
|
*.build.csdef
|
||||||
|
|
||||||
|
# Microsoft Azure Emulator
|
||||||
|
ecf/
|
||||||
|
rcf/
|
||||||
|
|
||||||
|
# Windows Store app package directories and files
|
||||||
|
AppPackages/
|
||||||
|
BundleArtifacts/
|
||||||
|
Package.StoreAssociation.xml
|
||||||
|
_pkginfo.txt
|
||||||
|
*.appx
|
||||||
|
*.appxbundle
|
||||||
|
*.appxupload
|
||||||
|
|
||||||
|
# Visual Studio cache files
|
||||||
|
# files ending in .cache can be ignored
|
||||||
|
*.[Cc]ache
|
||||||
|
# but keep track of directories ending in .cache
|
||||||
|
!?*.[Cc]ache/
|
||||||
|
|
||||||
|
# Others
|
||||||
|
ClientBin/
|
||||||
|
~$*
|
||||||
|
*~
|
||||||
|
*.dbmdl
|
||||||
|
*.dbproj.schemaview
|
||||||
|
*.jfm
|
||||||
|
*.pfx
|
||||||
|
*.publishsettings
|
||||||
|
orleans.codegen.cs
|
||||||
|
|
||||||
|
# Including strong name files can present a security risk
|
||||||
|
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
|
||||||
|
#*.snk
|
||||||
|
|
||||||
|
# Since there are multiple workflows, uncomment next line to ignore bower_components
|
||||||
|
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
|
||||||
|
#bower_components/
|
||||||
|
|
||||||
|
# RIA/Silverlight projects
|
||||||
|
Generated_Code/
|
||||||
|
|
||||||
|
# Backup & report files from converting an old project file
|
||||||
|
# to a newer Visual Studio version. Backup files are not needed,
|
||||||
|
# because we have git ;-)
|
||||||
|
_UpgradeReport_Files/
|
||||||
|
Backup*/
|
||||||
|
UpgradeLog*.XML
|
||||||
|
UpgradeLog*.htm
|
||||||
|
ServiceFabricBackup/
|
||||||
|
*.rptproj.bak
|
||||||
|
|
||||||
|
# SQL Server files
|
||||||
|
*.mdf
|
||||||
|
*.ldf
|
||||||
|
*.ndf
|
||||||
|
|
||||||
|
# Business Intelligence projects
|
||||||
|
*.rdl.data
|
||||||
|
*.bim.layout
|
||||||
|
*.bim_*.settings
|
||||||
|
*.rptproj.rsuser
|
||||||
|
*- [Bb]ackup.rdl
|
||||||
|
*- [Bb]ackup ([0-9]).rdl
|
||||||
|
*- [Bb]ackup ([0-9][0-9]).rdl
|
||||||
|
|
||||||
|
# Microsoft Fakes
|
||||||
|
FakesAssemblies/
|
||||||
|
|
||||||
|
# GhostDoc plugin setting file
|
||||||
|
*.GhostDoc.xml
|
||||||
|
|
||||||
|
# Node.js Tools for Visual Studio
|
||||||
|
.ntvs_analysis.dat
|
||||||
|
node_modules/
|
||||||
|
|
||||||
|
# Visual Studio 6 build log
|
||||||
|
*.plg
|
||||||
|
|
||||||
|
# Visual Studio 6 workspace options file
|
||||||
|
*.opt
|
||||||
|
|
||||||
|
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
|
||||||
|
*.vbw
|
||||||
|
|
||||||
|
# Visual Studio LightSwitch build output
|
||||||
|
**/*.HTMLClient/GeneratedArtifacts
|
||||||
|
**/*.DesktopClient/GeneratedArtifacts
|
||||||
|
**/*.DesktopClient/ModelManifest.xml
|
||||||
|
**/*.Server/GeneratedArtifacts
|
||||||
|
**/*.Server/ModelManifest.xml
|
||||||
|
_Pvt_Extensions
|
||||||
|
|
||||||
|
# Paket dependency manager
|
||||||
|
.paket/paket.exe
|
||||||
|
paket-files/
|
||||||
|
|
||||||
|
# FAKE - F# Make
|
||||||
|
.fake/
|
||||||
|
|
||||||
|
# CodeRush personal settings
|
||||||
|
.cr/personal
|
||||||
|
|
||||||
|
# Python Tools for Visual Studio (PTVS)
|
||||||
|
__pycache__/
|
||||||
|
*.pyc
|
||||||
|
|
||||||
|
# Cake - Uncomment if you are using it
|
||||||
|
# tools/**
|
||||||
|
# !tools/packages.config
|
||||||
|
|
||||||
|
# Tabs Studio
|
||||||
|
*.tss
|
||||||
|
|
||||||
|
# Telerik's JustMock configuration file
|
||||||
|
*.jmconfig
|
||||||
|
|
||||||
|
# BizTalk build output
|
||||||
|
*.btp.cs
|
||||||
|
*.btm.cs
|
||||||
|
*.odx.cs
|
||||||
|
*.xsd.cs
|
||||||
|
|
||||||
|
# OpenCover UI analysis results
|
||||||
|
OpenCover/
|
||||||
|
|
||||||
|
# Azure Stream Analytics local run output
|
||||||
|
ASALocalRun/
|
||||||
|
|
||||||
|
# MSBuild Binary and Structured Log
|
||||||
|
*.binlog
|
||||||
|
|
||||||
|
# NVidia Nsight GPU debugger configuration file
|
||||||
|
*.nvuser
|
||||||
|
|
||||||
|
# MFractors (Xamarin productivity tool) working folder
|
||||||
|
.mfractor/
|
||||||
|
|
||||||
|
# Local History for Visual Studio
|
||||||
|
.localhistory/
|
||||||
|
|
||||||
|
# BeatPulse healthcheck temp database
|
||||||
|
healthchecksdb
|
||||||
|
|
||||||
|
# Backup folder for Package Reference Convert tool in Visual Studio 2017
|
||||||
|
MigrationBackup/
|
||||||
|
|
||||||
|
# Ionide (cross platform F# VS Code tools) working folder
|
||||||
|
.ionide/
|
||||||
|
|
||||||
|
# Fody - auto-generated XML schema
|
||||||
|
FodyWeavers.xsd
|
130
EDPlayerJournal/BGS-ODDITIES.md
Normal file
130
EDPlayerJournal/BGS-ODDITIES.md
Normal file
@ -0,0 +1,130 @@
|
|||||||
|
# BGS Oddities
|
||||||
|
|
||||||
|
This file gathers BGS related oddities, as well as bugs within the player journal.
|
||||||
|
|
||||||
|
## Bounty Vouchers without factions
|
||||||
|
|
||||||
|
Somtimes bounty vouchers do not have faction information listed in them. It is unclear
|
||||||
|
what caused this bug, and it is also unclear whether this bug still persists within
|
||||||
|
the game:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"timestamp":"2021-10-07T14:57:50Z", "event":"RedeemVoucher",
|
||||||
|
"Type":"bounty", "Amount":20750,
|
||||||
|
"Factions":[ { "Faction":"", "Amount":500 }, { "Faction":"", "Amount":20250 }]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Bounty vouchers show up twice
|
||||||
|
|
||||||
|
Sometimes bounty vouchers are redeemed twice. This happens because FDev writes out two
|
||||||
|
`RedeemVoucher` entries with the same values:
|
||||||
|
|
||||||
|
```
|
||||||
|
{ "timestamp":"2022-11-20T14:30:30Z", "event":"RedeemVoucher", "Type":"bounty", "Amount":3197549,
|
||||||
|
"Factions":[ { "Faction":"Nova Paresa", "Amount":3197549 } ] }
|
||||||
|
{ "timestamp":"2022-11-20T14:30:34Z", "event":"RedeemVoucher", "Type":"bounty", "Amount":4785831,
|
||||||
|
"Factions":[ { "Faction":"", "Amount":723175 }, { "Faction":"Nova Paresa", "Amount":3197549 }, { "Faction":"Prismatic Imperium", "Amount":4062656 } ] }
|
||||||
|
```
|
||||||
|
|
||||||
|
Two separate events (apart by four seconds) containing the same entries twice. This
|
||||||
|
happens when you turn in one bounty manually, and then click the "redeem all" button
|
||||||
|
again, which contains the already turned in vouchers.
|
||||||
|
|
||||||
|
## Combat zones
|
||||||
|
|
||||||
|
Combat zones receive no mention within the player journal whatsoever. There is no event
|
||||||
|
when one is lost, or won, or what sort of difficulty it was. It is technically possible
|
||||||
|
to deduce combat zones from the text messages you receive from the combat coordinators.
|
||||||
|
|
||||||
|
## Influence given to empty/non-existant factions
|
||||||
|
|
||||||
|
Mission can give negative reputation and influence to an non-faction. This happens when
|
||||||
|
you affect an asset that is not owned by anyone. For example, randomly generated surface
|
||||||
|
POIs sometimes do not have an owner. If you receive a scan, infiltrate, or sabotage mission
|
||||||
|
for such a POI, the non-existant owner receives negative influence, and you damage your
|
||||||
|
reputation with that non-existant owner:
|
||||||
|
|
||||||
|
```json
|
||||||
|
"FactionEffects": [
|
||||||
|
{
|
||||||
|
"Faction": "",
|
||||||
|
"Effects": [
|
||||||
|
{
|
||||||
|
"Effect": "$MISSIONUTIL_Interaction_Summary_EP_down;",
|
||||||
|
"Effect_Localised": "The economic status of $#MinorFaction; has declined in the $#System; system.",
|
||||||
|
"Trend": "DownBad"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"Influence": [
|
||||||
|
{
|
||||||
|
"SystemAddress": 251012319587,
|
||||||
|
"Trend": "DownBad",
|
||||||
|
"Influence": "+"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"ReputationTrend": "DownBad",
|
||||||
|
"Reputation": "+"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
||||||
|
## No influence given to target or source faction
|
||||||
|
|
||||||
|
Sometimes neither the target faction, nor the source faction receive any influence. This
|
||||||
|
can happen because either the target faction, or the source faction - or both - are
|
||||||
|
currently in a conflict, and thus cannot receive any influence at the moment.
|
||||||
|
|
||||||
|
Systems that are influence locked also do not hand out influence to its factions.
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"timestamp": "2022-02-25T21:30:45Z",
|
||||||
|
"event": "MissionCompleted",
|
||||||
|
"Faction": "Social LHS 6103 Confederation",
|
||||||
|
"Name": "Mission_Courier_Elections_name",
|
||||||
|
"MissionID": 850025233,
|
||||||
|
"TargetFaction": "Delphin Blue Federal PLC",
|
||||||
|
"DestinationSystem": "Delphin",
|
||||||
|
"DestinationStation": "Aristotle Orbital",
|
||||||
|
"Reward": 122300,
|
||||||
|
"FactionEffects": [
|
||||||
|
{
|
||||||
|
"Faction": "Social LHS 6103 Confederation",
|
||||||
|
"Effects": [
|
||||||
|
{
|
||||||
|
"Effect": "$MISSIONUTIL_Interaction_Summary_EP_up;",
|
||||||
|
"Effect_Localised": "The economic status of $#MinorFaction; has improved in the $#System; system.",
|
||||||
|
"Trend": "UpGood"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"Influence": [],
|
||||||
|
"ReputationTrend": "UpGood",
|
||||||
|
"Reputation": "+"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Faction": "Delphin Blue Federal PLC",
|
||||||
|
"Effects": [],
|
||||||
|
"Influence": [],
|
||||||
|
"ReputationTrend": "UpGood",
|
||||||
|
"Reputation": "+"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Megaship scan missions both marked as abandoned and failed
|
||||||
|
|
||||||
|
Megaship missions that bug out, may both be marked as "abandoned", and "failed". It is
|
||||||
|
unclear which of these two counts. A failed mission has negative BGS implications, whereas
|
||||||
|
an abandoned mission should not.
|
||||||
|
|
||||||
|
```json
|
||||||
|
{ "timestamp":"2022-11-09T07:33:08Z", "event":"Missions", "Active":[ { "MissionID":899075054, "Name":"Mission_HackMegaship_name",
|
||||||
|
"PassengerMission":false, "Expires":51072 }, { "MissionID":899075080, "Name":"Mission_HackMegaship_name",
|
||||||
|
"PassengerMission":false, "Expires":51072 } ], "Failed":[ ], "Complete":[ ] }
|
||||||
|
|
||||||
|
{ "timestamp":"2022-11-09T08:23:59Z", "event":"MissionAbandoned", "Name":"Mission_HackMegaship_name", "MissionID":899075054 }
|
||||||
|
{ "timestamp":"2022-11-09T08:24:05Z", "event":"MissionFailed", "Name":"Mission_HackMegaship_name", "MissionID":899075054 }
|
||||||
|
```
|
70
EDPlayerJournal/BGS/BuyCargo.cs
Normal file
70
EDPlayerJournal/BGS/BuyCargo.cs
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
using System.Text;
|
||||||
|
using EDPlayerJournal.Entries;
|
||||||
|
|
||||||
|
namespace EDPlayerJournal.BGS;
|
||||||
|
|
||||||
|
public class BuyCargo : Transaction {
|
||||||
|
public BuyCargo() { }
|
||||||
|
|
||||||
|
public BuyCargo(MarketBuyEntry e) {
|
||||||
|
Entries.Add(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string? Cargo {
|
||||||
|
get {
|
||||||
|
string? cargo;
|
||||||
|
var sell = Entries.OfType<MarketBuyEntry>().First();
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(sell.TypeLocalised)) {
|
||||||
|
cargo = sell.TypeLocalised;
|
||||||
|
} else {
|
||||||
|
cargo = sell.Type;
|
||||||
|
if (cargo != null && cargo.Length >= 2) {
|
||||||
|
cargo = cargo[0].ToString().ToUpper() + cargo.Substring(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return cargo;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public long Amount {
|
||||||
|
get { return Entries.OfType<MarketBuyEntry>().Sum(x => x.Count); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public override int CompareTo(Transaction? other) {
|
||||||
|
if (other == null || other.GetType() != typeof(BuyCargo)) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
BuyCargo? buycargo = other as BuyCargo;
|
||||||
|
if (buycargo != null &&
|
||||||
|
buycargo.Cargo == Cargo &&
|
||||||
|
buycargo.System == System &&
|
||||||
|
buycargo.Faction == Faction) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string ToString() {
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
|
||||||
|
if (Entries.Count <= 0) {
|
||||||
|
return builder.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
builder.AppendFormat("Bought {0} {1} at the Commodity Market",
|
||||||
|
Amount,
|
||||||
|
Cargo
|
||||||
|
);
|
||||||
|
|
||||||
|
return builder.ToString().Trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Selling resources to a market only helps the controlling faction
|
||||||
|
/// </summary>
|
||||||
|
public override bool OnlyControllingFaction => true;
|
||||||
|
}
|
57
EDPlayerJournal/BGS/Cartographics.cs
Normal file
57
EDPlayerJournal/BGS/Cartographics.cs
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
using System.Text;
|
||||||
|
using EDPlayerJournal.Entries;
|
||||||
|
|
||||||
|
namespace EDPlayerJournal.BGS;
|
||||||
|
|
||||||
|
public class Cartographics : Transaction {
|
||||||
|
public Cartographics() { }
|
||||||
|
|
||||||
|
public Cartographics(MultiSellExplorationDataEntry e) {
|
||||||
|
Entries.Add(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Cartographics(SellExplorationDataEntry e) {
|
||||||
|
Entries.Add(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override int CompareTo(Transaction? other) {
|
||||||
|
if (other == null || other.GetType() != typeof(Cartographics)) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
Cartographics? b = other as Cartographics;
|
||||||
|
if (b != null &&
|
||||||
|
b.System == System &&
|
||||||
|
b.Faction == Faction &&
|
||||||
|
b.Station == Station) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long TotalSum {
|
||||||
|
get {
|
||||||
|
/* add multi sell and normal ones together */
|
||||||
|
long total =
|
||||||
|
Entries.OfType<MultiSellExplorationDataEntry>()
|
||||||
|
.Sum(x => x.Total)
|
||||||
|
+
|
||||||
|
Entries.OfType<SellExplorationDataEntry>()
|
||||||
|
.Sum(x => x.Total)
|
||||||
|
;
|
||||||
|
return total;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string ToString() {
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
builder.AppendFormat("Sold {0} worth of Cartographics Data", Credits.FormatCredits(TotalSum));
|
||||||
|
return builder.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Cartographics only help the controlling faction.
|
||||||
|
/// </summary>
|
||||||
|
public override bool OnlyControllingFaction => true;
|
||||||
|
}
|
130
EDPlayerJournal/BGS/CombatZone.cs
Normal file
130
EDPlayerJournal/BGS/CombatZone.cs
Normal file
@ -0,0 +1,130 @@
|
|||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace EDPlayerJournal.BGS;
|
||||||
|
public class CombatZone : Transaction {
|
||||||
|
/// <summary>
|
||||||
|
/// Type, either on foot or ship
|
||||||
|
/// </summary>
|
||||||
|
public string Type { get; set; } = CombatZones.ShipCombatZone;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Difficulty type, low, medium or high. Null means unknown.
|
||||||
|
/// </summary>
|
||||||
|
public string? Grade { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether spec ops were won.
|
||||||
|
/// </summary>
|
||||||
|
public bool? SpecOps { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether allied captain objective was won
|
||||||
|
/// </summary>
|
||||||
|
public bool? AlliedCaptain { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether enemy captain objective was won
|
||||||
|
/// </summary>
|
||||||
|
public bool? EnemyCaptain { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether the allied correspondent objective was won
|
||||||
|
/// </summary>
|
||||||
|
public bool? AlliedCorrespondent { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether the enemy correspondent objective was won
|
||||||
|
/// </summary>
|
||||||
|
public bool? EnemyCorrespondent { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether cap ship objective was won
|
||||||
|
/// </summary>
|
||||||
|
public bool? CapitalShip { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// If we have a combat zone, this might point to the settlement
|
||||||
|
/// in question.
|
||||||
|
/// </summary>
|
||||||
|
public string? Settlement { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// How many optional objectives were completed?
|
||||||
|
/// </summary>
|
||||||
|
public int OptionalObjectivesCompleted {
|
||||||
|
get {
|
||||||
|
if (IsGround) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return new List<bool?>() {
|
||||||
|
SpecOps,
|
||||||
|
AlliedCaptain,
|
||||||
|
EnemyCaptain,
|
||||||
|
AlliedCorrespondent,
|
||||||
|
EnemyCorrespondent,
|
||||||
|
CapitalShip
|
||||||
|
}
|
||||||
|
.Where(x => x != null && x == true)
|
||||||
|
.Count()
|
||||||
|
;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns true if it is an on foot/ground combat zone
|
||||||
|
/// </summary>
|
||||||
|
public bool IsGround {
|
||||||
|
get { return string.Compare(Type, CombatZones.GroundCombatZone) == 0; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns true if it is an on foot combat zone
|
||||||
|
/// </summary>
|
||||||
|
public bool IsShip {
|
||||||
|
get { return string.Compare(Type, CombatZones.ShipCombatZone) == 0; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns true if it is a thargoid combat zone
|
||||||
|
/// </summary>
|
||||||
|
public bool IsThargoid {
|
||||||
|
get { return string.Compare(Type, CombatZones.AXCombatZone) == 0; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns true if it is a power combat zone
|
||||||
|
/// </summary>
|
||||||
|
public bool IsPower {
|
||||||
|
get { return string.Compare(Type, CombatZones.PowerCombatZone) == 0; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public override int CompareTo(Transaction? obj) {
|
||||||
|
if (obj == null || obj.GetType() != typeof(CombatZone)) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
CombatZone? b = obj as CombatZone;
|
||||||
|
if (b == null) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (b.Faction != Faction || b.System != System) {
|
||||||
|
return -1; // System and faction don't match
|
||||||
|
}
|
||||||
|
|
||||||
|
if (b.Type != b.Type || b.Grade != b.Grade) {
|
||||||
|
return -1; // grade and type don't match
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string ToString() {
|
||||||
|
if (!string.IsNullOrEmpty(Grade)) {
|
||||||
|
return string.Format("Won {0} {1} Combat Zone", Grade, Type);
|
||||||
|
} else {
|
||||||
|
return string.Format("Won {0} Combat Zone", Type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
42
EDPlayerJournal/BGS/FactionKillBonds.cs
Normal file
42
EDPlayerJournal/BGS/FactionKillBonds.cs
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
using EDPlayerJournal.Entries;
|
||||||
|
|
||||||
|
namespace EDPlayerJournal.BGS;
|
||||||
|
public class FactionKillBonds : Transaction {
|
||||||
|
public ulong TotalSum {
|
||||||
|
get {
|
||||||
|
return (ulong)Entries
|
||||||
|
.OfType<FactionKillBondEntry>()
|
||||||
|
.Sum(x => (decimal)x.Reward)
|
||||||
|
;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string? VictimFaction {
|
||||||
|
get {
|
||||||
|
return Entries
|
||||||
|
.OfType<FactionKillBondEntry>()
|
||||||
|
.First()
|
||||||
|
.VictimFaction
|
||||||
|
;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override int CompareTo(Transaction? other) {
|
||||||
|
if (other == null || other.GetType() != typeof(FactionKillBonds)) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
FactionKillBonds? b = other as FactionKillBonds;
|
||||||
|
if (b == null || b.VictimFaction == VictimFaction) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string ToString() {
|
||||||
|
return string.Format("Faction Kill Bonds: {0} against {1}",
|
||||||
|
Credits.FormatCredits(TotalSum),
|
||||||
|
VictimFaction);
|
||||||
|
}
|
||||||
|
}
|
66
EDPlayerJournal/BGS/FoulMurder.cs
Normal file
66
EDPlayerJournal/BGS/FoulMurder.cs
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
using System.Text;
|
||||||
|
using EDPlayerJournal.Entries;
|
||||||
|
|
||||||
|
namespace EDPlayerJournal.BGS;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 36 Lessons of Vivec, Sermon Thirty Six
|
||||||
|
/// </summary>
|
||||||
|
public class FoulMurder : Transaction {
|
||||||
|
public FoulMurder() { }
|
||||||
|
public FoulMurder (CommitCrimeEntry e) {
|
||||||
|
Entries.Add(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string? CrimeType {
|
||||||
|
get { return Entries.OfType<CommitCrimeEntry>().First().CrimeType; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public long Bounties => Entries.OfType<CommitCrimeEntry>().Sum(x => x.Bounty);
|
||||||
|
|
||||||
|
public long Fines => Entries.OfType<CommitCrimeEntry>().Sum(x => x.Fine);
|
||||||
|
|
||||||
|
public override int CompareTo(Transaction? other) {
|
||||||
|
if (other == null || other.GetType() != typeof(FoulMurder)) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
FoulMurder? hortator = other as FoulMurder;
|
||||||
|
if (hortator != null &&
|
||||||
|
Faction == hortator.Faction &&
|
||||||
|
CrimeType == hortator.CrimeType) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string ToString() {
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
string type;
|
||||||
|
|
||||||
|
if (CrimeType == CrimeTypes.Murder) {
|
||||||
|
if (Entries.Count > 1) {
|
||||||
|
type = "ships";
|
||||||
|
} else {
|
||||||
|
type = "ship";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (Entries.Count > 1) {
|
||||||
|
type = "people";
|
||||||
|
} else {
|
||||||
|
type = "person";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
builder.AppendFormat("Murdered {0} {1} of {2} (Bounties: {3}, Fines: {4})",
|
||||||
|
Entries.Count,
|
||||||
|
type,
|
||||||
|
Faction,
|
||||||
|
Credits.FormatCredits(Bounties),
|
||||||
|
Credits.FormatCredits(Fines)
|
||||||
|
);
|
||||||
|
|
||||||
|
return builder.ToString();
|
||||||
|
}
|
||||||
|
}
|
16
EDPlayerJournal/BGS/IncompleteTransaction.cs
Normal file
16
EDPlayerJournal/BGS/IncompleteTransaction.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
using EDPlayerJournal.Entries;
|
||||||
|
|
||||||
|
namespace EDPlayerJournal.BGS;
|
||||||
|
|
||||||
|
public class IncompleteTransaction : Transaction {
|
||||||
|
public Transaction? UnderlyingTransaction { get; set; } = null;
|
||||||
|
public string Reason { get; set; } = "";
|
||||||
|
|
||||||
|
public IncompleteTransaction() { }
|
||||||
|
|
||||||
|
public IncompleteTransaction(Transaction? underlying, string reason, Entry entry) {
|
||||||
|
UnderlyingTransaction = underlying;
|
||||||
|
Reason = reason;
|
||||||
|
Entries.Add(entry);
|
||||||
|
}
|
||||||
|
}
|
54
EDPlayerJournal/BGS/InfluenceSupport.cs
Normal file
54
EDPlayerJournal/BGS/InfluenceSupport.cs
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
using System.Text;
|
||||||
|
using EDPlayerJournal.Entries;
|
||||||
|
|
||||||
|
namespace EDPlayerJournal.BGS;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This class is used when a completed mission gives influence to another
|
||||||
|
/// faction as well. This happens, for example, when you deliver cargo from one
|
||||||
|
/// faction to another. Both sometimes gain influence.
|
||||||
|
/// </summary>
|
||||||
|
public class InfluenceSupport : Transaction {
|
||||||
|
public MissionInfluence? Influence { get; set; } = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Relevant mission completed entry
|
||||||
|
/// </summary>
|
||||||
|
public MissionCompletedEntry? RelevantMission { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Mission information
|
||||||
|
/// </summary>
|
||||||
|
public Mission? Mission { get; set; }
|
||||||
|
|
||||||
|
public override DateTime? CompletedAtDateTime {
|
||||||
|
get {
|
||||||
|
if (RelevantMission == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return RelevantMission.Timestamp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string ToString() {
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
string? missionname;
|
||||||
|
|
||||||
|
if (RelevantMission != null && RelevantMission.Mission != null) {
|
||||||
|
missionname = RelevantMission.Mission.FriendlyName;
|
||||||
|
} else {
|
||||||
|
missionname = "UNKNOWN MISSION";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (missionname == null) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
builder.AppendFormat("Influence gained from \"{0}\": \"{1}\"",
|
||||||
|
missionname,
|
||||||
|
Influence == null ? "NONE" : Influence.TrendAdjustedInfluence
|
||||||
|
);
|
||||||
|
|
||||||
|
return builder.ToString();
|
||||||
|
}
|
||||||
|
}
|
32
EDPlayerJournal/BGS/MeritsGained.cs
Normal file
32
EDPlayerJournal/BGS/MeritsGained.cs
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
using EDPlayerJournal.Entries;
|
||||||
|
|
||||||
|
namespace EDPlayerJournal.BGS;
|
||||||
|
|
||||||
|
public class MeritsGained : Transaction {
|
||||||
|
public MeritsGained() { }
|
||||||
|
|
||||||
|
public MeritsGained(Entry entry) {
|
||||||
|
Entries.Add(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Number of merits gained
|
||||||
|
/// </summary>
|
||||||
|
public long Merits {
|
||||||
|
get {
|
||||||
|
return Entries
|
||||||
|
.OfType<PowerplayMeritsEntry>()
|
||||||
|
.Sum(x => x.MeritsGained)
|
||||||
|
;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// For what power those merits were gained
|
||||||
|
/// </summary>
|
||||||
|
public string Power { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public override string ToString() {
|
||||||
|
return string.Format("{0} Merits gained for {1}", Merits, Power);
|
||||||
|
}
|
||||||
|
}
|
88
EDPlayerJournal/BGS/MissionCompleted.cs
Normal file
88
EDPlayerJournal/BGS/MissionCompleted.cs
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using EDPlayerJournal.Entries;
|
||||||
|
|
||||||
|
namespace EDPlayerJournal.BGS;
|
||||||
|
|
||||||
|
public class MissionCompleted : Transaction {
|
||||||
|
public MissionCompletedEntry? CompletedEntry { get; set; }
|
||||||
|
|
||||||
|
public MissionAcceptedEntry? AcceptedEntry { get; set; }
|
||||||
|
|
||||||
|
public Mission? Mission { get; set; }
|
||||||
|
|
||||||
|
public MissionCompleted() { }
|
||||||
|
|
||||||
|
public override DateTime? CompletedAtDateTime {
|
||||||
|
get {
|
||||||
|
if (CompletedEntry == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return CompletedEntry.Timestamp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string MissionName {
|
||||||
|
get {
|
||||||
|
if (CompletedEntry == null || CompletedEntry.Mission == null) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
return CompletedEntry.Mission.FriendlyName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Influence {
|
||||||
|
get {
|
||||||
|
if (CompletedEntry == null || Faction == null || CompletedEntry.Mission == null) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
return string.Join("",
|
||||||
|
CompletedEntry
|
||||||
|
.Mission
|
||||||
|
.GetInfluenceForFaction(Faction, SystemAddress)
|
||||||
|
.Select(x => x.Influence)
|
||||||
|
.ToArray()
|
||||||
|
)
|
||||||
|
;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Rescue missions contribute to the system.
|
||||||
|
/// </summary>
|
||||||
|
public override bool SystemContribution {
|
||||||
|
get {
|
||||||
|
if (Mission == null || Mission.Name == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the mission starts with the name for thargoid war mission
|
||||||
|
// names, we assume its a system contribution
|
||||||
|
if (Mission.Name.Contains("Mission_TW_")) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string ToString() {
|
||||||
|
if (Faction == null || CompletedEntry == null || CompletedEntry.Mission == null) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
var influence = CompletedEntry.Mission.GetInfluenceForFaction(Faction, SystemAddress);
|
||||||
|
|
||||||
|
builder.AppendFormat("{0}", MissionName);
|
||||||
|
if (influence != null && influence.Length > 0) {
|
||||||
|
builder.AppendFormat(", Influence: {0}",
|
||||||
|
influence.Select(x => x.InfluenceAmount).Sum()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return builder.ToString();
|
||||||
|
}
|
||||||
|
}
|
67
EDPlayerJournal/BGS/MissionFailed.cs
Normal file
67
EDPlayerJournal/BGS/MissionFailed.cs
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
using System.Text;
|
||||||
|
using EDPlayerJournal.Entries;
|
||||||
|
|
||||||
|
namespace EDPlayerJournal.BGS;
|
||||||
|
public class MissionFailed : Transaction {
|
||||||
|
public MissionFailedEntry? Failed { get; set; }
|
||||||
|
public Mission? Mission { get; set; }
|
||||||
|
|
||||||
|
public MissionFailed() { }
|
||||||
|
|
||||||
|
public MissionFailed(MissionFailedEntry failed) {
|
||||||
|
Entries.Add(failed);
|
||||||
|
Failed = failed;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the amount of influence generated by failing this mission. The
|
||||||
|
/// system returns no influence for one INF missions, but sadly also for
|
||||||
|
/// when the influence had no affect at all (i.e. during a war).
|
||||||
|
/// </summary>
|
||||||
|
public long InfluenceAmount {
|
||||||
|
get {
|
||||||
|
if (Mission == null || string.IsNullOrEmpty(Mission.Influence)) {
|
||||||
|
return -1;
|
||||||
|
} else {
|
||||||
|
return Mission.Influence.Length * -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override int CompareTo(Transaction? other) {
|
||||||
|
if (other == null || other.GetType() != typeof(MissionFailed)) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
MissionFailed? failed = other as MissionFailed;
|
||||||
|
|
||||||
|
if (failed == null) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* if it is the same mission name, the same faction and the same system,
|
||||||
|
* collate mission failures together
|
||||||
|
*/
|
||||||
|
if (string.Compare(failed.Failed?.Mission?.Name, Failed?.Mission?.Name) == 0 &&
|
||||||
|
failed.Faction == Faction &&
|
||||||
|
failed.System == System) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string ToString() {
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
|
||||||
|
if (Failed == null || Mission == null) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
builder.AppendFormat(" Mission failed: \"{0}\"",
|
||||||
|
Mission?.FriendlyName
|
||||||
|
);
|
||||||
|
|
||||||
|
return builder.ToString();
|
||||||
|
}
|
||||||
|
}
|
126
EDPlayerJournal/BGS/Objective.cs
Normal file
126
EDPlayerJournal/BGS/Objective.cs
Normal file
@ -0,0 +1,126 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System;
|
||||||
|
using System.Text;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace EDPlayerJournal.BGS;
|
||||||
|
|
||||||
|
public class Objective : IComparable<Objective> {
|
||||||
|
private List<Transaction> entries = new List<Transaction>();
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
public bool IsEnabled { get; set; }
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
public List<Transaction> Children {
|
||||||
|
get => entries;
|
||||||
|
}
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
public string Name => this.ToString();
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
public bool IsExpanded { get; set; }
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
public List<Transaction> LogEntries {
|
||||||
|
get => entries;
|
||||||
|
set => entries = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Clear() {
|
||||||
|
if (entries == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
entries.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Matches(Transaction e) {
|
||||||
|
int match_count = 0;
|
||||||
|
|
||||||
|
if (e.OnlyControllingFaction) {
|
||||||
|
if (Faction == null || (e.Faction != Faction)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (e.Faction != null && Faction != null) {
|
||||||
|
if (string.Compare(e.Faction, Faction, true) != 0) {
|
||||||
|
/* if we have a faction, and it doesn't match we don't care.
|
||||||
|
* faction is the most important comparision, so if it doesn't match
|
||||||
|
* it is not the right objective
|
||||||
|
*/
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
++match_count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* system and station only add to the match strength though */
|
||||||
|
if (e.System != null && System != null) {
|
||||||
|
if (string.Compare(e.System, System, true) == 0) {
|
||||||
|
++match_count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* if system and faction already match, station is not so important */
|
||||||
|
if (e.Station != null && Station != null) {
|
||||||
|
if (string.Compare(e.Station, Station, true) == 0) {
|
||||||
|
++match_count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return match_count;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int CompareTo(Objective? other) {
|
||||||
|
if (other == null) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return (other.System == System &&
|
||||||
|
other.Station == Station &&
|
||||||
|
other.Faction == Faction) ? 0 : -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsValid => (!string.IsNullOrEmpty(System) && !string.IsNullOrEmpty(Faction));
|
||||||
|
|
||||||
|
public string System { get; set; } = "";
|
||||||
|
|
||||||
|
public string Station { get; set; } = "";
|
||||||
|
|
||||||
|
public string Faction { get; set; } = "";
|
||||||
|
|
||||||
|
public override string ToString() {
|
||||||
|
StringBuilder str = new StringBuilder();
|
||||||
|
if (System != null && System.Length > 0) {
|
||||||
|
str.AppendFormat("System: {0}", System);
|
||||||
|
}
|
||||||
|
if (Station != null && Station.Length > 0) {
|
||||||
|
if (str.Length > 0) {
|
||||||
|
str.Append(", ");
|
||||||
|
}
|
||||||
|
str.AppendFormat("Station: {0}", Station);
|
||||||
|
}
|
||||||
|
if (Faction != null && Faction.Length > 0) {
|
||||||
|
if (str.Length > 0) {
|
||||||
|
str.Append(", ");
|
||||||
|
}
|
||||||
|
str.AppendFormat("Faction: {0}", Faction);
|
||||||
|
}
|
||||||
|
return str.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public string ToShortString() {
|
||||||
|
StringBuilder str = new StringBuilder();
|
||||||
|
if (System != null && System.Length > 0) {
|
||||||
|
str.AppendFormat("{0}", System);
|
||||||
|
}
|
||||||
|
if (Station != null && Station.Length > 0) {
|
||||||
|
if (str.Length > 0) {
|
||||||
|
str.Append(", ");
|
||||||
|
}
|
||||||
|
str.AppendFormat("{0}", Station);
|
||||||
|
}
|
||||||
|
return str.ToString();
|
||||||
|
}
|
||||||
|
}
|
45
EDPlayerJournal/BGS/OrganicData.cs
Normal file
45
EDPlayerJournal/BGS/OrganicData.cs
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
|
||||||
|
using EDPlayerJournal.Entries;
|
||||||
|
|
||||||
|
namespace EDPlayerJournal.BGS;
|
||||||
|
|
||||||
|
public class OrganicData : Transaction {
|
||||||
|
public OrganicData() { }
|
||||||
|
|
||||||
|
public OrganicData(SellOrganicDataEntry e) {
|
||||||
|
Entries.Add(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
public long TotalValue {
|
||||||
|
get {
|
||||||
|
return Entries.OfType<SellOrganicDataEntry>().Sum(x => x.TotalValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override int CompareTo(Transaction? other) {
|
||||||
|
if (other == null || other.GetType() != typeof(OrganicData)) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (other?.Faction == Faction &&
|
||||||
|
other?.System == System &&
|
||||||
|
other?.Station == Station) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string ToString() {
|
||||||
|
return string.Format("Sold {0} worth of organic data to Vista Genomics",
|
||||||
|
Credits.FormatCredits(TotalValue)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Selling organic data only helps the controlling faction, just like
|
||||||
|
* selling cartographic data.
|
||||||
|
*
|
||||||
|
* Right now: Organic data helps no one.
|
||||||
|
*/
|
||||||
|
public override bool OnlyControllingFaction => true;
|
||||||
|
}
|
15
EDPlayerJournal/BGS/Parsers/ApproachSettlementParser.cs
Normal file
15
EDPlayerJournal/BGS/Parsers/ApproachSettlementParser.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
using EDPlayerJournal.Entries;
|
||||||
|
|
||||||
|
namespace EDPlayerJournal.BGS.Parsers;
|
||||||
|
|
||||||
|
internal class ApproachSettlementParser : ITransactionParserPart {
|
||||||
|
public void Parse(Entry entry, TransactionParserContext context, TransactionParserOptions options, TransactionList transactions) {
|
||||||
|
ApproachSettlementEntry? approach = entry as ApproachSettlementEntry;
|
||||||
|
if (approach == null || string.IsNullOrEmpty(approach.Name)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
context.Settlement = approach.Name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
30
EDPlayerJournal/BGS/Parsers/CarrierJumpParser.cs
Normal file
30
EDPlayerJournal/BGS/Parsers/CarrierJumpParser.cs
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
using EDPlayerJournal.Entries;
|
||||||
|
|
||||||
|
namespace EDPlayerJournal.BGS.Parsers;
|
||||||
|
|
||||||
|
internal class CarrierJumpParser : ITransactionParserPart {
|
||||||
|
public void Parse(Entry entry, TransactionParserContext context, TransactionParserOptions options, TransactionList transactions) {
|
||||||
|
CarrierJump? jump = entry as CarrierJump;
|
||||||
|
|
||||||
|
if (jump == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!jump.Docked) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
context.CurrentSystem = jump.StarSystem;
|
||||||
|
context.CurrentSystemAddress = jump.SystemAddress;
|
||||||
|
|
||||||
|
context.SystemsByID.TryAdd(jump.SystemAddress, jump.StarSystem);
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(jump.SystemFaction)) {
|
||||||
|
context.ControllingFaction = jump.SystemFaction;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (jump.SystemFactions != null && jump.SystemFactions.Count > 0) {
|
||||||
|
context.SystemFactions[jump.StarSystem] = jump.SystemFactions;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
17
EDPlayerJournal/BGS/Parsers/CommanderParser.cs
Normal file
17
EDPlayerJournal/BGS/Parsers/CommanderParser.cs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
using EDPlayerJournal.BGS;
|
||||||
|
using EDPlayerJournal.Entries;
|
||||||
|
|
||||||
|
internal class CommanderParser : ITransactionParserPart {
|
||||||
|
public void Parse(Entry entry, TransactionParserContext context, TransactionParserOptions options, TransactionList transactions) {
|
||||||
|
CommanderEntry commanderEntry = (CommanderEntry)entry;
|
||||||
|
if (commanderEntry != null && !string.IsNullOrEmpty(commanderEntry.FullName)) {
|
||||||
|
if (!context.Commanders.Contains(commanderEntry.FullName)) {
|
||||||
|
context.Commanders.Add(commanderEntry.FullName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// A commander entry happens when you log out, and log back in again
|
||||||
|
// for example when switching from Open, to Solo or PG.
|
||||||
|
context.DiscernCombatZone(transactions, entry);
|
||||||
|
context.ResetCombatZone();
|
||||||
|
}
|
||||||
|
}
|
44
EDPlayerJournal/BGS/Parsers/MarketBuyParser.cs
Normal file
44
EDPlayerJournal/BGS/Parsers/MarketBuyParser.cs
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
using EDPlayerJournal.Entries;
|
||||||
|
|
||||||
|
namespace EDPlayerJournal.BGS;
|
||||||
|
|
||||||
|
internal class MarketBuyParser : ITransactionParserPart {
|
||||||
|
public void Parse(Entry e, TransactionParserContext context, TransactionParserOptions options, TransactionList transactions) {
|
||||||
|
MarketBuyEntry? entry = e as MarketBuyEntry;
|
||||||
|
if (entry == null) {
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
context.BoughtCargo(entry.Type, entry.BuyPrice);
|
||||||
|
|
||||||
|
// We still want the information on buy price for profit,
|
||||||
|
// but if the option is on, we don't care for parsing it
|
||||||
|
// further.
|
||||||
|
// TODO: might be wise to split this parser into two; one for
|
||||||
|
// determining profit, the other for the BGS information
|
||||||
|
if (options.IgnoreMarketBuy) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (context.StationOwner == null) {
|
||||||
|
transactions.AddIncomplete(
|
||||||
|
new BuyCargo(),
|
||||||
|
"Could not discern the station owner for market buy.",
|
||||||
|
e);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ignore if its a fleet carrier faction.
|
||||||
|
if (string.Compare(context.StationOwner, Factions.FleetCarrier, StringComparison.OrdinalIgnoreCase) == 0 &&
|
||||||
|
options.IgnoreFleetCarrierFaction) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
transactions.Add(new BuyCargo(entry) {
|
||||||
|
System = context.CurrentSystem,
|
||||||
|
Station = context.CurrentStation,
|
||||||
|
Faction = context.StationOwner,
|
||||||
|
IsLegacy = context.IsLegacy,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
45
EDPlayerJournal/BGS/Parsers/MarketSellParser.cs
Normal file
45
EDPlayerJournal/BGS/Parsers/MarketSellParser.cs
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
using EDPlayerJournal.Entries;
|
||||||
|
|
||||||
|
namespace EDPlayerJournal.BGS;
|
||||||
|
|
||||||
|
internal class MarketSellParser : ITransactionParserPart {
|
||||||
|
public void Parse(Entry e, TransactionParserContext context, TransactionParserOptions options, TransactionList transactions) {
|
||||||
|
long profit = 0;
|
||||||
|
|
||||||
|
if (context.StationOwner == null) {
|
||||||
|
transactions.AddIncomplete(
|
||||||
|
new SellCargo(),
|
||||||
|
"Could not discern the station owner market sell.",
|
||||||
|
e);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ignore if its a fleet carrier faction.
|
||||||
|
if (string.Compare(context.StationOwner, Factions.FleetCarrier, StringComparison.OrdinalIgnoreCase) == 0 &&
|
||||||
|
options.IgnoreFleetCarrierFaction) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
MarketSellEntry? entry = e as MarketSellEntry;
|
||||||
|
if (entry == null) {
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entry.Type == null) {
|
||||||
|
throw new InvalidJournalEntryException("market sell contains no cargo type");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (context.BuyCost.ContainsKey(entry.Type)) {
|
||||||
|
long avg = context.BuyCost[entry.Type];
|
||||||
|
profit = (long)entry.TotalSale - (avg * entry.Count);
|
||||||
|
}
|
||||||
|
|
||||||
|
transactions.Add(new SellCargo(entry) {
|
||||||
|
System = context.CurrentSystem,
|
||||||
|
Station = context.CurrentStation,
|
||||||
|
Faction = context.StationOwner,
|
||||||
|
Profit = profit,
|
||||||
|
IsLegacy = context.IsLegacy,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
using EDPlayerJournal.Entries;
|
||||||
|
|
||||||
|
namespace EDPlayerJournal.BGS;
|
||||||
|
|
||||||
|
internal class MultiSellExplorationDataParser : ITransactionParserPart {
|
||||||
|
public void Parse(Entry e, TransactionParserContext context, TransactionParserOptions options, TransactionList transactions) {
|
||||||
|
MultiSellExplorationDataEntry? entry = e as MultiSellExplorationDataEntry;
|
||||||
|
if (entry == null) {
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (context.StationOwner == null) {
|
||||||
|
transactions.AddIncomplete(
|
||||||
|
new Cartographics(),
|
||||||
|
"Could not discern the station owner for cartographics sell.",
|
||||||
|
e);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ignore if its a fleet carrier faction.
|
||||||
|
if (string.Compare(context.StationOwner, Factions.FleetCarrier, StringComparison.OrdinalIgnoreCase) == 0 &&
|
||||||
|
options.IgnoreFleetCarrierFaction) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
transactions.Add(new Cartographics(entry) {
|
||||||
|
System = context.CurrentSystem,
|
||||||
|
Station = context.CurrentStation,
|
||||||
|
Faction = context.StationOwner,
|
||||||
|
IsLegacy = context.IsLegacy,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
17
EDPlayerJournal/BGS/Parsers/MusicParser.cs
Normal file
17
EDPlayerJournal/BGS/Parsers/MusicParser.cs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
using EDPlayerJournal.Entries;
|
||||||
|
|
||||||
|
namespace EDPlayerJournal.BGS.Parsers;
|
||||||
|
|
||||||
|
internal class MusicParser : ITransactionParserPart {
|
||||||
|
public void Parse(Entry entry, TransactionParserContext context, TransactionParserOptions options, TransactionList transactions) {
|
||||||
|
MusicEntry? entryMusic = (MusicEntry)entry;
|
||||||
|
|
||||||
|
if (entryMusic == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.Compare(entryMusic.MusicTrack, "Combat_CapitalShip") == 0) {
|
||||||
|
context.HaveSeenCapShip = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
31
EDPlayerJournal/BGS/Parsers/PowerplayMeritsParser.cs
Normal file
31
EDPlayerJournal/BGS/Parsers/PowerplayMeritsParser.cs
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
using EDPlayerJournal.Entries;
|
||||||
|
|
||||||
|
namespace EDPlayerJournal.BGS.Parsers;
|
||||||
|
|
||||||
|
internal class PowerplayMeritsParser : ITransactionParserPart {
|
||||||
|
public void Parse(Entry entry, TransactionParserContext context, TransactionParserOptions options, TransactionList transactions) {
|
||||||
|
PowerplayMeritsEntry? e = entry as PowerplayMeritsEntry;
|
||||||
|
if (e == null) {
|
||||||
|
throw new ApplicationException("not a valid PowerplayMerits entry");
|
||||||
|
}
|
||||||
|
|
||||||
|
MeritsGained? transaction = null;
|
||||||
|
|
||||||
|
transaction = transactions
|
||||||
|
.OfType<MeritsGained>()
|
||||||
|
.Where(x => x.System == context.CurrentSystem &&
|
||||||
|
x.Power == e.Power)
|
||||||
|
.FirstOrDefault()
|
||||||
|
;
|
||||||
|
if (transaction == null) {
|
||||||
|
transaction = new MeritsGained(e) {
|
||||||
|
System = context.CurrentSystem,
|
||||||
|
Power = e.Power,
|
||||||
|
Faction = e.Power,
|
||||||
|
};
|
||||||
|
transactions.Add(transaction);
|
||||||
|
} else {
|
||||||
|
transaction.Entries.Add(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
84
EDPlayerJournal/BGS/Parsers/RedeemVoucherParser.cs
Normal file
84
EDPlayerJournal/BGS/Parsers/RedeemVoucherParser.cs
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
using EDPlayerJournal.Entries;
|
||||||
|
|
||||||
|
namespace EDPlayerJournal.BGS.Parsers;
|
||||||
|
|
||||||
|
internal class RedeemVoucherParser : ITransactionParserPart {
|
||||||
|
public void Parse(Entry e, TransactionParserContext context, TransactionParserOptions options, TransactionList transactions) {
|
||||||
|
RedeemVoucherEntry? entry = e as RedeemVoucherEntry;
|
||||||
|
if (entry == null) {
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (context.CurrentSystem == null) {
|
||||||
|
transactions.AddIncomplete(new Vouchers(),
|
||||||
|
"Could not find out where the vouchers were redeemed", e
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Faction>? current_factions = context.GetFactions(context.CurrentSystem);
|
||||||
|
if (current_factions == null) {
|
||||||
|
transactions.AddIncomplete(new Vouchers(),
|
||||||
|
"Current system factions are unknown, so vouchers were ineffective", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (string faction in entry.Factions) {
|
||||||
|
bool relevantBond = false;
|
||||||
|
string relevantFaction = faction;
|
||||||
|
|
||||||
|
if (string.Compare(faction, Factions.PilotsFederationVouchers) == 0) {
|
||||||
|
// Target faction is pilots' federation, so we assume thargoid bonks
|
||||||
|
// Also assign this combat bond to the Pilots Federation
|
||||||
|
relevantFaction = Factions.PilotsFederation;
|
||||||
|
relevantBond = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (current_factions != null && !relevantBond) {
|
||||||
|
// If we have local factions, and it ain't thargoid bonds see if the bonds were
|
||||||
|
// useful in the current system
|
||||||
|
if (current_factions.Find(x => string.Compare(x.Name, faction, true) == 0) != null) {
|
||||||
|
relevantBond = true;
|
||||||
|
} else {
|
||||||
|
transactions.AddIncomplete(new Vouchers(),
|
||||||
|
string.Format("Vouchers for \"{0}\" had no effect in \"{1}\" since said " +
|
||||||
|
"faction is not present there", faction, context.CurrentSystem), e
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!relevantBond) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
var voucher = new Vouchers(entry) {
|
||||||
|
System = context.CurrentSystem,
|
||||||
|
Station = context.CurrentStation,
|
||||||
|
Faction = relevantFaction,
|
||||||
|
ControllingFaction = context.ControllingFaction,
|
||||||
|
IsLegacy = context.IsLegacy,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (options.FilterDoubleRedeemVouchers) {
|
||||||
|
// To filter out doubly redeemed vouchers, find another redeem voucher
|
||||||
|
// event that happened in the same system, same total sum, and also the
|
||||||
|
// same faction. If there is one, filter this one out.
|
||||||
|
var doubledEntry = transactions
|
||||||
|
.OfType<Vouchers>()
|
||||||
|
.Where(x => x.TotalSum == voucher.TotalSum &&
|
||||||
|
x.System == voucher.System &&
|
||||||
|
x.Faction == voucher.Faction)
|
||||||
|
.ToList()
|
||||||
|
;
|
||||||
|
if (doubledEntry.Count > 0) {
|
||||||
|
transactions.AddIncomplete(
|
||||||
|
voucher,
|
||||||
|
string.Format("A doubled redeem voucher for {0} valued {1} was detected",
|
||||||
|
voucher.Faction, Credits.FormatMillions(voucher.TotalSum)),
|
||||||
|
e);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
transactions.Add(voucher);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
33
EDPlayerJournal/BGS/Parsers/SellExplorationDataParser.cs
Normal file
33
EDPlayerJournal/BGS/Parsers/SellExplorationDataParser.cs
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
using EDPlayerJournal.Entries;
|
||||||
|
|
||||||
|
namespace EDPlayerJournal.BGS;
|
||||||
|
|
||||||
|
internal class SellExplorationDataParser : ITransactionParserPart {
|
||||||
|
public void Parse(Entry e, TransactionParserContext context, TransactionParserOptions options, TransactionList transactions) {
|
||||||
|
SellExplorationDataEntry? entry = e as SellExplorationDataEntry;
|
||||||
|
if (entry == null) {
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (context.StationOwner == null) {
|
||||||
|
transactions.AddIncomplete(
|
||||||
|
new Cartographics(),
|
||||||
|
"Could not discern the station owner for cartographics sell.",
|
||||||
|
e);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ignore if its a fleet carrier faction.
|
||||||
|
if (string.Compare(context.StationOwner, Factions.FleetCarrier, StringComparison.OrdinalIgnoreCase) == 0 &&
|
||||||
|
options.IgnoreFleetCarrierFaction) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
transactions.Add(new Cartographics(entry) {
|
||||||
|
System = context.CurrentSystem,
|
||||||
|
Station = context.CurrentStation,
|
||||||
|
Faction = context.StationOwner,
|
||||||
|
IsLegacy = context.IsLegacy,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
38
EDPlayerJournal/BGS/Parsers/SellOrganicDataParser.cs
Normal file
38
EDPlayerJournal/BGS/Parsers/SellOrganicDataParser.cs
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
using EDPlayerJournal.Entries;
|
||||||
|
|
||||||
|
namespace EDPlayerJournal.BGS;
|
||||||
|
|
||||||
|
internal class SellOrganicDataParser : ITransactionParserPart {
|
||||||
|
public void Parse(Entry e, TransactionParserContext context, TransactionParserOptions options, TransactionList transactions) {
|
||||||
|
// If exo biology is ignored, simply do nothing
|
||||||
|
if (options.IgnoreExoBiology) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SellOrganicDataEntry? entry = e as SellOrganicDataEntry;
|
||||||
|
if (entry == null) {
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (context.StationOwner == null) {
|
||||||
|
transactions.AddIncomplete(
|
||||||
|
new OrganicData(),
|
||||||
|
"Could not discern the station owner for organic data sell.",
|
||||||
|
e);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ignore if its a fleet carrier faction.
|
||||||
|
if (string.Compare(context.StationOwner, Factions.FleetCarrier, StringComparison.OrdinalIgnoreCase) == 0 &&
|
||||||
|
options.IgnoreFleetCarrierFaction) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
transactions.Add(new OrganicData(entry) {
|
||||||
|
System = context.CurrentSystem,
|
||||||
|
Station = context.CurrentStation,
|
||||||
|
Faction = context.StationOwner,
|
||||||
|
IsLegacy = context.IsLegacy,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
65
EDPlayerJournal/BGS/Parsers/ShipTargetedParser.cs
Normal file
65
EDPlayerJournal/BGS/Parsers/ShipTargetedParser.cs
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
using EDPlayerJournal.Entries;
|
||||||
|
|
||||||
|
namespace EDPlayerJournal.BGS;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// With ship targeted we might find out to which faction a given NPC belonged. This is
|
||||||
|
/// useful later when said NPC gets killed or murdered.
|
||||||
|
/// </summary>
|
||||||
|
internal class ShipTargetedParser : ITransactionParserPart {
|
||||||
|
public void Parse(Entry e, TransactionParserContext context, TransactionParserOptions options, TransactionList transactions) {
|
||||||
|
ShipTargetedEntry? entry = e as ShipTargetedEntry;
|
||||||
|
if (entry == null) {
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Scan happens in stages, and sometimes this information is not known
|
||||||
|
// yet. Do now throw an error, this is expected behaviour.
|
||||||
|
if (!string.IsNullOrEmpty(entry.PilotNameLocalised) &&
|
||||||
|
!string.IsNullOrEmpty(entry.Faction)) {
|
||||||
|
context.NPCFaction.TryAdd(entry.PilotNameLocalised, entry.Faction);
|
||||||
|
}
|
||||||
|
|
||||||
|
string? faction = context.LastRecordedAwardingFaction;
|
||||||
|
|
||||||
|
// We have seen a captain?
|
||||||
|
if (NPCs.IsWarzoneCaptain(entry.PilotName)) {
|
||||||
|
// if we have faction information, we can compare it to figure out
|
||||||
|
// whether it is the enemy or allied faction. but this is not always
|
||||||
|
// possible. In such a case we assume we have seen the enemy captain.
|
||||||
|
if (!string.IsNullOrEmpty(entry.Faction) &&
|
||||||
|
!string.IsNullOrEmpty(faction)) {
|
||||||
|
if (string.Compare(faction, entry.Faction) != 0) {
|
||||||
|
context.HaveSeenEnemyCaptain = true;
|
||||||
|
} else {
|
||||||
|
context.HaveSeenAlliedCaptain = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
context.HaveSeenEnemyCaptain = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Spec ops?
|
||||||
|
if (NPCs.IsSpecOps(entry.PilotName)) {
|
||||||
|
context.HaveSeenSpecOps = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Correspondent?
|
||||||
|
if (NPCs.IsWarzoneCorrespondent(entry.PilotName)) {
|
||||||
|
// if we have faction information, we can compare it to figure out
|
||||||
|
// whether it is the enemy or allied faction. but this is not always
|
||||||
|
// possible. In such a case we assume we have seen the enemy
|
||||||
|
// correspondent.
|
||||||
|
if (!string.IsNullOrEmpty(entry.Faction) &&
|
||||||
|
!string.IsNullOrEmpty(faction)) {
|
||||||
|
if (string.Compare(faction, entry.Faction) != 0) {
|
||||||
|
context.HaveSeenEnemyCorrespondent = true;
|
||||||
|
} else {
|
||||||
|
context.HaveSeenAlliedCorrespondent = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
context.HaveSeenEnemyCorrespondent = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
using EDPlayerJournal.Entries;
|
||||||
|
|
||||||
|
namespace EDPlayerJournal.BGS.Parsers;
|
||||||
|
|
||||||
|
internal class SupercruiseDestinationDropParser : ITransactionParserPart {
|
||||||
|
public void Parse(Entry entry, TransactionParserContext context, TransactionParserOptions options, TransactionList transactions) {
|
||||||
|
SupercruiseDestinationDropEntry? drop = entry as SupercruiseDestinationDropEntry;
|
||||||
|
if (drop == null || drop.Type == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
context.CurrentInstanceType = drop.Type;
|
||||||
|
}
|
||||||
|
}
|
53
EDPlayerJournal/BGS/SearchAndRescue.cs
Normal file
53
EDPlayerJournal/BGS/SearchAndRescue.cs
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
using EDPlayerJournal.Entries;
|
||||||
|
|
||||||
|
namespace EDPlayerJournal.BGS;
|
||||||
|
public class SearchAndRescue : Transaction {
|
||||||
|
public SearchAndRescue (SearchAndRescueEntry e) {
|
||||||
|
Entries.Add(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
public long Count {
|
||||||
|
get {
|
||||||
|
return Entries.OfType<SearchAndRescueEntry>().Sum(x => x.Count);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public long Reward {
|
||||||
|
get {
|
||||||
|
return Entries.OfType<SearchAndRescueEntry>().Sum(x => x.Reward);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string? NameLocalised {
|
||||||
|
get {
|
||||||
|
return Entries.OfType<SearchAndRescueEntry>().First().NameLocalised;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override int CompareTo(Transaction? 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 ({2})",
|
||||||
|
Count,
|
||||||
|
NameLocalised,
|
||||||
|
Credits.FormatCredits(Reward)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool OnlyControllingFaction => true;
|
||||||
|
}
|
74
EDPlayerJournal/BGS/SellCargo.cs
Normal file
74
EDPlayerJournal/BGS/SellCargo.cs
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
using System.Text;
|
||||||
|
using EDPlayerJournal.Entries;
|
||||||
|
|
||||||
|
namespace EDPlayerJournal.BGS;
|
||||||
|
public class SellCargo : Transaction {
|
||||||
|
public long Profit { get; set; }
|
||||||
|
|
||||||
|
public SellCargo() { }
|
||||||
|
|
||||||
|
public SellCargo(MarketSellEntry e) {
|
||||||
|
Entries.Add(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string? Cargo {
|
||||||
|
get {
|
||||||
|
string? cargo;
|
||||||
|
var sell = Entries.OfType<MarketSellEntry>().First();
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(sell.TypeLocalised)) {
|
||||||
|
cargo = sell.TypeLocalised;
|
||||||
|
} else {
|
||||||
|
cargo = sell.Type;
|
||||||
|
if (cargo != null && cargo.Length >= 2) {
|
||||||
|
cargo = cargo[0].ToString().ToUpper() + cargo.Substring(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return cargo;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Market {
|
||||||
|
get {
|
||||||
|
var sell = Entries.OfType<MarketSellEntry>().First();
|
||||||
|
return sell.BlackMarket ? "Black Market" : "Commodity Market";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public long Amount {
|
||||||
|
get { return Entries.OfType<MarketSellEntry>().Sum(x => x.Count); }
|
||||||
|
}
|
||||||
|
|
||||||
|
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} of {3}",
|
||||||
|
sell.Count,
|
||||||
|
Cargo,
|
||||||
|
Market,
|
||||||
|
Station
|
||||||
|
);
|
||||||
|
|
||||||
|
if (Profit != 0) {
|
||||||
|
builder.AppendFormat(" ({0} {1})",
|
||||||
|
Credits.FormatCredits(Profit),
|
||||||
|
Profit < 0 ? "loss" : "profit"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return builder.ToString().Trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Selling resources to a market only helps the controlling faction
|
||||||
|
/// </summary>
|
||||||
|
public override bool OnlyControllingFaction => true;
|
||||||
|
}
|
26
EDPlayerJournal/BGS/SellMicroResources.cs
Normal file
26
EDPlayerJournal/BGS/SellMicroResources.cs
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
using System.Linq;
|
||||||
|
using EDPlayerJournal.Entries;
|
||||||
|
|
||||||
|
namespace EDPlayerJournal.BGS;
|
||||||
|
public class SellMicroResources : Transaction {
|
||||||
|
public int TotalSum {
|
||||||
|
get {
|
||||||
|
return Entries
|
||||||
|
.OfType<SellMicroResourcesEntry>()
|
||||||
|
.Sum(x => x.Price)
|
||||||
|
;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public SellMicroResources() { }
|
||||||
|
|
||||||
|
public SellMicroResources(SellMicroResourcesEntry e) {
|
||||||
|
Entries.Add(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string ToString() {
|
||||||
|
return string.Format("Sell Micro Resources: {0}", Credits.FormatCredits(TotalSum));
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool OnlyControllingFaction => true;
|
||||||
|
}
|
47
EDPlayerJournal/BGS/ThargoidKill.cs
Normal file
47
EDPlayerJournal/BGS/ThargoidKill.cs
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
using EDPlayerJournal.Entries;
|
||||||
|
|
||||||
|
namespace EDPlayerJournal.BGS;
|
||||||
|
|
||||||
|
public class ThargoidKill : Transaction {
|
||||||
|
/// <summary>
|
||||||
|
/// Thargoid vessel that was killed
|
||||||
|
/// </summary>
|
||||||
|
public ThargoidVessel ThargoidType { get; set; } = ThargoidVessel.Unknown;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Name of the thargoid type killed
|
||||||
|
/// </summary>
|
||||||
|
public string? ThargoidName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Total reward received
|
||||||
|
/// </summary>
|
||||||
|
public ulong TotalReward {
|
||||||
|
get { return (ulong)Entries.OfType<FactionKillBondEntry>().Sum(x => (decimal)x.Reward); }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Kiling thargoids contributes to the system wide effort of
|
||||||
|
/// the thargoid war.
|
||||||
|
/// </summary>
|
||||||
|
public override bool SystemContribution {
|
||||||
|
get { return true; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public ThargoidKill() { }
|
||||||
|
|
||||||
|
public ThargoidKill(FactionKillBondEntry entry) {
|
||||||
|
if (!Factions.IsThargoid(entry.VictimFaction)) {
|
||||||
|
throw new Exception("Not a valid thargoid kill");
|
||||||
|
}
|
||||||
|
|
||||||
|
Entries.Add(entry);
|
||||||
|
|
||||||
|
ThargoidType = Thargoid.GetVesselByPayout(entry.Reward);
|
||||||
|
ThargoidName = Thargoid.GetVesselName(ThargoidType);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string ToString() {
|
||||||
|
return string.Format("{0}x {1} killed", Entries.Count, ThargoidName);
|
||||||
|
}
|
||||||
|
}
|
71
EDPlayerJournal/BGS/Transaction.cs
Normal file
71
EDPlayerJournal/BGS/Transaction.cs
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
using EDPlayerJournal.Entries;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
|
namespace EDPlayerJournal.BGS;
|
||||||
|
|
||||||
|
public class Transaction : IComparable<Transaction> {
|
||||||
|
public List<Entry> Entries { get; } = new List<Entry>();
|
||||||
|
|
||||||
|
public string CompletedAt {
|
||||||
|
get {
|
||||||
|
DateTime? datetime = CompletedAtDateTime;
|
||||||
|
if (datetime == null) {
|
||||||
|
return "Unknown";
|
||||||
|
}
|
||||||
|
|
||||||
|
return datetime.Value.ToString("dd.MM.yyyy HH:mm UTC");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual DateTime? CompletedAtDateTime {
|
||||||
|
get {
|
||||||
|
var items = Entries
|
||||||
|
.OrderBy(x => x.Timestamp)
|
||||||
|
.ToArray()
|
||||||
|
;
|
||||||
|
if (items == null || items.Length == 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Entry last = items.Last();
|
||||||
|
return last.Timestamp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether the transaction helps the entire system.
|
||||||
|
/// While all transactions are related to one faction, sometimes their
|
||||||
|
/// overall effect on the system as a whole is more important, than to
|
||||||
|
/// their faction. For example, rescuing refugees helps the Thargoid war
|
||||||
|
/// effort in the system as a whole, not just for the faction.
|
||||||
|
/// So this is true for transactions that help the system as a whole.
|
||||||
|
/// </summary>
|
||||||
|
public virtual bool SystemContribution { get; } = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns true if this transaction was completed in legacy ED
|
||||||
|
/// </summary>
|
||||||
|
public bool IsLegacy { get; set; } = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Controlling faction of the station this entry was made/turned into.
|
||||||
|
/// </summary>
|
||||||
|
public string? ControllingFaction { get; set; }
|
||||||
|
public string? Station { get; set; }
|
||||||
|
public string? System { get; set; }
|
||||||
|
public ulong SystemAddress { get; set; }
|
||||||
|
public string? Faction { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether this transaction type only benefits the controlling faction or not, default: no
|
||||||
|
/// </summary>
|
||||||
|
public virtual bool OnlyControllingFaction {
|
||||||
|
get { return false; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual int CompareTo(Transaction? other) {
|
||||||
|
throw new NotImplementedException("not implemented");
|
||||||
|
}
|
||||||
|
|
||||||
|
public string? Name => ToString();
|
||||||
|
}
|
709
EDPlayerJournal/BGS/TransactionParser.cs
Normal file
709
EDPlayerJournal/BGS/TransactionParser.cs
Normal file
@ -0,0 +1,709 @@
|
|||||||
|
using EDPlayerJournal.BGS.Parsers;
|
||||||
|
using EDPlayerJournal.Entries;
|
||||||
|
|
||||||
|
namespace EDPlayerJournal.BGS;
|
||||||
|
|
||||||
|
public class TransactionParserOptions {
|
||||||
|
/// <summary>
|
||||||
|
/// Whether to ignore exo biology. It does not contribute to BGS, so this
|
||||||
|
/// is true per default.
|
||||||
|
/// </summary>
|
||||||
|
public bool IgnoreExoBiology { get; set; } = true;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether to ignore influence support. Usually one only cares about the
|
||||||
|
/// primary faction for the influence.
|
||||||
|
/// </summary>
|
||||||
|
public bool IgnoreInfluenceSupport { get; set; } = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether we ignore power play and merits gained for now. Support for this
|
||||||
|
/// is experimental at the moment, so that is why it ist `true`.
|
||||||
|
/// </summary>
|
||||||
|
public bool IgnorePowerplay { get; set; } = true;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether to ignore market buy. Buying from a market gives a small amount
|
||||||
|
/// of INF if it is sold to a high demand market, but generally one buys from
|
||||||
|
/// a market to aid the faction the stuff is being sold to. So allow it to be
|
||||||
|
/// disabled.
|
||||||
|
/// </summary>
|
||||||
|
public bool IgnoreMarketBuy { get; set; } = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether we should ignore things done for the fleet carrier faction.
|
||||||
|
/// </summary>
|
||||||
|
public bool IgnoreFleetCarrierFaction { get; set; } = true;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Filter out double redeem vouchers that happen when you redeem a specific
|
||||||
|
/// voucher, and then redeem the rest of your vouchers (say from a KWS) in
|
||||||
|
/// bulk. The bulk redeem will also list the first voucher redeem again in
|
||||||
|
/// its bulk list.
|
||||||
|
/// </summary>
|
||||||
|
public bool FilterDoubleRedeemVouchers { get; set; } = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class TransactionList : List<Transaction> {
|
||||||
|
public void AddIncomplete(Transaction underlying, string reason, Entry entry) {
|
||||||
|
Add(new IncompleteTransaction(underlying, reason, entry));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The location parser only updates the context with useful information, and does not
|
||||||
|
/// by itself generate any transactions. Location is the best information gatherer here
|
||||||
|
/// as we are getting controlling faction, system factions, address and station name.
|
||||||
|
/// </summary>
|
||||||
|
internal class LocationParser : ITransactionParserPart {
|
||||||
|
public void Parse(Entry e, TransactionParserContext context, TransactionParserOptions options, TransactionList transactions) {
|
||||||
|
LocationEntry? entry = e as LocationEntry;
|
||||||
|
if (entry == null) {
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entry.StarSystem == null) {
|
||||||
|
throw new InvalidJournalEntryException();
|
||||||
|
}
|
||||||
|
|
||||||
|
context.CurrentSystem = entry.StarSystem;
|
||||||
|
context.CurrentSystemAddress = entry.SystemAddress;
|
||||||
|
|
||||||
|
context.SystemsByID.TryAdd(entry.SystemAddress, entry.StarSystem);
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(entry.SystemFaction)) {
|
||||||
|
context.ControllingFaction = entry.SystemFaction;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(entry.StationName)) {
|
||||||
|
context.CurrentStation = entry.StationName;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(entry.StationFaction)) {
|
||||||
|
context.StationOwner = entry.StationFaction;
|
||||||
|
} else {
|
||||||
|
context.StationOwner = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entry.SystemFactions != null && entry.SystemFactions.Count > 0) {
|
||||||
|
context.SystemFactions[entry.StarSystem] = entry.SystemFactions;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class FSDJumpParser : ITransactionParserPart {
|
||||||
|
public void Parse(Entry e, TransactionParserContext context, TransactionParserOptions options, TransactionList transactions) {
|
||||||
|
FSDJumpEntry? entry = e as FSDJumpEntry;
|
||||||
|
if (entry == null) {
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entry.StarSystem == null) {
|
||||||
|
throw new InvalidJournalEntryException();
|
||||||
|
}
|
||||||
|
|
||||||
|
// If you FSD jump straight out of the combat zone into a different system
|
||||||
|
// then the combat zone will be placed in the wrong system otherwise.
|
||||||
|
// This call needs to be *before* changing the current system.
|
||||||
|
context.DiscernCombatZone(transactions, e);
|
||||||
|
context.ResetCombatZone();
|
||||||
|
|
||||||
|
context.LeftInstance();
|
||||||
|
|
||||||
|
context.CurrentSystem = entry.StarSystem;
|
||||||
|
context.CurrentSystemAddress = entry.SystemAddress;
|
||||||
|
|
||||||
|
context.SystemsByID.TryAdd(entry.SystemAddress, entry.StarSystem);
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(entry.SystemFaction)) {
|
||||||
|
context.ControllingFaction = entry.SystemFaction;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entry.SystemFactions != null && entry.SystemFactions.Count > 0) {
|
||||||
|
context.SystemFactions[entry.StarSystem] = entry.SystemFactions;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class DockedParser : ITransactionParserPart {
|
||||||
|
public void Parse(Entry e, TransactionParserContext context, TransactionParserOptions options, TransactionList transactions) {
|
||||||
|
DockedEntry? entry = e as DockedEntry;
|
||||||
|
if (entry == null) {
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entry.StarSystem == null || entry.SystemAddress == null) {
|
||||||
|
throw new InvalidJournalEntryException();
|
||||||
|
}
|
||||||
|
|
||||||
|
context.CurrentSystem = entry.StarSystem;
|
||||||
|
context.CurrentSystemAddress = entry.SystemAddress;
|
||||||
|
|
||||||
|
context.SystemsByID.TryAdd(entry.SystemAddress.Value, entry.StarSystem);
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(entry.StationFaction)) {
|
||||||
|
context.StationOwner = entry.StationFaction;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(entry.StationName)) {
|
||||||
|
context.CurrentStation = entry.StationName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Commit crime can result in a transaction, especially if the crime committed is
|
||||||
|
/// murder.
|
||||||
|
/// </summary>
|
||||||
|
internal class CommitCrimeParser : ITransactionParserPart {
|
||||||
|
public void Parse(Entry e, TransactionParserContext context, TransactionParserOptions options, TransactionList transactions) {
|
||||||
|
CommitCrimeEntry? entry = e as CommitCrimeEntry;
|
||||||
|
if (entry == null) {
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Right now we only care for murder
|
||||||
|
if (!entry.IsMurder) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
string? victim = entry.Victim;
|
||||||
|
|
||||||
|
if (victim == null) {
|
||||||
|
victim = entry.VictimLocalised;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If they were not properly scanned prior to the murder we do not have
|
||||||
|
// This information. But in the end the name of the NPC does not matter.
|
||||||
|
if (victim == null) {
|
||||||
|
victim = "Unknown";
|
||||||
|
}
|
||||||
|
|
||||||
|
string faction;
|
||||||
|
|
||||||
|
if (entry.IsCrime(CrimeTypes.OnFootMurder)) {
|
||||||
|
if (entry.Faction == null) {
|
||||||
|
transactions.AddIncomplete(
|
||||||
|
new FoulMurder(),
|
||||||
|
"On foot murder victim did not have a faction", e
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// On foot murders are different, there the faction is
|
||||||
|
// the faction the NPC belonged too
|
||||||
|
faction = entry.Faction;
|
||||||
|
} else {
|
||||||
|
if (!context.NPCFaction.ContainsKey(victim)) {
|
||||||
|
transactions.AddIncomplete(
|
||||||
|
new FoulMurder(),
|
||||||
|
"Crime victim was not properly scanned.", e
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
faction = context.NPCFaction[victim];
|
||||||
|
}
|
||||||
|
|
||||||
|
transactions.Add(new FoulMurder(entry) {
|
||||||
|
System = context.CurrentSystem,
|
||||||
|
IsLegacy = context.IsLegacy,
|
||||||
|
Faction = faction,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class MissionsParser : ITransactionParserPart {
|
||||||
|
public void Parse(Entry entry, TransactionParserContext context, TransactionParserOptions options, TransactionList transactions) {
|
||||||
|
MissionsEntry? missions = entry as MissionsEntry;
|
||||||
|
|
||||||
|
if (missions == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (context.CurrentSystem == null || context.CurrentSystemAddress == null) {
|
||||||
|
transactions.AddIncomplete(new MissionCompleted(),
|
||||||
|
"Could not determine current location on Missions event.",
|
||||||
|
entry
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (Mission mission in missions.Active) {
|
||||||
|
try {
|
||||||
|
context.MissionAccepted(mission);
|
||||||
|
} catch (Exception exception) {
|
||||||
|
transactions.AddIncomplete(new MissionCompleted(),
|
||||||
|
exception.Message,
|
||||||
|
entry
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class MissionAcceptedParser : ITransactionParserPart {
|
||||||
|
public void Parse(Entry e, TransactionParserContext context, TransactionParserOptions options, TransactionList transactions) {
|
||||||
|
MissionAcceptedEntry? entry = e as MissionAcceptedEntry;
|
||||||
|
if (entry == null) {
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (context.CurrentSystem == null || context.CurrentSystemAddress == null) {
|
||||||
|
transactions.AddIncomplete(new MissionCompleted(),
|
||||||
|
"Could not determine current location on mission acceptance.",
|
||||||
|
e
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
context.MissionAccepted(entry);
|
||||||
|
} catch (Exception exception) {
|
||||||
|
transactions.AddIncomplete(new MissionCompleted(),
|
||||||
|
exception.Message,
|
||||||
|
e
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class MissionCompletedParser : ITransactionParserPart {
|
||||||
|
public void Parse(Entry e, TransactionParserContext context, TransactionParserOptions options, TransactionList transactions) {
|
||||||
|
MissionCompletedEntry? entry = e as MissionCompletedEntry;
|
||||||
|
if (entry == null || entry.Mission == null) {
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
Mission? mission;
|
||||||
|
Location? accepted_location;
|
||||||
|
string? target_faction_name = entry.Mission.TargetFaction;
|
||||||
|
string? source_faction_name = entry.Mission.Faction;
|
||||||
|
|
||||||
|
// We did not find when the mission was accepted.
|
||||||
|
if (!context.AcceptedMissions.TryGetValue(entry.Mission.MissionID, out mission)) {
|
||||||
|
transactions.AddIncomplete(new MissionCompleted(),
|
||||||
|
String.Format("Mission acceptance for mission id {0} was not found",
|
||||||
|
entry.Mission.MissionID), e);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!context.AcceptedMissionLocation.TryGetValue(entry.Mission.MissionID, out accepted_location)) {
|
||||||
|
transactions.AddIncomplete(new MissionCompleted(),
|
||||||
|
String.Format("Location for acceptance for mission id {0} was not found",
|
||||||
|
entry.Mission.MissionID), e);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// This block does some preliminary "repairs" on the influences block of a completed
|
||||||
|
// mission. Sometimes these entries are broken, or are missing information for later
|
||||||
|
// parsing.
|
||||||
|
foreach (var other in entry.Mission.Influences) {
|
||||||
|
string faction = other.Key;
|
||||||
|
if (string.IsNullOrEmpty(faction)) {
|
||||||
|
// Target faction might be empty string, in special cases. For example if you
|
||||||
|
// scan a surface installation, and the target faction of the surface installation
|
||||||
|
// gets negative REP, but the surface installation is not owned by anyone.
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fun ahead: sometimes the influence list is empty for a faction entry. Here
|
||||||
|
// we try to repair it.
|
||||||
|
if (other.Value.Count == 0) {
|
||||||
|
if (string.Compare(target_faction_name, faction, true) == 0) {
|
||||||
|
if (context.CurrentSystemAddress == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
other.Value.Add(context.CurrentSystemAddress.Value, new MissionInfluence());
|
||||||
|
// Mission gave no influence to the target faction, so we assume
|
||||||
|
// the target faction was in the same system.
|
||||||
|
} else if (string.Compare(source_faction_name, faction, true) == 0) {
|
||||||
|
// This happens if the source faction is not getting any influence
|
||||||
|
// This could be if the source faction is in a conflict, and thus does
|
||||||
|
// not gain any influence at all.
|
||||||
|
other.Value.Add(accepted_location.SystemAddress, new MissionInfluence());
|
||||||
|
|
||||||
|
// Just check if the target/source faction are the same, in which case
|
||||||
|
// we also have to make an additional entry
|
||||||
|
if (string.Compare(source_faction_name, target_faction_name, true) == 0 &&
|
||||||
|
context.CurrentSystemAddress != null) {
|
||||||
|
other.Value.Add(context.CurrentSystemAddress.Value, new MissionInfluence());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now actually parse completed mission
|
||||||
|
foreach (var influences in other.Value) {
|
||||||
|
ulong system_address = influences.Key;
|
||||||
|
string? system;
|
||||||
|
|
||||||
|
if (!context.SystemsByID.TryGetValue(system_address, out system)) {
|
||||||
|
transactions.AddIncomplete(new MissionCompleted(),
|
||||||
|
string.Format("Unknown system {0}, unable to assign that mission a target", system_address),
|
||||||
|
e
|
||||||
|
);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.Compare(faction, source_faction_name, true) == 0 &&
|
||||||
|
system_address == accepted_location.SystemAddress) {
|
||||||
|
// Source and target faction are the same, and this is the block
|
||||||
|
// for the source system. So we make a full mission completed entry.
|
||||||
|
transactions.Add(new MissionCompleted() {
|
||||||
|
CompletedEntry = entry,
|
||||||
|
Mission = mission,
|
||||||
|
System = accepted_location.StarSystem,
|
||||||
|
Faction = source_faction_name,
|
||||||
|
SystemAddress = accepted_location.SystemAddress,
|
||||||
|
Station = accepted_location.Station,
|
||||||
|
IsLegacy = context.IsLegacy,
|
||||||
|
});
|
||||||
|
} else if (string.Compare(faction, source_faction_name, true) != 0 ||
|
||||||
|
(string.Compare(faction, source_faction_name) == 0 &&
|
||||||
|
system_address != accepted_location.SystemAddress)) {
|
||||||
|
// Whether we ignore influence support
|
||||||
|
if (options.IgnoreInfluenceSupport) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// Source or target faction are different, and/or the system
|
||||||
|
// differs. Sometimes missions go to different systems but to
|
||||||
|
// the same faction.
|
||||||
|
transactions.Add(new InfluenceSupport() {
|
||||||
|
Mission = mission,
|
||||||
|
Faction = faction,
|
||||||
|
Influence = influences.Value,
|
||||||
|
System = system,
|
||||||
|
SystemAddress = system_address,
|
||||||
|
RelevantMission = entry,
|
||||||
|
IsLegacy = context.IsLegacy,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class MissionFailedParser : ITransactionParserPart {
|
||||||
|
public void Parse(Entry e, TransactionParserContext context, TransactionParserOptions options, TransactionList transactions) {
|
||||||
|
Mission? mission;
|
||||||
|
Location? accepted_location;
|
||||||
|
string? accepted_system;
|
||||||
|
|
||||||
|
MissionFailedEntry? entry = e as MissionFailedEntry;
|
||||||
|
if (entry == null) {
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entry.Mission == null) {
|
||||||
|
throw new InvalidJournalEntryException("No mission specified in mission failure");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!context.AcceptedMissions.TryGetValue(entry.Mission.MissionID, out mission)) {
|
||||||
|
transactions.AddIncomplete(new MissionFailed(),
|
||||||
|
"Mission acceptance was not found", e
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!context.AcceptedMissionLocation.TryGetValue(mission.MissionID, out accepted_location)) {
|
||||||
|
transactions.AddIncomplete(new MissionFailed(),
|
||||||
|
"Unable to figure out where failed mission was accepted", e
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!context.SystemsByID.TryGetValue(accepted_location.SystemAddress, out accepted_system)) {
|
||||||
|
transactions.AddIncomplete(new MissionFailed(),
|
||||||
|
"Unable to figure out in which system failed mission was accepted", e
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(mission.Faction)) {
|
||||||
|
transactions.AddIncomplete(new MissionFailed(),
|
||||||
|
"Could not determine for what faction you failed a mission. This happens if the " +
|
||||||
|
"mission acceptance is not within the given time frame.",
|
||||||
|
entry
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
transactions.Add(new MissionFailed(entry) {
|
||||||
|
Faction = mission?.Faction,
|
||||||
|
Mission = mission,
|
||||||
|
Station = accepted_location.Station,
|
||||||
|
System = accepted_location.StarSystem,
|
||||||
|
SystemAddress = accepted_location.SystemAddress,
|
||||||
|
IsLegacy = context.IsLegacy,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class SellMicroResourcesParser : ITransactionParserPart {
|
||||||
|
public void Parse(Entry e, TransactionParserContext context, TransactionParserOptions options, TransactionList transactions) {
|
||||||
|
SellMicroResourcesEntry? entry = e as SellMicroResourcesEntry;
|
||||||
|
if (entry == null) {
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (context.StationOwner == null) {
|
||||||
|
transactions.AddIncomplete(
|
||||||
|
new SellMicroResources(),
|
||||||
|
"Could not discern the station owner for micro resources sell.",
|
||||||
|
e);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
transactions.Add(new SellMicroResources(entry) {
|
||||||
|
System = context.CurrentSystem,
|
||||||
|
Station = context.CurrentStation,
|
||||||
|
Faction = context.StationOwner,
|
||||||
|
IsLegacy = context.IsLegacy,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class SearchAndRescueParser : ITransactionParserPart {
|
||||||
|
public void Parse(Entry e, TransactionParserContext context, TransactionParserOptions options, TransactionList transactions) {
|
||||||
|
SearchAndRescueEntry? entry = e as SearchAndRescueEntry;
|
||||||
|
if (entry == null) {
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (context.StationOwner == null) {
|
||||||
|
transactions.AddIncomplete(
|
||||||
|
new OrganicData(),
|
||||||
|
"Could not discern the station owner for S&R operations.",
|
||||||
|
e);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
transactions.Add(new SearchAndRescue(entry) {
|
||||||
|
System = context.CurrentSystem,
|
||||||
|
Station = context.CurrentStation,
|
||||||
|
Faction = context.StationOwner,
|
||||||
|
IsLegacy = context.IsLegacy,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class FactionKillBondParser : ITransactionParserPart {
|
||||||
|
public void Parse(Entry e, TransactionParserContext context, TransactionParserOptions options, TransactionList transactions) {
|
||||||
|
FactionKillBondEntry? entry = e as FactionKillBondEntry;
|
||||||
|
if (entry == null) {
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Factions.IsThargoid(entry.VictimFaction)) {
|
||||||
|
// Thargoid bonk
|
||||||
|
transactions.Add(new ThargoidKill(entry) {
|
||||||
|
System = context.CurrentSystem,
|
||||||
|
Faction = Factions.PilotsFederation,
|
||||||
|
Station = context.CurrentStation,
|
||||||
|
IsLegacy = context.IsLegacy,
|
||||||
|
});
|
||||||
|
|
||||||
|
ThargoidVessel vessel = Thargoid.GetVesselByPayout(entry.Reward);
|
||||||
|
if (vessel != ThargoidVessel.Unknown) {
|
||||||
|
if (vessel == ThargoidVessel.Scout) {
|
||||||
|
++context.ThargoidScoutKills;
|
||||||
|
} else {
|
||||||
|
++context.ThargoidInterceptorKills;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// We are done
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
context.RecordCombatBond(entry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class EmbarkDisembarkParser : ITransactionParserPart {
|
||||||
|
public void Parse(Entry e, TransactionParserContext context, TransactionParserOptions options, TransactionList transactions) {
|
||||||
|
if (e.Is(Events.Embark)) {
|
||||||
|
context.IsOnFoot = false;
|
||||||
|
} else if (e.Is(Events.Disembark)) {
|
||||||
|
context.IsOnFoot = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class SupercruiseEntryParser : ITransactionParserPart {
|
||||||
|
public void Parse(Entry entry, TransactionParserContext context, TransactionParserOptions options, TransactionList transactions) {
|
||||||
|
// After a super cruise entry we are no longer on foot.
|
||||||
|
context.IsOnFoot = false;
|
||||||
|
context.DiscernCombatZone(transactions, entry);
|
||||||
|
context.ResetCombatZone();
|
||||||
|
// Supercruise entry means you left the current local instance
|
||||||
|
context.LeftInstance();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class ShutdownParser : ITransactionParserPart {
|
||||||
|
public void Parse(Entry entry, TransactionParserContext context, TransactionParserOptions options, TransactionList transactions) {
|
||||||
|
context.DiscernCombatZone(transactions, entry);
|
||||||
|
context.ResetCombatZone();
|
||||||
|
// Shutdown (logout) means you left the instance
|
||||||
|
context.LeftInstance();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class CapShipBondParser : ITransactionParserPart {
|
||||||
|
public void Parse(Entry entry, TransactionParserContext context, TransactionParserOptions options, TransactionList transactions) {
|
||||||
|
if (entry.GetType() != typeof(CapShipBondEntry)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
context.HaveSeenCapShip = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class FileHeaderParser : ITransactionParserPart {
|
||||||
|
public void Parse(Entry entry, TransactionParserContext context, TransactionParserOptions options, TransactionList transactions) {
|
||||||
|
FileHeaderEntry? fileheader = entry as FileHeaderEntry;
|
||||||
|
|
||||||
|
if (fileheader == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
context.IsLegacy = fileheader.IsLegacy;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class ReceiveTextParser : ITransactionParserPart {
|
||||||
|
public void Parse(Entry entry, TransactionParserContext context, TransactionParserOptions options, TransactionList transactions) {
|
||||||
|
ReceiveTextEntry? receivetext = entry as ReceiveTextEntry;
|
||||||
|
|
||||||
|
if (receivetext == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.Compare(receivetext.Channel, Channels.NPC) != 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.Compare(receivetext.NPCCategory, NPCs.AXMilitary) == 0) {
|
||||||
|
context.HaveSeenAXWarzoneNPC = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class SelfDestructParser : ITransactionParserPart {
|
||||||
|
public void Parse(Entry entry, TransactionParserContext context, TransactionParserOptions options, TransactionList transactions) {
|
||||||
|
context.SelfDestruct = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class DiedParser : ITransactionParserPart {
|
||||||
|
public void Parse(Entry entry, TransactionParserContext context, TransactionParserOptions options, TransactionList transactions) {
|
||||||
|
// Death only matters in ship. On foot you can just redeploy with the dropship.
|
||||||
|
if (context.IsOnFoot) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (context.SelfDestruct != null && context.SelfDestruct == true) {
|
||||||
|
// Some people just suicide to fast track back to stations after a CZ,
|
||||||
|
// especially since combat bonds don't disappear on death. So count the CZ
|
||||||
|
// on self destruct
|
||||||
|
context.DiscernCombatZone(transactions, entry);
|
||||||
|
context.SelfDestruct = null;
|
||||||
|
}
|
||||||
|
context.ResetCombatZone();
|
||||||
|
// Dying also moves you back to another instance
|
||||||
|
context.LeftInstance();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class DropshipDeployParser : ITransactionParserPart {
|
||||||
|
public void Parse(Entry entry, TransactionParserContext context, TransactionParserOptions options, TransactionList transactions) {
|
||||||
|
// On drop ship deploy we are now on foot
|
||||||
|
context.IsOnFoot = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class TransactionParser {
|
||||||
|
private static Dictionary<string, ITransactionParserPart> ParserParts { get; } = new()
|
||||||
|
{
|
||||||
|
{ Events.ApproachSettlement, new ApproachSettlementParser() },
|
||||||
|
{ Events.CapShipBond, new CapShipBondParser() },
|
||||||
|
{ Events.CarrierJump, new CarrierJumpParser() },
|
||||||
|
{ Events.Commander, new CommanderParser() },
|
||||||
|
{ Events.CommitCrime, new CommitCrimeParser() },
|
||||||
|
{ Events.Died, new DiedParser() },
|
||||||
|
{ Events.Disembark, new EmbarkDisembarkParser() },
|
||||||
|
{ Events.Docked, new DockedParser() },
|
||||||
|
{ Events.DropshipDeploy, new DropshipDeployParser() },
|
||||||
|
{ Events.Embark, new EmbarkDisembarkParser() },
|
||||||
|
{ Events.FactionKillBond, new FactionKillBondParser() },
|
||||||
|
{ Events.FileHeader, new FileHeaderParser() },
|
||||||
|
{ Events.FSDJump, new FSDJumpParser() },
|
||||||
|
{ Events.Location, new LocationParser() },
|
||||||
|
{ Events.MarketBuy, new MarketBuyParser() },
|
||||||
|
{ Events.MarketSell, new MarketSellParser() },
|
||||||
|
{ Events.MissionAccepted, new MissionAcceptedParser() },
|
||||||
|
{ Events.MissionCompleted, new MissionCompletedParser() },
|
||||||
|
{ Events.MissionFailed, new MissionFailedParser() },
|
||||||
|
{ Events.Missions, new MissionsParser() },
|
||||||
|
{ Events.MultiSellExplorationData, new MultiSellExplorationDataParser() },
|
||||||
|
{ Events.Music, new MusicParser() },
|
||||||
|
{ Events.PowerplayMerits, new PowerplayMeritsParser() },
|
||||||
|
{ Events.ReceiveText, new ReceiveTextParser() },
|
||||||
|
{ Events.RedeemVoucher, new RedeemVoucherParser() },
|
||||||
|
{ Events.SearchAndRescue, new SearchAndRescueParser() },
|
||||||
|
{ Events.SelfDestruct, new SelfDestructParser() },
|
||||||
|
{ Events.SellExplorationData, new SellExplorationDataParser() },
|
||||||
|
{ Events.SellMicroResources, new SellMicroResourcesParser() },
|
||||||
|
{ Events.SellOrganicData, new SellOrganicDataParser() },
|
||||||
|
{ Events.ShipTargeted, new ShipTargetedParser() },
|
||||||
|
{ Events.Shutdown, new ShutdownParser() },
|
||||||
|
{ Events.SupercruiseDestinationDrop, new SupercruiseDestinationDropParser() },
|
||||||
|
{ Events.SupercruiseEntry, new SupercruiseEntryParser() },
|
||||||
|
};
|
||||||
|
|
||||||
|
public bool IsRelevant(string entry) {
|
||||||
|
return ParserParts.ContainsKey(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsRelevant(Entry e) {
|
||||||
|
if (e.Event == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return IsRelevant(e.Event);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Parses a list of entries with default options.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entries"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public List<Transaction>? Parse(IEnumerable<Entry> entries) {
|
||||||
|
TransactionParserOptions defaultOptions = new();
|
||||||
|
return Parse(entries, defaultOptions);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// List of commanders seen during parsing.
|
||||||
|
/// </summary>
|
||||||
|
public List<string> Commanders { get; set; } = new();
|
||||||
|
|
||||||
|
public List<Transaction>? Parse(IEnumerable<Entry> entries, TransactionParserOptions options) {
|
||||||
|
TransactionList transactions = new();
|
||||||
|
TransactionParserContext context = new();
|
||||||
|
|
||||||
|
foreach (Entry entry in entries) {
|
||||||
|
if (entry.Event == null) {
|
||||||
|
throw new InvalidJournalEntryException();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ParserParts.ContainsKey(entry.Event)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
ITransactionParserPart transactionParserPart = ParserParts[entry.Event];
|
||||||
|
transactionParserPart.Parse(entry, context, options, transactions);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Copy out list of commanders seen
|
||||||
|
Commanders = context.Commanders;
|
||||||
|
|
||||||
|
return transactions.ToList();
|
||||||
|
}
|
||||||
|
}
|
354
EDPlayerJournal/BGS/TransactionParserContext.cs
Normal file
354
EDPlayerJournal/BGS/TransactionParserContext.cs
Normal file
@ -0,0 +1,354 @@
|
|||||||
|
using EDPlayerJournal.Entries;
|
||||||
|
|
||||||
|
namespace EDPlayerJournal.BGS;
|
||||||
|
|
||||||
|
internal class TransactionParserContext {
|
||||||
|
/// <summary>
|
||||||
|
/// List of commander names seen in the logs. May be empty.
|
||||||
|
/// </summary>
|
||||||
|
public List<string> Commanders { get; } = new();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Name of the current system the player is in.
|
||||||
|
/// </summary>
|
||||||
|
public string? CurrentSystem { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 64 bit address of the current system.
|
||||||
|
/// </summary>
|
||||||
|
public ulong? CurrentSystemAddress { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Controlling faction of the current system.
|
||||||
|
/// </summary>
|
||||||
|
public string? ControllingFaction { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Name of the current station the player is docked at.
|
||||||
|
/// </summary>
|
||||||
|
public string? CurrentStation { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Faction that owns the current station.
|
||||||
|
/// </summary>
|
||||||
|
public string? StationOwner { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether the player is currently on foot, or in an SRV/ship.
|
||||||
|
/// </summary>
|
||||||
|
public bool IsOnFoot { get; set; } = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Type of the current instance after a SupercruiseDestinationDropEntry.
|
||||||
|
/// This is null if there is no current instance, or the current instance
|
||||||
|
/// is not known.
|
||||||
|
/// </summary>
|
||||||
|
public string? CurrentInstanceType { get; set; } = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Last faction that awarded the player with combat bonds.
|
||||||
|
/// </summary>
|
||||||
|
public string? LastRecordedAwardingFaction { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Highest combat bond seen so far.
|
||||||
|
/// </summary>
|
||||||
|
public ulong? HighestCombatBond { get; set; }
|
||||||
|
|
||||||
|
public bool HaveSeenCapShip { get; set; } = false;
|
||||||
|
public bool HaveSeenAlliedCaptain { get; set; } = false;
|
||||||
|
public bool HaveSeenEnemyCaptain { get; set; } = false;
|
||||||
|
public bool HaveSeenSpecOps { get; set; } = false;
|
||||||
|
public bool HaveSeenAlliedCorrespondent { get; set; } = false;
|
||||||
|
public bool HaveSeenEnemyCorrespondent { get; set; } = false;
|
||||||
|
|
||||||
|
public bool? SelfDestruct { get; set; } = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Current Odyssey settlement.
|
||||||
|
/// </summary>
|
||||||
|
public string? Settlement { get; set; } = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Current Merits
|
||||||
|
/// </summary>
|
||||||
|
public long? CurrentMerits { get; set; } = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Merits from last login
|
||||||
|
/// </summary>
|
||||||
|
public long? LastMerits { get; set; } = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns true if the current session is legacy
|
||||||
|
/// </summary>
|
||||||
|
public bool IsLegacy { get; set; } = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// How many on foot kills were done.
|
||||||
|
/// </summary>
|
||||||
|
public ulong OnFootKills { get; set; } = 0;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// How many ship kills were done.
|
||||||
|
/// </summary>
|
||||||
|
public ulong ShipKills { get; set; } = 0;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Thargoid scouts killed
|
||||||
|
/// </summary>
|
||||||
|
public ulong ThargoidScoutKills { get; set; } = 0;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Thargoid interceptor kills
|
||||||
|
/// </summary>
|
||||||
|
public ulong ThargoidInterceptorKills { get; set; } = 0;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether we have seen an AX warzone NPC talk to us with ReceiveText
|
||||||
|
/// </summary>
|
||||||
|
public bool HaveSeenAXWarzoneNPC { get; set; } = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A list of accepted missions index by their mission ID
|
||||||
|
/// </summary>
|
||||||
|
public Dictionary<ulong, Mission> AcceptedMissions { get; } = new();
|
||||||
|
public Dictionary<ulong, Location> AcceptedMissionLocation { get; } = new();
|
||||||
|
/// <summary>
|
||||||
|
/// A way to lookup a system by its system id
|
||||||
|
/// </summary>
|
||||||
|
public Dictionary<ulong, string> SystemsByID { get; } = new();
|
||||||
|
/// <summary>
|
||||||
|
/// A list of factions present in the given star system
|
||||||
|
/// </summary>
|
||||||
|
public Dictionary<string, List<Faction>> SystemFactions { get; } = new();
|
||||||
|
/// <summary>
|
||||||
|
/// To which faction a given named NPC belonged to.
|
||||||
|
/// </summary>
|
||||||
|
public Dictionary<string, string> NPCFaction { get; } = new();
|
||||||
|
/// <summary>
|
||||||
|
/// Buy costs for a given commodity
|
||||||
|
/// </summary>
|
||||||
|
public Dictionary<string, long> BuyCost = new();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Called when the player leaves an instance, either through logout, FSD jump or
|
||||||
|
/// supercruise instance.
|
||||||
|
/// </summary>
|
||||||
|
public void LeftInstance() {
|
||||||
|
CurrentInstanceType = null;
|
||||||
|
Settlement = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool HadCombatZone() {
|
||||||
|
if (CurrentInstanceType != null &&
|
||||||
|
Instances.IsInstance(CurrentInstanceType, Instances.PowerWarzoneMedium)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (HighestCombatBond == null &&
|
||||||
|
LastRecordedAwardingFaction == null &&
|
||||||
|
HaveSeenAXWarzoneNPC == false &&
|
||||||
|
CurrentInstanceType == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DiscernCombatZone(TransactionList transactions, Entry e) {
|
||||||
|
string? grade = CombatZones.DifficultyLow;
|
||||||
|
string cztype;
|
||||||
|
ulong highest = HighestCombatBond ?? 0;
|
||||||
|
string? faction = LastRecordedAwardingFaction;
|
||||||
|
|
||||||
|
if (!HadCombatZone()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (OnFootKills > 0 || IsOnFoot == true) {
|
||||||
|
cztype = CombatZones.GroundCombatZone;
|
||||||
|
// High on foot combat zones have enforcers that bring 80k a pop
|
||||||
|
if (highest >= 60000) {
|
||||||
|
grade = CombatZones.DifficultyHigh;
|
||||||
|
} else if (highest >= 30000) {
|
||||||
|
// In medium conflict zones, the enforcers are worth 30k
|
||||||
|
grade = CombatZones.DifficultyMedium;
|
||||||
|
} else {
|
||||||
|
grade = CombatZones.DifficultyLow;
|
||||||
|
}
|
||||||
|
} else if (CurrentInstanceType != null) {
|
||||||
|
if (!Instances.IsWarzone(CurrentInstanceType)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (LastRecordedAwardingFaction == null &&
|
||||||
|
(Instances.IsHumanWarzone(CurrentInstanceType) ||
|
||||||
|
Instances.IsPowerWarzone(CurrentInstanceType))) {
|
||||||
|
transactions.AddIncomplete(new CombatZone(),
|
||||||
|
"Could not discern for whom you fought for, " +
|
||||||
|
"as it seems you haven't killed anyone in the ship combat zone.",
|
||||||
|
e);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// If we have information about the current instance being a warship use that
|
||||||
|
// information to determine the warzone.
|
||||||
|
if (Instances.IsInstance(CurrentInstanceType, Instances.WarzoneLow)) {
|
||||||
|
cztype = CombatZones.ShipCombatZone;
|
||||||
|
grade = CombatZones.DifficultyLow;
|
||||||
|
} else if (Instances.IsInstance(CurrentInstanceType, Instances.WarzoneMedium)) {
|
||||||
|
cztype = CombatZones.ShipCombatZone;
|
||||||
|
grade = CombatZones.DifficultyMedium;
|
||||||
|
} else if (Instances.IsInstance(CurrentInstanceType, Instances.WarzoneHigh)) {
|
||||||
|
cztype = CombatZones.ShipCombatZone;
|
||||||
|
grade = CombatZones.DifficultyHigh;
|
||||||
|
} else if (Instances.IsInstance(CurrentInstanceType, Instances.WarzoneThargoidLow)) {
|
||||||
|
cztype = CombatZones.AXCombatZone;
|
||||||
|
grade = CombatZones.DifficultyLow;
|
||||||
|
} else if (Instances.IsInstance(CurrentInstanceType, Instances.WarzoneThargoidMedium)) {
|
||||||
|
cztype = CombatZones.AXCombatZone;
|
||||||
|
grade = CombatZones.DifficultyMedium;
|
||||||
|
} else if (Instances.IsInstance(CurrentInstanceType, Instances.WarzoneThargoidHigh)) {
|
||||||
|
cztype = CombatZones.AXCombatZone;
|
||||||
|
grade = CombatZones.DifficultyHigh;
|
||||||
|
} else if (Instances.IsInstance(CurrentInstanceType, Instances.WarzoneThargoidVeryHigh)) {
|
||||||
|
cztype = CombatZones.AXCombatZone;
|
||||||
|
grade = CombatZones.DifficultyVeryHigh;
|
||||||
|
} else if (Instances.IsInstance(CurrentInstanceType, Instances.PowerWarzoneMedium)) {
|
||||||
|
cztype = CombatZones.PowerCombatZone;
|
||||||
|
grade = CombatZones.DifficultyMedium;
|
||||||
|
} else {
|
||||||
|
transactions.AddIncomplete(new CombatZone(),
|
||||||
|
"Unknown conflict zone difficulty",
|
||||||
|
e);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else if (ShipKills > 0 && !IsOnFoot) {
|
||||||
|
// Ship combat zones can be identified by the amount of kills
|
||||||
|
if (ShipKills > 20) {
|
||||||
|
grade = CombatZones.DifficultyHigh;
|
||||||
|
} else if (ShipKills > 10) {
|
||||||
|
grade = CombatZones.DifficultyMedium;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cap ship, means a high conflict zone
|
||||||
|
if (HaveSeenCapShip) {
|
||||||
|
grade = CombatZones.DifficultyHigh;
|
||||||
|
} else {
|
||||||
|
int warzoneNpcs = new List<bool>() {
|
||||||
|
HaveSeenEnemyCaptain,
|
||||||
|
HaveSeenEnemyCorrespondent,
|
||||||
|
HaveSeenSpecOps
|
||||||
|
}
|
||||||
|
.Where(x => x == true)
|
||||||
|
.Count()
|
||||||
|
;
|
||||||
|
|
||||||
|
if (warzoneNpcs >= 1 && grade == CombatZones.DifficultyLow) {
|
||||||
|
grade = CombatZones.DifficultyMedium;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cztype = CombatZones.ShipCombatZone;
|
||||||
|
} else if ((ThargoidScoutKills > 0 && ThargoidInterceptorKills > 0) ||
|
||||||
|
HaveSeenAXWarzoneNPC == true) {
|
||||||
|
// Could be a thargoid combat zones if interceptors and scouts are there
|
||||||
|
cztype = CombatZones.AXCombatZone;
|
||||||
|
// Still unknown
|
||||||
|
grade = null;
|
||||||
|
} else {
|
||||||
|
transactions.AddIncomplete(new CombatZone(), "Failed to discern combat zone type", e);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
CombatZone zone = new CombatZone() {
|
||||||
|
System = CurrentSystem,
|
||||||
|
Faction = faction,
|
||||||
|
IsLegacy = IsLegacy,
|
||||||
|
Settlement = Settlement,
|
||||||
|
Grade = grade,
|
||||||
|
Type = cztype,
|
||||||
|
// Sad truth is, if HaveSeenXXX is false, we just don't know for certain
|
||||||
|
CapitalShip = HaveSeenCapShip ? true : null,
|
||||||
|
SpecOps = HaveSeenSpecOps ? true : null,
|
||||||
|
EnemyCorrespondent = HaveSeenEnemyCorrespondent ? true : null,
|
||||||
|
AlliedCorrespondent = HaveSeenAlliedCorrespondent ? true : null,
|
||||||
|
EnemyCaptain = HaveSeenEnemyCaptain ? true : null,
|
||||||
|
AlliedCaptain = HaveSeenAlliedCaptain ? true : null,
|
||||||
|
};
|
||||||
|
zone.Entries.Add(e);
|
||||||
|
transactions.Add(zone);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RecordCombatBond(FactionKillBondEntry e) {
|
||||||
|
if (HighestCombatBond == null || e.Reward > HighestCombatBond) {
|
||||||
|
HighestCombatBond = e.Reward;
|
||||||
|
}
|
||||||
|
|
||||||
|
LastRecordedAwardingFaction = e.AwardingFaction;
|
||||||
|
|
||||||
|
if (IsOnFoot) {
|
||||||
|
++OnFootKills;
|
||||||
|
} else {
|
||||||
|
++ShipKills;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ResetCombatZone() {
|
||||||
|
HighestCombatBond = null;
|
||||||
|
HaveSeenCapShip = false;
|
||||||
|
HaveSeenAlliedCaptain = false;
|
||||||
|
HaveSeenEnemyCaptain = false;
|
||||||
|
HaveSeenAlliedCorrespondent = false;
|
||||||
|
HaveSeenEnemyCorrespondent = false;
|
||||||
|
HaveSeenSpecOps = false;
|
||||||
|
LastRecordedAwardingFaction = null;
|
||||||
|
OnFootKills = 0;
|
||||||
|
ShipKills = 0;
|
||||||
|
ThargoidInterceptorKills = 0;
|
||||||
|
ThargoidScoutKills = 0;
|
||||||
|
HaveSeenAXWarzoneNPC = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void BoughtCargo(string? cargo, long? cost) {
|
||||||
|
if (cargo == null || cost == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
BuyCost[cargo] = cost.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Faction>? GetFactions(string? system) {
|
||||||
|
if (system == null || !SystemFactions.ContainsKey(system)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return SystemFactions[system];
|
||||||
|
}
|
||||||
|
|
||||||
|
public void MissionAccepted(MissionAcceptedEntry? entry) {
|
||||||
|
if (entry == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
MissionAccepted(entry.Mission);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void MissionAccepted(Mission? mission) {
|
||||||
|
if (CurrentSystem == null || CurrentSystemAddress == null) {
|
||||||
|
throw new Exception("Mission accepted without knowing where.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mission == null) {
|
||||||
|
throw new Exception("Mission is null");
|
||||||
|
}
|
||||||
|
|
||||||
|
AcceptedMissions.TryAdd(mission.MissionID, mission);
|
||||||
|
|
||||||
|
Location location = new() {
|
||||||
|
StarSystem = CurrentSystem,
|
||||||
|
SystemAddress = CurrentSystemAddress.Value,
|
||||||
|
Station = (CurrentStation ?? ""),
|
||||||
|
};
|
||||||
|
|
||||||
|
AcceptedMissionLocation.TryAdd(mission.MissionID, location);
|
||||||
|
}
|
||||||
|
}
|
19
EDPlayerJournal/BGS/TransactionParserPart.cs
Normal file
19
EDPlayerJournal/BGS/TransactionParserPart.cs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
using EDPlayerJournal.Entries;
|
||||||
|
|
||||||
|
namespace EDPlayerJournal.BGS;
|
||||||
|
|
||||||
|
internal interface ITransactionParserPart {
|
||||||
|
/// <summary>
|
||||||
|
/// Parse a given entry of the entry type specified when declaring to implement this
|
||||||
|
/// interface. You must add your transaction to the passed list in case you did have
|
||||||
|
/// enough information to parse one or more. You may update the parser context
|
||||||
|
/// with new information in case the entry yielded new information.
|
||||||
|
/// Throw an exception if there was an error or a malformed entry. If you have an
|
||||||
|
/// incomplete entry, i.e. not enough information to complete one, add an
|
||||||
|
/// IncompleteTransaction to the list
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entry">The entry to parse</param>
|
||||||
|
/// <param name="context">Parsing context that may contain useful information</param>
|
||||||
|
/// <param name="transactions">List of parsed transactions</param>
|
||||||
|
public void Parse(Entry entry, TransactionParserContext context, TransactionParserOptions options, TransactionList transactions);
|
||||||
|
}
|
74
EDPlayerJournal/BGS/Vouchers.cs
Normal file
74
EDPlayerJournal/BGS/Vouchers.cs
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
using System.Globalization;
|
||||||
|
using EDPlayerJournal.Entries;
|
||||||
|
|
||||||
|
namespace EDPlayerJournal.BGS;
|
||||||
|
|
||||||
|
public class Vouchers : Transaction {
|
||||||
|
private string? type = null;
|
||||||
|
|
||||||
|
public Vouchers() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vouchers(RedeemVoucherEntry e) {
|
||||||
|
Entries.Add(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
public long TotalSum {
|
||||||
|
get {
|
||||||
|
if (Faction == null) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return Entries
|
||||||
|
.OfType<RedeemVoucherEntry>()
|
||||||
|
.ToList()
|
||||||
|
.Sum(x => (long)x.GetBountyForFaction(Faction))
|
||||||
|
;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string? Type {
|
||||||
|
get {
|
||||||
|
if (Entries == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (type == null) {
|
||||||
|
string? v = Entries
|
||||||
|
.OfType<RedeemVoucherEntry>()
|
||||||
|
.GroupBy(x => x.Type)
|
||||||
|
.Select(x => x.Key)
|
||||||
|
.First();
|
||||||
|
if (v == null) {
|
||||||
|
return null;
|
||||||
|
} else if (v == Bonds.CombatBond) {
|
||||||
|
type = "Combat Bond";
|
||||||
|
} else if (v == Bonds.Bounty) {
|
||||||
|
type = "Bounty";
|
||||||
|
} else {
|
||||||
|
type = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(v);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override int CompareTo(Transaction? other) {
|
||||||
|
if (other == null || other.GetType() != typeof(Vouchers)) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
Vouchers? b = other as Vouchers;
|
||||||
|
if (b?.Type == Type &&
|
||||||
|
b?.Faction == Faction &&
|
||||||
|
b?.System == System &&
|
||||||
|
b?.Station == Station) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string ToString() {
|
||||||
|
return string.Format("{0} Vouchers: {1}", Type, Credits.FormatCredits(TotalSum));
|
||||||
|
}
|
||||||
|
}
|
13
EDPlayerJournal/Bonds.cs
Normal file
13
EDPlayerJournal/Bonds.cs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
namespace EDPlayerJournal;
|
||||||
|
|
||||||
|
public class Bonds {
|
||||||
|
/// <summary>
|
||||||
|
/// Internal string name for combat bonds.
|
||||||
|
/// </summary>
|
||||||
|
public static readonly string CombatBond = "CombatBond";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Internal string name for bounties.
|
||||||
|
/// </summary>
|
||||||
|
public static readonly string Bounty = "bounty";
|
||||||
|
}
|
8
EDPlayerJournal/Channels.cs
Normal file
8
EDPlayerJournal/Channels.cs
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
namespace EDPlayerJournal;
|
||||||
|
|
||||||
|
public class Channels {
|
||||||
|
/// <summary>
|
||||||
|
/// Channel NPCs use to talk to the commander.
|
||||||
|
/// </summary>
|
||||||
|
public static readonly string NPC = "npc";
|
||||||
|
}
|
69
EDPlayerJournal/CombatZones.cs
Normal file
69
EDPlayerJournal/CombatZones.cs
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
namespace EDPlayerJournal;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Static strings related to combat zones
|
||||||
|
/// </summary>
|
||||||
|
public class CombatZones {
|
||||||
|
/// <summary>
|
||||||
|
/// Type string for ground combat zone
|
||||||
|
/// </summary>
|
||||||
|
public static readonly string GroundCombatZone = "Ground";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Type string for ship combat zones
|
||||||
|
/// </summary>
|
||||||
|
public static readonly string ShipCombatZone = "Ship";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Power combat zones, new in Ascendancy update.
|
||||||
|
/// </summary>
|
||||||
|
public static readonly string PowerCombatZone = "Power";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// AX combat zone
|
||||||
|
/// </summary>
|
||||||
|
public static readonly string AXCombatZone = "AX";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Difficulty low
|
||||||
|
/// </summary>
|
||||||
|
public static readonly string DifficultyLow = "Low";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Difficulty medium
|
||||||
|
/// </summary>
|
||||||
|
public static readonly string DifficultyMedium = "Medium";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Difficulty high
|
||||||
|
/// </summary>
|
||||||
|
public static readonly string DifficultyHigh = "High";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Very high difficulty, so far AX combat zone only
|
||||||
|
/// </summary>
|
||||||
|
public static readonly string DifficultyVeryHigh = "Very High";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the given combat zone difficulty as an integer, so it can be sorted.
|
||||||
|
/// 0 = lowest difficulty, 1 = medium and so forth.
|
||||||
|
/// </summary>
|
||||||
|
public static int? DifficultyRank(string? difficulty) {
|
||||||
|
Dictionary<string, int> ranks = new() {
|
||||||
|
{ DifficultyLow, 0 },
|
||||||
|
{ DifficultyMedium, 1 },
|
||||||
|
{ DifficultyHigh, 2 },
|
||||||
|
{ DifficultyVeryHigh, 3 }
|
||||||
|
};
|
||||||
|
|
||||||
|
if (difficulty == null ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ranks.TryGetValue(difficulty, out int rank)) {
|
||||||
|
return rank;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
49
EDPlayerJournal/Credits.cs
Normal file
49
EDPlayerJournal/Credits.cs
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
using System.Globalization;
|
||||||
|
|
||||||
|
namespace EDPlayerJournal;
|
||||||
|
|
||||||
|
public class Credits {
|
||||||
|
public static string FormatCredits(uint amount) {
|
||||||
|
return FormatCredits((long)amount);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string FormatCredits(ulong amount) {
|
||||||
|
return FormatCredits((long)amount);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string FormatCredits(long amount) {
|
||||||
|
var format = new CultureInfo(CultureInfo.CurrentCulture.Name, true).NumberFormat;
|
||||||
|
format.NumberGroupSeparator = ",";
|
||||||
|
format.NumberDecimalSeparator = ".";
|
||||||
|
format.NumberGroupSizes = new int[1] { 3 };
|
||||||
|
format.NumberDecimalDigits = 0;
|
||||||
|
if (amount > 0 && (amount % 1000000000) == 0) {
|
||||||
|
amount /= 1000000000;
|
||||||
|
return string.Format("{0}M CR", amount.ToString("N", format));
|
||||||
|
} else if (amount > 0 && (amount % 1000000) == 0) {
|
||||||
|
amount /= 1000000;
|
||||||
|
return string.Format("{0}M CR", amount.ToString("N", format));
|
||||||
|
} else if (amount > 0 && (amount % 100000) == 0) {
|
||||||
|
double am = ((double)amount) / 1000000;
|
||||||
|
format.NumberDecimalDigits = 1;
|
||||||
|
return string.Format("{0}M CR", am.ToString("N", format));
|
||||||
|
} else if (amount > 0 && (amount % 1000) == 0) {
|
||||||
|
amount /= 1000;
|
||||||
|
return string.Format("{0}K CR", amount.ToString("N", format));
|
||||||
|
}
|
||||||
|
|
||||||
|
return string.Format("{0} CR", amount.ToString("N", format));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string FormatMillions(long amount) {
|
||||||
|
double millions = (amount / 1000000.0);
|
||||||
|
|
||||||
|
if (amount >= 100000) {
|
||||||
|
return string.Format("{0:0.0}M", millions);
|
||||||
|
} else if (amount >= 10000) {
|
||||||
|
return string.Format("{0:0.00}M", millions);
|
||||||
|
}
|
||||||
|
|
||||||
|
return string.Format("{0}", amount);
|
||||||
|
}
|
||||||
|
}
|
10
EDPlayerJournal/CrimeTypes.cs
Normal file
10
EDPlayerJournal/CrimeTypes.cs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
namespace EDPlayerJournal;
|
||||||
|
public class CrimeTypes {
|
||||||
|
public static readonly string Assault = "assault";
|
||||||
|
public static readonly string Murder = "murder";
|
||||||
|
public static readonly string OnFootArcCutterUse = "onFoot_arcCutterUse";
|
||||||
|
public static readonly string OnFootDataTransfer = "onFoot_dataTransfer";
|
||||||
|
public static readonly string OnFootIdentityTheft = "onFoot_identityTheft";
|
||||||
|
public static readonly string OnFootMurder = "onFoot_murder";
|
||||||
|
public static readonly string Piracy = "piracy";
|
||||||
|
}
|
13
EDPlayerJournal/EDPlayerJournal.csproj
Normal file
13
EDPlayerJournal/EDPlayerJournal.csproj
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
8
EDPlayerJournal/EliteDangerous.cs
Normal file
8
EDPlayerJournal/EliteDangerous.cs
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
namespace EDPlayerJournal;
|
||||||
|
public class EliteDangerous {
|
||||||
|
/// <summary>
|
||||||
|
/// The ingame universe is 1286 years in the future. This is needed to convert dates
|
||||||
|
/// and times to ingame dates and times
|
||||||
|
/// </summary>
|
||||||
|
public static readonly int YearOffset = 1286;
|
||||||
|
}
|
147
EDPlayerJournal/EnglishMissionNames.cs
Normal file
147
EDPlayerJournal/EnglishMissionNames.cs
Normal file
@ -0,0 +1,147 @@
|
|||||||
|
namespace EDPlayerJournal;
|
||||||
|
|
||||||
|
public class EnglishMissionNames {
|
||||||
|
public static Dictionary<string, string> MissionNames { get; } = new Dictionary<string, string>() {
|
||||||
|
{"Chain_FindThePirateLord_name", "Assassination (Pirate Lord) (Chain)"},
|
||||||
|
{"Chain_RegainFooting_name", "Regain Footing (Chain)"},
|
||||||
|
{"Chain_SalvageJustice_name", "Assassination (Legal) (Chain)"},
|
||||||
|
{"Mission_Altruism_Bust_name", "Donate (Bust)" },
|
||||||
|
{"Mission_Altruism_CivilUnrest_name", "Donate (Civil Unrest)" },
|
||||||
|
{"Mission_Altruism_name", "Donate"},
|
||||||
|
{"Mission_Altruism_Outbreak_name", "Donate (Outbreak)" },
|
||||||
|
{"Mission_AltruismCredits_Bust_name", "Donate Credits (Bust)"},
|
||||||
|
{"Mission_AltruismCredits_CivilUnrest_name", "Donate Credits (Civil Unrest)" },
|
||||||
|
{"Mission_AltruismCredits_Famine_name", "Donate Credits (Famine)"},
|
||||||
|
{"Mission_AltruismCredits_name", "Donate Credits"},
|
||||||
|
{"Mission_AltruismCredits_Outbreak_name", "Donate Credits (Outbreak)" },
|
||||||
|
{"Mission_Assassinate_Illegal_BLOPS_name", "Assassination (Illegal)"},
|
||||||
|
{"MISSION_assassinate_Illegal_Planetary_name", "Assassination (Illegal, Planetary)" },
|
||||||
|
{"Mission_Assassinate_Legal_Bust_name", "Assassination (Bust, Legal)" },
|
||||||
|
{"MISSION_assassinate_legal_CivilUnrest_name", "Assassination (Civil Unrest, Legal)" },
|
||||||
|
{"Mission_Assassinate_Legal_Communism_name", "Assassination (Communism, Legal)" },
|
||||||
|
{"Mission_Assassinate_Legal_Corporate_name", "Assassination (Corporate, Legal)"},
|
||||||
|
{"Mission_Assassinate_Legal_War_name", "Assassination (War, Legal)" },
|
||||||
|
{"Mission_Assassinate_name", "Assassination"},
|
||||||
|
{"Mission_Assassinate_Planetary_Expansion_name", "Assassination (Planetary Scan, Expansion)" },
|
||||||
|
{"Mission_Assassinate_Planetary_name", "Assassination (Planetary Scan)"},
|
||||||
|
{"Mission_Collect_Bust_name", "Provide (Bust)"},
|
||||||
|
{"Mission_Collect_CivilLiberty_name", "Provide (Civil Liberty)"},
|
||||||
|
{"Mission_Collect_CivilUnrest_name", "Provide (Civil Unrest)"},
|
||||||
|
{"Mission_Collect_Famine_name", "Provide (Famine)"},
|
||||||
|
{"Mission_Collect_Industrial_name", "Provide (Industrial)"},
|
||||||
|
{"Mission_Collect_name", "Provide"},
|
||||||
|
{"Mission_Collect_Outbreak_name", "Provide (Outbreak)" },
|
||||||
|
{"Mission_Collect_RankEmp_name", "Provide (Imperial Navy)"},
|
||||||
|
{"Mission_Collect_Retreat_name", "Provide (Retreat)"},
|
||||||
|
{"Mission_Courier_CivilUnrest_name", "Courier (Divil Unrest)" },
|
||||||
|
{"Mission_Courier_Democracy_name", "Courier (Democracy)"},
|
||||||
|
{"Mission_Courier_Elections_name", "Courier (Elections)"},
|
||||||
|
{"Mission_Courier_Expansion_name", "Courier (Expansion)"},
|
||||||
|
{"Mission_Courier_Famine_name", "Courier (Famine)"},
|
||||||
|
{"Mission_Courier_Lockdown_name", "Courier (Lockdown)"},
|
||||||
|
{"Mission_Courier_name", "Courier"},
|
||||||
|
{"Mission_Courier_RankEmp_name", "Courier (Imperial Navy)"},
|
||||||
|
{"Mission_Courier_War_name", "Courier (War)" },
|
||||||
|
{"Mission_Delivery_Agriculture_name", "Delivery (Agriculture)"},
|
||||||
|
{"Mission_Delivery_Boom_name", "Delivery (Boom)"},
|
||||||
|
{"Mission_Delivery_CivilUnrest_name", "Delivery (Civil Unrest)"},
|
||||||
|
{"Mission_Delivery_Democracy_name", "Delivery (Democracy)"},
|
||||||
|
{"Mission_Delivery_Investment_name", "Delivery (Investment)"},
|
||||||
|
{"Mission_Delivery_name", "Delivery"},
|
||||||
|
{"Mission_Delivery_RankEmp_name", "Delivery (Imperial Navy)"},
|
||||||
|
{"Mission_Delivery_Retreat_name", "Delivery (Retreat)"},
|
||||||
|
{"Mission_DeliveryWing_name", "Delivery (Wing)"},
|
||||||
|
{"Mission_DeliveryWing_War_name", "Delivery (Wing) (War)"},
|
||||||
|
{"Mission_Disable_BLOPS_Expansion_name", "Disable Surface Installation (Expansion) (Black Ops)" },
|
||||||
|
{"MISSION_Disable_BLOPS_name", "Disable Surface Installation (Black Ops)" },
|
||||||
|
{"MISSION_Disable_name", "Disable Surface Installation" },
|
||||||
|
{"MISSION_Hack_name", "Hack Surface Installation" },
|
||||||
|
{"Mission_Hack_BLOPS_Boom_name", "Hack Surface Installation (Boom)"},
|
||||||
|
{"Mission_Hack_BLOPS_Elections_name", "Hack Surface Installation (Elections)"},
|
||||||
|
{"Mission_Hack_BLOPS_Expansion_name", "Hack Surface Installation (Expansion)"},
|
||||||
|
{"MISSION_Hack_BLOPS_name", "Hack Surface Installation"},
|
||||||
|
{"Mission_HackMegaship_name", "Hack Megaship"},
|
||||||
|
{"Mission_LongDistanceExpedition_Explorer_Boom_name", "Long Distance Expedition (Boom)"},
|
||||||
|
{"Mission_LongDistanceExpedition_name", "Long Distance Expedition"},
|
||||||
|
{"Mission_Massacre_Conflict_CivilWar_name", "Massacre (Civil War)"},
|
||||||
|
{"Mission_Massacre_name", "Massacre"},
|
||||||
|
{"Mission_Massacre_RankEmp_name", "Massacre (Imperial Navy)"},
|
||||||
|
{"Mission_MassacreWing_Legal_Bust_name", "Massacre (Wing) (Bust)"},
|
||||||
|
{"Mission_MassacreWing_name", "Massacre (Wing)"},
|
||||||
|
{"Mission_Mining_name", "Mining" },
|
||||||
|
{"Mission_OnFoot_Assassination_MB_name", "On Foot Assassination"},
|
||||||
|
{"Mission_OnFoot_Assassination_Hard_MB_name", "On Foot Assassination (Flight-Risk)" },
|
||||||
|
{"Mission_OnFoot_Assassination_Covert_MB_name", "On Foot Assassination (Covert)" },
|
||||||
|
{"Mission_OnFoot_AssassinationIllegal_MB_name", "On Foot Assassination (Illegal)"},
|
||||||
|
{"Mission_OnFoot_AssassinationIllegal_NCD_MB_name", "On Foot Assassination (Illegal)" },
|
||||||
|
{"Mission_OnFoot_Collect_Contact_MB_name", "On Foot Collect"},
|
||||||
|
{"Mission_OnFoot_Collect_MB_name", "On Foot Collection"},
|
||||||
|
{"Mission_OnFoot_Defence_MacGuffin_MB_StandardCanister_name", "On Foot Cargo Defence" },
|
||||||
|
{"Mission_OnFoot_Delivery_Contact_MB_name", "On Foot Delivery (Contact)"},
|
||||||
|
{"Mission_OnFoot_Hack_Upload_Covert_MB_name", "On Foot Hack (Covert Upload)"},
|
||||||
|
{"Mission_OnFoot_Hack_Upload_MB_name", "On Foot Hack (Upload)"},
|
||||||
|
{"Mission_OnFoot_Heist_MB_name", "On Foot Heist" },
|
||||||
|
{"Mission_OnFoot_Heist_POI_MB_name", "On Foot Heist (POI)"},
|
||||||
|
{"Mission_OnFoot_Massacre_MB_name", "On Foot Massacre" },
|
||||||
|
{"Mission_OnFoot_MassacreIllegal_MB_name", "On Foot Massacre (Illegal)"},
|
||||||
|
{"Mission_OnFoot_Onslaught_MB_name", "On Foot Onslaught"},
|
||||||
|
{"Mission_OnFoot_Onslaught_Offline_MB_name", "On Foot Onslaught (Offline)"},
|
||||||
|
{"Mission_OnFoot_ProductionHeist_Covert_MB_name", "On Foot Production Heist (Covert)"},
|
||||||
|
{"Mission_OnFoot_ProductionHeist_MB_name", "On Foot Production Heist"},
|
||||||
|
{"Mission_OnFoot_Reboot_MB_name", "On Foot Reboot"},
|
||||||
|
{"Mission_OnFoot_RebootRestore_MB_name", "On Foot Reboot/Restore"},
|
||||||
|
{"Mission_OnFoot_Sabotage_Power_MB_name", "On Foot Power Sabotage"},
|
||||||
|
{"Mission_OnFoot_Sabotage_Power_Covert_MB_name", "On Foot Power Sabotage (Covert)"},
|
||||||
|
{"Mission_OnFoot_Sabotage_Production_MB_name", "On Foot Production Sabotage"},
|
||||||
|
{"Mission_OnFoot_Sabotage_Production_Covert_MB_name", "On Foot Production Sabotage (Covert)"},
|
||||||
|
{"Mission_OnFoot_Salvage_MB_name", "On Foot Salvage"},
|
||||||
|
{"Mission_OnFoot_SalvageIllegal_MB_name", "On Foot Salvage (Illegal)"},
|
||||||
|
{"Mission_OnFoot_Smuggle_Contact_MB_name", "On Foot Smuggling" },
|
||||||
|
{"Mission_PassengerBulk_AIDWORKER_ARRIVING", "Seeking Transport (Aid Workers)"},
|
||||||
|
{"Mission_PassengerBulk_name", "Seeking Transport" },
|
||||||
|
{"Mission_PassengerVIP", "Passenger (VIP)"},
|
||||||
|
{"Mission_PassengerVIP_Criminal_BOOM_name", "Passenger Criminal (VIP) (Boom)"},
|
||||||
|
{"Mission_PassengerVIP_name", "Passenger (VIP)"},
|
||||||
|
{"Mission_PassengerVIP_Scientist_FAMINE_name", "Passenger Scientist (VIP) (Famine)"},
|
||||||
|
{"Mission_PassengerVIP_Tourist_BOOM_name", "Passenger Tourist (VIP) (Boom)"},
|
||||||
|
{"Mission_Rescue_Elections_name", "Liberate Hostages (Election)" },
|
||||||
|
{"Mission_Rescue_name", "Liberate Hostages" },
|
||||||
|
{"Mission_Rescue_Planet_Expansion_name", "Planet Rescue (Expansion)" },
|
||||||
|
{"Mission_Rescue_Planet_Retreat_name", "Planet Rescue (Retreat)" },
|
||||||
|
{"Mission_Rescue_Planet_name", "Planet Rescue"},
|
||||||
|
{"MISSION_Salvage_CivilUnrest_name", "Salvage (Civil Unrest)"},
|
||||||
|
{"MISSION_Salvage_Expansion_name", "Salvage (Expansion)"},
|
||||||
|
{"MISSION_Salvage_Illegal_name", "Salvage (Illegal)"},
|
||||||
|
{"Mission_Salvage_name", "Salvage"},
|
||||||
|
{"Mission_Salvage_RankEmp_name", "Salvage (Imperial Navy)"},
|
||||||
|
{"MISSION_Salvage_Refinery_name", "Salvage (Refinery)"},
|
||||||
|
{"MISSION_Salvage_Retreat_name", "Salvage (Retreat)"},
|
||||||
|
{"MISSION_Scan_name", "Scan"},
|
||||||
|
{"Mission_Sightseeing_Criminal_FAMINE_name", "Sightseeing (Criminal) (Famine)"},
|
||||||
|
{"Mission_Sightseeing_name", "Sightseeing"},
|
||||||
|
{"Mission_Smuggle_Anarchy_name", "Smuggling (Anarchy)" },
|
||||||
|
{"Mission_TW_Massacre_Basilisk_Plural_name", "Kill Basilisks" },
|
||||||
|
{"Mission_TW_Massacre_Basilisk_Singular_name", "Kill Basilisk" },
|
||||||
|
{"Mission_TW_Massacre_Cyclops_Plural_name", "Kill Cyclops" },
|
||||||
|
{"Mission_TW_Massacre_Cyclops_Singular_name", "Kill Cyclop" },
|
||||||
|
{"Mission_TW_Massacre_Hydra_Plural_name", "Kill Hydras" },
|
||||||
|
{"Mission_TW_Massacre_Hydra_Singular_name", "Kill Hydra" },
|
||||||
|
{"Mission_TW_Massacre_Medusa_Plural_name", "Kill Medusas" },
|
||||||
|
{"Mission_TW_Massacre_Medusa_Singular_name", "Kill Medusa" },
|
||||||
|
{"Mission_TW_Massacre_Scout_Plural_name", "Kill Scouts" },
|
||||||
|
{"Mission_TW_OnFoot_Reboot_Occupied_MB_name", "Reboot Settlement (Thargoid)" },
|
||||||
|
{"Mission_TW_OnFoot_Reboot_NR_name", "Reboot Settlement (Thargoid)" },
|
||||||
|
{"Mission_TW_OnFoot_Reboot_MB_name", "Reboot Settlement (Thargoid)" },
|
||||||
|
{"Mission_TW_PassengerEvacuation_Burning_name", "Passenger Evacuation (Significant Damage)" },
|
||||||
|
{"Mission_TW_PassengerEvacuation_UnderAttack_name", "Passenger Evacuation (Thargoid Invasion)" },
|
||||||
|
{"Mission_TW_Rescue_UnderAttack_name", "Rescue (Thargoid Attack)" },
|
||||||
|
};
|
||||||
|
|
||||||
|
public static string? Translate(string name) {
|
||||||
|
if (MissionNames.ContainsKey(name)) {
|
||||||
|
return MissionNames[name];
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
48
EDPlayerJournal/Entries/ApproachSettlementEntry.cs
Normal file
48
EDPlayerJournal/Entries/ApproachSettlementEntry.cs
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
namespace EDPlayerJournal.Entries;
|
||||||
|
|
||||||
|
public class ApproachSettlementEntry : Entry {
|
||||||
|
/// <summary>
|
||||||
|
/// Settlement name
|
||||||
|
/// </summary>
|
||||||
|
public string? Name { get; set; } = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Market ID of the settlement
|
||||||
|
/// </summary>
|
||||||
|
public long? MarketID { get; set; } = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// System ID
|
||||||
|
/// </summary>
|
||||||
|
public long? SystemAddress { get; set; } = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Body ID
|
||||||
|
/// </summary>
|
||||||
|
public long? BodyID { get; set; } = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Name of the planet
|
||||||
|
/// </summary>
|
||||||
|
public string? BodyName { get; set; } = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Planet latitude
|
||||||
|
/// </summary>
|
||||||
|
public double Latitude { get; set; } = 0.0;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Planet longitude
|
||||||
|
/// </summary>
|
||||||
|
public double Longitude { get; set; } = 0.0;
|
||||||
|
|
||||||
|
protected override void Initialise() {
|
||||||
|
Name = JSON.Value<string?>("Name");
|
||||||
|
MarketID = JSON.Value<long?>("MarketID");
|
||||||
|
SystemAddress = JSON.Value<long?>("SystemID");
|
||||||
|
BodyID = JSON.Value<long?>("BodyID");
|
||||||
|
BodyName = JSON.Value<string?>("BodyName");
|
||||||
|
Longitude = JSON.Value<double?>("Longitude") ?? 0.0;
|
||||||
|
Latitude = JSON.Value<double?>("Latitude") ?? 0.0;
|
||||||
|
}
|
||||||
|
}
|
25
EDPlayerJournal/Entries/BountyEntry.cs
Normal file
25
EDPlayerJournal/Entries/BountyEntry.cs
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace EDPlayerJournal.Entries;
|
||||||
|
/**
|
||||||
|
* This entry appears whenever a bounty is awarded.
|
||||||
|
*/
|
||||||
|
public class BountyEntry : Entry {
|
||||||
|
private string? victimfaction = null;
|
||||||
|
private string? target = null;
|
||||||
|
private int rewards = 0;
|
||||||
|
|
||||||
|
protected override void Initialise() {
|
||||||
|
rewards = JSON.Value<int?>("TotalReward") ?? 0;
|
||||||
|
victimfaction = JSON.Value<string>("VictimFaction") ?? "";
|
||||||
|
target = JSON.Value<string>("Target_Localised") ?? "";
|
||||||
|
}
|
||||||
|
|
||||||
|
public string? VictimFaction => victimfaction;
|
||||||
|
public string? Target => target;
|
||||||
|
public int Rewards => rewards;
|
||||||
|
}
|
24
EDPlayerJournal/Entries/CapShipBondEntry.cs
Normal file
24
EDPlayerJournal/Entries/CapShipBondEntry.cs
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
namespace EDPlayerJournal.Entries;
|
||||||
|
|
||||||
|
public class CapShipBondEntry : Entry {
|
||||||
|
/// <summary>
|
||||||
|
/// Reward gained
|
||||||
|
/// </summary>
|
||||||
|
public ulong Reward { get; set; } = 0;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Victim faction, i.e. to whom the cap ship belongs
|
||||||
|
/// </summary>
|
||||||
|
public string? VictimFaction { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Awarding faction.
|
||||||
|
/// </summary>
|
||||||
|
public string? AwardingFaction { get; set; }
|
||||||
|
|
||||||
|
protected override void Initialise() {
|
||||||
|
Reward = JSON.Value<ulong?>("Reward") ?? 0;
|
||||||
|
VictimFaction = JSON.Value<string?>("VictimFaction");
|
||||||
|
AwardingFaction = JSON.Value<string?>("AwardingFaction");
|
||||||
|
}
|
||||||
|
}
|
44
EDPlayerJournal/Entries/CarrierJump.cs
Normal file
44
EDPlayerJournal/Entries/CarrierJump.cs
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
|
||||||
|
namespace EDPlayerJournal.Entries;
|
||||||
|
|
||||||
|
public class CarrierJump : Entry {
|
||||||
|
public bool Docked { get; set; } = false;
|
||||||
|
|
||||||
|
public string? StationName { get; set; } = null;
|
||||||
|
|
||||||
|
public string? StationType { get; set; } = null;
|
||||||
|
|
||||||
|
public string? StarSystem { get; set; } = null;
|
||||||
|
|
||||||
|
public ulong SystemAddress { get; set; } = 0;
|
||||||
|
|
||||||
|
public string? SystemFaction { get; set; } = null;
|
||||||
|
|
||||||
|
public List<Faction> SystemFactions { get; set; } = new List<Faction>();
|
||||||
|
|
||||||
|
protected override void Initialise() {
|
||||||
|
Docked = JSON.Value<bool?>("Docked") ?? false;
|
||||||
|
|
||||||
|
StarSystem = JSON.Value<string>("StarSystem");
|
||||||
|
SystemAddress = JSON.Value<ulong?>("SystemAddress") ?? 0;
|
||||||
|
|
||||||
|
StationName = JSON.Value<string?>("StationName");
|
||||||
|
StationType = JSON.Value<string?>("StationType");
|
||||||
|
|
||||||
|
var faction = JSON.Value<JObject>("SystemFaction");
|
||||||
|
if (faction != null) {
|
||||||
|
SystemFaction = faction.Value<string>("Name");
|
||||||
|
}
|
||||||
|
|
||||||
|
var factions = JSON.Value<JArray>("Factions");
|
||||||
|
if (factions != null) {
|
||||||
|
foreach (JObject system_faction in factions) {
|
||||||
|
Faction? f = Faction.FromJSON(system_faction);
|
||||||
|
if (f != null) {
|
||||||
|
SystemFactions.Add(f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
20
EDPlayerJournal/Entries/CommanderEntry.cs
Normal file
20
EDPlayerJournal/Entries/CommanderEntry.cs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
namespace EDPlayerJournal.Entries;
|
||||||
|
|
||||||
|
public class CommanderEntry : Entry {
|
||||||
|
public string? Name { get; set; }
|
||||||
|
public string? FID { get; set; }
|
||||||
|
|
||||||
|
protected override void Initialise() {
|
||||||
|
Name = JSON.Value<string>("Name") ?? "";
|
||||||
|
FID = JSON.Value<string>("FID") ?? "";
|
||||||
|
}
|
||||||
|
|
||||||
|
public string FullName {
|
||||||
|
get {
|
||||||
|
if (string.IsNullOrEmpty(Name)) {
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
return "CMDR " + Name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
30
EDPlayerJournal/Entries/CommitCrimeEntry.cs
Normal file
30
EDPlayerJournal/Entries/CommitCrimeEntry.cs
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
namespace EDPlayerJournal.Entries;
|
||||||
|
public class CommitCrimeEntry : Entry {
|
||||||
|
public string? CrimeType { get; set; }
|
||||||
|
public string? Faction { get; set; }
|
||||||
|
public string? Victim { get; set; }
|
||||||
|
public string? VictimLocalised { get; set; }
|
||||||
|
public long Bounty { get; set; }
|
||||||
|
public long Fine { get; set; }
|
||||||
|
|
||||||
|
protected override void Initialise() {
|
||||||
|
CrimeType = JSON.Value<string>("CrimeType") ?? "assault";
|
||||||
|
Faction = JSON.Value<string>("Faction") ?? "";
|
||||||
|
Victim = JSON.Value<string>("Victim") ?? "";
|
||||||
|
VictimLocalised = JSON.Value<string>("Victim_Localised") ?? "";
|
||||||
|
Bounty = JSON.Value<long?>("Bounty") ?? 0;
|
||||||
|
Fine = JSON.Value<long?>("Fine") ?? 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsMurder {
|
||||||
|
get { return CrimeType?.CompareTo(CrimeTypes.Murder) == 0 || CrimeType?.CompareTo(CrimeTypes.OnFootMurder) == 0; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsCrime(string crimetype) {
|
||||||
|
if (CrimeType == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return string.Compare(CrimeType, crimetype) == 0;
|
||||||
|
}
|
||||||
|
}
|
39
EDPlayerJournal/Entries/DiedEntry.cs
Normal file
39
EDPlayerJournal/Entries/DiedEntry.cs
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
|
||||||
|
namespace EDPlayerJournal.Entries;
|
||||||
|
public class Killer {
|
||||||
|
public string? Name { get; set; }
|
||||||
|
public string? Rank { get; set; }
|
||||||
|
public string? Ship { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class DiedEntry : Entry {
|
||||||
|
private readonly List<Killer> killers = new List<Killer>();
|
||||||
|
|
||||||
|
public List<Killer> Killers => killers;
|
||||||
|
public Killer? Killer => killers.Count > 0 ? killers[0] : null;
|
||||||
|
public bool WasWing => killers.Count > 1;
|
||||||
|
|
||||||
|
protected override void Initialise() {
|
||||||
|
var wing = JSON.Value<JArray>("Killers");
|
||||||
|
if (wing != null) {
|
||||||
|
/* a wing killed us */
|
||||||
|
foreach (JObject child in wing.Children<JObject>()) {
|
||||||
|
Killer killer = new Killer {
|
||||||
|
Name = child.Value<string>("Name"),
|
||||||
|
Rank = child.Value<string>("Rank"),
|
||||||
|
Ship = child.Value<string>("Ship")
|
||||||
|
};
|
||||||
|
killers.Add(killer);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
/* a single ship killed us */
|
||||||
|
Killer killer = new Killer {
|
||||||
|
Name = JSON.Value<string>("KillerName"),
|
||||||
|
Rank = JSON.Value<string>("KillerRank"),
|
||||||
|
Ship = JSON.Value<string>("KillerShip")
|
||||||
|
};
|
||||||
|
killers.Add(killer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
66
EDPlayerJournal/Entries/DisembarkEntry.cs
Normal file
66
EDPlayerJournal/Entries/DisembarkEntry.cs
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
namespace EDPlayerJournal.Entries;
|
||||||
|
|
||||||
|
public class DisembarkEntry : Entry {
|
||||||
|
/// <summary>
|
||||||
|
/// Disembarked into an SRV?
|
||||||
|
/// </summary>
|
||||||
|
public bool SRV { get; set; } = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Taxi?
|
||||||
|
/// </summary>
|
||||||
|
public bool Taxi { get; set; } = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Multicrew or not.
|
||||||
|
/// </summary>
|
||||||
|
public bool Multicrew { get; set; } = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Player's ship ID
|
||||||
|
/// </summary>
|
||||||
|
public ulong? ID { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Star system
|
||||||
|
/// </summary>
|
||||||
|
public string? StarSystem { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// System address
|
||||||
|
/// </summary>
|
||||||
|
public ulong? SystemAddress { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Body, name e.g. HIP 6182 B 2 a
|
||||||
|
/// </summary>
|
||||||
|
public string? Body { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Body ID
|
||||||
|
/// </summary>
|
||||||
|
public ulong? BodyID { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Disembarked on a station?
|
||||||
|
/// </summary>
|
||||||
|
public bool OnStation { get; set; } = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Disembarked on a planet?
|
||||||
|
/// </summary>
|
||||||
|
public bool OnPlanet { get; set; } = false;
|
||||||
|
|
||||||
|
protected override void Initialise() {
|
||||||
|
SRV = JSON.Value<bool?>("SRV") ?? false;
|
||||||
|
Taxi = JSON.Value<bool?>("Taxi") ?? false;
|
||||||
|
Multicrew = JSON.Value<bool?>("Multicrew") ?? false;
|
||||||
|
ID = JSON.Value<ulong?>("ID");
|
||||||
|
StarSystem = JSON.Value<string?>("StarSystem");
|
||||||
|
SystemAddress = JSON.Value<ulong?>("SystemAddress");
|
||||||
|
Body = JSON.Value<string?>("Body");
|
||||||
|
BodyID = JSON.Value<ulong?>("BodyID");
|
||||||
|
OnStation = JSON.Value<bool?>("OnStation") ?? false;
|
||||||
|
OnPlanet = JSON.Value<bool?>("OnPlanet") ?? false;
|
||||||
|
}
|
||||||
|
}
|
40
EDPlayerJournal/Entries/DockedEntry.cs
Normal file
40
EDPlayerJournal/Entries/DockedEntry.cs
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
|
||||||
|
namespace EDPlayerJournal.Entries;
|
||||||
|
public class DockedEntry : Entry {
|
||||||
|
/// <summary>
|
||||||
|
/// Name of the station
|
||||||
|
/// </summary>
|
||||||
|
public string? StationName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Star system of the station
|
||||||
|
/// </summary>
|
||||||
|
public string? StarSystem { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// System address
|
||||||
|
/// </summary>
|
||||||
|
public ulong? SystemAddress { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Faction owning the station.
|
||||||
|
/// </summary>
|
||||||
|
public string? StationFaction { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// State of the station, new in Update 14
|
||||||
|
/// </summary>
|
||||||
|
public string? StationState { get; set; }
|
||||||
|
|
||||||
|
protected override void Initialise() {
|
||||||
|
StationName = JSON.Value<string>("StationName");
|
||||||
|
StarSystem = JSON.Value<string>("StarSystem");
|
||||||
|
SystemAddress = JSON.Value<ulong?>("SystemAddress");
|
||||||
|
StationState = JSON.Value<string>("StationState");
|
||||||
|
JObject? faction = JSON.Value<JObject>("StationFaction");
|
||||||
|
if (faction != null) {
|
||||||
|
StationFaction = faction.Value<string>("Name") ?? "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
42
EDPlayerJournal/Entries/DropshipDeployEntry.cs
Normal file
42
EDPlayerJournal/Entries/DropshipDeployEntry.cs
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
namespace EDPlayerJournal.Entries;
|
||||||
|
|
||||||
|
public class DropshipDeployEntry : Entry {
|
||||||
|
/// <summary>
|
||||||
|
/// Star system this drop happened in.
|
||||||
|
/// </summary>
|
||||||
|
public string? StarSystem { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// System address
|
||||||
|
/// </summary>
|
||||||
|
public ulong? SystemAddress { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Planetary body
|
||||||
|
/// </summary>
|
||||||
|
public string? Body { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Body ID
|
||||||
|
/// </summary>
|
||||||
|
public ulong? BodyID { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether it happened on station.
|
||||||
|
/// </summary>
|
||||||
|
public bool? OnStation { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether it happened on a planet.
|
||||||
|
/// </summary>
|
||||||
|
public bool? OnPlanet { get; set; }
|
||||||
|
|
||||||
|
protected override void Initialise() {
|
||||||
|
StarSystem = JSON.Value<string?>("StarSystem");
|
||||||
|
SystemAddress = JSON.Value<ulong?>("SystemAddress");
|
||||||
|
Body = JSON.Value<string?>("Body");
|
||||||
|
BodyID = JSON.Value<ulong?>("BodyID");
|
||||||
|
OnStation = JSON.Value<bool?>("OnStation");
|
||||||
|
OnPlanet = JSON.Value<bool?>("OnPlanet");
|
||||||
|
}
|
||||||
|
}
|
66
EDPlayerJournal/Entries/EmbarkEntry.cs
Normal file
66
EDPlayerJournal/Entries/EmbarkEntry.cs
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
namespace EDPlayerJournal.Entries;
|
||||||
|
|
||||||
|
public class EmbarkEntry : Entry {
|
||||||
|
/// <summary>
|
||||||
|
/// Disembarked into an SRV?
|
||||||
|
/// </summary>
|
||||||
|
public bool SRV { get; set; } = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Taxi?
|
||||||
|
/// </summary>
|
||||||
|
public bool Taxi { get; set; } = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Multicrew or not.
|
||||||
|
/// </summary>
|
||||||
|
public bool Multicrew { get; set; } = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Player's ship ID
|
||||||
|
/// </summary>
|
||||||
|
public ulong? ID { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Star system
|
||||||
|
/// </summary>
|
||||||
|
public string? StarSystem { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// System address
|
||||||
|
/// </summary>
|
||||||
|
public ulong? SystemAddress { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Body, name e.g. HIP 6182 B 2 a
|
||||||
|
/// </summary>
|
||||||
|
public string? Body { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Body ID
|
||||||
|
/// </summary>
|
||||||
|
public ulong? BodyID { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Disembarked on a station?
|
||||||
|
/// </summary>
|
||||||
|
public bool OnStation { get; set; } = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Disembarked on a planet?
|
||||||
|
/// </summary>
|
||||||
|
public bool OnPlanet { get; set; } = false;
|
||||||
|
|
||||||
|
protected override void Initialise() {
|
||||||
|
SRV = JSON.Value<bool?>("SRV") ?? false;
|
||||||
|
Taxi = JSON.Value<bool?>("Taxi") ?? false;
|
||||||
|
Multicrew = JSON.Value<bool?>("Multicrew") ?? false;
|
||||||
|
ID = JSON.Value<ulong?>("ID");
|
||||||
|
StarSystem = JSON.Value<string?>("StarSystem");
|
||||||
|
SystemAddress = JSON.Value<ulong?>("SystemAddress");
|
||||||
|
Body = JSON.Value<string?>("Body");
|
||||||
|
BodyID = JSON.Value<ulong?>("BodyID");
|
||||||
|
OnStation = JSON.Value<bool?>("OnStation") ?? false;
|
||||||
|
OnPlanet = JSON.Value<bool?>("OnPlanet") ?? false;
|
||||||
|
}
|
||||||
|
}
|
156
EDPlayerJournal/Entries/Entry.cs
Normal file
156
EDPlayerJournal/Entries/Entry.cs
Normal file
@ -0,0 +1,156 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
namespace EDPlayerJournal.Entries;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Base class for a single entry within the player journal. If no specific sub class is available
|
||||||
|
/// this class gives basic information, such as EventType or date when it happened. It also allows
|
||||||
|
/// base classes access to the underlying JSON object. Base classes should be named after the event
|
||||||
|
/// type that they map + Entry. So "FSDJump" event is handled by FSDJumpEntry.
|
||||||
|
/// </summary>
|
||||||
|
public class Entry {
|
||||||
|
private static readonly Dictionary<string, Type> classes = new Dictionary<string, Type> {
|
||||||
|
{ Events.ApproachSettlement, typeof(ApproachSettlementEntry) },
|
||||||
|
{ Events.Bounty, typeof(BountyEntry) },
|
||||||
|
{ Events.CapShipBond, typeof(CapShipBondEntry) },
|
||||||
|
{ Events.CarrierJump, typeof(CarrierJump) },
|
||||||
|
{ Events.Commander, typeof(CommanderEntry) },
|
||||||
|
{ Events.CommitCrime, typeof(CommitCrimeEntry) },
|
||||||
|
{ Events.Died, typeof(DiedEntry) },
|
||||||
|
{ Events.Disembark, typeof(DisembarkEntry) },
|
||||||
|
{ Events.Docked, typeof(DockedEntry) },
|
||||||
|
{ Events.DropshipDeploy, typeof(DropshipDeployEntry) },
|
||||||
|
{ Events.Embark, typeof(EmbarkEntry) },
|
||||||
|
{ Events.FactionKillBond, typeof(FactionKillBondEntry) },
|
||||||
|
{ Events.FileHeader, typeof(FileHeaderEntry) },
|
||||||
|
{ Events.FSDJump, typeof(FSDJumpEntry) },
|
||||||
|
{ Events.HullDamage, typeof(HullDamageEntry) },
|
||||||
|
{ Events.LoadGame, typeof(LoadGameEntry) },
|
||||||
|
{ Events.Location, typeof(LocationEntry) },
|
||||||
|
{ Events.MarketBuy, typeof(MarketBuyEntry) },
|
||||||
|
{ Events.MarketSell, typeof(MarketSellEntry) },
|
||||||
|
{ Events.MissionAbandoned, typeof(MissionAbandonedEntry) },
|
||||||
|
{ Events.MissionAccepted, typeof(MissionAcceptedEntry) },
|
||||||
|
{ Events.MissionCompleted, typeof(MissionCompletedEntry) },
|
||||||
|
{ Events.MissionFailed, typeof(MissionFailedEntry) },
|
||||||
|
{ Events.MissionRedirected, typeof(MissionRedirectedEntry) },
|
||||||
|
{ Events.Missions, typeof(MissionsEntry) },
|
||||||
|
{ Events.MultiSellExplorationData, typeof(MultiSellExplorationDataEntry) },
|
||||||
|
{ Events.Music, typeof(MusicEntry) },
|
||||||
|
{ Events.Powerplay, typeof(PowerplayEntry) },
|
||||||
|
{ Events.PowerplayCollect, typeof(PowerplayCollectEntry) },
|
||||||
|
{ Events.PowerplayDeliver, typeof(PowerplayDeliverEntry) },
|
||||||
|
{ Events.PowerplayMerits, typeof(PowerplayMeritsEntry) },
|
||||||
|
{ Events.PowerplayRank, typeof(PowerplayRankEntry) },
|
||||||
|
{ Events.ReceiveText, typeof(ReceiveTextEntry) },
|
||||||
|
{ Events.RedeemVoucher, typeof(RedeemVoucherEntry) },
|
||||||
|
{ Events.SearchAndRescue, typeof(SearchAndRescueEntry) },
|
||||||
|
{ Events.SelfDestruct, typeof(SelfDestructEntry) },
|
||||||
|
{ Events.SellExplorationData, typeof(SellExplorationDataEntry) },
|
||||||
|
{ Events.SellMicroResources, typeof(SellMicroResourcesEntry) },
|
||||||
|
{ Events.SellOrganicData, typeof(SellOrganicDataEntry) },
|
||||||
|
{ Events.ShieldState, typeof(ShieldStateEntry) },
|
||||||
|
{ Events.ShipTargeted, typeof(ShipTargetedEntry) },
|
||||||
|
{ Events.SupercruiseDestinationDrop, typeof(SupercruiseDestinationDropEntry) },
|
||||||
|
{ Events.SupercruiseEntry, typeof(SupercruiseEntryEntry) },
|
||||||
|
{ Events.SupercruiseExit, typeof(SupercruiseExitEntry) },
|
||||||
|
{ Events.UnderAttack, typeof(UnderAttackEntry) },
|
||||||
|
};
|
||||||
|
|
||||||
|
private string? eventtype = null;
|
||||||
|
private string? datetime = null;
|
||||||
|
private DateTime timestamp;
|
||||||
|
|
||||||
|
private string? jsonstr = null;
|
||||||
|
protected JObject? json = null;
|
||||||
|
|
||||||
|
public Entry() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Entry? Parse(string journalline) {
|
||||||
|
using (JsonReader reader = new JsonTextReader(new StringReader(journalline))) {
|
||||||
|
reader.DateParseHandling = DateParseHandling.None;
|
||||||
|
JObject? json = null;
|
||||||
|
try {
|
||||||
|
json = JObject.Load(reader);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new InvalidJournalEntryException(
|
||||||
|
"invalid JSON journal entry: " + journalline,
|
||||||
|
e
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (json == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return Parse(json);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Entry? Parse(JObject json) {
|
||||||
|
string? event_name = json.Value<string?>("event");
|
||||||
|
|
||||||
|
if (event_name == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
classes.TryGetValue(event_name, out Type? classhandler);
|
||||||
|
if (classhandler == null) {
|
||||||
|
// No specific handler available so use base class
|
||||||
|
classhandler = typeof(Entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
Entry? obj = (Entry?)Activator.CreateInstance(classhandler);
|
||||||
|
if (obj == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
obj.InternalInitialise(json);
|
||||||
|
obj.Initialise();
|
||||||
|
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void InternalInitialise(JObject jobject) {
|
||||||
|
this.json = jobject;
|
||||||
|
this.jsonstr = json.ToString(formatting: Formatting.None);
|
||||||
|
|
||||||
|
this.eventtype = json.Value<string>("event");
|
||||||
|
// Do not change this or JSON parser will conver the string to
|
||||||
|
// datetime object and call .ToString() on it which changes the
|
||||||
|
// date and time format
|
||||||
|
this.datetime = json.GetValue("timestamp")?.ToString();
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(this.datetime)) {
|
||||||
|
this.timestamp = DateTime.Parse(this.datetime, null, System.Globalization.DateTimeStyles.RoundtripKind);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void Initialise() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Is(string eventtype) {
|
||||||
|
if (eventtype == null || this.eventtype == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return String.Equals(this.eventtype, eventtype, StringComparison.OrdinalIgnoreCase);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string? Event {
|
||||||
|
get { return eventtype; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public DateTime Timestamp {
|
||||||
|
get { return timestamp; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public JObject JSON {
|
||||||
|
get { return this.json ?? new JObject(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string ToString() {
|
||||||
|
return jsonstr ?? "";
|
||||||
|
}
|
||||||
|
}
|
51
EDPlayerJournal/Entries/Events.cs
Normal file
51
EDPlayerJournal/Entries/Events.cs
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
namespace EDPlayerJournal.Entries;
|
||||||
|
|
||||||
|
public class Events {
|
||||||
|
public static readonly string ApproachSettlement = "ApproachSettlement";
|
||||||
|
public static readonly string Bounty = "Bounty";
|
||||||
|
public static readonly string CapShipBond = "CapShipBond";
|
||||||
|
public static readonly string CarrierJump = "CarrierJump";
|
||||||
|
public static readonly string Commander = "Commander";
|
||||||
|
public static readonly string CommitCrime = "CommitCrime";
|
||||||
|
public static readonly string Died = "Died";
|
||||||
|
public static readonly string Disembark = "Disembark";
|
||||||
|
public static readonly string Docked = "Docked";
|
||||||
|
public static readonly string DropshipDeploy = "DropshipDeploy";
|
||||||
|
public static readonly string Embark = "Embark";
|
||||||
|
public static readonly string FactionKillBond = "FactionKillBond";
|
||||||
|
public static readonly string FighterDestroyed = "FighterDestroyed";
|
||||||
|
public static readonly string FileHeader = "Fileheader";
|
||||||
|
public static readonly string FSDJump = "FSDJump";
|
||||||
|
public static readonly string HullDamage = "HullDamage";
|
||||||
|
public static readonly string LoadGame = "LoadGame";
|
||||||
|
public static readonly string Location = "Location";
|
||||||
|
public static readonly string MarketBuy = "MarketBuy";
|
||||||
|
public static readonly string MarketSell = "MarketSell";
|
||||||
|
public static readonly string MissionAbandoned = "MissionAbandoned";
|
||||||
|
public static readonly string MissionAccepted = "MissionAccepted";
|
||||||
|
public static readonly string MissionCompleted = "MissionCompleted";
|
||||||
|
public static readonly string MissionFailed = "MissionFailed";
|
||||||
|
public static readonly string MissionRedirected = "MissionRedirected";
|
||||||
|
public static readonly string Missions = "Missions";
|
||||||
|
public static readonly string MultiSellExplorationData = "MultiSellExplorationData";
|
||||||
|
public static readonly string Music = "Music";
|
||||||
|
public static readonly string Powerplay = "Powerplay";
|
||||||
|
public static readonly string PowerplayCollect = "PowerplayCollect";
|
||||||
|
public static readonly string PowerplayDeliver = "PowerplayDeliver";
|
||||||
|
public static readonly string PowerplayMerits = "PowerplayMerits";
|
||||||
|
public static readonly string PowerplayRank = "PowerplayRank";
|
||||||
|
public static readonly string ReceiveText = "ReceiveText";
|
||||||
|
public static readonly string RedeemVoucher = "RedeemVoucher";
|
||||||
|
public static readonly string SearchAndRescue = "SearchAndRescue";
|
||||||
|
public static readonly string SelfDestruct = "SelfDestruct";
|
||||||
|
public static readonly string SellExplorationData = "SellExplorationData";
|
||||||
|
public static readonly string SellMicroResources = "SellMicroResources";
|
||||||
|
public static readonly string SellOrganicData = "SellOrganicData";
|
||||||
|
public static readonly string ShieldState = "ShieldState";
|
||||||
|
public static readonly string ShipTargeted = "ShipTargeted";
|
||||||
|
public static readonly string Shutdown = "Shutdown";
|
||||||
|
public static readonly string SupercruiseDestinationDrop = "SupercruiseDestinationDrop";
|
||||||
|
public static readonly string SupercruiseEntry = "SupercruiseEntry";
|
||||||
|
public static readonly string SupercruiseExit = "SupercruiseExit";
|
||||||
|
public static readonly string UnderAttack = "UnderAttack";
|
||||||
|
}
|
35
EDPlayerJournal/Entries/FSDJumpEntry.cs
Normal file
35
EDPlayerJournal/Entries/FSDJumpEntry.cs
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
|
||||||
|
namespace EDPlayerJournal.Entries;
|
||||||
|
public class FSDJumpEntry : Entry {
|
||||||
|
protected override void Initialise() {
|
||||||
|
SystemAddress = JSON.Value<ulong?>("SystemAddress") ?? 0;
|
||||||
|
StarSystem = JSON.Value<string>("StarSystem");
|
||||||
|
|
||||||
|
var pos = JSON.Value<JArray>("SarPos");
|
||||||
|
if (pos != null) {
|
||||||
|
StarPos = pos.ToObject<long[]>();
|
||||||
|
}
|
||||||
|
|
||||||
|
var faction = JSON.Value<JObject>("SystemFaction");
|
||||||
|
if (faction != null) {
|
||||||
|
SystemFaction = faction.Value<string>("Name");
|
||||||
|
}
|
||||||
|
|
||||||
|
var factions = JSON.Value<JArray>("Factions");
|
||||||
|
if (factions != null) {
|
||||||
|
foreach (JObject system_faction in factions) {
|
||||||
|
Faction? f = Faction.FromJSON(system_faction);
|
||||||
|
if (f != null) {
|
||||||
|
SystemFactions.Add(f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public long[]? StarPos { get; set; }
|
||||||
|
public string? StarSystem { get; set; }
|
||||||
|
public string? SystemFaction { get; set; }
|
||||||
|
public ulong SystemAddress { get; set; }
|
||||||
|
public List<Faction> SystemFactions { get; set; } = new List<Faction>();
|
||||||
|
}
|
32
EDPlayerJournal/Entries/FactionKillBondEntry.cs
Normal file
32
EDPlayerJournal/Entries/FactionKillBondEntry.cs
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
namespace EDPlayerJournal.Entries;
|
||||||
|
|
||||||
|
public class FactionKillBondEntry : Entry {
|
||||||
|
/// <summary>
|
||||||
|
/// Reward given
|
||||||
|
/// </summary>
|
||||||
|
public ulong Reward { get; set; } = 0;
|
||||||
|
/// <summary>
|
||||||
|
/// Faction that awarded the kill bond
|
||||||
|
/// </summary>
|
||||||
|
public string? AwardingFaction { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Localised string of the awarding faction if available
|
||||||
|
/// </summary>
|
||||||
|
public string? AwardingFactionLocalised { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Victim faction, internal name
|
||||||
|
/// </summary>
|
||||||
|
public string? VictimFaction { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Localised name of the victim faction
|
||||||
|
/// </summary>
|
||||||
|
public string? VictimFactionLocalised { get; set; }
|
||||||
|
|
||||||
|
protected override void Initialise() {
|
||||||
|
Reward = JSON.Value<ulong?>("Reward") ?? 0;
|
||||||
|
AwardingFaction = JSON.Value<string>("AwardingFaction");
|
||||||
|
AwardingFactionLocalised = JSON.Value<string>("AwardingFaction_Localised");
|
||||||
|
VictimFaction = JSON.Value<string>("VictimFaction");
|
||||||
|
VictimFactionLocalised = JSON.Value<string>("VictimFaction_Localised");
|
||||||
|
}
|
||||||
|
}
|
53
EDPlayerJournal/Entries/FileHeaderEntry.cs
Normal file
53
EDPlayerJournal/Entries/FileHeaderEntry.cs
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
namespace EDPlayerJournal.Entries;
|
||||||
|
|
||||||
|
public class FileHeaderEntry : Entry {
|
||||||
|
/// <summary>
|
||||||
|
/// File part.
|
||||||
|
/// </summary>
|
||||||
|
public ulong Part { get; set; } = 1;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Local language of the file.
|
||||||
|
/// </summary>
|
||||||
|
public string? Language { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether the file is for an Odyssey version
|
||||||
|
/// </summary>
|
||||||
|
public bool Odyssey { get; set; } = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Game version in question (3.8 or 4.0)
|
||||||
|
/// </summary>
|
||||||
|
public string GameVersion { get; set; } = "3.8";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Build version (SVN revision number).
|
||||||
|
/// </summary>
|
||||||
|
public string? Build { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns true if the version is legacy (3.X)
|
||||||
|
/// <summary>
|
||||||
|
public bool IsLegacy {
|
||||||
|
get {
|
||||||
|
return GameVersion.StartsWith("3.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns true if the version is live (4.x)
|
||||||
|
/// </summary>
|
||||||
|
public bool IsLive {
|
||||||
|
get { return !IsLegacy; }
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Initialise() {
|
||||||
|
Part = JSON.Value<ulong?>("part") ?? 1;
|
||||||
|
Language = JSON.Value<string?>("language") ?? string.Empty;
|
||||||
|
// If this entry is not there then its a legacy entry
|
||||||
|
Odyssey = JSON.Value<bool?>("Odyssey") ?? false;
|
||||||
|
GameVersion = JSON.Value<string?>("gameversion") ?? "3.8";
|
||||||
|
Build = JSON.Value<string?>("build");
|
||||||
|
}
|
||||||
|
}
|
16
EDPlayerJournal/Entries/HullDamageEntry.cs
Normal file
16
EDPlayerJournal/Entries/HullDamageEntry.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
namespace EDPlayerJournal.Entries;
|
||||||
|
public class HullDamageEntry : Entry {
|
||||||
|
private double health = 0;
|
||||||
|
private bool playerpilot = false;
|
||||||
|
private bool fighter = false;
|
||||||
|
|
||||||
|
public double Health => health;
|
||||||
|
public bool PlayerPilot => playerpilot;
|
||||||
|
public bool Fighter => fighter;
|
||||||
|
|
||||||
|
protected override void Initialise() {
|
||||||
|
health = JSON.Value<double?>("Health") ?? 100.0;
|
||||||
|
playerpilot = JSON.Value<bool?>("PlayerPilot") ?? true;
|
||||||
|
fighter = JSON.Value<bool?>("Fighter") ?? false;
|
||||||
|
}
|
||||||
|
}
|
51
EDPlayerJournal/Entries/LoadGameEntry.cs
Normal file
51
EDPlayerJournal/Entries/LoadGameEntry.cs
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace EDPlayerJournal.Entries;
|
||||||
|
public class LoadGameEntry : Entry {
|
||||||
|
public string? Commander { get; set; }
|
||||||
|
public string? FID { get; set; }
|
||||||
|
public bool Horizons { get; set; }
|
||||||
|
public bool Odyssey { get; set; }
|
||||||
|
public string? Ship { get; set; }
|
||||||
|
public long ShipID { get; set; }
|
||||||
|
public bool StartLanded { get; set; }
|
||||||
|
public bool StartDead { get; set; }
|
||||||
|
public string? GameMode { get; set; }
|
||||||
|
public string? Group { get; set; }
|
||||||
|
public long Credits { get; set; }
|
||||||
|
public long Loan { get; set; }
|
||||||
|
public string? ShipName { get; set; }
|
||||||
|
public string? ShipIdent { get; set; }
|
||||||
|
public double FuelLevel { get; set; }
|
||||||
|
public double FuelCapacity { get; set; }
|
||||||
|
|
||||||
|
protected override void Initialise() {
|
||||||
|
Commander = JSON.Value<string>("Commander");
|
||||||
|
FID = JSON.Value<string>("FID");
|
||||||
|
// Game
|
||||||
|
Horizons = JSON.Value<bool?>("Horizons") ?? false;
|
||||||
|
Odyssey = JSON.Value<bool?>("Odyssey") ?? false;
|
||||||
|
// Ships
|
||||||
|
Ship = JSON.Value<string>("Ship");
|
||||||
|
ShipID = JSON.Value<long?>("ShipID") ?? 0;
|
||||||
|
ShipName = JSON.Value<string>("ShipName");
|
||||||
|
ShipIdent = JSON.Value<string>("ShipIdent");
|
||||||
|
// Fuel
|
||||||
|
FuelLevel = JSON.Value<double?>("FuelLevel") ?? 0.0;
|
||||||
|
FuelCapacity = JSON.Value<double?>("FuelCapacity") ?? 0.0;
|
||||||
|
// Landed/Dead
|
||||||
|
StartLanded = JSON.Value<bool?>("StartLanded") ?? false;
|
||||||
|
StartDead = JSON.Value<bool?>("StartDead") ?? false;
|
||||||
|
// GameMode
|
||||||
|
GameMode = JSON.Value<string>("GameMode");
|
||||||
|
// Group
|
||||||
|
Group = JSON.Value<string>("Group");
|
||||||
|
// Wealth
|
||||||
|
Credits = JSON.Value<long?>("Credits") ?? 0;
|
||||||
|
Loan = JSON.Value<long?>("Loan") ?? 0;
|
||||||
|
}
|
||||||
|
}
|
80
EDPlayerJournal/Entries/LocationEntry.cs
Normal file
80
EDPlayerJournal/Entries/LocationEntry.cs
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
|
||||||
|
namespace EDPlayerJournal.Entries;
|
||||||
|
|
||||||
|
public class LocationEntry : Entry {
|
||||||
|
/// <summary>
|
||||||
|
/// Current star system.
|
||||||
|
/// </summary>
|
||||||
|
public string? StarSystem { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Faction in control of the current star system. Empty for unpopulated
|
||||||
|
/// systems.
|
||||||
|
/// </summary>
|
||||||
|
public string? SystemFaction { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 64bit system address.
|
||||||
|
/// </summary>
|
||||||
|
public ulong SystemAddress { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Station name if docked at a station.
|
||||||
|
/// </summary>
|
||||||
|
public string? StationName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Faction in control of the current station, if docked.
|
||||||
|
/// </summary>
|
||||||
|
public string? StationFaction { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Body within the system, might be null.
|
||||||
|
/// </summary>
|
||||||
|
public string? Body { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns true if the player is docked somewhere.
|
||||||
|
/// </summary>
|
||||||
|
public bool Docked { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Position of the star system.
|
||||||
|
/// </summary>
|
||||||
|
public long[]? StarPos { get; set; }
|
||||||
|
|
||||||
|
public List<Faction> SystemFactions { get; set; } = new List<Faction>();
|
||||||
|
|
||||||
|
protected override void Initialise() {
|
||||||
|
StarSystem = JSON.Value<string>("StarSystem") ?? "";
|
||||||
|
SystemAddress = JSON.Value<ulong?>("SystemAddress") ?? 0;
|
||||||
|
Docked = JSON.Value<bool?>("Docked") ?? false;
|
||||||
|
StationName = JSON.Value<string>("StationName") ?? "";
|
||||||
|
|
||||||
|
var pos = JSON.Value<JArray>("StarPos");
|
||||||
|
if (pos != null) {
|
||||||
|
StarPos = pos.ToObject<long[]>();
|
||||||
|
}
|
||||||
|
|
||||||
|
JObject? systemfaction = JSON.Value<JObject>("SystemFaction");
|
||||||
|
if (systemfaction != null) {
|
||||||
|
SystemFaction = systemfaction.Value<string>("Name");
|
||||||
|
}
|
||||||
|
|
||||||
|
JObject? stationfaction = JSON.Value<JObject>("StationFaction");
|
||||||
|
if (stationfaction != null) {
|
||||||
|
StationFaction = stationfaction.Value<string>("Name");
|
||||||
|
}
|
||||||
|
|
||||||
|
JArray? factions = JSON.Value<JArray>("Factions");
|
||||||
|
if (factions != null) {
|
||||||
|
foreach (JObject system_faction in factions) {
|
||||||
|
Faction? f = Faction.FromJSON(system_faction);
|
||||||
|
if (f != null) {
|
||||||
|
SystemFactions.Add(f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
22
EDPlayerJournal/Entries/MarketBuyEntry.cs
Normal file
22
EDPlayerJournal/Entries/MarketBuyEntry.cs
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace EDPlayerJournal.Entries;
|
||||||
|
public class MarketBuyEntry : Entry {
|
||||||
|
public string? Type { get; set; }
|
||||||
|
public string? TypeLocalised { get; set; }
|
||||||
|
public long Count { get; set; }
|
||||||
|
public long BuyPrice { get; set; }
|
||||||
|
public long TotalCost { get; set; }
|
||||||
|
|
||||||
|
protected override void Initialise() {
|
||||||
|
Type = JSON.Value<string>("Type");
|
||||||
|
TypeLocalised = JSON.Value<string>("Type_Localised");
|
||||||
|
Count = JSON.Value<long?>("Count") ?? 0;
|
||||||
|
BuyPrice = JSON.Value<long?>("BuyPrice") ?? 0;
|
||||||
|
TotalCost = JSON.Value<long?>("TotalCost") ?? 0;
|
||||||
|
}
|
||||||
|
}
|
50
EDPlayerJournal/Entries/MarketSellEntry.cs
Normal file
50
EDPlayerJournal/Entries/MarketSellEntry.cs
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
namespace EDPlayerJournal.Entries;
|
||||||
|
public class MarketSellEntry : Entry {
|
||||||
|
/// <summary>
|
||||||
|
/// Total value
|
||||||
|
/// </summary>
|
||||||
|
public int TotalSale { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// How many.
|
||||||
|
/// </summary>
|
||||||
|
public int Count { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Average price paid
|
||||||
|
/// </summary>
|
||||||
|
public int AvgPricePaid { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Cargo type
|
||||||
|
/// </summary>
|
||||||
|
public string? Type { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Localised name of the cargo sold, may be null.
|
||||||
|
/// </summary>
|
||||||
|
public string? TypeLocalised { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Price per unit
|
||||||
|
/// </summary>
|
||||||
|
public int SellPrice { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Whether the goods were illegal in the target system.
|
||||||
|
/// </summary>
|
||||||
|
public bool IllegalGoods { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Whether the goods were stolen
|
||||||
|
/// </summary>
|
||||||
|
public bool StolenGoods { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Whether the goods were sold to the black market
|
||||||
|
/// </summary>
|
||||||
|
public bool BlackMarket { get; set; }
|
||||||
|
|
||||||
|
protected override void Initialise() {
|
||||||
|
Type = JSON.Value<string>("Type");
|
||||||
|
TypeLocalised = JSON.Value<string>("Type_Localised");
|
||||||
|
TotalSale = JSON.Value<int?>("TotalSale") ?? 0;
|
||||||
|
Count = JSON.Value<int?>("Count") ?? 0;
|
||||||
|
AvgPricePaid = JSON.Value<int?>("AvgPricePaid") ?? 0;
|
||||||
|
IllegalGoods = JSON.Value<bool?>("IllegalGoods") ?? false;
|
||||||
|
StolenGoods = JSON.Value<bool?>("StolenGoods") ?? false;
|
||||||
|
BlackMarket = JSON.Value<bool?>("BlackMarket") ?? false;
|
||||||
|
}
|
||||||
|
}
|
9
EDPlayerJournal/Entries/MissionAbandonedEntry.cs
Normal file
9
EDPlayerJournal/Entries/MissionAbandonedEntry.cs
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
namespace EDPlayerJournal.Entries;
|
||||||
|
|
||||||
|
public class MissionAbandonedEntry : Entry {
|
||||||
|
public Mission? Mission { get; set; }
|
||||||
|
|
||||||
|
protected override void Initialise() {
|
||||||
|
Mission = Mission.FromMissionAbandoned(JSON);
|
||||||
|
}
|
||||||
|
}
|
9
EDPlayerJournal/Entries/MissionAcceptedEntry.cs
Normal file
9
EDPlayerJournal/Entries/MissionAcceptedEntry.cs
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
namespace EDPlayerJournal.Entries;
|
||||||
|
|
||||||
|
public class MissionAcceptedEntry : Entry {
|
||||||
|
public Mission? Mission { get; set; }
|
||||||
|
|
||||||
|
protected override void Initialise() {
|
||||||
|
Mission = Mission.FromMissionAccepted(JSON);
|
||||||
|
}
|
||||||
|
}
|
9
EDPlayerJournal/Entries/MissionCompletedEntry.cs
Normal file
9
EDPlayerJournal/Entries/MissionCompletedEntry.cs
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
namespace EDPlayerJournal.Entries;
|
||||||
|
|
||||||
|
public class MissionCompletedEntry : Entry {
|
||||||
|
public Mission? Mission { get; set; }
|
||||||
|
|
||||||
|
protected override void Initialise() {
|
||||||
|
Mission = Mission.FromMissionCompleted(JSON);
|
||||||
|
}
|
||||||
|
}
|
15
EDPlayerJournal/Entries/MissionFailedEntry.cs
Normal file
15
EDPlayerJournal/Entries/MissionFailedEntry.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
namespace EDPlayerJournal.Entries;
|
||||||
|
|
||||||
|
public class MissionFailedEntry : Entry {
|
||||||
|
/// <summary>
|
||||||
|
/// Fine imposed for mission failure.
|
||||||
|
/// </summary>
|
||||||
|
public int Fine { get; set; }
|
||||||
|
|
||||||
|
public Mission? Mission { get; set; }
|
||||||
|
|
||||||
|
protected override void Initialise() {
|
||||||
|
Mission = Mission.FromMissionFailed(JSON);
|
||||||
|
Fine = JSON.Value<int?>("Fine") ?? 0;
|
||||||
|
}
|
||||||
|
}
|
16
EDPlayerJournal/Entries/MissionRedirectedEntry.cs
Normal file
16
EDPlayerJournal/Entries/MissionRedirectedEntry.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
namespace EDPlayerJournal.Entries;
|
||||||
|
public class MissionRedirectedEntry : Entry {
|
||||||
|
public int MissionID { get; set; } = 0;
|
||||||
|
public string? Name { get; set; }
|
||||||
|
public string? NewDestinationStation { get; set; }
|
||||||
|
public string? NewDestinationSystem { get; set; }
|
||||||
|
public string? OldDestinationSystem { get; set; }
|
||||||
|
|
||||||
|
protected override void Initialise() {
|
||||||
|
MissionID = (JSON.Value<int?>("MissionID") ?? 0);
|
||||||
|
Name = JSON.Value<string>("Name");
|
||||||
|
NewDestinationStation = JSON.Value<string>("NewDestinationStation");
|
||||||
|
NewDestinationSystem = JSON.Value<string>("NewDestinationSystem");
|
||||||
|
OldDestinationSystem = JSON.Value<string>("OldDestinationSystem");
|
||||||
|
}
|
||||||
|
}
|
48
EDPlayerJournal/Entries/MissionsEntry.cs
Normal file
48
EDPlayerJournal/Entries/MissionsEntry.cs
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
|
||||||
|
namespace EDPlayerJournal.Entries;
|
||||||
|
|
||||||
|
public class MissionsEntry : Entry {
|
||||||
|
/// <summary>
|
||||||
|
/// List of currently active mission.
|
||||||
|
/// </summary>
|
||||||
|
public List<Mission> Active { get; set; } = new List<Mission>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// List of failed missions, not yet discarded.
|
||||||
|
/// </summary>
|
||||||
|
public List<Mission> Failed { get; set; } = new List<Mission>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// List of completed missions, not yet turned in.
|
||||||
|
/// </summary>
|
||||||
|
public List<Mission> Complete { get; set; } = new List<Mission>();
|
||||||
|
|
||||||
|
protected override void Initialise() {
|
||||||
|
JArray? arr;
|
||||||
|
|
||||||
|
arr = JSON.Value<JArray?>("Active");
|
||||||
|
if (arr != null) {
|
||||||
|
foreach (JObject item in arr.Children().OfType<JObject>()) {
|
||||||
|
Mission m = Mission.FromMissionAccepted(item);
|
||||||
|
Active.Add(m);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
arr = JSON.Value<JArray?>("Failed");
|
||||||
|
if (arr != null) {
|
||||||
|
foreach (JObject item in arr.Children().OfType<JObject>()) {
|
||||||
|
Mission m = Mission.FromMissionAccepted(item);
|
||||||
|
Failed.Add(m);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
arr = JSON.Value<JArray?>("Complete");
|
||||||
|
if (arr != null) {
|
||||||
|
foreach (JObject item in arr.Children().OfType<JObject>()) {
|
||||||
|
Mission m = Mission.FromMissionAccepted(item);
|
||||||
|
Complete.Add(m);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
23
EDPlayerJournal/Entries/MultiSellExplorationDataEntry.cs
Normal file
23
EDPlayerJournal/Entries/MultiSellExplorationDataEntry.cs
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
namespace EDPlayerJournal.Entries;
|
||||||
|
|
||||||
|
public class MultiSellExplorationDataEntry : Entry {
|
||||||
|
protected override void Initialise() {
|
||||||
|
TotalEarnings = JSON.Value<long?>("TotalEarnings") ?? 0;
|
||||||
|
BaseValue = JSON.Value<long?>("BaseValue") ?? 0;
|
||||||
|
Bonus = JSON.Value<long?>("Bonus") ?? 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long Total {
|
||||||
|
get { return BaseValue + Bonus; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public long BaseValue { get; set; } = 0;
|
||||||
|
|
||||||
|
public long Bonus { get; set; } = 0;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Total Earnings are the actual earnings without bonus. So this
|
||||||
|
/// value is BaseValue minus any percent a crew pilot takes.
|
||||||
|
/// </summary>
|
||||||
|
public long TotalEarnings { get; set; } = 0;
|
||||||
|
}
|
9
EDPlayerJournal/Entries/MusicEntry.cs
Normal file
9
EDPlayerJournal/Entries/MusicEntry.cs
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
namespace EDPlayerJournal.Entries;
|
||||||
|
|
||||||
|
public class MusicEntry : Entry {
|
||||||
|
public string? MusicTrack { get; set; } = null;
|
||||||
|
|
||||||
|
protected override void Initialise() {
|
||||||
|
MusicTrack = JSON.Value<string?>("MusicTrack");
|
||||||
|
}
|
||||||
|
}
|
7
EDPlayerJournal/Entries/PowerplayCollectEntry.cs
Normal file
7
EDPlayerJournal/Entries/PowerplayCollectEntry.cs
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
namespace EDPlayerJournal.Entries;
|
||||||
|
|
||||||
|
public class PowerplayCollectEntry : Entry {
|
||||||
|
protected override void Initialise() {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
}
|
7
EDPlayerJournal/Entries/PowerplayDeliverEntry.cs
Normal file
7
EDPlayerJournal/Entries/PowerplayDeliverEntry.cs
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
namespace EDPlayerJournal.Entries;
|
||||||
|
|
||||||
|
public class PowerplayDeliverEntry : Entry {
|
||||||
|
protected override void Initialise() {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
}
|
32
EDPlayerJournal/Entries/PowerplayEntry.cs
Normal file
32
EDPlayerJournal/Entries/PowerplayEntry.cs
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
using System.Reflection;
|
||||||
|
|
||||||
|
namespace EDPlayerJournal.Entries {
|
||||||
|
public class PowerplayEntry : Entry {
|
||||||
|
/// <summary>
|
||||||
|
/// Name of the power
|
||||||
|
/// </summary>
|
||||||
|
public string Power { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Player rank
|
||||||
|
/// </summary>
|
||||||
|
public int Rank { get; set; } = 0;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Current merits of the player
|
||||||
|
/// </summary>
|
||||||
|
public long Merits { get; set; } = 0;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Time pledged (in seconds?)
|
||||||
|
/// </summary>
|
||||||
|
public long TimePledged { get; set; } = 0;
|
||||||
|
|
||||||
|
protected override void Initialise() {
|
||||||
|
Power = JSON.Value<string>("Power") ?? string.Empty;
|
||||||
|
Rank = JSON.Value<int?>("Rank") ?? 0;
|
||||||
|
Merits = JSON.Value<long?>("Merits") ?? 0;
|
||||||
|
TimePledged = JSON.Value<long?>("TimePledged") ?? 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
15
EDPlayerJournal/Entries/PowerplayMeritsEntry.cs
Normal file
15
EDPlayerJournal/Entries/PowerplayMeritsEntry.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
namespace EDPlayerJournal.Entries;
|
||||||
|
|
||||||
|
public class PowerplayMeritsEntry : Entry {
|
||||||
|
protected override void Initialise() {
|
||||||
|
Power = JSON.Value<string?>("Power") ?? string.Empty;
|
||||||
|
MeritsGained = JSON.Value<long?>("MeritsGained") ?? 0;
|
||||||
|
TotalMerits = JSON.Value<long?>("TotalMerits") ?? 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Power { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public long MeritsGained { get; set; } = 0;
|
||||||
|
|
||||||
|
public long TotalMerits { get; set; } = 0;
|
||||||
|
}
|
7
EDPlayerJournal/Entries/PowerplayRankEntry.cs
Normal file
7
EDPlayerJournal/Entries/PowerplayRankEntry.cs
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
namespace EDPlayerJournal.Entries;
|
||||||
|
|
||||||
|
public class PowerplayRankEntry : Entry {
|
||||||
|
protected override void Initialise() {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
}
|
77
EDPlayerJournal/Entries/ReceiveTextEntry.cs
Normal file
77
EDPlayerJournal/Entries/ReceiveTextEntry.cs
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
namespace EDPlayerJournal.Entries;
|
||||||
|
|
||||||
|
public class ReceiveTextEntry : Entry {
|
||||||
|
/// <summary>
|
||||||
|
/// From whom this message is
|
||||||
|
/// </summary>
|
||||||
|
public string? From { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// The message, if it is just an NPC text, it will be a message ID
|
||||||
|
/// </summary>
|
||||||
|
public string? Message { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Message localised
|
||||||
|
/// </summary>
|
||||||
|
public string? MessageLocalised { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// On what channel this was received.
|
||||||
|
/// </summary>
|
||||||
|
public string? Channel { get; set; }
|
||||||
|
|
||||||
|
public bool HasNPCCategory {
|
||||||
|
get {
|
||||||
|
if (From == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (From.Contains(';') && From.StartsWith("$")) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the NPC's category, if it has one.
|
||||||
|
/// </summary>
|
||||||
|
public string? NPCCategory {
|
||||||
|
get {
|
||||||
|
if (!HasNPCCategory || From == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
string[] parts = From.Split(";", StringSplitOptions.TrimEntries);
|
||||||
|
if (parts.Length < 2) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return string.Format("{0};", parts[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the NPC's category, if it has one.
|
||||||
|
/// </summary>
|
||||||
|
public string? NPCName {
|
||||||
|
get {
|
||||||
|
if (!HasNPCCategory || From == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
string[] parts = From.Split(";", StringSplitOptions.TrimEntries);
|
||||||
|
if (parts.Length < 2) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return parts[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Initialise() {
|
||||||
|
From = JSON.Value<string>("From");
|
||||||
|
Message = JSON.Value<string>("Message");
|
||||||
|
MessageLocalised = JSON.Value<string>("Message_localised");
|
||||||
|
Channel = JSON.Value<string>("Channel");
|
||||||
|
}
|
||||||
|
}
|
63
EDPlayerJournal/Entries/RedeemVoucherEntry.cs
Normal file
63
EDPlayerJournal/Entries/RedeemVoucherEntry.cs
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace EDPlayerJournal.Entries;
|
||||||
|
public class RedeemVoucherEntry : Entry {
|
||||||
|
protected override void Initialise() {
|
||||||
|
Amount = (JSON.Value<ulong?>("Amount") ?? 0);
|
||||||
|
Type = JSON.Value<string>("Type");
|
||||||
|
|
||||||
|
/* according to API, there should be a Factions structure */
|
||||||
|
JToken? factions = JSON.GetValue("Factions");
|
||||||
|
if (factions != null) {
|
||||||
|
foreach (JObject faction in factions.Children<JObject>()) {
|
||||||
|
string? faction_name = faction.Value<string>("Faction");
|
||||||
|
ulong? faction_bounty = faction.Value<ulong?>("Amount");
|
||||||
|
if (faction_name == null || faction_name.Length <= 0 || faction_bounty == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Factions.Add(faction_name);
|
||||||
|
if (!FactionBounties.ContainsKey(faction_name)) {
|
||||||
|
FactionBounties[faction_name] = 0;
|
||||||
|
}
|
||||||
|
FactionBounties[faction_name] += (faction_bounty ?? 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* but there also might be just a Faction entry */
|
||||||
|
string? single_faction = JSON.Value<string>("Faction");
|
||||||
|
if (single_faction != null) {
|
||||||
|
Factions.Add(single_faction);
|
||||||
|
if (!FactionBounties.ContainsKey(single_faction)) {
|
||||||
|
FactionBounties[single_faction] = 0;
|
||||||
|
}
|
||||||
|
FactionBounties[single_faction] += Amount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ulong GetBountyForFaction(string? a) {
|
||||||
|
if (a == null) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
var relevant = FactionBounties.Where(x => EDPlayerJournal.Factions.CompareFactions(x.Key, a) == 0).ToList();
|
||||||
|
if (relevant == null || relevant.Count() == 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (ulong)relevant.Sum(x => (decimal)x.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ulong Amount { get; set; } = 0;
|
||||||
|
public string? Type { get; set; } = "Bounty";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// List of factions
|
||||||
|
/// </summary>
|
||||||
|
public List<string> Factions { get; set; } = new();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Bounties awarded by faction
|
||||||
|
/// </summary>
|
||||||
|
public Dictionary<string, ulong> FactionBounties { get; set; } = new();
|
||||||
|
}
|
18
EDPlayerJournal/Entries/SearchAndRescueEntry.cs
Normal file
18
EDPlayerJournal/Entries/SearchAndRescueEntry.cs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
namespace EDPlayerJournal.Entries;
|
||||||
|
public class SearchAndRescueEntry : Entry {
|
||||||
|
public long MarketID { get; set; }
|
||||||
|
public string? Name { get; set; }
|
||||||
|
public string? NameLocalised { get; set; }
|
||||||
|
public long Count { get; set; }
|
||||||
|
public long Reward { get; set; }
|
||||||
|
|
||||||
|
protected override void Initialise() {
|
||||||
|
MarketID = JSON.Value<long?>("MarketID") ?? 0;
|
||||||
|
Name = JSON.Value<string>("Name") ?? "";
|
||||||
|
NameLocalised = JSON.Value<string>("Name_Localised");
|
||||||
|
Count = JSON.Value<long?>("Count") ?? 0;
|
||||||
|
Reward = JSON.Value<long?>("Reward") ?? 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
5
EDPlayerJournal/Entries/SelfDestructEntry.cs
Normal file
5
EDPlayerJournal/Entries/SelfDestructEntry.cs
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
namespace EDPlayerJournal.Entries {
|
||||||
|
public class SelfDestructEntry : Entry {
|
||||||
|
// Has no data
|
||||||
|
}
|
||||||
|
}
|
38
EDPlayerJournal/Entries/SellExplorationDataEntry.cs
Normal file
38
EDPlayerJournal/Entries/SellExplorationDataEntry.cs
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace EDPlayerJournal.Entries;
|
||||||
|
public class SellExplorationDataEntry : Entry {
|
||||||
|
public long BaseValue { get; set; }
|
||||||
|
public long Bonus { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Total Earnings are the actual earnings without bonus. So this
|
||||||
|
/// value is BaseValue minus any percent a crew pilot takes.
|
||||||
|
/// </summary>
|
||||||
|
public long TotalEarnings { get; set; }
|
||||||
|
|
||||||
|
public long Total {
|
||||||
|
get { return BaseValue + Bonus; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<string> Systems { get; set; } = new List<string>();
|
||||||
|
public List<string> Discovered { get; set; } = new List<string>();
|
||||||
|
|
||||||
|
protected override void Initialise() {
|
||||||
|
BaseValue = JSON.Value<long?>("BaseValue") ?? 0;
|
||||||
|
Bonus = JSON.Value<long?>("Bonus") ?? 0;
|
||||||
|
TotalEarnings = JSON.Value<long?>("TotalEarnings") ?? 0;
|
||||||
|
|
||||||
|
var sys = JSON.Value<JArray>("Systems");
|
||||||
|
if (sys != null) {
|
||||||
|
Systems = sys.Select(x => x.ToString()).ToList<string>();
|
||||||
|
}
|
||||||
|
|
||||||
|
var dis = JSON.Value<JArray>("Discovered");
|
||||||
|
if (dis != null) {
|
||||||
|
Discovered = dis.Select(x => x.ToString()).ToList<string>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
8
EDPlayerJournal/Entries/SellMicroResourcesEntry.cs
Normal file
8
EDPlayerJournal/Entries/SellMicroResourcesEntry.cs
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
namespace EDPlayerJournal.Entries;
|
||||||
|
public class SellMicroResourcesEntry : Entry {
|
||||||
|
protected override void Initialise() {
|
||||||
|
Price = JSON.Value<int>("Price");
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Price { get; set; }
|
||||||
|
}
|
48
EDPlayerJournal/Entries/SellOrganicDataEntry.cs
Normal file
48
EDPlayerJournal/Entries/SellOrganicDataEntry.cs
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
|
||||||
|
namespace EDPlayerJournal.Entries;
|
||||||
|
public class BioData {
|
||||||
|
public string? Genus { get; set; }
|
||||||
|
public string? GenusLocalised { get; set; }
|
||||||
|
public string? Species { get; set; }
|
||||||
|
public string? SpeciesLocalised { get; set; }
|
||||||
|
public long Value { get; set; } = 0;
|
||||||
|
public long Bonus { get; set; } = 0;
|
||||||
|
|
||||||
|
public long TotalValue {
|
||||||
|
get {
|
||||||
|
return Value + Bonus;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public class SellOrganicDataEntry : Entry {
|
||||||
|
public long MarketID { get; set; }
|
||||||
|
|
||||||
|
public List<BioData> BioData { get; } = new();
|
||||||
|
|
||||||
|
protected override void Initialise() {
|
||||||
|
MarketID = JSON.Value<long?>("MarketID") ?? 0;
|
||||||
|
|
||||||
|
var biodata = JSON.Value<JArray>("BioData");
|
||||||
|
if (biodata == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (JObject item in biodata) {
|
||||||
|
BioData data = new BioData {
|
||||||
|
Bonus = item.Value<long?>("Bonus") ?? 0,
|
||||||
|
Value = item.Value<long?>("Value") ?? 0,
|
||||||
|
Species = item.Value<string>("Species"),
|
||||||
|
Genus = item.Value<string>("Genus"),
|
||||||
|
GenusLocalised = item.Value<string>("Genus_Localised"),
|
||||||
|
SpeciesLocalised = item.Value<string>("Species_Localised")
|
||||||
|
};
|
||||||
|
|
||||||
|
BioData.Add(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public long TotalValue {
|
||||||
|
get { return BioData.Sum(x => x.TotalValue); }
|
||||||
|
}
|
||||||
|
}
|
7
EDPlayerJournal/Entries/ShieldStateEntry.cs
Normal file
7
EDPlayerJournal/Entries/ShieldStateEntry.cs
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
namespace EDPlayerJournal.Entries;
|
||||||
|
public class ShieldStateEntry : Entry {
|
||||||
|
public bool ShieldsUp { get; set; } = false;
|
||||||
|
protected override void Initialise() {
|
||||||
|
ShieldsUp = JSON.Value<bool?>("ShieldsUp") ?? true;
|
||||||
|
}
|
||||||
|
}
|
31
EDPlayerJournal/Entries/ShipTargetedEntry.cs
Normal file
31
EDPlayerJournal/Entries/ShipTargetedEntry.cs
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace EDPlayerJournal.Entries;
|
||||||
|
public class ShipTargetedEntry : Entry {
|
||||||
|
public string? Ship { get; set; }
|
||||||
|
public long ScanStage { get; set; }
|
||||||
|
public string? PilotName { get; set; }
|
||||||
|
public string? PilotNameLocalised { get; set; }
|
||||||
|
public string? PilotRank { get; set; }
|
||||||
|
public double ShieldHealth { get; set; }
|
||||||
|
public double HullHealth { get; set; }
|
||||||
|
public long Bounty { get; set; }
|
||||||
|
public string? LegalStatus { get; set; }
|
||||||
|
public string? Faction { get; set; }
|
||||||
|
public string? Power { get; set; }
|
||||||
|
|
||||||
|
protected override void Initialise() {
|
||||||
|
ScanStage = JSON.Value<long?>("ScanStage") ?? 0;
|
||||||
|
Ship = JSON.Value<string>("Ship_Localised");
|
||||||
|
PilotName = JSON.Value<string>("PilotName");
|
||||||
|
PilotNameLocalised = JSON.Value<string>("PilotName_Localised");
|
||||||
|
PilotRank = JSON.Value<string>("PilotRank");
|
||||||
|
ShieldHealth = JSON.Value<double?>("ShieldHealth") ?? 0.0;
|
||||||
|
HullHealth = JSON.Value<double?>("HullHealth") ?? 0.0;
|
||||||
|
Bounty = JSON.Value<long?>("Bounty") ?? 0;
|
||||||
|
LegalStatus = JSON.Value<string>("LegalStatus") ?? "Clean";
|
||||||
|
Faction = JSON.Value<string>("Faction");
|
||||||
|
Power = JSON.Value<string>("Power");
|
||||||
|
}
|
||||||
|
}
|
30
EDPlayerJournal/Entries/SupercruiseDestinationDropEntry.cs
Normal file
30
EDPlayerJournal/Entries/SupercruiseDestinationDropEntry.cs
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
namespace EDPlayerJournal.Entries;
|
||||||
|
|
||||||
|
public class SupercruiseDestinationDropEntry : Entry {
|
||||||
|
/// <summary>
|
||||||
|
/// Destination type, internal string.
|
||||||
|
/// </summary>
|
||||||
|
public string? Type { get; set; } = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Destination type, localised string.
|
||||||
|
/// </summary>
|
||||||
|
public string? TypeLocalised { get; set; } = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Threat of the destination, if known.
|
||||||
|
/// </summary>
|
||||||
|
public long? Threat { get; set; } = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Market ID if it has one.
|
||||||
|
/// </summary>
|
||||||
|
public ulong? MarketID { get; set; } = null;
|
||||||
|
|
||||||
|
protected override void Initialise() {
|
||||||
|
Type = JSON.Value<string>("Type");
|
||||||
|
TypeLocalised = JSON.Value<string>("Type_Localised");
|
||||||
|
Threat = JSON.Value<long?>("Threat");
|
||||||
|
MarketID = JSON.Value<ulong?>("MarketID");
|
||||||
|
}
|
||||||
|
}
|
30
EDPlayerJournal/Entries/SupercruiseEntry.cs
Normal file
30
EDPlayerJournal/Entries/SupercruiseEntry.cs
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
namespace EDPlayerJournal.Entries;
|
||||||
|
|
||||||
|
public class SupercruiseEntryEntry : Entry {
|
||||||
|
/// <summary>
|
||||||
|
/// Taxi?
|
||||||
|
/// </summary>
|
||||||
|
public bool Taxi { get; set; } = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Multicrew or not.
|
||||||
|
/// </summary>
|
||||||
|
public bool Multicrew { get; set; } = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Star system
|
||||||
|
/// </summary>
|
||||||
|
public string? StarSystem { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// System address
|
||||||
|
/// </summary>
|
||||||
|
public ulong? SystemAddress { get; set; }
|
||||||
|
|
||||||
|
protected override void Initialise() {
|
||||||
|
Taxi = JSON.Value<bool?>("Taxi") ?? false;
|
||||||
|
Multicrew = JSON.Value<bool?>("Multicrew") ?? false;
|
||||||
|
StarSystem = JSON.Value<string?>("StarSystem");
|
||||||
|
SystemAddress = JSON.Value<ulong?>("SystemAddress");
|
||||||
|
}
|
||||||
|
}
|
48
EDPlayerJournal/Entries/SupercruiseExitEntry.cs
Normal file
48
EDPlayerJournal/Entries/SupercruiseExitEntry.cs
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
namespace EDPlayerJournal.Entries;
|
||||||
|
|
||||||
|
public class SupercruiseExitEntry : Entry {
|
||||||
|
/// <summary>
|
||||||
|
/// Taxi?
|
||||||
|
/// </summary>
|
||||||
|
public bool Taxi { get; set; } = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Multicrew or not.
|
||||||
|
/// </summary>
|
||||||
|
public bool Multicrew { get; set; } = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Star system
|
||||||
|
/// </summary>
|
||||||
|
public string? StarSystem { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// System address
|
||||||
|
/// </summary>
|
||||||
|
public ulong? SystemAddress { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Body, name e.g. HIP 6182 B 2 a
|
||||||
|
/// </summary>
|
||||||
|
public string? Body { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Body ID
|
||||||
|
/// </summary>
|
||||||
|
public ulong? BodyID { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Body type (star, planet etc.)
|
||||||
|
/// </summary>
|
||||||
|
public string? BodyType { get; set; }
|
||||||
|
|
||||||
|
protected override void Initialise() {
|
||||||
|
Taxi = JSON.Value<bool?>("Taxi") ?? false;
|
||||||
|
Multicrew = JSON.Value<bool?>("Multicrew") ?? false;
|
||||||
|
StarSystem = JSON.Value<string?>("StarSystem");
|
||||||
|
SystemAddress = JSON.Value<ulong?>("SystemAddress");
|
||||||
|
Body = JSON.Value<string?>("Body");
|
||||||
|
BodyType = JSON.Value<string?>("BodyType");
|
||||||
|
BodyID = JSON.Value<ulong?>("BodyID");
|
||||||
|
}
|
||||||
|
}
|
7
EDPlayerJournal/Entries/UnderAttackEntry.cs
Normal file
7
EDPlayerJournal/Entries/UnderAttackEntry.cs
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
namespace EDPlayerJournal.Entries;
|
||||||
|
public class UnderAttackEntry : Entry {
|
||||||
|
public string? Target { get; set; }
|
||||||
|
protected override void Initialise() {
|
||||||
|
Target = JSON.Value<string>("Target");
|
||||||
|
}
|
||||||
|
}
|
185
EDPlayerJournal/Faction.cs
Normal file
185
EDPlayerJournal/Faction.cs
Normal file
@ -0,0 +1,185 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
|
||||||
|
namespace EDPlayerJournal;
|
||||||
|
|
||||||
|
public class FactionState {
|
||||||
|
public string? State { get; set; }
|
||||||
|
public long? Trend { get; set; }
|
||||||
|
|
||||||
|
public static FactionState? FromJSON(JObject j) {
|
||||||
|
if (j == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
FactionState s = new FactionState() {
|
||||||
|
State = j.Value<string>("State"),
|
||||||
|
Trend = j.Value<long?>("Trend"),
|
||||||
|
};
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(s.State)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Factions {
|
||||||
|
/// <summary>
|
||||||
|
/// Internal name for the Pilots Federation faction
|
||||||
|
/// </summary>
|
||||||
|
public static string PilotsFederationInternal = "$faction_PilotsFederation;";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Name used for Pilots Federation in vouchers
|
||||||
|
/// </summary>
|
||||||
|
public static string PilotsFederationVouchers = "PilotsFederation";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Friendly name of the Pilots Federation
|
||||||
|
/// </summary>
|
||||||
|
public static string PilotsFederation = "Pilots' Federation";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Internal name for the Thargoid faction
|
||||||
|
/// </summary>
|
||||||
|
public static string ThargoidInternal = "$faction_Thargoid;";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Localised name of the Thargoids
|
||||||
|
/// </summary>
|
||||||
|
public static string Thargoid = "Thargoids";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The faction the fleet carriers use.
|
||||||
|
/// </summary>
|
||||||
|
public static string FleetCarrier = "FleetCarrier";
|
||||||
|
|
||||||
|
public static bool IsPilotsFederation(string? name) {
|
||||||
|
if (name == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.Compare(name, PilotsFederationInternal) == 0 ||
|
||||||
|
string.Compare(name, PilotsFederationVouchers) == 0 ||
|
||||||
|
string.Compare(name, PilotsFederation) == 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool IsThargoid(string? name) {
|
||||||
|
if (name == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.Compare(name, ThargoidInternal) == 0 ||
|
||||||
|
string.Compare(name, Thargoid) == 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Compares two factions names and sees if they are the same faction. Since
|
||||||
|
/// factions can have an internal name, and a public name, this function takes
|
||||||
|
/// these into account.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="a"></param>
|
||||||
|
/// <param name="b"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static int CompareFactions(string? a, string? b) {
|
||||||
|
if (a == null || b == null) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IsPilotsFederation(a) && IsPilotsFederation(b)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IsThargoid(a) && IsThargoid(b)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return string.Compare(a, b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Faction {
|
||||||
|
public string? Name { get; set; }
|
||||||
|
public string? FactionState { get; set; }
|
||||||
|
public string? Government { get; set; }
|
||||||
|
public double Influence { get; set; }
|
||||||
|
public string? Allegiance { get; set; }
|
||||||
|
public string? Happiness { get; set; }
|
||||||
|
public string? HappinessLocalised { get; set; }
|
||||||
|
public double MyReputation { get; set; }
|
||||||
|
public bool SquadronFaction { get; set; } = false;
|
||||||
|
public bool HomeSystem { get; set; } = false;
|
||||||
|
|
||||||
|
public List<FactionState> RecoveringStates { get; set; } = new List<FactionState>();
|
||||||
|
public List<FactionState> ActiveStates { get; set; } = new List<FactionState>();
|
||||||
|
public List<FactionState> PendingStates { get; set; } = new List<FactionState>();
|
||||||
|
|
||||||
|
public static Faction? FromJSON(JObject j) {
|
||||||
|
if (j == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Faction f = new Faction() {
|
||||||
|
Name = j.Value<string>("Name") ?? "",
|
||||||
|
FactionState = j.Value<string>("FactionState") ?? "",
|
||||||
|
Government = j.Value<string>("Government") ?? "",
|
||||||
|
Influence = j.Value<double?>("Influence") ?? 1.0,
|
||||||
|
Allegiance = j.Value<string>("Allegiance") ?? "",
|
||||||
|
Happiness = j.Value<string>("Happiness") ?? "",
|
||||||
|
HappinessLocalised = j.Value<string>("Happiness_Localised") ?? "",
|
||||||
|
MyReputation = j.Value<double?>("MyReputation") ?? 1.0,
|
||||||
|
SquadronFaction = (j.Value<bool?>("SquadronFaction") ?? false),
|
||||||
|
HomeSystem = (j.Value<bool?>("HomeSystem") ?? false),
|
||||||
|
};
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(f.Name)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
JArray? recovering_states = j.Value<JArray>("RecoveringStates");
|
||||||
|
if (recovering_states != null) {
|
||||||
|
foreach (JObject s in recovering_states) {
|
||||||
|
FactionState? state = EDPlayerJournal.FactionState.FromJSON(s);
|
||||||
|
if (state != null) {
|
||||||
|
f.RecoveringStates.Add(state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
JArray? active_states = j.Value<JArray>("ActiveStates");
|
||||||
|
if (active_states != null) {
|
||||||
|
foreach (JObject s in active_states) {
|
||||||
|
FactionState? state = EDPlayerJournal.FactionState.FromJSON(s);
|
||||||
|
if (state != null) {
|
||||||
|
f.ActiveStates.Add(state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
JArray? pending_states = j.Value<JArray>("PendingStates");
|
||||||
|
if (pending_states != null) {
|
||||||
|
foreach (JObject s in pending_states) {
|
||||||
|
FactionState? state = EDPlayerJournal.FactionState.FromJSON(s);
|
||||||
|
if (state != null) {
|
||||||
|
f.PendingStates.Add(state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return f;
|
||||||
|
}
|
||||||
|
}
|
87
EDPlayerJournal/Instances.cs
Normal file
87
EDPlayerJournal/Instances.cs
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
namespace EDPlayerJournal;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Contains information regarding instances you can supercruise into,
|
||||||
|
/// such as combat zones, installations and megaship scenarios.
|
||||||
|
/// </summary>
|
||||||
|
public class Instances {
|
||||||
|
/// <summary>
|
||||||
|
/// Low ship combat zone
|
||||||
|
/// </summary>
|
||||||
|
public static readonly string WarzoneLow = "$Warzone_PointRace_Low";
|
||||||
|
/// <summary>
|
||||||
|
/// Medium ship combat zone
|
||||||
|
/// </summary>
|
||||||
|
public static readonly string WarzoneMedium = "$Warzone_PointRace_Med";
|
||||||
|
/// <summary>
|
||||||
|
/// High ship combat zone.
|
||||||
|
/// </summary>
|
||||||
|
public static readonly string WarzoneHigh = "$Warzone_PointRace_High";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Medium power play conflict zone, new in PP 2.0 Ascendancy update
|
||||||
|
/// </summary>
|
||||||
|
public static readonly string PowerWarzoneMedium = "$Warzone_Powerplay_Med";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Low Thargoid combat zone
|
||||||
|
/// </summary>
|
||||||
|
public static readonly string WarzoneThargoidLow = "$Warzone_TG_Low";
|
||||||
|
/// <summary>
|
||||||
|
/// Medium Thargoid combat zone
|
||||||
|
/// </summary>
|
||||||
|
public static readonly string WarzoneThargoidMedium = "$Warzone_TG_Med";
|
||||||
|
/// <summary>
|
||||||
|
/// High Thargoid combat zone
|
||||||
|
/// </summary>
|
||||||
|
public static readonly string WarzoneThargoidHigh = "$Warzone_TG_High";
|
||||||
|
/// <summary>
|
||||||
|
/// Very High Thargoid combat zone
|
||||||
|
/// </summary>
|
||||||
|
public static readonly string WarzoneThargoidVeryHigh = "$Warzone_TG_VeryHigh";
|
||||||
|
|
||||||
|
public static bool IsThargoidWarzone(string type) {
|
||||||
|
return
|
||||||
|
IsInstance(type, WarzoneThargoidLow) ||
|
||||||
|
IsInstance(type, WarzoneThargoidMedium) ||
|
||||||
|
IsInstance(type, WarzoneThargoidHigh) ||
|
||||||
|
IsInstance(type, WarzoneThargoidVeryHigh)
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool IsHumanWarzone(string type) {
|
||||||
|
return
|
||||||
|
IsInstance(type, WarzoneLow) ||
|
||||||
|
IsInstance(type, WarzoneMedium) ||
|
||||||
|
IsInstance(type, WarzoneHigh)
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool IsPowerWarzone(string type) {
|
||||||
|
return
|
||||||
|
IsInstance(type, PowerWarzoneMedium)
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool IsWarzone(string type) {
|
||||||
|
return IsHumanWarzone(type) ||
|
||||||
|
IsThargoidWarzone(type) ||
|
||||||
|
IsPowerWarzone(type)
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool IsInstance(string type, string instance) {
|
||||||
|
if (string.IsNullOrEmpty(type) || string.IsNullOrEmpty(instance)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Instance names are split by a semi colon, with the remainder being
|
||||||
|
// additional info to such as index.
|
||||||
|
string[] parts = type.Split(":");
|
||||||
|
if (!parts[0].StartsWith("$")) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return string.Compare(parts[0], instance, true) == 0;
|
||||||
|
}
|
||||||
|
}
|
17
EDPlayerJournal/JournalException.cs
Normal file
17
EDPlayerJournal/JournalException.cs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
namespace EDPlayerJournal;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Thrown when the parser encounters an invalid journal entry
|
||||||
|
/// </summary>
|
||||||
|
public class InvalidJournalEntryException : Exception {
|
||||||
|
public InvalidJournalEntryException() { }
|
||||||
|
public InvalidJournalEntryException(string message) : base(message) { }
|
||||||
|
public InvalidJournalEntryException(string message, Exception inner) : base(message, inner) { }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Thrown when the parser finds an invalid journal file
|
||||||
|
/// </summary>
|
||||||
|
public class JournalException : Exception {
|
||||||
|
public JournalException(string message) : base(message) {}
|
||||||
|
}
|
149
EDPlayerJournal/JournalFile.cs
Normal file
149
EDPlayerJournal/JournalFile.cs
Normal file
@ -0,0 +1,149 @@
|
|||||||
|
using System.Text;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using System.Globalization;
|
||||||
|
using EDPlayerJournal.Entries;
|
||||||
|
|
||||||
|
namespace EDPlayerJournal;
|
||||||
|
public class JournalFile : IComparable<JournalFile>
|
||||||
|
{
|
||||||
|
public string FullPath { get; set; }
|
||||||
|
public int Part { get; set; }
|
||||||
|
public DateTime? DateTime { get; set; }
|
||||||
|
public DateTime? NormalisedDateTime { get; set; }
|
||||||
|
|
||||||
|
public List<Entry> entries = new List<Entry>();
|
||||||
|
|
||||||
|
private static Regex fileregex = new Regex("Journal\\.(\\d+)\\.(\\d+)\\.log");
|
||||||
|
private static Regex update11regex = new Regex("Journal\\.([^\\.]+)\\.(\\d+).log");
|
||||||
|
private static string iso8601 = "yyyyMMddTHHmmss";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A public list of errors encountered while parsing the journal files
|
||||||
|
/// </summary>
|
||||||
|
public List<Exception> Errors { get; private set; } = new List<Exception>();
|
||||||
|
|
||||||
|
public static bool VerifyFile(string path) {
|
||||||
|
string filename = Path.GetFileName(path);
|
||||||
|
|
||||||
|
var matches = fileregex.Matches(filename);
|
||||||
|
if (matches.Count != 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
matches = update11regex.Matches(filename);
|
||||||
|
if (matches.Count != 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetFilename(string path) {
|
||||||
|
string filename = Path.GetFileName(path);
|
||||||
|
if (!File.Exists(path) || filename == null) {
|
||||||
|
throw new JournalException(string.Format("Invalid journal file: {0}", filename));
|
||||||
|
}
|
||||||
|
|
||||||
|
var matches = fileregex.Matches(filename);
|
||||||
|
if (matches.Count == 0) {
|
||||||
|
matches = update11regex.Matches(filename);
|
||||||
|
if (matches.Count == 0) {
|
||||||
|
throw new JournalException(string.Format("invalid file format: {0}", filename));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FullPath = path;
|
||||||
|
var groups = matches[0].Groups;
|
||||||
|
string part = groups[2].ToString();
|
||||||
|
string timestamp = groups[1].ToString();
|
||||||
|
|
||||||
|
if (!timestamp.Contains("T")) {
|
||||||
|
/* pre update 11 file
|
||||||
|
*/
|
||||||
|
|
||||||
|
// The ISO is not quite correct on journal filenames, so build
|
||||||
|
// a proper ISO 8601 date time stamp out of it.
|
||||||
|
var date = new StringBuilder();
|
||||||
|
date.Append("20"); // Add the missing century in front.
|
||||||
|
date.Append(timestamp);
|
||||||
|
date.Insert(8, "T"); // Add the "T" separating date and time
|
||||||
|
|
||||||
|
timestamp = date.ToString();
|
||||||
|
} else {
|
||||||
|
/* post update 11 file, remove dashes
|
||||||
|
*/
|
||||||
|
timestamp = timestamp.Replace("-", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
this.DateTime = System.DateTime.ParseExact(timestamp, iso8601, CultureInfo.InvariantCulture);
|
||||||
|
this.Part = int.Parse(part);
|
||||||
|
this.NormalisedDateTime = System.DateTime.Parse(DateTime.Value.ToShortDateString());
|
||||||
|
}
|
||||||
|
|
||||||
|
public int CompareTo(JournalFile? other) {
|
||||||
|
if (other == null || DateTime == null || other.DateTime == null) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
var comp = System.DateTime.Compare(DateTime.Value, other.DateTime.Value);
|
||||||
|
if (comp == 0) {
|
||||||
|
/* If we have the exact same datetime we compare by parts.
|
||||||
|
*/
|
||||||
|
return Part - other.Part;
|
||||||
|
} else {
|
||||||
|
return comp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public JournalFile(string path) {
|
||||||
|
FullPath = "";
|
||||||
|
SetFilename(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Entry> Entries {
|
||||||
|
get {
|
||||||
|
if (entries == null || entries.Count == 0) {
|
||||||
|
try {
|
||||||
|
LoadEntries();
|
||||||
|
} catch (IOException) {
|
||||||
|
}
|
||||||
|
if (entries == null) {
|
||||||
|
entries = new List<Entry>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return entries;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void LoadEntries() {
|
||||||
|
List<string> lines = new List<string>();
|
||||||
|
|
||||||
|
/* This needs to be done this way, otherwise, if the game is still running the journal files cannot
|
||||||
|
* be accessed. And it is very much convenient to generate logs while the game is still running.
|
||||||
|
*/
|
||||||
|
using (var fs = new FileStream(FullPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) {
|
||||||
|
using (var sr = new StreamReader(fs, Encoding.UTF8)) {
|
||||||
|
string? line;
|
||||||
|
while ((line = sr.ReadLine()) != null) {
|
||||||
|
lines.Add(line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
entries.Clear();
|
||||||
|
Errors.Clear();
|
||||||
|
foreach (var line in lines) {
|
||||||
|
// Skip empty lines
|
||||||
|
if (line.Trim().Length == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
Entry? entry = Entry.Parse(line);
|
||||||
|
if (entry != null) {
|
||||||
|
entries.Add(entry);
|
||||||
|
}
|
||||||
|
} catch (Exception ex) {
|
||||||
|
Errors.Add(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
94
EDPlayerJournal/JournalStream.cs
Normal file
94
EDPlayerJournal/JournalStream.cs
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
using EDPlayerJournal.Entries;
|
||||||
|
|
||||||
|
namespace EDPlayerJournal;
|
||||||
|
public class JournalStream {
|
||||||
|
private FileSystemWatcher? watcher = null;
|
||||||
|
|
||||||
|
private Dictionary<string, StreamReader> streams = new Dictionary<string, StreamReader>();
|
||||||
|
|
||||||
|
public delegate void NewJournalEntryDelegate(Entry entry);
|
||||||
|
|
||||||
|
public event NewJournalEntryDelegate? NewJournalEntry;
|
||||||
|
|
||||||
|
public PlayerJournal? Journal;
|
||||||
|
|
||||||
|
public JournalStream() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public JournalStream(PlayerJournal journal) {
|
||||||
|
Journal = journal;
|
||||||
|
Open();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AddFileToStreams(string path, bool seekend = false) {
|
||||||
|
if (!streams.ContainsKey(path) && JournalFile.VerifyFile(path)) {
|
||||||
|
var filestream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
||||||
|
streams[path] = new StreamReader(filestream);
|
||||||
|
|
||||||
|
if (seekend) {
|
||||||
|
streams[path].BaseStream.Seek(0, SeekOrigin.End);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Open() {
|
||||||
|
if (watcher != null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Journal == null || Journal.Location == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Journal.Files.Count > 0) {
|
||||||
|
JournalFile lastfile = Journal.GetLastFile();
|
||||||
|
/* add last file to stream */
|
||||||
|
AddFileToStreams(lastfile.FullPath, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
watcher = new FileSystemWatcher(Journal.Location);
|
||||||
|
|
||||||
|
watcher.NotifyFilter = NotifyFilters.FileName |
|
||||||
|
NotifyFilters.LastWrite |
|
||||||
|
NotifyFilters.Size;
|
||||||
|
|
||||||
|
watcher.Changed += Watcher_Changed;
|
||||||
|
watcher.Created += Watcher_Created;
|
||||||
|
|
||||||
|
watcher.Filter = "*.log";
|
||||||
|
watcher.EnableRaisingEvents = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Close() {
|
||||||
|
if (watcher != null) {
|
||||||
|
watcher.EnableRaisingEvents = false;
|
||||||
|
}
|
||||||
|
watcher = null;
|
||||||
|
streams.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Watcher_Created(object sender, FileSystemEventArgs e) {
|
||||||
|
AddFileToStreams(e.FullPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Watcher_Changed(object sender, FileSystemEventArgs e) {
|
||||||
|
AddFileToStreams(e.FullPath);
|
||||||
|
|
||||||
|
var stream = streams[e.FullPath];
|
||||||
|
if (stream == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
string? line;
|
||||||
|
|
||||||
|
while ((line = stream.ReadLine()) != null) {
|
||||||
|
try {
|
||||||
|
Entry? entry = Entry.Parse(line);
|
||||||
|
if (entry != null) {
|
||||||
|
NewJournalEntry?.Invoke(entry);
|
||||||
|
}
|
||||||
|
} catch (Exception) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
674
EDPlayerJournal/LICENCE.txt
Normal file
674
EDPlayerJournal/LICENCE.txt
Normal file
@ -0,0 +1,674 @@
|
|||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
Version 3, 29 June 2007
|
||||||
|
|
||||||
|
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The GNU General Public License is a free, copyleft license for
|
||||||
|
software and other kinds of works.
|
||||||
|
|
||||||
|
The licenses for most software and other practical works are designed
|
||||||
|
to take away your freedom to share and change the works. By contrast,
|
||||||
|
the GNU General Public License is intended to guarantee your freedom to
|
||||||
|
share and change all versions of a program--to make sure it remains free
|
||||||
|
software for all its users. We, the Free Software Foundation, use the
|
||||||
|
GNU General Public License for most of our software; it applies also to
|
||||||
|
any other work released this way by its authors. You can apply it to
|
||||||
|
your programs, too.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
|
them if you wish), that you receive source code or can get it if you
|
||||||
|
want it, that you can change the software or use pieces of it in new
|
||||||
|
free programs, and that you know you can do these things.
|
||||||
|
|
||||||
|
To protect your rights, we need to prevent others from denying you
|
||||||
|
these rights or asking you to surrender the rights. Therefore, you have
|
||||||
|
certain responsibilities if you distribute copies of the software, or if
|
||||||
|
you modify it: responsibilities to respect the freedom of others.
|
||||||
|
|
||||||
|
For example, if you distribute copies of such a program, whether
|
||||||
|
gratis or for a fee, you must pass on to the recipients the same
|
||||||
|
freedoms that you received. You must make sure that they, too, receive
|
||||||
|
or can get the source code. And you must show them these terms so they
|
||||||
|
know their rights.
|
||||||
|
|
||||||
|
Developers that use the GNU GPL protect your rights with two steps:
|
||||||
|
(1) assert copyright on the software, and (2) offer you this License
|
||||||
|
giving you legal permission to copy, distribute and/or modify it.
|
||||||
|
|
||||||
|
For the developers' and authors' protection, the GPL clearly explains
|
||||||
|
that there is no warranty for this free software. For both users' and
|
||||||
|
authors' sake, the GPL requires that modified versions be marked as
|
||||||
|
changed, so that their problems will not be attributed erroneously to
|
||||||
|
authors of previous versions.
|
||||||
|
|
||||||
|
Some devices are designed to deny users access to install or run
|
||||||
|
modified versions of the software inside them, although the manufacturer
|
||||||
|
can do so. This is fundamentally incompatible with the aim of
|
||||||
|
protecting users' freedom to change the software. The systematic
|
||||||
|
pattern of such abuse occurs in the area of products for individuals to
|
||||||
|
use, which is precisely where it is most unacceptable. Therefore, we
|
||||||
|
have designed this version of the GPL to prohibit the practice for those
|
||||||
|
products. If such problems arise substantially in other domains, we
|
||||||
|
stand ready to extend this provision to those domains in future versions
|
||||||
|
of the GPL, as needed to protect the freedom of users.
|
||||||
|
|
||||||
|
Finally, every program is threatened constantly by software patents.
|
||||||
|
States should not allow patents to restrict development and use of
|
||||||
|
software on general-purpose computers, but in those that do, we wish to
|
||||||
|
avoid the special danger that patents applied to a free program could
|
||||||
|
make it effectively proprietary. To prevent this, the GPL assures that
|
||||||
|
patents cannot be used to render the program non-free.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
0. Definitions.
|
||||||
|
|
||||||
|
"This License" refers to version 3 of the GNU General Public License.
|
||||||
|
|
||||||
|
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||||
|
works, such as semiconductor masks.
|
||||||
|
|
||||||
|
"The Program" refers to any copyrightable work licensed under this
|
||||||
|
License. Each licensee is addressed as "you". "Licensees" and
|
||||||
|
"recipients" may be individuals or organizations.
|
||||||
|
|
||||||
|
To "modify" a work means to copy from or adapt all or part of the work
|
||||||
|
in a fashion requiring copyright permission, other than the making of an
|
||||||
|
exact copy. The resulting work is called a "modified version" of the
|
||||||
|
earlier work or a work "based on" the earlier work.
|
||||||
|
|
||||||
|
A "covered work" means either the unmodified Program or a work based
|
||||||
|
on the Program.
|
||||||
|
|
||||||
|
To "propagate" a work means to do anything with it that, without
|
||||||
|
permission, would make you directly or secondarily liable for
|
||||||
|
infringement under applicable copyright law, except executing it on a
|
||||||
|
computer or modifying a private copy. Propagation includes copying,
|
||||||
|
distribution (with or without modification), making available to the
|
||||||
|
public, and in some countries other activities as well.
|
||||||
|
|
||||||
|
To "convey" a work means any kind of propagation that enables other
|
||||||
|
parties to make or receive copies. Mere interaction with a user through
|
||||||
|
a computer network, with no transfer of a copy, is not conveying.
|
||||||
|
|
||||||
|
An interactive user interface displays "Appropriate Legal Notices"
|
||||||
|
to the extent that it includes a convenient and prominently visible
|
||||||
|
feature that (1) displays an appropriate copyright notice, and (2)
|
||||||
|
tells the user that there is no warranty for the work (except to the
|
||||||
|
extent that warranties are provided), that licensees may convey the
|
||||||
|
work under this License, and how to view a copy of this License. If
|
||||||
|
the interface presents a list of user commands or options, such as a
|
||||||
|
menu, a prominent item in the list meets this criterion.
|
||||||
|
|
||||||
|
1. Source Code.
|
||||||
|
|
||||||
|
The "source code" for a work means the preferred form of the work
|
||||||
|
for making modifications to it. "Object code" means any non-source
|
||||||
|
form of a work.
|
||||||
|
|
||||||
|
A "Standard Interface" means an interface that either is an official
|
||||||
|
standard defined by a recognized standards body, or, in the case of
|
||||||
|
interfaces specified for a particular programming language, one that
|
||||||
|
is widely used among developers working in that language.
|
||||||
|
|
||||||
|
The "System Libraries" of an executable work include anything, other
|
||||||
|
than the work as a whole, that (a) is included in the normal form of
|
||||||
|
packaging a Major Component, but which is not part of that Major
|
||||||
|
Component, and (b) serves only to enable use of the work with that
|
||||||
|
Major Component, or to implement a Standard Interface for which an
|
||||||
|
implementation is available to the public in source code form. A
|
||||||
|
"Major Component", in this context, means a major essential component
|
||||||
|
(kernel, window system, and so on) of the specific operating system
|
||||||
|
(if any) on which the executable work runs, or a compiler used to
|
||||||
|
produce the work, or an object code interpreter used to run it.
|
||||||
|
|
||||||
|
The "Corresponding Source" for a work in object code form means all
|
||||||
|
the source code needed to generate, install, and (for an executable
|
||||||
|
work) run the object code and to modify the work, including scripts to
|
||||||
|
control those activities. However, it does not include the work's
|
||||||
|
System Libraries, or general-purpose tools or generally available free
|
||||||
|
programs which are used unmodified in performing those activities but
|
||||||
|
which are not part of the work. For example, Corresponding Source
|
||||||
|
includes interface definition files associated with source files for
|
||||||
|
the work, and the source code for shared libraries and dynamically
|
||||||
|
linked subprograms that the work is specifically designed to require,
|
||||||
|
such as by intimate data communication or control flow between those
|
||||||
|
subprograms and other parts of the work.
|
||||||
|
|
||||||
|
The Corresponding Source need not include anything that users
|
||||||
|
can regenerate automatically from other parts of the Corresponding
|
||||||
|
Source.
|
||||||
|
|
||||||
|
The Corresponding Source for a work in source code form is that
|
||||||
|
same work.
|
||||||
|
|
||||||
|
2. Basic Permissions.
|
||||||
|
|
||||||
|
All rights granted under this License are granted for the term of
|
||||||
|
copyright on the Program, and are irrevocable provided the stated
|
||||||
|
conditions are met. This License explicitly affirms your unlimited
|
||||||
|
permission to run the unmodified Program. The output from running a
|
||||||
|
covered work is covered by this License only if the output, given its
|
||||||
|
content, constitutes a covered work. This License acknowledges your
|
||||||
|
rights of fair use or other equivalent, as provided by copyright law.
|
||||||
|
|
||||||
|
You may make, run and propagate covered works that you do not
|
||||||
|
convey, without conditions so long as your license otherwise remains
|
||||||
|
in force. You may convey covered works to others for the sole purpose
|
||||||
|
of having them make modifications exclusively for you, or provide you
|
||||||
|
with facilities for running those works, provided that you comply with
|
||||||
|
the terms of this License in conveying all material for which you do
|
||||||
|
not control copyright. Those thus making or running the covered works
|
||||||
|
for you must do so exclusively on your behalf, under your direction
|
||||||
|
and control, on terms that prohibit them from making any copies of
|
||||||
|
your copyrighted material outside their relationship with you.
|
||||||
|
|
||||||
|
Conveying under any other circumstances is permitted solely under
|
||||||
|
the conditions stated below. Sublicensing is not allowed; section 10
|
||||||
|
makes it unnecessary.
|
||||||
|
|
||||||
|
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||||
|
|
||||||
|
No covered work shall be deemed part of an effective technological
|
||||||
|
measure under any applicable law fulfilling obligations under article
|
||||||
|
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||||
|
similar laws prohibiting or restricting circumvention of such
|
||||||
|
measures.
|
||||||
|
|
||||||
|
When you convey a covered work, you waive any legal power to forbid
|
||||||
|
circumvention of technological measures to the extent such circumvention
|
||||||
|
is effected by exercising rights under this License with respect to
|
||||||
|
the covered work, and you disclaim any intention to limit operation or
|
||||||
|
modification of the work as a means of enforcing, against the work's
|
||||||
|
users, your or third parties' legal rights to forbid circumvention of
|
||||||
|
technological measures.
|
||||||
|
|
||||||
|
4. Conveying Verbatim Copies.
|
||||||
|
|
||||||
|
You may convey verbatim copies of the Program's source code as you
|
||||||
|
receive it, in any medium, provided that you conspicuously and
|
||||||
|
appropriately publish on each copy an appropriate copyright notice;
|
||||||
|
keep intact all notices stating that this License and any
|
||||||
|
non-permissive terms added in accord with section 7 apply to the code;
|
||||||
|
keep intact all notices of the absence of any warranty; and give all
|
||||||
|
recipients a copy of this License along with the Program.
|
||||||
|
|
||||||
|
You may charge any price or no price for each copy that you convey,
|
||||||
|
and you may offer support or warranty protection for a fee.
|
||||||
|
|
||||||
|
5. Conveying Modified Source Versions.
|
||||||
|
|
||||||
|
You may convey a work based on the Program, or the modifications to
|
||||||
|
produce it from the Program, in the form of source code under the
|
||||||
|
terms of section 4, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) The work must carry prominent notices stating that you modified
|
||||||
|
it, and giving a relevant date.
|
||||||
|
|
||||||
|
b) The work must carry prominent notices stating that it is
|
||||||
|
released under this License and any conditions added under section
|
||||||
|
7. This requirement modifies the requirement in section 4 to
|
||||||
|
"keep intact all notices".
|
||||||
|
|
||||||
|
c) You must license the entire work, as a whole, under this
|
||||||
|
License to anyone who comes into possession of a copy. This
|
||||||
|
License will therefore apply, along with any applicable section 7
|
||||||
|
additional terms, to the whole of the work, and all its parts,
|
||||||
|
regardless of how they are packaged. This License gives no
|
||||||
|
permission to license the work in any other way, but it does not
|
||||||
|
invalidate such permission if you have separately received it.
|
||||||
|
|
||||||
|
d) If the work has interactive user interfaces, each must display
|
||||||
|
Appropriate Legal Notices; however, if the Program has interactive
|
||||||
|
interfaces that do not display Appropriate Legal Notices, your
|
||||||
|
work need not make them do so.
|
||||||
|
|
||||||
|
A compilation of a covered work with other separate and independent
|
||||||
|
works, which are not by their nature extensions of the covered work,
|
||||||
|
and which are not combined with it such as to form a larger program,
|
||||||
|
in or on a volume of a storage or distribution medium, is called an
|
||||||
|
"aggregate" if the compilation and its resulting copyright are not
|
||||||
|
used to limit the access or legal rights of the compilation's users
|
||||||
|
beyond what the individual works permit. Inclusion of a covered work
|
||||||
|
in an aggregate does not cause this License to apply to the other
|
||||||
|
parts of the aggregate.
|
||||||
|
|
||||||
|
6. Conveying Non-Source Forms.
|
||||||
|
|
||||||
|
You may convey a covered work in object code form under the terms
|
||||||
|
of sections 4 and 5, provided that you also convey the
|
||||||
|
machine-readable Corresponding Source under the terms of this License,
|
||||||
|
in one of these ways:
|
||||||
|
|
||||||
|
a) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by the
|
||||||
|
Corresponding Source fixed on a durable physical medium
|
||||||
|
customarily used for software interchange.
|
||||||
|
|
||||||
|
b) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by a
|
||||||
|
written offer, valid for at least three years and valid for as
|
||||||
|
long as you offer spare parts or customer support for that product
|
||||||
|
model, to give anyone who possesses the object code either (1) a
|
||||||
|
copy of the Corresponding Source for all the software in the
|
||||||
|
product that is covered by this License, on a durable physical
|
||||||
|
medium customarily used for software interchange, for a price no
|
||||||
|
more than your reasonable cost of physically performing this
|
||||||
|
conveying of source, or (2) access to copy the
|
||||||
|
Corresponding Source from a network server at no charge.
|
||||||
|
|
||||||
|
c) Convey individual copies of the object code with a copy of the
|
||||||
|
written offer to provide the Corresponding Source. This
|
||||||
|
alternative is allowed only occasionally and noncommercially, and
|
||||||
|
only if you received the object code with such an offer, in accord
|
||||||
|
with subsection 6b.
|
||||||
|
|
||||||
|
d) Convey the object code by offering access from a designated
|
||||||
|
place (gratis or for a charge), and offer equivalent access to the
|
||||||
|
Corresponding Source in the same way through the same place at no
|
||||||
|
further charge. You need not require recipients to copy the
|
||||||
|
Corresponding Source along with the object code. If the place to
|
||||||
|
copy the object code is a network server, the Corresponding Source
|
||||||
|
may be on a different server (operated by you or a third party)
|
||||||
|
that supports equivalent copying facilities, provided you maintain
|
||||||
|
clear directions next to the object code saying where to find the
|
||||||
|
Corresponding Source. Regardless of what server hosts the
|
||||||
|
Corresponding Source, you remain obligated to ensure that it is
|
||||||
|
available for as long as needed to satisfy these requirements.
|
||||||
|
|
||||||
|
e) Convey the object code using peer-to-peer transmission, provided
|
||||||
|
you inform other peers where the object code and Corresponding
|
||||||
|
Source of the work are being offered to the general public at no
|
||||||
|
charge under subsection 6d.
|
||||||
|
|
||||||
|
A separable portion of the object code, whose source code is excluded
|
||||||
|
from the Corresponding Source as a System Library, need not be
|
||||||
|
included in conveying the object code work.
|
||||||
|
|
||||||
|
A "User Product" is either (1) a "consumer product", which means any
|
||||||
|
tangible personal property which is normally used for personal, family,
|
||||||
|
or household purposes, or (2) anything designed or sold for incorporation
|
||||||
|
into a dwelling. In determining whether a product is a consumer product,
|
||||||
|
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||||
|
product received by a particular user, "normally used" refers to a
|
||||||
|
typical or common use of that class of product, regardless of the status
|
||||||
|
of the particular user or of the way in which the particular user
|
||||||
|
actually uses, or expects or is expected to use, the product. A product
|
||||||
|
is a consumer product regardless of whether the product has substantial
|
||||||
|
commercial, industrial or non-consumer uses, unless such uses represent
|
||||||
|
the only significant mode of use of the product.
|
||||||
|
|
||||||
|
"Installation Information" for a User Product means any methods,
|
||||||
|
procedures, authorization keys, or other information required to install
|
||||||
|
and execute modified versions of a covered work in that User Product from
|
||||||
|
a modified version of its Corresponding Source. The information must
|
||||||
|
suffice to ensure that the continued functioning of the modified object
|
||||||
|
code is in no case prevented or interfered with solely because
|
||||||
|
modification has been made.
|
||||||
|
|
||||||
|
If you convey an object code work under this section in, or with, or
|
||||||
|
specifically for use in, a User Product, and the conveying occurs as
|
||||||
|
part of a transaction in which the right of possession and use of the
|
||||||
|
User Product is transferred to the recipient in perpetuity or for a
|
||||||
|
fixed term (regardless of how the transaction is characterized), the
|
||||||
|
Corresponding Source conveyed under this section must be accompanied
|
||||||
|
by the Installation Information. But this requirement does not apply
|
||||||
|
if neither you nor any third party retains the ability to install
|
||||||
|
modified object code on the User Product (for example, the work has
|
||||||
|
been installed in ROM).
|
||||||
|
|
||||||
|
The requirement to provide Installation Information does not include a
|
||||||
|
requirement to continue to provide support service, warranty, or updates
|
||||||
|
for a work that has been modified or installed by the recipient, or for
|
||||||
|
the User Product in which it has been modified or installed. Access to a
|
||||||
|
network may be denied when the modification itself materially and
|
||||||
|
adversely affects the operation of the network or violates the rules and
|
||||||
|
protocols for communication across the network.
|
||||||
|
|
||||||
|
Corresponding Source conveyed, and Installation Information provided,
|
||||||
|
in accord with this section must be in a format that is publicly
|
||||||
|
documented (and with an implementation available to the public in
|
||||||
|
source code form), and must require no special password or key for
|
||||||
|
unpacking, reading or copying.
|
||||||
|
|
||||||
|
7. Additional Terms.
|
||||||
|
|
||||||
|
"Additional permissions" are terms that supplement the terms of this
|
||||||
|
License by making exceptions from one or more of its conditions.
|
||||||
|
Additional permissions that are applicable to the entire Program shall
|
||||||
|
be treated as though they were included in this License, to the extent
|
||||||
|
that they are valid under applicable law. If additional permissions
|
||||||
|
apply only to part of the Program, that part may be used separately
|
||||||
|
under those permissions, but the entire Program remains governed by
|
||||||
|
this License without regard to the additional permissions.
|
||||||
|
|
||||||
|
When you convey a copy of a covered work, you may at your option
|
||||||
|
remove any additional permissions from that copy, or from any part of
|
||||||
|
it. (Additional permissions may be written to require their own
|
||||||
|
removal in certain cases when you modify the work.) You may place
|
||||||
|
additional permissions on material, added by you to a covered work,
|
||||||
|
for which you have or can give appropriate copyright permission.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, for material you
|
||||||
|
add to a covered work, you may (if authorized by the copyright holders of
|
||||||
|
that material) supplement the terms of this License with terms:
|
||||||
|
|
||||||
|
a) Disclaiming warranty or limiting liability differently from the
|
||||||
|
terms of sections 15 and 16 of this License; or
|
||||||
|
|
||||||
|
b) Requiring preservation of specified reasonable legal notices or
|
||||||
|
author attributions in that material or in the Appropriate Legal
|
||||||
|
Notices displayed by works containing it; or
|
||||||
|
|
||||||
|
c) Prohibiting misrepresentation of the origin of that material, or
|
||||||
|
requiring that modified versions of such material be marked in
|
||||||
|
reasonable ways as different from the original version; or
|
||||||
|
|
||||||
|
d) Limiting the use for publicity purposes of names of licensors or
|
||||||
|
authors of the material; or
|
||||||
|
|
||||||
|
e) Declining to grant rights under trademark law for use of some
|
||||||
|
trade names, trademarks, or service marks; or
|
||||||
|
|
||||||
|
f) Requiring indemnification of licensors and authors of that
|
||||||
|
material by anyone who conveys the material (or modified versions of
|
||||||
|
it) with contractual assumptions of liability to the recipient, for
|
||||||
|
any liability that these contractual assumptions directly impose on
|
||||||
|
those licensors and authors.
|
||||||
|
|
||||||
|
All other non-permissive additional terms are considered "further
|
||||||
|
restrictions" within the meaning of section 10. If the Program as you
|
||||||
|
received it, or any part of it, contains a notice stating that it is
|
||||||
|
governed by this License along with a term that is a further
|
||||||
|
restriction, you may remove that term. If a license document contains
|
||||||
|
a further restriction but permits relicensing or conveying under this
|
||||||
|
License, you may add to a covered work material governed by the terms
|
||||||
|
of that license document, provided that the further restriction does
|
||||||
|
not survive such relicensing or conveying.
|
||||||
|
|
||||||
|
If you add terms to a covered work in accord with this section, you
|
||||||
|
must place, in the relevant source files, a statement of the
|
||||||
|
additional terms that apply to those files, or a notice indicating
|
||||||
|
where to find the applicable terms.
|
||||||
|
|
||||||
|
Additional terms, permissive or non-permissive, may be stated in the
|
||||||
|
form of a separately written license, or stated as exceptions;
|
||||||
|
the above requirements apply either way.
|
||||||
|
|
||||||
|
8. Termination.
|
||||||
|
|
||||||
|
You may not propagate or modify a covered work except as expressly
|
||||||
|
provided under this License. Any attempt otherwise to propagate or
|
||||||
|
modify it is void, and will automatically terminate your rights under
|
||||||
|
this License (including any patent licenses granted under the third
|
||||||
|
paragraph of section 11).
|
||||||
|
|
||||||
|
However, if you cease all violation of this License, then your
|
||||||
|
license from a particular copyright holder is reinstated (a)
|
||||||
|
provisionally, unless and until the copyright holder explicitly and
|
||||||
|
finally terminates your license, and (b) permanently, if the copyright
|
||||||
|
holder fails to notify you of the violation by some reasonable means
|
||||||
|
prior to 60 days after the cessation.
|
||||||
|
|
||||||
|
Moreover, your license from a particular copyright holder is
|
||||||
|
reinstated permanently if the copyright holder notifies you of the
|
||||||
|
violation by some reasonable means, this is the first time you have
|
||||||
|
received notice of violation of this License (for any work) from that
|
||||||
|
copyright holder, and you cure the violation prior to 30 days after
|
||||||
|
your receipt of the notice.
|
||||||
|
|
||||||
|
Termination of your rights under this section does not terminate the
|
||||||
|
licenses of parties who have received copies or rights from you under
|
||||||
|
this License. If your rights have been terminated and not permanently
|
||||||
|
reinstated, you do not qualify to receive new licenses for the same
|
||||||
|
material under section 10.
|
||||||
|
|
||||||
|
9. Acceptance Not Required for Having Copies.
|
||||||
|
|
||||||
|
You are not required to accept this License in order to receive or
|
||||||
|
run a copy of the Program. Ancillary propagation of a covered work
|
||||||
|
occurring solely as a consequence of using peer-to-peer transmission
|
||||||
|
to receive a copy likewise does not require acceptance. However,
|
||||||
|
nothing other than this License grants you permission to propagate or
|
||||||
|
modify any covered work. These actions infringe copyright if you do
|
||||||
|
not accept this License. Therefore, by modifying or propagating a
|
||||||
|
covered work, you indicate your acceptance of this License to do so.
|
||||||
|
|
||||||
|
10. Automatic Licensing of Downstream Recipients.
|
||||||
|
|
||||||
|
Each time you convey a covered work, the recipient automatically
|
||||||
|
receives a license from the original licensors, to run, modify and
|
||||||
|
propagate that work, subject to this License. You are not responsible
|
||||||
|
for enforcing compliance by third parties with this License.
|
||||||
|
|
||||||
|
An "entity transaction" is a transaction transferring control of an
|
||||||
|
organization, or substantially all assets of one, or subdividing an
|
||||||
|
organization, or merging organizations. If propagation of a covered
|
||||||
|
work results from an entity transaction, each party to that
|
||||||
|
transaction who receives a copy of the work also receives whatever
|
||||||
|
licenses to the work the party's predecessor in interest had or could
|
||||||
|
give under the previous paragraph, plus a right to possession of the
|
||||||
|
Corresponding Source of the work from the predecessor in interest, if
|
||||||
|
the predecessor has it or can get it with reasonable efforts.
|
||||||
|
|
||||||
|
You may not impose any further restrictions on the exercise of the
|
||||||
|
rights granted or affirmed under this License. For example, you may
|
||||||
|
not impose a license fee, royalty, or other charge for exercise of
|
||||||
|
rights granted under this License, and you may not initiate litigation
|
||||||
|
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||||
|
any patent claim is infringed by making, using, selling, offering for
|
||||||
|
sale, or importing the Program or any portion of it.
|
||||||
|
|
||||||
|
11. Patents.
|
||||||
|
|
||||||
|
A "contributor" is a copyright holder who authorizes use under this
|
||||||
|
License of the Program or a work on which the Program is based. The
|
||||||
|
work thus licensed is called the contributor's "contributor version".
|
||||||
|
|
||||||
|
A contributor's "essential patent claims" are all patent claims
|
||||||
|
owned or controlled by the contributor, whether already acquired or
|
||||||
|
hereafter acquired, that would be infringed by some manner, permitted
|
||||||
|
by this License, of making, using, or selling its contributor version,
|
||||||
|
but do not include claims that would be infringed only as a
|
||||||
|
consequence of further modification of the contributor version. For
|
||||||
|
purposes of this definition, "control" includes the right to grant
|
||||||
|
patent sublicenses in a manner consistent with the requirements of
|
||||||
|
this License.
|
||||||
|
|
||||||
|
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||||
|
patent license under the contributor's essential patent claims, to
|
||||||
|
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||||
|
propagate the contents of its contributor version.
|
||||||
|
|
||||||
|
In the following three paragraphs, a "patent license" is any express
|
||||||
|
agreement or commitment, however denominated, not to enforce a patent
|
||||||
|
(such as an express permission to practice a patent or covenant not to
|
||||||
|
sue for patent infringement). To "grant" such a patent license to a
|
||||||
|
party means to make such an agreement or commitment not to enforce a
|
||||||
|
patent against the party.
|
||||||
|
|
||||||
|
If you convey a covered work, knowingly relying on a patent license,
|
||||||
|
and the Corresponding Source of the work is not available for anyone
|
||||||
|
to copy, free of charge and under the terms of this License, through a
|
||||||
|
publicly available network server or other readily accessible means,
|
||||||
|
then you must either (1) cause the Corresponding Source to be so
|
||||||
|
available, or (2) arrange to deprive yourself of the benefit of the
|
||||||
|
patent license for this particular work, or (3) arrange, in a manner
|
||||||
|
consistent with the requirements of this License, to extend the patent
|
||||||
|
license to downstream recipients. "Knowingly relying" means you have
|
||||||
|
actual knowledge that, but for the patent license, your conveying the
|
||||||
|
covered work in a country, or your recipient's use of the covered work
|
||||||
|
in a country, would infringe one or more identifiable patents in that
|
||||||
|
country that you have reason to believe are valid.
|
||||||
|
|
||||||
|
If, pursuant to or in connection with a single transaction or
|
||||||
|
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||||
|
covered work, and grant a patent license to some of the parties
|
||||||
|
receiving the covered work authorizing them to use, propagate, modify
|
||||||
|
or convey a specific copy of the covered work, then the patent license
|
||||||
|
you grant is automatically extended to all recipients of the covered
|
||||||
|
work and works based on it.
|
||||||
|
|
||||||
|
A patent license is "discriminatory" if it does not include within
|
||||||
|
the scope of its coverage, prohibits the exercise of, or is
|
||||||
|
conditioned on the non-exercise of one or more of the rights that are
|
||||||
|
specifically granted under this License. You may not convey a covered
|
||||||
|
work if you are a party to an arrangement with a third party that is
|
||||||
|
in the business of distributing software, under which you make payment
|
||||||
|
to the third party based on the extent of your activity of conveying
|
||||||
|
the work, and under which the third party grants, to any of the
|
||||||
|
parties who would receive the covered work from you, a discriminatory
|
||||||
|
patent license (a) in connection with copies of the covered work
|
||||||
|
conveyed by you (or copies made from those copies), or (b) primarily
|
||||||
|
for and in connection with specific products or compilations that
|
||||||
|
contain the covered work, unless you entered into that arrangement,
|
||||||
|
or that patent license was granted, prior to 28 March 2007.
|
||||||
|
|
||||||
|
Nothing in this License shall be construed as excluding or limiting
|
||||||
|
any implied license or other defenses to infringement that may
|
||||||
|
otherwise be available to you under applicable patent law.
|
||||||
|
|
||||||
|
12. No Surrender of Others' Freedom.
|
||||||
|
|
||||||
|
If conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot convey a
|
||||||
|
covered work so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you may
|
||||||
|
not convey it at all. For example, if you agree to terms that obligate you
|
||||||
|
to collect a royalty for further conveying from those to whom you convey
|
||||||
|
the Program, the only way you could satisfy both those terms and this
|
||||||
|
License would be to refrain entirely from conveying the Program.
|
||||||
|
|
||||||
|
13. Use with the GNU Affero General Public License.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, you have
|
||||||
|
permission to link or combine any covered work with a work licensed
|
||||||
|
under version 3 of the GNU Affero General Public License into a single
|
||||||
|
combined work, and to convey the resulting work. The terms of this
|
||||||
|
License will continue to apply to the part which is the covered work,
|
||||||
|
but the special requirements of the GNU Affero General Public License,
|
||||||
|
section 13, concerning interaction through a network will apply to the
|
||||||
|
combination as such.
|
||||||
|
|
||||||
|
14. Revised Versions of this License.
|
||||||
|
|
||||||
|
The Free Software Foundation may publish revised and/or new versions of
|
||||||
|
the GNU General Public License from time to time. Such new versions will
|
||||||
|
be similar in spirit to the present version, but may differ in detail to
|
||||||
|
address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the
|
||||||
|
Program specifies that a certain numbered version of the GNU General
|
||||||
|
Public License "or any later version" applies to it, you have the
|
||||||
|
option of following the terms and conditions either of that numbered
|
||||||
|
version or of any later version published by the Free Software
|
||||||
|
Foundation. If the Program does not specify a version number of the
|
||||||
|
GNU General Public License, you may choose any version ever published
|
||||||
|
by the Free Software Foundation.
|
||||||
|
|
||||||
|
If the Program specifies that a proxy can decide which future
|
||||||
|
versions of the GNU General Public License can be used, that proxy's
|
||||||
|
public statement of acceptance of a version permanently authorizes you
|
||||||
|
to choose that version for the Program.
|
||||||
|
|
||||||
|
Later license versions may give you additional or different
|
||||||
|
permissions. However, no additional obligations are imposed on any
|
||||||
|
author or copyright holder as a result of your choosing to follow a
|
||||||
|
later version.
|
||||||
|
|
||||||
|
15. Disclaimer of Warranty.
|
||||||
|
|
||||||
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||||
|
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||||
|
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||||
|
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||||
|
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||||
|
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
16. Limitation of Liability.
|
||||||
|
|
||||||
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||||
|
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||||
|
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||||
|
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||||
|
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||||
|
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||||
|
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||||
|
SUCH DAMAGES.
|
||||||
|
|
||||||
|
17. Interpretation of Sections 15 and 16.
|
||||||
|
|
||||||
|
If the disclaimer of warranty and limitation of liability provided
|
||||||
|
above cannot be given local legal effect according to their terms,
|
||||||
|
reviewing courts shall apply local law that most closely approximates
|
||||||
|
an absolute waiver of all civil liability in connection with the
|
||||||
|
Program, unless a warranty or assumption of liability accompanies a
|
||||||
|
copy of the Program in return for a fee.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest
|
||||||
|
possible use to the public, the best way to achieve this is to make it
|
||||||
|
free software which everyone can redistribute and change under these terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. It is safest
|
||||||
|
to attach them to the start of each source file to most effectively
|
||||||
|
state the exclusion of warranty; and each file should have at least
|
||||||
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
<one line to give the program's name and a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
If the program does terminal interaction, make it output a short
|
||||||
|
notice like this when it starts in an interactive mode:
|
||||||
|
|
||||||
|
<program> Copyright (C) <year> <name of author>
|
||||||
|
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||||
|
This is free software, and you are welcome to redistribute it
|
||||||
|
under certain conditions; type `show c' for details.
|
||||||
|
|
||||||
|
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||||
|
parts of the General Public License. Of course, your program's commands
|
||||||
|
might be different; for a GUI interface, you would use an "about box".
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or school,
|
||||||
|
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||||
|
For more information on this, and how to apply and follow the GNU GPL, see
|
||||||
|
<https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
The GNU General Public License does not permit incorporating your program
|
||||||
|
into proprietary programs. If your program is a subroutine library, you
|
||||||
|
may consider it more useful to permit linking proprietary applications with
|
||||||
|
the library. If this is what you want to do, use the GNU Lesser General
|
||||||
|
Public License instead of this License. But first, please read
|
||||||
|
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
7
EDPlayerJournal/Location.cs
Normal file
7
EDPlayerJournal/Location.cs
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
namespace EDPlayerJournal;
|
||||||
|
public class Location {
|
||||||
|
public string StarSystem { get; set; } = "";
|
||||||
|
public ulong SystemAddress { get; set; } = 0;
|
||||||
|
public string Station { get; set; } = "";
|
||||||
|
public ulong[]? StarPos { get; set; }
|
||||||
|
}
|
475
EDPlayerJournal/Mission.cs
Normal file
475
EDPlayerJournal/Mission.cs
Normal file
@ -0,0 +1,475 @@
|
|||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
using EDPlayerJournal.Entries;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
|
||||||
|
namespace EDPlayerJournal;
|
||||||
|
|
||||||
|
public class FactionEffect {
|
||||||
|
public string? Effect { get; set; }
|
||||||
|
public string? EffectLocalised { get; set; }
|
||||||
|
public string? Trend { get; set; }
|
||||||
|
|
||||||
|
public static FactionEffect FromJSON(JObject obj) {
|
||||||
|
FactionEffect effect = new FactionEffect();
|
||||||
|
|
||||||
|
effect.Effect = obj.Value<string?>("Effect");
|
||||||
|
effect.EffectLocalised = obj.Value<string?>("Effect_Localised");
|
||||||
|
effect.Trend = obj.Value<string?>("Trend");
|
||||||
|
|
||||||
|
return effect;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class MissionInfluence {
|
||||||
|
/// <summary>
|
||||||
|
/// System Address this influence happened in.
|
||||||
|
/// </summary>
|
||||||
|
public ulong? SystemAddress { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Generic description of the trend (up or down)
|
||||||
|
/// </summary>
|
||||||
|
public string? Trend { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Influence gained in plusses
|
||||||
|
/// </summary>
|
||||||
|
public string Influence { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public long InfluenceAmount {
|
||||||
|
get {
|
||||||
|
string trend = TrendAdjustedInfluence;
|
||||||
|
return (long)
|
||||||
|
(trend.Count(x => x == '-') * -1) +
|
||||||
|
trend.Count(x => x == '+')
|
||||||
|
;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns how much influence was made, represented in pluses for positive influence,
|
||||||
|
/// and minuses with negative influence. This takes Trend (up, bad etc.) into account.
|
||||||
|
/// </summary>
|
||||||
|
public string TrendAdjustedInfluence {
|
||||||
|
get {
|
||||||
|
if (!string.IsNullOrEmpty(Trend) &&
|
||||||
|
Trend.Contains("bad", StringComparison.OrdinalIgnoreCase)) {
|
||||||
|
return new string('-', Influence.Length);
|
||||||
|
} else {
|
||||||
|
return new string('+', Influence.Length);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MissionInfluence FromJSON(JObject obj) {
|
||||||
|
MissionInfluence missionInfluence = new MissionInfluence();
|
||||||
|
|
||||||
|
missionInfluence.SystemAddress = obj.Value<ulong?>("SystemAddress");
|
||||||
|
missionInfluence.Trend = obj.Value<string?>("Trend");
|
||||||
|
missionInfluence.Influence = obj.Value<string?>("Influence") ?? "";
|
||||||
|
|
||||||
|
return missionInfluence;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class MissionFactionEffects {
|
||||||
|
/// <summary>
|
||||||
|
/// Faction in question
|
||||||
|
/// </summary>
|
||||||
|
public string? Faction { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Reputation trend
|
||||||
|
/// </summary>
|
||||||
|
public string? ReputationTrend { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Reputation in pluses.
|
||||||
|
/// </summary>
|
||||||
|
public string Reputation { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// List of economic and security affects.
|
||||||
|
/// </summary>
|
||||||
|
public List<FactionEffect> Effects { get; set; } = new List<FactionEffect>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Influence gained.
|
||||||
|
/// </summary>
|
||||||
|
public List<MissionInfluence> Influences { get; set; } = new List<MissionInfluence>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether this affect is for an empty, or non-existant faction.
|
||||||
|
/// </summary>
|
||||||
|
public bool IsEmptyFaction {
|
||||||
|
get { return string.IsNullOrEmpty(Faction); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MissionFactionEffects FromJSON(JObject j) {
|
||||||
|
MissionFactionEffects o = new MissionFactionEffects();
|
||||||
|
|
||||||
|
o.Faction = j.Value<string>("Faction");
|
||||||
|
|
||||||
|
o.ReputationTrend = j.Value<string?>("ReputationTrend");
|
||||||
|
o.Reputation = j.Value<string?>("Reputation") ?? string.Empty;
|
||||||
|
|
||||||
|
JArray? effects = j.Value<JArray?>("Effects");
|
||||||
|
if (effects != null) {
|
||||||
|
foreach (JObject effect in effects.Children().OfType<JObject>()) {
|
||||||
|
FactionEffect e = FactionEffect.FromJSON(effect);
|
||||||
|
o.Effects.Add(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
JArray? influences = j.Value<JArray?>("Influence");
|
||||||
|
if (influences != null) {
|
||||||
|
foreach (JObject influence in influences.Children().OfType<JObject>()) {
|
||||||
|
MissionInfluence missionInfluence = MissionInfluence.FromJSON(influence);
|
||||||
|
o.Influences.Add(missionInfluence);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Mission : IComparable<Mission> {
|
||||||
|
/// <summary>
|
||||||
|
/// Passenger type for refugees
|
||||||
|
/// </summary>
|
||||||
|
public static readonly string PassengerTypeRefugee = "Refugee";
|
||||||
|
|
||||||
|
public ulong MissionID { get; set; } = 0;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Name of the mission, in machine readable format.
|
||||||
|
/// </summary>
|
||||||
|
public string? Name { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Localised, human readable mission name.
|
||||||
|
/// </summary>
|
||||||
|
public string? LocalisedName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Target of the mission. Optional.
|
||||||
|
/// </summary>
|
||||||
|
public string? Target { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Target of the mission as a localised human readable string.
|
||||||
|
/// </summary>
|
||||||
|
public string? TargetLocalised { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Target system of the mission
|
||||||
|
/// </summary>
|
||||||
|
public string? DestinationSystem { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Destination station.
|
||||||
|
/// </summary>
|
||||||
|
public string? DestinationStation { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Destination settlement
|
||||||
|
/// </summary>
|
||||||
|
public string? DestinationSettlement { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// In case of redirection, these values denote the new system.
|
||||||
|
/// </summary>
|
||||||
|
public string? NewDestinationSystem { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// In case of redirection, these values denote the new station.
|
||||||
|
/// </summary>
|
||||||
|
public string? NewDestinationStation { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Faction offering the mission.
|
||||||
|
/// </summary>
|
||||||
|
public string? Faction { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Target faction (for example for courier missions).
|
||||||
|
/// </summary>
|
||||||
|
public string? TargetFaction { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether the mission is a wing message.
|
||||||
|
/// </summary>
|
||||||
|
public bool Wing { get; set; } = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Expiry date for the mission.
|
||||||
|
/// </summary>
|
||||||
|
public string? Expiry { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Certain missions have an expires number. No one knows what that is.
|
||||||
|
/// </summary>
|
||||||
|
public ulong? Expires { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Influence reward offered. This is for accepting missions only, see the
|
||||||
|
/// mission effects for actual effects once the mission is complete.
|
||||||
|
/// </summary>
|
||||||
|
public string? Influence { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Reputation reward offered.
|
||||||
|
/// </summary>
|
||||||
|
public string? Reputation { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Number of kills required for massacre missions.
|
||||||
|
/// </summary>
|
||||||
|
public ulong? KillCount { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Monatery reward offered for the mission. Optional, as donate missions don't give
|
||||||
|
/// a monatery reward.
|
||||||
|
/// </summary>
|
||||||
|
public ulong? Reward { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Amount donated for donation missions, optional. If this is null, then
|
||||||
|
/// the mission was not a donation mission.
|
||||||
|
/// </summary>
|
||||||
|
public ulong? Donation { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Actual amount donated.
|
||||||
|
/// </summary>
|
||||||
|
public ulong? Donated { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Commodity delivered, or donated. Optional, if this is null, then no
|
||||||
|
/// commodity was donated or delivered.
|
||||||
|
/// </summary>
|
||||||
|
public string? Commodity { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Amount of the commodity donated or delivered. Optional.
|
||||||
|
/// </summary>
|
||||||
|
public ulong? Count { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// How many passengers are being transported.
|
||||||
|
/// </summary>
|
||||||
|
public ulong? PassengerCount { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// If the passengers are VIPs.
|
||||||
|
/// </summary>
|
||||||
|
public bool? PassengerVIPs { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// If the passengers are wanted.
|
||||||
|
/// </summary>
|
||||||
|
public bool? PassengerWanted { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// What sort of passengers are being transported.
|
||||||
|
/// </summary>
|
||||||
|
public string? PassengerType { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Affect this mission had on factions.
|
||||||
|
/// </summary>
|
||||||
|
public List<MissionFactionEffects> FactionEffects { get; set; } = new List<MissionFactionEffects>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns true if the name is an on foot mission.
|
||||||
|
/// </summary>
|
||||||
|
public bool IsOnFoot {
|
||||||
|
get {
|
||||||
|
if (string.IsNullOrEmpty(Name)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Name.Contains("OnFoot");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsPassengerMission {
|
||||||
|
get {
|
||||||
|
if (PassengerCount == null || PassengerCount == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsRescueMission {
|
||||||
|
get {
|
||||||
|
if (!IsPassengerMission) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.Compare(PassengerType, PassengerTypeRefugee) == 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a friendly human-readable name for the mission. If a localised name is available
|
||||||
|
/// it will use that, baring that it will check EnglishMissionNames for a translation, and
|
||||||
|
/// if that ain't available either, it will just use the internal Name.
|
||||||
|
/// </summary>
|
||||||
|
public string FriendlyName {
|
||||||
|
get {
|
||||||
|
if (!string.IsNullOrEmpty(LocalisedName)) {
|
||||||
|
return LocalisedName;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(Name)) {
|
||||||
|
return "Unknown Mission";
|
||||||
|
}
|
||||||
|
|
||||||
|
string? translate = EnglishMissionNames.Translate(Name);
|
||||||
|
if (!string.IsNullOrEmpty(translate)) {
|
||||||
|
return translate;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int CompareTo(Mission? other) {
|
||||||
|
if (other == null) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return MissionID.CompareTo(other.MissionID);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Mission FromJSON(JObject o) {
|
||||||
|
Mission mission = new Mission();
|
||||||
|
|
||||||
|
mission.MissionID = o.Value<ulong?>("MissionID") ?? 0;
|
||||||
|
|
||||||
|
mission.Reputation = o.Value<string>("Reputation");
|
||||||
|
mission.Influence = o.Value<string>("Influence");
|
||||||
|
|
||||||
|
mission.DestinationSystem = o.Value<string>("DestinationSystem");
|
||||||
|
mission.DestinationSettlement = o.Value<string>("DestinationSettlement");
|
||||||
|
mission.DestinationStation = o.Value<string>("DestinationStation");
|
||||||
|
|
||||||
|
mission.NewDestinationSystem = o.Value<string>("NewDestinationSystem");
|
||||||
|
mission.NewDestinationStation = o.Value<string>("NewDestinationSystem");
|
||||||
|
|
||||||
|
mission.Reward = o.Value<ulong?>("Reward");
|
||||||
|
|
||||||
|
mission.Target = o.Value<string>("Target");
|
||||||
|
mission.TargetLocalised = o.Value<string>("Target_Localised");
|
||||||
|
|
||||||
|
mission.Expiry = o.Value<string?>("Expiry");
|
||||||
|
mission.Expires = o.Value<ulong?>("Expires");
|
||||||
|
mission.Wing = o.Value<bool?>("Wing") ?? false;
|
||||||
|
|
||||||
|
mission.Name = o.Value<string>("Name");
|
||||||
|
mission.LocalisedName = o.Value<string>("LocalisedName");
|
||||||
|
|
||||||
|
mission.Faction = o.Value<string?>("Faction");
|
||||||
|
mission.TargetFaction = o.Value<string?>("TargetFaction");
|
||||||
|
|
||||||
|
mission.Donation = o.Value<ulong?>("Donation");
|
||||||
|
mission.Donated = o.Value<ulong?>("Donated");
|
||||||
|
|
||||||
|
mission.PassengerCount = o.Value<ulong?>("PassengerCount");
|
||||||
|
mission.PassengerVIPs = o.Value<bool?>("PassengerVIPs");
|
||||||
|
mission.PassengerWanted = o.Value<bool?>("PassengerWanted");
|
||||||
|
mission.PassengerType = o.Value<string>("PassengerType");
|
||||||
|
|
||||||
|
mission.KillCount = o.Value<ulong?>("KillCount");
|
||||||
|
|
||||||
|
JArray? factionEffects = o.Value<JArray?>("FactionEffects");
|
||||||
|
if (factionEffects != null) {
|
||||||
|
foreach (JObject effect in factionEffects.Children().OfType<JObject>()) {
|
||||||
|
MissionFactionEffects factionEffect = MissionFactionEffects.FromJSON(effect);
|
||||||
|
mission.FactionEffects.Add(factionEffect);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return mission;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a list of all affected factions.
|
||||||
|
/// </summary>
|
||||||
|
public string[] AffectedFactions {
|
||||||
|
get {
|
||||||
|
return FactionEffects
|
||||||
|
.Where(x => !string.IsNullOrEmpty(x.Faction))
|
||||||
|
.Select(x => (x.Faction ?? string.Empty))
|
||||||
|
.ToArray()
|
||||||
|
;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the influence for a given faction in a given star system.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="faction">Faction name in question.</param>
|
||||||
|
/// <param name="systemaddr">Star System address</param>
|
||||||
|
/// <returns>null if no entry was found, or a string denoting pluses for the amount influence gained.</returns>
|
||||||
|
public MissionInfluence[]? GetInfluenceForFaction(string faction, ulong systemaddr) {
|
||||||
|
var results = FactionEffects
|
||||||
|
.Where(x => string.Compare(x.Faction, faction) == 0)
|
||||||
|
.SelectMany(x => x.Influences)
|
||||||
|
.Where(x => (x.SystemAddress != null && x.SystemAddress == systemaddr))
|
||||||
|
.Select(x => x)
|
||||||
|
.ToArray()
|
||||||
|
;
|
||||||
|
|
||||||
|
if (results == null || results.Length == 0) {
|
||||||
|
return new MissionInfluence[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A convenient Dictionary containing all influences given out by faction,
|
||||||
|
/// then by system address and then by influence handed out. Influence can
|
||||||
|
/// be either a series of "+" for positive influence, or "-" for negative
|
||||||
|
/// influence.
|
||||||
|
/// </summary>
|
||||||
|
public Dictionary<string, Dictionary<ulong, MissionInfluence>> Influences {
|
||||||
|
get {
|
||||||
|
return FactionEffects
|
||||||
|
.Where(x => x.Faction != null)
|
||||||
|
.ToDictionary(
|
||||||
|
x => (x.Faction ?? string.Empty),
|
||||||
|
x => x.Influences
|
||||||
|
.Where(x => x.SystemAddress != null)
|
||||||
|
.ToDictionary(
|
||||||
|
x => (x.SystemAddress ?? 0),
|
||||||
|
x => x
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Mission FromMissionAccepted(JObject o) {
|
||||||
|
return FromJSON(o);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Mission FromMissionAbandoned(JObject o) {
|
||||||
|
return FromJSON(o);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Mission FromMissionFailed(JObject o) {
|
||||||
|
return FromJSON(o);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Mission FromMissionCompleted(JObject o) {
|
||||||
|
return FromJSON(o);
|
||||||
|
}
|
||||||
|
}
|
122
EDPlayerJournal/NPC.cs
Normal file
122
EDPlayerJournal/NPC.cs
Normal file
@ -0,0 +1,122 @@
|
|||||||
|
namespace EDPlayerJournal;
|
||||||
|
|
||||||
|
public class NPCs {
|
||||||
|
/// <summary>
|
||||||
|
/// Internal name of Spec Ops Wing Alpha
|
||||||
|
/// </summary>
|
||||||
|
public static string SpecOpsAInternal = "$LUASC_Scenario_Warzone_NPC_SpecOps_A;";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Internal name of Spec Ops Wing Beta
|
||||||
|
/// </summary>
|
||||||
|
public static string SpecOpsBInternal = "$LUASC_Scenario_Warzone_NPC_SpecOps_B;";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Internal name of Spec Ops Wing Gamma
|
||||||
|
/// </summary>
|
||||||
|
public static string SpecOpsGInternal = "$LUASC_Scenario_Warzone_NPC_SpecOps_G;";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Internal name of Spec Ops Wing Delta
|
||||||
|
/// </summary>
|
||||||
|
public static string SpecOpsDInternal = "$LUASC_Scenario_Warzone_NPC_SpecOps_D;";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Empire captain
|
||||||
|
/// </summary>
|
||||||
|
public static string EmpireCaptain = "$LUASC_Scenario_Warzone_NPC_WarzoneGeneral_Emp;";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Federation captain
|
||||||
|
/// </summary>
|
||||||
|
public static string FederationCaptain = "$LUASC_Scenario_Warzone_NPC_WarzoneGeneral_Fed;";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Federation captain
|
||||||
|
/// </summary>
|
||||||
|
public static string IndependentCaptain = "$LUASC_Scenario_Warzone_NPC_WarzoneGeneral_Ind;";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Warzone correspondant
|
||||||
|
/// </summary>
|
||||||
|
public static string WarzoneCorrespondent = "$LUASC_Scenario_Warzone_NPC_WarzoneCorrespondent;";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// AX Military NPC
|
||||||
|
/// </summary>
|
||||||
|
public static string AXMilitary = "$Name_AX_Military;";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns true if the pilotname is either a captain, specops, or correspondent
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="pilotname"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static bool IsWarzoneNPC(string? pilotname) {
|
||||||
|
if (IsWarzoneCaptain(pilotname) ||
|
||||||
|
IsWarzoneCorrespondent(pilotname) ||
|
||||||
|
IsSpecOps(pilotname)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns true if the given pilot name is a warzone correspondent
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static bool IsWarzoneCorrespondent(string? pilotname) {
|
||||||
|
if (pilotname == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.Compare(pilotname, WarzoneCorrespondent) == 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns true if the given pilot name is a spec ops wing.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static bool IsSpecOps(string? pilotname) {
|
||||||
|
if (pilotname == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.Compare(pilotname, SpecOpsAInternal) == 0 ||
|
||||||
|
string.Compare(pilotname, SpecOpsBInternal) == 0 ||
|
||||||
|
string.Compare(pilotname, SpecOpsGInternal) == 0 ||
|
||||||
|
string.Compare(pilotname, SpecOpsDInternal) == 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns true if the given pilot name is a warzone captain
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static bool IsWarzoneCaptain(string? pilotname) {
|
||||||
|
if (pilotname == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.Compare(pilotname, EmpireCaptain) == 0 ||
|
||||||
|
string.Compare(pilotname, FederationCaptain) == 0 ||
|
||||||
|
string.Compare(pilotname, IndependentCaptain) == 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class NPC {
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user