Esempio n. 1
0
	def test_mdc_DERE_line_negative_effect(self):
		"""
		Test what happens when the DERE party line is chosen for detractors
		"""

		self.set_turn_line(MDCVoteOrder.BANK, MDCVoteOrder.DERE, MDCVoteOrder.DERE)
		self.g.resolve_current_turn()

		# Player 1 has voted BANK, so he shouldn't be able to speculate
		o = CorporationSpeculationOrder(
			player=self.p,
			corporation=self.c3,
			rank=1,
			investment=5
		)
		self.assertRaises(OrderNotAvailable, o.clean)

		# Check that player 3 still can
		o2 = CorporationSpeculationOrder(
			player=self.p3,
			corporation=self.c3,
			rank=1,
			investment=5
		)
		o2.clean()
Esempio n. 2
0
	def test_mdc_BANK_line_negative_effect(self):
		"""
		Test what happens when BANK party line is chosen to people who voted deregulation
		"""

		self.set_turn_line(MDCVoteOrder.BANK, MDCVoteOrder.BANK, MDCVoteOrder.DERE)
		self.g.resolve_current_turn()

		# Player 3 has voted DERE, so he shouldn't be able to speculate
		o = CorporationSpeculationOrder(
			player=self.p3,
			corporation=self.c3,
			rank=1,
			investment=1
		)
		self.assertRaises(OrderNotAvailable, o.clean)

		# Check that player 1 still can
		o2 = CorporationSpeculationOrder(
			player=self.p,
			corporation=self.c3,
			rank=1,
			investment=1
		)
		o2.clean()
Esempio n. 3
0
    def test_max_speculation(self):
        """
		Can't speculate more than influence
		"""
        self.p.influence.level = 1
        self.p.influence.save()

        o = CorporationSpeculationOrder(player=self.p,
                                        corporation=self.c2,
                                        rank=1,
                                        investment=5)
        o.save()

        o2 = CorporationSpeculationOrder(player=self.p,
                                         corporation=self.c2,
                                         rank=1,
                                         investment=5)
        self.assertRaises(OrderNotAvailable, o2.clean)

        dso = DerivativeSpeculationOrder(
            player=self.p,
            speculation=DerivativeSpeculationOrder.UP,
            investment=DerivativeSpeculationOrder.MAX_AMOUNT_SPECULATION + 1)
        self.assertRaises(OrderNotAvailable, dso.clean)

        self.p.influence.level = 2
        self.p.influence.save()

        # assertNoRaises
        o2.clean()
Esempio n. 4
0
    def test_corporation_speculation(self):
        """
		Task should be called
		"""
        self.c.assets = 50
        self.c.save()

        cso = CorporationSpeculationOrder(player=self.p,
                                          corporation=self.c,
                                          rank=1,
                                          investment=5)
        cso.save()

        self.g.resolve_current_turn()

        self.assertEqual(
            self.reload(self.p).money, self.initial_money + cso.get_cost() * 2)
Esempio n. 5
0
	def test_corporation_speculation(self):
		"""
		Task should be called
		"""
		self.c.set_market_assets(50)

		cso = CorporationSpeculationOrder(
			player=self.p,
			corporation=self.c,
			rank=1,
			investment=5
		)
		cso.save()

		self.g.resolve_current_turn()

		self.assertEqual(self.reload(self.p).money, self.initial_money + cso.get_cost() * 2)
Esempio n. 6
0
    def test_max_corporation_speculation_amount_in_single_instance(self):
        """
		Can't speculate more than influence * MAX_AMOUNT_SPECULATION
		"""
        o = CorporationSpeculationOrder(
            player=self.p,
            corporation=self.c2,
            rank=1,
            investment=self.p.influence.level * CorporationSpeculationOrder.MAX_AMOUNT_SPECULATION + 1,
        )
        self.assertRaises(OrderNotAvailable, o.clean)

        influence = self.p.influence
        influence.level = 2
        influence.save()

        # assertNoRaises
        o.clean()
Esempio n. 7
0
    def test_corporation_rank_limited(self):
        """
		Can't speculate on non existing rank
		"""
        o = CorporationSpeculationOrder(player=self.p,
                                        corporation=self.last_corporation,
                                        rank=self.g.corporation_set.count() +
                                        1,
                                        investment=5)

        self.assertRaises(OrderNotAvailable, o.clean)
