Esempio n. 1
0
    def setUp(self):
        super(InformationRunOrderTest, self).setUp()

        self.p2 = Player(game=self.g, secrets="Some nasty sfuff")
        self.p2.save()
        self.p2.citizenship.corporation = self.c
        self.p2.citizenship.save()

        from engine_modules.influence.models import BuyInfluenceOrder

        # Initial setup, create a resolution sheet we'll use later.
        o = BuyInfluenceOrder(player=self.p2)
        o.save()

        self.g.resolve_current_turn()

        self.io = InformationOrder(
            target=self.p2,
            player=self.p,
            additional_percents=0,
        )
        self.io.clean()
        self.io.save()

        self.set_to_zero(self.io.target.citizenship.corporation)
Esempio n. 2
0
	def setUp(self):
		super(InformationRunOrderTest, self).setUp()

		self.p2 = Player(game=self.g, secrets="Some nasty sfuff")
		self.p2.save()
		self.p2.citizenship.corporation = self.c
		self.p2.citizenship.save()

		from engine_modules.influence.models import BuyInfluenceOrder

		# Initial setup, create a resolution sheet we'll use later.
		o = BuyInfluenceOrder(
			player=self.p2
		)
		o.save()

		self.g.resolve_current_turn()

		self.io = InformationOrder(
			target=self.p2,
			player=self.p,
			additional_percents=0,
		)
		self.io.clean()
		self.io.save()

		self.set_to_zero(self.io.target.citizenship.corporation)
Esempio n. 3
0
	def test_information_run_cant_target_self(self):
		"""
		Check a Johnson can't target himself
		"""
		o = InformationOrder(
			target=self.p,
			player=self.p,
		)
		self.assertRaises(OrderNotAvailable, o.clean)
Esempio n. 4
0
	def test_double_information_gives_logs(self):
		"""
		Sending the same information run twice should not crash (not add concernedplayer twice)
		"""
		self.io.player_targets.add(self.p2)
		self.io2 = InformationOrder(
			player=self.p,
			additional_percents=10,
		)
		self.io2.clean()
		self.io2.save()
		self.io2.player_targets.add(self.p2)

		self.g.resolve_current_turn()

		self.assertEqual(len(Log.objects.for_player(self.p2, self.p, self.g.current_turn).filter(Q(event_type=self.g.OPE_SABOTAGE) | Q(event_type=self.g.OPE_SABOTAGE_FAIL))), 1)
Esempio n. 5
0
	def setUp(self):
		super(InformationRunOrderTest, self).setUp()

		self.p2 = Player(game=self.g)
		self.p2.save()

		from engine_modules.corporation_run.models import SabotageOrder

		# Initial setup, create logs we'll use later.
		o = SabotageOrder(
			player=self.p2,
			target_corporation_market=self.c.get_random_corporation_market_among_bests()
		)
		o.save()

		self.io = InformationOrder(
			player=self.p,
		)
		self.io.clean()
		self.io.save()
Esempio n. 6
0
class InformationRunOrderTest(RunOrdersTest):
	def setUp(self):
		super(InformationRunOrderTest, self).setUp()

		self.p2 = Player(game=self.g, secrets="Some nasty sfuff")
		self.p2.save()
		self.p2.citizenship.corporation = self.c
		self.p2.citizenship.save()

		from engine_modules.influence.models import BuyInfluenceOrder

		# Initial setup, create a resolution sheet we'll use later.
		o = BuyInfluenceOrder(
			player=self.p2
		)
		o.save()

		self.g.resolve_current_turn()

		self.io = InformationOrder(
			target=self.p2,
			player=self.p,
			additional_percents=0,
		)
		self.io.clean()
		self.io.save()

		self.set_to_zero(self.io.target.citizenship.corporation)

	def tearDown(self):
		self.set_to_original(self.io.target.citizenship.corporation)

	def test_information_success(self):
		"""
		Information yields players data
		"""
		self.io.additional_percents = 10
		self.io.save()
		# Save message
		p2_resolution_message = self.p2.message_set.get(flag=Message.RESOLUTION, turn=1).content
		p2_resolution_message_formatted = p2_resolution_message.replace('# ', '## ')

		self.g.resolve_current_turn()

		p_results = self.p.message_set.get(flag=Message.PRIVATE_MESSAGE).content

		self.assertIn("Tour 1", p_results)
		self.assertIn(self.p2.secrets, p_results)
		self.assertNotIn("Tour 2", p_results)  # Current turn not included

		self.assertIn(p2_resolution_message_formatted, p_results)

	def test_information_failure(self):
		"""
		Failed information should not give information
		"""
		self.io.hidden_percents -= 10
		self.io.save()
		self.g.resolve_current_turn()

		self.assertRaises(Message.DoesNotExist, lambda: self.p.message_set.get(flag=Message.PRIVATE_MESSAGE))
