whitespace, comments, broad subtypes

- changes some whitespace stuff
- adds some comments for ease of reading

player facing stuff
- adds hharar, njarir to tajara
- adds axiori, xiialt, xiori to skrell
- adds breeders, bulwarks to vaurca
- adds baseline, bishop to ipc models
- renames g1, g2 heavy frames to industrial
- fixes shells being listed twice
- removes 'do not clone' option
This commit is contained in:
Llywelwyn 2022-07-24 11:42:32 +01:00
parent 11f108b5f8
commit 9b85a836fb
10 changed files with 696 additions and 683 deletions

View file

@ -8,10 +8,10 @@ using System.Windows;
namespace AuroraRecordGenerator namespace AuroraRecordGenerator
{ {
/// <summary> /// <summary>
/// Interaction logic for App.xaml /// Interaction logic for App.xaml
/// </summary> /// </summary>
public partial class App : Application public partial class App : Application
{ {
} }
} }

View file

@ -1,18 +1,18 @@
namespace AuroraRecordGenerator namespace AuroraRecordGenerator
{ {
public partial class GeneratedResultWindow public partial class GeneratedResultWindow
{ {
public GeneratedResultWindow() public GeneratedResultWindow()
{ {
InitializeComponent(); InitializeComponent();
} }
public GeneratedResultWindow(Record record) : this() public GeneratedResultWindow(Record record) : this()
{ {
var formatter = new RecordFormatter(record); var formatter = new RecordFormatter(record);
EmploymentBox.Text = formatter.EmploymentRecords; EmploymentBox.Text = formatter.EmploymentRecords;
MedicalBox.Text = formatter.MedicalRecords; MedicalBox.Text = formatter.MedicalRecords;
SecurityBox.Text = formatter.SecurityRecords; SecurityBox.Text = formatter.SecurityRecords;
} }
} }
} }

View file

@ -30,12 +30,12 @@ using System.Windows;
[assembly: ThemeInfo( [assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page, //(used if a resource is not found in the page,
// or application resource dictionaries) // or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page, //(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries) // app, or any theme specific resource dictionaries)
)] )]

View file

@ -3,118 +3,115 @@ using ProtoBuf;
namespace AuroraRecordGenerator namespace AuroraRecordGenerator
{ {
[ProtoContract] [ProtoContract]
public class Record public class Record
{ {
// Defaults defined here will automatically populate the form on program load // Defaults defined here will automatically populate the form on program load
[ProtoMember(1)] [ProtoMember(1)]
public string FirstName { get; set; } = string.Empty; public string FirstName { get; set; } = string.Empty;
[ProtoMember(2)] [ProtoMember(2)]
public string MiddleName { get; set; } = string.Empty; public string MiddleName { get; set; } = string.Empty;
[ProtoMember(3)] [ProtoMember(3)]
public string LastName { get; set; } = string.Empty; public string LastName { get; set; } = string.Empty;
[ProtoMember(4)] [ProtoMember(4)]
public string NameSuffix { get; set; } = string.Empty; public string NameSuffix { get; set; } = string.Empty;
[ProtoMember(5, IsRequired = true)] [ProtoMember(5, IsRequired = true)]
public SpeciesType Species { get; set; } = SpeciesType.Human; public SpeciesType Species { get; set; } = SpeciesType.Human;
[ProtoMember(16)] [ProtoMember(16)]
public SpeciesSubType Subspecies { get; set; } = SpeciesSubType.None; public SpeciesSubType Subspecies { get; set; } = SpeciesSubType.None;
[ProtoMember(6, IsRequired = true)] [ProtoMember(6, IsRequired = true)]
public GenderType Gender { get; set; } public GenderType Gender { get; set; }
[ProtoMember(7)] [ProtoMember(7)]
public DateTime BirthDate { get; set; } = Info.IcDate; public DateTime BirthDate { get; set; } = Info.IcDate;
[ProtoMember(8)] [ProtoMember(8)]
public double? CharHeight { get; set; } = 170; public double? CharHeight { get; set; } = 170;
[ProtoMember(9)] [ProtoMember(9)]
public double? Weight { get; set; } = 70; public double? Weight { get; set; } = 70;
[ProtoMember(10)] [ProtoMember(10)]
public string SkinColor { get; set; } = string.Empty; public string SkinColor { get; set; } = string.Empty;
[ProtoMember(11)] [ProtoMember(11)]
public string EyeColor { get; set; } = string.Empty; public string EyeColor { get; set; } = string.Empty;
[ProtoMember(12)] [ProtoMember(12)]
public string DistinguishingFeatures { get; set; } = string.Empty; public string DistinguishingFeatures { get; set; } = string.Empty;
[ProtoMember(13)] [ProtoMember(13)]
public string HairColor { get; set; } = string.Empty; public string HairColor { get; set; } = string.Empty;
[ProtoMember(14)] [ProtoMember(14)]
public string EmployedAs { get; set; } = string.Empty; public string EmployedAs { get; set; } = string.Empty;
[ProtoMember(15)] [ProtoMember(15)]
public string Citizenship { get; set; } = string.Empty; public string Citizenship { get; set; } = string.Empty;
// 16 & 17 used to be PictureUrl and PictureCredit, now unused. // 16 & 17 used to be PictureUrl and PictureCredit, now unused.
[ProtoMember(18)] [ProtoMember(18)]
public string Clearance { get; set; } = string.Empty; public string Clearance { get; set; } = string.Empty;
[ProtoMember(19)] [ProtoMember(19)]
public string MedicalPublicRecord { get; set; } = string.Empty; public string MedicalPublicRecord { get; set; } = string.Empty;
[ProtoMember(20)] [ProtoMember(20)]
public string MedicalHistory { get; set; } = string.Empty; public string MedicalHistory { get; set; } = string.Empty;
[ProtoMember(21)] [ProtoMember(21)]
public string MedicalNotes { get; set; } = string.Empty; public string MedicalNotes { get; set; } = string.Empty;
[ProtoMember(22)] [ProtoMember(22)]
public string MedicalPsychHistory { get; set; } = string.Empty; public string MedicalPsychHistory { get; set; } = string.Empty;
[ProtoMember(23)] [ProtoMember(23)]
public string MedicalPsychNotes { get; set; } = string.Empty; public string MedicalPsychNotes { get; set; } = string.Empty;
[ProtoMember(24)] [ProtoMember(24)]
public bool NoBorg { get; set; } = false; public bool NoBorg { get; set; } = false;
[ProtoMember(25)] [ProtoMember(26)]
public bool NoClone { get; set; } = false; public bool NoRevive { get; set; } = false;
[ProtoMember(26)] [ProtoMember(27)]
public bool NoRevive { get; set; } = false; public bool NoProsthetic { get; set; } = false;
[ProtoMember(27)] [ProtoMember(28)]
public bool NoProsthetic { get; set; } = false; public string MedicalPrescriptions { get; set; } = string.Empty;
[ProtoMember(28)] [ProtoMember(29)]
public string MedicalPrescriptions { get; set; } = string.Empty; public string SecurityPublicRecord { get; set; } = string.Empty;
[ProtoMember(29)] [ProtoMember(30)]
public string SecurityPublicRecord { get; set; } = string.Empty; public string SecurityRecords { get; set; } = string.Empty;
[ProtoMember(30)] [ProtoMember(31)]
public string SecurityRecords { get; set; } = string.Empty; public string SecurityNotes { get; set; } = string.Empty;
[ProtoMember(31)] [ProtoMember(32)]
public string SecurityNotes { get; set; } = string.Empty; public string EmploymentPublicRecord { get; set; } = string.Empty;
[ProtoMember(32)] [ProtoMember(33)]
public string EmploymentPublicRecord { get; set; } = string.Empty; public string EmploymentExperience { get; set; } = string.Empty;
[ProtoMember(33)] [ProtoMember(34)]
public string EmploymentExperience { get; set; } = string.Empty; public string EmploymentPreNtEmployment { get; set; } = string.Empty;
[ProtoMember(34)] [ProtoMember(35)]
public string EmploymentPreNtEmployment { get; set; } = string.Empty; public string EmploymentFormalEducation { get; set; } = string.Empty;
[ProtoMember(35)] [ProtoMember(36)]
public string EmploymentFormalEducation { get; set; } = string.Empty; public string EmploymentNtEmploymentHistory { get; set; } = string.Empty;
[ProtoMember(36)] [ProtoMember(37)]
public string EmploymentNtEmploymentHistory { get; set; } = string.Empty; public string EmploymentSkills { get; set; } = string.Empty;
}
[ProtoMember(37)]
public string EmploymentSkills { get; set; } = string.Empty;
}
} }

