Example #1
0
    def test_can_identify_special_items(self):
        self.assertTrue(
            ItemService.is_special_item(
                Item('Backstage passes to johny concert', 50, 30)))

        self.assertFalse(
            ItemService.is_special_item(Item('passes to john legend', 25, 50)))
Example #2
0
    def test_attribute_is_defined(self):
        self.assertTrue(
            ItemService.item_has_given_attributte(Item('concert', 12, 30),
                                                  'name'))

        self.assertRaises(AttributeError,
                          ItemService.item_has_given_attributte,
                          Item('concert', 12, 30), 'price')
Example #3
0
    def __init__(self, user):
        self.window = Tk()
        self.window.title('Add Items')
        self.window.geometry('500x500+0+0')

        self.item = Item()
        # self.user = user

        self.update_index = ""

        self.item_name = Label(self.window, text="Item Name")
        self.item_name.grid(row=0, column=0)

        self.entry_name = Entry(self.window)
        self.entry_name.grid(row=0, column=1)

        self.item_type = Label(self.window, text="Item Type")
        self.item_type.grid(row=1, column=0)

        self.entry_type = Entry(self.window)
        self.entry_type.grid(row=1, column=1)

        self.item_rate = Label(self.window, text="Item Rate")
        self.item_rate.grid(row=2, column=0)

        self.entry_rate = Entry(self.window)
        self.entry_rate.grid(row=2, column=1)

        self.item_add = Button(self.window,
                               text="Add Item",
                               command=self.add_item)
        self.item_add.grid(row=3, column=0)

        self.item_update = Button(self.window,
                                  text="Update Item",
                                  command=self.update_item)
        self.item_update.grid(row=3, column=1)

        self.item_tree = ttk.Treeview(self.window,
                                      columns=('name', 'type', 'rate'))
        self.item_tree.grid(row=4, column=0, columnspan=2)
        self.item_tree['show'] = 'headings'
        self.item_tree.column('name', width=100)
        self.item_tree.column('type', width=100)
        self.item_tree.column('rate', width=100)
        self.item_tree.heading('name', text="Name")
        self.item_tree.heading('type', text="Type")
        self.item_tree.heading('rate', text="Rate")

        self.item_type = Label(self.window, text="Welcome ")
        self.item_type.grid(row=5, column=0)

        self.show_item_tree()
        self.show_menu()

        self.window.mainloop()
Example #4
0
    def test_can_reduce_item_sell_in(self):
        item = Item("Sulfuras", 20, 80)
        item2 = Item("AgedBrie", "20", 50)

        expected_value = item.sell_in - 1

        self.assertTrue(
            ItemService.reduce_item_sell_in(item) == expected_value)

        self.assertRaises(TypeError, ItemService.reduce_item_sell_in, item2)
Example #5
0
    def test_can_update_backstage(self):
        item = Item("Backstage passes to johny", 5, 35)
        expected_value = 38

        item2 = Item("Backstage passes to johny", 0, 50)
        expected_value2 = 0

        self.assertTrue(
            BackstageService.update_item_quality(item) == expected_value)

        self.assertTrue(
            BackstageService.update_item_quality(item2) == expected_value2)
 def test_can_update_item_quality(self):
     item = Item("passes to johnny", 25, 25)
     expected_quality = item.quality - 1
     expected_sell_in = item.sell_in - 1
     self.assertTrue(
         StandardItemService.update_item_quality(item) == (
             expected_quality, expected_sell_in))
Example #7
0
    def __init__(self, x, y, char, name, color, blocks=False,\
        always_visible=False, fighter=None, ai=None, item=None, equipment=None):
        self.x = x
        self.y = y
        self.char = char
        self.name = name
        self.color = color
        self.blocks = blocks
        self.always_visible = always_visible

        self.fighter = fighter
        if self.fighter:  #let the fighter component know who owns it
            self.fighter.owner = self

        self.ai = ai
        if self.ai:  #let the AI component know who owns it
            self.ai.owner = self

        self.item = item
        if self.item:  #let the Item component know who owns it
            self.item.owner = self

        self.equipment = equipment
        if self.equipment:  # let the Equipment component know who owns it
            self.equipment.owner = self

            # there must be and Item component for the Equipment component to work properly
            self.item = Item()
            self.item.owner = self
    def test_can_update_conjured_items_quality(self):
        item = Item("Conjured", 25, 35)

        expected_quality = 33

        self.assertTrue(
            ConjuredService.update_quality(item) == expected_quality)
    def test_can_set_agedBrie_quality(self):
        item = Item("Aged Brie", 25, 30)
        q_value = -10

        self.assertTrue(AgedBrieService.set_item_quality(item, q_value) == 0)

        self.assertTrue(AgedBrieService.increase_item_quality(item, 100) < 50)
