First commit
This commit is contained in:
BIN
__pycache__/game_classes.cpython-312.pyc
Normal file
BIN
__pycache__/game_classes.cpython-312.pyc
Normal file
Binary file not shown.
12
core_game.py
Normal file
12
core_game.py
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
import game_classes as gc
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Difficulty()
|
||||||
|
|
||||||
|
hero = gc.Character(100, 3)
|
||||||
|
first_ennemy = gc.Character(25, ennemy_power)
|
||||||
|
|
||||||
|
print(ennemy_power)
|
||||||
|
|
||||||
|
'Fight(hero, first_ennemy)'
|
||||||
110
game_classes.py
Normal file
110
game_classes.py
Normal file
@@ -0,0 +1,110 @@
|
|||||||
|
from random import randrange
|
||||||
|
import time
|
||||||
|
|
||||||
|
class Character():
|
||||||
|
'Classe de personnage'
|
||||||
|
def __init__(self, health, power):
|
||||||
|
self.health = health
|
||||||
|
self.power = power
|
||||||
|
self.damage = randrange(2,7) * self.power
|
||||||
|
self.armor = randrange(1,3) * self.power
|
||||||
|
|
||||||
|
def Fight(player, ennemy):
|
||||||
|
turn_count = 1
|
||||||
|
while player.health > 0 and ennemy.health > 0:
|
||||||
|
print("Tour %s\n====================\n" % (str(turn_count)))
|
||||||
|
|
||||||
|
'Calcul des forces et défenses'
|
||||||
|
|
||||||
|
player_damage = randrange(2,7) * player.power
|
||||||
|
player_armor = randrange(1,3) * player.power
|
||||||
|
ennemy_damage = randrange(2,7) * ennemy.power
|
||||||
|
ennemy_armor = randrange(1,3) * ennemy.power
|
||||||
|
|
||||||
|
'Calculs de Fight'
|
||||||
|
|
||||||
|
damage_to_ennemy = player_damage - ennemy_armor
|
||||||
|
|
||||||
|
if damage_to_ennemy > 0:
|
||||||
|
ennemy.health -= damage_to_ennemy
|
||||||
|
print("Vous faites %s dégâts à votre ennemi." % (damage_to_ennemy))
|
||||||
|
if damage_to_ennemy <= 0:
|
||||||
|
print("Vous ne faites aucun dégât !")
|
||||||
|
|
||||||
|
damage_to_player = ennemy_damage - player_armor
|
||||||
|
|
||||||
|
if damage_to_player > 0:
|
||||||
|
player.health -= damage_to_player
|
||||||
|
print("Votre ennemi vous fait %s dégâts." % (damage_to_player))
|
||||||
|
if damage_to_player <= 0:
|
||||||
|
print("Votre ennemi ne vous fait aucun dégât !")
|
||||||
|
|
||||||
|
'Résultats'
|
||||||
|
|
||||||
|
print("Il vous reste %s points de vie, et à votre ennemi %s.\n" % (player.health, ennemy.health))
|
||||||
|
turn_count += 1
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
|
'Sorties de boucle'
|
||||||
|
|
||||||
|
if player.health <= 0:
|
||||||
|
print("Vous avez succombé.")
|
||||||
|
if ennemy.health <= 0:
|
||||||
|
print("Vous avez triomphé !")
|
||||||
|
|
||||||
|
def Difficulty():
|
||||||
|
match input("Quelle difficulté voulez-vous ?\n\
|
||||||
|
MERCI DE CHOISIR UN CHIFFRE\n \
|
||||||
|
> Facile [1]\n \
|
||||||
|
> Moyen [2]\n \
|
||||||
|
> Difficile [3]\n \
|
||||||
|
> Hardcore [4]\n \
|
||||||
|
> "):
|
||||||
|
case "1" | "Facile" | "&" | "F" | "f":
|
||||||
|
print("\nLa difficulté sera sur \"Facile\"")
|
||||||
|
return 1
|
||||||
|
case "2" | "Moyen" | "é" | "M" | "m":
|
||||||
|
print("\nLa difficulté sera sur \"Moyen\"")
|
||||||
|
return 2
|
||||||
|
case "3" | "Difficile" | "\"" | "D" | "d":
|
||||||
|
print("\nLa difficulté sera sur \"Difficile\"")
|
||||||
|
return 3
|
||||||
|
case "4" | "Hardcore" | "\'" | "H" | "h":
|
||||||
|
print("\nLa difficulté sera sur \"Hardcore\"")
|
||||||
|
return 4
|
||||||
|
case _:
|
||||||
|
print("\nMerci de donner un objectif clair.\n")
|
||||||
|
return Difficulty()
|
||||||
|
|
||||||
|
def EnnemyHealth():
|
||||||
|
match input("Combien de points de vie voulez-vous pour votre ennemi ?\n\
|
||||||
|
MERCI DE CHOISIR UN CHIFFRE\n \
|
||||||
|
> 25 [1]\n \
|
||||||
|
> 50 [2]\n \
|
||||||
|
> 75 [3]\n \
|
||||||
|
> 100 [4]\n \
|
||||||
|
> "):
|
||||||
|
case "1" | "25" | "&":
|
||||||
|
return 25
|
||||||
|
case "2" | "50" | "é":
|
||||||
|
return 50
|
||||||
|
case "3" | "75" | "\"":
|
||||||
|
return 75
|
||||||
|
case "4" | "100" | "\'":
|
||||||
|
return 100
|
||||||
|
case _:
|
||||||
|
print("\nMerci de rester dans les clous.\n")
|
||||||
|
return EnnemyHealth()
|
||||||
|
|
||||||
|
moi = Character(100, 3)
|
||||||
|
|
||||||
|
'Bloc ennemi'
|
||||||
|
|
||||||
|
ennemy_power = Difficulty()
|
||||||
|
ennemy_health = EnnemyHealth()
|
||||||
|
|
||||||
|
lui = Character(ennemy_health, ennemy_power)
|
||||||
|
|
||||||
|
'Combat 1'
|
||||||
|
|
||||||
|
Fight(moi, lui)
|
||||||
Reference in New Issue
Block a user