View file

@ -248,7 +248,7 @@
<ScrollViewer> <ScrollViewer>
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="60" /> <RowDefinition Height="50" />
<!-- Checkboxes --> <!-- Checkboxes -->
<RowDefinition Height="122" MinHeight="60" /> <RowDefinition Height="122" MinHeight="60" />
<RowDefinition Height="122" MinHeight="60" /> <RowDefinition Height="122" MinHeight="60" />
@ -260,21 +260,29 @@
</Grid.RowDefinitions> </Grid.RowDefinitions>
<!-- Opt-Outs --> <!-- Opt-Outs -->
<Grid Grid.Row="0" ToolTip="If the character wishes to not be cloned."> <Grid Grid.Row="0" ToolTip="If the character wishes to not be cloned.">
<CheckBox x:Name="NoClone" Content="Do Not Clone" HorizontalAlignment="Left" <Grid.ColumnDefinitions>
Margin="10,10,0,0" VerticalAlignment="Top" TabIndex="1" /> <ColumnDefinition Width="163*"/>
<CheckBox x:Name="NoProsthetic" Content="No Prosthetics" <ColumnDefinition Width="163*"/>
HorizontalAlignment="Left" Margin="10,33,0,0" VerticalAlignment="Top" <ColumnDefinition Width="163*"/>
ToolTip="If the character should not be fitted with prosthetics." TabIndex="3" /> <ColumnDefinition Width="163*"/>
<CheckBox x:Name="NoBorg" Content="Do Not Borgify" HorizontalAlignment="Left" <ColumnDefinition Width="163*"/>
Margin="136,10,0,0" VerticalAlignment="Top" </Grid.ColumnDefinitions>
ToolTip="If the character should not be borged." TabIndex="2" /> <CheckBox x:Name="NoBorg" Content="Do Not Borgify"
HorizontalAlignment="Left"
Margin="0,10,0,0"
ToolTip="If the character should not be borged." TabIndex="1" Grid.Column="0" />
<CheckBox x:Name="NoRevive" Content="Do Not Resuscitate" <CheckBox x:Name="NoRevive" Content="Do Not Resuscitate"
HorizontalAlignment="Left" Margin="136,33,0,0" VerticalAlignment="Top" HorizontalAlignment="Left"
ToolTip="If the character should not be revived." TabIndex="4" /> Margin="-10,10,0,0"
ToolTip="If the character should not be revived." TabIndex="2" Grid.Column="1" />
<CheckBox x:Name="NoProsthetic" Content="No Prosthetics"
HorizontalAlignment="Left"
Margin="0,10,0,0"
ToolTip="If the character should not be fitted with prosthetics." TabIndex="3" Grid.Column="2" />
</Grid> </Grid>
<!-- user-resizable stuff is fun! Not. --> <!-- user-resizable stuff is fun! Not. -->
<GridSplitter Grid.Row="1" Grid.ColumnSpan="1" HorizontalAlignment="Stretch" <GridSplitter Grid.Row="1" Grid.ColumnSpan="1" HorizontalAlignment="Stretch"
VerticalAlignment="Bottom" Margin="0" Height="10" /> VerticalAlignment="Bottom" Height="10" />
<GridSplitter Grid.Row="2" Grid.ColumnSpan="1" HorizontalAlignment="Stretch" <GridSplitter Grid.Row="2" Grid.ColumnSpan="1" HorizontalAlignment="Stretch"
VerticalAlignment="Bottom" Margin="0" Height="10" /> VerticalAlignment="Bottom" Margin="0" Height="10" />
<GridSplitter Grid.Row="3" Grid.ColumnSpan="1" HorizontalAlignment="Stretch" <GridSplitter Grid.Row="3" Grid.ColumnSpan="1" HorizontalAlignment="Stretch"
@ -286,14 +294,14 @@
<GridSplitter Grid.Row="6" Grid.ColumnSpan="1" HorizontalAlignment="Stretch" <GridSplitter Grid.Row="6" Grid.ColumnSpan="1" HorizontalAlignment="Stretch"
VerticalAlignment="Bottom" Margin="0" Height="10" /> VerticalAlignment="Bottom" Margin="0" Height="10" />
<TextBox Margin="0,10,0,10" AcceptsReturn="True" <TextBox Margin="0,10" AcceptsReturn="True"
TextWrapping="Wrap" controls:TextBoxHelper.Watermark="Public Record" TextWrapping="Wrap" controls:TextBoxHelper.Watermark="Public Record"
controls:TextBoxHelper.UseFloatingWatermark="True" controls:TextBoxHelper.UseFloatingWatermark="True"
controls:TextBoxHelper.IsSpellCheckContextMenuEnabled="True" controls:TextBoxHelper.IsSpellCheckContextMenuEnabled="True"
ToolTip="Public medical notes posted on employment and security records. One per line." ToolTip="Public medical notes posted on employment and security records. One per line."
Grid.Row="1" VerticalScrollBarVisibility="Auto" Grid.Row="1" VerticalScrollBarVisibility="Auto"
Text="{Binding Path=MedicalPublicRecord}" TabIndex="5" /> Text="{Binding Path=MedicalPublicRecord}" TabIndex="5" />
<TextBox Margin="0,10,0,10" AcceptsReturn="True" TextWrapping="Wrap" <TextBox Margin="0,10" AcceptsReturn="True" TextWrapping="Wrap"
controls:TextBoxHelper.Watermark="Medical History" controls:TextBoxHelper.Watermark="Medical History"
controls:TextBoxHelper.UseFloatingWatermark="True" controls:TextBoxHelper.UseFloatingWatermark="True"
controls:TextBoxHelper.IsSpellCheckContextMenuEnabled="True" controls:TextBoxHelper.IsSpellCheckContextMenuEnabled="True"

View file

