static void Main(string[] args) { List<SimpleEdge> edges = new List<SimpleEdge>(); /*edges.Add(new SimpleEdge(0, 1)); edges.Add(new SimpleEdge(1, 2)); edges.Add(new SimpleEdge(2, 0)); edges.Add(new SimpleEdge(1, 3)); Book book = new Book("book1", 4, edges); ItemType it = new ItemType("item1", true); book.AddNewItem(it); var x = book.GetEdges(1, 3).First(); x.AddRequestedItem(new RequestedItemUnit(it)); book.GetParagraph(2).AddRecievedItem(new ItemUnit(it));*/ edges.Add(new SimpleEdge(0, 1)); edges.Add(new SimpleEdge(0, 2)); edges.Add(new SimpleEdge(1, 3)); edges.Add(new SimpleEdge(2, 3)); edges.Add(new SimpleEdge(2, 4)); edges.Add(new SimpleEdge(4, 3)); edges.Add(new SimpleEdge(3, 5)); edges.Add(new SimpleEdge(5, 3)); edges.Add(new SimpleEdge(3, 6)); Book book = new Book("book1", 7, edges); ItemType gold = new ItemType("gold", false); ItemType am = new ItemType("am", true); book.GetEdges(0, 1).First().AddRequestedItem(new RequestedItemUnit(gold, 2)); book.GetEdges(3, 5).First().AddRequestedItem(new RequestedItemUnit(gold, 1)); book.GetEdges(3, 6).First().AddRequestedItem(new RequestedItemUnit(am, 4)); book.GetParagraph(1).AddRecievedItem(new ItemUnit(am, 1)); book.GetParagraph(4).AddRecievedItem(new ItemUnit(am, 1)); book.GetParagraph(5).AddRecievedItem(new ItemUnit(am, 1)); var searchResults = book.RunSearch(new PersonState(0, new List<ItemUnit> { new ItemUnit(gold, 3) })); using (TextWriter writer = File.CreateText("output.txt")) { foreach (var result in searchResults) { writer.WriteLine("{0} Distance: {1}", result.Key, result.Value); } } }
public RequestedItemUnit(ItemType item, int count, bool isDisappearing) : base(item, count) { this.IsDisappearing = isDisappearing; }
public RequestedItemUnit(ItemType item) : this(item, 1, true) { }
public RequestedItemUnit(ItemType item, bool isDisappearing) : this(item, 1, isDisappearing) { }
public RequestedItemUnit(ItemType item, int count) : this(item, count, true) { }
public ItemTypeModel(ItemType itemType) { ItemType = itemType; }
private void AddNewItemExecute() { if (!string.IsNullOrEmpty(NewItemName)) { // TODO: Change constructor var newItem = new ItemType(NewItemName, NewItemIsUnique, NewItemIsVital); m_Book.AvailableItems.Add(newItem); Items.Add(new ItemTypeModel(newItem)); AddNewItemCommand.RaiseCanExecuteChanged(); } }
public void RemoveItem(ItemType itemType) { foreach (var paragraph in Paragraphs) { paragraph.RecievedItems.RemoveAll(item => item.BasicItem == itemType); } foreach (var edges in m_Edges.Values) { foreach (var edge in edges) { edge.RecievedItems.RemoveAll(item => item.BasicItem == itemType); edge.RequestedItems.RemoveAll(item => item.BasicItem == itemType); } } AvailableItems.Remove(itemType); }
public void AddNewItem(ItemType item) { AvailableItems.Add(item); }
public ItemUnit(ItemType item, int count) { this.BasicItem = item; this.Count = count; }
public ItemUnit(ItemType basicItem) : this(basicItem, 1) { }