forked from RDavidNH/projet-mini-jeu-poo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp_2.rb
70 lines (51 loc) · 1.47 KB
/
app_2.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
require 'bundler'
Bundler.require
require_relative 'lib/game'
require_relative 'lib/player'
puts "-----------------------------------------------"
puts "Bienvenue sur 'ILS VEULENT TOUS MA POO' !"
puts "Le but du jeu est d'être le dernier survivant !"
puts "-----------------------------------------------"
puts "Entrez votre nom:"
print "> "
hplayer = HumanPlayer.new(gets.chomp)
#enemies = [Player.new("Josiane"), Player.new("José")]
player1 = Player.new("Josiane")
player2 = Player.new("José")
while hplayer.life_points > 0 && (player1.life_points > 0 || player2.life_points > 0)
puts "Voici l'état de chaque joueur : "
hplayer.show_state
player1.show_state
player2.show_state
puts "===================================="
puts "Quelle action veux-tu effectuer ?"
puts "----------------------------------"
puts "a - chercher une meilleure arme"
puts "s - chercher à se soigner "
puts "----------------------------------"
puts "attaquer un joueur en vue :"
print "0 - "
player1.show_state
print "1 - "
player2.show_state
action = gets.chomp
if action == "a"
hplayer.search_weapon
end
if action == "s"
hplayer.search_health_pack
end
if action == "0"
hplayer.attacks(player1)
elsif action == "1"
hplayer.attacks(player2)
end
puts "===================================="
#break
end
puts "La partie est finie"
if hplayer.life_points > 0
puts "BRAVO! TU AS GAGNE!"
else
puts "Loser! Tu as perdu!"
end