were_wolf 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/were_wolf/game.rb +15 -3
- data/lib/were_wolf/player/doctor.rb +19 -0
- data/lib/were_wolf/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 462912b620902731bd1c5da583b550168bd14758
|
4
|
+
data.tar.gz: a7e607a0babd354dba97e7467113640a0ad26e3d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d44d9cf638d6e99787b2a6abdf32ce0dc2b0fbefc9fe560f3ae65446ebb3ce9704b2dd3e427fb2974f6dcc15eaa0b5c3e79ce41378e4e0f60eb2be32d3c0c52f
|
7
|
+
data.tar.gz: 0afbf5a4f4734317934d9e98a01bdfc6aaf209a695a39ef5a9626c627780f91b658b0512a80326969939ad4ade24f9182bb5d976862098292f00faacf6f30485
|
data/lib/were_wolf/game.rb
CHANGED
@@ -37,7 +37,10 @@ private
|
|
37
37
|
saved_people = []
|
38
38
|
# Doctor chooses to save a person
|
39
39
|
doctor = @players.doctor
|
40
|
-
|
40
|
+
if doctor
|
41
|
+
person_saved_by_doctor = doctor.choose_a_player_to_save(@players)
|
42
|
+
saved_people.push(person_saved_by_doctor)
|
43
|
+
end
|
41
44
|
# Witch chooses to save a person once in the entire game
|
42
45
|
witch = @players.witch
|
43
46
|
person_saved_by_witch = witch.choose_a_player_to_save(@players) if witch
|
@@ -61,8 +64,17 @@ private
|
|
61
64
|
end
|
62
65
|
|
63
66
|
victims.uniq.each do |victim|
|
64
|
-
|
65
|
-
|
67
|
+
if saved_people.include?(victim)
|
68
|
+
# Don't kill the person if the doctor saved the person
|
69
|
+
if victim == person_saved_by_doctor
|
70
|
+
doctor.remember_innocent(victim)
|
71
|
+
end
|
72
|
+
if victim == person_saved_by_witch
|
73
|
+
witch.remember_innocent(victim)
|
74
|
+
end
|
75
|
+
else
|
76
|
+
@players.kill(victim)
|
77
|
+
end
|
66
78
|
end
|
67
79
|
end
|
68
80
|
|
@@ -1,4 +1,9 @@
|
|
1
1
|
class Doctor < Villager
|
2
|
+
def initialize
|
3
|
+
super
|
4
|
+
forget_all!
|
5
|
+
end
|
6
|
+
|
2
7
|
def choose_a_player_to_save(players)
|
3
8
|
# Save myself when ther eare only 2 players,a s the other player
|
4
9
|
# should be a wolf
|
@@ -10,4 +15,18 @@ class Doctor < Villager
|
|
10
15
|
return players.alive_players.sample
|
11
16
|
end
|
12
17
|
end
|
18
|
+
|
19
|
+
def remember_innocent(player)
|
20
|
+
@known_innocents.push(player)
|
21
|
+
end
|
22
|
+
|
23
|
+
def accuse(players)
|
24
|
+
forget_all! if players.alive_players.count == @known_innocents.count + 1
|
25
|
+
|
26
|
+
return (players.alive_players - [self] - @known_innocents).sample
|
27
|
+
end
|
28
|
+
|
29
|
+
def forget_all!
|
30
|
+
@known_innocents = []
|
31
|
+
end
|
13
32
|
end
|
data/lib/were_wolf/version.rb
CHANGED