Archived
1
0

implement combat zones and combat bonds

This commit is contained in:
Florian Stinglmayr 2021-09-28 14:14:16 +02:00
parent fcf1802d22
commit 0fdd3e2c9a
7 changed files with 212 additions and 3 deletions

View File

@ -1,5 +1,30 @@
namespace NonaBGS.BGS {
public class CombatZone {
private int level;
using System;
namespace NonaBGS.BGS {
public class CombatZone : LogEntry, IComparable {
public string Type { get; set; }
public string Grade { get; set; }
public int Amount { get; set; }
public int CompareTo(object obj) {
if (obj.GetType() != typeof(CombatZone)) {
return -1;
}
var b = obj as CombatZone;
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() {
return string.Format("Won {0} x {1} {2} Combat Zone(s)", Amount, Type, Grade);
}
}
}

View File

@ -57,6 +57,26 @@ namespace NonaBGS.BGS {
return string.Format("Sold {0} CR worth of Micro Resources\n", sum);
}
private string BuildKillBonds(Objective objective) {
StringBuilder builder = new StringBuilder();
FactionKillBonds[] bonds = objective.LogEntries
.OfType<FactionKillBonds>()
.ToArray()
;
if (bonds == null || bonds.Length == 0) {
return builder.ToString();
}
foreach (FactionKillBonds bond in bonds) {
builder.AppendFormat("{0}\n", bond.ToString());
}
builder.AppendFormat("\n");
return builder.ToString();
}
private string BuildVouchers(Objective objective) {
StringBuilder builder = new StringBuilder();
var missions = from entries in objective.LogEntries
@ -126,6 +146,26 @@ namespace NonaBGS.BGS {
return output.ToString();
}
private string BuildCombatZones(Objective objective) {
StringBuilder builder = new StringBuilder();
CombatZone[] zones = objective.LogEntries
.OfType<CombatZone>()
.ToArray()
;
if (zones == null || zones.Length == 0) {
return builder.ToString();
}
foreach (CombatZone zone in zones) {
builder.AppendFormat("{0}\n", zone.ToString());
}
builder.Append("\n");
return builder.ToString();
}
public string GenerateDiscordLog(Report report) {
StringBuilder log = new StringBuilder();
@ -147,6 +187,12 @@ namespace NonaBGS.BGS {
var vouchers = BuildVouchers(objective);
entries.Append(vouchers);
var zones = BuildCombatZones(objective);
entries.Append(zones);
var bonds = BuildKillBonds(objective);
entries.Append(bonds);
var carto = BuildCartoGraphics(objective);
entries.Append(carto);

48
CombatZoneDialog.xaml Normal file
View File

@ -0,0 +1,48 @@
<Window x:Class="NonaBGS.CombatZoneDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:NonaBGS"
mc:Ignorable="d"
Title="Add Combat Zone Wins" Height="150" Width="370" WindowStartupLocation="CenterOwner">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<GroupBox Header="Add Combat Zone" Grid.Row="0" Grid.Column="0" Width="Auto">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<ComboBox x:Name="type" Grid.Column="0" VerticalAlignment="Top" Width="Auto" IsReadOnly="True" Height="23" Margin="5" SelectedIndex="0">
<ComboBoxItem Content="Space"/>
<ComboBoxItem Content="On Foot"/>
</ComboBox>
<ComboBox x:Name="grade" Grid.Column="1" VerticalAlignment="Top" IsReadOnly="True" Margin="5" Height="23" Width="Auto" SelectedIndex="0">
<ComboBoxItem Content="Low"/>
<ComboBoxItem Content="Medium"/>
<ComboBoxItem Content="High"/>
</ComboBox>
<TextBox x:Name="amount" Grid.Column="2" Height="23" TextWrapping="Wrap" Text="1" VerticalAlignment="Top" Width="Auto" Margin="5" HorizontalContentAlignment="Right"/>
</Grid>
</GroupBox>
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Button x:Name="Accept" Content="Accept" HorizontalAlignment="Right" Grid.Column="0" Grid.Row="1" VerticalAlignment="Top" Width="75" Margin="5" IsDefault="True" Click="Accept_Click"/>
<Button x:Name="Cancel" Content="Cancel" HorizontalAlignment="Right" Grid.Column="1" Grid.Row="1" VerticalAlignment="Top" Width="75" Margin="5" IsCancel="True" Click="Cancel_Click"/>
</Grid>
</Grid>
</Window>

47
CombatZoneDialog.xaml.cs Normal file
View File

@ -0,0 +1,47 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Forms;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace NonaBGS {
/// <summary>
/// Interaction logic for CombatZoneDialog.xaml
/// </summary>
public partial class CombatZoneDialog : Window {
public CombatZoneDialog() {
InitializeComponent();
}
public string Type => (type.SelectedItem as ComboBoxItem).Content.ToString();
public string Grade => (grade.SelectedItem as ComboBoxItem).Content.ToString();
public int Amount {
get {
try {
return int.Parse(amount.Text);
} catch (Exception) {
return 1;
}
}
}
private void Accept_Click(object sender, RoutedEventArgs e) {
DialogResult = true;
Close();
}
private void Cancel_Click(object sender, RoutedEventArgs e) {
DialogResult = false;
Close();
}
}
}

View File

@ -37,6 +37,8 @@
<abc:AutoCompleteTextBox x:Name="faction" Margin="0" VerticalAlignment="Center" MinWidth="120" MinHeight="22" KeyDown="Filter_KeyDown"/>
<Separator Height="26.2857142857143" Margin="0" VerticalAlignment="Top"/>
<Button x:Name="AddFilter" Content="Add Objective" VerticalAlignment="Stretch" Click="AddFilter_Click" Margin="0,0,0,0.286" RenderTransformOrigin="0.5,0.505"/>
<Separator Height="26.2857142857143" Margin="0" VerticalAlignment="Top"/>
<Button x:Name="AddCombatZone" Content="Add Combat Zone Win" VerticalAlignment="Stretch" Margin="0,0,0,0.286" RenderTransformOrigin="0.5,0.505" Click="AddCombatZone_Click"/>
</ToolBar>
<ToolBar VerticalAlignment="Top" Grid.Row="1" Width="Auto" Margin="0,0,0,0" Height="Auto" Grid.ColumnSpan="3" HorizontalAlignment="Left">
<Button x:Name="ParseJournal" Content="Parse Journal" VerticalAlignment="Center" Click="ParseJournal_Click" HorizontalAlignment="Center"/>

View File

@ -241,5 +241,39 @@ namespace NonaBGS {
dialog.StartDownload();
dialog.ShowDialog();
}
private void AddCombatZone_Click(object sender, RoutedEventArgs e) {
if (entries.SelectedItem == null) {
return;
}
TreeViewItem item = entries.SelectedItem as TreeViewItem;
var obj = item.Tag;
if (obj.GetType() != typeof(Objective)) {
return;
}
Objective objective = obj as Objective;
CombatZoneDialog dialog = new CombatZoneDialog() { Owner = this };
if (!(dialog.ShowDialog() ?? false)) {
return;
}
CombatZone zone = new CombatZone();
zone.Faction = objective.Faction;
zone.System = objective.System;
zone.Station = objective.Station;
zone.Grade = dialog.Grade;
zone.Type = dialog.Type;
zone.Amount = dialog.Amount;
objective.LogEntries.Add(zone);
RefreshObjectives();
}
}
}

View File

@ -87,6 +87,9 @@
<Compile Include="ProgressDialog.xaml.cs">
<DependentUpon>ProgressDialog.xaml</DependentUpon>
</Compile>
<Compile Include="CombatZoneDialog.xaml.cs">
<DependentUpon>CombatZoneDialog.xaml</DependentUpon>
</Compile>
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
@ -110,6 +113,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="CombatZoneDialog.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs">