1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- using System.Collections.Generic;
- namespace FL.Data
- {
- public class PartnerPlan
- {
- public int Id { get; private set; }
- public string Name { get; private set; }
- /// <summary>
- /// key 位置 : value 槽位信息
- /// </summary>
- private Dictionary<int, PartnerPlanSlot> _planMap = new Dictionary<int, PartnerPlanSlot>();
- /// <summary>
- /// key 绑定的圣兵id :value 槽位id
- /// </summary>
- private Dictionary<int, int> _idMap = new Dictionary<int, int>();
- public Dictionary<int, PartnerPlanSlot>.ValueCollection Slots
- {
- get { return _planMap.Values; }
- }
- public void SetData(int id, string name, List<PartnerPlanSlot> planList)
- {
- Id = id;
- Name = name.Length > 0 ? name : string.Format(StringDefine.partnerInitPlanName, id);
- _planMap.Clear();
- _idMap.Clear();
- foreach (var slot in planList)
- {
- _planMap.Add(slot.CaoId, slot);
- if (slot.SbId > 0)
- {
- _idMap.Add(slot.SbId, slot.CaoId);
- }
- }
- }
- public bool TryGetUpPos(int sbId, out int upPos)
- {
- return _idMap.TryGetValue(sbId, out upPos);
- }
- public PartnerPlanSlot GetSlot(int slotId)
- {
- return _planMap.GetValueOrDefault(slotId);
- }
- }
- }
|