Esempio n. 1
0
    def test_Swap(self):
        self.assertIsNone(container.get_item(self.inv_15, 0))

        container.put_item(self.inv_15, self.sword_1, 0)
        sword1 = container.get_item(self.inv_15, 0)
        sword1_data = sword1.containable
        self.assertEqual(sword1_data.container,
                         self.sword_1.containable.container)
        self.assertEqual(sword1_data.slot, self.sword_1.containable.slot)

        sword2 = container.put_item(self.inv_15, self.dagger_1, 0)
        sword2_data = sword2.containable
        self.assertEqual(sword2_data.container, sword2_data.container)
        self.assertEqual(sword2_data.slot, sword2_data.slot)

        self.assertIsNotNone(container.get_item(self.inv_15, 0))
        dagger_1_container = self.world.get_entity(
            self.dagger_1.containable.container)
        self.assertListEqual(container.get_items(self.inv_15),
                             container.get_items(dagger_1_container))
        self.assertEqual(
            container.get_item(self.inv_15, 0).containable.container,
            self.dagger_1.containable.container)
        self.assertEqual(container.get_item(self.inv_15, 0).containable.slot,
                         self.dagger_1.containable.slot)
Esempio n. 2
0
    def test_PutTakeNoSlots(self):
        self.assertIsNone(container.get_item(self.inv_no_slots, 0))

        container.put_item(self.inv_no_slots, self.sword_1)
        self.assertIsNotNone(container.get_item(self.inv_no_slots,
                                                self.sword_1.containable.slot))
        self.assertIsNotNone(self.sword_1.containable.container)
        sword_1_container = self.world.get_entity(
            self.sword_1.containable.container)
        self.assertListEqual(container.get_items(self.inv_no_slots),
                             container.get_items(sword_1_container))
        self.assertEqual(container.get_item(self.inv_no_slots, 0),
                         self.sword_1)
        container.put_item(self.inv_no_slots, self.axe_2)
        self.assertEqual(self.axe_2.containable.slot, 1)
        container.put_item(self.inv_no_slots, self.mace_1, 5)
        self.assertEqual(self.mace_1.containable.slot, 2)
        self.assertEqual(container.take_item(self.inv_no_slots, 1), self.axe_2)
        self.assertEqual(self.mace_1.containable.slot, 1)
        self.assertEqual(container.take_item(self.inv_no_slots, 1),
                         self.mace_1)
        container.take_item(self.inv_no_slots, 1)
        temp_item = container.get_item(self.inv_no_slots, 0)
        self.assertEqual(temp_item.containable.slot,
                         self.sword_1.containable.slot)

        container.take_item(self.inv_no_slots, 0)
        self.assertIsNone(container.get_item(self.inv_no_slots, 0))
        self.assertEqual(self.sword_1.containable.container, "")
Esempio n. 3
0
 def test_StackSlotBulk(self):
     self.assertIsNone(container.get_item(self.inv_15, 0))
     container.put_item(self.inv_15, self.gold_1, 0)
     self.assertIsNotNone(container.get_item(self.inv_15, 0))
     self.assertIsNotNone(self.gold_1.containable.container)
     self.assertRaises(container.BulkLimitError, container.put_item,
                       self.inv_15, self.gold_2, 1)
     self.assertEqual(self.gold_1.containable.current_stack,
                      20)
     self.assertEqual(self.gold_2.containable.current_stack, 60)
Esempio n. 4
0
    def test_PutTakeSlots(self):
        self.assertIsNone(container.get_item(self.inv_15, 0))

        container.put_item(self.inv_15, self.sword_1, 0)
        self.assertIsNotNone(container.get_item(self.inv_15, 0))
        self.assertIsNotNone(self.sword_1.containable.container)
        sword_1_container = self.world.get_entity(
            self.sword_1.containable.container)
        self.assertListEqual(container.get_items(self.inv_15),
                             container.get_items(sword_1_container))
        self.assertEqual(container.get_item(self.inv_15, 0),
                         self.sword_1)
        self.assertEqual(container.get_item(self.inv_15, 0).containable.slot,
                         self.sword_1.containable.slot)

        container.take_item(self.inv_15, 0)
        self.assertIsNone(container.get_item(self.inv_15, 0))
        self.assertEqual(self.sword_1.containable.container, "")
