programming, computer, environment

Python Code Using Marvel Comics – Part 7


After overcoming the previous challenges I faced my toughest yet. How could I modify FASERIP? More specifically, how would I modify an attribute to go up or down the ranking system. To quote Abraham Erskine, “Good becomes great. Bad becomes worse.”

The solution was to look at the index of a list and then do a comparison of the attribute against the initial ranks and determine the index value. Once the value was discovered you could modify it either way by simple addition or subtraction. Here is an example of how to modify the resources of a character based on their physical form being a normal human.

For this example we are forcing a resource value of ‘Good’ for our ‘Normal Human’ hero.

initial_ranks = ['Feeble', 'Poor', 'Typical', 'Good', 'Excellent', 'Remarkable', 'Incredible', 'Amazing', 'Monstrous']

char_resources = 'Good'
char_physical_form = 'Normal Human'

if char_physical_form == 'Normal Human':
    resources_mod = initial_ranks.index(char_resources)+1
    char_resources = initial_ranks[resources_mod]


The output is ‘Excellent’. An increase of one rank. Bam! Dynamic attributes are possible now.

Another problem I had to solve was duplicate powers. How do you do that? This was an easy one and only needed a simple “not in” function. Also, I was able to tackle another complication at the same time, powers that were more expensive and cost twice as many available slots. This was one was trickier, but solved by performing a find check based on a special character “*” that I put in powers that were expensive.

For the example below I used a counter method by putting the amount of powers rolled into char_powers and then used a while loop to count through the possibilities automatically. The python list append feature adds the string value or in this case “power” to a list called character_powers.

while power_loop_count <= char_powers:
    power_class_roll = random.randint(1, 100)
    power_class = get_power_class(power_class_roll)
    if power_class == 'Defensive':
        power_category_roll = random.randint(1, 100)
        power = get_power_category_defensive(power_category_roll)
        if power not in character_powers:
            if (power.find('*') != -1):
                power_loop_count += 2
                power_loop_count += 1

My current steps are working through updating the Physical Forms to affect FASERIP, Powers, etc.

Current Code Count: 2124 lines.

The latest code is up on my GitHub. You can try it for yourself and run it from a web browser via my Replit, Trinket, or embedded below.