Ajout de l'enum SkillType et de l'attribut et class Skill 📦

pull/21/head
Pierre Ferreira 2 years ago
parent dd1a88ce1e
commit c66e651660

@ -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<Skill> Skills => skills.ToImmutableHashSet();
private HashSet<Skill> skills = new HashSet<Skill>();
public ChampionEntity(string name) {
this.name = name;
}
public bool AddSkill(Skill skill)
=> skills.Add(skill);
public bool RemoveSkill(Skill skill)
=> skills.Remove(skill);
}
}

@ -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
}
}

@ -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 = "";
}
}
Loading…
Cancel
Save