basketball 0.0.6 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +20 -7
- data/Gemfile +11 -0
- data/README.md +49 -41
- data/basketball.gemspec +2 -13
- data/exe/basketball-draft +1 -1
- data/exe/{basketball-schedule → basketball-season-scheduling} +1 -1
- data/lib/basketball/{drafting → draft}/cli.rb +34 -34
- data/lib/basketball/{drafting → draft}/event.rb +1 -1
- data/lib/basketball/{drafting → draft}/front_office.rb +1 -1
- data/lib/basketball/{drafting → draft}/league.rb +1 -1
- data/lib/basketball/{drafting → draft}/pick_event.rb +1 -1
- data/lib/basketball/{drafting → draft}/player.rb +1 -1
- data/lib/basketball/{drafting → draft}/player_search.rb +1 -1
- data/lib/basketball/{drafting → draft}/position.rb +1 -1
- data/lib/basketball/{drafting/engine.rb → draft/room.rb} +2 -2
- data/lib/basketball/draft/room_serializer.rb +186 -0
- data/lib/basketball/{drafting → draft}/roster.rb +1 -1
- data/lib/basketball/{drafting → draft}/sim_event.rb +1 -1
- data/lib/basketball/{drafting → draft}/skip_event.rb +1 -1
- data/lib/basketball/{drafting.rb → draft.rb} +2 -2
- data/lib/basketball/{scheduling → season}/calendar.rb +1 -1
- data/lib/basketball/{scheduling → season}/calendar_serializer.rb +31 -21
- data/lib/basketball/{scheduling → season}/conference.rb +1 -1
- data/lib/basketball/{scheduling → season}/coordinator.rb +2 -2
- data/lib/basketball/{scheduling → season}/division.rb +1 -1
- data/lib/basketball/{scheduling → season}/game.rb +1 -1
- data/lib/basketball/{scheduling → season}/league.rb +1 -1
- data/lib/basketball/{scheduling → season}/league_serializer.rb +26 -17
- data/lib/basketball/{scheduling → season}/preseason_game.rb +1 -1
- data/lib/basketball/{scheduling/cli.rb → season/scheduling_cli.rb} +9 -9
- data/lib/basketball/{scheduling → season}/season_game.rb +1 -1
- data/lib/basketball/{scheduling → season}/team.rb +1 -1
- data/lib/basketball/{scheduling.rb → season.rb} +2 -2
- data/lib/basketball/version.rb +1 -1
- data/lib/basketball.rb +2 -2
- metadata +32 -172
- data/lib/basketball/drafting/engine_serializer.rb +0 -174
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c6417577ab066cf68ac376551774f538e5ba1d018139e2d2e99af4a607acf10e
|
4
|
+
data.tar.gz: 2bf491b44bfb3591e411e105c33353f20044933662dc8f4a64999144f943bd3d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bbc69e448e39af4cb2a1df48d2e1fa729cc3eb85868b15eb8127aaac32ed57672c3c16cc1afa38cc147b2e9770e06bf89df9325a737ee1ea4f067afb253ced92
|
7
|
+
data.tar.gz: 1b0046ce516d37e5d1b86f818213b2e0dd1197be910338bc380a653aecb9158bdb85f5647452f2889ebba4fe2dc7b02b85ce2df4d32bae814d7ea10563bb1204
|
data/CHANGELOG.md
CHANGED
@@ -1,21 +1,34 @@
|
|
1
|
+
|
2
|
+
#### 0.0.8 - May 15th, 2023
|
3
|
+
|
4
|
+
* Renamed Drafting to Draft to match bounded context word form.
|
5
|
+
* Renamed Drafting::Engine to Draft::Room for better language.
|
6
|
+
* Renamed Scheduling to Season to include more things other than scheduling.
|
7
|
+
* Issued README warning for 0.0.X releases not having stable APIs.
|
8
|
+
|
9
|
+
#### 0.0.7 - May 14th, 2023
|
10
|
+
|
11
|
+
* Added #to_hash and #from_hash serializer methods to allow larger consumer json constructions more directly.
|
12
|
+
* Opt for string keys during serialization/deserialization.
|
13
|
+
|
1
14
|
#### 0.0.6 - May 11th, 2023
|
2
15
|
|
3
|
-
* Added
|
4
|
-
*
|
16
|
+
* Added Season module that can generate full schedules for entire league.
|
17
|
+
* Draft::Event does not have identity anymore (no current tangible benefit).
|
5
18
|
|
6
19
|
#### 0.0.5 - May 5th, 2023
|
7
20
|
|
8
21
|
* Remove the notion of Team in favor of a flat front office.
|
9
22
|
#### 0.0.4 - May 5th, 2023
|
10
23
|
|
11
|
-
* Add ability to skip draft picks using `Basketball::
|
12
|
-
* Add ability to output event full
|
24
|
+
* Add ability to skip draft picks using `Basketball::Draft::Room#skip!`
|
25
|
+
* Add ability to output event full draft event log using CLI: `basketball-draft -i tmp/draft-wip.json -l`
|
13
26
|
* Add ability to skip draft picks using CLI: `basketball-draft -i tmp/draft-wip.json -x 1`
|
14
27
|
|
15
28
|
#### 0.0.3 - May 5th, 2023
|
16
29
|
|
17
|
-
* `
|
18
|
-
* Added `
|
30
|
+
* `Draft::Room#sim!` should return events
|
31
|
+
* Added `Draft::Room#undrafted_player_search`
|
19
32
|
|
20
33
|
#### 0.0.2 - May 4th, 2023
|
21
34
|
|
@@ -23,4 +36,4 @@
|
|
23
36
|
|
24
37
|
#### 0.0.1 - May 4th, 2023
|
25
38
|
|
26
|
-
* Initial release with
|
39
|
+
* Initial release with Draft module only
|
data/Gemfile
CHANGED
@@ -3,3 +3,14 @@
|
|
3
3
|
source 'https://rubygems.org'
|
4
4
|
|
5
5
|
gemspec
|
6
|
+
|
7
|
+
gem 'bundler-audit', '~>0.9'
|
8
|
+
gem 'guard-rspec', '~>4.7'
|
9
|
+
gem 'pry', '~>0.14'
|
10
|
+
gem 'rake', '~>13.0'
|
11
|
+
gem 'rspec', '~>3.12'
|
12
|
+
gem 'rubocop', '~>1.49'
|
13
|
+
gem 'rubocop-rake', '~>0.6'
|
14
|
+
gem 'rubocop-rspec', '~>2.20'
|
15
|
+
gem 'simplecov', '~>0.22'
|
16
|
+
gem 'simplecov-console', '~>0.9'
|
data/README.md
CHANGED
@@ -2,7 +2,9 @@
|
|
2
2
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/basketball.svg)](https://badge.fury.io/rb/basketball) [![CI](https://github.com/mattruggio/basketball/actions/workflows/ci.yaml/badge.svg)](https://github.com/mattruggio/basketball/actions/workflows/ci.yaml) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
|
4
4
|
|
5
|
-
|
5
|
+
:warning: **Note:** This is currently in the early phases of initial development. Consider all 0.0.X releases as having unstable APIs between versions. A formal 0.1 minor release will be eventually releases which will honor [Semver](https://semver.org/).
|
6
|
+
|
7
|
+
#### Basketball League Game Room
|
6
8
|
|
7
9
|
This library is meant to serve as the domain for a basketball league/season simulator/turn-based game. It models core ideas such as: players, general managers, draft strategy, drafting, season generation, season simultation, playoff generation, playoff simulation, and more.
|
8
10
|
|
@@ -30,20 +32,24 @@ bundle binstubs basketball
|
|
30
32
|
|
31
33
|
This library is broken down into several bounded contexts that can be consumed either via its Ruby API's or CLI through provided executable scripts:
|
32
34
|
|
33
|
-
![Basketball Architecture - Overview](/docs/architecture/
|
35
|
+
![Basketball Architecture - Overview](/docs/architecture/Basketball%20Architecture%20-%20Overview.png)
|
36
|
+
|
37
|
+
#### Command Line Interfaces
|
34
38
|
|
35
|
-
|
39
|
+
Each module is meant to be interfaced with using its Ruby API by consuming applications. Each module also ships with a CLI script (backed by a module service) which a user can interact with to emulate different portions of the league management process. Technically speaking, the CLI provides an example application built on top of the each individual core module. Each module section below should contain with it example CLI calls.
|
36
40
|
|
37
|
-
|
41
|
+
## Draft Module
|
38
42
|
|
39
|
-
|
43
|
+
The draft module is responsible for providing a turn-based iterator allowing the consumer to either manually pick or simulate picks. Here is a cartoon showing the major components:
|
44
|
+
|
45
|
+
![Basketball Architecture - Draft](/docs/architecture/Basketball%20Architecture%20-%20Draft.png)
|
40
46
|
|
41
47
|
Element | Description
|
42
48
|
:------------ | :-----------
|
43
|
-
**
|
44
|
-
**
|
45
|
-
**Event** | Represents one cycle execution result from the
|
46
|
-
**External Ruby App** | An example consumer for the
|
49
|
+
**Draft** | Bounded context (sub-module) dealing with executing an asynchronous draft.
|
50
|
+
**Room** | Aggregate root responsible for providing an iterable interface capable of executing a draft, pick by pick.
|
51
|
+
**Event** | Represents one cycle execution result from the Room.
|
52
|
+
**External Ruby App** | An example consumer for the Draft context.
|
47
53
|
**Front Office** | Identifiable as a team, contains configuration for how to auto-pick draft selections.
|
48
54
|
**League** | Set of rosters that together form a cohesive league.
|
49
55
|
**Pick Event** | Result event emitted when a player is manually selected.
|
@@ -53,75 +59,75 @@ Element | Description
|
|
53
59
|
**Sim Event** | Result event emitted when a player is automatically selected by a front office.
|
54
60
|
**Skip Event** | Result event emitted when a front office decides to skip a round.
|
55
61
|
|
56
|
-
|
62
|
+
#### The Draft CLI
|
57
63
|
|
58
|
-
The
|
64
|
+
The draft module's main object: `Basketball::Draft::Room` is a stateful iterator. Each time a CLI command is executed, it's results will be re-saved to disk so the output file can then be used as the next command's input file to string together commands.
|
59
65
|
|
60
|
-
|
66
|
+
###### Generate a Fresh Draft
|
61
67
|
|
62
68
|
```zsh
|
63
69
|
basketball-draft -o tmp/draft.json
|
64
70
|
```
|
65
71
|
|
66
|
-
|
72
|
+
###### N Top Available Players
|
67
73
|
|
68
74
|
```zsh
|
69
75
|
basketball-draft -i tmp/draft.json -t 10
|
70
76
|
```
|
71
77
|
|
72
|
-
|
78
|
+
###### N Top Available Players for a Position
|
73
79
|
|
74
80
|
```zsh
|
75
81
|
basketball-draft -i tmp/draft.json -t 10 -q PG
|
76
82
|
```
|
77
83
|
|
78
|
-
|
84
|
+
###### Output Current Rosters
|
79
85
|
|
80
86
|
```zsh
|
81
87
|
basketball-draft -i tmp/draft.json -r
|
82
88
|
```
|
83
89
|
|
84
|
-
|
90
|
+
###### Output Event Log
|
85
91
|
|
86
92
|
```zsh
|
87
93
|
basketball-draft -i tmp/draft.json -l
|
88
94
|
```
|
89
95
|
|
90
|
-
|
96
|
+
###### Simulate N Picks
|
91
97
|
|
92
98
|
```zsh
|
93
99
|
basketball-draft -i tmp/draft.json -s 10
|
94
100
|
```
|
95
101
|
|
96
|
-
|
102
|
+
###### Skip N Picks
|
97
103
|
|
98
104
|
```zsh
|
99
105
|
basketball-draft -i tmp/draft.json -x 10
|
100
106
|
```
|
101
107
|
|
102
|
-
|
108
|
+
###### Pick Players
|
103
109
|
|
104
110
|
```zsh
|
105
111
|
basketball-draft -i tmp/draft.json -p P-100,P-200,P-300
|
106
112
|
```
|
107
113
|
|
108
|
-
|
114
|
+
###### Simulate the Rest of the Draft
|
109
115
|
|
110
116
|
```zsh
|
111
117
|
basketball-draft -i tmp/draft.json -a
|
112
118
|
```
|
113
119
|
|
114
|
-
|
120
|
+
###### Help Menu
|
115
121
|
|
116
122
|
```zsh
|
117
123
|
basketball-draft -h
|
118
124
|
```
|
119
125
|
|
120
|
-
##
|
126
|
+
## Season Module
|
121
127
|
|
122
|
-
The
|
128
|
+
The Season module is meant to take a League (conferences/divisions/teams) and turn it into a Calendar. This Calendar creation is atomic - the full calendar will be generated completely all in one call. Here is a cartoon showing the major components:
|
123
129
|
|
124
|
-
![Basketball Architecture -
|
130
|
+
![Basketball Architecture - Season](/docs/architecture/Basketball%20Architecture%20-%20Season.png)
|
125
131
|
|
126
132
|
Element | Description
|
127
133
|
:------------ | :-----------
|
@@ -135,55 +141,57 @@ Element | Description
|
|
135
141
|
**Home Team** | Team object designated as the home team for a Game.
|
136
142
|
**League Serializer** | Understands how to serialize and deserialize a League object.
|
137
143
|
**League** | Describes a league in terms of structure; composed of an array conferences (there can only be 2).
|
138
|
-
**
|
144
|
+
**Season** | Bounded context (sub-module) dealing with calendar and matchup generation.
|
139
145
|
**Team** | Identified by an ID and described by a name: represents a basketball team that can be scheduled.
|
140
146
|
|
141
|
-
|
147
|
+
#### The Season CLI
|
148
|
+
|
149
|
+
###### Generate League
|
142
150
|
|
143
151
|
```zsh
|
144
|
-
basketball-
|
152
|
+
basketball-season-scheduling -o tmp/league.json
|
145
153
|
```
|
146
154
|
|
147
|
-
|
155
|
+
###### Generate Calendar From League
|
148
156
|
|
149
157
|
```zsh
|
150
|
-
basketball-
|
158
|
+
basketball-season-scheduling -i tmp/league.json -o tmp/calendar.json
|
151
159
|
```
|
152
160
|
|
153
|
-
|
161
|
+
###### Generate Calendar From League For a Specific Year
|
154
162
|
|
155
163
|
```zsh
|
156
|
-
basketball-
|
164
|
+
basketball-season-scheduling -i tmp/league.json -o tmp/calendar.json -y 2005
|
157
165
|
```
|
158
166
|
|
159
|
-
|
167
|
+
###### Output a Generated Calendar's Matchups
|
160
168
|
|
161
169
|
```zsh
|
162
|
-
basketball-
|
170
|
+
basketball-season-scheduling -c tmp/calendar.json
|
163
171
|
```
|
164
172
|
|
165
|
-
|
173
|
+
###### Output a Generated Calendar's Matchups For a Specific Team
|
166
174
|
|
167
175
|
```zsh
|
168
|
-
basketball-
|
176
|
+
basketball-season-scheduling -c tmp/calendar.json -t C0-D0-T0
|
169
177
|
```
|
170
178
|
|
171
|
-
|
179
|
+
###### Output a Generated Calendar's Matchups For a Specific Date
|
172
180
|
|
173
181
|
```zsh
|
174
|
-
basketball-
|
182
|
+
basketball-season-scheduling -c tmp/calendar.json -d 2005-02-03
|
175
183
|
```
|
176
184
|
|
177
|
-
|
185
|
+
###### Output a Generated Calendar's Matchups For a Specific Team and Date
|
178
186
|
|
179
187
|
```zsh
|
180
|
-
basketball-
|
188
|
+
basketball-season-scheduling -c tmp/calendar.json -d 2005-02-03 -t C0-D0-T0
|
181
189
|
```
|
182
190
|
|
183
|
-
|
191
|
+
###### Help Menu
|
184
192
|
|
185
193
|
```zsh
|
186
|
-
basketball-
|
194
|
+
basketball-season-scheduling -h
|
187
195
|
```
|
188
196
|
|
189
197
|
## Contributing
|
data/basketball.gemspec
CHANGED
@@ -5,7 +5,7 @@ require './lib/basketball/version'
|
|
5
5
|
Gem::Specification.new do |s|
|
6
6
|
s.name = 'basketball'
|
7
7
|
s.version = Basketball::VERSION
|
8
|
-
s.summary = 'Basketball League Game
|
8
|
+
s.summary = 'Basketball League Game Room'
|
9
9
|
|
10
10
|
s.description = <<-DESC
|
11
11
|
This library is meant to serve as the domain for a basketball league/season simulator/turn-based game.
|
@@ -17,7 +17,7 @@ Gem::Specification.new do |s|
|
|
17
17
|
s.email = ['mattruggio@icloud.com']
|
18
18
|
s.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(.github|bin|docs|spec)/}) }
|
19
19
|
s.bindir = 'exe'
|
20
|
-
s.executables = %w[basketball-draft basketball-
|
20
|
+
s.executables = %w[basketball-draft basketball-season-scheduling]
|
21
21
|
s.homepage = 'https://github.com/mattruggio/basketball'
|
22
22
|
s.license = 'MIT'
|
23
23
|
s.metadata = {
|
@@ -33,15 +33,4 @@ Gem::Specification.new do |s|
|
|
33
33
|
|
34
34
|
s.add_dependency('faker', '~>3.2')
|
35
35
|
s.add_dependency('slop', '~>4.10')
|
36
|
-
|
37
|
-
s.add_development_dependency('bundler-audit', '~>0.9')
|
38
|
-
s.add_development_dependency('guard-rspec', '~>4.7')
|
39
|
-
s.add_development_dependency('pry', '~>0.14')
|
40
|
-
s.add_development_dependency('rake', '~>13.0')
|
41
|
-
s.add_development_dependency('rspec', '~>3.12')
|
42
|
-
s.add_development_dependency('rubocop', '~>1.49')
|
43
|
-
s.add_development_dependency('rubocop-rake', '~>0.6')
|
44
|
-
s.add_development_dependency('rubocop-rspec', '~>2.20')
|
45
|
-
s.add_development_dependency('simplecov', '~>0.22')
|
46
|
-
s.add_development_dependency('simplecov-console', '~>0.9')
|
47
36
|
end
|
data/exe/basketball-draft
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative '
|
4
|
-
require_relative '
|
3
|
+
require_relative 'room'
|
4
|
+
require_relative 'room_serializer'
|
5
5
|
require_relative 'player_search'
|
6
6
|
require_relative 'position'
|
7
7
|
|
8
8
|
module Basketball
|
9
|
-
module
|
9
|
+
module Draft
|
10
10
|
# Examples:
|
11
11
|
# exe/basketball-draft -o tmp/draft.json
|
12
12
|
# exe/basketball-draft -i tmp/draft.json -o tmp/draft-wip.json -s 26 -p P-5,P-10 -t 10 -q PG
|
@@ -23,7 +23,7 @@ module Basketball
|
|
23
23
|
|
24
24
|
def initialize(args:, io: $stdout)
|
25
25
|
@io = io
|
26
|
-
@serializer =
|
26
|
+
@serializer = RoomSerializer.new
|
27
27
|
@opts = slop_parse(args)
|
28
28
|
|
29
29
|
if opts[:input].to_s.empty? && opts[:output].to_s.empty?
|
@@ -36,31 +36,31 @@ module Basketball
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def invoke!
|
39
|
-
|
39
|
+
room = load_room
|
40
40
|
|
41
|
-
execute(
|
41
|
+
execute(room)
|
42
42
|
|
43
43
|
io.puts
|
44
44
|
io.puts('Status')
|
45
45
|
|
46
|
-
if
|
46
|
+
if room.done?
|
47
47
|
io.puts('Draft is complete!')
|
48
48
|
else
|
49
|
-
current_round =
|
50
|
-
current_round_pick =
|
51
|
-
current_front_office =
|
49
|
+
current_round = room.current_round
|
50
|
+
current_round_pick = room.current_round_pick
|
51
|
+
current_front_office = room.current_front_office
|
52
52
|
|
53
|
-
io.puts("#{
|
53
|
+
io.puts("#{room.remaining_picks} Remaining pick(s)")
|
54
54
|
io.puts("Up Next: Round #{current_round} pick #{current_round_pick} for #{current_front_office}")
|
55
55
|
end
|
56
56
|
|
57
|
-
write(
|
57
|
+
write(room)
|
58
58
|
|
59
|
-
log(
|
59
|
+
log(room)
|
60
60
|
|
61
|
-
league(
|
61
|
+
league(room)
|
62
62
|
|
63
|
-
query(
|
63
|
+
query(room)
|
64
64
|
|
65
65
|
self
|
66
66
|
end
|
@@ -72,8 +72,8 @@ module Basketball
|
|
72
72
|
o.banner = 'Usage: basketball-draft [options] ...'
|
73
73
|
|
74
74
|
o.string '-i', '--input',
|
75
|
-
'Path to load the
|
76
|
-
o.string '-o', '--output', 'Path to write the
|
75
|
+
'Path to load the room from. If omitted then a new draft will be generated.'
|
76
|
+
o.string '-o', '--output', 'Path to write the room to (if omitted then input path will be used)'
|
77
77
|
o.integer '-s', '--simulate', 'Number of picks to simulate (default is 0).', default: 0
|
78
78
|
o.bool '-a', '--simulate-all', 'Simulate the rest of the draft', default: false
|
79
79
|
o.array '-p', '--picks', 'Comma-separated list of ordered player IDs to pick.', delimiter: ','
|
@@ -90,7 +90,7 @@ module Basketball
|
|
90
90
|
end.to_h
|
91
91
|
end
|
92
92
|
|
93
|
-
def
|
93
|
+
def load_room
|
94
94
|
if opts[:input].to_s.empty?
|
95
95
|
io.puts('Input path was not provided, generating fresh front_offices and players')
|
96
96
|
|
@@ -119,32 +119,32 @@ module Basketball
|
|
119
119
|
)
|
120
120
|
end
|
121
121
|
|
122
|
-
|
122
|
+
Room.new(players:, front_offices:)
|
123
123
|
end
|
124
124
|
|
125
|
-
def league(
|
125
|
+
def league(room)
|
126
126
|
return unless opts[:rosters]
|
127
127
|
|
128
128
|
io.puts
|
129
|
-
io.puts(
|
129
|
+
io.puts(room.to_league)
|
130
130
|
end
|
131
131
|
|
132
|
-
def log(
|
132
|
+
def log(room)
|
133
133
|
return unless opts[:log]
|
134
134
|
|
135
135
|
io.puts
|
136
136
|
io.puts('Event Log')
|
137
137
|
|
138
|
-
puts
|
138
|
+
puts room.events
|
139
139
|
end
|
140
140
|
|
141
141
|
# rubocop:disable Metrics/AbcSize
|
142
|
-
def query(
|
142
|
+
def query(room)
|
143
143
|
top = opts[:top]
|
144
144
|
|
145
145
|
return if top <= 0
|
146
146
|
|
147
|
-
search = PlayerSearch.new(
|
147
|
+
search = PlayerSearch.new(room.undrafted_players)
|
148
148
|
position = opts[:query].to_s.empty? ? nil : Position.new(opts[:query])
|
149
149
|
players = search.query(position:).take(opts[:top])
|
150
150
|
|
@@ -167,20 +167,20 @@ module Basketball
|
|
167
167
|
end
|
168
168
|
|
169
169
|
# rubocop:disable Metrics/AbcSize
|
170
|
-
def execute(
|
170
|
+
def execute(room)
|
171
171
|
event_count = 0
|
172
172
|
|
173
173
|
io.puts
|
174
174
|
io.puts('New Events')
|
175
175
|
|
176
176
|
(opts[:picks] || []).each do |id|
|
177
|
-
break if
|
177
|
+
break if room.done?
|
178
178
|
|
179
|
-
player =
|
179
|
+
player = room.players.find { |p| p.id == id.to_s.upcase }
|
180
180
|
|
181
181
|
raise PlayerNotFound, "player not found by id: #{id}" unless player
|
182
182
|
|
183
|
-
event =
|
183
|
+
event = room.pick!(player)
|
184
184
|
|
185
185
|
io.puts(event)
|
186
186
|
|
@@ -188,21 +188,21 @@ module Basketball
|
|
188
188
|
end
|
189
189
|
|
190
190
|
opts[:skip].times do
|
191
|
-
event =
|
191
|
+
event = room.skip!
|
192
192
|
|
193
193
|
io.puts(event)
|
194
194
|
|
195
195
|
event_count += 1
|
196
196
|
end
|
197
197
|
|
198
|
-
|
198
|
+
room.sim!(opts[:simulate]) do |event|
|
199
199
|
io.puts(event)
|
200
200
|
|
201
201
|
event_count += 1
|
202
202
|
end
|
203
203
|
|
204
204
|
if opts[:simulate_all]
|
205
|
-
|
205
|
+
room.sim! do |event|
|
206
206
|
io.puts(event)
|
207
207
|
|
208
208
|
event_count += 1
|
@@ -215,10 +215,10 @@ module Basketball
|
|
215
215
|
end
|
216
216
|
# rubocop:enable Metrics/AbcSize
|
217
217
|
|
218
|
-
def write(
|
218
|
+
def write(room)
|
219
219
|
output = opts[:output].to_s.empty? ? opts[:input] : opts[:output]
|
220
220
|
|
221
|
-
contents = serializer.serialize(
|
221
|
+
contents = serializer.serialize(room)
|
222
222
|
out_dir = File.dirname(output)
|
223
223
|
|
224
224
|
FileUtils.mkdir_p(out_dir)
|