Пример #1
0
 def __init__(self):
     self.view = View()
     self.map = Map()
     self.characters = Characters('anyadat')
     self.hero = Hero()
     self.skeleton = Skeleton()
     self.boss = Boss()
     self.view.draw_map(self.map.gamezone1)
Пример #2
0
 def __init__(self):
     self.view = View()
     self.map = Map()
     self.hero = Hero()
     self.view.screen(self.map.playscreen)
     self.view.draw_hero(self.hero.x, self.hero.y, "down")
     self.view.canvas.bind("<Up>", self.move_up)
     self.view.canvas.bind("<Down>", self.move_down)
     self.view.canvas.bind("<Left>", self.move_left)
     self.view.canvas.bind("<Right>", self.move_right)
     self.enemies = [Skeletons(8, 10), Skeletons(7, 5), Boss(4, 4)]
     self.view.draw_enemies(self.enemies)
Пример #3
0
 def create_monsters(self):
     skeleton = PhotoImage(file="images/skeleton.png")
     boss = PhotoImage(file="images/boss.png")
     count = 0
     while count < random.randint(3, 6):
         i = random.randint(0, 9)
         j = random.randint(0, 9)
         if m.matrix[j][i] == 0:
             skelet = Skeleton(i, j, skeleton)
             self.characters.append(skelet)
             count += 1
     #creating random boss
     count2 = 0
     while count2 < 1:
         i = random.randint(0, 9)
         j = random.randint(0, 9)
         if m.matrix[j][i] == 0:
             bos = Boss(i, j, boss)
             self.characters.append(bos)
             count2 += 1
Пример #4
0
 def enter(self):
     print "You walk from your desk to the coffee room"
     print "You realize you did not bring a lunch today :(\n"
     a = choice([Linda(), Coach(), Boss()])
     a.action()
     return 'desk'
Пример #5
0
 def enter(self):
     print "You walk from your desk to the water cooler."
     a = choice([Linda(), Coach(), Boss()])
     a.action()
     return 'desk'
Пример #6
0
""" Section 2 """

""" make a list of enemies, with positions on the main map. If a enemy is in current frame, then pull him out of the list, and activate him. If he dies, remove him. If he leaves map, remove him.
Place him in ways such that he doesnt fall into holes lmao"""

enemies = []

enemies.append(Mushroom(2*13, 80 + 4* 6, 10))
enemies.append(Mushroom(2*13, 80 + 4* 10, 3))
enemies.append(Mushroom(2*13, 160 + 4* 6, 3))
enemies.append(Mushroom(2*13, 160 + 4* 10, 3))
enemies.append(Mushroom(2*13, 240 + 4* 8, 3))
enemies.append(Mushroom(2*13, 400 + 4* 6, 3))
enemies.append(Mushroom(2*13, 400 + 4* 10, 3))
enemies.append(Mushroom(2*13, 480 + 4* 8, 5))
enemies.append(Boss(2*10, 880 + 4*14 ))

""" Section 2 """

""" Section 3 """

coins = []

