Skip to content

Commit

Permalink
add Factions and FactionsExtensions classes
Browse files Browse the repository at this point in the history
  • Loading branch information
Konrad Jamrozik committed Jun 13, 2024
1 parent b6c604f commit eccb44a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/game-lib/Model/Factions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System.Text.Json.Serialization;

namespace UfoGameLib.Model;

public class Factions : List<Faction>
{
[JsonConstructor]
public Factions()
{
}

public Factions(IEnumerable<Faction>? factions = null)
=> AddRange(factions ?? new List<Faction>());

public Factions DeepClone()
=> new Factions(this.Select(faction => faction.DeepClone()));
}
7 changes: 7 additions & 0 deletions src/game-lib/Model/FactionsExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace UfoGameLib.Model;

public static class FactionsExtensions
{
public static Factions ToFactions(this IEnumerable<Faction> factionsEnumerable)
=> new Factions(factionsEnumerable);
}

0 comments on commit eccb44a

Please sign in to comment.