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 +4 -4
- data/lib/were_wolf/game.rb +19 -4
- data/lib/were_wolf/game_suggestor.rb +2 -1
- data/lib/were_wolf/player/little_girl.rb +2 -0
- data/lib/were_wolf/player/player_collection.rb +11 -0
- data/lib/were_wolf/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b43b3701ae243f345069083700d2387c0bb0a0a0
|
4
|
+
data.tar.gz: 8aedb4b7f11deabfa497b749d3b7aa8e4e7c11cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7b8e60f622d9f8e9f5a417fbf9432c36aa35693c712e31a407c28ab46b0783498ab0c13d946d780df31b14dfa602ff32dab6cf264fb8e52d22d79ac221be3fe7
|
7
|
+
data.tar.gz: 4e1e2f0e6d54909998bcc16b939a38db86f449e870e63a5928b6c3cf8e92e5b6e736701eff869fcd1328a762c81787a49684611917647945bcb4e3c153693710
|
data/lib/were_wolf/game.rb
CHANGED
@@ -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
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
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['
|
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)
|
@@ -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
|
data/lib/were_wolf/version.rb
CHANGED
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.
|
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
|