def __init__(self, x, y): r = random.random() if r < 0.50: self.enemy = enemies.GiantSpider() self.alive_text = "A giant spider jumps down from " \ "its web in front of you!" self.dead_text = "The corpse of the dead spider lies " \ "rotting on the ground." elif r < 0.80: self.enemy = enemies.Ogre() self.alive_text = "An ogre blocks your path!" self.dead_text = "An ogres stinking corpse litters the path." elif r < 0.90: self.enemy = enemies.BatColony() self.alive_text = "A distance squeaking grows louder and louder " \ "until you suddenly find yourself lost in a swarm of bats." self.dead_text = "Dozens of dead bats cover the ground. " \ "You can barely take a step without crushing bat corpses underfoot." elif r < 0.95: self.enemy = enemies.Seth() self.alive_text = "A terrifying Seth monster lumbers out of the shadows." self.dead_text = "Laying on the floor is the corpse of a Seth monster " \ "It's body is covered in Python and C++ code tattoos." else: self.enemy = enemies.RockMonster() self.alive_text = "You've disturbed a rock monster from his slumber!" self.dead_text = "A rock monster's corpse has crumbled into " \ "a mass of small bloody pebbles that cover the floor." super().__init__(x, y)
def __init__(self, x, y): r = random.random() if r < 0.50: self.enemy = enemies.GiantSpider() self.alive_text = 'A giant spider jump down fom ' \ 'its web in front of you!' self.dead_text = 'The corpse of a dead spider ' \ 'rots on the ground.' elif r < 0.80: self.enemy = enemies.Ogre() self.alive_text = 'An ogre is blocking your path!' self.dead_text = 'A dead ogre reminds you of your triumph.' elif r < 0.95: self.enemy = enemies.BatColony() self.alive_text = 'You hear a squeaking noise growing louser ' \ '...suddenly you are lost in a swarm of bats!' self.dead_text = 'Dozens of dead bats are scattered on the ground.' else: self.enemy = enemies.RockMonster() self.alive_text = 'You\'ve disturbed a rock monster ' \ 'from its slumber!' self.dead_text = 'Defeated, the monster has reverted ' \ 'into an ordinary rock.' super().__init__(x, y)
def __init__(self, x, y): r = random.random() if r < 0.50: self.enemy = enemies.GiantSpider() self.alive_text = "A giant spider jumps down from " \ "its web in front of you!" self.dead_text = "The corpse of a dead spider " \ "rots on the ground." elif r < 0.80: self.enemy = enemies.Ogre() self.alive_text = "An ogre is blocking your path!" self.dead_text = "A dead ogre reminds you of your triumph." elif r < 0.95: self.enemy = enemies.BatColony() self.alive_text = "You hear a squeaking noise growing louder" \ "...suddenly you are lost in s swarm of bats!" self.dead_text = "Dozens of dead bats are scattered on the ground." else: self.enemy = enemies.RockMonster() self.alive_text = "You've disturbed a rock monster " \ "from his slumber!" self.dead_text = "Defeated, the monster has reverted " \ "into an ordinary rock." super().__init__(x, y)
def create_enemy(self): r = random.random() if r < 0.50: return enemies.GiantSpider() elif r < 0.80: return enemies.Ogre() elif r < 0.95: return enemies.BatColony() else: return enemies.RockMonster()
def __init__(self, x, y): r = random.random() if r < 0.50: self.enemy = enemies.GiantSpider(x, y) elif r < 0.80: self.enemy = enemies.Ogre(x, y) elif r < 0.95: self.enemy = enemies.BatColony(x, y) else: self.enemy = enemies.RockMonster(x, y) super(EnemyTile, self).__init__(x, y, self.enemy)
def __init__(self, x, y): r = random.random() if r < 0.75: self.enemy = enemies.GiantSpider() self.alive_text = """ A giant spider jumps down from its web in front of you!""" self.dead_text = """ The corpse of a dead spider rots on the ground. """ else: self.enemy = enemies.Ogre() self.alive_text = """ An ogre is blocking your path!""" self.dead_text = """ A dead ogre reminds you of your triumph.""" super().__init__(x, y)
def __init__(self, x, y): r = random.random() if r < 0.5: self.enemy = enemies.GiantSpider() self.alive_text = "A giant spider jumps down at you!" self.dead_text = "The corpse of a dead spider lies on the ground." elif r < 0.8: self.enemy = enemies.Ogre() self.alive_text = "An ogre is blocking your path!" self.dead_text = "There's a dead ogre." else: self.enemy = enemies.GiantSpider() self.alive_text = "There's a giant spider here!" self.dead_text = "There's a dead spider here." super().__init__(x, y)
def __init__(self, x, y): r = random.random() if r < 0.50: self.enemy = enemies.KillerTeddy() elif r < 0.75: self.enemy = enemies.Ogre() elif r < 0.90: self.enemy = enemies.BatColony() elif r < 0.97: self.enemy = enemies.GiantSpider() else: self.enemy = enemies.RockMonster() # print("Has Been created: " + self.enemy.name + " in [" + str(x) + "," + str(y) +"]") # print("r: " + str(r)) #print("Has Been created: " + self.enemy.name ) super().__init__(x, y)
def _init_(self,x,y): r = random.random() if r < 0.50: self.enemy = enemies.GiantSpider() self.alive_text = "A giant spider jumps down from "\ "its web in fromt of you!" self.dead_text = "The corpse of a dead spider " \ "rots on the ground." elif r < 0.80: self.enemy = enemies.Ogre() self.alive_text = "An ogre is blocking your path!" slef.dead_text ="A dead orge reminds you of your triumph." elif r < 0.95: self.enemy = enemies.batColony() self.alive_text = "" self.dead_text = "" super().__init__(x,y) def intro_text(self):
def __init__(self, x, y): r = random.randint(0, 5) if r <= 1: self.enemy = enemies.GiantSpider() self.alive_text = "A giant spider jumps down from\nit's web down in front of you!" self.dead_text = "The corpse of a dead spider\nrots on the ground" elif r <= 2: self.enemy = enemies.Ogre() self.alive_text = "An ogre is blocking your path!" self.dead_text = "A dead ogre reminds you of your triumph." elif r <= 3: self.enemy = enemies.BatColony() self.alive_text = "You hear a squeaking noise growing louder\nsuddenly you are lost in a swarm of bats!" self.dead_text = "Dozens of dead bats are scattered on the ground." else: self.enemy = enemies.RockMonster() self.alive_text = "You've disturbed a rock monster!" self.dead_text = "Defeated, the monster has gone into a deep hibernation and appears to be a normal rock." super().__init__(x, y)
def __init__(self, x, y): r = random.random() if r < 0.50: self.enemy = enemies.GiantSpider() self.alive_text = """ A giant spider jumps down from its web in front of you! """ self.dead_text = """ The corpse of a dead spider rots on the ground. """ elif r < 0.80: self.enemy = enemies.Ogre() self.alive_text = """ A mighty ogre blocks your path. """ self.dead_text = """ A dead ogre reminds you of your tryumph. """ elif r < 0.95: self.enemy = enemies.BatColony() self.alive_text = """ Seems like you got lost in the middle of a smarm of bats! """ self.dead_text = """ Dozens of dead bats are scattered on the ground. """ else: self.enemy = enemies.RockElemental() self.alive_text = """ A pile of rocks seems to have found its way to me middle of the room. When you get near it, you see it's a Rock Elemental! """ self.dead_text = """ As it was defeated, it became a pile of crumbled rocks. """ super().__init__(x, y)
def __init__(self, x, y): r = random.random() if r < 0.5: self.enemy = enemies.GiantSpider() self.alive_text = "The room is covered in spiderweb." \ "From the ceiling, a Giant Spider Descends!" self.dead_text = "The corpse of the dead spider decays before you." elif r < 0.80: self.enemy = enemies.Ogre() self.alive_text = "An Ogre is blocking the path!" self.dead_text = "A dead Ogre reminds you of your triumph." elif r < 0.95: self.enemy = enemies.BatColony() self.alive_text = "You hear a squeaking noise growing louder" \ "... suddenly you are lost in a swarm of bats!" self.dead_text = "Dozend of dead bats are scattered on the ground" else: self.enemy = enemies.RockMonster() self.alive_text = "You've disturbed a rock monster " \ "from his slumber!" self.dead_text = "Defeated, the monster has reverted " \ "into an ordinary rock." super().__init__(x,y)
def __init__(self, x, y): super(OgreRoom, self).__init__(x, y, enemies.Ogre())
def __init__(self, x, y): #sets r = random in the random module r = random.random() #if r < less than 0.50 then select Wolves for the user to face if r < 0.50: self.enemy = enemies.Wolves() # sets .alive_text self.alive_text = """ *********************************************************************** * Out of nowhere you find yourself surrounded by a pack of vicious * * hater wolves. These wolf like creatures feast on insecurities and * * would like nothing more than to eviscerate your selfconfidence. * *********************************************************************** ****************************************************************** **"Dout will kills more dreams than failure ever will." --Kassem** ****************************************************************** """ self.dead_text = """ ******************************************************************** * The wolves proved to be stronger than you thought. You were * * not able to reach the the Magical Forest on the other side of * * the City. Learning from your mistakes will put your on the * * fast track to Enlightenment and if you can apply thesel lessons * * in your next life you be more likely to suceed. * ******************************************************************** *************************************************************** **"Doubt kills more dreams than failure ever will." --Kassem ** *************************************************************** """ #if e ia < .0.75 hen select Ogre for the user to face and .alive_text elif r < 0.75: #if r is lessthank self.enemy = enemies.Ogre() self.alive_text = """ ************************************************************************** * An ogre sized ego is blocking your path!Egos that have grown to the * * size of this the Ogre's can do only one thing! Well 2 things, to be * * correct all the time and keeping you from achieving enlightment * * Learning to apologize does not mean you are wrong and another person * * is right. Respecting other's beliefs even when they go against your * * own may not easy but Hey!, Do you want to be right or happy? The * * choice is yours. * ************************************************************************** """ self.dead_text = """ ************************************************************************* * Wow! You were able to check that ogre's ego with tact and class. * * Choices like that will surely lead you to the other side of the City.* ************************************************************************* ******************************************************************** * The Ancients say 'Yeild to overcome; Bend and be straight; * * Empty and be full; Wear out to become new; Have little and gain; * * Have much and be confused... * ******************************************************************** """ elif r < 0.85: self.enemy = enemies.KarmaChameleon() self.alive_text = """ *********************************************************************** * You feel the wind pick up and you are suddenly lost in swarm of * * bommerangs! You quickly notice that these are not your average * * everyday boomerangs but instead one's that you threw in the * * distant past. Everyone has a past or a history of Choices and * * if this has happend to you while on your journey through the city * * take a breath and deal with your karma now because by it's very * * nature it's not coming back to or for you. Hopefully the former! * *********************************************************************** """ self.dead_text = """ ************************************************************************** * Dozens of boomerangs have hit your and knocked you to the ground. * * Look on the bright side you were able to settle an recent or age old * * karmatic debt. * ************************************************************************** ********************************************************** * "There is such thing as good or bad, right or wrong, * * those are perspectives of what actual is" --Tolle * ********************************************************** """ else: self.enemy = enemies.KarmaChameleon() self.alive_text = """ ********************************************************************* * You feel the wind pick up and you are suddenlylost in swarm of * * bommerangs! You quickly notice that these are not your average * * everyday boomerangs but instead one's that you threw in the * * distant past. Everyone has a past or a history of Choices and * * if this has happend to you while on your journeythrough the city * * take a breath and deal with your karma now because by it's very * * nature it's not coming back to or for you. Hopefully the former! * ********************************************************************* """ self.dead_text = """ ********************************************************************* * Dozens of boomerangs have hit your and knocked you to the ground. * * Look on the bright side you were able to settle an recent or age * * old karmatic debt. * ********************************************************************* ****************************************************************** *"There is such thing as good or bad, right or wrong, those are * * perspectives of what actual is' --Tolle * ****************************************************************** """ super().__init__( x, y) #Defines the intro_text Player will see when they enter room
def __init__(self, game): super().__init__(game, enemies.Ogre(game))
class World: # I choose to define the world as a class. This makes it more straightforward to import into the game. map = [[ Corridor(barriers=[barriers.LockedDoor('e')]), NearVictory(barriers=[barriers.Wall('s')]), VictoryTile(), Corridor(barriers=[barriers.Wall('w')]), Corridor() ], [ ExpanseNW(), ExpanseNE(barriers=[barriers.Wall('n')]), Nook(barriers=[ barriers.Wall('n'), barriers.Wall('s'), barriers.Wall('e') ]), Corridor(barriers=[barriers.Wall('e'), barriers.Wall('w')], enemies=[enemies.Ogre('s')]), Corridor(barriers=[barriers.Wall('w')]) ], [ ExpanseSW(), ExpanseSE(barriers=[barriers.Wall('s')]), Corridor(barriers=[barriers.Wall('n'), barriers.Wall('s')]), Corridor(barriers=[barriers.Wall('e'), barriers.Wall('s')]), Corridor(barriers=[barriers.Wall('w')]) ], [ Corridor(barriers=[barriers.Wall('n')]), Corridor(barriers=[barriers.Wall('n')]), StartTile(barriers=[barriers.Wall('s'), barriers.Wall('n')]), Corridor(barriers=[barriers.Wall('n')]), Corridor() ], [ Cave(barriers=[barriers.Wall('e')]), Corridor( barriers=[barriers.WoodenDoor('e'), barriers.Wall('w')], enemies=[enemies.GiantSpider('e')]), StoreRoom(barriers=[barriers.Wall('n')]), None, None ]] def __init__(self): for i in range( len(self.map) ): # We want to set the x, y coordinates for each tile so that it "knows" where it is in the map. for j in range( len(self.map[i]) ): # I prefer to handle this automatically so there is no chance that the map index does not match if (self.map[i][j]): # the tile's internal coordinates. self.map[i][j].x = j self.map[i][j].y = i self.add_implied_barriers( j, i ) # If there are implied barriers (e.g. edge of map, adjacent None room, etc.) add a Wall. def tile_at(self, x, y): if x < 0 or y < 0: return None try: return self.map[y][x] except IndexError: return None def check_north(self, x, y): for enemy in self.map[y][x].enemies: if (enemy.direction == 'north'): return [False, enemy.check_text()] for barrier in self.map[y][x].barriers: if (barrier.direction == 'north' and not barrier.passable): return [False, barrier.description()] if y - 1 < 0: room = None else: try: room = self.map[y - 1][x] except IndexError: room = None if (room): return [True, "You head to the north."] else: return [False, "There doesn't seem to be a path to the north."] def check_south(self, x, y): for enemy in self.map[y][x].enemies: if (enemy.direction == 'south'): return [False, enemy.check_text()] for barrier in self.map[y][x].barriers: if (barrier.direction == 'south' and not barrier.passable): return [False, barrier.description()] if y + 1 < 0: room = None else: try: room = self.map[y + 1][x] except IndexError: room = None if (room): return [True, "You head to the south."] else: return [False, "There doesn't seem to be a path to the south."] def check_west(self, x, y): for enemy in self.map[y][x].enemies: if (enemy.direction == 'west'): return [False, enemy.check_text()] for barrier in self.map[y][x].barriers: if (barrier.direction == 'west' and not barrier.passable): return [False, barrier.description()] if x - 1 < 0: room = None else: try: room = self.map[y][x - 1] except IndexError: room = None if (room): return [True, "You head to the west."] else: return [False, "There doesn't seem to be a path to the west."] def check_east(self, x, y): for enemy in self.map[y][x].enemies: if (enemy.direction == 'east'): return [False, enemy.check_text()] for barrier in self.map[y][x].barriers: if (barrier.direction == 'east' and not barrier.passable): return [False, barrier.description()] if x + 1 < 0: room = None else: try: room = self.map[y][x + 1] except IndexError: room = None if (room): return [True, "You head to the east."] else: return [False, "There doesn't seem to be a path to the east."] def add_implied_barriers(self, x, y): [status, text] = self.check_north(x, y) barrier_present = False if (not status): for enemy in self.map[y][x].enemies: if enemy.direction == 'north': barrier_present = True for barrier in self.map[y][x].barriers: if barrier.direction == 'north': barrier_present = True if (not barrier_present): self.map[y][x].add_barrier(barriers.Wall('n')) [status, text] = self.check_south(x, y) barrier_present = False if (not status): for enemy in self.map[y][x].enemies: if enemy.direction == 'south': barrier_present = True for barrier in self.map[y][x].barriers: if barrier.direction == 'south': barrier_present = True if (not barrier_present): self.map[y][x].add_barrier(barriers.Wall('s')) [status, text] = self.check_east(x, y) barrier_present = False if (not status): for enemy in self.map[y][x].enemies: if enemy.direction == 'east': barrier_present = True for barrier in self.map[y][x].barriers: if barrier.direction == 'east': barrier_present = True if (not barrier_present): self.map[y][x].add_barrier(barriers.Wall('e')) [status, text] = self.check_west(x, y) barrier_present = False if (not status): for enemy in self.map[y][x].enemies: if enemy.direction == 'west': barrier_present = True for barrier in self.map[y][x].barriers: if barrier.direction == 'west': barrier_present = True if (not barrier_present): self.map[y][x].add_barrier(barriers.Wall('w')) def update_rooms(self, player): for row in self.map: for room in row: if (room): room.update(player)
class Nook(MapTile): enemies = [enemies.Ogre()] description = """You have entered a shadowy nook of the cave. The only way out is back the way you came."""
def __init__(self, x, y): super().__init__(x, y, enemies.Ogre())
def random_spawn(self): if (randint(0, 2) == 0): # 1 in 3 odds. self.enemies = [enemies.Ogre()] else: self.enemies = []