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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b43b3701ae243f345069083700d2387c0bb0a0a0
4
- data.tar.gz: 8aedb4b7f11deabfa497b749d3b7aa8e4e7c11cf
3
+ metadata.gz: 462912b620902731bd1c5da583b550168bd14758
4
+ data.tar.gz: a7e607a0babd354dba97e7467113640a0ad26e3d
5
5
  SHA512:
6
- metadata.gz: 7b8e60f622d9f8e9f5a417fbf9432c36aa35693c712e31a407c28ab46b0783498ab0c13d946d780df31b14dfa602ff32dab6cf264fb8e52d22d79ac221be3fe7
7
- data.tar.gz: 4e1e2f0e6d54909998bcc16b939a38db86f449e870e63a5928b6c3cf8e92e5b6e736701eff869fcd1328a762c81787a49684611917647945bcb4e3c153693710
6
+ metadata.gz: d44d9cf638d6e99787b2a6abdf32ce0dc2b0fbefc9fe560f3ae65446ebb3ce9704b2dd3e427fb2974f6dcc15eaa0b5c3e79ce41378e4e0f60eb2be32d3c0c52f
7
+ data.tar.gz: 0afbf5a4f4734317934d9e98a01bdfc6aaf209a695a39ef5a9626c627780f91b658b0512a80326969939ad4ade24f9182bb5d976862098292f00faacf6f30485
@@ -37,7 +37,10 @@ private
37
37
  saved_people = []
38
38
  # Doctor chooses to save a person
39
39
  doctor = @players.doctor
40
- saved_people.push(doctor.choose_a_player_to_save(@players)) if doctor
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
- # Don't kill the person if the doctor saved the person
65
- @players.kill(victim) unless saved_people.include?(victim)
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
@@ -1,3 +1,3 @@
1
1
  module WereWolf
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: were_wolf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - BV Satyaram