def test_parse_coins(self):
        """Verify basic coin amount parsing"""

        c = D20Coin.parse_coin("10gp")
        self.assertEqual(c.value, D20Coin(gp=10).value)
        c = D20Coin.parse_coin("10gp 10sp, 100,000cp")
        self.assertEqual(c.value, D20Coin(gp=10, sp=10, cp=100000).value)
    def test_convert_coin_types(self):
        """Try the four coin type conversions"""

        self.assertEqual(D20Coin.pp(1), 1000)
        self.assertEqual(D20Coin.gp(1), 100)
        self.assertEqual(D20Coin.sp(1), 10)
        self.assertEqual(D20Coin.cp(1), 1)
Beispiel #3
0
#!/usr/bin/python
from pathfindertreasure import D20Weapon, D20Coin
import sys

n = (len(sys.argv) > 1 and int(sys.argv[1])) or 20
for n in range(n):
    w = D20Weapon.random_weapon()
    print "%s: cost %s" % (w.describe(), D20Coin.coin_value(w.value))
    def test_get_value(self):
        """Call the get_value method"""

        value = TreasureGenerator(apl=10).get_value()
        self.assertTrue(value >= D20Coin.gp(int(5450.0 - (5450.0 * 0.2))))
        self.assertTrue(value <= D20Coin.gp(int(5450.0 + (5450.0 * 0.2))))
    def test_parse_fractional_coins(self):
        """Test fractional coin parsing"""

        c = D20Coin.parse_coin("10.5gp")
        self.assertEqual(c.value, D20Coin(gp=10, sp=5).value)