@ -9,185 +9,184 @@ using System.Windows.Controls;
namespace AuroraRecordGenerator namespace AuroraRecordGenerator
{ {
/// <summary> /// <summary>
/// Interaction logic for RecordEditor.xaml /// Interaction logic for RecordEditor.xaml
/// </summary> /// </summary>
public partial class RecordEditor public partial class RecordEditor
{ {
public RecordEditor() public RecordEditor()
{ {
// Initialize the record object used for storage and generation // Initialize the record object used for storage and generation
Data = new Record(); Data = new Record();
DataContext = Data; DataContext = Data;
ProtoBuf.Serializer.PrepareSerializer<GenderType>(); ProtoBuf.Serializer.PrepareSerializer<GenderType>();
ProtoBuf.Serializer.PrepareSerializer<SpeciesType>(); ProtoBuf.Serializer.PrepareSerializer<SpeciesType>();
ProtoBuf.Serializer.PrepareSerializer<SpeciesSubType>(); ProtoBuf.Serializer.PrepareSerializer<SpeciesSubType>();
ProtoBuf.Serializer.PrepareSerializer<Record>(); ProtoBuf.Serializer.PrepareSerializer<Record>();
InitializeComponent(); InitializeComponent();
SubSpeciesCombo.ItemsSource = GetSpeciesOptions(); SubSpeciesCombo.ItemsSource = GetSpeciesOptions();
VersionLabel.Content = $"v{Utility.GetVersion()}"; VersionLabel.Content = $"v{Utility.GetVersion()}";
} }
private Record Data { get; set; } private Record Data { get; set; }
private string _currentFilePath; private string _currentFilePath;
private void SpeciesSelectChanged(object sender, SelectionChangedEventArgs e) private void SpeciesSelectChanged(object sender, SelectionChangedEventArgs e)
{ {
if (SpeciesCombo.SelectionBoxItem == null) if (SpeciesCombo.SelectionBoxItem == null)
return; return;
var type = (SpeciesType)SpeciesCombo.SelectedValue; var type = (SpeciesType)SpeciesCombo.SelectedValue;
switch (type) switch (type)
{ {
// non-gendered species // non-gendered species
case SpeciesType.Diona: case SpeciesType.Diona:
case SpeciesType.IPC: case SpeciesType.IPC:
case SpeciesType.Vaurca: case SpeciesType.Vaurca:
Debug.WriteLine("Disabled GenderCombo, type is " + type); Debug.WriteLine("Disabled GenderCombo, type is " + type);
GenderCombo.IsEnabled = false; GenderCombo.IsEnabled = false;
GenderCombo.Text = "N/A"; GenderCombo.Text = "N/A";
break; break;
// gendered species // gendered species
case SpeciesType.Human: case SpeciesType.Human:
case SpeciesType.Skrell: case SpeciesType.Skrell:
case SpeciesType.Tajara: case SpeciesType.Tajara:
case SpeciesType.Unathi: case SpeciesType.Unathi:
Debug.WriteLine("Enabled GenderCombo, type is " + type); Debug.WriteLine("Enabled GenderCombo, type is " + type);
GenderCombo.IsEnabled = true; GenderCombo.IsEnabled = true;
break; break;
case SpeciesType.None: case SpeciesType.None:
break; break;
default: default:
throw new ArgumentOutOfRangeException(); throw new ArgumentOutOfRangeException();
} }
Debug.WriteLine("Updating subspecies types."); Debug.WriteLine("Updating subspecies types.");
var types = GetSpeciesOptions(type); var types = GetSpeciesOptions(type);
var itemsSource = types as IList<string> ?? types.ToList(); var itemsSource = types as IList<string> ?? types.ToList();
SubSpeciesCombo.ItemsSource = itemsSource; SubSpeciesCombo.ItemsSource = itemsSource;
Debug.WriteLine($"New types: {string.Join(",", itemsSource)}"); Debug.WriteLine($"New types: {string.Join(",", itemsSource)}");
} }
private void WindowLoaded(object sender, RoutedEventArgs e) private void WindowLoaded(object sender, RoutedEventArgs e)
{ {
SpeciesCombo.SelectedIndex = 0; SpeciesCombo.SelectedIndex = 0;
} }
private void GenerateRecord(object sender, RoutedEventArgs e) private void GenerateRecord(object sender, RoutedEventArgs e)
{ {
// Update medical checkboxes. // Update medical checkboxes.
Data.NoClone = NoClone.IsChecked ?? false; Data.NoBorg = NoBorg.IsChecked ?? false;
Data.NoBorg = NoBorg.IsChecked ?? false; Data.NoProsthetic = NoProsthetic.IsChecked ?? false;
Data.NoProsthetic = NoProsthetic.IsChecked ?? false; Data.NoRevive = NoRevive.IsChecked ?? false;
Data.NoRevive = NoRevive.IsChecked ?? false;
// Figure out what subspecies we've got. // Figure out what subspecies we've got.
var subspecies = SubSpeciesCombo.SelectedItem as string; var subspecies = SubSpeciesCombo.SelectedItem as string;
Data.Subspecies = subspecies != null ? Utility.SubspeciesNiceNameToEnum(subspecies) : SpeciesSubType.None; Data.Subspecies = subspecies != null ? Utility.SubspeciesNiceNameToEnum(subspecies) : SpeciesSubType.None;
// Figure out their species too. // Figure out their species too.
Data.Species = (SpeciesType)SpeciesCombo.SelectedValue; Data.Species = (SpeciesType)SpeciesCombo.SelectedValue;
// Finally, gender. // Finally, gender.
switch ((string)GenderCombo.SelectionBoxItem) switch ((string)GenderCombo.SelectionBoxItem)
{ {
case "Male": case "Male":
Data.Gender = GenderType.Male; Data.Gender = GenderType.Male;
break; break;
case "Female": case "Female":
Data.Gender = GenderType.Female; Data.Gender = GenderType.Female;
break; break;
default: default:
Data.Gender = GenderType.NotApplicable; Data.Gender = GenderType.NotApplicable;
break; break;
} }
var wnd = new GeneratedResultWindow(Data); var wnd = new GeneratedResultWindow(Data);
wnd.Show(); wnd.Show();
} }
private async void SaveContent(object sender, RoutedEventArgs e) private async void SaveContent(object sender, RoutedEventArgs e)
{ {
if (string.IsNullOrWhiteSpace(_currentFilePath)) if (string.IsNullOrWhiteSpace(_currentFilePath))
SaveContentAs(null, null); SaveContentAs(null, null);
else else
{ {
// have a path, attempt to save to it // have a path, attempt to save to it
if (!File.Exists(_currentFilePath)) if (!File.Exists(_currentFilePath))
{ {
switch ( switch (
await await
this.ShowMessageAsync("File Error", this.ShowMessageAsync("File Error",
"Current file missing, renamed, or deleted. Do you want to save as another name?", "Current file missing, renamed, or deleted. Do you want to save as another name?",
MessageDialogStyle.AffirmativeAndNegative)) MessageDialogStyle.AffirmativeAndNegative))
{ {
case MessageDialogResult.Negative: case MessageDialogResult.Negative:
_currentFilePath = null; _currentFilePath = null;
return; return;
case MessageDialogResult.Affirmative: case MessageDialogResult.Affirmative:
SaveContentAs(null, null); SaveContentAs(null, null);
return; return;
default: default:
throw new ArgumentOutOfRangeException(); throw new ArgumentOutOfRangeException();
} }
} }
var fs = File.Open(_currentFilePath, FileMode.Truncate); var fs = File.Open(_currentFilePath, FileMode.Truncate);
ProtoBuf.Serializer.Serialize(fs, Data); ProtoBuf.Serializer.Serialize(fs, Data);
} }
} }
private async void OpenContent(object sender, RoutedEventArgs e) private async void OpenContent(object sender, RoutedEventArgs e)
{ {
var dialog = new Microsoft.Win32.OpenFileDialog var dialog = new Microsoft.Win32.OpenFileDialog
{ {
AddExtension = true, AddExtension = true,
CheckFileExists = true, CheckFileExists = true,
CheckPathExists = true, CheckPathExists = true,
Filter = "Character Profiles (*.ss13prof)|*.ss13prof|All Files (*.*)|*.*" Filter = "Character Profiles (*.ss13prof)|*.ss13prof|All Files (*.*)|*.*"
}; };
if (!(dialog.ShowDialog() ?? false)) return; if (!(dialog.ShowDialog() ?? false)) return;
var fs = File.Open(dialog.FileName, FileMode.Open); var fs = File.Open(dialog.FileName, FileMode.Open);
try try
{ {
Data = ProtoBuf.Serializer.Deserialize<Record>(fs); Data = ProtoBuf.Serializer.Deserialize<Record>(fs);
_currentFilePath = dialog.FileName; _currentFilePath = dialog.FileName;
// So WPF updates bindings // So WPF updates bindings
DataContext = Data; DataContext = Data;
} }
catch (ProtoBuf.ProtoException) catch (ProtoBuf.ProtoException)
{ {
await this.ShowMessageAsync("Profile Error", "An error occurred during loading of your profile. You may have selected a file that is not a profile file, or the profile is corrupted."); await this.ShowMessageAsync("Profile Error", "An error occurred during loading of your profile. You may have selected a file that is not a profile file, or the profile is corrupted.");
} }
} }
private void SaveContentAs(object sender, RoutedEventArgs e) private void SaveContentAs(object sender, RoutedEventArgs e)
{ {
var dialog = new Microsoft.Win32.SaveFileDialog var dialog = new Microsoft.Win32.SaveFileDialog
{ {
AddExtension = true, AddExtension = true,
CheckPathExists = true, CheckPathExists = true,
Filter = "Character Profiles (*.ss13prof)|*.ss13prof|All Files (*.*)|*.*" Filter = "Character Profiles (*.ss13prof)|*.ss13prof|All Files (*.*)|*.*"
}; };
if (!(dialog.ShowDialog() ?? false)) return; if (!(dialog.ShowDialog() ?? false)) return;
var fs = File.Open(dialog.FileName, FileMode.Create); var fs = File.Open(dialog.FileName, FileMode.Create);
ProtoBuf.Serializer.Serialize(fs, Data); ProtoBuf.Serializer.Serialize(fs, Data);
_currentFilePath = dialog.FileName; _currentFilePath = dialog.FileName;
} }
private static IEnumerable<string> GetSpeciesOptions() => Enum.GetValues(typeof(SpeciesSubType)).Cast<SpeciesSubType>().Select(Utility.SubspeciesNiceName); private static IEnumerable<string> GetSpeciesOptions() => Enum.GetValues(typeof(SpeciesSubType)).Cast<SpeciesSubType>().Select(Utility.SubspeciesNiceName);
private static IEnumerable<string> GetSpeciesOptions(SpeciesType limitTo) => from item in Enum.GetValues(typeof(SpeciesSubType)).Cast<SpeciesSubType>() private static IEnumerable<string> GetSpeciesOptions(SpeciesType limitTo) => from item in Enum.GetValues(typeof(SpeciesSubType)).Cast<SpeciesSubType>()
let attr = item.GetAttributeOfType<SubspeciesMetaAttribute>() let attr = item.GetAttributeOfType<SubspeciesMetaAttribute>()
where attr != null && (attr.AssociatedSpecies == limitTo || attr.AssociatedSpecies == SpeciesType.None) where attr != null && (attr.AssociatedSpecies == limitTo || attr.AssociatedSpecies == SpeciesType.None)
select Utility.SubspeciesNiceName(item); select Utility.SubspeciesNiceName(item);
} }
} }

