コード例 #1
0
def sloop2():
    smloop = True
    while smloop:
        print_smenu2()
        choice = raw_input("Enter you choice: ")
        print
        if choice == "1":
            print "1-S2"
        if choice == "2":
            print "Add skills"
            skill.add_skill()
        if choice == "4":
            cfgData.clear_screen()
            export.export_to_excel()
            cfgData.clear_screen()
        if choice == "3":
            p = charMenu.char_menu()
            menu_len = len(p)
            while True:
                s = int(raw_input("Select Character: "))
                if s >= 1 and s <= menu_len:
                    break
                else:
                    print "Invalid Selection! Select a character from the list"

            # Open the file
            char_dict = {}
            s -= 1
            char = p[s]
            skill.import_skill(char)
            cfgData.clear_screen()
        if choice == "6":
            cfgData.clear_screen()
            charData.mbbonus()
            cfgData.clear_screen()
        elif choice.upper() == "X":
            print "Exiting program"
            smloop = False
        else:
            raw_input("Wrong option selection2. Enter any key to try again..")
コード例 #2
0
def create_char():
    # Set base Experience
    char_dict['exp'] = 10000
    char_dict['next_lvl'] = 20000

    print 30 * "-", "Professions", 30 * "-"
    print ""
    #Skip header
    ln = 1
    menu = 1
    while ln <= len(plist):
        # Create Section Headers
        if plist[ln][8] == "NON" and menu == 1:
            print 25 * "-", "Non", 25 * "-"
            menu = 2
        if plist[ln][8] == "SEMI" and menu == 2:
            print ""
            print 25 * "-", "Semi", 25 * "-"
            menu = 3
        if plist[ln][8] == "PURE" and menu == 3:
            print ""
            print 25 * "-", "Pure", 25 * "-"
            menu = 4
        if plist[ln][8] == "HYB" and menu == 4:
            print ""
            print 25 * "-", "Hybrid", 25 * "-"
            menu = 5
        if plist[ln + 1][8] == plist[ln][8]:
            print "{:2}.) {:20} {:2}.) {:20}".format(plist[ln][0],
                                                     plist[ln][1],
                                                     plist[ln + 1][0],
                                                     plist[ln + 1][1])
            ln += 1
        else:
            print "{:2}.) {:20}".format(plist[ln][0], plist[ln][1])
        ln += 1
    print ""
    print 63 * "-"
    pro_ch = ""
    while pro_ch < 1 or pro_ch > len(plist):
        try:
            pro_ch = int(raw_input('Select Profession: '))
            if pro_ch < 1 or pro_ch > len(plist):
                print "You must enter a number between 1 and {:2}".format(
                    len(plist))
        except:
            print "You must enter a number between 1 and {:2}".format(
                len(plist))
    # Set Profession name
    char_dict['proname'] = plist[pro_ch][1]
    print char_dict['proname']
    char_dict['pro_pr1'] = plist[pro_ch][2]
    char_dict['pro_pr2'] = plist[pro_ch][3]
    char_dict['pro_pr3'] = plist[pro_ch][4]
    char_dict['mrealm'] = plist[pro_ch][7]
    proID = int(plist[pro_ch][0])
    proID += 7
    print ""

    # Race Selection
    print len(rlist), ":len(rlist)"
    ln = 1
    print 30 * "-", "Races", 30 * "-"
    print ""
    while ln <= len(rlist):
        if (len(rlist) - ln) == 0:
            print "{:2}.) {:20}".format(rlist[ln][0], rlist[ln][1])
            ln += 1
        else:
            print "{:2}.) {:20} {:2}.) {:20}".format(rlist[ln][0],
                                                     rlist[ln][1],
                                                     rlist[ln + 1][0],
                                                     rlist[ln + 1][1])
            ln += 2
    print ""
    print 63 * "-"
    race_input = ""
    while race_input < 1 or race_input > len(rlist):
        try:
            race_input = int(raw_input('Select a Race: '))
            if race_input < 1 or race_input > len(rlist):
                print "You must enter a number between 1 and {:2}".format(
                    len(rlist))
        except:
            print "You must enter a number between 1 and {:2}".format(
                len(rlist))
    char_dict['race'] = rlist[race_input][1]
    print char_dict['race']

    ### Enter current statistic values
    curlist = []
    statlist = []
    stat_temp_list = []
    print "Roll for Current stats"
    print ""

    cnt = 1
    for i in range(12):
        while i < 20 or i > 100:
            try:
                i = int(raw_input('Current Stat Roll {:<2} :'.format(cnt)))
                if i < 20 or i > 100:
                    print "You must enter a number between 20 and 100"
            except:
                print "You must enter a number between 20 and 100"
        curlist.append(i)
        cnt += 1

    # Reset the counter
    cnt = 1
    curlist.sort()

    # Test the number of 90 or higher rolls
    if curlist[-3] > 89:
        ninty = 3
    elif curlist[-2] > 89:
        ninty = 2
    elif curlist[-1] > 89:
        ninty = 1
    elif curlist[-1] < 90:
        ninty = 0

    # Test if enough 90+ rolls for profession and replace lowest value with 90
    if char_dict['proname'] == 'Archmage':
        if ninty == 2:
            curlist[0] = 90
        if ninty == 1:
            curlist[0], curlist[1] = 90, 90
        if ninty == 0:
            curlist[0], curlist[1], curlist[2] = 90, 90, 90
    else:
        if ninty == 1:
            curlist[0] = 90
        if ninty == 0:
            curlist[0], curlist[1] = 90, 90

    # Enter Potential stat rolls
    for i in curlist:
        try:
            p = int(raw_input('Potential Roll {:<2} :'.format(cnt)))
            if p < 1 or p > 100:
                print "You must enter a number between 1 and 100"
        except:
            print "You must enter a number between 1 and 100"
        pot = cfgData.pot_calc(i, p)
        statlist.append([i, pot])
        cnt += 1
    # Clear screen
    cfgData.clear_screen()

    # Reset counter
    cnt = 1
    print 65 * "-"
    print ""
    # Open chart of stat values
    with open(cfgData.cfg_dir + "/sttchart.csv") as f:
        statchart = f.read().splitlines()
    f.close()
    sc = []
    cnt = 1
    for x in statchart:
        sc.append(x.split(","))
    u = 0
    while u < len(statlist):
        for x1 in sc:
            if int(x1[0]) == statlist[u][0]:
                stat_temp_list.append(
                    [statlist[u][0], statlist[u][1], x1[1], x1[2], x1[3]])
        u += 1
    cnt = 1

    print "+", 48 * "=", "+"
    print "|{:5}| {:7} | {:9} | {:5} | {:4} | {:5} |".format(
        "", "", "", "Stat", "Dev", "Power")
    print "|{:5}| {:6} | {:9} | {:5} | {:4} | {:5} |".format(
        "", "Current", "Potential", "Bonus", "Pts", "Pts")
    print "+", 48 * "=", "+"

    while cnt <= len(statlist):
        print "| {:>2}.) | {:^6} | {:^9} | {:^5} | {:4} | {:^5} |".format(
            cnt, stat_temp_list[cnt - 1][0], stat_temp_list[cnt - 1][1],
            stat_temp_list[cnt - 1][2], stat_temp_list[cnt - 1][3],
            stat_temp_list[cnt - 1][4])
        cnt += 1
    print "+", 48 * "=", "+"
    print ""
    print "Remove (2) stats"
    cnt = 1

    while cnt < len(stat_temp_list) > 10:
        cnt, r = 1, 0
        while r < 1 or r > (len(stat_temp_list)):
            try:
                r = int(raw_input("Enter Stat to remove:"))
                if r < 1 or r > len(stat_temp_list):
                    print "Please enter a number between 1 and {:2}".format(
                        len(stat_temp_list))
            except:
                print "Please enter a number between 1 and {:2}".format(
                    len(stat_temp_list))
        stat_temp_list.pop(r - 1)

        print "+", 48 * "=", "+"
        print "|{:5}| {:7} | {:9} | {:5} | {:4} | {:5} |".format(
            "", "", "", "Stat", "Dev", "Power")
        print "|{:5}| {:6} | {:9} | {:5} | {:4} | {:5} |".format(
            "", "Current", "Potential", "Bonus", "Pts", "Pts")
        print "+", 48 * "=", "+"
        while cnt <= len(stat_temp_list):
            print "| {:>2}.) | {:^6} | {:^9} | {:^5} | {:4} | {:^5} |".format(
                cnt, stat_temp_list[cnt - 1][0], stat_temp_list[cnt - 1][1],
                stat_temp_list[cnt - 1][2], stat_temp_list[cnt - 1][3],
                stat_temp_list[cnt - 1][4])
            cnt += 1
        print "+", 48 * "=", "+"
        print ""
        cnt = 0

    stat = [['Strength', 'ST', 'st_stat', 'st_pot', 'stb', 'stdp', 'stpp'],
            ['Quickness', 'QU', 'qu_stat', 'qu_pot', 'qub', 'qudp', 'qupp'],
            ['Empathy', 'EM', 'em_stat', 'em_pot', 'emb', 'emdp', 'empp'],
            ['Presence', 'PR', 'pr_stat', 'pr_pot', 'prb', 'prdp', 'prpp'],
            ['Intuition', 'IN', 'in_stat', 'in_pot', 'inb', 'indp', 'inpp'],
            ['Constitution', 'CO', 'co_stat', 'co_pot', 'cob', 'codp', 'copp'],
            ['Agility', 'AG', 'ag_stat', 'ag_pot', 'agb', 'agdp', 'agpp'],
            [
                'Self Discipline', 'SD', 'sd_stat', 'sd_pot', 'sdb', 'sddp',
                'sdpp'
            ], ['Memory', 'ME', 'me_stat', 'me_pot', 'meb', 'medp', 'mepp'],
            ['Reasoning', 'RE', 're_stat', 're_pot', 'reb', 'redp', 'repp']]
    # Clear screen
    cfgData.clear_screen()
    # Redraw table
    cnt = 1
    print "+", 81 * "=", "+"
    print "|{:5}| {:7} | {:9} | {:5} | {:4} | {:5} || {:2}    | {:<16} | {:2} |".format(
        "", "", "", "Stat", "Dev", "Power", "", "", "")
    print "|{:5}| {:6} | {:9} | {:5} | {:4} | {:5} || {:^2}    | {:<16} | {:2} |".format(
        "", "Current", "Potential", "Bonus", "Pts", "Pts", "", "Stat", "")
    print "+", 81 * "=", "+"
    while cnt <= len(stat_temp_list):
        print "| {:>2}.) | {:^6} | {:^9} | {:^5} | {:4} | {:^5} || {:>2} .) | {:<16} | {:2} |".format(
            cnt, stat_temp_list[cnt - 1][0], stat_temp_list[cnt - 1][1],
            stat_temp_list[cnt - 1][2], stat_temp_list[cnt - 1][3],
            stat_temp_list[cnt - 1][4], cnt, stat[cnt - 1][0],
            stat[cnt - 1][1])
        cnt += 1
    print "+", 81 * "=", "+"
    print ""
    print "Assign rolls to the stat"
    print "You must assign a 90 or higher to your professions prime requisites stats"
    print ""
    print " Your Profession is a {:35}".format(char_dict['proname'])
    if char_dict['pro_pr3'] == "":
        print " Your Prime Requisites are {:2}/{:2}".format(
            char_dict['pro_pr1'], char_dict['pro_pr2'])
    else:
        print " Your Prime Requisites are {:2}/{:2}/{:3}".format(
            char_dict['pro_pr1'], char_dict['pro_pr2'], char_dict['pro_pr3'])
    print ""
    while len(stat) > 0:
        colx, coly = 0, 0
        # Select last stat to roll
        if len(stat) == 1:
            colx, coly = 1, 1
            y01, y02, y03 = stat[coly - 1][2], stat[coly - 1][3], stat[coly -
                                                                       1][4]
            y04, y05 = stat[coly - 1][5], stat[coly - 1][6]
            char_dict[y01] = stat_temp_list[colx - 1][0]
            char_dict[y02] = stat_temp_list[colx - 1][1]
            char_dict[y03] = stat_temp_list[colx - 1][2]
            char_dict[y04] = stat_temp_list[colx - 1][3]
            char_dict[y05] = stat_temp_list[colx - 1][4]
        # Select current value to assign to a stat
        while colx < 1 or colx > len(stat):
            try:
                colx = int(raw_input('Select a Current Roll: '))
                if colx < 1 or colx > len(stat):
                    print "You must enter a number between 1 and {:<2}".format(
                        len(stat))
            except:
                print "You must enter number between and {:<2}".format(
                    len(stat))
        # Select stat that current value will be assigned to
        while coly < 1 or coly > len(stat):
            pr = 0
            while pr == 0:
                try:
                    coly = int(raw_input('Select a Stat to assign: '))
                    #print pr,":pr"
                    if stat_temp_list[colx - 1][0] < 90:
                        '''print stat_temp_list[colx-1][0]
                        print stat[coly-1][1]
                        print char_dict['pro_pr1']
                        print char_dict['pro_pr2']
                        print char_dict['pro_pr3']'''
                        if stat[coly-1][1] == char_dict['pro_pr1'] or \
                           stat[coly-1][1] == char_dict['pro_pr2'] or stat[coly-1][1] == char_dict['pro_pr3']:
                            print "This is a prime requisite for your profession and must be assigned a value of 90 or higher!"
                            print "Please enter a higher value.."
                            print ""
                        else:
                            # Break loop
                            pr = 1
                    else:
                        pr = 1
                    if coly < 1 or coly > len(stat):
                        print "You must enter a number between 1 and {:<2}".format(
                            len(stat))
                        pr = 1
                except:
                    print "You must enter number between and {:<2}".format(
                        len(stat))

        y01, y02, y03 = stat[coly - 1][2], stat[coly - 1][3], stat[coly - 1][4]
        y04, y05 = stat[coly - 1][5], stat[coly - 1][6]

        char_dict[y01] = stat_temp_list[colx - 1][0]
        char_dict[y02] = stat_temp_list[colx - 1][1]
        char_dict[y03] = stat_temp_list[colx - 1][2]
        char_dict[y04] = stat_temp_list[colx - 1][3]
        char_dict[y05] = stat_temp_list[colx - 1][4]

        # Remove assigned stat and roll
        stat.pop(coly - 1)
        stat_temp_list.pop(colx - 1)
        if len(stat) > 1:
            cnt = 1
            print "+", 81 * "=", "+"
            print "|{:5}| {:7} | {:9} | {:5} | {:4} | {:5} || {:2}    | {:<16} | {:2} |".format(
                "", "", "", "Stat", "Dev", "Power", "", "", "")
            print "|{:5}| {:6} | {:9} | {:5} | {:4} | {:5} || {:2}    | {:<16} | {:2} |".format(
                "", "Current", "Potential", "Bonus", "Pts", "Pts", "", "Stat",
                "")
            print "+", 81 * "=", "+"
            while cnt <= len(stat_temp_list):
                print "| {:>2}.) | {:^6} | {:^9} | {:^5} | {:4} | {:^5} || {:>2} .) | {:<16} | {:2} |".format(
                    cnt, stat_temp_list[cnt - 1][0],
                    stat_temp_list[cnt - 1][1], stat_temp_list[cnt - 1][2],
                    stat_temp_list[cnt - 1][3], stat_temp_list[cnt - 1][4],
                    cnt, stat[cnt - 1][0], stat[cnt - 1][1])
                cnt += 1
            print "+", 81 * "=", "+"

    print ""
    print "+", 38 * "=", "+"
    print "| {:^38} |".format('Suggested Chooses')
    print "+", 38 * "=", "+"
    print "| {:^8} | {:^16} | {:^8} |".format('Gender', 'Hair', 'Eye')
    print "+", 38 * "=", "+"
    print "| {:^8} | {:^8} {:^8}| {:^8} |".format('Male', 'Black', 'Grey',
                                                  'Brown')
    print "| {:^8} | {:^8} {:^8}| {:^8} |".format('Female', 'Brown', 'Yellow',
                                                  'Blue')
    print "| {:^8} | {:^8} {:^8}| {:^8} |".format('', 'Blonde', 'White',
                                                  'Grey')
    print "| {:^8} | {:^8} {:^8}| {:^8} |".format('', 'Red', 'Calico', 'Red')
    print "| {:^8} | {:^8} {:^8}| {:^8} |".format('', 'Purple', 'None',
                                                  'Black')
    print "+", 38 * "=", "+"
    print ""

    # Enter character's gender
    le = 1
    while le == 1:
        try:
            sexch = raw_input("Enter a Gender: ")
            if re.match("^[A-Za-z]*$", sexch):
                le = 0
            else:
                print "Enter a gender for your character"
        except:
            print "Enter a gender for your character"
    char_dict['gender'] = sexch

    # Enter character's Hair Color
    le = 1
    while le == 1:
        try:
            hairch = raw_input("Enter a Hair color: ")
            if re.match("^[A-Za-z]*$", hairch):
                le = 0
            else:
                print "Enter a hair color for your character"
        except:
            print "Enter a hair color for your character"
    char_dict['hair'] = hairch

    # Enter character's Eye Color
    le = 1
    while le == 1:
        try:
            eyech = raw_input("Enter a Eye color: ")
            if re.match("^[A-Za-z]*$", eyech):
                le = 0
            else:
                print "Enter a eye color for your character"
        except:
            print "Enter a eye color for your character"
    char_dict['eye'] = eyech

    # Enter characters age
    age = ""
    while age < 1 or age > 1000:
        try:
            age = int(raw_input("Character's Age: "))
        except:
            print "You must enter a number.."
    char_dict['age'] = age

    ht = ""
    while ht == "":
        try:
            ht = str(raw_input("Enter Height: "))
        except:
            print "You must enter a height in ft' in\" format"
    # Enter weight
    wt = ""
    while wt < 1 or wt > 1000:
        try:
            wt = int(raw_input("Enter Weight: "))
        except:
            print "Enter a number between 1 and 1000.."
    char_dict['height'], char_dict['weight'] = ht, wt

    # Load data into dictionary for saving of the character
    char_dict['lvl'] = 0
    char_dict['realm'] = plist[pro_ch][8]
    char_dict['stmb'], char_dict['qumb'], char_dict['emmb'], char_dict[
        'inmb'], char_dict['prmb'] = 0, 0, 0, 0, 0
    char_dict['comb'], char_dict['agmb'], char_dict['sdmb'], char_dict[
        'remb'], char_dict['memb'] = 0, 0, 0, 0, 0
    hp_math = Decimal(char_dict['co_stat']) / Decimal(10)
    hp = Decimal(hp_math).quantize(Decimal('1e-3'))
    char_dict['hp_base'] = int(round(hp, 0))

    #######################
    # Calcalute Total Bonus
    #######################
    raclist = []
    with open(cfgData.cfg_dir + "/race.csv") as rf:
        rline = rf.readlines()
    raclist = [x.strip() for x in rline]
    for x in raclist:
        #print x.split(",")
        if x.split(",")[1] == char_dict['race']:
            char_dict['strb'] = x.split(",")[2]
            char_dict['qurb'] = x.split(",")[3]
            char_dict['prrb'] = x.split(",")[4]
            char_dict['inrb'] = x.split(",")[5]
            char_dict['emrb'] = x.split(",")[6]
            char_dict['corb'] = x.split(",")[7]
            char_dict['agrb'] = x.split(",")[8]
            char_dict['sdrb'] = x.split(",")[9]
            char_dict['merb'] = x.split(",")[10]
            char_dict['rerb'] = x.split(",")[11]
            char_dict['Essmod'] = x.split(",")[12]
            char_dict['Chanmod'] = x.split(",")[13]
            char_dict['Mentmod'] = x.split(",")[14]
            char_dict['Poimod'] = x.split(",")[15]
            char_dict['Dismod'] = x.split(",")[16]
            char_dict['HitDie'] = x.split(",")[19]

    # Add Total Bonus of skills to character data
    char_dict['sttb'] = (int(char_dict['stb']) + int(char_dict['strb']) +
                         int(char_dict['stmb']))
    char_dict['qutb'] = (int(char_dict['qub']) + int(char_dict['qurb']) +
                         int(char_dict['qumb']))
    char_dict['prtb'] = (int(char_dict['prb']) + int(char_dict['prrb']) +
                         int(char_dict['prmb']))
    char_dict['intb'] = (int(char_dict['inb']) + int(char_dict['inrb']) +
                         int(char_dict['inmb']))
    char_dict['emtb'] = (int(char_dict['emb']) + int(char_dict['emrb']) +
                         int(char_dict['emmb']))
    char_dict['cotb'] = (int(char_dict['cob']) + int(char_dict['corb']) +
                         int(char_dict['comb']))
    char_dict['agtb'] = (int(char_dict['agb']) + int(char_dict['agrb']) +
                         int(char_dict['agmb']))
    char_dict['sdtb'] = (int(char_dict['sdb']) + int(char_dict['sdrb']) +
                         int(char_dict['sdmb']))
    char_dict['metb'] = (int(char_dict['meb']) + int(char_dict['merb']) +
                         int(char_dict['memb']))
    char_dict['retb'] = (int(char_dict['reb']) + int(char_dict['rerb']) +
                         int(char_dict['remb']))

    # Set Armor defaults
    char_dict['armorType'] = 1
    char_dict['armorTypeDesc'] = "Skin"
    char_dict['at_min_mod'] = 0
    char_dict['at_max_mod'] = 0
    char_dict['at_miss_pen'] = 0
    char_dict['at_qu_pen'] = 0
    char_dict['shieldType'] = "None"
    char_dict['shieldMeDB'] = 0
    char_dict['shieldMiDB'] = 0
    char_dict['shieldMaDB'] = 0
    char_dict['helm'] = "None"
    char_dict['helmMaDB'] = -5
    char_dict['armGrea'] = "None"
    char_dict['legGrea'] = "None"
    char_dict['at_qu_pen'] = 0

    # Development Points
    tdp = (float(char_dict['codp']) + float(char_dict['agdp']) +
           float(char_dict['sddp']) + float(char_dict['medp']) +
           float(char_dict['redp'])) * float(cfgData.dp_multipler)
    char_dict['dp'] = round(tdp, 1)
    dp_math = Decimal(char_dict['dp'])
    dp = Decimal(dp_math).quantize(Decimal('1e-3'))
    char_dict['tempdp'] = int(round(dp, 0))

    # Set Resistance Roll Modifiers
    char_dict['Essmod'] = int(char_dict['Essmod']) + int(char_dict['emtb'])
    char_dict['Chanmod'] = int(char_dict['Chanmod']) + int(char_dict['intb'])
    char_dict['Mentmod'] = int(char_dict['Mentmod']) + int(char_dict['prtb'])
    char_dict['Poimod'] = int(char_dict['Poimod']) + int(char_dict['cotb'])
    char_dict['Dismod'] = int(char_dict['Dismod']) + int(char_dict['cotb'])

    # Power Point Math
    char_dict['stpp'], char_dict['qupp'], char_dict['copp'], char_dict[
        'agpp'], char_dict['sdpp'], char_dict['mepp'], char_dict[
            'repp'] = "-", "-", "-", "-", "-", "-", "-"
    if char_dict['mrealm'] == "NON":
        char['prpp'], char_dict['inpp'], char_dict['empp'] = 0.0, 0.0, 0.0
        char_dict['tpp'] = 0.0
    if char_dict['mrealm'] == "PR":
        char_dict['inpp'], char_dict['empp'] = 0.0, 0.0
        char_dict['tpp'] = char_dict['prpp']
    if char_dict['mrealm'] == "IN":
        char_dict['empp'], char_dict['prpp'] = 0.0, 0.0
        char_dict['tpp'] = char_dict['inpp']
    if char_dict['mrealm'] == "EM":
        char_dict['inpp'], char_dict['prpp'] = 0.0, 0.0
        char_dict['tpp'] = char_dict['empp']
    if char_dict['mrealm'] == "IP":
        char_dict['empp'] = 0.0
        char_dict['tpp'] = (float(char_dict['inpp']) +
                            float(char_dict['prpp'])) / 2
    if char_dict['mrealm'] == "PE":
        char_dict['inpp'] = 0.0
        char_dict['tpp'] = (float(char_dict['empp']) +
                            float(char_dict['prpp'])) / 2
    if char_dict['mrealm'] == "IE":
        char_dict['prpp'] = 0.0
        char_dict['tpp'] = (float(char_dict['inpp']) +
                            float(char_dict['empp'])) / 2
    if char_dict['mrealm'] == "AR":
        char_dict['tpp'] = (float(char_dict['inpp']) + float(char_dict['prpp'])
                            + float(char_dict['empp'])) / 3

    # Development Point Math
    stdp, qudp, emdp, indp, prdp = "-", "-", "-", "-", "-"

    # Set Character's First Name
    le = 1
    while le == 1:
        try:
            first_name = raw_input('Enter the Character\'s First Name: ')
            if re.match("^[A-Za-z]*$", first_name):
                le = 0
            else:
                print "You must enter a First name for your character!"
        except:
            print "You must enter a First name for your character!"
    char_dict['name'] = first_name
    # Set Last Name
    last_name = ""
    last_name = raw_input('Enter the Character\'s Last Name: ')
    if last_name == "":
        char_dict['Fullname'] = first_name
    else:
        char_dict['FullName'] = first_name + " " + last_name
    char_path = cfgData.char_dir + "/" + first_name

    # Check if character exists
    path_check = os.path.exists(char_path + "/" + first_name + ".json")
    while path_check == True:
        print "Character exists! Please enter a different name for your character"
        le = 1
        try:
            first_name = raw_input('Enter the Character\'s First Name: ')
            if re.match("^[A-Za-z]*$", first_name):
                le = 0
                char_path = cfgData.char_dir + "/" + first_name
                path_check = os.path.exists(char_path + "/" + first_name +
                                            ".json")
            else:
                print "You must enter a First name for your character!"
        except:
            print "Character exists! Please enter a different name for your character"

        # If character and folder doesn't exist - create it
        char_dict['name'] = first_name
    if not os.path.exists(char_path):
        os.makedirs(char_path)

    # Write out file
    with open(char_path + "/" + first_name + ".json", 'w') as f:
        f.write(json.dumps(char_dict))

    # Open Skill file
    with open(cfgData.cfg_dir + "/ds.csv") as f:
        sl = f.read().splitlines()
    skill_list = []
    for list in sl:
        skill_list.append(list.split(","))
        crt = 1

    # Loop through skills and add to dictionary
    for i in skill_list:
        #print i[1]
        stat_tb2, stat_tb3, stat_tb4 = i[2].lower() + "tb", i[3].lower(
        ) + "tb", i[4].lower() + "tb"
        if i[2] == "NA" or i[3] == "NA":
            char_skill[i[0]] = (i[1], i[5], i[7], i[proID], i[6], 0, 0, 0, 0,
                                0, 0, 0, 0, 0, 0)
        elif i[2] == "":
            if i[1].startswith("Spell") or i[1].startswith(
                    "Transcend") or i[1].startswith("Power"):
                if char_dict['mrealm'] == "NA":
                    i[2], i[5] = "NA", "NA"
                    char_skill[i[0]] = (i[1], i[5], i[7], i[proID], i[6], 0, 0,
                                        0, 0, 0, 0, 0, 0, 0, 0)
                if char_dict['mrealm'] == "EM":
                    stat_tb2, i[5] = "em", char_dict['mrealm']
                    char_skill[i[0]] = (i[1], i[5], i[7], i[proID], i[6], 0, 0,
                                        0, 0, 0, 0, 0, 0, 0, 0)
                if char_dict['mrealm'] == "IN":
                    stat_tb2, i[5] = "in", char_dict['mrealm']
                    char_skill[i[0]] = (i[1], i[5], i[7], i[proID], i[6], 0, 0,
                                        0, 0, 0, 0, 0, 0, 0, 0)
                if char_dict['mrealm'] == "PR":
                    stat_tb2, i[5] = "pr", char_dict['mrealm']
                    char_skill[i[0]] = (i[1], i[5], i[7], i[proID], i[6], 0, 0,
                                        0, 0, 0, 0, 0, 0, 0, 0)
                if char_dict['mrealm'] == "IP":
                    stat_tb2, stat_tb3, i[5] = "in", "pr", i[6]
                    char_skill[i[0]] = (i[1], i[5], i[7], i[proID], i[6], 0, 0,
                                        0, 0, 0, 0, 0, 0, 0, 0)
                if char_dict['mrealm'] == "PE":
                    stat_tb2, stat_tb3, i[5] = "em", "pr", i[6]
                    char_skill[i[0]] = (i[1], i[5], i[7], i[proID], i[6], 0, 0,
                                        0, 0, 0, 0, 0, 0, 0, 0)
                if char_dict['mrealm'] == "IE":
                    stat_tb2, stat_tb3, i[5] = "in", "em", i[6]
                    char_skill[i[0]] = (i[1], i[5], i[7], i[proID], i[6], 0, 0,
                                        0, 0, 0, 0, 0, 0, 0, 0)
                if char_dict['mrealm'] == "AR":
                    stat_tb2, stat_tb3, stat_tb4, i[5] = "em", "in", "pr", i[6]
                    char_skill[i[0]] = (i[1], i[5], i[7], i[proID], i[6], 0, 0,
                                        0, 0, 0, 0, 0, 0, 0, 0)
        elif i[3] == "":
            char_skill[i[0]] = (i[1], i[5], i[7], i[proID], i[6], 0, 0, 0, 0,
                                0, 0, 0, 0, 0, 0)
        else:
            char_skill[i[0]] = (i[1], i[5], i[7], i[proID], i[6], 0, 0, 0, 0,
                                0, 0, 0, 0, 0, 0)
    # Write Character data to file
    with open(
            cfgData.char_dir + "/" + char_dict['name'] + "/" +
            char_dict['name'].capitalize() + "_Skills.json", 'w') as f:
        f.write(json.dumps(char_skill))

    # Set Weapon costs using function
    weapon_costs(first_name)
