Skip to content

Commit

Permalink
co-op mode changes and code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
DarwinBaker committed Nov 29, 2022
1 parent c284934 commit b640df4
Show file tree
Hide file tree
Showing 17 changed files with 464 additions and 147 deletions.
222 changes: 219 additions & 3 deletions AATool/AATool.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@
<Compile Include="Data\Objectives\Complex\Trident.cs" />
<Compile Include="Data\Objectives\Complex\WitherSkulls.cs" />
<Compile Include="Data\Progress\Completion.cs" />
<Compile Include="Data\Progress\NetworkContribution.cs" />
<Compile Include="Data\Progress\NetworkState.cs" />
<Compile Include="Data\Progress\ProgressState.cs" />
<Compile Include="Data\Speedrunning\NicknameSheet.cs" />
<Compile Include="Data\Speedrunning\Run.cs" />
Expand Down Expand Up @@ -478,6 +480,27 @@
<Content Include="assets\objectives\1.19\potions.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="assets\objectives\1.20 Snapshot\advancements\adventure.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="assets\objectives\1.20 Snapshot\advancements\end.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="assets\objectives\1.20 Snapshot\advancements\husbandry.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="assets\objectives\1.20 Snapshot\advancements\minecraft.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="assets\objectives\1.20 Snapshot\advancements\nether.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="assets\objectives\1.20 Snapshot\blocks.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="assets\objectives\1.20 Snapshot\potions.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="assets\sprites\ab_guide\all_infested_blocks%246x6x30.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
Expand Down Expand Up @@ -685,6 +708,102 @@
<Content Include="assets\sprites\blocks\animated\water^48%24198x29.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="assets\sprites\blocks\bamboo\bamboo_fence^32.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="assets\sprites\blocks\bamboo\bamboo_fence^48.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="assets\sprites\blocks\bamboo\bamboo_fence_gate^32.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="assets\sprites\blocks\bamboo\bamboo_fence_gate^48.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="assets\sprites\blocks\bamboo\bamboo_block^32.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="assets\sprites\blocks\bamboo\bamboo_block^48.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="assets\sprites\blocks\bamboo\bamboo_button^32.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="assets\sprites\blocks\bamboo\bamboo_button^48.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="assets\sprites\blocks\bamboo\bamboo_door^32.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="assets\sprites\blocks\bamboo\bamboo_door^48.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="assets\sprites\blocks\bamboo\bamboo_mosaic^32.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="assets\sprites\blocks\bamboo\bamboo_mosaic^48.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="assets\sprites\blocks\bamboo\bamboo_mosaic_slab^32.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="assets\sprites\blocks\bamboo\bamboo_mosaic_slab^48.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="assets\sprites\blocks\bamboo\bamboo_mosaic_stairs^32.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="assets\sprites\blocks\bamboo\bamboo_mosaic_stairs^48.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="assets\sprites\blocks\bamboo\bamboo_planks^32.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="assets\sprites\blocks\bamboo\bamboo_planks^48.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="assets\sprites\blocks\bamboo\bamboo_pressure_plate^32.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="assets\sprites\blocks\bamboo\bamboo_pressure_plate^48.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="assets\sprites\blocks\bamboo\bamboo_slab^32.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="assets\sprites\blocks\bamboo\bamboo_slab^48.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="assets\sprites\blocks\bamboo\bamboo_stairs^32.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="assets\sprites\blocks\bamboo\bamboo_stairs^48.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="assets\sprites\blocks\bamboo\bamboo_trapdoor^32.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="assets\sprites\blocks\bamboo\bamboo_trapdoor^48.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="assets\sprites\blocks\bamboo\chiseled_bookshelf^32.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="assets\sprites\blocks\bamboo\chiseled_bookshelf^48.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="assets\sprites\blocks\bamboo\chiseled_bookshelf_full^32.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="assets\sprites\blocks\bamboo\chiseled_bookshelf_full^48.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="assets\sprites\blocks\bamboo\stripped_bamboo_block^32.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="assets\sprites\blocks\bamboo\stripped_bamboo_block^48.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="assets\sprites\blocks\banners\black_banner^32.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
Expand Down Expand Up @@ -1966,6 +2085,78 @@
<Content Include="assets\sprites\ab_guide\recipe_tripwire_hook.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="assets\sprites\blocks\hanging_signs\bamboo_hanging_sign^32.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="assets\sprites\blocks\hanging_signs\acacia_hanging_sign^32.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="assets\sprites\blocks\hanging_signs\bamboo_hanging_sign^48.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="assets\sprites\blocks\hanging_signs\acacia_hanging_sign^48.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="assets\sprites\blocks\hanging_signs\birch_hanging_sign^32.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="assets\sprites\blocks\hanging_signs\birch_hanging_sign^48.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="assets\sprites\blocks\hanging_signs\crimson_hanging_sign^32.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="assets\sprites\blocks\hanging_signs\crimson_hanging_sign^48.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="assets\sprites\blocks\hanging_signs\dark_oak_hanging_sign^32.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="assets\sprites\blocks\hanging_signs\dark_oak_hanging_sign^48.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="assets\sprites\blocks\hanging_signs\jungle_hanging_sign^32.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="assets\sprites\blocks\hanging_signs\jungle_hanging_sign^48.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="assets\sprites\blocks\hanging_signs\mangrove_hanging_sign^32.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="assets\sprites\blocks\hanging_signs\mangrove_hanging_sign^48.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="assets\sprites\blocks\hanging_signs\oak_hanging_sign^32.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="assets\sprites\blocks\hanging_signs\oak_hanging_sign^48.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="assets\sprites\blocks\bamboo\bamboo_sign^32.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="assets\sprites\blocks\bamboo\bamboo_sign^48.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="assets\sprites\blocks\hanging_signs\spruce_hanging_sign^32.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="assets\sprites\blocks\hanging_signs\spruce_hanging_sign^48.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="assets\sprites\blocks\hanging_signs\warped_hanging_sign^32.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="assets\sprites\blocks\hanging_signs\warped_hanging_sign^48.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="assets\sprites\blocks\heads\piglin_head^32.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="assets\sprites\blocks\heads\piglin_head^48.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="assets\sprites\blocks\lush\azalea^32.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
Expand Down Expand Up @@ -2263,6 +2454,12 @@
<Content Include="assets\sprites\blocks\plants\big_dripleaf^48.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="assets\sprites\blocks\plants\bamboo_sapling^32.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="assets\sprites\blocks\plants\bamboo_sapling^48.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="assets\sprites\blocks\plants\birch_sapling^48.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
Expand Down Expand Up @@ -2497,6 +2694,12 @@
<Content Include="assets\sprites\global\badges\supporter\badge_supporter_diamond.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="assets\sprites\global\criteria\animals\camel.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="assets\sprites\global\criteria\mobs\vex_1.19.3.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="assets\sprites\global\glow\glint%24825.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
Expand Down Expand Up @@ -6490,6 +6693,15 @@
<Content Include="assets\views\all_advancements\1.16\main_vertical.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="assets\views\all_advancements\1.20 Snapshot\main_compact.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="assets\views\all_advancements\1.20 Snapshot\main_relaxed.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="assets\views\all_advancements\1.20 Snapshot\main_vertical.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="assets\views\all_advancements\1.19\main_compact.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
Expand All @@ -6511,6 +6723,12 @@
<Content Include="assets\views\all_blocks\1.16\main.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="assets\views\all_blocks\1.20 Snapshot\help.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="assets\views\all_blocks\1.20 Snapshot\main.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="assets\views\all_blocks\overlay.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
Expand Down Expand Up @@ -8876,9 +9094,7 @@
<SubType>Designer</SubType>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<Folder Include="assets\sprites\blocks\unobtainable\" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\MonoGame.Framework.WindowsDX.3.8.0.1641\build\MonoGame.Framework.WindowsDX.targets" Condition="Exists('..\packages\MonoGame.Framework.WindowsDX.3.8.0.1641\build\MonoGame.Framework.WindowsDX.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
Expand Down
2 changes: 2 additions & 0 deletions AATool/Data/Objectives/Criterion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ namespace AATool.Data.Objectives
{
public class Criterion : Objective
{
public static string Key(string advancement, string criterion) => $"{advancement} {criterion}";

public readonly Advancement Owner;

public Uuid DesignatedPlayer => this.Owner.DesignatedPlayer;
Expand Down
8 changes: 3 additions & 5 deletions AATool/Data/Progress/Completion.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
using System;
using AATool.Net;
using Newtonsoft.Json;

namespace AATool.Data.Progress
{
[JsonObject]
public struct Completion
{
public static readonly Completion Empty = new (Uuid.Empty, default);

[JsonProperty] public Uuid Player;
[JsonProperty] public DateTime Timestamp;
public Uuid Player;
public DateTime Timestamp;

[JsonIgnore] public bool IsEmpty => this.Player == Uuid.Empty;
public bool IsEmpty => this.Player == Uuid.Empty;

public Completion(Uuid player, DateTime timestamp)
{
Expand Down
47 changes: 27 additions & 20 deletions AATool/Data/Progress/Contribution.cs
Original file line number Diff line number Diff line change
@@ -1,38 +1,45 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using AATool.Data.Objectives;
using AATool.Net;
using Newtonsoft.Json;

namespace AATool.Data.Progress
{
[TypeConverter(typeof(Contribution))]
[JsonObject]
public class Contribution : ProgressState
{
[JsonProperty] public readonly Uuid Player;

[JsonConstructor]
public Contribution(Uuid Player,
Dictionary<string, Completion> Advancements,
Dictionary<(string, string), Completion> Criteria,
Dictionary<string, Completion> Recipes)
: base(Advancements, Criteria, Recipes)
{
this.Player = Player;
}
public readonly Uuid Player;

public Contribution(Uuid Player) : base()
{
this.Player = Player;
}

public static Contribution FromJsonString(string jsonString) =>
JsonConvert.DeserializeObject<Contribution>(jsonString);
public Contribution(NetworkContribution network) : this(network.UUID)
{
this.Player = network.UUID;
this.InGameTime = network.InGameTime;
this.ObtainedGodApple = network.ObtainedGodApple;

public string ToJsonString() =>
JsonConvert.SerializeObject(this);
//add advancements
foreach (KeyValuePair<string, DateTime> advancement in network.Advancements)
this.Advancements[advancement.Key] = new Completion(this.Player, advancement.Value);
//add criteria
foreach (string criterion in network.Criteria)
this.Criteria[criterion] = default;
//add stats
foreach (KeyValuePair<string, int> stat in network.PickupCounts)
this.PickupCounts[stat.Key] = stat.Value;
foreach (KeyValuePair<string, int> stat in network.DropCounts)
this.DropCounts[stat.Key] = stat.Value;
foreach (KeyValuePair<string, int> stat in network.MineCounts)
this.MineCounts[stat.Key] = stat.Value;
foreach (KeyValuePair<string, int> stat in network.CraftCounts)
this.CraftCounts[stat.Key] = stat.Value;
foreach (KeyValuePair<string, int> stat in network.UseCounts)
this.UseCounts[stat.Key] = stat.Value;
foreach (KeyValuePair<string, int> stat in network.KillCounts)
this.KillCounts[stat.Key] = stat.Value;
}

public override HashSet<Completion> CompletionsOf(IObjective objective)
{
Expand All @@ -45,7 +52,7 @@ public override HashSet<Completion> CompletionsOf(IObjective objective)
}
else if (objective is Criterion criterion)
{
if (this.Criteria.TryGetValue((criterion.OwnerId, criterion.Id), out Completion completion))
if (this.Criteria.TryGetValue(Criterion.Key(criterion.OwnerId, criterion.Id), out Completion completion))
completionists.Add(completion);
}
else if (objective is Block block)
Expand Down
Loading

0 comments on commit b640df4

Please sign in to comment.