Ejemplo n.º 1
0
 def __init__(self):
     self.text = Text()
     self.myPlayer = Player(self)
     self.myEnemy = Enemy(self)
     self.quests = Quests(self)
     self.zonemap = zonemap
     self.equipment_set = equipment_set
Ejemplo n.º 2
0
    def game_loop(self):
        clock = pygame.time.Clock()
        #Run the game loop
        while True:
            clock.tick(60)

            key_pressed = pygame.key.get_pressed()
            if key_pressed[pygame.K_w]:
                self.chr.move(self.chr.FORWARD)
                self.camera.viewport.centery -= 10
                print('Forward')
            elif key_pressed[pygame.K_s]:
                self.chr.move(self.chr.BACKWARD)
                self.camera.viewport.centery += 10
                print('Backward')
            elif key_pressed[pygame.K_a]:
                self.chr.move(self.chr.LEFT)
                self.camera.viewport.centerx -= 10
                print('Stroll Left')
            elif key_pressed[pygame.K_d]:
                self.chr.move(self.chr.RIGHT)
                self.camera.viewport.centerx += 10
                print('Stroll Right')

            for event in pygame.event.get():
                if event.type == QUIT:
                    sys.exit()
                if event.type == pygame.KEYDOWN:
                    if event.key == pygame.K_UP:
                        self.chr.shoot(self.windowSurface, direction=UP)
                        print('Up')
                    elif event.key == pygame.K_DOWN:
                        self.chr.shoot(self.windowSurface, direction=DOWN)
                        print('Down')
                    elif event.key == pygame.K_LEFT:
                        self.chr.shoot(self.windowSurface, direction=LEFT)
                        print('Left')
                    elif event.key == pygame.K_RIGHT:
                        self.chr.shoot(self.windowSurface, direction=RIGHT)
                        print('Right')
                if event.type == pygame.MOUSEBUTTONUP:
                    pos = pygame.mouse.get_pos()
                    self.chr.shoot(self.windowSurface, target=Vec2d(pos))
                    print(pos)

            self.map.render(self.windowSurface, self.camera)
            self.windowSurface.blit(self.text, self.textRect)
            self.chr.draw(self.windowSurface)
            Enemy.update()
            Enemy.draw_all(self.windowSurface)
            self.gom.check_boundry()
            Projectile.update(self.windowSurface)
            pygame.display.update()

            self.camera.move(chr)
def createCharacters(minE,maxE,minF,maxF):
  #use random to create 1 to 3 enemies and friends
  numofEnemies = random.randint(minE, maxE)
  numofFriends = random.randint(minF, maxF)
  #create the enemy list
  enemiesList=[]
  for i in range(numofEnemies):
    # create a list with the enemy instances
    enemiesList.append(Enemy(characternames[i]))
    # set the descriptions for the enemies
    tdescription=('a ' + adjectivesBad[i] + " " + type[i])
    enemiesList[i].set_description(tdescription)
    # want list is created in createCharacter.py
    enemiesList[i].set_wants(wants[i])
  #create the friend list
    friendsList=[]
  for i in range(numofFriends):
      #we need to create an index to make sure we do not assin a want that is assigned to an enemy
      j = i + numofEnemies
      # create a list with the enemy instances
      friendsList.append(Friend(characternames[j]))
      # set the descriptions
      tdescription=('a '+ adjectivesGood[j] + " " + type[j])
      friendsList[i].set_description(tdescription)
      # want list is created in createCharacter.py
      friendsList[i].set_wants(wants[j])
  #combine the two lists
  characterList=friendsList+enemiesList
  return characterList
Ejemplo n.º 4
0
 def get_enemy(self, enemy):
     name = enemy.find(self.CONST.NAME_TAG).text
     description = enemy.find(self.CONST.DESCRIPTION_TAG).text
     level = int(enemy.find(self.CONST.LEVEL_TAG).text)
     # location = int(enemy.find(self.CONST.LOCATION_TAG).text)
     object_list = self.get_objects(enemy)
     return Enemy(name, description, level, object_list)