コード例 #3
0
    print 30 * "=", "Character modifications", 30 * "="
    print
    print "1. Add experience to character"
    print "2. Add/Increase skills"
    print "3. Add skills for imported character"
    print "4. Stat gain"
    print "5. Export Character Sheet"
    print "6. Add Misc Stat bonus"
    print "7. Add Misc Skill bonus"
    print "8. Assign Armor/Shield to character"
    print ""
    print "X. Exit"


# Clear the clear_screen
cfgData.clear_screen()


#####################
###   Sub Menu    ###
#####################
def sloop1():
    smloop = True
    while smloop:
        print_smenu1()
        choice = raw_input("Enter you choice: ")
        print
        if choice == "1":
            cfgData.clear_screen()
            charCreate.create_char()
        if choice == "2":
コード例 #4
0
ファイル: charData.py プロジェクト: telathos/pyRoleManager
def stat_gain():
    cfgData.clear_screen()
    p = charMenu.char_menu()
    menu_len = len(p)
    while True:
        s = int(raw_input("Select Character: "))
        if s >= 1 and s <= menu_len:
            break
        else:
            print "Invalid Selection! Select a character from the list"
    skill_list = []
    s -= 1
    user_name = p[s]
    with open(cfgData.char_dir + "/" + user_name + "/" + user_name + ".json",
              "r") as cf:
        char_dict = json.load(cf)
    st_diff = char_dict['st_pot'] - char_dict['st_stat']
    qu_diff = char_dict['qu_pot'] - char_dict['qu_stat']
    pr_diff = char_dict['pr_pot'] - char_dict['pr_stat']
    em_diff = char_dict['em_pot'] - char_dict['em_stat']
    in_diff = char_dict['in_pot'] - char_dict['in_stat']
    co_diff = char_dict['co_pot'] - char_dict['co_stat']
    sd_diff = char_dict['sd_pot'] - char_dict['sd_stat']
    ag_diff = char_dict['ag_pot'] - char_dict['ag_stat']
    me_diff = char_dict['me_pot'] - char_dict['me_stat']
    re_diff = char_dict['re_pot'] - char_dict['re_stat']
    st_stat, qu_stat, pr_stat, em_stat, in_stat = char_dict[
        'st_stat'], char_dict['qu_stat'], char_dict['pr_stat'], char_dict[
            'em_stat'], char_dict['in_stat']
    co_stat, sd_stat, ag_stat, me_stat, re_stat = char_dict[
        'co_stat'], char_dict['sd_stat'], char_dict['ag_stat'], char_dict[
            'me_stat'], char_dict['re_stat']

    difflist = [[st_stat, st_diff, "ST", "st_stat"],
                [qu_stat, qu_diff, "QU", "qu_stat"],
                [pr_stat, pr_diff, "PR", "pr_stat"],
                [in_stat, in_diff, "IN", "in_stat"],
                [em_stat, em_diff, "EM", "em_stat"],
                [co_stat, co_diff, "CO", "co_stat"],
                [ag_stat, ag_diff, "AG", "ag_stat"],
                [sd_stat, sd_diff, "SD", "sd_stat"],
                [me_stat, me_diff, "ME", "me_stat"],
                [re_stat, re_diff, "RE", "re_stat"]]
    change = 0

    #print difflist
    for x in difflist:
        print
        print "Stat: {:2}".format(x[2])
        roll = int(raw_input("Enter roll: "))
        change = stat_gain_lookup(x[1], roll)
        newStat = x[0] + change
        print "Stat: {:2} had a change of {:<2}".format(x[2], change)
        print "Prev: {:<3}".format(x[0])
        print "Cur:  {:<3}".format(newStat)
        char_dict[x[3]] = newStat
        #print char_dict[x[3]]

    # Open chart of stat values
    with open(cfgData.cfg_dir + "/sttchart.csv") as f:
        statchart = f.read().splitlines()
    sc = []

    for x in statchart:
        sc.append(x.split(","))

    # Loop through statistics to pull bonuses
    for x1 in sc:
        if int(x1[0]) == int(char_dict['st_stat']):
            stb, stdp, stpp = x1[1], x1[2], x1[3]
        if int(x1[0]) == int(char_dict['qu_stat']):
            qub, qudp, qupp = x1[1], x1[2], x1[3]
        if int(x1[0]) == int(char_dict['pr_stat']):
            prb, prdp, prpp = x1[1], x1[2], x1[3]
        if int(x1[0]) == int(char_dict['in_stat']):
            inb, indp, inpp = x1[1], x1[2], x1[3]
        if int(x1[0]) == int(char_dict['em_stat']):
            emb, emdp, empp = x1[1], x1[2], x1[3]
        if int(x1[0]) == int(char_dict['co_stat']):
            cob, codp, copp = x1[1], x1[2], x1[3]
        if int(x1[0]) == int(char_dict['ag_stat']):
            agb, agdp, agpp = x1[1], x1[2], x1[3]
        if int(x1[0]) == int(char_dict['sd_stat']):
            sdb, sddp, sdpp = x1[1], x1[2], x1[3]
        if int(x1[0]) == int(char_dict['me_stat']):
            meb, medp, mepp = x1[1], x1[2], x1[3]
        if int(x1[0]) == int(char_dict['re_stat']):
            reb, redp, repp = x1[1], x1[2], x1[3]

    ###################
    # Lookup Race Bonus
    ###################
    with open(cfgData.cfg_dir + "/race.csv") as r:
        racechart = r.read().splitlines()
    r.close()
    rc = []

    for x in racechart:
        rc.append(x.split(","))

    # Race Bonus
    for x2 in rc:
        if x2[0] == char_dict['race']:
            raceb = x2

    #######################
    # Calcalute Total Bonus
    #######################

    sttb = (int(stb) + int(raceb[1]) + int(char_dict['stmb']))
    qutb = (int(qub) + int(raceb[2]) + int(char_dict['qumb']))
    prtb = (int(prb) + int(raceb[3]) + int(char_dict['prmb']))
    intb = (int(inb) + int(raceb[4]) + int(char_dict['inmb']))
    emtb = (int(emb) + int(raceb[5]) + int(char_dict['emmb']))
    cotb = (int(cob) + int(raceb[6]) + int(char_dict['comb']))
    agtb = (int(agb) + int(raceb[7]) + int(char_dict['agmb']))
    sdtb = (int(sdb) + int(raceb[8]) + int(char_dict['sdmb']))
    metb = (int(meb) + int(raceb[9]) + int(char_dict['memb']))
    retb = (int(reb) + int(raceb[10]) + int(char_dict['remb']))
    tdp = char_dict['dp']
    # Updaet character file
    char_dict['sttb'], char_dict['qutb'] = sttb, qutb
    char_dict['prtb'], char_dict['intb'] = prtb, intb
    char_dict['emtb'], char_dict['cotb'] = emtb, cotb
    char_dict['agtb'], char_dict['sdtb'] = agtb, sdtb
    char_dict['metb'], char_dict['retb'] = metb, retb

    # Power Point Math
    stpp, qupp, copp, agpp, sdpp, mepp, repp = "-", "-", "-", "-", "-", "-", "-"
    if char_dict['realm'] == "NULL":
        prpp, inpp, empp = 0.0, 0.0, 0.0
        tpp = 0.0
    if char_dict['realm'] == "PR":
        inpp, empp = 0.0, 0.0
        tpp = prpp
    if char_dict['realm'] == "IN":
        empp, prpp = 0.0, 0.0
        tpp = inpp
    if char_dict['realm'] == "EM":
        inpp, prpp = 0.0, 0.0
        tpp = empp
    if char_dict['realm'] == "IP":
        empp = 0.0
        tpp = (float(inpp) + float(prpp)) / 2
    if char_dict['realm'] == "PE":
        inpp = 0.0
        tpp = (float(empp) + float(prpp)) / 2
    if char_dict['realm'] == "IE":
        prpp = 0.0
        tpp = (float(inpp) + float(empp)) / 2
    if char_dict['realm'] == "AR":
        tpp = (float(inpp) + float(prpp) + float(empp)) / 3

    # Development Point Math
    stdp, qudp, emdp, indp, prdp = "-", "-", "-", "-", "-"

    # Write Character data to file
    with open(cfgData.char_dir + '/' + user_name + '/' + user_name + '.json',
              'w') as f:
        f.write(json.dumps(char_dict))
