liars_dice 0.0.4 → 0.0.5
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.
- data/liars_dice.gemspec +2 -2
- data/lib/liars_dice/command_line_watcher.rb +30 -7
- data/lib/liars_dice/event.rb +5 -1
- metadata +2 -2
data/liars_dice.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |gem|
|
2
2
|
gem.name = 'liars_dice'
|
3
|
-
gem.version = '0.0.
|
4
|
-
gem.date = '2013-07-
|
3
|
+
gem.version = '0.0.5'
|
4
|
+
gem.date = '2013-07-10'
|
5
5
|
gem.summary = "Liar's Dice game"
|
6
6
|
gem.description = "A liar's dice botting environment, developed by Aisle50"
|
7
7
|
gem.authors = ['Ben Schmeckpeper', 'Chris Doyle', 'Max Page', 'Molly Struve']
|
@@ -2,14 +2,37 @@ module LiarsDice
|
|
2
2
|
class CommandLineWatcher
|
3
3
|
include Watcher
|
4
4
|
|
5
|
+
attr_reader :names
|
6
|
+
|
5
7
|
def initialize
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
8
|
+
self.names = {}
|
9
|
+
append_after_dice_rolled method(:print_dice)
|
10
|
+
append_after_bid lambda{|seat, bid| puts "#{name(seat, true)} bids #{bid}" }
|
11
|
+
append_after_bs lambda{|seat| puts "#{name(seat)} calls BS" }
|
12
|
+
append_after_game lambda{|winner| puts "Game over. #{name(winner)} wins." }
|
13
|
+
append_after_round lambda{|loser| puts "#{name(loser)} loses a die" }
|
14
|
+
append_after_invalid_bid lambda{|seat| puts "#{name(seat)} made an invalid bid" }
|
15
|
+
append_after_seats_assigned lambda{|assignments| self.names = assignments }
|
16
|
+
end
|
17
|
+
|
18
|
+
def name(seat_number, justified=false)
|
19
|
+
(names[seat_number] || "Seat #{seat_number}").ljust(justified ? justification : 0)
|
20
|
+
end
|
21
|
+
|
22
|
+
def justification
|
23
|
+
@justification ||= names.values.map(&:length).max
|
24
|
+
@justification
|
25
|
+
end
|
26
|
+
|
27
|
+
def names=(value)
|
28
|
+
@names = value
|
29
|
+
@names.each{|number, name| puts "Seat #{number}: #{name}" }
|
30
|
+
end
|
31
|
+
|
32
|
+
def print_dice(dice)
|
33
|
+
dice.each_with_index { |roll, seat| puts "#{name(seat, true)} Rolled: #{roll.inspect.to_s}" }
|
34
|
+
all_dice = dice.flatten
|
35
|
+
(1..6).to_a.each {|face_value| puts Bid.new(all_dice.select{|d| d == face_value}.count, face_value) }
|
13
36
|
end
|
14
37
|
end
|
15
38
|
end
|
data/lib/liars_dice/event.rb
CHANGED
@@ -69,7 +69,11 @@ module LiarsDice
|
|
69
69
|
|
70
70
|
def initialize(seats)
|
71
71
|
self.seat_assignments = {}
|
72
|
-
seats.each
|
72
|
+
seats.each do |seat|
|
73
|
+
name = seat.player.name if seat.player.respond_to? :name
|
74
|
+
name ||= seat.player.class.to_s
|
75
|
+
self.seat_assignments[seat.number] = name
|
76
|
+
end
|
73
77
|
end
|
74
78
|
end
|
75
79
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: liars_dice
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2013-07-
|
15
|
+
date: 2013-07-10 00:00:00.000000000Z
|
16
16
|
dependencies: []
|
17
17
|
description: A liar's dice botting environment, developed by Aisle50
|
18
18
|
email: dev@aisle50.com
|