Ejemplo n.º 5
0
        def charsetting(s_name, c_type, room_asgn, c_cat, c_speech, c_weakness):
            """
            function to create character objects and assign details
            """
            n_stg = s_name
            unwrap_gift = c_weakness.split('|')
            if c_type == 'Friend':
                """
                the unwrap_gift will pass a 2 item list to the friend
                all items follow the same list pattern
                (see in previous function ==> hidden_item)
                """
                stg = Friend(s_name, c_cat, c_speech, (unwrap_gift[0],unwrap_gift[1]))
                cls.Fr_dict[str(n_stg)] = stg
                cls.Ch_dict[str(n_stg)] = stg
            else:
                stg = Enemy(s_name, c_cat, c_speech, unwrap_gift)
                GameInfo.potentialfriends += 1
                cls.En_dict[str(n_stg)] = stg
                cls.Ch_dict[str(n_stg)] = stg
            for rm, r_obj in cls.House_dict.items():
                """
                assign character to room
                """
                if room_asgn == rm:
                    r_obj.set_character(stg)
                    r_obj.set_ch_det(cls.Ch_dict)

            return stg, cls.Fr_dict, cls.En_dict, cls.Ch_dict, cls.House_dict
Ejemplo n.º 6
0
 def _spawn_enemies(self):
     """ has chance to spawn enemies on outermost tiles, if they are free """
     outer_tiles = [
         self.grid.tiles_dict["left_tiles"][-1],
         self.grid.tiles_dict["right_tiles"][-1]
     ]
     for tile in outer_tiles:
         if not tile.get_character():
             if random() < self.settings.enemy_spawn_prob:
                 new_enemy = Enemy(self, tile)
                 self.enemies_group.add(new_enemy)
                 self.characters_group.add(new_enemy)
Ejemplo n.º 7
0
    def __init__(self, id, number_of_enemies):
        self.enemies = []

        # Do not create monsters in the starting scene
        if id != 0:
            for i in range(number_of_enemies):
                self.enemies.append( Enemy(i) )

        self.has_chest = False
        self.id = id
        self.connections = []
        self.number_of_connections = 0
Ejemplo n.º 8
0
def main():

    player = Hero("King", "The brave king of nowhere!")
    player.Talk = "Who is here?"

    enemy = Enemy("Wizard", "The evil wizard!")
    enemy.Talk = "Your worst enemy!!!!"

    castle = []
    layout(castle)
    current_room = castle[0]

    castle[random.randint(1, len(castle) - 1)].Character = enemy

    print(player)
    print("I'm in:")
    print(current_room)

    print()
    while True:
        direction = input("Where to ? ").upper()
        if direction == "EXIT":
            break
        print()
        if direction in DIRECTIONS:
            current_room = current_room.move_to_direction(direction)
            print(current_room)
            if current_room.Character:
                print(player.Talk)
                print(enemy.Talk)
                if player.fight(current_room.Character):
                    print("\nWell done you have defeated your enemy!\n")
                    break
                print(player.Back)
                player.change_weapon()
        print()
Ejemplo n.º 9
0
    def __init__(self):
        pygame.init()
        #Set up the window
        self.windowSurface = pygame.display.set_mode((WIDTH, HEIGHT), 0, 32)
        pygame.display.set_caption('Hello World')
        #Set up fonts
        basicFont = pygame.font.SysFont(None, 48)
        self.text = basicFont.render('HELLO WORLD', True, BLACK)
        self.textRect = self.text.get_rect()
        self.textRect.centerx = self.windowSurface.get_rect().centerx
        self.textRect.centery = self.windowSurface.get_rect().centery

        self.map = Map()
        self.chr = Character(HALF_WIDTH, HALF_HEIGHT)
        Enemy.enemies.append(Enemy())
        self.gom = GameObjectManager(WIDTH, HEIGHT)
        self.camera = Camera(WIDTH, HEIGHT)