コード例 #5
0
ファイル: charData.py プロジェクト: telathos/pyRoleManager
def show_char():
    p = charMenu.char_menu()
    menu_len = len(p)
    while True:
        s = int(raw_input("Select Character: "))
        if s >= 1 and s <= menu_len:
            break
        else:
            print "Invalid Selection! Select a character from the list"

    # Open the file
    char_dict = {}
    s -= 1
    char = p[s]
    with open(cfgData.char_dir + "/" + char + "/" + char + ".json", "r") as cf:
        char_dict = json.load(cf)
    # Open chart of stat values
    with open(cfgData.cfg_dir + "/sttchart.csv") as f:
        statchart = f.read().splitlines()
    sc = []

    for x in statchart:
        sc.append(x.split(","))

    # Loop through statistics to pull bonuses
    for x1 in sc:
        #print x1[0],":",x1[1],":",x1[2],":",x1[3]
        if int(x1[0]) == int(char_dict['st_stat']):
            stb, stdp, stpp = x1[1], x1[2], x1[3]
        if int(x1[0]) == int(char_dict['qu_stat']):
            qub, qudp, qupp = x1[1], x1[2], x1[3]
        if int(x1[0]) == int(char_dict['pr_stat']):
            prb, prdp, prpp = x1[1], x1[2], x1[3]
        if int(x1[0]) == int(char_dict['in_stat']):
            inb, indp, inpp = x1[1], x1[2], x1[3]
        if int(x1[0]) == int(char_dict['em_stat']):
            emb, emdp, empp = x1[1], x1[2], x1[3]
        if int(x1[0]) == int(char_dict['co_stat']):
            cob, codp, copp = x1[1], x1[2], x1[3]
        if int(x1[0]) == int(char_dict['ag_stat']):
            agb, agdp, agpp = x1[1], x1[2], x1[3]
        if int(x1[0]) == int(char_dict['sd_stat']):
            sdb, sddp, sdpp = x1[1], x1[2], x1[3]
        if int(x1[0]) == int(char_dict['me_stat']):
            meb, medp, mepp = x1[1], x1[2], x1[3]
        if int(x1[0]) == int(char_dict['re_stat']):
            reb, redp, repp = x1[1], x1[2], x1[3]

    ###################
    # Lookup Race Bonus
    ###################
    with open(cfgData.cfg_dir + "/race.csv") as r:
        racechart = r.read().splitlines()
    r.close()
    rc = []

    for x in racechart:
        rc.append(x.split(","))

    # Race Bonus
    for x2 in rc:
        if x2[0] == char_dict['race']:
            raceb = x2

    #######################
    # Calcalute Total Bonus
    #######################

    sttb = (int(stb) + int(raceb[1]) + int(char_dict['stmb']))
    qutb = (int(qub) + int(raceb[2]) + int(char_dict['qumb']))
    prtb = (int(prb) + int(raceb[3]) + int(char_dict['prmb']))
    intb = (int(inb) + int(raceb[4]) + int(char_dict['inmb']))
    emtb = (int(emb) + int(raceb[5]) + int(char_dict['emmb']))
    cotb = (int(cob) + int(raceb[6]) + int(char_dict['comb']))
    agtb = (int(agb) + int(raceb[7]) + int(char_dict['agmb']))
    sdtb = (int(sdb) + int(raceb[8]) + int(char_dict['sdmb']))
    metb = (int(meb) + int(raceb[9]) + int(char_dict['memb']))
    retb = (int(reb) + int(raceb[10]) + int(char_dict['remb']))
    tdp = char_dict['dp']

    cfgData.clear_screen()
    print "Calculating totals..."
    print

    # Create list of the level bonus
    lblist = []
    with open(cfgData.cfg_dir + "/pro.csv") as f:
        llbonus = f.read()
    for lb in llbonus.splitlines():
        rt = lb.split(",")
        if rt[0] == char_dict['pro_name']:
            lblist = [
                rt[9], rt[10], rt[11], rt[12], rt[13], rt[14], rt[15], rt[16],
                rt[17], rt[18], rt[19], rt[20], rt[21], rt[22], rt[23], rt[24]
            ]

    # Pull previously assigned weapon cost for normal weapon costs
    for v in char_dict:
        if v.isdigit():
            index = v
            if char_dict[v][0] == 'Dagger':
                hs1 = char_dict[v][3]
            if char_dict[v][0] == 'Mace':
                hc1 = char_dict[v][3]
            if char_dict[v][0] == 'Bola':
                thr = char_dict[v][3]
            if char_dict[v][0] == 'Quarterstaff':
                h2 = char_dict[v][3]
            if char_dict[v][0] == 'Short Bow':
                msl = char_dict[v][3]
            if char_dict[v][0] == 'Polearm':
                pa = char_dict[v][3]

    # Check if is a skill
    sklist = []
    for words in char_dict:
        if words.isdigit():
            index = words
            sklist.append([
                char_dict[words][0], char_dict[words][1], char_dict[words][2],
                char_dict[words][3], char_dict[words][5], char_dict[words][6],
                char_dict[words][7], char_dict[words][8], char_dict[words][10],
                char_dict[words][11], char_dict[words][12],
                char_dict[words][13], char_dict[words][14], index
            ])

            # Lookup category and Calcalute lvl Bonus
            if char_dict[words][4] == "academic":
                lvl_bonus = int(lblist[0])
            if char_dict[words][4] == "arms":
                lvl_bonus = int(lblist[1])
            if char_dict[words][4] == "athletic":
                lvl_bonus = int(lblist[2])
            if char_dict[words][4] == "base":
                lvl_bonus = int(lblist[3])
            if char_dict[words][4] == "body development":
                lvl_bonus = int(lblist[4])
            if char_dict[words][4] == "concentration":
                lvl_bonus = int(lblist[5])
            if char_dict[words][4] == "deadly":
                lvl_bonus = int(lblist[6])
            if char_dict[words][4] == "directed spells":
                lvl_bonus = int(lblist[7])
            if char_dict[words][4] == "general":
                lvl_bonus = int(lblist[8])
            if char_dict[words][4] == "linguistic":
                lvl_bonus = int(lblist[9])
            if char_dict[words][4] == "magical":
                lvl_bonus = int(lblist[10])
            if char_dict[words][4] == "medical":
                lvl_bonus = int(lblist[11])
            if char_dict[words][4] == "outdoor":
                lvl_bonus = int(lblist[12])
            if char_dict[words][4] == "perception":
                lvl_bonus = int(lblist[13])
            if char_dict[words][4] == "social":
                lvl_bonus = int(lblist[14])
            if char_dict[words][4] == "subterfuge":
                lvl_bonus = int(lblist[15])

            if char_dict['lvl'] <= 1:
                lvl_mult = 1
            elif char_dict['lvl'] >= 1 and char_dict['lvl'] <= 20:
                lvl_mult = int(char_dict['lvl'])
            else:
                lvl_mult = 20

            if char_dict['pro_name'] == "Fighter" and char_dict[words][
                    4] == "arms" and char_dict['lvl'] > 20:
                lvl_bonus = 60 + (char_dict['lvl'] - 20)
            else:
                lvl_bonus = lvl_bonus * lvl_mult
            char_dict[words][13] = lvl_bonus

            # Update weapon costs
            if not char_dict[words][2] == 'Polearm' or not char_dict[words][
                    2] == 'Missile':
                if char_dict[words][0].startswith('TWC'):
                    if char_dict[words][2] == '1-HS':
                        weatype = hs1
                    elif char_dict[words][2] == 'Thrown':
                        weatype = thr
                    elif char_dict[words][2] == '1-HC':
                        weatype = hc1
                    elif char_dict[words][2] == '2-H':
                        weatype = h2
                    if len(weatype) == 1:
                        twc_wea = int(weatype) * 2
                    elif len(weatype) == 2:
                        twc_wea = int(weatype) * 2
                    elif len(weatype) == 3:
                        temp = weatype.split('/')
                        twc_wea = ` int(temp[0]) * 2 ` + "/" + ` int(
                            temp[1]) * 2 `
                    char_dict[words][3] = twc_wea
                #print char_dict[words][0],":",char_dict[words][3]

                # Set weapon cost if NULL
            if char_dict[words][3] == 'NULL':
                if char_dict[words][2] == '1-HS':
                    char_dict[words][3] = hs1
                elif char_dict[words][2] == 'Thrown':
                    char_dict[words][3] = thr
                elif char_dict[words][2] == '1-HC':
                    char_dict[words][3] = hc1
                elif char_dict[words][2] == '2-H':
                    char_dict[words][3] = h2
                elif char_dict[words][2] == 'Polearm':
                    char_dict[words][3] = pa
                elif char_dict[words][2] == 'Missile':
                    char_dict[words][3] = msl

                # Write Character data to file
                with open(cfgData.char_dir + "/" + char + "/" + char + ".json",
                          "w") as f:
                    f.write(json.dumps(char_dict))

            # Get stat total bonuses
            stat = char_dict[words][1]
            if len(stat) == 2:
                if stat.upper() == "NA":
                    stat_bonus = 0
                else:
                    if stat == "ST":
                        stat_bonus = sttb
                    elif stat == "QU":
                        stat_bonus = qutb
                    elif stat == "PR":
                        stat_bonus = prtb
                    elif stat == "IN":
                        stat_bonus = intb
                    elif stat == "EM":
                        stat_bonus = emtb
                    elif stat == "CO":
                        stat_bonus = cotb
                    elif stat == "AG":
                        stat_bonus = agtb
                    elif stat == "SD":
                        stat_bonus = sdtb
                    elif stat == "ME":
                        stat_bonus = metb
                    elif stat == "RE":
                        stat_bonus = retb
                    char_dict[words][11] = stat_bonus
            elif len(stat) == 5:
                stats = stat.split('/')
                # Stat 1
                if stats[0] == "ST":
                    stat_bonus1 = sttb
                elif stats[0] == "QU":
                    stat_bonus1 = qutb
                elif stats[0] == "PR":
                    stat_bonus1 = prtb
                elif stats[0] == "IN":
                    stat_bonus1 = intb
                elif stats[0] == "EM":
                    stat_bonus1 = emtb
                elif stats[0] == "CO":
                    stat_bonus1 = cotb
                elif stats[0] == "AG":
                    stat_bonus1 = agtb
                elif stats[0] == "SD":
                    stat_bonus1 = sdtb
                elif stats[0] == "ME":
                    stat_bonus1 = metb
                elif stats[0] == "RE":
                    stat_bonus1 = retb
                # Stat 2
                if stats[1] == "ST":
                    stat_bonus2 = sttb
                elif stats[1] == "QU":
                    stat_bonus2 = qutb
                elif stats[1] == "PR":
                    stat_bonus2 = prtb
                elif stats[1] == "IN":
                    stat_bonus2 = intb
                elif stats[1] == "EM":
                    stat_bonus2 = emtb
                elif stats[1] == "CO":
                    stat_bonus2 = cotb
                elif stats[1] == "AG":
                    stat_bonus2 = agtb
                elif stats[1] == "SD":
                    stat_bonus2 = sdtb
                elif stats[1] == "ME":
                    stat_bonus2 = metb
                elif stats[1] == "RE":
                    stat_bonus2 = retb
                stat_bonus = (stat_bonus1 + stat_bonus2) / 2
                char_dict[words][11] = cfgData.iround(stat_bonus)
            elif len(stat) == 8:
                stats = stat.split('/')
                # Stat 1
                if stats[0] == "ST":
                    stat_bonus1 = sttb
                elif stats[0] == "QU":
                    stat_bonus1 = qutb
                elif stats[0] == "PR":
                    stat_bonus1 = prtb
                elif stats[0] == "IN":
                    stat_bonus1 = intb
                elif stats[0] == "EM":
                    stat_bonus1 = emtb
                elif stats[0] == "CO":
                    stat_bonus1 = cotb
                elif stats[0] == "AG":
                    stat_bonus1 = agtb
                elif stats[0] == "SD":
                    stat_bonus1 = sdtb
                elif stats[0] == "ME":
                    stat_bonus1 = metb
                elif stats[0] == "RE":
                    stat_bonus1 = retb
                # Stat 2
                if stats[1] == "ST":
                    stat_bonus2 = sttb
                elif stats[1] == "QU":
                    stat_bonus2 = qutb
                elif stats[1] == "PR":
                    stat_bonus2 = prtb
                elif stats[1] == "IN":
                    stat_bonus2 = intb
                elif stats[1] == "EM":
                    stat_bonus2 = emtb
                elif stats[1] == "CO":
                    stat_bonus2 = cotb
                elif stats[1] == "AG":
                    stat_bonus2 = agtb
                elif stats[1] == "SD":
                    stat_bonus2 = sdtb
                elif stats[1] == "ME":
                    stat_bonus2 = metb
                elif stats[1] == "RE":
                    stat_bonus2 = retb
                # Stat 3
                if stats[2] == "ST":
                    stat_bonus3 = sttb
                elif stats[2] == "QU":
                    stat_bonus3 = qutb
                elif stats[2] == "PR":
                    stat_bonus3 = prtb
                elif stats[2] == "IN":
                    stat_bonus3 = intb
                elif stats[2] == "EM":
                    stat_bonus3 = emtb
                elif stats[2] == "CO":
                    stat_bonus3 = cotb
                elif stats[2] == "AG":
                    stat_bonus3 = agtb
                elif stats[2] == "SD":
                    stat_bonus3 = sdtb
                elif stats[2] == "ME":
                    stat_bonus3 = metb
                elif stats[2] == "RE":
                    stat_bonus3 = retb
                stat_bonus = (stat_bonus1 + stat_bonus2 + stat_bonus3) / 3

            # Update dictionary
            char_dict[words][11] = cfgData.iround(stat_bonus)

            # Calcalute skill bonus
            skill_rank_total = char_dict[words][5] + char_dict[words][
                6] + char_dict[words][7] + char_dict[words][8]

            if char_dict[words][0] == 'Maneuvering in Soft Leather':
                skill_bonus = skill_rank_total * 5
            elif char_dict[words][0] == 'Maneuvering in Rigid Leather':
                skill_bonus = skill_rank_total * 5
            elif char_dict[words][0] == 'Maneuvering in Chain':
                skill_bonus = skill_rank_total * 5
            elif char_dict[words][0] == 'Maneuvering in Plate':
                skill_bonus = skill_rank_total * 5
            elif skill_rank_total <= 10:
                skill_bonus = skill_rank_total * 5
            elif skill_rank_total >= 11 and skill_rank_total <= 20:
                skill_bonus = 50 + ((skill_rank_total - 10) * 2)
            elif skill_rank_total >= 21 and skill_rank_total <= 30:
                skill_bonus = 70 + ((skill_rank_total - 20) * 1)
            else:
                skill_bonus = 80 + ((skill_rank_total - 30) * 0.5)
            # Update dictionary
            char_dict[words][10] = cfgData.iround(skill_bonus)

            # Calcalute Total Skill Bonus
            total_skill_bonus = char_dict[words][10] + char_dict[words][
                11] + char_dict[words][12] + char_dict[words][13]
            # Update dictionary
            char_dict[words][14] = total_skill_bonus
        # Write Character data to file
        with open(cfgData.char_dir + "/" + char + "/" + char + ".json",
                  "w") as f:
            f.write(json.dumps(char_dict))

    # Power Point Math
    stpp, qupp, copp, agpp, sdpp, mepp, repp = "-", "-", "-", "-", "-", "-", "-"
    if char_dict['realm'] == "NULL":
        prpp, inpp, empp = 0.0, 0.0, 0.0
        tpp = 0.0
    if char_dict['realm'] == "PR":
        inpp, empp = 0.0, 0.0
        tpp = prpp
    if char_dict['realm'] == "IN":
        empp, prpp = 0.0, 0.0
        tpp = inpp
    if char_dict['realm'] == "EM":
        inpp, prpp = 0.0, 0.0
        tpp = empp
    if char_dict['realm'] == "IP":
        empp = 0.0
        tpp = (float(inpp) + float(prpp)) / 2
    if char_dict['realm'] == "PE":
        inpp = 0.0
        tpp = (float(empp) + float(prpp)) / 2
    if char_dict['realm'] == "IE":
        prpp = 0.0
        tpp = (float(inpp) + float(empp)) / 2
    if char_dict['realm'] == "AR":
        tpp = (float(inpp) + float(prpp) + float(empp)) / 3

    # Development Point Math
    stdp, qudp, emdp, indp, prdp = "-", "-", "-", "-", "-"

    if char_dict['lvl'] == 0:
        lvl = "AD"
    elif char_dict['lvl'] == 0.5:
        lvl = "AP"
    else:
        lvl = char_dict['lvl']

    cfgData.clear_screen()
    print
    print "*", 93 * "-", "*"
    print "| Name: {:<23} Level: {:2}{:13}Race: {:20}{:16}|".format(
        char_dict['FullName'].title(), lvl, "", char_dict['race'], "")
    print "| Profession: {:<18}Exp: {:<8}{:5}Next Level: {:<33} |".format(
        char_dict['pro_name'].title(), char_dict['exp'], "",
        char_dict['next_lvl'])
    print "| Sex: {:<7}{:10}Age: {:<4}{:63}|".format(
        char_dict['gender'].title(), "", char_dict['age'], "")
    print "| Height: {:<7}{:4}Weight: {:<4}{:63}|".format(
        char_dict['height'], " ", char_dict['weight'], "")
    print "| Hair: {:<8}{:7}Eyes: {:<8}{:59}|".format(char_dict['hair'], "",
                                                      char_dict['eye'], "")
    print "*", 93 * "-", "*"
    print "|                                          Stats                                                |"
    print "*", 93 * "-", "*"
    print "|                             |         |           |  Stat |  Race | Dev | PP  | Misc  | Total |"
    print "|                             | Current |   Pot'l   | Bonus | Bonus | Pts | Pts | Bonus | Bonus |"
    print "*", 93 * "-", "*"
    print "| Strength (ST)               |{:^9}|{:^11}|{:^7}|{:^7}|{:^5}|{:^5}|{:^7}|{:^7}|".format(
        char_dict['st_stat'], char_dict['st_pot'], stb, raceb[1], stdp, stpp,
        char_dict['stmb'], sttb)
    print "| Quickness (QU)              |{:^9}|{:^11}|{:^7}|{:^7}|{:^5}|{:^5}|{:^7}|{:^7}|".format(
        char_dict['qu_stat'], char_dict['qu_pot'], qub, raceb[2], qudp, qupp,
        char_dict['qumb'], qutb)
    print "| Presence (PR)               |{:^9}|{:^11}|{:^7}|{:^7}|{:^5}|{:^5}|{:^7}|{:^7}|".format(
        char_dict['pr_stat'], char_dict['pr_pot'], prb, raceb[3], prdp, prpp,
        char_dict['prmb'], prtb)
    print "| Intuition (IN)              |{:^9}|{:^11}|{:^7}|{:^7}|{:^5}|{:^5}|{:^7}|{:^7}|".format(
        char_dict['in_stat'], char_dict['in_pot'], inb, raceb[4], indp, inpp,
        char_dict['inmb'], intb)
    print "| Empathy (EM)                |{:^9}|{:^11}|{:^7}|{:^7}|{:^5}|{:^5}|{:^7}|{:^7}|".format(
        char_dict['em_stat'], char_dict['em_pot'], emb, raceb[5], emdp, empp,
        char_dict['emmb'], emtb)
    print "| Constitution (CO)           |{:^9}|{:^11}|{:^7}|{:^7}|{:^5}|{:^5}|{:^7}|{:^7}|".format(
        char_dict['co_stat'], char_dict['co_pot'], cob, raceb[6], codp, copp,
        char_dict['comb'], cotb)
    print "| Agility (AG)                |{:^9}|{:^11}|{:^7}|{:^7}|{:^5}|{:^5}|{:^7}|{:^7}|".format(
        char_dict['ag_stat'], char_dict['ag_pot'], agb, raceb[7], agdp, agpp,
        char_dict['agmb'], agtb)
    print "| Self Discipline (SD)        |{:^9}|{:^11}|{:^7}|{:^7}|{:^5}|{:^5}|{:^7}|{:^7}|".format(
        char_dict['sd_stat'], char_dict['sd_pot'], sdb, raceb[8], sddp, sdpp,
        char_dict['sdmb'], sdtb)
    print "| Memory (ME)                 |{:^9}|{:^11}|{:^7}|{:^7}|{:^5}|{:^5}|{:^7}|{:^7}|".format(
        char_dict['me_stat'], char_dict['me_pot'], meb, raceb[9], medp, mepp,
        char_dict['memb'], metb)
    print "| Reasoning (RE)              |{:^9}|{:^11}|{:^7}|{:^7}|{:^5}|{:^5}|{:^7}|{:^7}|".format(
        char_dict['re_stat'], char_dict['re_pot'], reb, raceb[10], redp, repp,
        char_dict['remb'], retb)
    print "*", 93 * "-", "*"
    print "| Development/Power Points:{:41}| {:^4}| {:^4}|               |".format(
        " ", tdp, tpp)
    print "*", 93 * "-", "*"
    print "| {:32} | Hobby | AD  | AP  |     | Skill| Stat |Level| Misc | Total |".format(
        " ")
    print "| {:32} | Ranks |Ranks|Ranks|Ranks| Bonus| Bonus|Bonus| Bonus| Bonus |".format(
        "Skill Name")
    print "*", 93 * "-", "*"
    sklist = []
    for words in char_dict:
        if words.isdigit():
            if char_dict[words][5] > 0 or char_dict[words][6] > 0 or char_dict[
                    words][7] > 0 or char_dict[words][8] > 0:
                print "| {:32} | {:^5} |{:^5}|{:^5}|{:^5}|{:^6}|{:^6}|{:^5}|{:^6}|{:^7}|".format(
                    char_dict[words][0], char_dict[words][5],
                    char_dict[words][6], char_dict[words][7],
                    char_dict[words][8], char_dict[words][10],
                    char_dict[words][11], char_dict[words][13],
                    char_dict[words][12], char_dict[words][14])
    print "*", 93 * "-", "*"
    print
    print
