tic_tac_toes 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/tic_tac_toes/ui/serializer.rb +4 -4
- data/lib/tic_tac_toes/version.rb +1 -1
- data/spec/tic_tac_toes/ui/serializer_spec.rb +2 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bcac1579f402fe618f217be136e16cde83e4a876
|
4
|
+
data.tar.gz: 96a65f0375261f44ffbde3dd0af7b30349fa074c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4072723e31a232796c4dce79c3c7244b74e770927954d663f22558861e18dde1d4bf3001ba28976391d7ef1687b77451076d57b691d50ec191883f9630fb71fe
|
7
|
+
data.tar.gz: d464b36eecd7854380e4e765757687c16b7284f8f94942f67d2764d3ebeea9be2efffbae97238a021c6ee6bc2c89c259bd50798fa9d73f766db14ef3ac42d6db
|
data/Gemfile.lock
CHANGED
@@ -14,7 +14,7 @@ module TicTacToes
|
|
14
14
|
board.spaces
|
15
15
|
end
|
16
16
|
|
17
|
-
def self.game_state(board_structure, computer_type, move_history)
|
17
|
+
def self.game_state(board_structure, computer_type, move_history, connection)
|
18
18
|
player_factory = Core::PlayerFactory.new('unused_io')
|
19
19
|
human_player = player_factory.generate_player(X, Core::PlayerFactory::HUMAN)
|
20
20
|
computer_player = player_factory.generate_player(O, Core::PlayerFactory.const_get(computer_type))
|
@@ -23,7 +23,7 @@ module TicTacToes
|
|
23
23
|
board_structure_with_players = replace_tokens_with_players(board_structure, human_player, computer_player)
|
24
24
|
board = board(board_structure_with_players)
|
25
25
|
|
26
|
-
history = history(move_history)
|
26
|
+
history = history(move_history, connection)
|
27
27
|
|
28
28
|
Core::GameState.new(board, players, history)
|
29
29
|
end
|
@@ -73,8 +73,8 @@ module TicTacToes
|
|
73
73
|
board
|
74
74
|
end
|
75
75
|
|
76
|
-
def self.history(move_history)
|
77
|
-
storage_wrapper = Database::PGWrapper.new(
|
76
|
+
def self.history(move_history, connection)
|
77
|
+
storage_wrapper = Database::PGWrapper.new(connection)
|
78
78
|
history = Core::History.new(storage_wrapper)
|
79
79
|
if move_history
|
80
80
|
moves = move_history.split(//).each_slice(2).to_a
|
data/lib/tic_tac_toes/version.rb
CHANGED
@@ -17,8 +17,9 @@ describe TicTacToes::UI::Serializer do
|
|
17
17
|
ai_type = 'EASY_AI'
|
18
18
|
move_history = 'X0O4'
|
19
19
|
ai = TicTacToes::Core::PlayerFactory::AIS.fetch(TicTacToes::Core::PlayerFactory::EASY_AI)
|
20
|
+
connection = double
|
20
21
|
|
21
|
-
game_state = TicTacToes::UI::Serializer.game_state(board_structure, ai_type, move_history)
|
22
|
+
game_state = TicTacToes::UI::Serializer.game_state(board_structure, ai_type, move_history, connection)
|
22
23
|
middle_space = game_state.board.space(4)
|
23
24
|
first_player = game_state.players.first
|
24
25
|
second_player = game_state.players.last
|