View file

@ -4,98 +4,98 @@ using System.Text;
namespace AuroraRecordGenerator namespace AuroraRecordGenerator
{ {
internal partial class RecordFormatter internal partial class RecordFormatter
{ {
private Record _targetRecord; private Record _targetRecord;
public RecordFormatter(Record r) public RecordFormatter(Record r)
{ {
_targetRecord = r; _targetRecord = r;
UpdateSplitRecords(); UpdateSplitRecords();
MakeCommonRecords(); MakeCommonRecords();
} }
private IList<string> _medicalPublicRecord; private IList<string> _medicalPublicRecord;
private IList<string> _medicalHistory; private IList<string> _medicalHistory;
private IList<string> _medicalNotes; private IList<string> _medicalNotes;
private IList<string> _medicalPsychHistory; private IList<string> _medicalPsychHistory;
private IList<string> _medicalPsychNotes; private IList<string> _medicalPsychNotes;
private IList<string> _medicalPrescriptions; private IList<string> _medicalPrescriptions;
private IList<string> _securityPublicRecord; private IList<string> _securityPublicRecord;
private IList<string> _securityRecords; private IList<string> _securityRecords;
private IList<string> _securityNotes; private IList<string> _securityNotes;
private IList<string> _employmentPublicRecord; private IList<string> _employmentPublicRecord;
private IList<string> _employmentExperience; private IList<string> _employmentExperience;
private IList<string> _employmentPreNtEmployment; private IList<string> _employmentPreNtEmployment;
private IList<string> _employmentFormalEducation; private IList<string> _employmentFormalEducation;
private IList<string> _employmentNtEmployment; private IList<string> _employmentNtEmployment;
private IList<string> _employmentSkills; private IList<string> _employmentSkills;
private void UpdateSplitRecords() private void UpdateSplitRecords()
{ {
if (_targetRecord == null) if (_targetRecord == null)
{ {
_targetRecord = new Record(); _targetRecord = new Record();
} }
// Medical // Medical
_medicalPublicRecord = _targetRecord.MedicalPublicRecord?.LineSplit(); _medicalPublicRecord = _targetRecord.MedicalPublicRecord?.LineSplit();
_medicalHistory = _targetRecord.MedicalHistory?.LineSplit(); _medicalHistory = _targetRecord.MedicalHistory?.LineSplit();
_medicalNotes = _targetRecord.MedicalNotes?.LineSplit(); _medicalNotes = _targetRecord.MedicalNotes?.LineSplit();
_medicalPsychHistory = _targetRecord.MedicalPsychHistory?.LineSplit(); _medicalPsychHistory = _targetRecord.MedicalPsychHistory?.LineSplit();
_medicalPsychNotes = _targetRecord.MedicalPsychNotes?.LineSplit(); _medicalPsychNotes = _targetRecord.MedicalPsychNotes?.LineSplit();
_medicalPrescriptions = _targetRecord.MedicalPrescriptions?.LineSplit(); _medicalPrescriptions = _targetRecord.MedicalPrescriptions?.LineSplit();
// security // security
_securityPublicRecord = _targetRecord.SecurityPublicRecord?.LineSplit(); _securityPublicRecord = _targetRecord.SecurityPublicRecord?.LineSplit();
_securityRecords = _targetRecord.SecurityRecords?.LineSplit(); _securityRecords = _targetRecord.SecurityRecords?.LineSplit();
_securityNotes = _targetRecord.SecurityNotes?.LineSplit(); _securityNotes = _targetRecord.SecurityNotes?.LineSplit();
// employment // employment
_employmentPublicRecord = _targetRecord.EmploymentPublicRecord?.LineSplit(); _employmentPublicRecord = _targetRecord.EmploymentPublicRecord?.LineSplit();
_employmentExperience = _targetRecord.EmploymentExperience?.LineSplit(); _employmentExperience = _targetRecord.EmploymentExperience?.LineSplit();
_employmentPreNtEmployment = _targetRecord.EmploymentPreNtEmployment?.LineSplit(); _employmentPreNtEmployment = _targetRecord.EmploymentPreNtEmployment?.LineSplit();
_employmentFormalEducation = _targetRecord.EmploymentFormalEducation?.LineSplit(); _employmentFormalEducation = _targetRecord.EmploymentFormalEducation?.LineSplit();
_employmentNtEmployment = _targetRecord.EmploymentNtEmploymentHistory?.LineSplit(); _employmentNtEmployment = _targetRecord.EmploymentNtEmploymentHistory?.LineSplit();
_employmentSkills = _targetRecord.EmploymentSkills?.LineSplit(); _employmentSkills = _targetRecord.EmploymentSkills?.LineSplit();
// flush the record cache so they're regenerated // flush the record cache so they're regenerated
_commonRecords = null; _commonRecords = null;
} }
public string EmploymentRecords => MakeEmploymentRecords(); public string EmploymentRecords => MakeEmploymentRecords();
public string MedicalRecords => MakeMedicalRecords(); public string MedicalRecords => MakeMedicalRecords();
public string SecurityRecords => MakeSecurityRecords(); public string SecurityRecords => MakeSecurityRecords();
private string _commonRecords; private string _commonRecords;
/// <summary> /// <summary>
/// Writes the <see cref="string"/> form of a record section to the specified <see cref="StringBuilder"/>, as long as there's entries to write. /// Writes the <see cref="string"/> form of a record section to the specified <see cref="StringBuilder"/>, as long as there's entries to write.
/// </summary> /// </summary>
/// <param name="builder">The <see cref="StringBuilder"/> to write to.</param> /// <param name="builder">The <see cref="StringBuilder"/> to write to.</param>
/// <param name="header">The title for the section.</param> /// <param name="header">The title for the section.</param>
/// <param name="entries">The entries of this section.</param> /// <param name="entries">The entries of this section.</param>
private static void WriteSectionIfAny(ref StringBuilder builder, string header, IList<string> entries) private static void WriteSectionIfAny(ref StringBuilder builder, string header, IList<string> entries)
{ {
if (entries == null || !entries.Any() || entries[0].Trim().Length == 0) if (entries == null || !entries.Any() || entries[0].Trim().Length == 0)
return; return;
builder.AppendLine(header); builder.AppendLine(header);
builder.AppendLine(entries.FormatAsList()); builder.AppendLine(entries.FormatAsList());
} }
private string MakeNameLine() private string MakeNameLine()
{ {
var builder = new StringBuilder("Name: "); var builder = new StringBuilder("Name: ");
builder.Append(_targetRecord.FirstName); builder.Append(_targetRecord.FirstName);
builder.Append(_targetRecord.MiddleName.SpaceIfValue()); builder.Append(_targetRecord.MiddleName.SpaceIfValue());
builder.Append($" {_targetRecord.LastName}"); builder.Append($" {_targetRecord.LastName}");
builder.Append(_targetRecord.NameSuffix.SpaceIfValue()); builder.Append(_targetRecord.NameSuffix.SpaceIfValue());
return builder.ToString(); return builder.ToString();
} }
private static void MakeMedicalNote(ref StringBuilder b, string s) => private static void MakeMedicalNote(ref StringBuilder b, string s) =>
b.AppendLine($" - {s}"); b.AppendLine($" - {s}");
} }
} }