コード例 #6
0
ファイル: charData.py プロジェクト: telathos/pyRoleManager
def lang_set(char):
    with open(cfgData.char_dir + "/" + char + "/" + char + ".json", "r") as cf:
        char_dict = json.load(cf)

    # Pull number of languages from race.csv
    with open(cfgData.cfg_dir + "/lang.csv", "r") as la:
        lan = la.read().splitlines()

    #clear_screen()
    num_of_lang = 0
    with open(cfgData.cfg_dir + "/race.csv", "r") as rf:
        racelist = rf.read().splitlines()
    # loop thru race list to find a matching race
    f = 0
    while f < len(racelist):
        x = racelist[f].split(',')
        f += 1
        if x[0] == char_dict['race']:
            num_of_lang = x[16]
    # Check if character's languages are set
    check = 1
    lcheck = []
    while check <= int(num_of_lang):
        lanSearch = "lang" + ` check `
        if lanSearch in char_dict:
            lcheck.append(check)
        check += 1
    if len(lcheck) == int(num_of_lang):
        print "Base languages are already set."
        print "Returning to Main Menu"
        print
    else:
        with open(cfgData.cfg_dir + "/lc.csv", "r") as r:
            lc = r.read().splitlines()

        lanlist = []
        lcnt = 1
        while len(lanlist) < int(num_of_lang):
            num = 1
            j = 0
            print "+", 87 * "=", "+"
            for x in lc:
                j = x.split(';')
                print "| {:<2} | {:40}| {:40} |".format(j[0], j[1], j[2])
            print "+", 87 * "=", "+"
            print
            # Create menu of languages
            for y in lan:
                print "{:<2}.) {:20}".format(num, y)
                num += 1
            lanch = ""
            while lanch < 1 or lanch > len(lan):
                try:
                    lanch = int(raw_input("Select Language: "))
                except:
                    print "Enter a number between 1 and {:2}..".format(
                        len(lan))

            lanspoke = ""
            while lanspoke < 1 or lanspoke > 10:
                try:
                    lanspoke = int(raw_input("Enter Spoken rank: "))
                except:
                    print "Enter a number between 1 and 10.."
            lanwritten = ""
            while lanwritten < 1 or lanwritten > 10:
                try:
                    lanwritten = int(raw_input("Enter Written rank: "))
                except:
                    print "Enter a number between 1 and 10.."

            lanlist.append(lan[lanch - 1])
            lan.pop(lanch - 1)
            y = "lang" + ` lcnt `
            char_dict[y] = [lanlist[lcnt - 1], lanspoke, lanwritten]
            lcnt += 1

        # Add languages to dictionary
        # Open character file to write out data
        with open(cfgData.char_dir + "/" + char + "/" + char + ".json",
                  'w') as f:
            f.write(json.dumps(char_dict))
        cfgData.clear_screen()
