Esempio n. 1
0
def updateInCombat():
    global gameOver, inCombat, currentEnemy, won
    #for i in range(1, 31):
    #    win.addstr(i, 1, ' '*90)

    combat = Combat(mapWin, statWin, control.player,
                    control.enemies[currentEnemy])

    #win.addstr(1, 2, "combat goes here...")
    #win.addstr(2, 2, "press any key to continue (` still quits)")

    #mapWin.refresh()
    #ch = win.getkey()

    fightOutcome = combat.fight()

    mapWin.border('|', '|', '-', '-', '+', '+', '+', '+')

    if fightOutcome == 2 or fightOutcome == 1:
        gameOver = True
        inCombat = False
        won = 0
        return
    elif fightOutcome == 0:
        control.enemies[currentEnemy].alive = False
        inCombat = False
        currentEnemy = None
        return
Esempio n. 2
0
    def do_combat(self):

        monster = Monster(self.player.level,
                          location=self.player.location_in_wild)
        monster.generate_char(boss=False)
        combat = Combat(monster, player=self.player)
        leave = combat.combat()
        return leave
Esempio n. 3
0
	def receiveObject(self, obj):
		if self.grid[obj.x][obj.y].object is "empty":
			self.grid[obj.x][obj.y].receiveObject(obj)
		else:
			Combat.meleeCombat(obj, self.grid[obj.x][obj.y].object, self)
			if obj.isDead:
				pass
			else:
				self.grid[obj.x][obj.y].receiveObject(obj)
Esempio n. 4
0
def main():
    ITEMS_PER_PLAYER = 0

    existed = True

    new = False
    level = 1

    while (True):
        print()
        main, existed = safe_load("Main", existed, new, level=level)
        viic14, existed = safe_load("Buddy", existed, new, level=level)

        for _ in range(ITEMS_PER_PLAYER):
            main.add_item(Item(main))
            viic14.add_item(Spell(viic14))

        if (existed): break
        if (not 'n' in input("Press enter to start \n")): break

    menu = {'1': "Fight", '2': "Show player stats", '0': "Quit"}

    menu_funct = {
        '1':
        lambda: Combat({
            'Bona gent': [main, viic14],
            "Mala gent": [
                Character("Enemy1", main.level - randint(0, 1)),
                Character("Enemy2", viic14.level - randint(0, 1))
            ]
        }).start(),
        '2':
        lambda: print(f"{main._item_stats}\n\n{viic14._item_stats}"),
        '0':
        lambda: 0
    }

    pstr = '\n\t'.join([f"[{num}] {desc}" for num, desc in menu.items()])
    del menu

    try:
        move = input(f"Menu: \n\t{pstr}\n> ")
        while (move != '0'):
            menu_funct.get(
                move,
                lambda: print("Invalid opion. Please choose another one"))()

            move = input(f"\nMenu: \n\t{pstr}\n> ")

    except KeyboardInterrupt:
        if ('n' in input("\nSave anyway? [y] ").lower()):
            exit(0)

    print()
    main.save()
    viic14.save()
Esempio n. 5
0
    def move(self, direction):
        nextArea = None
        if direction == "n": nextArea = self.current_area.north
        if direction == "e": nextArea = self.current_area.east
        if direction == "s": nextArea = self.current_area.south
        if direction == "w": nextArea = self.current_area.west

        direction_names = {
            "n": "North",
            "e": "East",
            "s": "South",
            "w": "West"
        }

        if nextArea != None:
            distance = 3
            header = "   Travelling " + direction_names[direction] + " to " + nextArea.name
            print()
            safe = None

            for i in range(0, distance):
                print(header + ("." * i), end="\r")
                sleep(0.4)
                if randint(0,20) == 1:
                    rand_encounter = Combat(self.player)
                    safe = rand_encounter.combat_loop()
                    break

            if safe == None:
                print(header + "...  You made it safely.", end ="\r")
                self.current_area = nextArea
                sleep(1)
            elif safe == True:
                print()
                print_loading_anim("You made it to " + nextArea.name + " safely.", 3)
                self.current_area = nextArea
            else:
                print_loading_anim("You stumble back to " + self.current_area.name + ", defeated", 3)


            return True
        else:
            return False
