Пример #1
0
 def get_character_class(self, classname=None):
     """
     We determine character class based on your prime attribute.
     """
     if classname:
         return characterclass.CLASS_BY_NAME[classname]
     if self.demihumans and d(100) < 50:
         # sorted attributes (excluding charisma)
         attributes = sorted(self.attributes[:5],
                             reverse=True,
                             key=operator.itemgetter(1))
         if not (self.thieves and 'DEX' == attributes[0][0]
                 and d(100) < 80):
             # We randomly test because there is overlap in what could
             # succeed and we want each to be equally likely in the long
             # run.
             tests = [_is_dwarf, _is_halfling, _is_elf]
             random.shuffle(tests)
             for t in tests:
                 result, c = t(self.INT, self.CON, self.DEX, self.STR)
                 if result:
                     return c
     # You're playing a human!
     index = 4 if self.thieves else 3
     prime_attribute, _ = sorted(self.attributes[:index],
                                 reverse=True,
                                 key=operator.itemgetter(1))[0]
     return characterclass.PRIME_REQUISITE[prime_attribute]
Пример #2
0
 def get_wild_talent(self):
     # TODO: what frequency do I actually want here?
     if d(6) != 1:
         return
     talent_roll = self.WIS - d(20)
     if talent_roll < 0:
         save_bonus = abs(talent_roll) / 2
         if save_bonus:
             return "+%d to saves vs. psionic attacks" % save_bonus
         else:
             return None
     else:
         return characterclass.WILD_TALENTS[talent_roll]
Пример #3
0
 def get_hp(self):
     """
     Determine HP based on hit dice and CON modifiers. Note: this value may
     be negative and that is handled by the caller.
     """
     return d(self.hit_die) + self.get_bonus(
         *self.attributes[characterclass.CON])
Пример #4
0
 def get_hp(self):
     """
     LotFP characters have a minimum number of HP.
     """
     hp = d(self.hit_die) + self.get_bonus(
         *self.attributes[characterclass.CON])
     hp = max(hp,
              characterclass.LOTFP['min_hp'][self.character_class['name']])
     return hp
Пример #5
0
    def __init__(self, *args, **kwargs):
        super(Character, self).__init__(*args, **kwargs)

        # Attributes
        self.skill = dice.d(3) + 3
        self.stamina = dice.xdy(2, 6) + 12
        self.luck = dice.d(6) + 6

        # Pick a Background
        background = random.choice(self.BACKGROUNDS)

        self.background = background['name'][3:]
        self.description = background['description']
        self.special = background['special']

        # Pick one of the "ORs" for possessions when picking equipment
        self.equipment = [
            random.choice(equipment.split(' OR '))
            for equipment in background['possesions']
        ] + [
            # Add default equipment
            'Knife',
            'Lantern and a flask of oil',
            'Rucksack',
            '6 provisions',
            '%d silver pennies' % dice.xdy(2, 6),
        ]

        # Turn random spells into actual spells when picking skills
        self.skills = [
            skill.replace('Random (Table 5)', random.choice(self.MAGIC_SPELLS))
            for skill in background['skills']
        ]

        # Fix some gender issues
        if 'Female' in self.appearance and self.background == 'Lonesome King':
            self.background = 'Lonesome Queen'
        elif self.background == 'Rhino-Man':
            self.appearance = self.appearance.replace('Female, ', '')
            self.appearance = self.appearance.replace('Male, ', '')
        elif self.background == 'Parchment Witch':
            self.appearance = self.appearance.replace('Male', 'Female')
Пример #6
0
    def generate_attributes(self):
        attributes = {
            a.lower(): int(math.ceil(1.0 * dice.d(10) / 2.0))
            for a in self.ATTRIBUTES
        }

        if self.role == "Victim":
            attributes["calm"] = max(attributes["calm"], 4)
        elif self.role == "Problem":
            attributes["calm"] = max(attributes["calm"], 3)
        elif self.role == "Investigator":
            attributes["cash"] = max(attributes["cash"], 3)
        elif self.role == "Friend":
            attribute = random.choice(["perception", "calm"])
            attributes[attribute] = attributes[attribute] + 1

        self.attributes = attributes
Пример #7
0
 def roll_attribute(self):
     """ 4d6 drop the lowest """
     return sum(sorted(d(6) for _ in xrange(4))[1:])
Пример #8
0
def four_dee_six():
    roll = [sum(sorted(dice.d(6) for _ in xrange(4))[1:]) for _ in range(6)]
    return render_template("4d6.html", roll=roll)
