OpenedRolesEntity.cs 2.3 KB

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