def test_connect_give(self): give = self.evt_fact.new(objects.GIVE) cont = self.ent_fact.new(objects.NPC) self.world.add_entity(cont) connector = visitor.EventConnector(objects.GIVE, self.world, {}) connector.connect(give) self.assertEqual(give.item_owner, cont)
def test_connect_take(self): take = self.evt_fact.new(objects.TAKE) cont = self.ent_fact.new(objects.NPC) self.world.add_entity(cont) connector = visitor.EventConnector(objects.TAKE, self.world, {}) connector.connect(take) self.assertEqual(take.new_owner, cont)
def test_connect_toggle(self): toggle = self.evt_fact.new(objects.TOGGLE_ACTIVE) cont = self.ent_fact.new(objects.NPC) self.world.add_entity(cont) connector = visitor.EventConnector(objects.TOGGLE_ACTIVE, self.world, {}) connector.connect(toggle) self.assertEqual(toggle.target, cont)
def test_connect_conditional(self): conditional = self.evt_fact.new(objects.CONDITIONAL) connector = visitor.EventConnector( objects.CONDITIONAL, self.world, {objects.QUESTION['id']: objects.QUESTION}) connector.connect(conditional) self.assertEqual(conditional.condition.question, objects.QUESTION['question']) self.assertIs(conditional.success, self.event) self.assertIs(conditional.failure, self.inform)
def test_connect_interaction(self): interaction = self.evt_fact.new(objects.INTERACTION) connector = visitor.EventConnector( objects.INTERACTION, self.world, { objects.QUESTION['id']: objects.QUESTION, objects.INTERACTION['options'][0]['id']: objects.INTERACTION['options'][0], objects.INTERACTION['options'][1]['id']: objects.INTERACTION['options'][1] }) connector.connect(interaction) opt_1 = interaction.options[0] opt_2 = interaction.options[1] self.assertIs(opt_1.event, self.event) self.assertIs(opt_2.event, self.inform)
def test_connect_move(self): connector = visitor.EventConnector(objects.MOVE, self.world, {}) connector.connect(self.move) self.assertIn(self.inform, self.move.subjects) self.assertIs(self.move.destination, self.room)
def test_connect_event(self): connector = visitor.EventConnector(objects.INFORM, self.world, {}) connector.connect(self.inform) self.assertIn(self.event, self.inform.subjects)
def test_connect_group(self): group = self.evt_fact.new(objects.GROUP) connector = visitor.EventConnector(objects.GROUP, self.world, {}) connector.connect(group) self.assertIn(self.event, group.events) self.assertIn(self.inform, group.events)