Esempio n. 7
0
class InformationRunOrderTest(EngineTestCase):
	def setUp(self):
		super(InformationRunOrderTest, self).setUp()

		self.p2 = Player(game=self.g)
		self.p2.save()

		from engine_modules.corporation_run.models import SabotageOrder

		# Initial setup, create logs we'll use later.
		o = SabotageOrder(
			player=self.p2,
			target_corporation_market=self.c.get_random_corporation_market_among_bests()
		)
		o.save()

		self.io = InformationOrder(
			player=self.p,
		)
		self.io.clean()
		self.io.save()

	def test_no_information_gives_no_logs(self):
		"""
		No information run == no logs for target player.
		Just a sanity check
		"""
		self.io.delete()

		self.g.resolve_current_turn()

		# Sanity check: no information run, no knownloedge on player 2 action
		self.assertEqual(len(Log.objects.for_player(self.p2, self.p, self.g.current_turn)), 0)

	def test_information_on_player_gives_logs(self):
		"""
		Information run gives information about the sabotage
		"""
		self.io.player_targets.add(self.p2)
		self.g.resolve_current_turn()

		self.assertEqual(len(Log.objects.for_player(self.p2, self.p, self.g.current_turn).filter(Q(event_type=self.g.OPE_SABOTAGE) | Q(event_type=self.g.OPE_SABOTAGE_FAIL))), 1)

	def test_double_information_gives_logs(self):
		"""
		Sending the same information run twice should not crash (not add concernedplayer twice)
		"""
		self.io.player_targets.add(self.p2)
		self.io2 = InformationOrder(
			player=self.p,
			additional_percents=10,
		)
		self.io2.clean()
		self.io2.save()
		self.io2.player_targets.add(self.p2)

		self.g.resolve_current_turn()

		self.assertEqual(len(Log.objects.for_player(self.p2, self.p, self.g.current_turn).filter(Q(event_type=self.g.OPE_SABOTAGE) | Q(event_type=self.g.OPE_SABOTAGE_FAIL))), 1)

	def test_informations_on_corporations_gives_logs(self):
		self.io.corporation_targets.add(self.c)

		self.g.resolve_current_turn()

	def test_information_on_corporation_give_logs(self):
		"""
		We get information about the corporation
		"""
		self.io.corporation_targets.add(self.c)
		self.g.resolve_current_turn()

		self.assertEqual(len(Log.objects.for_player(self.p2, self.p, self.g.current_turn)), 1)

	def test_more_information_than_money(self):
		"""
		We have enough to buy 1 player and 2 corporation and we ask for 1 player and 3 corporations. The order should be reduced to 1 player and 2 corporations
		"""

		self.p.money = 2 * InformationOrder.CORPORATION_COST + InformationOrder.PLAYER_COST
		self.p.save()

		self.io.player_targets.add(self.p2)
		self.io.corporation_targets.add(self.c, self.c2, self.c3)

		self.assertEqual(self.io.player_targets.count(), 1)
		self.assertEqual(self.io.corporation_targets.count(), 2)
Esempio n. 8
0
class InformationRunOrderTest(RunOrdersTest):
    def setUp(self):
        super(InformationRunOrderTest, self).setUp()

        self.p2 = Player(game=self.g, secrets="Some nasty sfuff")
        self.p2.save()
        self.p2.citizenship.corporation = self.c
        self.p2.citizenship.save()

        from engine_modules.influence.models import BuyInfluenceOrder

        # Initial setup, create a resolution sheet we'll use later.
        o = BuyInfluenceOrder(player=self.p2)
        o.save()

        self.g.resolve_current_turn()

        self.io = InformationOrder(
            target=self.p2,
            player=self.p,
            additional_percents=0,
        )
        self.io.clean()
        self.io.save()

        self.set_to_zero(self.io.target.citizenship.corporation)

    def tearDown(self):
        self.set_to_original(self.io.target.citizenship.corporation)

    def test_information_success(self):
        """
		Information yields players data
		"""
        self.io.additional_percents = 10
        self.io.save()
        # Save message
        p2_resolution_message = self.p2.message_set.get(
            flag=Message.RESOLUTION, turn=1).content
        p2_resolution_message_formatted = p2_resolution_message.replace(
            '# ', '## ')

        self.g.resolve_current_turn()

        p_results = self.p.message_set.get(
            flag=Message.PRIVATE_MESSAGE).content

        self.assertIn("Tour 1", p_results)
        self.assertIn(self.p2.secrets, p_results)
        self.assertNotIn("Tour 2", p_results)  # Current turn not included

        self.assertIn(p2_resolution_message_formatted, p_results)

    def test_information_failure(self):
        """
		Failed information should not give information
		"""
        self.io.hidden_percents -= 10
        self.io.save()
        self.g.resolve_current_turn()

        self.assertRaises(
            Message.DoesNotExist,
            lambda: self.p.message_set.get(flag=Message.PRIVATE_MESSAGE))