Exemple #1
0
 def test_convert_to_gold(self):
     money = [
         currency.CopperPieces(1000),
         currency.SilverPieces(100),
         currency.GoldPieces(10),
         currency.PlatinumPieces(1),
     ]
     self.assertEqual(currency.GoldPieces(40),
                      currency.convert_to_gold(money))
Exemple #2
0
    def test_with_money(self):
        pouch = currency.MoneyPouch(cp=currency.CopperPieces(1000),
                                    sp=currency.SilverPieces(100),
                                    gp=currency.GoldPieces(10),
                                    pp=currency.PlatinumPieces(1))
        self.assertEqual(pouch.money['CP'].amt, 1000)
        self.assertEqual(pouch.money['SP'].amt, 100)
        self.assertEqual(pouch.money['GP'].amt, 10)
        self.assertEqual(pouch.money['PP'].amt, 1)

        self.assertEqual(currency.CopperPieces(4000), pouch.total_copper)
Exemple #3
0
    def __init__(self,
                 copper_pieces=0,
                 silver_pieces=0,
                 gold_pieces=0,
                 platnium_pieces=0,
                 items=None):
        self.money_pouch = currency.MoneyPouch(currency.CopperPieces(copper_pieces),
                                               currency.SilverPieces(silver_pieces),
                                               currency.GoldPieces(gold_pieces),
                                               currency.PlatinumPieces(platnium_pieces))

        self.items = items if items else []
Exemple #4
0
    def test_total_item_worth(self):
        self.assertEqual(0, self.backpack.total_item_worth)

        item = items.Item('Bedroll', price=currency.GoldPieces(1), weight=7)
        for i in range(0, 10):
            self.backpack.add_item(item)
        self.assertEqual(10, self.backpack.total_item_worth)

        # This is a bit strange because some items are priced by unit
        # and others are priced by a bundle.
        # This is something that should be nailed down...
        item = items.Item('Torches', price=currency.SilverPieces(1), weight=1, quantity=10)
        for i in range(0, 10):
            self.backpack.add_item(item)
        self.assertEqual(20, self.backpack.total_item_worth)
Exemple #5
0
 def test_silver_pieces(self):
     sp = currency.SilverPieces(100)
     self.assertEqual(100, sp.amt)
     self.assertEqual(currency.CopperPieces(1000), sp.copper_conversion())