software_challenge_client 20.2.0 → 21.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 +1 -0
- data/.ruby-version +1 -1
- data/.vscode/launch.json +41 -0
- data/.vscode/settings.json +10 -0
- data/Dockerfile +1 -1
- data/Gemfile +1 -0
- data/Guardfile +1 -0
- data/README.md +4 -3
- data/RELEASES.md +16 -0
- data/Rakefile +4 -4
- data/example/client.rb +6 -9
- data/example/main.rb +9 -9
- data/lib/software_challenge_client.rb +26 -23
- data/lib/software_challenge_client/board.rb +99 -34
- data/lib/software_challenge_client/client_interface.rb +1 -0
- data/lib/software_challenge_client/color.rb +23 -0
- data/lib/software_challenge_client/condition.rb +4 -1
- data/lib/software_challenge_client/coordinate_set.rb +92 -0
- data/lib/software_challenge_client/coordinates.rb +45 -0
- data/lib/software_challenge_client/debug_hint.rb +1 -0
- data/lib/software_challenge_client/field.rb +21 -53
- data/lib/software_challenge_client/game_rule_logic.rb +255 -328
- data/lib/software_challenge_client/game_state.rb +87 -69
- data/lib/software_challenge_client/has_hints.rb +1 -1
- data/lib/software_challenge_client/invalid_move_exception.rb +1 -0
- data/lib/software_challenge_client/logging.rb +1 -0
- data/lib/software_challenge_client/network.rb +1 -1
- data/lib/software_challenge_client/piece.rb +43 -14
- data/lib/software_challenge_client/piece_shape.rb +83 -0
- data/lib/software_challenge_client/player.rb +7 -6
- data/lib/software_challenge_client/player_type.rb +14 -0
- data/lib/software_challenge_client/protocol.rb +82 -76
- data/lib/software_challenge_client/rotation.rb +22 -0
- data/lib/software_challenge_client/runner.rb +2 -1
- data/lib/software_challenge_client/set_move.rb +13 -4
- data/lib/software_challenge_client/skip_move.rb +5 -0
- data/lib/software_challenge_client/util/constants.rb +3 -4
- data/lib/software_challenge_client/version.rb +2 -1
- data/lib/update_client_module.sh +15 -0
- data/software_challenge_client.gemspec +14 -12
- metadata +52 -35
- data/lib/software_challenge_client/cube_coordinates.rb +0 -23
- data/lib/software_challenge_client/direction.rb +0 -55
- data/lib/software_challenge_client/drag_move.rb +0 -19
- data/lib/software_challenge_client/line_direction.rb +0 -15
- data/lib/software_challenge_client/piece_type.rb +0 -18
- data/lib/software_challenge_client/player_color.rb +0 -25
@@ -1,23 +0,0 @@
|
|
1
|
-
class CubeCoordinates
|
2
|
-
|
3
|
-
attr_reader :x, :y, :z
|
4
|
-
|
5
|
-
def initialize(x, y, z = nil)
|
6
|
-
@x = x
|
7
|
-
@y = y
|
8
|
-
@z = z.nil? ? -x - y : z
|
9
|
-
throw InvalidArgumentException("sum of coordinates #{@x}, #{@y}, #{@z} have to be equal 0") if @x + @y + @z != 0
|
10
|
-
end
|
11
|
-
|
12
|
-
def ==(other)
|
13
|
-
x == other.x && y == other.y && z == other.z
|
14
|
-
end
|
15
|
-
|
16
|
-
def to_s
|
17
|
-
"(#{x}, #{y}, #{z})"
|
18
|
-
end
|
19
|
-
|
20
|
-
def inspect
|
21
|
-
to_s
|
22
|
-
end
|
23
|
-
end
|
@@ -1,55 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'typesafe_enum'
|
4
|
-
|
5
|
-
# Die sechs möglichen Bewegungsrichtungen auf dem Spielbrett. Die Richtungen sind:
|
6
|
-
#
|
7
|
-
# - UP_RIGHT
|
8
|
-
# - RIGHT
|
9
|
-
# - DOWN_RIGHT
|
10
|
-
# - DOWN_LEFT
|
11
|
-
# - LEFT
|
12
|
-
# - UP_LEFT
|
13
|
-
#
|
14
|
-
# Zugriff erfolgt z.B. durch Direction::UP_RIGHT.
|
15
|
-
class Direction < TypesafeEnum::Base
|
16
|
-
new :UP_RIGHT
|
17
|
-
new :RIGHT
|
18
|
-
new :DOWN_RIGHT
|
19
|
-
new :DOWN_LEFT
|
20
|
-
new :LEFT
|
21
|
-
new :UP_LEFT
|
22
|
-
|
23
|
-
# Verschiebt den durch das Koordinatenpaar angegebenen Punkt in die
|
24
|
-
# entsprechende Richtung. Der resultierende Punkt kann ausserhalb des
|
25
|
-
# Spielbrettes liegen. Dies kann mit {GameRuleLogic#inside_bounds?} geprüft
|
26
|
-
# werden.
|
27
|
-
# @param coordinates [CubeCoordinates] Das zu verschiebende Koordinatenpaar.
|
28
|
-
# @param distance [Integer] Um wieviele Felder in die Richtung verschoben werden soll.
|
29
|
-
def translate(start, distance = 1)
|
30
|
-
shiftX = start.x
|
31
|
-
shiftY = start.y
|
32
|
-
shiftZ = start.z
|
33
|
-
case self.key
|
34
|
-
when :RIGHT
|
35
|
-
shiftX = start.x + distance
|
36
|
-
shiftY = start.y - distance
|
37
|
-
when :LEFT
|
38
|
-
shiftX = start.x - distance
|
39
|
-
shiftY = start.y + distance
|
40
|
-
when :UP_RIGHT
|
41
|
-
shiftX = start.x + distance
|
42
|
-
shiftZ = start.z - distance
|
43
|
-
when :UP_LEFT
|
44
|
-
shiftY = start.y + distance
|
45
|
-
shiftZ = start.z - distance
|
46
|
-
when :DOWN_RIGHT
|
47
|
-
shiftY = start.y - distance
|
48
|
-
shiftZ = start.z + distance
|
49
|
-
when :DOWN_LEFT
|
50
|
-
shiftX = start.x - distance
|
51
|
-
shiftZ = start.z + distance
|
52
|
-
end
|
53
|
-
return CubeCoordinates.new(shiftX, shiftY, shiftZ)
|
54
|
-
end
|
55
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
require_relative 'has_hints'
|
2
|
-
|
3
|
-
class DragMove
|
4
|
-
|
5
|
-
include HasHints
|
6
|
-
|
7
|
-
attr_reader :start
|
8
|
-
attr_reader :destination
|
9
|
-
|
10
|
-
def initialize(start, destination)
|
11
|
-
@start = start
|
12
|
-
@destination = destination
|
13
|
-
@hints = []
|
14
|
-
end
|
15
|
-
|
16
|
-
def to_s
|
17
|
-
"[Move: Drag from #{start} to #{destination}]"
|
18
|
-
end
|
19
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'typesafe_enum'
|
4
|
-
# Ausrichtung einer Linie auf dem Spielbrett. Mögliche Werte sind:
|
5
|
-
# - HORIZONTAL
|
6
|
-
# - VERTICAL
|
7
|
-
# - RISING_DIAGONAL
|
8
|
-
# - FALLING_DIAGONAL
|
9
|
-
|
10
|
-
class LineDirection < TypesafeEnum::Base
|
11
|
-
new :HORIZONTAL
|
12
|
-
new :VERTICAL
|
13
|
-
new :RISING_DIAGONAL
|
14
|
-
new :FALLING_DIAGONAL
|
15
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'typesafe_enum'
|
4
|
-
# Der Typ eines Spielsteins. Es gibt folgende Typen:
|
5
|
-
# - BEE
|
6
|
-
# - BEETLE
|
7
|
-
# - GRASSHOPPER
|
8
|
-
# - SPIDER
|
9
|
-
# - ANT
|
10
|
-
#
|
11
|
-
# Zugriff z.B. mit PieceType::BEE
|
12
|
-
class PieceType < TypesafeEnum::Base
|
13
|
-
new :BEE, 'Q'
|
14
|
-
new :BEETLE, 'B'
|
15
|
-
new :GRASSHOPPER, 'G'
|
16
|
-
new :SPIDER, 'S'
|
17
|
-
new :ANT, 'A'
|
18
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
# player color constants
|
3
|
-
require 'typesafe_enum'
|
4
|
-
|
5
|
-
# Die Spielerfarben. RED oder BLUE
|
6
|
-
class PlayerColor < TypesafeEnum::Base
|
7
|
-
new :RED, 'R'
|
8
|
-
new :BLUE, 'B'
|
9
|
-
|
10
|
-
# @param color [PlayerColor]
|
11
|
-
# @return [PlayerColor] Farbe des Gegenspielers
|
12
|
-
def self.opponent_color(color)
|
13
|
-
case color
|
14
|
-
when PlayerColor::RED
|
15
|
-
PlayerColor::BLUE
|
16
|
-
when PlayerColor::BLUE
|
17
|
-
PlayerColor::RED
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def opponent
|
22
|
-
PlayerColor.opponent_color(self)
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|