public IActionResult CreateNewItem(CreateItemViewModel model) { IItemCollection itemCollection = _itemFactory.ItemCollection(); itemCollection.CreateItem(new Item(model.Name, model.Description, model.Type, model.IsUnique)); return(RedirectToAction("Index", "Item")); }
/// <summary> /// Insert items into pool. /// </summary> /// <param name="items">collection of items to be inserted</param> public void Insert(IItemCollection items) { foreach (Item item in items) { Insert(item); } }
public void Construct(Construction construction, Character technician, IItemCollection roomItems, Item mainItem, ClassicGame world) { IItemCollection insert = technician.Items; if (!technician.Items.Contains(mainItem)) { insert = roomItems; } for (int i = 0; i < construction.construction.Items.Length; i++) { Item item = technician.Items.Find(world.ItemTypes[construction.construction.Items[i]]); if (item != null) { technician.Items.Remove(item); } else { item = roomItems.Find(world.ItemTypes[construction.construction.Items[i]]); roomItems.Remove(item); } } insert.Add(world.ItemTypes[construction.construction.Result].Generate()); }
/// <summary> /// Remove all items contained in both collections. /// </summary> /// <param name="me">collection to remove items from</param> /// <param name="collection">collection with items to remove from me</param> public static void Remove(this IItemCollection me, IItemCollection collection) { for (int i = 0; i < collection.Count; i++) { me.Remove(collection[i]); } }
public MatchManager(ILogger <MatchManager> logger, ICharacterCollection charColl, IItemCollection itemColl, IRealtimeEventBroadcastService events, IMatchEventBroadcastService matchEvents, IRealtimeMonitor realtime, IChallengeEventBroadcastService challengeEvents, IMatchMessageBroadcastService matchMessages, IAdminMessageBroadcastService adminMessages, IChallengeManager challenges, ISecondTimer timer) { _Logger = logger ?? throw new ArgumentNullException(nameof(logger)); _CharacterColleciton = charColl ?? throw new ArgumentNullException(nameof(charColl)); _ItemCollection = itemColl ?? throw new ArgumentNullException(nameof(itemColl)); _Realtime = realtime ?? throw new ArgumentNullException(nameof(realtime)); _RealtimeEvents = events ?? throw new ArgumentNullException(nameof(events)); _MatchEvents = matchEvents ?? throw new ArgumentNullException(nameof(matchEvents)); _ChallengeEvents = challengeEvents ?? throw new ArgumentNullException(nameof(challengeEvents)); _MatchMessages = matchMessages ?? throw new ArgumentNullException(nameof(matchMessages)); _AdminMessages = adminMessages ?? throw new ArgumentNullException(nameof(adminMessages)); _Challenges = challenges ?? throw new ArgumentNullException(nameof(challenges)); _Timer = timer ?? throw new ArgumentNullException(nameof(timer)); SetSettings(new MatchSettings()); AddListeners(); }
ConstructionInfo FindConstruction(IItemCollection primary, IItemCollection secondary, ItemType mainItem, CharClass charClass, out bool canBuild) { canBuild = false; ConstructionInfo best = null; if (constructions.ContainsKey(mainItem)) { for (int i = 0; i < constructions[mainItem].Count; i++) { ConstructionInfo construction = constructions[mainItem][i]; if (!construction.Classes[(int)charClass]) { continue; } if (CanConstruct(primary, secondary, construction)) { best = construction; canBuild = true; break; } else if (best == null && MainItemsAvailable(primary, secondary, construction)) { best = construction; } } } return(best); }
public void MoveItems(IItemCollection items) { foreach (Character ch in characterList) { ch.Items.Move(items); } }
public WorkItemActionModel(IItemCollection <WorkItem> workItems, ActivityMonitorComponent owner) : base(new ApplicationThemeResourceResolver(typeof(ActivityMonitorComponent).Assembly, new ApplicationThemeResourceResolver(typeof(CrudActionModel).Assembly))) { _workItems = workItems; _owner = owner; if (PermissionsHelper.IsInRole(AuthorityTokens.ActivityMonitor.WorkItems.Stop)) { this.CancelAction = AddAction("cancel", SR.MenuStopWorkItem, "CancelToolSmall.png", SR.TooltipStopWorkItem, CancelSelectedWorkItems); } if (PermissionsHelper.IsInRole(AuthorityTokens.ActivityMonitor.WorkItems.Restart)) { this.RestartAction = AddAction("restart", SR.MenuRestartWorkItem, "RestartToolSmall.png", SR.TooltipRestartWorkItem, RestartSelectedWorkItems); } if (PermissionsHelper.IsInRole(AuthorityTokens.ActivityMonitor.WorkItems.Delete)) { this.DeleteAction = AddAction("delete", SR.MenuDeleteWorkItem, "DeleteToolSmall.png", SR.TooltipDeleteWorkItem, DeleteSelectedWorkItems); } if (PermissionsHelper.IsInRole(AuthorityTokens.ActivityMonitor.WorkItems.Prioritize)) { this.StatAction = AddAction("stat", SR.MenuStatWorkItem, "StatToolSmall.png", SR.TooltipStatWorkItem, StatSelectedWorkItems); } UpdateActionEnablement(); }
/// <summary> /// Copies this file to another folder. /// </summary> /// <param name="destFolder">Destination folder.</param> /// <param name="destName">New file name in destination folder.</param> /// <param name="deep">Is not used.</param> /// <param name="multistatus">Container for errors with items other than this file.</param> public override void CopyTo( IItemCollection destFolder, string destName, bool deep, MultistatusException multistatus) { DavFolder destDavFolder = destFolder as DavFolder; if (destFolder == null) { throw new DavException("Destination folder doesn't exist.", DavStatus.CONFLICT); } if (!destDavFolder.ClientHasToken()) { throw new LockedException("Doesn't have token for destination folder."); } DavHierarchyItem destItem = destDavFolder.FindChild(destName); if (destItem != null) { try { destItem.Delete(multistatus); } catch (DavException ex) { multistatus.AddInnerException(destItem.Path, ex); return; } } CopyThisItem(destDavFolder, null, destName); }
/// <summary> /// Remove all items. /// </summary> /// <param name="me">collection to remove items from</param> public static void Clear(this IItemCollection me) { while (me.Count > 0) { me.Remove(me[0]); } }
public ShoppingListRandomizer(IRandomizerAgent agent, IItemCollection itemCollection, IItemTierList itemTierList, IItemRandomizer itemRandomizer) { Agent = agent; ItemCollection = itemCollection; ItemTierList = ItemTierList; ItemRandomizer = itemRandomizer; }
public SparsityMode(IRandomizerAgent agent, IAreaCollection areaCollection, IEnemyCollection enemyCollection, IItemCollection itemCollection, IItemTierList itemTierList) { Agent = agent; AreaCollection = areaCollection; EnemyCollection = enemyCollection; ItemCollection = itemCollection; ItemTierList = itemTierList; }
public IActionResult SaveEdit(ShowAllItemsViewModel model) { IItemCollection accountCollection = _itemFactory.ItemCollection(); accountCollection.Update(new Item(model.Name, model.Description, model.Type, model.Unique)); return(RedirectToAction("Index", "Item")); }
public ThreeOrbMode(IRandomizerAgent randomizerAgent, IBossOrbTierList bossOrbTierList, IEnemyCollection enemyCollection, IItemTierList itemTierList, IItemCollection itemCollection, IAreaCollection areaCollection) { Agent = randomizerAgent; BossOrbTierList = bossOrbTierList; EnemyCollection = enemyCollection; ItemTierList = itemTierList; ItemCollection = itemCollection; AreaCollection = areaCollection; }
/// <summary> /// Constructor /// </summary> /// <param name="enableImport"></param> /// <param name="locatorRegistryFactory"></param> /// <param name="startupConfiguration"></param> /// <param name="locatorDefaultRegistrations"></param> /// <param name="locatorRegistryFinalizer"></param> public StartupTaskContext(bool enableImport, ILocatorRegistryFactory locatorRegistryFactory, IStartupConfiguration startupConfiguration, ILocatorDefaultRegistrations locatorDefaultRegistrations, Action <ILocatorRegistry> locatorRegistryFinalizer) { EnableImport = enableImport; LocatorRegistry = locatorRegistryFactory?.CreateRegistry(); Locator = locatorRegistryFactory?.CreateLocator(); Configuration = startupConfiguration; _taskItems = new StartupEnvironmentItemCollection(); _taskItems.Set(locatorDefaultRegistrations); _taskItems.Set(locatorRegistryFinalizer); }
/// <summary> /// Heal value for doctors. /// </summary> /// <param name="me">collection of items</param> /// <returns>heal value</returns> public static int GetHealValue(this IItemCollection me) { float v = 0; foreach (Item item in me) { v += item.HealValue; } return((int)v); }
void OnRightClickItemRoom(Framework.States.StateObject state) { BurntimeClassic classic = app as BurntimeClassic; Item item = state as Item; IItemCollection right = (classic.InventoryRoom == null) ? (IItemCollection)classic.PickItems : classic.InventoryRoom.Items; // eat if (item.FoodValue != 0) { int left = group.Eat(leader, item.FoodValue); // remove item only if somebody actually ate if (left < item.FoodValue) { if (item.Type.Empty != null) { item.MakeEmpty(); grid.Update(item); } else { right.Remove(item); grid.Remove(item); } } } // drink else if (item.WaterValue != 0) { int left = group.Drink(leader, item.WaterValue); // remove item only if somebody actually drank if (left < item.WaterValue) { if (item.Type.Empty != null) { item.MakeEmpty(); grid.Update(item); } else { right.Remove(item); grid.Remove(item); } } } else //if (inventory.ActiveCharacter.Class == CharClass.Technician) { construction = classic.Game.Constructions.GetConstruction(inventory.ActiveCharacter, right, item); this.item = item; dialog.SetCharacter(inventory.ActiveCharacter, construction.Dialog); dialog.Show(); } }
bool MainItemsAvailable(IItemCollection primary, IItemCollection secondary, ConstructionInfo construction) { for (int i = 0; i < construction.MainItems.Length; i++) { if (primary.Contains(construction.MainItems[i]) || secondary.Contains(construction.MainItems[i])) { return(true); } } return(false); }
public EnemyRandomizer(IRandomizerAgent agent, IEnemyCollection enemyCollection, IItemCollection itemCollection, IAttackTierList attackTierList, IItemTierList itemTierList, IEnemyTierList enemyTierList, IElementRandomizer elementRandomizer, IItemRandomizer itemRandomizer) { Agent = agent; EnemyCollection = enemyCollection; ItemCollection = itemCollection; AttackTierList = attackTierList; ItemTierList = itemTierList; EnemyTierList = enemyTierList; ElementRandomizer = elementRandomizer; ItemRandomizer = itemRandomizer; }
public void AddNewAndSetItems <T>(List <T> items, IItemCollection <T> dbCollection, SelectableDbItemList selectList) where T : DatabaseObject { foreach (var item in items) { if (dbCollection[item.Id] == null) { selectList.Add(item); } } selectList.SetSelection(items.Select(a => a.Id)); }
/// <summary> /// Add all items from collection. /// </summary> /// <param name="me">collection to add items to</param> /// <param name="collection">collection to add items from</param> /// <returns>true if all items were added</returns> public static bool Add(this IItemCollection me, IItemCollection collection) { foreach (Item item in collection) { if (!me.Add(item)) { return(false); } } return(true); }
/// <summary> /// Get item with specific item type. /// </summary> /// <param name="me">collection of items</param> /// <param name="type">item type id</param> /// <returns>item or null</returns> public static Item Find(this IItemCollection me, string type) { for (int i = 0; i < me.Count; i++) { if (me[i].Type == type) { return(me[i]); } } return(null); }
/// <summary> /// Check wether collection contains a specific item type. /// </summary> /// <param name="me">collection of items</param> /// <param name="type">item type id</param> /// <returns>true if contained</returns> public static bool Contains(this IItemCollection me, string type) { for (int i = 0; i < me.Count; i++) { if (me[i].Type == type) { return(true); } } return(false); }
/// <summary> /// Copies this folder to another folder with option to rename it. /// </summary> /// <param name="destFolder">Folder to copy this folder to.</param> /// <param name="destName">New name of this folder.</param> /// <param name="deep">Whether children shall be copied.</param> /// <param name="multistatus">Container for errors. We put here errors which occur with /// individual items being copied.</param> public override void CopyTo(IItemCollection destFolder, string destName, bool deep, MultistatusException multistatus) { DavFolder destDavFolder = destFolder as DavFolder; if (destFolder == null) { throw new DavException("Destination folder doesn't exist", DavStatus.CONFLICT); } if (!destDavFolder.ClientHasToken()) { throw new LockedException("Doesn't have token for destination folder."); } if (isRecursive(destDavFolder)) { throw new DavException("Cannot copy folder to its subtree", DavStatus.FORBIDDEN); } IHierarchyItem destItem = destDavFolder.FindChild(destName); if (destItem != null) { try { destItem.Delete(multistatus); } catch (DavException ex) { multistatus.AddInnerException(destItem.Path, ex); return; } } DavFolder newDestFolder = CopyThisItem(destDavFolder, null, destName); // copy children if (deep) { foreach (IHierarchyItem child in GetChildren(new PropertyName[0])) { var dbchild = child as DavHierarchyItem; try { dbchild.CopyTo(newDestFolder, child.Name, deep, multistatus); } catch (DavException ex) { multistatus.AddInnerException(dbchild.Path, ex); } } } }
public bool Move(IItemCollection ItemList) { while (ItemList.Count != 0) { if (!Add(ItemList[0])) { return(false); } ItemList.Remove(ItemList[0]); } return(true); }
public bool MoveTo(IItemCollection ItemList) { while (Count != 0) { if (!ItemList.Add(list[0])) { return(false); } Remove(list[0]); } return(true); }
/// <summary> /// Constructor. /// </summary> /// <param name="table">The <see cref="Table{TItem}"/> to filter.</param> /// <param name="filterParams">The filter parameters.</param> public FilteredItemCollection(ITable <TItem> table, TableFilterParams filterParams) : base(table.Items) { _baseCollection = table.Items; _columns = table.Columns; _filterParams = filterParams; _filteredList = _filterParams.Column == null ? GetFilteredItemCollection(AnyColumnMatch) : GetFilteredItemCollection(SingleColumnMatch); _baseCollection.ItemsChanged += BaseItemsChanged; }
/// <summary> /// Get count of item type in collection. /// </summary> /// <param name="me">collection of items</param> /// <param name="type">item type id</param> /// <returns>count</returns> public static int GetCount(this IItemCollection me, string type) { int count = 0; for (int i = 0; i < me.Count; i++) { if (me[i].Type.ID == type) { count++; } } return(count); }
public Construction GetConstruction(Character technician, IItemCollection roomItems, Item mainItem) { int index = 3; // TODO bool canBuild = false; ConstructionInfo construction = FindConstruction(technician.Items, roomItems, mainItem.Type, technician.Class, out canBuild); Conversation conv = new Conversation(); if (construction == null) { conv.Text = ResourceManager.GetStrings("men_" + defaultDialog.ToString("D3") + "?s" + index); } else { conv.Text = ResourceManager.GetStrings("men_" + construction.Dialog.ToString("D3") + "?s" + index); string[] repl = new string[] { "|E", "|F", "|G", "|H" }; for (int i = 0; i < conv.Text.Length; i++) { conv.Text[i] = conv.Text[i].Replace("|I", BurntimeClassic.Instance.Game.ItemTypes[construction.Result].Text); for (int j = 0; j < construction.Items.Length; j++) { conv.Text[i] = conv.Text[i].Replace(repl[j], BurntimeClassic.Instance.Game.ItemTypes[construction.Items[j]].Text); } } } conv.Choices = new ConversationChoice[3]; conv.Choices[0] = new ConversationChoice(); conv.Choices[1] = new ConversationChoice(); if (canBuild) { conv.Choices[1].Action = new ConversationAction(ConversationActionType.Yes); conv.Choices[1].Text = ResourceManager.GetString("burn?501").Replace("|I", BurntimeClassic.Instance.Game.ItemTypes[construction.Result].Text); } conv.Choices[2] = new ConversationChoice(); conv.Choices[2].Action = new ConversationAction(ConversationActionType.No); conv.Choices[2].Text = ResourceManager.GetString("burn?503"); Construction constr = new Construction(); constr.Dialog = conv; constr.construction = construction; return(constr); }
public static int IndexOf(this IItemCollection collection, Item item) { int index = 0; foreach (Item thisItem in collection) { if (thisItem == item) { return(index); } index++; } return(-1); }