예제 #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))
예제 #2
0
    def test_add_item(self):
        self.assertEqual(0, len(self.backpack.items))

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

        # We'll consider a "package" of stuffs to be a singular unit
        # As in, some items (i.e. bag of ball bearings) would make more sense
        # if they were grouped together as one unit.
        item = items.Item('Torches', price=currency.GoldPieces(1), weight=1, quantity=10)
        for i in range(0, 10):
            self.backpack.add_item(item)
        self.assertEqual(20, len(self.backpack.items))
예제 #3
0
    def test_is_proficient_category(self):
        proficiencies = ['simple', 'rapier']

        weapon = weapons.Weapon('Mace', category=weapons.SIMPLE,
                                damage='1d6 bludgeoning',
                                price=currency.GoldPieces(5),
                                weight=4,
                                properties=[])
        self.assertEqual(True, weapons.is_proficient(weapon, proficiencies))

        weapon = weapons.Weapon('Longsword', category=weapons.MARTIAL,
                                damage='1d6 bludgeoning',
                                price=currency.GoldPieces(5),
                                weight=4,
                                properties=[])
        self.assertEqual(False, weapons.is_proficient(weapon, proficiencies))
예제 #4
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)
예제 #5
0
    def test_no_money(self):
        pouch = currency.MoneyPouch()

        self.assertEqual(pouch.money['CP'].amt, 0)
        self.assertEqual(pouch.money['SP'].amt, 0)
        self.assertEqual(pouch.money['GP'].amt, 0)
        self.assertEqual(pouch.money['PP'].amt, 0)

        self.assertEqual(currency.CopperPieces(0), pouch.total_copper)

        self.assertEqual(currency.GoldPieces(0), pouch.total_gold)
예제 #6
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 []
예제 #7
0
 def test_determine_attack_bonus_type_finesse(self):
     ability_scores = {
         'STR': base.AbilityScore('STR', 10),
         'DEX': base.AbilityScore('DEX', 14),
     }
     str_weapon = weapons.Weapon('Finesse weapon', category=weapons.SIMPLE,
                                 damage='1d6 bludgeoning',
                                 price=currency.GoldPieces(5),
                                 weight=4,
                                 properties=['finesse'])
     result = weapons.determine_attack_bonus_type(str_weapon, ability_scores)
     self.assertEqual(('DEX', 2), result)
예제 #8
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)
예제 #9
0
 def test_gold_pieces(self):
     gp = currency.GoldPieces(10)
     self.assertEqual(10, gp.amt)
     self.assertEqual(currency.CopperPieces(1000), gp.copper_conversion())
예제 #10
0
def calc_medium_armor_rating(dex_mod):
    # chain shirt
    return 13 + min(dex_mod, 2)


def calc_heavy_armor_rating():
    # chain mail
    return 16


#############################
# ARMOR
#############################

LEATHER_ARMOR = Armor('Leather Armor',
                      price=currency.GoldPieces(10),
                      weight=10,
                      armor_class=calc_light_armor_rating,
                      strength=0,
                      stealth='')

CHAIN_SHIRT = Armor('Chain Shirt',
                    price=currency.GoldPieces(50),
                    weight=20,
                    armor_class=calc_medium_armor_rating,
                    strength=0,
                    stealth='')

CHAIN_MAIL = Armor('Chain Mail',
                   price=currency.GoldPieces(75),
                   weight=55,
예제 #11
0
LIGHT = 'light'
FINESSE = 'finesse'
HEAVY = 'heavy'
TWO_HANDED = 'two-handed'
AMMUNITION = 'ammunition'
THROWN = 'thrown'

#############################
# WEAPONS
#############################

MACE = Weapon('mace',
              category=SIMPLE,
              damage='1d6 bludgeoning',
              price=currency.GoldPieces(5),
              weight=4,
              properties=[])

HANDAXE = Weapon('handaxe',
                 category=SIMPLE,
                 damage='1d6 slashing',
                 price=currency.GoldPieces(5),
                 weight=2,
                 properties=[LIGHT, 'thrown (range 20/60)'])

SHORTBOW = Weapon('shortbow',
                  category=SIMPLE,
                  damage='1d6 piercing',
                  price=currency.GoldPieces(10),
                  weight=2,