First commit
This commit is contained in:
115
user_v1.py
Normal file
115
user_v1.py
Normal file
@@ -0,0 +1,115 @@
|
||||
# Import de librairie
|
||||
from random import randrange
|
||||
|
||||
print "Bienvenue au jeu GOOOOOOOOOOOOOOOBLIIIINS ! Le jeu inspire de Goblin Slayer."
|
||||
print
|
||||
|
||||
class character(object):
|
||||
def __init__(self, name, health, damage, armor, weapon, shield, damage_weight):
|
||||
self.name = name
|
||||
self.health = health
|
||||
self.damage = damage
|
||||
self.armor = armor
|
||||
self.weapon = weapon
|
||||
self.shield = shield
|
||||
self.damage_weight = damage_weight
|
||||
|
||||
# Fiche de joueur
|
||||
player = character(raw_input("Quel est ton nom ? "), 100, randrange(5, 19), 5, True, True, 1)
|
||||
print
|
||||
# Trois ennemis de force croissante
|
||||
goblin = character("Guerrier gobelin", 20, randrange(2, 7), 0, False, False, 1)
|
||||
hobgoblin = character("HobGobelin", 40, randrange(4, 9), 2, True, False, 2)
|
||||
goblin_lord = character("Seigneur Gobelin", 100, randrange(7, 15), 5, True, True, 3)
|
||||
|
||||
goblin_number = raw_input("Combien de gobelins voulez-vous affronter ? ")
|
||||
goblin_number = int(goblin_number)
|
||||
hobgoblin_number = raw_input("Combien de hobgobelins voulez-vous affronter ? ")
|
||||
hobgoblin_number = int(hobgoblin_number)
|
||||
goblin_lord_number = raw_input("Combien de seigneurs gobelins voulez-vous affronter ? ")
|
||||
goblin_lord_number = int(goblin_lord_number)
|
||||
|
||||
print
|
||||
print "Vous, %s, allez affronter %s %s, %s %s et %s %s. Faites attentions a vous. Apres chaque combat, vous aurez droit au repos." % (player.name, goblin_number, goblin.name, hobgoblin_number, hobgoblin.name, goblin_lord_number, goblin_lord.name)
|
||||
print
|
||||
|
||||
# Fonction de combat
|
||||
def fight(main, ennemy):
|
||||
turn = 1
|
||||
while main.health > 0 and ennemy.health > 0:
|
||||
print "===== Tour " + str(turn) + " ====="
|
||||
print
|
||||
print "Votre ennemi a %s points de vie. Vous en avez %s." % (ennemy.health, main.health)
|
||||
print
|
||||
main.damage = randrange(5, 15)
|
||||
ennemy.damage = randrange(2, 7) * ennemy.damage_weight
|
||||
if main.damage > ennemy.armor:
|
||||
damage = (main.damage - ennemy.armor)
|
||||
# DEBUG print main.damage, ennemy.armor
|
||||
print "Vous faites %s degats." % (damage)
|
||||
print
|
||||
ennemy.health -= damage
|
||||
if ennemy.damage > main.armor:
|
||||
damage = (ennemy.damage - main.armor)
|
||||
# DEBUG print ennemy.damage, main.armor
|
||||
print "Il vous inflige %s degats." % (damage)
|
||||
print
|
||||
main.health -= damage
|
||||
if main.damage <= ennemy.armor:
|
||||
print "Vous frappez, mais pas assez fort."
|
||||
print
|
||||
if ennemy.damage <= main.armor:
|
||||
print "Il vous frappe, mais pas assez fort."
|
||||
print
|
||||
turn += 1
|
||||
else:
|
||||
if main.health <= 0:
|
||||
print "Vous avez succombe."
|
||||
exit()
|
||||
elif ennemy.health <= 0:
|
||||
print "Votre ennemi est mort."
|
||||
print
|
||||
print "=================="
|
||||
|
||||
raw_input("Quand vous etes pret a demarrer, appuyez sur Entree : ")
|
||||
|
||||
# Combats avec les gobelins
|
||||
goblin_turn = 1
|
||||
|
||||
while goblin_turn != goblin_number:
|
||||
print
|
||||
print "Un %s vous attaque ! Il en reste %s." % (goblin.name, (goblin_number + 1) - goblin_turn)
|
||||
print
|
||||
fight(player, goblin)
|
||||
goblin.health = 20
|
||||
goblin_turn += 1
|
||||
|
||||
player.health = 100
|
||||
raw_input("Prenez du repos, et appuyez sur une touche pour continuer : ")
|
||||
|
||||
# Combats avec les hobgobelins
|
||||
hobgoblin_turn = 1
|
||||
|
||||
while hobgoblin_turn <= hobgoblin_number:
|
||||
print
|
||||
print "Un %s vous attaque ! Il en reste %s." % (hobgoblin.name, (hobgoblin_number + 1) - hobgoblin_turn)
|
||||
print
|
||||
fight(player, hobgoblin)
|
||||
hobgoblin.health = 40
|
||||
hobgoblin_turn += 1
|
||||
|
||||
player.health = 100
|
||||
raw_input("Prenez du repos, et appuyez sur une touche pour continuer : ")
|
||||
|
||||
# Combats avec les seigneurs gobelins
|
||||
goblin_lord_turn = 1
|
||||
|
||||
while goblin_lord_turn <= goblin_lord_number:
|
||||
print
|
||||
print "Un %s vous attaque ! Il en reste %s." % (goblin_lord.name, (goblin_lord_number + 1) - goblin_lord_turn)
|
||||
print
|
||||
fight(player, goblin_lord)
|
||||
goblin_lord.health = 100
|
||||
goblin_lord_turn += 1
|
||||
|
||||
raw_input("Bravo, vous avez vaincu. ")
|
||||
Reference in New Issue
Block a user