Exemplo n.º 1
0
        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);
                }
            }
        }
Exemplo n.º 2
0
 public RequestedItemUnit(ItemType item, int count, bool isDisappearing)
     : base(item, count)
 {
     this.IsDisappearing = isDisappearing;
 }
Exemplo n.º 3
0
 public RequestedItemUnit(ItemType item)
     : this(item, 1, true)
 {
 }
Exemplo n.º 4
0
 public RequestedItemUnit(ItemType item, bool isDisappearing)
     : this(item, 1, isDisappearing)
 {
 }
Exemplo n.º 5
0
 public RequestedItemUnit(ItemType item, int count)
     : this(item, count, true)
 {
 }
Exemplo n.º 6
0
 public ItemTypeModel(ItemType itemType)
 {
     ItemType = itemType;
 }
Exemplo n.º 7
0
        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();
            }
        }
Exemplo n.º 8
0
        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);
        }
Exemplo n.º 9
0
 public void AddNewItem(ItemType item)
 {
     AvailableItems.Add(item);
 }
Exemplo n.º 10
0
 public ItemUnit(ItemType item, int count)
 {
     this.BasicItem = item;
     this.Count = count;
 }
Exemplo n.º 11
0
 public ItemUnit(ItemType basicItem)
     : this(basicItem, 1)
 {
 }