Ejemplo n.º 10
0
    def start(self):
        self.background = pygame.image.load(
            'resources/backgrounds/background.png')
        if self.sprites:
            self.tilemap.layers.remove(self.sprites)
        if self.enemies:
            self.tilemap.layers.remove(self.enemies)
        if self.blockers:
            self.tilemap.layers.remove(self.blockers)

        self.sprites = tmx.SpriteLayer()
        self.enemies = tmx.SpriteLayer()
        self.blockers = tmx.SpriteLayer()

        start_cell = self.tilemap.layers['triggers'].find('player')[0]
        self.player = Player((start_cell.px, start_cell.py), self.sprites)
        goal_cell = self.tilemap.layers['triggers'].find('exit')[0]
        self.goal = Goal((goal_cell.px, goal_cell.py), self.enemies)

        for enemy in self.tilemap.layers['triggers'].find('enemy'):
            if enemy.properties['type'] == 'f':
                FlyEnemy((enemy.px, enemy.py),
                         int(enemy.properties.get('direction', '1')),
                         self.enemies)
            elif enemy.properties['type'] == 'toucan':
                ToucanEnemy((enemy.px, enemy.py),
                            int(enemy.properties.get('direction', '1')),
                            self.enemies)
            else:
                Enemy((enemy.px, enemy.py),
                      int(enemy.properties.get('direction', '1')),
                      self.enemies)
        for weapon in self.tilemap.layers['triggers'].find('weapon'):
            Weapon((weapon.px, weapon.py), self.enemies)
        for box in self.tilemap.layers['triggers'].find('box'):
            Box((box.px, box.py), self.blockers)

        self.tilemap.layers.add_named(self.enemies, 'enemies')
        self.tilemap.layers.add_named(self.sprites, 'sprites')
        self.tilemap.layers.add_named(self.blockers, 'blockers')
Ejemplo n.º 11
0
dining_hall.description = 'The place that people eat them food'

# link the kitchen to the ballrom and dining hall
kitchen.link_room(ballroom, 'southwest')
kitchen.link_room(dining_hall, 'south')

# link the dining to the ballrom and kitchen
dining_hall.link_room(kitchen, 'north')
dining_hall.link_room(ballroom, 'east')

# link the ballroom to the kitchen and dining hall
ballroom.link_room(kitchen, 'northeast')
ballroom.link_room(dining_hall, 'west')

# creating the first enemy and putting him in the dining hall
enemy = Enemy('Drake', 'A sweetie zumbie')
enemy.conversation = 'braaain, I want braaaain'
enemy.weakness = 'cheese'
dining_hall.character = enemy

# creating the second enemy and putting him in the ballroom
enemy_two = Enemy('David', 'A dangerous demon')
enemy_two.conversation = 'I want to take your soul'
enemy_two.weakness = 'silver'
ballroom.character = enemy_two

# creating a friendly person and putting in the kitchen
friend = Friend('jacob', 'A very friendly guy')
friend.conversation = 'I\'m just passing a time here'
kitchen.character = friend
Ejemplo n.º 12
0
from character import Enemy

dave = Enemy("Dave", "A smelly zombie")

dave.describe()

dave.set_conversation("Hi.")

dave.talk()

dave.set_weakness("Hammer")

print("What will you fight with?")
fight_with = input("> ")
dave.fight(fight_with)
Ejemplo n.º 13
0
else:
    new_game = True

if new_game:
    player_name = input("Enter your name: ")
    character_name = input("Enter your hero's name: ")
    hero = PlayerCharacter(character_name,
                           races.Human,
                           "hero",
                           player_name,
                           catch_phrase="Go beyond! Plus Ultra!")
    hero.sayHello()

print("Welcome to the game %s" % (hero.player_name))

villan = Enemy("Nomu", races.Human, "villan", catch_phrase="...")

while True:

    villan.sayHello()

    while True:
        if hero.hp > 0:
            hero.choose_action(villan)
        if villan.hp > 0:
            villan.choose_action(hero)

        if hero.hp <= 0 or villan.hp <= 0:
            break

    if hero.hp > 0:
Ejemplo n.º 14
0
from character import Enemy

dave = Enemy("Dave", "A smelly zombie")
from character import Enemy

dave.describe()
dave.talk()
dave.set_weakness("cheese")
print("What will you fight with?")
fight_with = input()
dave.fight(fight_with)
Ejemplo n.º 15
0
from character import Enemy 

sid = Enemy('sid','demon from hell')
sid.describe()
sid.set_conversation("I lurk in the darkness")
sid.talk()
sid.set_weakness('light')
sid.get_weakness()
x = input()
sid.fight(x)
Ejemplo n.º 16
0
from room import Room
from character import Character,Enemy,Friend
from item import Item

kitchen = Room("Kitchen")
kitchen.set_description("A dank and dirty room buzzing with flies.")

dining_hall = Room("Dining Hall")
dining_hall.set_description("A large room with ornate decorations.")

ballroom = Room("Ballroom")
ballroom.set_description("A vast room with a shiny wooden floor.")

# Add an enemy and it's weakness to defeat it
dave = Enemy("Dave","A bad, very smelly Zombie")
dave.set_weakness("cheese")
# Add some conversation for Dave when talked to
dave.set_conversation("Argh, me eat your brains!")

