def test_share_knowledge(self): shared_card = PlayerCard('London', 'Blue') unshared_card = PlayerCard('Moscow', 'Black') self.character.hand = [shared_card, unshared_card] self.character.set_location('London') self.other_character.set_location('London') self.character.action_count = 4 success = self.character.share_knowledge('London', self.other_character) self.assertTrue(success) self.assertNotIn(shared_card, self.character.hand) self.assertIn(shared_card, self.other_character.hand) self.assertEqual(3, self.character.action_count) success = self.character.share_knowledge('London', self.other_character) self.assertTrue(success) self.assertNotIn(shared_card, self.other_character.hand) self.assertIn(shared_card, self.character.hand) self.assertEqual(2, self.character.action_count) success = self.character.share_knowledge('Moscow', self.other_character) self.assertFalse(success) self.assertNotIn(unshared_card, self.other_character.hand) self.assertIn(unshared_card, self.character.hand) self.assertEqual(2, self.character.action_count)
def setUp(self): random.seed(42) self.game = Game() self.character = Character('Alice') self.game.add_character(self.character) self.game.setup_game(self.settings) self.character.set_location('London') self.character.action_count = 4 self.character.hand = [ PlayerCard('London', 'Blue'), PlayerCard('New York', 'Yellow') ]
def test_check_direct_flight(self): self.character.set_location('London') self.character.hand = [PlayerCard('Moscow', 'Black')] self.character.action_count = 4 self.assertFalse(self.character.check_direct_flight( 'London', 'Bejing')) self.assertTrue(self.character.check_direct_flight('London', 'Moscow')) self.assertFalse( self.character.check_direct_flight('New York', 'Moscow')) self.character.action_count = 0 self.assertFalse(self.character.check_direct_flight( 'London', 'Moscow'))
def test_check_share_knowledge(self): self.character.hand = [ PlayerCard('London', 'Blue'), PlayerCard('Moscow', 'Black') ] self.character.set_location('London') self.other_character.set_location('London') self.assertFalse( self.character.check_share_knowledge('London', self.other_character)) self.character.action_count = 4 self.assertTrue( self.character.check_share_knowledge('London', self.other_character)) self.assertFalse( self.character.check_share_knowledge('Moscow', self.other_character)) self.assertFalse( self.character.check_share_knowledge('London', self.character)) self.other_character.hand.append(self.character.hand.pop(0)) self.assertTrue( self.character.check_share_knowledge('London', self.other_character)) self.other_character.set_location('New York') self.assertFalse( self.character.check_share_knowledge('London', self.other_character)) self.character.set_location('New York') self.assertFalse( self.character.check_share_knowledge('New York', self.other_character))