Пример #9
0
    def get_background(self):
        backgrounds = [
            ("Poulticer",
             "mortar and pestle, dagger, mystery potion (you know what it doesn't do), oil flask, chalk"
             ),
            ("Slaughterer",
             "heavy cleaver, half-chain, a string of fine sausage, twine"),
            ("Fungus Picker",
             "two different kinds of mushrooms, club, sling, rabbuck-hide gloves, lamp, oil flask"
             ),
            ("Pickler",
             "pickle cask with delicious pickles, spice-rack, trident, wading boots"
             ),
            ("Charcoal Burner",
             "Iron-banded broom, knife, sooty rags, mastic, crampons"),
            ("Purloiner",
             "hammer and spike, off-hand daggers, 50' rope, clothes with hidden pockets, a golden ring (stolen)"
             ),
            ("Hunter",
             "crossbow OR bow, quiver, skinning-knife, leather jack, axe, brace of smoked frog"
             ),
            ("Noble",
             "sword and shield and full chain OR pistolet and powderhorn and chain shirt, off-hand dagger, map to 'inheritance', a fine cape and mantle, laudanum OR signet ring"
             ),
            ("Mendicant",
             "begging bowl, smart pet, reed flute, staff OR club"),
            ("Scribe",
             "mace, robes, runestones, oil-lamp, lard-pot, vellum, brush and ink"
             ),
            ("Porter", "fists, club, auroch-hide armour, a porter's basket"),
            ("Timberfeller",
             "great-axe, knife, raspberry aquavit, sling, 50' rope"),
            ("Plumber", "gluepot, throwing hammer, weather-proof overalls"),
            ("Hayseed",
             "axe OR pitchfork OR threshing flail, dirk, harmonium OR great-kazoo, chewing weed, three torches"
             ),
            ("House-guard",
             "shield, spear, misericorde, half-chain, club, 50' rope"),
            ("Fisher",
             "fishing pole and hook, gutting knife, 2 throwing spears, eel-hide armour, 3 torches, a smoked eel"
             ),
            ("Barber",
             "bonesaw, steggar, clamps, bloody rags, leechjar OR pendulum"),
            ("Scroll-Runner",
             "running shoes, jerky, 50' rope, emberhorn, dagger, news-scroll, farseeing glass"
             ),
            ("Paramour",
             "woodblock erotica OR book of poems, sword, perfume (as lamp-oil), locket OR prophylactics, bow and quiver"
             ),
            ("Guild-Partisan",
             "great-weapon, mancatcher, dagger, hauberk with party armband, guild news-scroll, a set of trade tools (dyer, tanner, weaver, napier, builder, etc.)"
             ),
            ("Bondsman",
             "waraxe OR crossbow and quiver and club, mail shirt, shield, saexe, gift-ring"
             ),
            ("Apiarist",
             "chainmail, goggles, club, bellows, smokebomb, honeycomb"),
            ("Sailor",
             "axe OR cat, off-hand marlinspike, scrimshaw, shield OR leather armour, lodestone"
             ),
            ("Bellman",
             "hookspear, chainmail shirt, shield, handbell, truncheon, 3 torches"
             ),
            ("Smith",
             "warhammer OR sword, off-hand hammer, chainmail OR leather armour and shield, anvil, crucible"
             ),
            ("Janissary",
             "harquebus, powderhorn, chainmail shirt, sword, shield, contract"
             ),
            ("Seer", "silver dagger, cage of finches, brazier"),
            ("Ursar", "mancatcher, 20' chain, club, hide armour, hand drum"),
            ("Merchant",
             "fine clothes, guilder's chain, mace OR axe, a servant with a bale of trade goods"
             ),
            ("Wolfs-head",
             "waraxe, caltrops, leather armour, crossbow, quiver, writ of blood price"
             ),
            ("Therapist",
             "flail, shield, pendulum, meditation cushion, oil-lamp, oil-pot"),
            ("Skald",
             "harp OR scroll of epic poetry, off-hand dagger, sword OR bow and quiver, collection plate"
             ),
            ("Drover",
             "studded leather, whip, club, brand, firehorn, heavy gloves, throwing axe"
             ),
            ("Judicial Functionary",
             "great-weapon, leather jack, hooded cloak, hanging rope OR tongs, manacles and keys"
             ),
            ("Wildling", "fists, moss and furs, 'lucky' stone, shillelagh"),
            ("Mercenary",
             "great-weapon OR waraxe and shield, dirk, ringed leathers, bow and quiver, totem"
             ),
        ]
        background, equipment = random.choice(backgrounds)
        equipment = equipment.split(', ')

        bonus_equipment, silver = random.choice([
            (["fists", "a half-empty bottle", "a turnip"], lambda: dice.d(6)),
            (["nullwater", "a white conch"], lambda: dice.xdy(3, 6)),
            (["3 flasks of oil", "a hammer", "iron spikes"], lambda: 0),
            (["quill and ink", "incense"], lambda: 0),
            (["a hex scroll", "a pine sprig"], lambda: dice.d(6) * 10),
            (["sword and scabbard OR waraxe OR warhammer"], lambda: 0),
        ])
        equipment += bonus_equipment
        equipment.append("%d SP" % silver())

        # process the equipment list down to a finite list of stuff
        final_equipment = []
        for e in equipment:
            items = random.choice(e.split(' OR ')).split(' and ')
            final_equipment.append(items)

        return background, ", ".join(list(itertools.chain(*final_equipment)))