View file

@ -4,209 +4,205 @@ using System.Text;
namespace AuroraRecordGenerator namespace AuroraRecordGenerator
{ {
internal partial class RecordFormatter internal partial class RecordFormatter
{ {
private void MakeCommonRecords() private void MakeCommonRecords()
{ {
var record = new StringBuilder(); var record = new StringBuilder();
record.AppendLine("/// PUBLIC RECORD ///"); record.AppendLine("/// PUBLIC RECORD ///");
record.AppendLine(MakeNameLine()); record.AppendLine(MakeNameLine());
record.AppendLine($"Date of Birth: {_targetRecord.BirthDate.ToString("MMMM")} {_targetRecord.BirthDate.Day.Ordinalize()}, {_targetRecord.BirthDate.Year}"); record.AppendLine($"Date of Birth: {_targetRecord.BirthDate.ToString("MMMM")} {_targetRecord.BirthDate.Day.Ordinalize()}, {_targetRecord.BirthDate.Year}");
record.AppendLine($"Species: {_targetRecord.Species.Humanize()}");// might fuck up the names record.AppendLine($"Species: {_targetRecord.Species.Humanize()}");// might fuck up the names
if (_targetRecord.Subspecies != SpeciesSubType.None) if (_targetRecord.Subspecies != SpeciesSubType.None)
{ {
record.AppendLine($"{_targetRecord.Subspecies.GetAttributeOfType<SubspeciesMetaAttribute>()?.FieldName ?? "Subspecies"}: {Utility.SubspeciesNiceName(_targetRecord.Subspecies)}"); record.AppendLine($"{_targetRecord.Subspecies.GetAttributeOfType<SubspeciesMetaAttribute>()?.FieldName ?? "Subspecies"}: {Utility.SubspeciesNiceName(_targetRecord.Subspecies)}");
} }
record.AppendLine(_targetRecord.Species.HasGender() record.AppendLine(_targetRecord.Species.HasGender()
? $"Gender: {_targetRecord.Gender.Humanize()}" ? $"Gender: {_targetRecord.Gender.Humanize()}"
: "Gender: Not Applicable."); : "Gender: Not Applicable.");
record.AppendLine($"Citizenship: {_targetRecord.Citizenship.IfEmpty("Not Specified.")}"); record.AppendLine($"Citizenship: {_targetRecord.Citizenship.IfEmpty("Not Specified.")}");
record.AppendLine($"Clearance Level: {_targetRecord.Clearance.IfEmpty("Not Specified")}"); record.AppendLine($"Clearance Level: {_targetRecord.Clearance.IfEmpty("Not Specified")}");
record.AppendLine($"Employed As: {_targetRecord.EmployedAs.IfEmpty("Assistant")}"); record.AppendLine($"Employed As: {_targetRecord.EmployedAs.IfEmpty("Assistant")}");
if (_targetRecord.CharHeight != null) if (_targetRecord.CharHeight != null)
record.AppendLine($"Height: {_targetRecord.CharHeight} cm ({Utility.CmToFeet(_targetRecord.CharHeight.Value)})"); record.AppendLine($"Height: {_targetRecord.CharHeight} cm ({Utility.CmToFeet(_targetRecord.CharHeight.Value)})");
if (_targetRecord.Weight != null) if (_targetRecord.Weight != null)
record.AppendLine($"Weight: {_targetRecord.Weight} kg ({Utility.KgToLb(_targetRecord.Weight ?? 0)} lb)"); record.AppendLine($"Weight: {_targetRecord.Weight} kg ({Utility.KgToLb(_targetRecord.Weight ?? 0)} lb)");
// Eye color // Eye color
var trimmedEye = _targetRecord.EyeColor.Trim(); var trimmedEye = _targetRecord.EyeColor.Trim();
record.AppendFormat("Eye Color: {0}\n", trimmedEye.Length > 0 ? trimmedEye : "Not Specified."); record.AppendFormat("Eye Color: {0}\n", trimmedEye.Length > 0 ? trimmedEye : "Not Specified.");
var bodyColor = _targetRecord.SkinColor.Trim(); var bodyColor = _targetRecord.SkinColor.Trim();
record.AppendFormat("Skin/Body Color: {0}\n", bodyColor.Length > 0 ? bodyColor : "Not Specified."); record.AppendFormat("Skin/Body Color: {0}\n", bodyColor.Length > 0 ? bodyColor : "Not Specified.");
var hairColor = _targetRecord.HairColor.Trim(); var hairColor = _targetRecord.HairColor.Trim();
record.AppendFormat("Hair Color: {0}\n", hairColor.Length > 0 ? hairColor : "Not Specified."); record.AppendFormat("Hair Color: {0}\n", hairColor.Length > 0 ? hairColor : "Not Specified.");
// identifying features // identifying features
var trimmedFeatures = _targetRecord.DistinguishingFeatures.Trim(); var trimmedFeatures = _targetRecord.DistinguishingFeatures.Trim();
record.Append("Distinguishing Features: "); record.Append("Distinguishing Features: ");
record.AppendLine(trimmedFeatures.Length > 0 ? trimmedFeatures : "None noted."); record.AppendLine(trimmedFeatures.Length > 0 ? trimmedFeatures : "None noted.");
record.AppendLine(); record.AppendLine();
// general notes // general notes
WriteSectionIfAny(ref record, WriteSectionIfAny(ref record,
"General Notes:", "General Notes:",
_employmentPublicRecord); _employmentPublicRecord);
WriteSectionIfAny(ref record, WriteSectionIfAny(ref record,
"Medical Notes:", "Medical Notes:",
_medicalPublicRecord); _medicalPublicRecord);
WriteSectionIfAny(ref record, WriteSectionIfAny(ref record,
"Security Notes:", "Security Notes:",
_securityPublicRecord); _securityPublicRecord);
_commonRecords = record.ToString(); _commonRecords = record.ToString();
} }
private string MakeEmploymentRecords() private string MakeEmploymentRecords()
{ {
var recordText = new StringBuilder(); var recordText = new StringBuilder();
if (_commonRecords.IsEmpty()) if (_commonRecords.IsEmpty())
MakeCommonRecords(); MakeCommonRecords();
recordText.Append(_commonRecords); recordText.Append(_commonRecords);
if (!_employmentExperience.Any() && if (!_employmentExperience.Any() &&
!_employmentFormalEducation.Any() && !_employmentFormalEducation.Any() &&
!_employmentNtEmployment.Any() && !_employmentNtEmployment.Any() &&
!_employmentPreNtEmployment.Any() && !_employmentPreNtEmployment.Any() &&
!_employmentPublicRecord.Any() && !_employmentPublicRecord.Any() &&
!_employmentSkills.Any()) !_employmentSkills.Any())
{ {
recordText.AppendLine("/// NO EMPLOYMENT RECORD FOUND ///"); recordText.AppendLine("/// NO EMPLOYMENT RECORD FOUND ///");
} }
else else
{ {
recordText.AppendLine("/// EMPLOYMENT RECORD ///"); recordText.AppendLine("/// EMPLOYMENT RECORD ///");
recordText.AppendLine(); recordText.AppendLine();
WriteSectionIfAny(ref recordText, WriteSectionIfAny(ref recordText,
"Experience:", "Experience:",
_employmentExperience); _employmentExperience);
WriteSectionIfAny(ref recordText, WriteSectionIfAny(ref recordText,
"Formal Education History:", "Formal Education History:",
_employmentFormalEducation); _employmentFormalEducation);
WriteSectionIfAny(ref recordText, WriteSectionIfAny(ref recordText,
"Pre-NanoTrasen Employment History:", "Pre-NanoTrasen Employment History:",
_employmentPreNtEmployment); _employmentPreNtEmployment);
WriteSectionIfAny(ref recordText, WriteSectionIfAny(ref recordText,
"NanoTrasen Employment History:", "NanoTrasen Employment History:",
_employmentNtEmployment); _employmentNtEmployment);
WriteSectionIfAny(ref recordText, WriteSectionIfAny(ref recordText,
"Trained in the following:", "Trained in the following:",
_employmentSkills); _employmentSkills);
} }
return recordText.ToString(); return recordText.ToString();
} }
private string MakeMedicalRecords() private string MakeMedicalRecords()
{ {
var recordText = new StringBuilder(); var recordText = new StringBuilder();
if (_commonRecords.IsEmpty()) if (_commonRecords.IsEmpty())
MakeCommonRecords(); MakeCommonRecords();
recordText.Append(_commonRecords); recordText.Append(_commonRecords);
// TODO: make this less horrible // TODO: make this less horrible
if (!_medicalHistory.Any() && if (!_medicalHistory.Any() &&
!_medicalNotes.Any() && !_medicalNotes.Any() &&
!_medicalPsychHistory.Any() && !_medicalPsychHistory.Any() &&
!_medicalPsychNotes.Any() && !_medicalPsychNotes.Any() &&
!_medicalPrescriptions.Any() && !_medicalPrescriptions.Any() &&
!_targetRecord.NoBorg && !_targetRecord.NoBorg &&
!_targetRecord.NoClone && !_targetRecord.NoProsthetic &&
!_targetRecord.NoProsthetic && !_targetRecord.NoRevive)
!_targetRecord.NoRevive) {
{ recordText.AppendLine("/// NO MEDICAL RECORD FOUND ///");
recordText.AppendLine("/// NO MEDICAL RECORD FOUND ///"); }
} else
else {
{ recordText.AppendLine("/// MEDICAL RECORD ///");
recordText.AppendLine("/// MEDICAL RECORD ///"); recordText.AppendLine();
recordText.AppendLine();
recordText.AppendLine( recordText.AppendLine(
" The following information is protected by doctor-patient confidentiality laws. Do not release without patient's consent.\n"); " The following information is protected by doctor-patient confidentiality laws. Do not release without patient's consent.\n");
if (_targetRecord.NoBorg || _targetRecord.NoClone || _targetRecord.NoProsthetic || _targetRecord.NoRevive) if (_targetRecord.NoBorg || _targetRecord.NoProsthetic || _targetRecord.NoRevive)
{ {
recordText.AppendLine("IMPORTANT NOTES:"); recordText.AppendLine("IMPORTANT NOTES:");
if (_targetRecord.NoBorg) if (_targetRecord.NoBorg)
MakeMedicalNote(ref recordText, "DO NOT BORGIFY"); MakeMedicalNote(ref recordText, "DO NOT BORGIFY");
if (_targetRecord.NoClone) if (_targetRecord.NoProsthetic)
MakeMedicalNote(ref recordText, "DO NOT CLONE"); MakeMedicalNote(ref recordText, "DO NOT INSTALL PROSTHETICS");
if (_targetRecord.NoProsthetic) if (_targetRecord.NoRevive)
MakeMedicalNote(ref recordText, "DO NOT INSTALL PROSTHETICS"); MakeMedicalNote(ref recordText, "DO NOT REVIVE");
if (_targetRecord.NoRevive) recordText.AppendLine();
MakeMedicalNote(ref recordText, "DO NOT REVIVE"); }
recordText.AppendLine(); WriteSectionIfAny(ref recordText,
} "Notes:",
_medicalNotes);
WriteSectionIfAny(ref recordText, WriteSectionIfAny(ref recordText,
"Notes:", "Medical History:",
_medicalNotes); _medicalHistory);
WriteSectionIfAny(ref recordText, WriteSectionIfAny(ref recordText,
"Medical History:", "Psychiatric Notes:",
_medicalHistory); _medicalPsychNotes);
WriteSectionIfAny(ref recordText, WriteSectionIfAny(ref recordText,
"Psychiatric Notes:", "Psychiatric History:",
_medicalPsychNotes); _medicalPsychHistory);
WriteSectionIfAny(ref recordText, WriteSectionIfAny(ref recordText,
"Psychiatric History:", "Prescriptions:",
_medicalPsychHistory); _medicalPrescriptions);
}
WriteSectionIfAny(ref recordText, return recordText.ToString();
"Prescriptions:", }
_medicalPrescriptions);
}
return recordText.ToString(); private string MakeSecurityRecords()
} {
var recordText = new StringBuilder();
if (_commonRecords.IsEmpty())
MakeCommonRecords();
private string MakeSecurityRecords() recordText.Append(_commonRecords);
{
var recordText = new StringBuilder();
if (_commonRecords.IsEmpty())
MakeCommonRecords();
recordText.Append(_commonRecords); if (!_securityRecords.Any() && !_securityNotes.Any())
{
recordText.AppendLine("/// NO SECURITY RECORD FOUND ///");
}
else
{
recordText.AppendLine("/// SECURITY RECORD ///");
recordText.AppendLine();
if (!_securityRecords.Any() && !_securityNotes.Any()) WriteSectionIfAny(ref recordText,
{ "Notes:",
recordText.AppendLine("/// NO SECURITY RECORD FOUND ///"); _securityNotes);
}
else
{
recordText.AppendLine("/// SECURITY RECORD ///");
recordText.AppendLine();
WriteSectionIfAny(ref recordText, WriteSectionIfAny(ref recordText,
"Notes:", "Record:",
_securityNotes); _securityRecords);
}
WriteSectionIfAny(ref recordText, return recordText.ToString();
"Record:", }
_securityRecords); }
}
return recordText.ToString();
}
}
} }