Esempio n. 8
0
    def test_max_corporation_speculation_amount(self):
        """
		can't speculate more than influence * MAX_AMOUNT_SPECULATION
		"""
        self.p.influence.level = 1
        self.p.influence.save()

        o = CorporationSpeculationOrder(
            player=self.p,
            corporation=self.c2,
            rank=1,
            investment=self.p.influence.level *
            CorporationSpeculationOrder.MAX_AMOUNT_SPECULATION + 1)
        self.assertRaises(OrderNotAvailable, o.clean)

        self.p.influence.level = 2
        self.p.influence.save()

        #assertNoRaises
        o.clean()
Esempio n. 9
0
	def test_mdc_DERE_line_positive_effect(self):
		"""
		Test what happens when the DERE party line is chosen for players who voted for it
		"""

		self.set_turn_line(MDCVoteOrder.BANK, MDCVoteOrder.DERE, MDCVoteOrder.DERE)
		self.g.resolve_current_turn()

		o = CorporationSpeculationOrder(
			player=self.p2,
			corporation=self.c,
			rank=1,
			investment=5
		)
		o.save()

		o.resolve()
		self.assertEqual(o.on_win_ratio, 3)  # 2 + 1
		self.assertEqual(o.on_loss_ratio, 1)  # Default
		self.assertEqual(self.reload(self.p2).money, self.initial_money + o.investment * 3)
Esempio n. 10
0
    def test_max_corporation_speculation_amount_in_multiple_instance(self):
        """
		Can't speculate more than influence * MAX_AMOUNT_SPECULATION, even with many speculations
		"""
        o = CorporationSpeculationOrder(
            player=self.p,
            corporation=self.c2,
            rank=1,
            investment=self.p.influence.level * CorporationSpeculationOrder.MAX_AMOUNT_SPECULATION / 2 + 1,
        )
        # assertNoRaises
        o.clean()
        o.save()

        o2 = CorporationSpeculationOrder(
            player=self.p,
            corporation=self.c2,
            rank=1,
            investment=self.p.influence.level * CorporationSpeculationOrder.MAX_AMOUNT_SPECULATION / 2,
        )
        self.assertRaises(OrderNotAvailable, o2.clean)
Esempio n. 11
0
	def test_max_speculation(self):
		"""
		Can't speculate more than influence
		"""
		self.p.influence.level = 1
		self.p.influence.save()

		o = CorporationSpeculationOrder(
			player=self.p,
			corporation=self.c2,
			rank=1,
			investment=5
		)
		o.save()

		o2 = CorporationSpeculationOrder(
			player=self.p,
			corporation=self.c2,
			rank=1,
			investment=5
		)
		self.assertRaises(OrderNotAvailable, o2.clean)

		dso = DerivativeSpeculationOrder(
			player=self.p,
			speculation=DerivativeSpeculationOrder.UP,
			investment=DerivativeSpeculationOrder.MAX_AMOUNT_SPECULATION + 1
		)
		self.assertRaises(OrderNotAvailable, dso.clean)

		self.p.influence.level = 2
		self.p.influence.save()

		# assertNoRaises
		o2.clean()
Esempio n. 12
0
    def test_mdc_BANK_line_negative_effect(self):
        """
		Test what happens when BANK party line is chosen to people who voted deregulation
		"""

        self.set_turn_line(MDCVoteOrder.BANK, MDCVoteOrder.BANK,
                           MDCVoteOrder.DERE)
        self.g.resolve_current_turn()

        # Player 3 has voted DERE, so he shouldn't be able to speculate
        o = CorporationSpeculationOrder(player=self.p3,
                                        corporation=self.c3,
                                        rank=1,
                                        investment=1)
        self.assertRaises(OrderNotAvailable, o.clean)

        # Check that player 1 still can
        o2 = CorporationSpeculationOrder(player=self.p,
                                         corporation=self.c3,
                                         rank=1,
                                         investment=1)
        o2.clean()
Esempio n. 13
0
    def test_mdc_DERE_line_negative_effect(self):
        """
		Test what happens when the DERE party line is chosen for detractors
		"""

        self.set_turn_line(MDCVoteOrder.BANK, MDCVoteOrder.DERE,
                           MDCVoteOrder.DERE)
        self.g.resolve_current_turn()

        # Player 1 has voted BANK, so he shouldn't be able to speculate
        o = CorporationSpeculationOrder(player=self.p,
                                        corporation=self.c3,
                                        rank=1,
                                        investment=5)
        self.assertRaises(OrderNotAvailable, o.clean)

        # Check that player 3 still can
        o2 = CorporationSpeculationOrder(player=self.p3,
                                         corporation=self.c3,
                                         rank=1,
                                         investment=5)
        o2.clean()