# Add a friend and it's feelings
kati = Friend("Kati","A friendly skeleton")
kati.set_feelings("I'm very happy today!")
# Add some conversation for Kati when talked to
kati.set_conversation("Do you need a hug today?")

# Add an item
cheese = Item("Cheese")
cheese.set_description("A large and smelly block of cheese")

kitchen.link_room(dining_hall, "south")
dining_hall.link_room(kitchen, "north")
Ejemplo n.º 17
0
from room import Room
from item import Item
from helpMe import HelpMe
from character import Enemy
from character import Friend

myhelp = HelpMe()
myhelp.helpMe()

dave = Enemy("Dave", "A smelly zombie")
dave.set_conversation("I am a a zomilator")
dave.set_weakness("cheese")

mary = Friend("Mary", "A nice person")
mary.set_conversation("I like hugs")
#dave.set_weakness("cheese")

# create rooms
kitchen = Room("Kitchen")
kitchen.set_description("A dank and dirty room buzzing with flies.")
kitchen.set_character(mary)

dining_hall = Room("Dining Hall")
dining_hall.set_description(
    "A large room with ornate golden decorations on each wall.")
#put an enemy in the room
dining_hall.set_character(dave)

ballroom = Room("Ballroom")
ballroom.set_description(
    "A vast room with a shiny wooden floor. Huge candlesticks guard the entrance."
Ejemplo n.º 18
0
from character import Character, Enemy

dave = Enemy("Dave", "A smelly zombie")

dave.describe()

# Add some conversation for Dave when he is talked to
dave.set_conversation("I want your brains!")

# Trigger a conversation with Dave
dave.talk()

dave.set_weakness("water")

print("What will you fight with?")

fight_with = input()

dave.fight(fight_with)
Ejemplo n.º 19
0

kitchen=Room ("kitchen")
kitchen.set_description ("A dank and dirty room buzzing with flies.")

dining_hall=Room ("dining_hall")
dining_hall.set_description ("A big and clean dining hall")

ballroom=Room ("ballroom")
ballroom.set_description ("An empty and huge ballroom")

kitchen.link_room(dining_hall, "south")
dining_hall.link_room (ballroom, "east")
ballroom.link_room (kitchen,"north")

dave=Enemy ("Dave", "A smelly zombie")
dave.describe()

dave.set_conversation ("What's up dude?")
dave.talk()

dave.set_weakness ("cheese")
print ("what will you fight with?")
fight_with=input()
dave.fight (fight_with)
dining_hall.set_character(dave)

greeny = Enemy ("Greeny", " A big messy worm")
greeny.set_conversation ("Ajj, I'm so ugly")
greeny.set_weakness ("teddy")
ballroom.set_character (greeny)
Ejemplo n.º 20
0
    def __init__(self, config=None):
        """Create a game world using the supplied configuration details.
        If no config specified, then use default_config world configuration.
        The game world has: title, rooms, characters, items, messages,
        and the success criteria.
        """
        # use default_config is none supplied
        if config == None:
            config = default_config

        # instance variables for a world
        self.title = config['title']
        self.rooms = {}
        self.items = {}
        self.characters = {}
        self.player = None
        self.messages = config['messages']
        self.success = config['success']

        # populate the world using the configuration details
        try:
            # configure rooms
            doing = "rooms"
            # room config has: (name, description, key_item, used_msg)*
            keyitems = []  # list of key items to config later
            for conf in config['rooms']:
                self.rooms[conf[0]] = Room(conf[0], conf[1])
                if conf[3] != None:  # key items to be set when have items
                    keyitems.append(
                        (conf[0], conf[2], conf[3]))  # (room, item, msg)

            # configure links between rooms
            doing = "links"
            # links config has: (room1, direction1, room2, direction2)*
            for conf in config['links']:
                self.rooms[conf[0]].link_room(self.rooms[conf[2]], conf[1],
                                              conf[3])
            # configure items
            doing = "items"
            # items config has: (name, description, location)
            player_items = []  # list of player items to config later
            for conf in config['items']:
                self.items[conf[0]] = Item(conf[0], conf[1])
                if conf[2] in self.rooms:  # place item in room
                    self.rooms[conf[2]].leave(self.items[conf[0]])
                else:  # item on character to add later
                    player_items.append((conf[0], conf[2]))

            # now configure key_items in rooms - has (room, item, msg)
            doing = "key_items"
            for conf in keyitems:
                self.rooms[conf[0]].set_key_item(self.items[conf[1]], conf[2])

            # configure characters (enemies, friends, player)
            doing = "enemies"
            # links config has: (name, description, conversation, location, weakness, defeat_msg)*
            for conf in config['enemies']:
                self.characters[conf[0]] = Enemy(conf[0], conf[1])
                self.characters[conf[0]].set_conversation(conf[2])
                self.characters[conf[0]].move_to(self.rooms[conf[3]])
                if conf[4] != None:
                    self.characters[conf[0]].set_weakness(
                        self.items[conf[4]], conf[5])

            doing = "friends"
            # friends config has: (name, description, conversation, location, desire, thank_msg)*
            for conf in config['friends']:
                self.characters[conf[0]] = Friend(conf[0], conf[1])
                self.characters[conf[0]].set_conversation(conf[2])
                self.characters[conf[0]].move_to(self.rooms[conf[3]])
                if conf[4] != None:
                    self.characters[conf[0]].set_desires(
                        self.items[conf[4]], conf[5])

            doing = "players"
            # players config has: (name, description, location)*
            num_players = 0
            for conf in config['players']:
                self.characters[conf[0]] = Player(conf[0], conf[1])
                self.characters[conf[0]].move_to(self.rooms[conf[2]])
                self.player = self.characters[conf[0]]
                num_players += 1
            if num_players != 1:
                print("You can only have 1 player character in the game!")

            # now configure player_items on characters - has (item, character)
            doing = "player_items"
            for conf in player_items:
                self.characters[conf[1]].add(self.items[conf[0]])

        except (IndexError, KeyError, ValueError) as msg:
            print("### Error: Incorrect format or values in " + doing +
                  " config: " + str(conf))
            print(str(msg))
            raise
Ejemplo n.º 21
0
kitchen = Room("Kitchen")
kitchen.set_description("A dank and dirty room buzzing with flies.")

dining_hall = Room("Dining Hall")
dining_hall.set_description(
    "A large room with ornate golden decorations on every wall")

ballroom = Room("Ballroom")
ballroom.set_description("A vast room with shiny decorations")

kitchen.link_room(dining_hall, "south")
dining_hall.link_room(kitchen, "north")
dining_hall.link_room(ballroom, "west")
ballroom.link_room(dining_hall, "east")

dave = Enemy("Dave", "A smelly zombie")
dave.set_conversation("Brrlgrh... rgrhl... brains...")
dave.set_weakness("cheese")
dining_hall.set_character(dave)

catrina = Friend("Catrina", "A friendly skeleton")
catrina.set_conversation("Why hello there.")
ballroom.set_character(catrina)

candle = Item("Candle")
candle.set_description("A candle to see your way through dark passages")
kitchen.set_item(candle)

current_room = kitchen
backpack = []
Ejemplo n.º 22
0
)

