private void OnResetSelection(object parameter) { foreach (AdvancedSearchEquipment x in Equipments.Where(x => x.IsVisible)) { x.RestoreOriginalSelection(); } }
private bool FindItemByExtraDescriptionOrName(CommandParameter parameter, out string description) // Find by extra description then name (search in inventory, then equipment, then in room) { description = null; int count = 0; foreach (IItem item in Content.Where(CanSee) .Concat(Equipments.Where(x => x.Item != null && CanSee(x.Item)).Select(x => x.Item)) .Concat(Room.Content.Where(CanSee))) { // Search in item extra description keywords if (item.ExtraDescriptions != null) { foreach (KeyValuePair <string, string> extraDescription in item.ExtraDescriptions) { if (parameter.Tokens.All(x => FindHelpers.StringStartsWith(extraDescription.Key, x)) && ++count == parameter.Count) { description = extraDescription.Value; return(true); } } } // Search in item keywords if (FindHelpers.StringListStartsWith(item.Keywords, parameter.Tokens) && ++count == parameter.Count) { description = FormatItem(item, false) + Environment.NewLine; return(true); } } return(false); }
private void OnUnselectAll(object parameter) { foreach (AdvancedSearchEquipment x in Equipments.Where(x => x.IsVisible)) { x.IsSelected = false; } }
private void OnInverseSelection(object parameter) { foreach (AdvancedSearchEquipment x in Equipments.Where(x => x.IsVisible)) { x.IsSelected = !x.IsSelected; } }
/// <summary> /// Освободить все занятые ресурсы. /// </summary> internal void ReleaseResources(ref List <Student> students, int threadId) { lock (students) { foreach (var eqName in Student.SubjectToPassing.EquipmentNames) { var eq = Equipments.Where(e => e.Name == eqName).FirstOrDefault(); if (eq == null) { throw new Exception($"Попытка освободить несуществующий ресурс {eqName}."); } ++eq.Count; } if (Student.SubjectToPassing.RemainingTime > 0) { Student.CurrentState = CurrentThreadState.W; } else { Student.CurrentState = CurrentThreadState.F; } ++Teacher.NumberOfStudents; } }
public bool HasNotification(int level, long blockIndex) { var availableSlots = UnlockHelper.GetAvailableEquipmentSlots(level); foreach (var(type, slotCount) in availableSlots) { var equipments = Equipments.Where(e => e.ItemSubType == type && e.RequiredBlockIndex <= blockIndex); var current = equipments.Where(e => e.equipped); // When an equipment slot is empty. if (current.Count() < Math.Min(equipments.Count(), slotCount)) { return(true); } // When any other equipments are stronger than current one. foreach (var equipment in equipments) { if (equipment.equipped) { continue; } var cp = CPHelper.GetCP(equipment); if (current.Any(i => CPHelper.GetCP(i) < cp)) { return(true); } } } return(false); }
/// <summary> /// Забрать все необходимые для сдачи ресурсы. /// </summary> internal void TakeResources(ref List <Student> students) { lock (students) { var maxPriority = students.Min(s => s.Priority); Student = students.Where(s => s.Priority == maxPriority).First(); students.Remove(Student); Student.CurrentState = CurrentThreadState.R; foreach (var eqName in Student.SubjectToPassing.EquipmentNames) { var eq = Equipments.Where(e => e.Name == eqName && e.Count > 0).FirstOrDefault(); if (eq == null) { throw new Exception($"Нет свободного оборудования типа <{eqName}>."); } --eq.Count; } if (Teacher.NumberOfStudents < 1) { throw new Exception($"Преподаватель <{Teacher}> уже занят."); } --Teacher.NumberOfStudents; } }
private void OnResetSelection(object parameter) { isInBatch = true; try { foreach (AdvancedSearchEquipment x in Equipments.Where(x => x.IsVisible)) { x.RestoreOriginalSelection(); } } finally { isInBatch = false; UpdateSelectedCount(); } }
private void OnUnselectAll(object parameter) { isInBatch = true; try { foreach (AdvancedSearchEquipment x in Equipments.Where(x => x.IsVisible)) { x.IsSelected = false; } } finally { isInBatch = false; UpdateSelectedCount(); } }
// Remove item protected virtual bool DoRemove(string rawParameters, params CommandParameter[] parameters) { if (parameters.Length == 0) { Send("Remove what?"); } else { EquipedItem equipmentSlot = FindHelpers.FindByName(Equipments.Where(x => x.Item != null && CanSee(x.Item)), x => x.Item, parameters[0]); if (equipmentSlot?.Item == null) { Send(StringHelpers.ItemInventoryNotFound); } else { RemoveItem(equipmentSlot); } } return(true); }
public bool HasNotification() { foreach (var subType in new [] { ItemSubType.Weapon, ItemSubType.Armor, ItemSubType.Belt, ItemSubType.Necklace, ItemSubType.Ring }) { var equipments = Equipments.Where(e => e.ItemSubType == subType).ToList(); var current = equipments.FirstOrDefault(e => e.equipped); //현재 장착안한 슬롯에 장착 가능한 장비가 있는 경우 if (current is null && equipments.Any()) { return(true); } var hasNotification = equipments.Any(e => CPHelper.GetCP(e) > CPHelper.GetCP(current)); // 현재장착한 장비보다 강한 장비가 있는 경우 if (hasNotification) { return(true); } } return(false); }
public ICollection <IEquipment> GetEquipments(EquipmentType type) { return(Equipments .Where(p => p.EquipmentType == type) .ToList()); }
public virtual int UpdatedEquipmentNum(DateTime date) { return(Equipments.Where(e => e.IsUpdatedInMonth(date)).Count()); }