Esempio n. 6
0
    def change_state(self) -> None:
        """Calcul gérant le changement d'état de la machine"""
        if self._etatActuel == Etats.Gestion:
            pass
        elif self._etatActuel == Etats.Expedition:
            if self._whatAppend is not None:
                self._etatActuel = Etats.Evenement
                TypeCase = self._expedition.returnTypeCase(self._whatAppend).split("_")
                event = Recompense(TypeCase[0])

                if TypeCase[0] == "Tour" or TypeCase[1].startswith("S"):
                    event = Combat(self._expedition.getEquipe(), "Bandit")
                    print("Combat contre Bandit")
                if TypeCase[0] == "Archer" or TypeCase[1].startswith("R"):
                    event = Combat(self._expedition.getEquipe(), "Soldat")
                    print("Combat contre Soldat")
                if TypeCase[0] == "Arche" or TypeCase[1].startswith("A"):
                    event = Combat(self._expedition.getEquipe(), "Chien")
                    print("Combat contre Chien")
                if TypeCase[0] == "Mine":
                    event = Combat(self._expedition.getEquipe(), "Kv2v2v2")
                    print("Combat contre Kv2v2v2")

                event.lancement()
                self._modeEvenement = ModeEvenement(event, self._expedition.getEquipe())

        elif self._etatActuel == Etats.Evenement:
            if not self._modeEvenement.getEnCours():
                self._etatActuel = Etats.Expedition
                self._whatAppend = None
                if self._modeEvenement.getVictoire() == False:
                    self._etatActuel = Etats.Gestion
                    self._whatAppend = "DEFAITE"
                elif self._modeEvenement.getEvenement().nom == "Kv2v2v2":
                    self._whatAppend = "VICTOIRE"
                    self._etatActuel = Etats.Gestion
                else:
                    self._combatdispute += 1

        else:
            print("Etat inexistant dsl ...")
Esempio n. 7
0
def main():
    pygame.init()
    run = True
    bg = pygame.image.load("imgs/BG1.png")

    screen = pygame.display.set_mode((1920, 1080), flags=pygame.FULLSCREEN)

    screen.blit(bg, (0, 0))
    pygame.display.flip()
    while run:
        wait(20)
        keys = pygame.key.get_pressed()
        if keys[pygame.K_ESCAPE]:
            run = False
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                run = False
            if event.type == pygame.KEYDOWN and event.key == pygame.K_RETURN:
                p1 = Party(Monster.Larchanter(100))
                p2 = Party(Monster.Larchanter(100))
                Combat(p1, p2, "normal", True, screen)
                screen.blit(bg, (0, 0))
                pygame.display.flip()
Esempio n. 8
0
perso.addInvent(objet)
transceiver.sauver_personnage(perso)
transceiver.sauver_personnage(perso1)
transceiver.sauver_personnage(perso2)

transceiver.sauver_arme(arme)
arme["nom"] = "2eme"
transceiver.sauver_arme(arme)

transceiver.sauver_armure(armure)
transceiver.sauver_competance(competance)
transceiver.sauver_sort(sort)
transceiver.sauver_objet(objet)

partie = Partie("aLELJD")
combat1 = Combat()
combat1.addPlayer(perso)
combat1.addPlayer(perso1)
combat1.addMonster(perso1)
combat1.addMonster(perso2)
combat1.rename("plouf")
partie.addCombat(combat1)

combat1 = ""
combat2 = Combat([], [])
combat2.addPlayer(perso)
combat2.addMonster(perso1)
combat2.addMonster(perso2)
combat2.rename("plouf2")
combat2.commencer()
partie.addCombat(combat2)
Esempio n. 9
0
	def __init__(self):
		GameObject.__init__(self)
		Combat.__init__(self) 
		Spell.__init__(self) 
Esempio n. 10
0
	def __init__(self):
		GameObject.__init__(self) 
		Combat.__init__(self) 
		Spell.__init__(self) 
Esempio n. 11
0
from Combat import Enemy, Combat
from Player import Player, Weapon, Armour
from bestiary import bastard_sword, quarterstaff

player = Player("Hrothgar")
player.add_item(bastard_sword)
player.add_item(quarterstaff)
player.add_item(Armour("Leather Leggings", "", 1, "leggings"))
player.equip("sword")