coins.append(Coin(2*10,4*8+81))
coins.append(Coin(2*10,4*7 + 161))
coins.append(Coin(2*10,4*10 + 161))
coins.append(Coin(2*10,401 + 4*4))
coins.append(Coin(2*10,401 + 4*8))
coins.append(Coin(2*10,401 + 4*12))
coins.append(Coin(2*6,401 + 4*8))
coins.append(Coin(2*10,481+ 4*5))
Пример #7
0
class Game:
    """ Class used to play the game. """

    # We start Pygame
    pygame.init()
    pygame.font.init()
    # We prepare the font of our caption to indicate how many items we picked
    # up
    myfont = pygame.font.SysFont(None, 40)

    # We display the window
    square_window = pygame.display.set_mode(WINDOW_DIMENSIONS)

    # We make the labyrinth
    labyrinth = Labyrinth(FLOOR_IMAGE, WALL_IMAGE, LEVEL_FILE)
    labyrinth.initialize_labyrinth(square_window)

    # We initialize McGyver and the gatekeeper
    mac = Player(PLAYER_PIC, labyrinth.PLAYER_COORDINATES)
    gatekeeper = Boss(BOSS_PIC, labyrinth.BOSS_COORDINATES)

    # We initialize the three components of the serynge
    needle = Items(NEEDLE_PIC, labyrinth)
    tube = Items(TUBE_PIC, labyrinth)
    ether = Items(ETHER_PIC, labyrinth)

    # Displays Items
    def display_items(self, item):
        self.square_window.blit(item.image, item.coordinates)

    # Display characters
    def display_character(self, character):
        self.square_window.blit(character.head, character.coordinates)

    def main(self):
        """ Function that runs the game """
        is_running = True
        # Loop of the game
        while is_running:

            # Displays the game
            self.labyrinth.display_labyrinth(self.square_window)
            self.display_character(self.mac)
            self.display_character(self.gatekeeper)
            for item in Items.LIST_OF_ITEMS:
                self.display_items(item)
            pygame.display.flip()

            # What happens when we meet the gatekeeper
            if self.mac.coordinates in self.labyrinth.FIGHT_POSITION:
                if self.mac.count == 3:
                    self.mac.neutralize(
                        self.labyrinth,
                        self.gatekeeper,
                        self.labyrinth.EXIT_POSITION)
                else:
                    self.gatekeeper.lose(self.mac, CARCASS)
                    self.square_window.blit(
                        self.mac.head, self.mac.coordinates)
                    is_running = False

            # Reaching the exit position
            if self.mac.coordinates == self.labyrinth.EXIT_POSITION:
                self.mac.victorious = True
                is_running = False

            # Events detection
            for event in pygame.event.get():
                if event.type == QUIT:
                    is_running = False
                if event.type == KEYDOWN:
                    x, y = self.mac.move(event)

                    # Square where we can walk, or with a serynge component, or
                    # wall so we can't use it
                    if (x, y) in [
                            item.coordinates for item in Items.LIST_OF_ITEMS]:
                        self.mac.count += 1
                        Items.LIST_OF_ITEMS = [
                            item for item in Items.LIST_OF_ITEMS if item.coordinates != (
                                x, y)]
                        moving = True
                        print(self.mac.count)
                    else:
                        moving = False

                    if self.labyrinth.reachable((x / 40, y / 40)):
                        moving = True

                    #  Moving means replace the position of Mac by en empty square
                    # Moving also means replacing an empty square by the
                    # position of Mac
                    if moving:
                        self.labyrinth.void.append(self.mac.coordinates)
                        self.mac.coordinates = (x, y)

            txt = self.myfont.render(
                str(self.mac.count) + "items picked up!", False, (255, 255, 255))
            self.square_window.blit(txt, (0, 0))
            pygame.display.flip()

        # Outcome of the game
        if self.mac.victorious:
            path = VICTORY
        else:
            path = FAILURE

        # Showing the outcome notification
        notification = pygame.image.load(path).convert()
        self.square_window.blit(notification, (100, 300))
        pygame.display.flip()

        #  Waiting 1 seconds before closing the window
        sleep(1)
Пример #8
0
from spells import Effect, TimedEffect
from spells import magic_missile, drain, shield, poison, recharge
from characters import Boss, Wizard
from strategies import SelectSpellByPredefinedOrder
from game_state import GameState

def hit_armor_mana(wizard):
	return (wizard.hit_points, wizard.armor, wizard.mana)

mock_order = [poison(), magic_missile(), recharge(), shield(), drain(), poison(), magic_missile()]

# For example, suppose the player has 10 hit points and 250 mana,
wizard = Wizard(hit_points=10, mana=250, spell_selection_strategy=SelectSpellByPredefinedOrder(mock_order))
# and that the boss has 13 hit points and 8 damage:
boss = Boss(hit_points=13, damage=8)

game_state = GameState(wizard, boss)

# -- Player turn --
# - Player has 10 hit points, 0 armor, 250 mana
assert hit_armor_mana(wizard) == (10, 0, 250)
# - Boss has 13 hit points
assert boss.hit_points == 13

# Player casts Poison.
s = wizard.launch_spell(game_state)
assert s.name == 'Poison'