View file

@ -3,114 +3,127 @@ using System;
namespace AuroraRecordGenerator namespace AuroraRecordGenerator
{ {
[ProtoContract] [ProtoContract]
public enum SpeciesType public enum SpeciesType
{ {
[ProtoEnum] [ProtoEnum]
None = 0, None = 0,
[ProtoEnum] [ProtoEnum]
Human, Human,
[ProtoEnum] [ProtoEnum]
Skrell, Skrell,
[ProtoEnum] [ProtoEnum]
Tajara, Tajara,
[ProtoEnum] [ProtoEnum]
Unathi, Unathi,
[ProtoEnum] [ProtoEnum]
Vaurca, Vaurca,
[ProtoEnum] [ProtoEnum]
Diona, Diona,
[ProtoEnum] [ProtoEnum]
IPC IPC
} }
[ProtoContract] [ProtoContract]
public enum SpeciesSubType public enum SpeciesSubType
{ {
[ProtoEnum, SubspeciesMeta(SpeciesType.None, "N/A")] [ProtoEnum, SubspeciesMeta(SpeciesType.None, "N/A")]
None = 0, None = 0,
[ProtoEnum, SubspeciesMeta(SpeciesType.Tajara, "M'sai", "Ethnicity")] // SKRELL VARIANTS
MsaiTajara, [ProtoEnum, SubspeciesMeta(SpeciesType.Skrell, "Axiori", "Ethnicity")]
SkrellAxiori,
[ProtoEnum, SubspeciesMeta(SpeciesType.Skrell, "Xiialt", "Ethnicity")]
SkrellXiialt,
[ProtoEnum, SubspeciesMeta(SpeciesType.Skrell, "Xiiori", "Ethnicity")]
SkrellXiiori,
[ProtoEnum, SubspeciesMeta(SpeciesType.Tajara, "Zhan-Khazan", "Ethnicity")] // TAJARA VARIANTS
ZhanTajara, [ProtoEnum, SubspeciesMeta(SpeciesType.Tajara, "Hharar", "Ethnicity")]
TajaraHharar,
[ProtoEnum, SubspeciesMeta(SpeciesType.Tajara, "Zhan-Khazan", "Ethnicity")]
TajaraZhan,
[ProtoEnum, SubspeciesMeta(SpeciesType.Tajara, "Njarir'Akhran", "Ethnicity")]
TajaraNjarir,
[ProtoEnum, SubspeciesMeta(SpeciesType.Tajara, "M'sai", "Ethnicity")]
TajaraMsai,
[ProtoEnum, SubspeciesMeta(SpeciesType.Vaurca, "Type A (Worker)", "Classification")] // VAURCA VARIANTS
VaurcaWorker, [ProtoEnum, SubspeciesMeta(SpeciesType.Vaurca, "Type A (Worker)", "Classification")]
VaurcaWorker,
[ProtoEnum, SubspeciesMeta(SpeciesType.Vaurca, "Type B (Warrior)", "Classification")] [ProtoEnum, SubspeciesMeta(SpeciesType.Vaurca, "Type B (Warrior)", "Classification")]
VaurcaWarrior, VaurcaWarrior,
[ProtoEnum, SubspeciesMeta(SpeciesType.Vaurca, "Type C (Breeder)", "Classification")]
[ProtoEnum, SubspeciesMeta(SpeciesType.IPC, "Shell", "Model")] VaurcaBreeder,
IpcShell, [ProtoEnum, SubspeciesMeta(SpeciesType.Vaurca, "Type E (Bulwark)", "Classification")]
VaurcaBulwark,
[ProtoEnum, SubspeciesMeta(SpeciesType.IPC, "Hephaestus G1 Heavy", "Model")]
IpcG1Industrial,
[ProtoEnum, SubspeciesMeta(SpeciesType.IPC, "Hephaestus G2 Heavy", "Model")]
IpcG2Industrial,
[ProtoEnum, SubspeciesMeta(SpeciesType.IPC, "Bishop Accessory", "Model")]
IpcFancy,
[ProtoEnum, SubspeciesMeta(SpeciesType.IPC, "Zeng-Hu Mobility", "Model")]
IpcMedsci,
// IPC VARIANTS
[ProtoEnum, SubspeciesMeta(SpeciesType.IPC, "Baseline", "Model")]
IpcBaseline,
[ProtoEnum, SubspeciesMeta(SpeciesType.IPC, "Shell", "Model")] [ProtoEnum, SubspeciesMeta(SpeciesType.IPC, "Shell", "Model")]
IpcHumanoid, IpcShell,
[ProtoEnum, SubspeciesMeta(SpeciesType.IPC, "Hephaestus G1 Industrial", "Model")]
IpcG1,
[ProtoEnum, SubspeciesMeta(SpeciesType.IPC, "Hephaestus G2 Industrial", "Model")]
IpcG2,
[ProtoEnum, SubspeciesMeta(SpeciesType.IPC, "Xion Industrial", "Model")] [ProtoEnum, SubspeciesMeta(SpeciesType.IPC, "Xion Industrial", "Model")]
IpcHeavy, IpcXion,
[ProtoEnum, SubspeciesMeta(SpeciesType.IPC, "Zeng-Hu Mobility", "Model")]
IpcZengHu,
[ProtoEnum, SubspeciesMeta(SpeciesType.IPC, "Bishop Accessory", "Model")]
IpcBishop,
// UNATHI VARIANTS
[ProtoEnum, SubspeciesMeta(SpeciesType.Unathi, "Aut'akh", "Variant")] [ProtoEnum, SubspeciesMeta(SpeciesType.Unathi, "Aut'akh", "Variant")]
UnathiRobot, UnathiAutakh,
// HUMAN VARIANTS
[ProtoEnum, SubspeciesMeta(SpeciesType.Human, "Offworlder", "Variant")] [ProtoEnum, SubspeciesMeta(SpeciesType.Human, "Offworlder", "Variant")]
HumanOffworld HumanOffworld
} }
[ProtoContract] [ProtoContract]
public enum GenderType public enum GenderType
{ {
[ProtoEnum] [ProtoEnum]
NotApplicable = 0, NotApplicable = 0,
[ProtoEnum] [ProtoEnum]
Male, Male,
[ProtoEnum] [ProtoEnum]
Female Female
} }
public static class Info public static class Info
{ {
/// <summary> /// <summary>
/// The current in-character date. /// The current in-character date.
/// </summary> /// </summary>
public static DateTime IcDate => new DateTime(DateTime.Now.Year + 442, public static DateTime IcDate => new DateTime(DateTime.Now.Year + 442,
DateTime.Now.Month, DateTime.Now.Month,
DateTime.Now.Day); DateTime.Now.Day);
} }
[AttributeUsage(AttributeTargets.Field)] [AttributeUsage(AttributeTargets.Field)]
public class SubspeciesMetaAttribute : Attribute public class SubspeciesMetaAttribute : Attribute
{ {
public SpeciesType AssociatedSpecies {get; private set;} public SpeciesType AssociatedSpecies { get; private set; }
public string NiceName { get; private set; } public string NiceName { get; private set; }
public string FieldName { get; private set; } public string FieldName { get; private set; }
public SubspeciesMetaAttribute(SpeciesType associatedType, string nicename, string fieldname = "Subspecies") public SubspeciesMetaAttribute(SpeciesType associatedType, string nicename, string fieldname = "Subspecies")
{ {
AssociatedSpecies = associatedType; AssociatedSpecies = associatedType;
NiceName = nicename; NiceName = nicename;
FieldName = fieldname; FieldName = fieldname;
} }
} }
} }

