were_wolf 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a63c18b5139dcf4282bbc79aa18bd08df03b654d
4
- data.tar.gz: 6ff720629a4862574e3e68f92d151e5f26e2b2f8
3
+ metadata.gz: b43b3701ae243f345069083700d2387c0bb0a0a0
4
+ data.tar.gz: 8aedb4b7f11deabfa497b749d3b7aa8e4e7c11cf
5
5
  SHA512:
6
- metadata.gz: ea4e4bc2cc2102a967d9445f8db83aa330f8023b983bb6ce845c896b44352710f40265139b0ed09da282ebc5f375372a1af096a67252adc709c94ac7a347f5f2
7
- data.tar.gz: 6b9370e4d9f1c1d7ac869639ed7cb4bf26f274e6e6f3db0d2618f53c221e2c6db6b4a0a7eca634376fbc8318df1b030c9f3ab4f189ed49889874aba48533de47
6
+ metadata.gz: 7b8e60f622d9f8e9f5a417fbf9432c36aa35693c712e31a407c28ab46b0783498ab0c13d946d780df31b14dfa602ff32dab6cf264fb8e52d22d79ac221be3fe7
7
+ data.tar.gz: 4e1e2f0e6d54909998bcc16b939a38db86f449e870e63a5928b6c3cf8e92e5b6e736701eff869fcd1328a762c81787a49684611917647945bcb4e3c153693710
@@ -31,6 +31,9 @@ private
31
31
  # Cop identifies a person
32
32
  cop = @players.cop
33
33
  cop.identify_a_player(@players) if cop
34
+ little_girl = @players.little_girl
35
+ little_girl.identify_a_player(@players) if little_girl
36
+
34
37
  saved_people = []
35
38
  # Doctor chooses to save a person
36
39
  doctor = @players.doctor
@@ -39,16 +42,28 @@ private
39
42
  witch = @players.witch
40
43
  person_saved_by_witch = witch.choose_a_player_to_save(@players) if witch
41
44
  saved_people.push(person_saved_by_witch) if witch && person_saved_by_witch
45
+
46
+ victims = []
42
47
  # Wolves kill a villager
43
48
  wolves_victim = villagers_alive.sample
49
+ victims.push(wolves_victim)
50
+ if wolves_victim == little_girl
51
+ second_victim = (villagers_alive - [little_girl]).sample
52
+ victims.push(second_victim)
53
+ end
44
54
  # Rogue kills a players once in the entire game
45
55
  rogue = @players.rogue
46
56
  rogues_victim = rogue.choose_victim(@players) if rogue
57
+ victims.push(rogues_victim)
58
+ if rogues_victim == little_girl
59
+ second_victim = (villagers_alive - [little_girl]).sample
60
+ victims.push(second_victim)
61
+ end
47
62
 
48
- # Don't kill the person if the doctor saved the person
49
- @players.kill(wolves_victim) unless saved_people.include?(wolves_victim)
50
- # Don't kill the person again, if the wolves have already killed the person
51
- @players.kill(rogues_victim) unless (saved_people.include?(rogues_victim)) || (rogues_victim == wolves_victim)
63
+ 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)
66
+ end
52
67
  end
53
68
 
54
69
  def day_mode
@@ -35,7 +35,8 @@ private
35
35
  players['doctors'] = 1 if @players_count - wolves_count > 1
36
36
  players['rogues'] = 1 if @players_count - wolves_count > 2
37
37
  players['witches'] = 1 if @players_count - wolves_count > 3
38
- players['villagers'] = (@players_count - wolves_count - 4) if @players_count - wolves_count > 4
38
+ players['little_girls'] = 1 if @players_count - wolves_count > 4
39
+ players['villagers'] = (@players_count - wolves_count - 5) if @players_count - wolves_count > 5
39
40
 
40
41
  probabilities = {}
41
42
  probabilities['wolves_win'] = (100.0*(best_wins[Game::WOLF] || 0)/@no_of_runs)
@@ -0,0 +1,2 @@
1
+ class LittleGirl < Cop
2
+ end
@@ -4,6 +4,7 @@ require_relative 'cop'
4
4
  require_relative 'doctor'
5
5
  require_relative 'rogue'
6
6
  require_relative 'witch'
7
+ require_relative 'little_girl'
7
8
 
8
9
  class PlayerCollection
9
10
  def initialize(no_of_wolves, no_of_villagers)
@@ -29,6 +30,9 @@ class PlayerCollection
29
30
  elsif i == 4
30
31
  villager = Witch.new
31
32
  @witch = villager
33
+ elsif i == 5
34
+ villager = LittleGirl.new
35
+ @little_girl = villager
32
36
  else
33
37
  villager = Villager.new
34
38
  end
@@ -58,11 +62,13 @@ class PlayerCollection
58
62
  @doctor = nil if player.is_a?(Doctor)
59
63
  @rogue = nil if player.is_a?(Rogue)
60
64
  @witch = nil if player.is_a?(Witch)
65
+ @little_girl = nil if player.is_a?(LittleGirl)
61
66
  collection = @villagers
62
67
  end
63
68
  collection.delete(player)
64
69
  @players.delete(player)
65
70
  @cop.forget(player) if @cop
71
+ @little_girl.forget(player) if @little_girl
66
72
  end
67
73
 
68
74
  def cop
@@ -81,6 +87,10 @@ class PlayerCollection
81
87
  @witch
82
88
  end
83
89
 
90
+ def little_girl
91
+ @little_girl
92
+ end
93
+
84
94
  private
85
95
  def promote_rogue_to_wolf
86
96
  return if @wolves.count > 0
@@ -93,5 +103,6 @@ private
93
103
  end
94
104
 
95
105
  @cop.forget_all!
106
+ @little_girl.forget_all!
96
107
  end
97
108
  end
@@ -1,3 +1,3 @@
1
1
  module WereWolf
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
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.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - BV Satyaram
@@ -58,6 +58,7 @@ files:
58
58
  - lib/were_wolf/game_suggestor.rb
59
59
  - lib/were_wolf/player/cop.rb
60
60
  - lib/were_wolf/player/doctor.rb
61
+ - lib/were_wolf/player/little_girl.rb
61
62
  - lib/were_wolf/player/player.rb
62
63
  - lib/were_wolf/player/player_collection.rb
63
64
  - lib/were_wolf/player/rogue.rb