Exemple #1
0
def put(results: list):
    obj_list, preposition = _extend_with_prep(results)
    if not obj_list or not preposition:
        print("Please specify what you want to do, i.e. \"put coin in box\"")
        return

    if len(obj_list) == 1:
        print(f"{obj_list[0][1].capitalize()} {preposition[0][1]} what?")
        return

    target_one, obj_one = be.guess_object(obj_list[0][1])
    target_two, obj_two = be.guess_object(obj_list[1][1])

    if obj_one is Object.NONEXISTENT or obj_two is Object.NONEXISTENT:
        print("There is no such thing.")
        return

    if preposition[0][0] is Prep.WITHIN:
        if obj_one.is_gettable:
            be.add_item_to(obj_two, obj_one)
            print(f"You put {obj_one.name} in {obj_two.name}.")
        else:
            print("That can't be stored.")
Exemple #2
0
 def test_vicinity(self):
     e = 'Everything in vicinity is active unless concealed.'
     b.add_item_to(self.box, self.ite)
     b.add_item_to(self.roo, self.key, self.box)
     self.assertTrue(len(b.vicinity()) == 3, e)
Exemple #3
0
 def remove_item_from(self):
     e = 'Should pop from contents dict.'
     b.add_item_to(self.box, self.key)
     b.remove_item_from(self.box, self.key)
     self.assertTrue(len(self.box.contents) == 0, e)
Exemple #4
0
 def test_free_item(self):
     e = 'When adding items, should free `parent_container.`'
     b.add_item_to(self.box, self.ite)
     b.add_item_to(self.roo, self.ite)
     case = self.ite.parent_container
     self.assertTrue(case is self.roo, e)
Exemple #5
0
 def test_add_item_to(self):
     e = 'Should take multiple distinct item params.'
     b.add_item_to(self.roo, self.ite, self.ite, self.key)
     self.assertTrue(len(self.roo.contents) == 2, e)