Critical Injuries Computer (Python) Script

By shidarin, in Star Wars: Edge of the Empire RPG

As a quick break my character builder work, I decided to make a helper app for Critical Injuries, which should make their assignment a lot faster.

The script asks how many critical injuries the target already has, and if the attacker is granted any other bonuses (and how much) before either letting the computer roll or inputting a roll by hand.

It then adds them all together, looks up the resulting critical injury, and displays the results.

Typical run:

>>> python SW_EotE_CriticalInjuries.py

                Edge of the Empire Critical Hit Calculator
                      Python Edition 1.0, by Shidarin
                     
             All Star Wars & Edge of the Empire material is 
            Copywrite Lucasfilm Ltd and Fantasy Flight Games
            
            
How many critical injuries have yet to be healed?: 3
Please enter any bonuses additional advantage, talents, etc grant: 20

You can:
	[1] Let the computer roll for you 
		or 
	[2] Input a roll manually.
Which option do you choose?: 1

		
	Critical Injury Table
| Roll |     Severity    | Result									|
|  53  | Average [**]    | Fearsome Wound: The target increases the difficulty of all Presence and Will |
                         | power checks by (1) until the end of the encounter.                          |

The python version is 2.7, but most 2.x flavors should be compatible. 3.x will not be.

All OSX and most Linux distro's come with 2.x installed. Just download the script, open up a terminal window and type:

python TheScriptYouDownloadedFromThisPage.py

Python can be downloaded here.

The Self-Executing versions do NOT require python. I'll have a Win build up shortly.

Python Script

Self-Executing OSX

Please post any bugs you find, or (if you know Python) diatribes about how shoddy the coding is (no seriously, advice would be great).

Shows a mix of tabs and spaces in the indent when I fire it up in idle on OSX. (Bad coding practice in Python; forbidden in later versions).

Default windows are 80 characters wide in many terminal programs; might want to set a column input check.

Need to be able to account for both increases to and decreases to the critical roll. I'm not certain (not having gone pouring over the code) which it's doing.

Shows a mix of tabs and spaces in the indent when I fire it up in idle on OSX. (Bad coding practice in Python; forbidden in later versions).

Default windows are 80 characters wide in many terminal programs; might want to set a column input check.

Need to be able to account for both increases to and decreases to the critical roll. I'm not certain (not having gone pouring over the code) which it's doing.

Thanks for all 3, all have been addressed. Updated files in OP.

Changes in v1.1:

Everything properly detab'd now

Checks for window size and warns if set below recomended 120

Allows negative roll adjustment, sets minimum total roll to 1

Hey, here's a bit of code for you for formatting the output to various screen widths:

#Start of Program settings. Replace the Screenwidth with the checking routine's output. I'm too lazy to look it up.
ScreenWidth = 80 
SliceWidth = ScreenWidth - 37
    #the above line is set to 10 below the desired width, by increasing
    #the amount subtracted, so that it finds the first space in the last 10 characters of a given line.
if SliceWidth <23:
    SliceWidth = 23
    #we assure a minimum virtual width of 60 characters

#ToBePrinted is set with whatever output goes in the right.
ToBePrinted = "Lorem ipsum dolor sit amet Consectetur adipiscing elit Eset eiusmod tempor  incid nt et labore et dolore magna aliquam. Ut enim ad minim veniam, quis nostrud exerc.  Irure dolor in reprehend incididunt ut labore et dolore magna aliqua. Ut enim ad minim      veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat."

#Actual line breaking starts here
PrintPos = 0
PrintString = "|      |                 | "
    # you can replace the above line with the formatting you previously used to set roll on the first line.
while PrintPos < len(ToBePrinted):
    if (PrintPos > SliceWidth):
        if ToBePrinted[PrintPos] <> " ":
            print PrintString
            ToBePrinted = ToBePrinted[PrintPos:len(ToBePrinted)]
                #The above line slices to be printed.
            PrintPos = 0
            PrintString = "|      |                 | "
                # the above line is for subsequent lines
    PrintString = PrintString + ToBePrinted[PrintPos]
    PrintPos += 1

I've tested the above code snipped and it runs, at least without the comments.