Esempio n. 14
0
	def test_mdc_BANK_line_positive_effect(self):
		"""
		Test what happens when BANK party line is chosen to people who voted it
		"""

		self.set_turn_line(MDCVoteOrder.BANK, MDCVoteOrder.BANK, MDCVoteOrder.DERE)
		self.c.update_assets(10)
		self.g.resolve_current_turn()

		# should fail, because c is first rank
		o = CorporationSpeculationOrder(
			player=self.p,
			corporation=self.c2,
			rank=1,
			investment=5
		)
		o.save()
		o.resolve()

		self.assertEqual(o.on_win_ratio, 2)  # Default
		self.assertEqual(o.on_loss_ratio, 0)  # 1 - 1
		self.assertEqual(self.reload(self.p).money, self.initial_money)
Esempio n. 15
0
    def test_corporation_speculation_order_cost_money(self):
        """
		Order should cost money
		"""
        o = CorporationSpeculationOrder(player=self.p,
                                        corporation=self.last_corporation,
                                        rank=1,
                                        investment=5)
        o.save()

        o.resolve()

        self.assertEqual(
            self.reload(self.p).money, self.initial_money - o.get_cost())
Esempio n. 16
0
    def test_corporation_speculation_big_success_give_money(self):
        """
		Success when speculate on a non first/last corpo should give lots of money
		"""
        o = CorporationSpeculationOrder(player=self.p,
                                        corporation=self.medium_corporation,
                                        rank=2,
                                        investment=5)
        o.save()

        o.resolve()

        self.assertEqual(
            self.reload(self.p).money, self.initial_money + o.get_cost() * 4)
Esempio n. 17
0
    def test_corporation_speculation_little_success_last_give_money(self):
        """
		Success when speculate on a last corpo should give money
		"""
        o = CorporationSpeculationOrder(player=self.p,
                                        corporation=self.last_corporation,
                                        rank=3,
                                        investment=5)
        o.save()

        o.resolve()

        self.assertEqual(
            self.reload(self.p).money, self.initial_money + o.get_cost() * 2)
Esempio n. 18
0
	def test_corporation_speculation_little_success_last_give_money(self):
		"""
		Success when speculate on a last corpo should give money
		"""
		o = CorporationSpeculationOrder(
			player=self.p,
			corporation=self.last_corporation,
			rank=3,
			investment=5
		)
		o.save()

		o.resolve()

		self.assertEqual(self.reload(self.p).money, self.initial_money + o.get_cost() * 2)
Esempio n. 19
0
	def test_corporation_speculation_big_success_give_money(self):
		"""
		Success when speculate on a non first/last corpo should give lots of money
		"""
		o = CorporationSpeculationOrder(
			player=self.p,
			corporation=self.medium_corporation,
			rank=2,
			investment=5
		)
		o.save()

		o.resolve()

		self.assertEqual(self.reload(self.p).money, self.initial_money + o.get_cost() * 4)
Esempio n. 20
0
	def test_corporation_speculation_order_cost_money(self):
		"""
		Order should cost money
		"""
		o = CorporationSpeculationOrder(
			player=self.p,
			corporation=self.last_corporation,
			rank=1,
			investment=5
		)
		o.save()

		o.resolve()

		self.assertEqual(self.reload(self.p).money, self.initial_money - o.get_cost())
Esempio n. 21
0
    def test_mdc_DERE_line_positive_effect(self):
        """
		Test what happens when the DERE party line is chosen for players who voted for it
		"""

        self.set_turn_line(MDCVoteOrder.BANK, MDCVoteOrder.DERE,
                           MDCVoteOrder.DERE)
        self.g.resolve_current_turn()

        o = CorporationSpeculationOrder(player=self.p2,
                                        corporation=self.c,
                                        rank=1,
                                        investment=5)
        o.save()

        o.resolve()
        self.assertEqual(o.on_win_ratio, 3)  # 2 + 1
        self.assertEqual(o.on_loss_ratio, 1)  # Default
        self.assertEqual(
            self.reload(self.p2).money, self.initial_money + o.investment * 3)
Esempio n. 22
0
    def test_mdc_BANK_line_positive_effect(self):
        """
		Test what happens when BANK party line is chosen to people who voted it
		"""

        self.set_turn_line(MDCVoteOrder.BANK, MDCVoteOrder.BANK,
                           MDCVoteOrder.DERE)
        self.c.update_assets(10)
        self.g.resolve_current_turn()

        # should fail, because c is first rank
        o = CorporationSpeculationOrder(player=self.p,
                                        corporation=self.c2,
                                        rank=1,
                                        investment=5)
        o.save()
        o.resolve()

        self.assertEqual(o.on_win_ratio, 2)  # Default
        self.assertEqual(o.on_loss_ratio, 0)  # 1 - 1
        self.assertEqual(self.reload(self.p).money, self.initial_money)