From c66e6516604230f76b57865b1a6b606a9674bd4d Mon Sep 17 00:00:00 2001
From: Pierre Ferreira
Date: Fri, 24 Feb 2023 16:07:32 +0100
Subject: [PATCH] Ajout de l'enum SkillType et de l'attribut et class Skill
:package:
---
Sources/EntityFramework/ChampionEntity.cs | 11 ++++++
Sources/EntityFramework/EnumSkillType.cs | 16 +++++++++
Sources/EntityFramework/Skill.cs | 42 +++++++++++++++++++++++
3 files changed, 69 insertions(+)
create mode 100644 Sources/EntityFramework/EnumSkillType.cs
create mode 100644 Sources/EntityFramework/Skill.cs
diff --git a/Sources/EntityFramework/ChampionEntity.cs b/Sources/EntityFramework/ChampionEntity.cs
index 36d33f6..a943aee 100644
--- a/Sources/EntityFramework/ChampionEntity.cs
+++ b/Sources/EntityFramework/ChampionEntity.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Collections.Immutable;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
@@ -17,9 +18,19 @@ namespace EntityFramework
public string name { get; set; }
public ChampionClass Class { get; set; }
+ public ImmutableHashSet Skills => skills.ToImmutableHashSet();
+ private HashSet skills = new HashSet();
public ChampionEntity(string name) {
this.name = name;
}
+
+
+
+ public bool AddSkill(Skill skill)
+ => skills.Add(skill);
+
+ public bool RemoveSkill(Skill skill)
+ => skills.Remove(skill);
}
}
diff --git a/Sources/EntityFramework/EnumSkillType.cs b/Sources/EntityFramework/EnumSkillType.cs
new file mode 100644
index 0000000..f8f56f8
--- /dev/null
+++ b/Sources/EntityFramework/EnumSkillType.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace EntityFramework
+{
+ public enum SkillType
+ {
+ Unknown,
+ Basic,
+ Passive,
+ Ultimate
+ }
+}
diff --git a/Sources/EntityFramework/Skill.cs b/Sources/EntityFramework/Skill.cs
new file mode 100644
index 0000000..e9b1f32
--- /dev/null
+++ b/Sources/EntityFramework/Skill.cs
@@ -0,0 +1,42 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace EntityFramework
+{
+ public class Skill
+ {
+ public SkillType Type { get; private set; }
+
+ public string Name
+ {
+ get => name;
+ private init
+ {
+ if (string.IsNullOrWhiteSpace(value))
+ {
+ throw new ArgumentException("a Skill needs a name");
+ }
+ name = value;
+ }
+ }
+ private readonly string name = null!;
+
+ public string Description
+ {
+ get => description;
+ set
+ {
+ if (string.IsNullOrWhiteSpace(value))
+ {
+ description = "";
+ return;
+ }
+ description = value;
+ }
+ }
+ private string description = "";
+ }
+}