Hi i am trying to create a game that uses 2 scripts one that creats the game instance and another that hold the varbles of monsters and the player as well as the game my problem is i am trying to creat "rooms" for each area with in the game and i wanted each "room" to be its own class but i am haveing troble switching from one "room" aka class to another this is the test of thing i have so far

import random 
from random import randint
class Player(object):
   ye
    def __init__ (self, name = " ", max_hp = 400, max_att = 200, max_def = 100,pl_lv = 0, pl_xp = 0,):
        self.name = name
        self.player_hp = max_hp
        self.player_att  = max_att
        self.player_def = max_def 
        self.player_lv = pl_lv
        self.player_xp = pl_xp
        self.big_hit = self.player_att * 5.0

    def Player_lvl(self, xp_gain):
        self.xp_gain = xp_gain 
        self.player_xp += xp_gain 
        if self.player_xp == 500:
            self.lv += 1
            self.max_hp += 10 * self.lv
            self.max_att *= 2.0
            self.max_def *= 1.5





class Monster(object):

    def __init__ (self, mon_name, max_hp, max_att, max_def, max_lv,):
        self.mon_max_hp = max_hp 
        self.mon_att = max_att
        self.mon_def = max_def
        self.mon_lv = max_lv 
        self.mon_name = mon_name
        self.mon_big_hit = self.mon_att * 4.0

    def Monster_lv (self):

        if self.mon_lv == 1:
            self.mon_hp *= 1.5
            self.mon_att *= 2.0 
            self.mon_def *= 1.3
        elif self.mon_lv == 2:
            self.mon_hp *= 2.0
            self.mon_att *= 2.3 
            self.mon_def *= 1.5
        elif self.mon_lv == 3:
            self.mon_hp *= 2.5
            self.mon_att *= 2.5
            self.mon_def *= 1.7



class Battle(object):


        def __init__(self,player,monster):
            self.player = player 
            self.monster = monster 
            self.attack_turn = True 
        def Attacking(self):
            self.monster.mon_lv = self.player.player_lv
            while True:

                if self.monster.mon_hp <= 0:
                    print " Congrats you have killed %s and gaine 100 xp" % self.monster.mon_hp
                    self.player.Player_xp(100)


                if self.player.player_hp <= 0:
                    print "You have been killed by %s" % self.monster.mon_name
                    return "dead"

                if randint(1,5) == 3 or randint(0,5) == 5 and self.attack_turn: 
                    self.monster.mon_hp -= self.player.big_hit - self.monster.mon_def
                    print "You hit %s in its weak spot for %f and has %f HP left" %(self.monster.mon_name,self.player.big_hit, self.monster.mon_hp)
                    self.attack_turn = False
                else:
                    self.monster.mon_hp -= self.player.player_att - self.monster.mon_def
                    print " YOu hit %s for %f it has %f HP left" %(self.monster.mon_name, self.player.player_att, self.monster.mon_hp)

                if randint(1,5) == 3 or randint(0,5) ==5 and not self.attack_turn:
                    self.player.player_hp -= self.monster.big_hit - self.player.player_def
                    print " You have been hit by %s for %f and have %f hp left" %(self.monster.mon_name, self.monster.mon_big_hit, self.player.player_hp)
                else:
                    self.player.player_hp -= self.monster.mon_att - self.player.player_def 
                    print " You have been hit by %s for %f and have %f hp left" %(self.monster.mon_name, self.monster.mon_big_hit, self.player.player_hp)

class Game(object):

    def __init__(self, player, monster,start):
        self.player = player
        self.monster = monster 
        self.start = start 

    def play (self):
        next = self.start 
        while True:
            start = getattr(self, next)
            next = start()

class Start_room(object):
        print "*" 
        print "Welcome to the world %s their will be tought times ahead for you on this enventful aventure" % self.player.name 
        start_area = raw_input("\nTheir are 4 places you can start from \n\t1.City\n\t2.Mountain\n\t3.Ocaen\n\t4.Sky_Dungon\n Type in the number of the area you will go to")
        if start_area == "1": 
            return "City"
        elif start_area == "2":
            return "Mountain"
        elif start_area == "3":
            return "Ocaen"
        elif start_area == "4":
            return "Sky_Dungon"
        else:
            "plese enter a a vaild number"

def City(object):

    def __init__(self, player, monster):
        self.player = player
        self.monster = monster

    def Start(self):
        print "This is a test"

This is the Run script

from mygame import *



player = Player(raw_input("Plese enter a name for your Char"))
monster = Monster("Dragon",420, 150, 100, 0)
monster2 = Monster("Ealgel", 500,120, 80, 0) 
game = Game(player, monster, "Start_room")
game.play()  

Help!

My 2 c:
Your rooms should be instances of Room class. You are messing around and everything is mixed up. Use dictionary of Room and make __hash__ for Room so room instances can be used as keys of dictionary.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.