View file

@ -6,91 +6,91 @@ using System.Text;
namespace AuroraRecordGenerator namespace AuroraRecordGenerator
{ {
public static class Utility public static class Utility
{ {
public static IList<string> LineSplit(this string source) => public static IList<string> LineSplit(this string source) =>
source.Split('\n').Where(item => item.Trim().Length != 0).ToList(); source.Split('\n').Where(item => item.Trim().Length != 0).ToList();
public static string CmToFeet(double cm) public static string CmToFeet(double cm)
{ {
var feet = Math.Floor(cm * 0.0328084); var feet = Math.Floor(cm * 0.0328084);
var inches = Math.Floor(cm * 0.39370079); // Isn't imperial a lovely system? var inches = Math.Floor(cm * 0.39370079); // Isn't imperial a lovely system?
inches -= feet * 12; inches -= feet * 12;
return $"{feet}'{inches}\""; return $"{feet}'{inches}\"";
} }
/// <summary> /// <summary>
/// Converts a weight in Kilograms to Pounds. /// Converts a weight in Kilograms to Pounds.
/// </summary> /// </summary>
/// <param name="kg">The weight in kilograms.</param> /// <param name="kg">The weight in kilograms.</param>
/// <returns>The weight converted to pounds.</returns> /// <returns>The weight converted to pounds.</returns>
public static double KgToLb(double kg) => Math.Round(kg * 2.2046, 2); public static double KgToLb(double kg) => Math.Round(kg * 2.2046, 2);
/// <summary> /// <summary>
/// Returns <paramref name="val"/> and a trailing space if val is not whitespace, <see cref="string.Empty"/> otherwise. /// Returns <paramref name="val"/> and a trailing space if val is not whitespace, <see cref="string.Empty"/> otherwise.
/// </summary> /// </summary>
/// <param name="val"></param> /// <param name="val"></param>
/// <returns></returns> /// <returns></returns>
public static string SpaceIfValue(this string val) => string.IsNullOrWhiteSpace(val) ? string.Empty : $" {val} "; public static string SpaceIfValue(this string val) => string.IsNullOrWhiteSpace(val) ? string.Empty : $" {val} ";
public static string IfEmpty(this string target, string fallback) => public static string IfEmpty(this string target, string fallback) =>
target.IsEmpty() ? fallback : target; target.IsEmpty() ? fallback : target;
public static bool IsEmpty(this string val) => string.IsNullOrWhiteSpace(val); public static bool IsEmpty(this string val) => string.IsNullOrWhiteSpace(val);
public static string FormatAsList(this IEnumerable<string> target) => public static string FormatAsList(this IEnumerable<string> target) =>
target.Aggregate(new StringBuilder(), (b, s) => b.AppendLine($" - {s.Trim()}")).ToString(); target.Aggregate(new StringBuilder(), (b, s) => b.AppendLine($" - {s.Trim()}")).ToString();
public static string Repeat(this string target, int repeatNum) public static string Repeat(this string target, int repeatNum)
{ {
var builder = new StringBuilder(target.Length * repeatNum); var builder = new StringBuilder(target.Length * repeatNum);
for (var i = 0; i < repeatNum; i++) for (var i = 0; i < repeatNum; i++)
builder.Append(target); builder.Append(target);
return builder.ToString(); return builder.ToString();
} }
/// <summary> /// <summary>
/// Returns true if the specified species has gender. /// Returns true if the specified species has gender.
/// </summary> /// </summary>
/// <param name="species"></param> /// <param name="species"></param>
/// <returns></returns> /// <returns></returns>
public static bool HasGender(this SpeciesType species) => public static bool HasGender(this SpeciesType species) =>
!(species == SpeciesType.Diona || species == SpeciesType.IPC || species == SpeciesType.Vaurca); !(species == SpeciesType.Diona || species == SpeciesType.IPC || species == SpeciesType.Vaurca);
public static string SubspeciesNiceName(SpeciesSubType species) public static string SubspeciesNiceName(SpeciesSubType species)
{ {
var attr = species.GetAttributeOfType<SubspeciesMetaAttribute>(); var attr = species.GetAttributeOfType<SubspeciesMetaAttribute>();
return attr?.NiceName ?? Enum.GetName(typeof(SpeciesSubType), species); return attr?.NiceName ?? Enum.GetName(typeof(SpeciesSubType), species);
} }
public static SpeciesSubType SubspeciesNiceNameToEnum(string nicename) public static SpeciesSubType SubspeciesNiceNameToEnum(string nicename)
{ {
return (from item in Enum.GetValues(typeof(SpeciesSubType)).Cast<SpeciesSubType>() return (from item in Enum.GetValues(typeof(SpeciesSubType)).Cast<SpeciesSubType>()
let attr = item.GetAttributeOfType<SubspeciesMetaAttribute>() let attr = item.GetAttributeOfType<SubspeciesMetaAttribute>()
where attr != null && attr.NiceName == nicename where attr != null && attr.NiceName == nicename
select item).FirstOrDefault(); select item).FirstOrDefault();
} }
public static Version GetVersion() => Assembly.GetExecutingAssembly().GetName().Version; public static Version GetVersion() => Assembly.GetExecutingAssembly().GetName().Version;
} }
// From https://stackoverflow.com/questions/1799370/getting-attributes-of-enums-value // From https://stackoverflow.com/questions/1799370/getting-attributes-of-enums-value
public static class EnumHelper public static class EnumHelper
{ {
/// <summary> /// <summary>
/// Gets an attribute on an enum field value /// Gets an attribute on an enum field value
/// </summary> /// </summary>
/// <typeparam name="T">The type of the attribute you want to retrieve</typeparam> /// <typeparam name="T">The type of the attribute you want to retrieve</typeparam>
/// <param name="enumVal">The enum value</param> /// <param name="enumVal">The enum value</param>
/// <returns>The attribute of type T that exists on the enum value</returns> /// <returns>The attribute of type T that exists on the enum value</returns>
/// <example>string desc = myEnumVariable.GetAttributeOfType<DescriptionAttribute>().Description;</example> /// <example>string desc = myEnumVariable.GetAttributeOfType<DescriptionAttribute>().Description;</example>
public static T GetAttributeOfType<T>(this Enum enumVal) where T : Attribute public static T GetAttributeOfType<T>(this Enum enumVal) where T : Attribute
{ {
var type = enumVal.GetType(); var type = enumVal.GetType();
var memInfo = type.GetMember(enumVal.ToString()); var memInfo = type.GetMember(enumVal.ToString());
var attributes = memInfo[0].GetCustomAttributes(typeof(T), false); var attributes = memInfo[0].GetCustomAttributes(typeof(T), false);
return attributes.Length > 0 ? (T)attributes[0] : null; return attributes.Length > 0 ? (T)attributes[0] : null;
} }
} }
} }