Example #10
0
    def test_can_increase_backstage_item_quality(self):
        item = Item("Backstage passes to johny", 50, 50)
        value_to_add = 3
        expected_val = 50

        self.assertTrue(
            BackstageService.increase_item_quality(item, value_to_add) ==
            expected_val)
Example #11
0
    def test_canInstantiateItem(self):
        item = Item("Sulfuras", 50, 80)

        self.assertTrue(hasattr(item, "sell_in"))

        self.assertTrue(hasattr(item, "quality"))

        self.assertTrue(hasattr(item, "name"))
Example #12
0
    def test_can_update_sulfura_item(self):
        item = Item("Sulfuras", 25, 50)
        sell_in_expected = item.sell_in - 1
        quality_expected = 80

        self.assertTrue(
            SulfuraService.update_item(item) == (quality_expected,
                                                 sell_in_expected))
    def test_can_set_conjured_item_quality(self):
        item = Item("Conjured", 25, 35)
        q_value = 100

        expected_quality = 50

        self.assertTrue(
            ConjuredService.set_item_quality(item, q_value) ==
            expected_quality)
Example #14
0
    def makeSpells(self):
        cur = self.getCursor()
        query = "select name, attr, qt, setid from spells " + self.makeSQLWhere(
        )
        cur.execute(query)
        rows = cur.fetchall()

        spellsList = []

        for row in rows:
            item = Item()
            item.name = row["name"]
            item.attributes = row["attr"].split(", ")

            for i in range(0, row["qt"]):
                spellsList.append(item)

        return spellsList
    def test_can_reduce_conjured_item_quality(self):
        item = Item("Conjured", 25, 35)

        value_to_reduce = 2

        expected_quality = 33

        self.assertTrue(
            ConjuredService.reduce_item_quality(item, value_to_reduce) ==
            expected_quality)
Example #16
0
def create_item(item_dict):
    name = item_dict["name"]
    description = item_dict["description"]
    mass = item_dict.get("mass",1)
    value = item_dict.get("value",0)
    droppable = item_dict.get("droppable",False)

    item_object = Item(name, description, mass, value, droppable)

    return item_object
Example #17
0
    def test_identify_aged_brie_type(self):
        item = Item('Aged Brie', 25, 50)

        item2 = Item("sulfuras", 35, 50)

        item3 = Item("conjured", 35, 50)

        item4 = Item("Backstage passes to johny concert", 35, 50)

        item5 = Item('passes to john legend', 25, 50)

        self.assertTrue(ItemService.is_aged_brie, item)

        self.assertTrue(ItemService.is_item_sulfuras, item2)

        self.assertFalse(ItemService.is_aged_brie(item2))

        self.assertTrue(ItemService.is_item_conjured, item3)

        self.assertTrue(ItemService.is_item_back_stage(item4))

        self.assertFalse(ItemService.is_item_back_stage(item5))
    def test_can_update_items(self):
        current_time = "00:00:00"
        items = [
            Item("Sulfuras", 20, 40),
            Item("Conjured", 25, 60),
            Item("Backstage passes to johny", 2, 46)
        ]

        expected_first_item = Item("Sulfuras", 19, 80)
        expected_second_item = Item("Conjured", 24, 50)
        tirth_expeted_item = Item("Backstage passes to johny", 1, 49)

        new_items_list = GildedRose.update_items(items, current_time)

        self.assertTrue(
            ItemService.are_item_equal(new_items_list[0], expected_first_item))

        self.assertTrue(
            ItemService.are_item_equal(new_items_list[1],
                                       expected_second_item))

        self.assertTrue(
            ItemService.are_item_equal(new_items_list[2], tirth_expeted_item))
Example #19
0
    def test_can_compare_two_items(self):
        item = Item('Aged Brie', 25, 50)

        item2 = Item('Aged Brie', 25, 50)

        self.assertTrue(ItemService.are_item_equal(item, item2))