コード例 #7
0
ファイル: charData.py プロジェクト: telathos/pyRoleManager
def mbbonus():
    p = charMenu.char_menu()
    menu_len = len(p)
    while True:
        s = int(raw_input("Select Character: "))
        if s >= 1 and s <= menu_len:
            break
        else:
            print "Invalid Selection! Select a character from the list"

    # Open the file
    s -= 1
    char = p[s]
    with open(cfgData.char_dir + "/" + char + "/" + char + ".json", "r") as cf:
        char_dict = json.load(cf)

    stat_name = [["Strength", "stmb", "stb", "strb", "sttb"],
                 ["Quickness", "qumb", "qub", "qurb", "qutb"],
                 ["Presence", "prmb", "prb", "prrb", "prtb"],
                 ["Intuition", "inmb", "inb", "inrb", "intb"],
                 ["Empathy", "emmb", "emb", "emrb", "emtb"],
                 ["Constitution", "comb", "cob", "corb", "cotb"],
                 ["Agility", "agmb", "agb", "agrb", "agtb"],
                 ["Self Discipline", "sdmb", "sdb", "sdrb", "sdtb"],
                 ["Memory", "memb", "meb", "merb", "metb"],
                 ["Reasoning", "remb", "reb", "rerb", "retb"]]
    mb = ""

    cfgData.clear_screen()
    mbloop = True
    while mbloop:
        cnt, menu = 1, 0
        print ""
        print "+", 47 * "=", "+"
        while cnt <= len(stat_name):
            print "|  {:>2}.) {:9}({:2})   {:>2}.) {:16}({:2}) |".format(
                cnt, stat_name[menu][0], char_dict[stat_name[menu][1]],
                cnt + 1, stat_name[menu + 1][0],
                char_dict[stat_name[menu + 1][1]])
            cnt += 2
            menu += 2
        print "|", 47 * " ", "|"
        print "|  {:>2}.) {:42}|".format("X", "Exit")
        print "+", 47 * "=", "+"
        print ""
        le = 1
        while le == 1:
            try:
                mbch = raw_input("Select a stat to increase: ")
                if re.match("^[1-9xX]$", mbch):
                    le = 0
                elif re.match("^10$", mbch):
                    le = 0
                else:
                    print "Enter a number between 1 and 10!"
            except:
                print "Enter a number or X to exit"

            # Run Misc Bonus function
            if mbch.upper() == "X":
                le = 0
                mbloop = False
            else:
                j = int(mbch)
                if 0 < j < 11:
                    mb = mbset(stat_name[int(mbch) - 1][1])
                    stat_total_bonus = int(
                        char_dict[stat_name[int(mbch) - 1][1]]) + int(
                            char_dict[stat_name[int(mbch) - 1][2]]) + int(
                                char_dict[stat_name[int(mbch) - 1][3]])
                    char_dict[stat_name[int(mbch) - 1][1]] = mb
                    char_dict[stat_name[int(mbch) - 1][4]] = stat_total_bonus

        # Open character file to write out data
        with open(cfgData.char_dir + "/" + char + "/" + char + ".json",
                  'w') as f:
            f.write(json.dumps(char_dict))