Author Topic: Pokemon text-based game.  (Read 566 times)

0 Members and 1 Guest are viewing this topic.

Offline Cr1TH1T

  • Serf
  • *
  • Posts: 21
  • Cookies: -33
  • Where'd all the good people go?
    • View Profile
Pokemon text-based game.
« on: April 16, 2015, 09:20:28 pm »
I was tinker ing with some code and decided to make a pokemon game with python, I ran into a prolem though and now I can't figure out what is wrong with it.
CODE IS BELOW:

def pokemon_lab():
    print "You've just entered the Pokemon Lab! Before you lies a table with three Pokeballs."
    print "Do you take the Pokeball on the left, the right or in the center?"
    answer = raw_input("Type left, right or center and hit 'Enter'.").lower()
    if answer == "left" or answer == "l":
        print "The Water Type Pokemon, Squirtle, is quite the charmer!"
     
    elif answer == "right" or answer == "r":
        print "Of course! This is the Fire Type Pokemon, Charmander!"
    elif answer == "center" or answer == "c":
         print "Superb! You picked Bulbasaur, The Grass Type Pokemon!"
   
    else:
        print "You didn't pick a pokemon! Try again."
        pokemon_lab()


pokemon_lab()


def route_1():
    print "After leaving the Pokemon Lab, you embark on your journey. Leaving town, you take your first steps towards becoming a Pokemon Master."
    print "You see a path leading West, one leading to the North, and one leading East; Which way do you go?"
    answer = raw_input("Type west, east or north and hit 'Enter' to continue.").lower()
    if answer == "north" or answer == "n":
        print "You walk into a large clearing filled with tall grass."
       
    elif answer == "west" or answer == "w":
        print "You lock eyes with a Trainer standing next to a large Sitrus Berry tree!"
    elif answer == "east" or answer == "e":
        print "You continue down the path with the tall Berry trees around you blowing slightly in the wind."
    else:
        print "Pick a direction in order to continue your Journey!"
        route_1()


route_1()
def battle_c():
    print "As you walk into the clearing, a small Pidgy jumps from the trees and begins to attack!!! You hurriedly send out your Charmander to combat the encroaching bird pokemon!"
    print "Do you Attack, Run, or throw a pokeball?"
    answer == raw_input("Type Attack, Run, or Ball to continue.").lower()
    if answer == "Attack" or answer == "A":
        attack == raw_input("Type Ember, Scratch, Tail Whip, or Smokescreen and hit 'Enter'").lower()
        if attack == "Ember" or attack == "1":
            print "Your Charmander cries out as He uses Ember on the Wild Pidgey! Striking the brown bird pokemon in the chest it lets out an involuntary cry of pain as it falls to your victorious feet. Weakly, it peers up at you as if begging for mercy. To caught up in your celebration to notice you leave the decimated bird behind, its cries drawing other pokemon out who then proceed to silence the injured bird."
        elif attack == "Scratch" or attack == "2":
            print "Lunging at the Pidgey with rage burning in it's eyes it brutally cuts down the meek bird without mercy.YOu leave the bird's bloodied and beaten body behind you move along excited about having won your first battle."
        elif attack == "Tail Whip" or attack == "3":
            print "Your pokemon wags it's tail at the bird pokemon. Senseing an oppertunity to attack it visously tears at your pokemon eyes, causing it to make a gurgling sound as the bird succesfully rips your pokemon to pieces. It's bloodied beak slowly rises and the gore covered bird begins to step towards you it's intent quite clear."
            print "YOUR DEAD"
        elif attack == "Smokscreen" or attack == "4":
            print "Your fire type begins to pour toxic black smoke out of his mouth, suffocating all near by wildlife."
    elif answer == "Ball" or answer == "B":
        print "You dont got balls son!"
    elif answer == "Run" or answer == "R":
        print "Pansy"
        print "You paid dearly for your mistake YOUR DEAD"
    else:
        print "Make your freakin decison!"
    battle_c()
   
battle_c()
YOOOOOOOOOOOOOOOOOOOOO

Offline Teapot

  • Peasant
  • *
  • Posts: 127
  • Cookies: -2
  • E-Book Whore
    • View Profile
Re: Pokemon text-based game.
« Reply #1 on: April 16, 2015, 10:20:50 pm »
Listen to the errors you are getting, read the error messages.
What i was getting, and what i assume you are getting, was newb mistakes
that are easily fixed.




1. you are not declaring the
Code: [Select]
attack= variable inside of a new function.
A quick fix for this would be to make it a global variable and then reassign its value in each
function or to declare it separately in each function.

FIX:
More specifically you where typing
Code: [Select]
attack== just remove the second =

2. You where mixing capital and lower case letters.
The first half of the program used lower case in the answers the second half used upper case.
Python is case sensative so if your user enters in
Code: [Select]
run and the flow modifier compares
it as an upper case
Code: [Select]
Run then it will jump to the else statement.
Which was "make your decision" or something.

3. After that one i got another declaration error and stopped working on it.  Presumable you accidentally
added a second = sign when trying to declare it.

« Last Edit: April 16, 2015, 10:28:26 pm by Teapot »