# -- Boss turn --
# - Player has 10 hit points, 0 armor, 77 mana
Пример #9
0
def warriorBattle(player,level):
    enemy = Boss(level)
    print(f"You are up against a level {level} boss. Good luck!\n")
    counter = 0
    while player.health > 0:
        attack = input("Would you like to jab (10 energy), use strike (25 energy), rest (gives 50 energy), or use invincibility (50 energy)? ")
        if attack == 'jab':
            player.jab()
            print(f"That did {player.damage} damage!\n")
            print(f"You now have {player.energy} energy left.\n")
            enemy.health -= player.damage
            print(f"The boss has {enemy.health} HP left.\n")
            player.damage = 0
        elif attack == 'strike':
            player.strike()
            print(f"That did {player.damage} damage!\n")
            print(f"You now have {player.energy} energy left.\n")
            enemy.health -= player.damage
            print(f"The boss has {enemy.health} HP left.\n")
            player.damage = 0
        elif attack == 'rest':
            player.rest()
            print("Ah! You're awake!\n")
            print(f"You now have {player.energy} energy left.\n")
        elif attack == 'invincibility':
            player.invincibility()
            print("You now have a 75% damage reduction for 2 turns.\n")
            print(f"You have {player.energy} energy left\n")
        if player.invincible:
            counter+= 1
        if counter == 2:
            player.invincible = False
            counter = 0
        time.sleep(1)
        boss_attack = random.randint(0, 1)
        if enemy.health < 0:
            print(f"\nCongratulations {player.name}! You defeated the boss!\n")
            player.coins += enemy.coins
            print(f"You earned {enemy.coins} coins!\n")
            break
        while True:
            if boss_attack:
                enemy.smash()
                if enemy.enough_energy:
                    if random.random() < player.agility:
                        time.sleep(1)
                        print("But he misses!\n")
                    else:
                        time.sleep(1)
                        if player.invincible:
                            print(f"That only did {enemy.damage * 0.25} damage!\n")
                            player.health -= (enemy.damage * 0.25)
                            time.sleep(1)
                            print(f"You have {player.health} HP left.\n")
                        else:
                            print(f"That did {enemy.damage} damage!\n")
                            player.health -= enemy.damage
                            time.sleep(1)
                            print(f"You have {player.health} HP left.\n")
                    enemy.damage = 0
                    enemy.enough_energy = None
                    break
                elif not enemy.enough_energy:
                    enemy.enough_energy = None
                    boss_attack = 0
            if not boss_attack:
                enemy.stomp()
                if enemy.other_energy:
                    if random.random() < player.agility:
                        time.sleep(1)
                        print("But he misses!\n")
                    else:
                        time.sleep(1)
                        if player.invincible:
                            print(f"That only did {enemy.damage * 0.25} damage!\n")
                            player.health -= (enemy.damage * 0.25)
                            time.sleep(1)
                            print(f"You have {player.health} HP left.\n")
                        else:
                            print(f"That did {enemy.damage} damage!\n")
                            player.health -= enemy.damage
                            time.sleep(1)
                            print(f"You have {player.health} HP left.\n")
                    enemy.damage = 0
                    enemy.other_energy = None
                    break
                elif not enemy.other_energy:
                    enemy.other_energy = None
                    boss_attack = 1
            if enemy.energy < 15:
                enemy.rest()
                print("The boss takes a rest.\n")
                break
    if player.health <= 0:
        print("You have died. Game over.\n")
        win = 0
Пример #10
0
def sorcererBattle(player,level):
    enemy = Boss(level)
    print(f"You are up against a level {level} boss. Good luck!")
    counter = 0
    while player.health > 0:
        attack = input("Would you like to blast (10 energy), use fireball (30 energy), rest (gives 50 energy), or use invisibility (60 energy)? ")
        if attack == 'blast':
            player.blast()
            print(f"That did {player.damage} damage!\n")
            print(f"You now have {player.energy} energy left.\n")
            enemy.health -= player.damage
            print(f"The boss has {enemy.health} HP left.\n")
            player.damage = 0
        elif attack == 'fireball':
            player.fireball()
            print(f"That did {player.damage} damage!\n")
            print(f"You now have {player.energy} energy left.\n")
            enemy.health -= player.damage
            print(f"The boss has {enemy.health} HP left.\n")
            player.damage = 0
        elif attack == 'rest':
            player.rest()
            print("Ah! You're awake!")
            print(f"\nYou now have {player.energy} energy left.\n")
        elif attack == 'invisibility':
            player.invisibility()
            print("You are now invisible for 2 turns.\n")
            print(f"You have {player.energy} energy left.\n")
            player.agility = 1
        if player.invisible:
            counter+= 1
        if counter == 2:
            print("You are no longer invisible.\n")
            player.invisible = False
            player.agility = player.speed
            counter = 0
        time.sleep(1)
        boss_attack = random.randint(0, 1)
        if enemy.health < 0:
            print(f"\nCongratulations {player.name}! You defeated the boss!\n")
            player.coins += enemy.coins
            print(f"You earned {enemy.coins} coins!\n")
            break
        while True:
            if boss_attack:
                enemy.smash()
                if enemy.enough_energy:
                    if random.random() < player.agility:
                        time.sleep(1)
                        print("But he misses!\n")
                    else:
                        time.sleep(1)
                        print(f"That did {enemy.damage} damage!\n")
                        player.health -= enemy.damage
                        time.sleep(1)
                        print(f"You have {player.health} HP left.\n")
                    enemy.damage = 0
                    enemy.enough_energy = None
                    break
                elif not enemy.enough_energy:
                    enemy.enough_energy = None
                    boss_attack = 0
            if not boss_attack:
                enemy.stomp()
                if enemy.other_energy:
                    if random.random() < player.agility:
                        time.sleep(1)
                        print("But he misses!\n")
                    else:
                        time.sleep(1)
                        print(f"That did {enemy.damage} damage!\n")
                        player.health -= enemy.damage
                        time.sleep(1)
                        print(f"You have {player.health} HP left.\n")
                    enemy.damage = 0
                    enemy.other_energy = None
                    break
                elif not enemy.other_energy:
                    enemy.other_energy = None
                    boss_attack = 1
            if enemy.energy < 15:
                enemy.rest()
                print("The boss takes a rest.\n")
                break
    if player.health<= 0:
        print("You have died. Game over.\n")
        win = 0