using System.Collections.Generic; namespace FL.Data { public class PartnerPlan { public int Id { get; private set; } public string Name { get; private set; } /// /// key 位置 : value 槽位信息 /// private Dictionary _planMap = new Dictionary(); /// /// key 绑定的圣兵id :value 槽位id /// private Dictionary _idMap = new Dictionary(); public Dictionary.ValueCollection Slots { get { return _planMap.Values; } } public void SetData(int id, string name, List 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); } } }