bedroom = Room("Bedroom")
bedroom.set_description(
    "A cozy but spooky place to rest with skeletons on the bed")

print("There are " + str(Room.number_of_rooms) + " rooms to explore.")

kitchen.link_room(dining_hall, "south")
dining_hall.link_room(kitchen, "north")
dining_hall.link_room(ballroom, "west")
dining_hall.link_room(bedroom, "east")
ballroom.link_room(dining_hall, "east")
bedroom.link_room(dining_hall, "west")

dave = Enemy("Dave", "A smelly zombie")
dave.set_conversation("Brrlgrh... rgrhl... brains...")
dave.set_weakness("gun")
dining_hall.set_character(dave)

davi = Enemy("Davi", "Another smelly zombie")
davi.set_conversation("Brrlgrh...urgghh..wanna dance?..")
davi.set_weakness("water")
bedroom.set_character(davi)

catrina = Friend("Catrina", "A friendly skeleton")
catrina.set_conversation("Why hello there.")
ballroom.set_character(catrina)

glasses = Item("glasses")
glasses.set_description("A pair of old glasses")
Ejemplo n.º 23
0
    def enter(self):
        print(
            dedent("""
                You currently stand in front of a dilapidated mansion. Lightning strikes in
                distance eluminate the nights sky. The shutters on the windows are closed and the
                front door is currently locked.

                You are currently investigated noise complaints from neighbours. They claim to have
                heard screams from the house.
                """))

        encounter_num = 0
        while encounter_num < 1:
            random_encounter = randint(1, 100)
            encounter_num += 1
            print(random_encounter)
            if random_encounter <= 10:
                Emy.rand_encounter()
                encounter_num += 1
                print(encounter_num)

            # put this in another function

            else:
                print("There are no enemies in sight")
                print("What would you like to do")

        choice = input("> ")
        global player_inventory
        if choice.lower() == 'West' or choice.lower() == 'w':
            return 'side_yard'
        elif choice.lower() == 'North' or choice.lower() == 'n':

            if 'front_door_key' in player_inventory:
                print("You open the door")
                print("_________________________________")
                return 'house_hall'
            else:
                print("The door is currently locked.")

        elif choice.lower() == 'South' or choice.lower() == 's':
            print("Behind you stands a busy street")
            print("You turn to leave, but something draws you back")
            print("You turn back to the house.")
            print("___________________________")
            return 'front_yard'
        elif choice.lower() == "east" or choice.lower() == 'e':
            global key_items
            print(key_items)
            if 'garage_door_opener' in key_items:
                print(
                    "you click the old garage door opening. A slow rumble can he heard as the old doors slowly open"
                )
                print("______________________________")
                return 'garage_door'
            else:
                print("The garage door is locked")
                print("_______________________")
                return 'front_yard'
            print("A large garage door stands in your way.")
            print("It currently appears to be locked.")
            print("_________________________________")
            return 'front_yard'
        #w_pn = Weapon('something', 'another', 'b')
        #weapon = w_pn.weapon_spawn()
        #print(weapon)

        elif choice.lower() == "items":
            item = Inventory()
            item.inventory()
            return 'front_yard'

        elif choice.lower() == 'health':
            global player_health
            print("Your current health is: ", player_health)
            return 'front_yard'

        else:
            print("I do not understand that command")
            return 'front_yard'