Example #20
0
def get_item(id_num):
    if Connection.Mysql.isHealth() == True:
        return Item.get_items(request.args.get('from'), request.args.get('to'),
                              id_num)
    return "Error: DB Connection"
Example #21
0
 def __init__(this, drink):
     this.number = drink["number"]
     this.item_id = drink["item_id"]
     Item.__init__(this, drink["drink_name"])
Example #22
0
 def __init__(this, pizza):
     this.size = pizza["size"]
     this.toppings = pizza["toppings"]
     this.number = pizza["number"]
     this.item_id = pizza["item_id"]
     Item.__init__(this, pizza["type"])
Example #23
0
class ItemView:
    def __init__(self, user):
        self.window = Tk()
        self.window.title('Add Items')
        self.window.geometry('500x500+0+0')

        self.item = Item()
        # self.user = user

        self.update_index = ""

        self.item_name = Label(self.window, text="Item Name")
        self.item_name.grid(row=0, column=0)

        self.entry_name = Entry(self.window)
        self.entry_name.grid(row=0, column=1)

        self.item_type = Label(self.window, text="Item Type")
        self.item_type.grid(row=1, column=0)

        self.entry_type = Entry(self.window)
        self.entry_type.grid(row=1, column=1)

        self.item_rate = Label(self.window, text="Item Rate")
        self.item_rate.grid(row=2, column=0)

        self.entry_rate = Entry(self.window)
        self.entry_rate.grid(row=2, column=1)

        self.item_add = Button(self.window,
                               text="Add Item",
                               command=self.add_item)
        self.item_add.grid(row=3, column=0)

        self.item_update = Button(self.window,
                                  text="Update Item",
                                  command=self.update_item)
        self.item_update.grid(row=3, column=1)

        self.item_tree = ttk.Treeview(self.window,
                                      columns=('name', 'type', 'rate'))
        self.item_tree.grid(row=4, column=0, columnspan=2)
        self.item_tree['show'] = 'headings'
        self.item_tree.column('name', width=100)
        self.item_tree.column('type', width=100)
        self.item_tree.column('rate', width=100)
        self.item_tree.heading('name', text="Name")
        self.item_tree.heading('type', text="Type")
        self.item_tree.heading('rate', text="Rate")

        self.item_type = Label(self.window, text="Welcome ")
        self.item_type.grid(row=5, column=0)

        self.show_item_tree()
        self.show_menu()

        self.window.mainloop()

    def add_item(self):
        name = self.entry_name.get()
        type = self.entry_type.get()
        rate = self.entry_rate.get()
        if self.validate():
            if self.item.add_item(name, type, rate):
                # messagebox.showinfo('Item', "Item Added")
                # self.show_item_tree()
                return True
            else:
                # messagebox.showerror("Error", self.item.add_item(name, type, rate))
                return False

    def update_item(self):
        if self.update_index == "":
            messagebox.showerror("Error", "Please select a row first")
        else:
            name = self.entry_name.get()
            type = self.entry_type.get()
            rate = self.entry_rate.get()
            if self.item.update_item(self.update_index, name, type, rate):
                messagebox.showinfo('Item', "Item Updated")
                self.show_item_tree()
                self.update_index = ""
            else:
                messagebox.showerror("Error", 'Can not be updated !!!')

    def show_item_tree(self):
        self.item_tree.delete(*self.item_tree.get_children())
        data = self.item.show_item()
        for i in data:
            self.item_tree.insert("",
                                  "end",
                                  text=i[0],
                                  value=(i[1], i[2], i[3]))
        self.item_tree.bind("<Double-1>", self.on_item_select)

    def on_item_select(self, event):
        selected_row = self.item_tree.selection()[0]
        selected_item = self.item_tree.item(selected_row, 'values')
        self.update_index = self.item_tree.item(selected_row, 'text')
        self.entry_name.delete(0, END)
        self.entry_name.insert(0, selected_item[0])
        self.entry_type.delete(0, END)
        self.entry_type.insert(0, selected_item[1])
        self.entry_rate.delete(0, END)
        self.entry_rate.insert(0, selected_item[2])

    def open_order_window(self):
        OrderView()

    def show_menu(self):
        my_menu = Menu(self.window)
        self.window.config(menu=my_menu)
        order_menu = Menu(my_menu)
        my_menu.add_cascade(label="Order", menu=order_menu)

        order_menu.add_cascade(label="Add", command=self.open_add_order)
        order_menu.add_cascade(label="Show")
        order_menu.add_separator()
        order_menu.add_cascade(label="Exit", command=self.window.quit)

        bill_menu = Menu(my_menu)
        my_menu.add_cascade(label="Bill", menu=bill_menu)

        bill_menu.add_cascade(label="Generate")
        bill_menu.add_cascade(label="Show")

    def open_add_order(self):
        OrderView()

    def validate(self):
        name = self.entry_name.get()
        type = self.entry_type.get()
        rate = self.entry_rate.get()
        if name == '' or type == '' or rate == '':
            messagebox.showerror('Error', 'Fill all the fields')
            return False
        elif not rate.isdigit():
            messagebox.showerror('Error', 'Invalid value for rate')
            return False
        else:
            return True
