software_challenge_client 0.3.4 → 1.0.0
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 +4 -4
- data/.rubocop.yml +3 -1
- data/.ruby-version +1 -0
- data/Guardfile +5 -5
- data/RELEASES.md +6 -0
- data/example/client.rb +71 -33
- data/lib/software_challenge_client.rb +1 -1
- data/lib/software_challenge_client/action.rb +116 -196
- data/lib/software_challenge_client/board.rb +17 -73
- data/lib/software_challenge_client/card_type.rb +13 -0
- data/lib/software_challenge_client/field.rb +10 -44
- data/lib/software_challenge_client/field_type.rb +20 -26
- data/lib/software_challenge_client/game_rules.rb +378 -0
- data/lib/software_challenge_client/game_state.rb +167 -49
- data/lib/software_challenge_client/move.rb +23 -13
- data/lib/software_challenge_client/player.rb +35 -34
- data/lib/software_challenge_client/player_color.rb +1 -1
- data/lib/software_challenge_client/protocol.rb +82 -39
- data/lib/software_challenge_client/version.rb +1 -1
- metadata +6 -5
- data/lib/software_challenge_client/direction.rb +0 -39
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: software_challenge_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- 'kwollw '
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2017-
|
13
|
+
date: 2017-08-24 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: typesafe_enum
|
@@ -234,6 +234,7 @@ files:
|
|
234
234
|
- ".gitignore"
|
235
235
|
- ".rspec"
|
236
236
|
- ".rubocop.yml"
|
237
|
+
- ".ruby-version"
|
237
238
|
- AUTHORS
|
238
239
|
- CODE_OF_CONDUCT.md
|
239
240
|
- Gemfile
|
@@ -250,13 +251,14 @@ files:
|
|
250
251
|
- lib/software_challenge_client.rb
|
251
252
|
- lib/software_challenge_client/action.rb
|
252
253
|
- lib/software_challenge_client/board.rb
|
254
|
+
- lib/software_challenge_client/card_type.rb
|
253
255
|
- lib/software_challenge_client/client_interface.rb
|
254
256
|
- lib/software_challenge_client/condition.rb
|
255
257
|
- lib/software_challenge_client/debug_hint.rb
|
256
|
-
- lib/software_challenge_client/direction.rb
|
257
258
|
- lib/software_challenge_client/field.rb
|
258
259
|
- lib/software_challenge_client/field_type.rb
|
259
260
|
- lib/software_challenge_client/field_unavailable_exception.rb
|
261
|
+
- lib/software_challenge_client/game_rules.rb
|
260
262
|
- lib/software_challenge_client/game_state.rb
|
261
263
|
- lib/software_challenge_client/invalid_move_exception.rb
|
262
264
|
- lib/software_challenge_client/logging.rb
|
@@ -289,10 +291,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
289
291
|
version: '0'
|
290
292
|
requirements: []
|
291
293
|
rubyforge_project:
|
292
|
-
rubygems_version: 2.6.
|
294
|
+
rubygems_version: 2.6.11
|
293
295
|
signing_key:
|
294
296
|
specification_version: 4
|
295
297
|
summary: This gem provides functions to build a client for the coding competition
|
296
298
|
Software-Challenge 2017.
|
297
299
|
test_files: []
|
298
|
-
has_rdoc:
|
@@ -1,39 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
require 'typesafe_enum'
|
4
|
-
# A direction on the hexagonal board of the game. Possible directions are:
|
5
|
-
# * RIGHT
|
6
|
-
# * UP_RIGHT
|
7
|
-
# * UP_LEFT
|
8
|
-
# * LEFT
|
9
|
-
# * DOWN_LEFT
|
10
|
-
# * DOWN_RIGHT
|
11
|
-
# Access them as Direction::RIGHT for example.
|
12
|
-
class Direction < TypesafeEnum::Base
|
13
|
-
new :RIGHT
|
14
|
-
new :UP_RIGHT
|
15
|
-
new :UP_LEFT
|
16
|
-
new :LEFT
|
17
|
-
new :DOWN_LEFT
|
18
|
-
new :DOWN_RIGHT
|
19
|
-
|
20
|
-
# @param direction [Direction] starting direction
|
21
|
-
# @param turns [Integer] number of turns (positive means turning
|
22
|
-
# counterclockwise).
|
23
|
-
# @return [Direction] The direction when turning the given number of steps
|
24
|
-
# from the given direction.
|
25
|
-
def self.get_turn_direction(direction, turns)
|
26
|
-
# order of directions is equal to counterclockwise turning
|
27
|
-
Direction.find_by_ord((direction.ord + turns) % 6)
|
28
|
-
end
|
29
|
-
|
30
|
-
# @return [Turn] The Turn action to get from from_direction to to_direction.
|
31
|
-
def self.from_to(from_direction, to_direction)
|
32
|
-
distance = (to_direction.ord - from_direction.ord + 6) % 6
|
33
|
-
if distance > 3
|
34
|
-
distance = distance - 6
|
35
|
-
end
|
36
|
-
Turn.new(distance)
|
37
|
-
end
|
38
|
-
|
39
|
-
end
|