SharedTextba.ipynbOpen in CoCalc
Textba

import time
import math
from random import randint
## Mock Battle Code
print('You encounter a wild boar in the forest!')
time.sleep(1)
print('')
print('What do you do?')
time.sleep(.5)
print('press 1 to attempt to flee')
print('press 2 to engage in combat')
user_selection=input('')
print(user_selection)
print(type(user_selection))

while user_selection !="1" and user_selection !="2":
    print("That's not a valid option at this time!")
    time.sleep(.5)
    user_selection=input("please enter 1 or 2")
if user_selection==str(1):
    print("You attempt to flee...")
    time.sleep(1)
    user_flee_score=randint(1,20)
    boar_speed=8
    if user_flee_score > boar_speed:
        print("You successfully flee from combat!")
    else:
        print("You fail to flee the boar!")
You encounter a wild boar in the forest! What do you do? press 1 to attempt to flee press 2 to engage in combat
1 <class 'str'> You attempt to flee... You fail to flee the boar!
print(user_flee_score)
12
class Player(Object):
    name = None
    gender = None
    strength = 
    
    def __init__(self,a):
        self.name = a
# player creation and stat builder
time.sleep(.5)
username=input('What is your name?')
time.sleep(1)
print('Hello',username,'welcome to this world of Swordcraft!')
time.sleep(1)
print('')
gender=input('Are you a boy or a girl?')
while gender.lower() !="boy" and gender.lower() !="girl":
    time.sleep(.5)
    gender=input("I'm sorry, it's dark in here.  Are you a boy or a girl?")
if gender.lower()== "boy":
    usergender="boy"
if gender.lower()== "girl":
    usergender="girl"
time.sleep(.5)
print('')
print('Excellent',username,'!')
print('You are now ready to set off on your adventure...')
What is your name?
Hello William Davis welcome to this world of Swordcraft!
Are you a boy or a girl?
Excellent William Davis ! You are now ready to set off on your adventure...
# stat selection
stat_points=10
strength=5
strdesc=""
agility=5
agidesc=""
intelligence=5
intdesc=""
perception=5
perdesc=""
luck=5
luckdesc=""
stats=[strength,agility,intelligence,perception,luck]
statnames=["Strength","Agility","Intelligence","Perception","Luck"]

print('You begin as a rather average adventurer,')
print('however, your past experience has given you the opportunity to focus on some of your stats,')
time.sleep(.5)
print('to begin, your strength is',stats[0],', agility is',stats[1],', intelligence is',stats[2],', perception is',stats[3],', and luck is',stats[4])
time.sleep(.5)
print('you have',stat_points,'points to assign to your stats')
time.sleep(1)
for stat, name in zip(stats,statnames):
    print('')
    print(name,':',stat)
    stat_bonus=int(input('How many points would you like to attribute to this stat?'))
    if stat_bonus > stat_points:
        print('You do not have enough points to add')
        statbonus=input('How many points would you like to attribute?')
    stat_points=stat_points-stat_bonus
    stat=stat+stat_bonus
    print('Your',name,'is now',stat)
    print('You have',stat_points,'points remaining')
print('Your strength is now',stats[0],', agility is',stats[1],', intelligence is',stats[2],', perception is',stats[3],', and luck is',stats[4])
You begin as a rather average adventurer, however, your past experience has given you the opportunity to focus on some of your stats, to begin, your strength is 5 , agility is 5 , intelligence is 5 , perception is 5 , and luck is 5 you have 10 points to assign to your stats Strength : 5
How many points would you like to attribute to this stat?
Your Strength is now 7 You have 8 points remaining Agility : 5
How many points would you like to attribute to this stat?