예제 #1
0
def run_generate_item(conn, args):
    '''Runs the individual item generator.'''
    # Set up the roller.
    if args.manual:
        roller = rollers.ManualDiceRoller()
    else:
        roller = rollers.PseudorandomRoller()
    # Generate an item.
    keywords = (' '.join(args.item_args)).lower()
    x = item.generate_item(conn, keywords, roller, None)
    item.print_item(str(x))
예제 #2
0
def run_generate_item(conn, args):
    '''Runs the individual item generator.'''
    # Set up the roller.
    if args.manual:
        roller = rollers.ManualDiceRoller()
    else:
        roller = rollers.PseudorandomRoller()
    # Generate an item.
    keywords = (' '.join(args.item_args)).lower()
    x = item.generate_item(conn, keywords, roller, None)
    item.print_item(str(x))
예제 #3
0
def run_lookup(conn, args):
    '''Runs the lookup generator.'''

    class SerialRoller(rollers.Roller):
        def __init__(self, rolls):
            self.rolls = rolls
            self.rolls.reverse()
        def roll(self, dice_expression, purpose):
            if len(self.rolls) > 0:
                return self.rolls.pop()
            raise NotEnoughRolls

    roller = SerialRoller(args.rolls)
    x = item.generate_item(conn, args.strength + ' ' + args.kind.lower(),
            roller, None)
    item.print_item(x)
예제 #4
0
def run_lookup(conn, args):
    '''Runs the lookup generator.'''
    class SerialRoller(rollers.Roller):
        def __init__(self, rolls):
            self.rolls = rolls
            self.rolls.reverse()

        def roll(self, dice_expression, purpose):
            if len(self.rolls) > 0:
                return self.rolls.pop()
            raise NotEnoughRolls

    roller = SerialRoller(args.rolls)
    x = item.generate_item(conn, args.strength + ' ' + args.kind.lower(),
                           roller, None)
    item.print_item(x)
예제 #5
0
def run_generate_settlement(conn, args):
    '''Runs the settlement item generator.'''
    # Set up the roller.
    if args.manual:
        roller = rollers.ManualDiceRoller()
    else:
        roller = rollers.PseudorandomRoller()
    # Generate items.
    settlement = (' '.join(args.settlement_type)).lower()
    result = settlements.generate_settlement_items(conn, settlement, roller)
    # Print the results.
    print('Magic items for a ', settlement, ':', sep='')
    print('-' * 78)
    print('Base value:', result['base_value'], 'gp')
    print()
    if len(result['minor_items']) > 0:
        print('Minor Magic Items')
        print('-' * 78)
        for x in result['minor_items']:
            item.print_item(x)
        print('\n')
    if len(result['medium_items']) > 0:
        print('Medium Magic Items')
        print('-' * 78)
        for x in result['medium_items']:
            item.print_item(x)
        print('\n')
    if len(result['major_items']) > 0:
        print('Major Magic Items')
        print('-' * 78)
        for x in result['major_items']:
            item.print_item(x)
예제 #6
0
def run_generate_settlement(conn, args):
    '''Runs the settlement item generator.'''
    # Set up the roller.
    if args.manual:
        roller = rollers.ManualDiceRoller()
    else:
        roller = rollers.PseudorandomRoller()
    # Generate items.
    settlement = (' '.join(args.settlement_type)).lower()
    result = settlements.generate_settlement_items(conn, settlement, roller)
    # Print the results.
    print('Magic items for a ', settlement, ':', sep='')
    print('-' * 78)
    print('Base value:', result['base_value'], 'gp')
    print()
    if len(result['minor_items']) > 0:
        print('Minor Magic Items')
        print('-' * 78)
        for x in result['minor_items']:
            item.print_item(x)
        print('\n')
    if len(result['medium_items']) > 0:
        print('Medium Magic Items')
        print('-' * 78)
        for x in result['medium_items']:
            item.print_item(x)
        print('\n')
    if len(result['major_items']) > 0:
        print('Major Magic Items')
        print('-' * 78)
        for x in result['major_items']:
            item.print_item(x)