OpenedRolesEntity.cs 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using System.Collections.Generic;
  2. using System.ComponentModel;
  3. using System.ComponentModel.DataAnnotations;
  4. using System.ComponentModel.DataAnnotations.Schema;
  5. using MafiaTelegramBot.Resources;
  6. namespace MafiaTelegramBot.DataBase.Entity
  7. {
  8. [Table("opened_roles")]
  9. public class OpenedRolesEntity
  10. {
  11. [Key]
  12. [DatabaseGenerated(DatabaseGeneratedOption.None)]
  13. [Column("id"), MaxLength(127)] public long Id { get; init; }
  14. [Column("bodyguard") , MaxLength(127)] public bool Bodyguard { get; init; }
  15. [Column("dame") , MaxLength(127)] public bool Dame { get; init; }
  16. [Column("detective") , MaxLength(127)] public bool Detective { get; init; }
  17. [Column("elder") , MaxLength(127)] public bool Elder { get; init; }
  18. [Column("fool") , MaxLength(127)] public bool Fool { get; init; }
  19. [Column("hooker") , MaxLength(127)] public bool Hooker { get; init; }
  20. [Column("journalist") , MaxLength(127)] public bool Journalist { get; init; }
  21. [Column("lawyer") , MaxLength(127)] public bool Lawyer { get; init; }
  22. [Column("necromancer") , MaxLength(127)] public bool Necromancer { get; init; }
  23. [Column("parasite") , MaxLength(127)] public bool Parasite { get; init; }
  24. [Column("werewolf") , MaxLength(127)] public bool Werewolf { get; init; }
  25. public List<Roles> ToList()
  26. {
  27. var list = new List<Roles> {Roles.Don, Roles.Doctor, Roles.Cop};
  28. if(Bodyguard) list.Add(Roles.Bodyguard);
  29. if(Dame) list.Add(Roles.Dame);
  30. if(Detective) list.Add(Roles.Detective);
  31. if(Elder) list.Add(Roles.Elder);
  32. if(Fool) list.Add(Roles.Fool);
  33. if(Hooker) list.Add(Roles.Hooker);
  34. if(Journalist) list.Add(Roles.Journalist);
  35. if(Lawyer) list.Add(Roles.Lawyer);
  36. if(Necromancer) list.Add(Roles.Necromancer);
  37. if(Parasite) list.Add(Roles.Parasite);
  38. if(Werewolf) list.Add(Roles.Werewolf);
  39. return list;
  40. }
  41. public bool AllRolesOpened()
  42. {
  43. return Bodyguard && Dame && Detective
  44. && Elder && Fool && Hooker && Journalist
  45. && Lawyer && Necromancer && Parasite && Werewolf;
  46. }
  47. }
  48. }