tttazures 0.0.9 → 0.0.10

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/config.rb +14 -65
  3. data/lib/human_player.rb +4 -9
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 460e19f29c18852dacd3caa80532ca13dfad0420
4
- data.tar.gz: f1219fe9ebdd295aebd4368b58d29a98346c9dbc
3
+ metadata.gz: 275bf25f5feb16fb1bedc8058079290cfed0d42f
4
+ data.tar.gz: 68821836bbb6dd1a85c8066d3fd2e52ea12e6374
5
5
  SHA512:
6
- metadata.gz: a5cbc1431951539ce91812d3e4464d02972b66421b67cc62c5114583c9c9b5e2e6ade8751fb5d7857e498944b46a5f2705f7b7acd214264ec200f717d35ae50f
7
- data.tar.gz: a80d5113273b3f26f936b14bdfc2ae1565738015a7c64624e12fde150ca23a4e25b9ee8bc4c7fddca9584bd0252e3b1ece363e34607fe2941db8a210fe374087
6
+ metadata.gz: 407733209f8104d0284fc8b84779978a5ff5eb36d4a4a9732394d430a850ddd146c1c6c4641e7a51ea24560c128c23378f8e0a512319a31605ebcc90e7783e50
7
+ data.tar.gz: f5949f23fc03faa97f08dfe17fcea28fe5a34a21d4aa8feb65016c0cf2ae7a6ab5ac8952f7f5c4b5a718f14aa1f4b392f1a241329dba091024809c2dc4d6e4da
data/lib/config.rb CHANGED
@@ -3,76 +3,25 @@ require_relative './human_player'
3
3
  require_relative './two_dimensional_board'
4
4
  require_relative './three_dimensional_board'
5
5
 
6
- class Configurer
7
-
8
- def initialize console
9
- @console = console
10
- end
11
-
12
- def get_board
13
- choice = get_board_choice
14
- case choice
15
- when 0 then TwoDimensionalBoard.new 3
16
- when 1 then TwoDimensionalBoard.new 4
17
- when 2 then TwoDimensionalBoard.new 5
18
- when 3 then ThreeDimensionalBoard.new 3
6
+ class Factory
7
+
8
+ def get_board board_type
9
+ case board_tupe
10
+ when :three_by_three then TwoDimensionalBoard.new 3
11
+ when :four_by_four then TwoDimensionalBoard.new 4
12
+ when :five_by_five then TwoDimensionalBoard.new 5
13
+ when :cube_three then ThreeDimensionalBoard.new 3
19
14
  end
20
15
  end
21
16
 
22
- def get_players
23
- user_input = @console.query_user_for_game_type
24
- players = {}
17
+ def get_player player_type, symbol
25
18
  case user_input
26
- when 0
27
- players[:player1] = HumanPlayer.new(:x, @console)
28
- players[:player2] = HumanPlayer.new(:o, @console)
29
- when 1
30
- players[:player1] = HumanPlayer.new(:x, @console)
31
- players[:player2] = set_ai_difficulty(:o)
32
- when 2
33
- players[:player1] = set_ai_difficulty(:o)
34
- players[:player2] = HumanPlayer.new(:x, @console)
35
- when 3
36
- players[:player1] = set_ai_difficulty(:x)
37
- players[:player2] = set_ai_difficulty(:o)
19
+ when :human then HumanPlayer.new(symbol)
20
+ when :easy_ai then ComputerAI.new(symbol, 10)
21
+ when :medium_ai then ComputerAI.new(symbol, 50)
22
+ when :unbeatable_ai then ComputerAI.new(symbol, 100)
38
23
  end
39
- players
40
- end
41
-
42
- def set_ai_difficulty symbol
43
- ai_difficulty_choice = get_ai_choice_from_user(symbol)
44
- case ai_difficulty_choice
45
- when 0 then ComputerAI.new(symbol, 10)
46
- when 1 then ComputerAI.new(symbol, 50)
47
- when 2 then ComputerAI.new(symbol, 100)
48
- end
49
- end
50
-
51
- def get_board_choice
52
- valid_choice = false
53
- while valid_choice == false
54
- choice = @console.query_user_for_board_type
55
- if choice >= 0 && choice < 4 then valid_choice = true
56
- else @console.print_user_input_error end
57
- end
58
- choice
59
24
  end
25
+ end
60
26
 
61
- def get_ai_choice_from_user symbol
62
- valid_choice = false
63
- while(!valid_choice)
64
- choice = @console.query_user_for_ai_difficulty(symbol)
65
- if choice < 3 && choice >= 0 then valid_choice = true end
66
- end
67
- choice
68
- end
69
27
 
70
- def get_board_printer board
71
- if board.get_type == :two_dimensional_board
72
- BoardPrinterTwoDim.new
73
- elsif board.get_type == :three_dimensional_board
74
- BoardPrinterThreeDim.new
75
- end
76
- end
77
-
78
- end
data/lib/human_player.rb CHANGED
@@ -1,17 +1,12 @@
1
1
  class HumanPlayer
2
2
 
3
- attr_reader :player
3
+ attr_reader :symbol
4
4
 
5
- def initialize player, console
6
- @console = console
7
- @player = player
5
+ def initialize player
6
+ @symbol = symbol
8
7
  end
9
8
 
10
9
  def make_move board
11
- valid_choice = false
12
- while !valid_choice
13
- choice = @console.query_user_for_choice(@player)
14
- valid_choice = board.record_choice(choice, @player)
15
- end
10
+ true
16
11
  end
17
12
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tttazures
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Zures