示例#1
0
def lookup_treasure_type(conn, type_code, result):
    result[type_code] = []
    # Draft the entire table.
    sql = 'SELECT * FROM {0}'.format('Type_' + type_code.upper() + '_Treasure')
    i = 0
    for row in conn.execute(sql):
        cost = item.Price(row[0])
        result[type_code].append({
            'index': i,
            'cost': int(cost.as_float()),
            'item': row[0],
            'description': row[1],
            'count': 0
        })
        i += 1
示例#2
0
def calculate_budget_npc_gear(conn, npc_level, is_heroic):
    level = 0
    try:
        level = int(npc_level)
        if is_heroic: level += 1
    except:
        # Return an empty dict
        return {}

    # Look up the NPC info.
    sql = 'SELECT {0} FROM {1} WHERE ("Level" = ?)'.format(
        '"Treasure Value"', 'NPC_Gear')
    result = conn.execute(sql, (level, ))
    budget = result.fetchone()[0]
    price = item.Price(budget)

    return {'budget': str(price), 'as_int': int(price.as_float())}
示例#3
0
def run_generate_fast(conn, args):
    '''Runs the fast individual item generator.'''
    # No "roller" required.
    # Generate an item.
    count = 1
    if args.count:
        count = args.count
    print('Fast-generating', count, 'items')
    for i in range(count):
        try:
            result = item.fast_generate(conn, args.strength, args.kind,
                                        args.gold)
            print('Item:', result[0], str(item.Price(result[1])))
        except:
            print('No eligible items')
            # If none for one run, none for any
            return
示例#4
0
def calculate_budget_encounter(conn, apl, rate, magnitude):
    # Convert the parameters to usable values.
    try:
        rate = RATES[rate]
        magnitude = MAGNITUDES[magnitude]
    except:
        # Return an empty dict
        return {}

    # Look up the encounter.
    sql = 'SELECT {0} FROM {1} WHERE ("Average Party Level" = ?)'.format(
        rate, 'Treasure_Values_Per_Encounter')
    result = conn.execute(sql, (apl, ))
    budget = result.fetchone()[0]
    price = item.Price(budget)
    price.multiply(magnitude)

    return {'budget': str(price), 'as_int': int(price.as_float())}
示例#5
0
def calculate_budget_custom(conn, gp_in):
    # A simple reflection
    price = item.Price(gp_in)
    return {'budget': str(price), 'as_int': int(price.as_float())}