Hey, I am trying to create my text adventure geared towards all of the frequent posters on daniweb's python forum, just alittle something to have fun with. But, it isn't going as planned. I used vegaseat's suggestion for combat, shuffling lists randomly to randomize hit/miss results. I think I did it wrong. I got many errors, I think I fixed most of them, except for the "expected an indent block" message I got (I noted the line with a comment in the source). So, if any of you would like to help me with this project I would appreciate it. I will give full credit to ALL who contribute to this project in the source as well as in the credits of the program itself. Here is the code I am working with:
# Decided to make a simpler Text based game
# will try to use classes and functions primarily
# I am going to try vegaseat's suggestion for combat
# creating a hit list for player and monster
# then using random.shuffle to mix it up
# where list = [1, 0, 2, 0, 3, 0, 0, 1]
# and where 0 = miss
# 1 = minor boo-boo
# 2 = black and blue
# 3 = ER visit and possible stiches
# (minor to major damage) lol
# this is going to be a text based tournament simulator
# "TEXT KWON DO" v1.0
# by Franki
# ten victories to win the competition!
import random
import math
myhitlist = [1, 0, 2, 0, 3, 0, 0, 1]
enemyhit_list = [1, 0, 2, 0, 3, 0, 0, 1]
myhp = 20
enemyhp = 15
myhit_list2 = [1, 0, 1, 2, 0]
print ''' TEXT KWON DO
The ultimate text based martial arts tournament!
Created especially for the many fine folks at
www.daniweb.com's Python forum. '''
print
raw_input("Press Enter to continue: ")
start()
def start():
print '''Are you ready fighter! Are you ready to pit your martial arts
typing skills against the best of the Text Kwon Do Federation? You will
need nerves of steel, and the muscle to match, to win this competition.
If you can survive ten fights, each time beating your adversary, you win
the title of 'Text Kwon Do World Champion!' Good luck, and have no mercy! '''
print
raw_input("Press enter to continue: ")
game_controls()
def game_controls():
print ''' Gameplay is carried out in the following fashion. On your turn, you type in your
command. The available commands are 'punch' 'kick' 'headbutt' 'super punch' super kick' and
'rage attack'. Each attack does different amounts of damage. During the game, you can type
'help' to come back to this screen at anytime during your turn. '''
print
raw_input("Press enter to continue: ")
enter_ring()
def enter_ring():
print ''' You are about to enter the ring, soldier! Prepare yourself, do some push-ups,
pull-ups, kick stuff, do some karate chops, throw a few fireballs (hint hint) and when
you are ready, type 'start fight' to commence the beatings! '''
print
prompt_a()
def prompt_a():
prompt_this = raw_input("What do I do Sensai? ").lower()
try:
if prompt_this == "start fight":
fight_one()
elif prompt_this == "help":
game_controls()
else:
print "You must say 'start fight', Daniel San!"
except: # I believe Ene Uran from daniweb's python forum told me to do this with pass
pass
prompt_a()
# taking first break.
# when return, need to define fight_one()
# need to create myhit_list and enemy.namehit_List where enemy.name = name of enemy; ex. forumlurkerhit_list
# try to figure out a way for each attack to do higher damage
# one idea is to make different hit lists for each attack
# another idea is to figure out how to have each attack
# filter out some integers and return only specific ones.
# for fight_one() I need to make:
# ring1_desc(), fighter1_desc(), the main battle script,
# and then test.
# try NOT TO USE PYTHON FORUM UNLESS I ABSOLUTELY CANNOT FIGURE IT OUT!!!!
# first break taken at 10/27/06 1:28 pm
# break ended 10/29/06 3:23 pm
# now defining fight_one()
# fight_one() includes ring1_desc(), fighter1_desc(), and main battle script (fight_one() )
def fight_one():
myhit_list[1, 0, 2, 0, 3, 0, 0, 1]
c++punkhit_list[1, 0, 2, 3, 0, 0, 1]
print '''You are in the ring. Your opponent, C++ Punk, is on the opposite end of the ring.
The referee yells "Fight!", and the battle commences. Type 'help' for a list of commands. '''
print
prompt_fight1()
def prompt_fight1():
raw_input("What do you do, Daniel San?").lower()
try:
if prompt_fight1 == "help" or prompt_fight1 == "help commands":
game_controls()
elif prompt_fight1 == "punch" or prompt_fight1 == "kick":
x = random.shuffle(myhitlist)
if x == '0':
print 'You missed!'
enemy_turn()
elif x == '1':
print 'You hit C++ Punk!'
enemyhp = enemyhp - 1
enemy_turn()
elif x == '2':
print 'You hit C++ Punk hard!'
enemyhp = enemyhp - 2
enemy_turn()
elif x == '3':
print 'You hit C++ Punk really hard!'
enemyhp = enemyhp - 3
enemy_turn()
elif prompt_fight1 == "headbutt" or prompt_fight1 == "super punch" or prompt_fight1 == "super kick" or prompt_fight1 == "rage attack":
x = random.shuffle(myhitlist)
if x == '0':
print 'You missed!'
enemy_turn()
elif x == '1':
print 'You hit C++ Punk!'
enemyhp = enemyhp - 1
enemy_turn()
elif x == '2':
print 'You hit C++ Punk hard!'
enemyhp = enemyhp - 2
enemy_turn()
elif x == '3':
print 'You hit C++ Punk really hard!'
enemyhp = enemyhp - 3
enemy_turn()
elif prompt_fight1 == "fireball":
n = random.shuffle(myhit_list2)
if n == '0':
print 'You missed'
enemy_turn()
elif n == '1':
print 'You missed'
enemy_turn()
elif n == '2':
print 'You hit C++ Punk very freakin hard!'
enemyhp = enemyhp - 5
enemy_turn()
if enemyhp == 0:
print 'You defeated C++ Punk! Prepare for the second fight!' #error: expected indented block
fight_two()
else:
print 'That is not a Text Kwon Do technique, Daniel San!'
except:
pass
# this is supposed to be the oppenents turn, [enemy_turn() ]
# Still get many syntax errors but everything seems to line up fine
# need to learn to read the error messages
def enemy_turn():
x = random.shuffle(enemyhit_list)
if x == '0':
print 'C++ Punk missed!'
prompt_fight1()
elif x == '1':
print 'C++ Punk hit you!'
myhp = myhp - 1
prompt_fight1()
elif x == '2':
print 'C++ Punk hit you hard!'
myhp = myhp - 2
prompt_fight1()
elif x == '3':
print 'C++ Punk hit you really hard!'
prompt_fight1()
elif myhp == 0:
print 'You have been defeated.'
game_over()
# do not need to define ring_desc() or fighter_desc() or whatever else I had intended on
def fight_two():
print '''You enter the ring again, and the crowd cheers you on. On the opposite end of the ring
is your opponent, Wimpy HTML Dude. The referee signals the start of the fight, saying, "Fight!" '''
# second break:
# still need to complete def fight_two()
# as well as all related functions
# break taken 10/29/06 5:38 pm
# will test then continue later
Thank you all very much. I had hoped for this to remain on the d-L until I posted the finished project but I guess I am still to intermediate (if that) to do it on my own. :D