Example #24
0
    def can_back_stage_item_quality(self):
        item = Item("Backstage passes to johny", 25, 30)
        q_value = 100

        self.assertTrue(BackstageService.set_item_quality(item, q_value) == 50)
Example #25
0
    @staticmethod
    def is_end_of_the_day(my_time):
        return GildedRose.time_in_right_format(
            my_time) and my_time == "00:00:00"

    @staticmethod
    def update_items(items, current_time):
        if GildedRose.is_end_of_the_day(current_time):
            for item in items:
                if ItemService.is_item_conjured(item):
                    ConjuredService.update_quality(item)
                elif ItemService.is_item_back_stage(item):
                    BackstageService.update_item_quality(item)
                elif ItemService.is_item_sulfuras(item):
                    SulfuraService.update_item(item)
                elif ItemService.is_aged_brie(item):
                    AgedBrieService.update_item(item)
                elif not ItemService.is_special_item(item):
                    StandardItemService.update_item_quality(item)
            return items


if __name__ == '__main__':
    while True:
        items = [
            Item("Sulfuras", 20, 40),
            Item("Conjured", 25, 60),
            Item("Backstage passes to johny", 2, 46)
        ]
        GildedRose.update_items(items, datetime.now().strftime('%H:%M:%S'))
 def test_can_update_agedBrie_items(self):
     item = Item("Aged Brie", 20, 30)
     expected_quality = item.quality + 1
     sell_in_expected = item.sell_in - 1
     self.assertTrue(AgedBrieService.update_item(item) == (expected_quality, sell_in_expected))
Example #27
0
def test_new_item():
    item = Item("Coke")
    assert item.type == "Coke"
Example #28
0
    def test_can_set_sulfuras_item_quality(self):
        item = Item("Sulfuras", 25, 50)

        self.assertTrue(SulfuraService.set_item_quality(item) == 80)
Example #29
0
    def test_can_detect_items_of_valid_type(self):
        self.assertRaises(TypeError, ItemService.is_item_valid, 'item')

        self.assertTrue(ItemService.is_item_valid, Item('Sulfuras', 20, 80))
Example #30
0
print("                    _________________________             __________")
print("Valos:    1200/1200|█████████████████████████|      65/65|██████████|")

#Create Black Magic
fire = Magic("Fire", 10, 100, "Black")
thunder = Magic("Thunder", 12, 124, "Black")
blizzard = Magic("Blizzard", 10, 100, "Black")
meteor = Magic("Meteor", 20, 200, "Black")
quake = Magic("Quake", 14, 140, "Black")

#Create White Magic
cure = Magic("Cure", 12, 120, "White")
cura = Magic("Cura", 18, 200, "White")

#Create Item
potion = Item("Potion", "potion", "Heals 50 hp", 50)
hiPotion = Item("Hi - Potion", "potion", "Heals 100 hp", 100)
superPotion = Item("Super Potion", "potion", "Heals 500 hp", 500)
elixer = Item("Elixer", "elixer", "Fully restores hp/mp of one party member",
              9999)
hiElixier = Item("Hi - Elixer", "elixer", "Fully restores party's hp/mp", 9999)

grenade = Item("Grenade", "attack", "Deals 500 damage", 500)

playerSpells = [fire, thunder, blizzard, meteor, cure, cura]
playerItems = [{
    "item": potion,
    "quantity": 5
}, {
    "item": hiPotion,
    "quantity": 5