rand_encounter = Combat(player)
rand_encounter.combat_loop()
Esempio n. 12
0
	def moveObject(self, owner): #In this case, the owner is the grid
		speed = self.object.getSpeed() #To see how many tiles we need to check
		direction = self.object.direction #To see in what direction
		moved = self.object.hasMoved() #To ensure we move at least once. (But not more)
		if self.object.handle is not "hero":
			#RIGHT
			if direction == "RIGHT" and self.object.hasMoved() is False: #Check x+1 through x+speed    TODO ----
				if self.x+speed < owner.widthTiles: 
					if owner.tileIsWalkable(self.x+speed, self.y):
						self.object.moved(True)
						self.object.moveRight()
						owner.receiveObject(self.object) #Send the object on it's way
						self.object = "empty" # Remove the object that is no longer occupying the space
						
					elif not owner.tileIsWalkable(self.x+speed, self.y) and owner.grid[self.x+speed][self.y].object.team is not self.object.team:#We couldn't move there, but can we attack it?
						Combat.meleeCombat(self.object, owner.grid[self.x+speed][self.y].object, owner)
					else: #Right didn't work, due to collision or edge of map
						self.object.getRandomDirection() #Collision
				else:
					self.object.getRandomDirection()#Edge of world
			
			
			#LEFT
			elif direction == "LEFT" and self.object.hasMoved() is False:
				if self.x-speed >= 0:
					if owner.tileIsWalkable(self.x-speed, self.y):
						self.object.moved(True)
						self.object.moveLeft()#Update XorY value
						owner.receiveObject(self.object) #Send the object on it's way
						self.object = "empty" # Remove the object that is no longer occupying the space
						
					elif not owner.tileIsWalkable(self.x-speed, self.y) and owner.grid[self.x-speed][self.y].object.team is not self.object.team:#We couldn't move there, but can we attack it?
						Combat.meleeCombat(self.object, owner.grid[self.x-speed][self.y].object, owner)

					else: #Left didn't work, due to collision or edge of map 
						self.object.getRandomDirection() #Collision
				else:
					self.object.getRandomDirection() #Edge of world
					
					
			#DOWN		
			elif direction == "DOWN" and self.object.hasMoved() is False:
				if self.y + speed < owner.lengthTiles:
					if owner.tileIsWalkable(self.x, self.y+speed):
						self.object.moved(True)
						self.object.moveDown()#Update XorY value
						owner.receiveObject(self.object) #Send the object on it's way
						self.object = "empty" # Remove the object that is no longer occupying the space
						
					elif not owner.tileIsWalkable(self.x, self.y+speed) and owner.grid[self.x][self.y+speed].object.team is not self.object.team:#We couldn't move there, but can we attack it?
						Combat.meleeCombat(self.object, owner.grid[self.x][self.y+speed].object, owner)
						
					else: #Down didn't work, due to collision or edge of map 
						self.object.getRandomDirection() #Collision
				else:
					self.object.getRandomDirection() #Edge of world
						
						
			#UP			
			elif direction == "UP" and self.object.hasMoved() is False:
				if self.y-speed >= 0:
					if owner.tileIsWalkable(self.x, self.y-speed):
						self.object.moved(True)
						self.object.moveUp()#Update XorY value
						owner.receiveObject(self.object) #Send the object on it's way
						self.object = "empty" # Remove the object that is no longer occupying the space
						
					elif not owner.tileIsWalkable(self.x, self.y-speed) and owner.grid[self.x][self.y-speed].object.team is not self.object.team:#We couldn't move there, but can we attack it?
						Combat.meleeCombat(self.object, owner.grid[self.x][self.y-speed].object, owner)
						
					else: #Up didn't work due to collision (OR EDGE OF MAP)
						self.object.getRandomDirection() #Collision
				else:
					self.object.getRandomDirection()#Edge of world	
		
		else:
			pass
			
Esempio n. 13
0
 def create_combat(self, nom):
     cbt = Combat()
     cbt.rename(nom)
     self.listCbts.append(cbt)
Esempio n. 14
0
    boss_enum = HARPY_BOSS
    is_victory = False

    # create map object
    maps = Maps(ROWS, COLUMNS)
    maps.new_map()

    while boss_enum <= DRAGON_BOSS:
        # check if alchemist walked onto a pick-up
        potential_pick_up = maps.set_alchemist_position(alchemist)
        is_boss = check_pick_up(potential_pick_up)

        # if pick-up was a boss
        if is_boss:
            current_boss = make_boss(boss_enum)
            current_boss.appear()
            is_victory = Combat(alchemist, current_boss).fight()

        # if boss was killed
        if is_victory:
            boss_enum += 1

        # update map and prompt user input for move/inventory
        maps.print_map()
        choice = user_choice()

        # move alchemist and change map if zoned
        is_new_map = alchemist.user_choice(choice, ROWS, COLUMNS)
        if is_new_map:
            maps.new_map()
Esempio n. 15
0
char2.name = "Herbert"
action2 = Action(char2, hieb0, gladius)
reaction2 = Action(char2, block0, gladius)

arena = Arena()
arena.addTeam("blue", [char1])
arena.addTeam("red", [char2])
print (arena.getCharacters())
# Create a Player for each character


player1 = RandomPlayer("Player1", char1, arena, action1, reaction1)
player2 = RandomPlayer("Player2", char2, arena, action2, reaction2)
players = [player1, player2]

points = [0,0]
for round in range(100):
    # reset chars
    char1.reset()
    char2.reset()
    # Create a combat
    combat = Combat(arena, players)
    # fight till the death of one team
    combat.fightTillDefeat()
    points[0] += 1 if char1.isAlive() else 0
    points[1] += 1 if char2.isAlive() else 0
print("%s VS %s   =>  (%d : %d)"%(char1.name, char2.name, points[0], points[1]))