Skip to content

Commit eae1760

Browse files
committed
[VEX-84]: Added Ability to generate Agent Contract Goals + Fixed Streaks
1 parent bf20e02 commit eae1760

File tree

11 files changed

+236
-3
lines changed

11 files changed

+236
-3
lines changed

VexTrack/Core/CalcUtil.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,23 @@ public static int CalcMaxForLevel(int level)
4040
{
4141
return Constants.Level2Offset + (level * Constants.XPPerLevel);
4242
}
43+
44+
public static int CalcMaxForTier(int tier)
45+
{
46+
switch(tier)
47+
{
48+
case 1: return 20000;
49+
case 2: return 30000;
50+
case 3: return 40000;
51+
case 4: return 50000;
52+
case 5: return 60000;
53+
case 6: return 75000;
54+
case 7: return 100000;
55+
case 8: return 150000;
56+
case 9: return 200000;
57+
case 10: return 250000;
58+
default: return 0;
59+
}
60+
}
4361
}
4462
}

VexTrack/Core/Constants.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ static class Constants
2121

2222
public static readonly int BattlepassLevels = 50;
2323
public static readonly int EpilogueLevels = 5;
24+
public static readonly int AgentTiers = 10;
2425

2526
public static readonly int XPPerLevel = 750;
2627
public static readonly int XPPerEpilogueLevel = 36500;

VexTrack/Core/StreakDataCalc.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,13 @@ public static int CalcCurrentStreak(bool epilogue)
1818
if(!epilogue) targetStatus.Add(Constants.StreakStatusOrder.Keys.ElementAt(1));
1919