Ejemplo n.º 24
0
from character import Enemy
dave = Enemy("dave", "a smelly zombie")
davi = Enemy("davi", "another smelly zombie")
dave.describe()
davi.describe()
dave.set_conversation("hey")
davi.set_conversation("what weapon have you got?")
dave.talk()
davi.talk()

dave.set_weakness("sword")
print("What will you fight with?")
fight_with = input()
dave.fight(fight_with)

davi.set_weakness("gun")
print("okay, but what will you fight me with?")
fight_with = input()
davi.fight(fight_with)
from character import Character
from character import Enemy

sylv = Enemy("Sylvanas","A dirty, smelly, morally grey banshee zombie.")
sylv.describe()
sylv.set_conversation("BURN IT!")
sylv.talk()
sylv.set_weakness("Frostmourne")

print("What will you fight with?")
fight_with = input()
sylv.fight(fight_with)
Ejemplo n.º 26
0
# Connect rooms. These are one-way connections.
kitchen.link_room(library, "EAST")
kitchen.link_room(smalloffice, "SOUTH")
kitchen.link_room(locked, "WEST")
supplycloset.link_room(smalloffice, "EAST")
smalloffice.link_room(kitchen, "NORTH")
smalloffice.link_room(lab, "EAST")
smalloffice.link_room(locked, "SOUTH")
smalloffice.link_room(supplycloset, "WEST")
lab.link_room(locked, "SOUTH")
lab.link_room(smalloffice, "WEST")
library.link_room(kitchen, "WEST")
current_room = kitchen

# Set up characters
dmitry = Enemy("Dmitry", "A smelly zombie")
dmitry.set_speech("Brrlgrh... rgrhl... brains...")
dmitry.set_weaknesses(["FORK","SPORK","KNIFE"])
supplycloset.set_character(dmitry)

# This is a procedure that simply prints the items the player is holding and tells them if they can do something with that item
def playerItems():
    # Print out the player's Held Items and let player know if they can USE an item to fight a character or something
    if len(heldItems) == 1:
        print("You are holding a "+heldItems[0])
        print("You can DROP "+heldItems[0].upper())
        if current_room.character is not None:
            print("You can USE "+heldItems[0].upper()+" to fight "+current_room.character.name)
    elif len(heldItems) >= 2:
        print("Your hands are full. You must drop something before you can pick anything else up.")
        print("You are holding a "+heldItems[0]+" and a "+heldItems[1])
Ejemplo n.º 27
0
refrigerator.add_contents(cheese, pizza)
refrigerator.key = knife

kitchen.add_items(refrigerator, cheese, pizza)

book = Item("book")
dining_hall.add_items(book)