Esempio n. 5
0
    def test_PutTake(self):
        self.assertIsNone(container.get_item(self.inv_15, 0))

        container.put_item(self.inv_15, self.sword_1, 0)
        self.assertIsNotNone(container.get_item(self.inv_15, 0))
        self.assertIsNotNone(self.sword_1.containable.container)
        sword_1_container = self.world.get_entity(
                                self.sword_1.containable.container)
        self.assertListEqual(self.inv_15.container.children,
                    sword_1_container.container.children)
        self.assertEqual(container.get_item(self.inv_15, 0),
                         self.sword_1)
        self.assertEqual(container.get_item(self.inv_15, 0).containable.slot,
                         self.sword_1.containable.slot)

        container.take_item(self.inv_15, 0)
        self.assertIsNone(self.inv_15.container.children[0])
        self.assertIsNone(self.sword_1.containable.container)
Esempio n. 6
0
    def test_Stack(self):
        self.assertIsNone(container.get_item(self.inv_15, 0))
        container.put_item(self.inv_15, self.gold_1)
        self.assertIsNotNone(container.get_item(self.inv_15, 0))
        self.assertIsNotNone(self.gold_1.containable.container)
        self.assertRaises(container.BulkLimitError, container.put_item,
                          self.inv_15, self.gold_2)
        self.assertEqual(self.gold_1.containable.current_stack,
                         60)
        self.assertEqual(self.gold_2.containable.current_stack, 20)

        self.assertIsNone(container.get_item(self.inv_25, 0))
        container.put_item(self.inv_25, self.gold_3)
        container.put_item(self.inv_25, self.gold_4)
        self.assertEqual(self.gold_3.containable.current_stack, 100)
        self.assertEqual(self.gold_4.containable.current_stack, 0)

        self.reset_gold()

        # Testing if stacks are filled and a the rest put into a new slot
        self.assertIsNone(container.get_item(self.inv_no_slots, 0))
        container.put_item(self.inv_no_slots, self.gold_1)
        container.put_item(self.inv_no_slots, self.gold_4)
        self.assertEqual(self.gold_1.containable.current_stack, 90)
        self.assertEqual(self.gold_4.containable.current_stack, 0)
        container.put_item(self.inv_no_slots, self.gold_2)
        self.assertEqual(self.gold_1.containable.current_stack, 100)
        self.assertEqual(self.gold_2.containable.current_stack, 50)
        self.assertEqual(self.gold_1.containable.slot, 0)
        self.assertEqual(self.gold_2.containable.slot, 1)
        container.put_item(self.inv_no_slots, self.gold_3)
        self.assertEqual(self.gold_2.containable.current_stack, 80)
        self.assertEqual(self.gold_3.containable.current_stack, 0)
        container.put_item(self.inv_no_slots, self.gold_5)
        self.assertEqual(self.gold_2.containable.current_stack, 100)
        self.assertEqual(self.gold_5.containable.current_stack, 20)
        self.assertEqual(self.gold_1.containable.slot, 0)
        self.assertEqual(self.gold_2.containable.slot, 1)
        self.assertEqual(self.gold_5.containable.slot, 2)
Esempio n. 7
0
 def test_StackSlotMerge(self):
     self.assertIsNone(container.get_item(self.inv_25, 0))
     container.put_item(self.inv_25, self.sword_1, 0)
     temp_item = container.put_item(self.inv_25, self.paper_1, 0)
     self.assertEqual(temp_item, self.sword_1)
     temp_item = container.put_item(self.inv_25, self.gold_1, 0)
     self.assertEqual(temp_item, self.paper_1)
     self.assertEqual(self.gold_1.containable.slot,
                      0)
     container.put_item(self.inv_25, self.gold_3, 1)
     self.assertEqual(self.gold_3.containable.slot, 1)
     container.put_item(self.inv_25, self.gold_5, 1)
     self.assertEqual(self.gold_1.containable.current_stack, 20)
     self.assertEqual(self.gold_3.containable.current_stack, 70)
     self.assertEqual(self.gold_5.containable.current_stack, 0)
     self.assertRaises(container.BulkLimitError, container.put_item,
                       self.inv_25, self.gold_2, 1)
     self.assertEqual(self.gold_3.containable.current_stack, 80)
     self.assertEqual(self.gold_2.containable.current_stack, 50)