Exemplo n.º 1
0
    def testCountHutWithEnoughResources(self):
        hut = CountHut(4, 2)
        resources = [2, 2, 3, 3, 5, 5, 5]

        self.assertEqual([], hut.missing(resources))

        hut = CountHut(5, 3)
        resources = [2, 2, 3, 3, 5, 5, 5, 6]

        self.assertEqual([], hut.missing(resources))
Exemplo n.º 2
0
    def testCountHutWithToFewResources(self):
        hut = CountHut(4, 2)
        resources = [2, 2, 3, 3, 5]

        self.assertEqual([3], hut.missing(resources))

        hut = CountHut(4, 4)
        resources = [2, 2, 3, 3, 5]
        self.assertEqual([4, 6], hut.missing(resources))

        hut = CountHut(5, 2)
        resources = [4, 4, 4, 5]
        self.assertEqual([4], hut.missing(resources))
Exemplo n.º 3
0
    def testCountHutWithNoResources(self):
        hut = CountHut(4, 1)
        resources = []

        self.assertEqual([3, 3, 3, 3], hut.missing(resources))

        hut = CountHut(4, 3)
        resources = []
        self.assertListEqual([3, 3, 4, 5], sorted(hut.missing(resources)))

        hut = CountHut(5, 4)
        resources = []
        self.assertListEqual([3, 3, 4, 5, 6], sorted(hut.missing(resources)))
Exemplo n.º 4
0
    def testCountHutCostsWithOnePossiblePayment(self):
        hut = CountHut(4, 2)
        resources = [2, 2, 3, 3, 5, 5]
        self.assertEqual(0, hut.value(),
                         "value should be 0 before cost is calculated")

        self.assertEqual([3, 3, 5, 5], sorted(hut.costs(resources)))
        self.assertEqual(16, hut.value(), "value should be 16")

        hut = CountHut(5, 3)
        resources = [2, 2, 3, 3, 5, 5, 6]
        self.assertEqual([3, 3, 5, 5, 6], sorted(hut.costs(resources)))
        self.assertEqual(22, hut.value(), "value should be 22")
Exemplo n.º 5
0
 def _defaultHuts(self):
     return [SimpleHut(3, 3, 4),
             SimpleHut(3, 3, 5),
             SimpleHut(3, 3, 6),
             SimpleHut(3, 4, 5),
             SimpleHut(3, 4, 4),
             SimpleHut(3, 5, 5),
             SimpleHut(3, 4, 6),
             SimpleHut(3, 4, 6),
             SimpleHut(3, 4, 5),
             SimpleHut(3, 5, 6),
             SimpleHut(3, 5, 6),
             SimpleHut(4, 4, 5),
             SimpleHut(4, 4, 6),
             SimpleHut(4, 5, 5),
             SimpleHut(4, 5, 6),
             SimpleHut(4, 5, 6),
             SimpleHut(5, 5, 6),
             AnyHut(),
             AnyHut(),
             AnyHut(),
             CountHut(4,1),
             CountHut(4,2),
             CountHut(4,3),
             CountHut(4,4),
             CountHut(5,1),
             CountHut(5,2),
             CountHut(5,3),
             CountHut(5,4),
             ]
Exemplo n.º 6
0
    def testIsPayableBug(self):
        self.player.addResources([3, 3, 3, 3, 3, 4, 4, 5, 6,])
        firstHut = CountHut(4, 2)

        self.player.strategy.adjustResources(firstHut, self.player.resources)
        
        self.assertDictEqual({firstHut : [3,4,3,3]}, self.player.strategy.plannedCosts)
        
        secondHut = CountHut(4, 3)
        self.assertTrue(self.player.isPayable(secondHut))
        self.player.strategy.adjustResources(secondHut, self.player.resources)

        self.assertDictEqual({firstHut : [3,4,3,3], secondHut : [3,4,5,3]}, self.player.strategy.plannedCosts)
        
        thirdHut = SimpleHut(5, 5, 6)
        self.assertFalse(self.player.isPayable(thirdHut))
        
        fourthHut = CountHut(5, 2)
        self.assertFalse(self.player.isPayable(fourthHut))
Exemplo n.º 7
0
 def testCountHutError2(self):
     hut = CountHut(5, 2)
     resources = [4, 4, 5, 6, 6]
     self.assertEqual([4, 4], hut.missing(resources))
Exemplo n.º 8
0
 def testCountHutError(self):
     hut = CountHut(5, 1)
     resources = [3, 3, 3, 6, 4, 4, 4]
     self.assertEqual([3, 3], hut.missing(resources))
Exemplo n.º 9
0
 def testCountHutCostsWithMorePossiblePayments3(self):
     hut = CountHut(4, 2)
     resources = [3, 4, 5, 5, 5]
     self.assertEqual([3, 5, 5, 5], sorted(hut.costs(resources)))