def setUp(self): super().setUp() self.sale_item = Actor(self.game, "kate") self.actor = Actor(self.game, "dmitri") self.currency = Thing(self.game, "penny") self.me.addThing(self.currency) self.actor.addSelling(self.sale_item, self.currency, 2, 1) self.start_room.addThing(self.actor) self.sale_item.makeKnown(self.me)
def setUp(self): super().setUp() self.sale_item = Thing(self.game, "bulb") self.actor1 = Actor(self.game, "dmitri") self.actor2 = Actor(self.game, "kate") self.currency = Thing(self.game, "penny") self.me.addThing(self.sale_item) self.actor1.addWillBuy(self.sale_item, self.currency, 1, 1) self.start_room.addThing(self.actor1) self.start_room.addThing(self.actor2)
def setUp(self): super().setUp() self.sale_item = Thing(self.game, "bulb") self.actor1 = Actor(self.game, "Dmitri") self.actor2 = Actor(self.game, "Kate") self.currency = Thing(self.game, "penny") self.me.addThing(self.currency) self.actor1.addSelling(self.sale_item, self.currency, 1, 1) self.start_room.addThing(self.actor1) self.start_room.addThing(self.actor2) self.sale_item.makeKnown(self.me)
def setUp(self): super().setUp() self.actor1 = Actor(self.game, "grocer") self.actor1.can_be_led = True self.start_room.addThing(self.actor1) self.room2 = Room(self.game, "Place", "Words") self.start_room.north = self.room2
def setUp(self): super().setUp() self.item = Thing(self.game, "mess") self.actor = Actor(self.game, "Jenny") self.start_room.addThing(self.item) self.start_room.addThing(self.actor) self.CANNOT_TALK_MSG = "You cannot talk to that. " self.topic = Topic(self.game, '"Ah, yes," says Jenny mysteriously. ')
def setUp(self): super().setUp() self.sale_item = Thing(self.game, "widget") self.actor = Actor(self.game, "Dmitri") self.currency = Thing(self.game, "penny") self.me.addThing(self.currency) self.actor.addSelling(self.sale_item, self.currency, 1, True) self.start_room.addThing(self.actor) self.sale_item.makeKnown(self.me)
def setUp(self): super().setUp() self.sale_item = Thing(self.game, "widget") self.sale_item.makeKnown(self.me) self.actor = Actor(self.game, "Dmitri") self.me.addThing(self.sale_item) self.start_room.addThing(self.actor) self.BASE_DOES_NOT_WANT_MSG = "doesn't want to buy"
def test_gets_correct_objects_with_adjacent_dobj_iobj(self): dobj_item = Actor(self.game, self._get_unique_noun()) self.start_room.addThing(dobj_item) iobj_item = Thing(self.game, self._get_unique_noun()) self.start_room.addThing(iobj_item) self.game.turnMain(f"give {dobj_item.name} {iobj_item.name}") self.assertEqual(self.game.parser.command.dobj.target, dobj_item) self.assertEqual(self.game.parser.command.iobj.target, iobj_item)
def setUp(self): super().setUp() self.sale_item = Thing(self.game, "widget") self.actor = Actor(self.game, "Dmitri") self.currency = Thing(self.game, "penny") self.me.addThing(self.currency) self.actor.addSelling(self.sale_item, self.currency, 1, 1) self.start_room.addThing(self.actor) self.sale_item.makeKnown(self.me) self.OUT_STOCK_MSG = "That item is out of stock. "
def test_gets_correct_verb_with_dobj_and_direction_iobj(self): dobj = Actor(self.game, self._get_unique_noun()) self.start_room.addThing(dobj) iobj = "east" self.start_room.east = self.start_room self.game.turnMain(f"lead {dobj.name} {iobj}") self.assertIs(self.game.parser.command.verb, LeadDirVerb) self.assertIs(self.game.parser.command.dobj.target, dobj) self.assertEqual(self.game.parser.command.iobj.target, iobj)
def setUp(self): super().setUp() self.sale_item = Thing(self.game, "widget") self.sale_item.makeKnown(self.me) self.actor = Actor(self.game, "dmitri") self.currency = Thing(self.game, "penny") self.me.addThing(self.sale_item) self.me.addThing(self.sale_item.copyThing()) self.actor.addWillBuy(self.sale_item, self.currency, 1, 1) self.start_room.addThing(self.actor) self.BASE_DOES_NOT_WANT_MORE_MSG = "will not buy any more"
def setUp(self): super().setUp() self.actor = Actor(self.game, "girl") self.actor.moveTo(self.start_room) self.item = Thing(self.game, "mess") self.item.moveTo(self.start_room) self.CANNOT_TALK_MSG = "You cannot talk to that. " self.topic = Topic(self.game, '"Ah, yes," says the girl mysteriously. ') self.sticky_topic = Topic( self.game, '"But remember about the thing!" insists the girl. ') self.game.turnMain("l")
def test_verb_by_objects_no_near_matches_unrecognized_noun(self): sarah1 = Actor(self.game, "teacher") sarah1.setAdjectives(["good"]) self.start_room.addThing(sarah1) sarah2 = Actor(self.game, "teacher") sarah2.setAdjectives(["bad"]) self.start_room.addThing(sarah2) self.game.turnMain("hi teacher") self.assertTrue(self.game.parser.command.ambiguous) self.game.turnMain("set green sarah") msg = self.app.print_stack.pop() expected = "I understood as far as" self.assertIn( expected, msg, "Unexpected response attempting to disambiguate verb with unrecognized " "noun.", )
def test_create_Actor(self): item = Actor(self.game, Actor.__name__) self.assertTrue(item.ix) self.assertIn( item.ix, self.game.ifp_objects, f"Tried to create a {Actor.__name__}, but index not in things obj_map", ) self.assertIs( self.game.ifp_objects[item.ix], item, f"New {Actor.__name__} index successfully added to " f"object_map, but {self.game.ifp_objects[item.ix]} found under key instead of " f"the new instance {item}", )
def setUp(self): super().setUp() self.actor = Actor(self.game, "shepherd") self.actor.moveTo(self.start_room) self.verb_keyword = "ask" self.subject_phrase = "how come" suggestion = " ".join([self.verb_keyword, self.subject_phrase]) self.text = "He shakes his head sadly." topic = SpecialTopic(self.game, suggestion, self.text) self.actor.addSpecialTopic(topic) self.game.turnMain("hi")
def test_accept_suggestion(self): girl = Actor(self.game, "girl") TOPIC_SUGGESTION = "ask what her name is" TOPIC_TEXT = '"It\'s Karen," says the girl.' topic = SpecialTopic(self.game, TOPIC_SUGGESTION, TOPIC_TEXT) girl.addSpecialTopic(topic) self.start_room.addThing(girl) self.game.turnMain("talk to girl") self.assertTrue(self.game.parser.command.specialTopics) self.game.turnMain(TOPIC_SUGGESTION) msg = self.app.print_stack.pop(-2) self.assertEqual( msg, TOPIC_TEXT, "Expected topic text to print after accepting suggestion" )
def test_look_through_person(self): item = Actor(self.game, "dude") item.moveTo(self.start_room) self.game.turnMain("look through dude") self.assertIn("cannot look through the dude", self.app.print_stack.pop())
startroom.exit = shackdoor beach.entrance = shackdoor # Attic attic = Room(game, "Shack, attic", "You are in a dim, cramped attic. ") shackladder = LadderConnector(game, startroom, attic) shackladder.entrance_a.description = ( "Against the north wall is a ladder leading up to the attic. ") startroom.north = shackladder silverkey.moveTo(attic) # CHARACTERS # Sarah sarah = Actor(game, "Sarah") sarah.makeProper("Sarah") sarah.moveTo(startroom) def sarahOpalFunc(game, dobj): """ IntFicPy verbs can be overridden or customized for specific items. To do this, find the verb you want to customize in the intficpy.verb module. Note 1) the class name of the verb 2) whether its verbFunc method takes just a "dobj" (direct object) parameter, or an "iobj" (indirect object) as well For instance, GetVerb (as in, "get opal") takes only a direct object (here, "opal"), while GiveVerb (as in, "give opal to Sarah") takes an indirect object as well (here, "Sarah")
def setUp(self): super().setUp() self.actor = Actor(self.game, "girl") self.actor.moveTo(self.start_room)
def setUp(self): super().setUp() self.actor1 = Actor(self.game, "grocer") self.start_room.addThing(self.actor1)
def setUp(self): super().setUp() self.actor = Actor(self.game, "girl") self.item = Thing(self.game, "item") self.item.moveTo(self.actor)