# define characters and enemies
mike = Character("Mike", "a computer programmer")
mike.conversation = ["You never know when you could use some cheese.", "And you can't use cheese after you've eaten it."]
mike.QA = ({"what", "favorite", "language"}, "Python, of course!")
kitchen.inhabitants.add(mike)

dave = Enemy("Dave", "a smelly zombie")
dave.conversation = ["What's up, dude! I'm hungry.", "What do you call cheese that isn't yours?", "Nacho cheese!"]
dave.weakness = cheese
dining_hall.inhabitants.add(dave)

eddie = Enemy("Eddie", "another smelly zombie")
eddie.conversation = ["I'm not really hungry.", "Ok, I'm a zombie.  I'm always hungry.", "But for what?!"]
eddie.weakness = pizza
dining_hall.inhabitants.add(eddie)

tabitha = Enemy("Tabitha", "an enormous spider with countless eyes and furry legs.")
tabitha.conversation = ["Sssss....I'm so bored...", "Read any good books lately?"]
tabitha.weakness = book
ballroom.inhabitants.add(tabitha)

Ejemplo n.º 28
0
# ITEMS
party_invite = Item("Party Invite")
party_invite.set_description("A Party Invite on rich parchment stamped wtih the Royal Seal.")

fancy = Item("Fancy Shoes")
fancy.set_description("A pair of sparkling shoes that seem to be made of diamonds, and flash in the light.")


### CHARACTERS ###

###she should probably have fish in her store ha ha ha
molly = Npc("Molly Malone", "A shop keeper who has the same old items, but new gossip every day.")
molly.set_conversation("'Welcome to my shop!'")
shop.set_character(molly)

redbeard = Enemy("Redbeard", "A handsome pirate with a large red beard and suspiciously dazzling shoes.\nHe carries a large blade on his side that is knicked and marred with age.")
redbeard.set_conversation("'Without the secret token, I will not allow you on board.'")
redbeard.set_attack_strength(100)
redbeard.set_defense_strength(100)
redbeard.set_weapon("Pistol")
ship.set_character(redbeard)

borris = Npc("Borris Boreleon", "A stiff guard who takes joy in following orders and has been working for the Royal Family for over twenty years.")
borris.set_conversation("Judging by your clothes, I doubt you have a Party Invitation.  If you don't, you will need to leave or face severe consequence.")
borris.set_item_give(party_invite.name)
gate.set_character(borris)



#### NAME COLLECTION ####
Ejemplo n.º 29
0
# Define the items
fromage = Item("fromage")
fromage.set_readable_name("du fromage")
fromage.set_description("Il sent encore plus mauvais que le zombie !")
cuisine.set_item(fromage)

livre = Item("livre")
livre.set_readable_name("un livre")
livre.set_description("Un très gros livre intitulé \"Python pour les nuls\".")
salon.set_item(livre)



# Define the people
dave = Enemy("Dave", "Un zombie puant")
dave.set_conversation("Arrrgggg... yahhhhh... manger...")
dave.set_weakness("fromage")
salon.set_character(dave)

olga = Friend("Olga", "Un squelette sympa")
olga.set_conversation("Salut ! Je suis un tas d'os.")
cuisine.set_character(olga)

tabatha = Enemy("Tabatha", "Une énorme araignée aux pattes velues.")
tabatha.set_conversation("Pfffff.... Je m'ennuie...")
tabatha.set_weakness("livre")
salle_a_manger.set_character(tabatha)


Ejemplo n.º 30
0
kitchen = Room("Kitchen")
kitchen.set_description("A dank and dirty room buzzing with flies.")

dining_hall = Room("Dining Hall")
dining_hall.set_description("A large room with ornate golden decorations on each wall.")

ballroom = Room("Ballroom")
ballroom.set_description("A vast room with a shiny wooden floor. Huge candlesticks guard the entrance.")

kitchen.link_room(dining_hall, "south")
dining_hall.link_room(kitchen, "north")
dining_hall.link_room(ballroom, "west")
ballroom.link_room(dining_hall, "east")

dave = Enemy("Dave", "A smelly zombie")
dave.set_conversation("aaaaaghhh")
dave.set_weakness("cheese")
dining_hall.set_character(dave)

catrina = Friend("Catrina", "A friendly skeleton")
catrina.set_conversation("Why hello there.")
ballroom.set_character(catrina)

current_room = kitchen

dead = False

while dead == False:
    print("\n")
    current_room.get_details()