PartnerPlan.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. using System.Collections.Generic;
  2. namespace FL.Data
  3. {
  4. public class PartnerPlan
  5. {
  6. public int Id { get; private set; }
  7. public string Name { get; private set; }
  8. /// <summary>
  9. /// key 位置 : value 槽位信息
  10. /// </summary>
  11. private Dictionary<int, PartnerPlanSlot> _planMap = new Dictionary<int, PartnerPlanSlot>();
  12. /// <summary>
  13. /// key 绑定的圣兵id :value 槽位id
  14. /// </summary>
  15. private Dictionary<int, int> _idMap = new Dictionary<int, int>();
  16. public Dictionary<int, PartnerPlanSlot>.ValueCollection Slots
  17. {
  18. get { return _planMap.Values; }
  19. }
  20. public void SetData(int id, string name, List<PartnerPlanSlot> planList)
  21. {
  22. Id = id;
  23. Name = name.Length > 0 ? name : string.Format(StringDefine.partnerInitPlanName, id);
  24. _planMap.Clear();
  25. _idMap.Clear();
  26. foreach (var slot in planList)
  27. {
  28. _planMap.Add(slot.CaoId, slot);
  29. if (slot.SbId > 0)
  30. {
  31. _idMap.Add(slot.SbId, slot.CaoId);
  32. }
  33. }
  34. }
  35. public bool TryGetUpPos(int sbId, out int upPos)
  36. {
  37. return _idMap.TryGetValue(sbId, out upPos);
  38. }
  39. public PartnerPlanSlot GetSlot(int slotId)
  40. {
  41. return _planMap.GetValueOrDefault(slotId);
  42. }
  43. }
  44. }