2020
DateTimeOffset today = DateTimeOffset.Now.ToLocalTime().Date;
21+
DateTimeOffset prevDate = DateTimeOffset.FromUnixTimeSeconds(TrackingDataHelper.Data.Streak[0].Date);
22+
2123
foreach(StreakEntry streakEntry in TrackingDataHelper.Data.Streak)
2224
{
25+
if ((prevDate - DateTimeOffset.FromUnixTimeSeconds(streakEntry.Date)).Days > 1) break;
26+
prevDate = DateTimeOffset.FromUnixTimeSeconds(streakEntry.Date);
27+
2328
if (streakEntry.Date == today.ToUnixTimeSeconds() && !targetStatus.Contains(streakEntry.Status)) continue;
2429
if (!targetStatus.Contains(streakEntry.Status)) break;
2530
streak++;

VexTrack/Core/TrackingData.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ public static void LoadData()
324324
if (goalGroup["goals"] == null)
325325
{
326326
source = jo["goals"];
327-
goalGroups.Add(new GoalGroup(Guid.NewGuid().ToString(), "No Group", new List<Goal>()));
327+
goalGroups.Add(new GoalGroup(Constants.DefaultGroupUUID, "No Group", new List<Goal>()));
328328
convertToGrouped = true;
329329
}
330330

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Globalization;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
using System.Windows;
8+
using System.Windows.Data;
9+
using VexTrack.Core;
10+
11+
namespace VexTrack.MVVM.Converter
12+
{
13+
class IsDefaultGroupToVisibilityConverter : IValueConverter
14+
{
15+
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
16+
{
17+
string val = value as string;
18+
19+
if (val == Constants.DefaultGroupUUID) return Visibility.Collapsed;
20+
return Visibility.Visible;
21+
}
22+
23+
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
24+
{
25+
throw new NotImplementedException();
26+
}
27+
}
28+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Globalization;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
using System.Windows.Controls;
8+
9+
namespace VexTrack.MVVM.Validation
10+
{
11+
public class TierValidationRule : ValidationRule
12+
{
13+
public override ValidationResult Validate(object value, CultureInfo cultureInfo)
14+
{
15+
string strValue = Convert.ToString(value);
16+
17+
if (string.IsNullOrEmpty(strValue))
18+
return new ValidationResult(false, $"This field cannot be empty, last known value will be used");
19+
bool canConvert = false;
20+
21+
int val;
22+
canConvert = int.TryParse(strValue, out val);
23+
if (!canConvert) return new ValidationResult(false, $"Input must be a number, last known value will be used");
24+
25+
if (val < 1) return new ValidationResult(false, $"Input cannot be less than 1");
26+
if (val > 10) return new ValidationResult(false, $"Input cannot be larger than 10");
27+
return new ValidationResult(true, null);
28+
}
29+
}
30+
}

VexTrack/MVVM/View/GoalView.xaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
<UserControl.Resources>
1313
<conv:StatusToBadgeConverter x:Key="statusToBadgeConv"/>
14+
<conv:IsDefaultGroupToVisibilityConverter x:Key="IsDefaultToVisibleConv"/>
1415
</UserControl.Resources>
1516

1617
<Grid>
@@ -96,6 +97,7 @@
9697
HorizontalAlignment="Right"
9798
VerticalAlignment="Center"
9899
Margin="0, 0, 16, 0"
100+
Visibility="{Binding UUID, Converter={StaticResource IsDefaultToVisibleConv}}"
99101
Style="{DynamicResource SmallDeleteButtonTheme}"
100102
Command="{Binding RelativeSource={RelativeSource AncestorType=UserControl, Mode=FindAncestor}, Path=DataContext.OnGroupDeleteClicked}"
101103
CommandParameter="{Binding UUID}"/>
@@ -105,6 +107,7 @@
105107
HorizontalAlignment="Right"
106108
VerticalAlignment="Center"
107109
Margin="0, 0, 52, 0"
110+
Visibility="{Binding UUID, Converter={StaticResource IsDefaultToVisibleConv}}"
108111
Style="{DynamicResource SmallEditButtonTheme}"
109112
Command="{Binding RelativeSource={RelativeSource AncestorType=UserControl, Mode=FindAncestor}, Path=DataContext.OnGroupEditClicked}"
110113
CommandParameter="{Binding UUID}"/>

VexTrack/MVVM/View/Popups/DataInitPopup.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
Foreground="{DynamicResource Foreground}"
8383
Margin="0, 0, 0, 8"/>
8484

85-
<TextBlock Text="Collected XP in Current Level"
85+
<TextBlock Text="Collected XP in Active Level"
8686
Grid.Row="4"
8787
Grid.Column="0"
8888
FontSize="14"

VexTrack/MVVM/View/Popups/EditableGoalGroupPopup.xaml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99
mc:Ignorable="d"
1010
d:DesignHeight="812" d:DesignWidth="872">
1111

12+
<UserControl.Resources>
13+
<BooleanToVisibilityConverter x:Key="BoolToVisibileConv"/>
14+
<conv:InvertedBooleanToVisibilityConverter x:Key="InvBoolToVisibileConv"/>
15+
</UserControl.Resources>
16+
1217
<Grid Height="Auto"
1318
Width="640"
1419
VerticalAlignment="Center">
@@ -42,6 +47,8 @@
4247
<RowDefinition Height="Auto"/>
4348
<RowDefinition Height="30"/>
4449
<RowDefinition Height="Auto"/>
50+
<RowDefinition Height="Auto"/>
51+
<RowDefinition Height="Auto"/>
4552
</Grid.RowDefinitions>
4653

4754
<TextBlock Text="{Binding Title}"
@@ -58,6 +65,37 @@
5865
Grid.Column="0"
5966
FontSize="14"
6067
FontWeight="Bold"
68+
VerticalAlignment="Center"
69+
Foreground="{DynamicResource Foreground}"
70+
Margin="0, 0, 0, 4"/>
71+
72+
<TextBlock Text="Generate Goals for Agents"
73+
Grid.Row="2"
74+
Visibility="{Binding EditMode, Converter={StaticResource InvBoolToVisibileConv}, ConverterParameter=true}"
75+
Foreground="{DynamicResource Foreground}"
76+
FontSize="14"
77+
Margin="0, 0, 0, 8"
78+
HorizontalAlignment="Left"
79+
VerticalAlignment="Center"
80+
FontWeight="Bold"/>
81+
82+
<TextBlock Text="Active Tier"
83+
Grid.Row="3"
84+
Grid.Column="0"
85+
FontSize="14"
86+
FontWeight="Bold"
87+
VerticalAlignment="Center"
88+
Visibility="{Binding GenerateAgentGoals, Converter={StaticResource BoolToVisibileConv}}"
89+
Foreground="{DynamicResource Foreground}"
90+
Margin="0, 0, 0, 4"/>
91+
92+
<TextBlock Text="Collected XP in Active Tier"
93+
Grid.Row="4"
94+
Grid.Column="0"
95+
FontSize="14"
96+
FontWeight="Bold"
97+
VerticalAlignment="Center"
98+
Visibility="{Binding GenerateAgentGoals, Converter={StaticResource BoolToVisibileConv}}"
6199
Foreground="{DynamicResource Foreground}"
62100
Margin="0, 0, 0, 4"/>
63101

@@ -70,6 +108,58 @@
70108
Margin="0, 0, 0, 8"
71109
Height="22"
72110
Style="{DynamicResource TextBoxTheme}"/>
111+
112+
<CheckBox Width="50" Height="30"
113+
Grid.Row="2"
114+
Grid.Column="1"
115+
x:Name="PART_AccentCheckBox"
116+
HorizontalAlignment="Right"
117+
Visibility="{Binding EditMode, Converter={StaticResource InvBoolToVisibileConv}, ConverterParameter=true}"
118+
IsChecked="{Binding GenerateAgentGoals}"
119+
Style="{StaticResource CheckBoxTheme}"
120+
Margin="0, 0, 0, 8"/>
121+
122+
<TextBox x:Name="PART_TierBox"
123+
Grid.Row="3"
124+
Grid.Column="1"
125+
FontSize="14"
126+
Margin="0, 0, 0, 8"
127+
Height="22"
128+
Visibility="{Binding GenerateAgentGoals, Converter={StaticResource BoolToVisibileConv}}"
129+
Style="{DynamicResource TextBoxTheme}">
130+
<TextBox.Text>
131+
<Binding Path="ActiveTier"
132+
UpdateSourceTrigger="PropertyChanged"
133+
ValidatesOnNotifyDataErrors="True"
134+
ValidatesOnDataErrors="True"
135+
NotifyOnValidationError="True">
136+
<Binding.ValidationRules>
137+
<validation:TierValidationRule ValidatesOnTargetUpdated="True"/>
138+
</Binding.ValidationRules>
139+
</Binding>
140+
</TextBox.Text>
141+
</TextBox>
142+
143+
<TextBox x:Name="PART_CollectedBox"
144+
Grid.Row="4"
145+
Grid.Column="1"
146+
FontSize="14"
147+
Margin="0, 0, 0, 8"
148+
Height="22"
149+
Visibility="{Binding GenerateAgentGoals, Converter={StaticResource BoolToVisibileConv}}"
150+
Style="{DynamicResource TextBoxTheme}">
151+
<TextBox.Text>
152+
<Binding Path="Collected"
153+
UpdateSourceTrigger="PropertyChanged"
154+
ValidatesOnNotifyDataErrors="True"
155+
ValidatesOnDataErrors="True"
156+
NotifyOnValidationError="True">
157+
<Binding.ValidationRules>
158+
<validation:NumericValidationRule ValidatesOnTargetUpdated="True"/>
159+
</Binding.ValidationRules>
160+
</Binding>
161+
</TextBox.Text>
162+
</TextBox>
73163
</Grid>
74164

75165
<Grid Grid.Row="2"

VexTrack/MVVM/ViewModel/Popups/DeleteGoalGroupConfirmationPopupViewModel.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ public DeleteGoalGroupConfirmationPopupViewModel()
3636
{
3737
TrackingDataHelper.MoveGoal(UUID, Constants.DefaultGroupUUID, goal.UUID);
3838
}
39+
40+
KeepGoals = false;
3941
}
4042

4143
TrackingDataHelper.RemoveGoalGroup(UUID);

0 commit comments

Comments
 (0)