Gamer.cs 667 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using System.Collections.Generic;
  2. using System.Linq;
  3. namespace Model
  4. {
  5. public sealed class Gamer : Entity
  6. {
  7. public string Account { get; }
  8. public int Team { get; set; }
  9. private readonly Dictionary<long, Unit> dictionary = new Dictionary<long, Unit>();
  10. public Gamer(string account)
  11. {
  12. this.Account = account;
  13. }
  14. public Unit[] GetAll()
  15. {
  16. return this.dictionary.Values.ToArray();
  17. }
  18. public void Add(Unit unit)
  19. {
  20. this.dictionary.Add(unit.Id, unit);
  21. }
  22. public void Remove(long id)
  23. {
  24. this.dictionary.Remove(id);
  25. }
  26. public override void Dispose()
  27. {
  28. if (this.Id == 0)
  29. {
  30. return;
  31. }
  32. base.Dispose();
  33. }
  34. }
  35. }