spy_alley_application 0.3.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 +7 -0
- data/.gitignore +13 -0
- data/.rspec +3 -0
- data/.travis.yml +7 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +92 -0
- data/LICENSE.txt +21 -0
- data/README.md +39 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/spy_alley_application.rb +6 -0
- data/lib/spy_alley_application/actions/buy_equipment.rb +31 -0
- data/lib/spy_alley_application/actions/choose_new_spy_identity.rb +26 -0
- data/lib/spy_alley_application/actions/choose_space_to_move.rb +21 -0
- data/lib/spy_alley_application/actions/confiscate_materials.rb +58 -0
- data/lib/spy_alley_application/actions/generate_new_game.rb +70 -0
- data/lib/spy_alley_application/actions/make_accusation.rb +40 -0
- data/lib/spy_alley_application/actions/pass.rb +21 -0
- data/lib/spy_alley_application/actions/roll_die.rb +25 -0
- data/lib/spy_alley_application/actions/use_move_card.rb +28 -0
- data/lib/spy_alley_application/execute_action.rb +20 -0
- data/lib/spy_alley_application/injection_container.rb +596 -0
- data/lib/spy_alley_application/models/acquisition_method/by_confiscation.rb +22 -0
- data/lib/spy_alley_application/models/acquisition_method/by_free_gift.rb +20 -0
- data/lib/spy_alley_application/models/acquisition_method/by_passing_start.rb +20 -0
- data/lib/spy_alley_application/models/acquisition_method/by_purchase.rb +21 -0
- data/lib/spy_alley_application/models/acquisition_method/by_selling_top_secret_information.rb +21 -0
- data/lib/spy_alley_application/models/board_spaces/black_market.rb +24 -0
- data/lib/spy_alley_application/models/board_spaces/border_crossing.rb +24 -0
- data/lib/spy_alley_application/models/board_spaces/buy_equipment.rb +26 -0
- data/lib/spy_alley_application/models/board_spaces/buy_password.rb +26 -0
- data/lib/spy_alley_application/models/board_spaces/confiscate_materials.rb +24 -0
- data/lib/spy_alley_application/models/board_spaces/draw_free_gift.rb +24 -0
- data/lib/spy_alley_application/models/board_spaces/draw_move_card.rb +24 -0
- data/lib/spy_alley_application/models/board_spaces/embassy.rb +26 -0
- data/lib/spy_alley_application/models/board_spaces/move_back.rb +25 -0
- data/lib/spy_alley_application/models/board_spaces/sold_top_secret_information.rb +27 -0
- data/lib/spy_alley_application/models/board_spaces/spy_alley_entrance.rb +38 -0
- data/lib/spy_alley_application/models/board_spaces/spy_eliminator.rb +24 -0
- data/lib/spy_alley_application/models/board_spaces/start.rb +36 -0
- data/lib/spy_alley_application/models/board_spaces/take_another_turn.rb +24 -0
- data/lib/spy_alley_application/models/equipment.rb +42 -0
- data/lib/spy_alley_application/models/game_board.rb +23 -0
- data/lib/spy_alley_application/models/game_board/black_market_option_state.rb +59 -0
- data/lib/spy_alley_application/models/game_board/buy_equipment_option_state.rb +52 -0
- data/lib/spy_alley_application/models/game_board/buy_password_option_state.rb +39 -0
- data/lib/spy_alley_application/models/game_board/confiscate_materials_option_state.rb +68 -0
- data/lib/spy_alley_application/models/game_board/eliminate_player.rb +91 -0
- data/lib/spy_alley_application/models/game_board/embassy_victory.rb +23 -0
- data/lib/spy_alley_application/models/game_board/equipment_bought.rb +42 -0
- data/lib/spy_alley_application/models/game_board/equipment_confiscated.rb +67 -0
- data/lib/spy_alley_application/models/game_board/free_gift_drawn.rb +39 -0
- data/lib/spy_alley_application/models/game_board/money_gained_or_lost.rb +22 -0
- data/lib/spy_alley_application/models/game_board/move_card_drawn.rb +31 -0
- data/lib/spy_alley_application/models/game_board/move_card_used.rb +30 -0
- data/lib/spy_alley_application/models/game_board/move_options.rb +23 -0
- data/lib/spy_alley_application/models/game_board/new_spy_identity_chosen.rb +37 -0
- data/lib/spy_alley_application/models/game_board/next_game_state.rb +70 -0
- data/lib/spy_alley_application/models/game_board/player_moved.rb +24 -0
- data/lib/spy_alley_application/models/game_board/spy_eliminator_options.rb +41 -0
- data/lib/spy_alley_application/models/game_state/buy_equipment.rb +26 -0
- data/lib/spy_alley_application/models/game_state/choose_new_spy_identity.rb +29 -0
- data/lib/spy_alley_application/models/game_state/confiscate_materials.rb +29 -0
- data/lib/spy_alley_application/models/game_state/game_over.rb +27 -0
- data/lib/spy_alley_application/models/game_state/move_option.rb +25 -0
- data/lib/spy_alley_application/models/game_state/spy_eliminator.rb +25 -0
- data/lib/spy_alley_application/models/game_state/start_of_turn.rb +23 -0
- data/lib/spy_alley_application/models/game_state/victory_reason/by_elimination.rb +22 -0
- data/lib/spy_alley_application/models/game_state/victory_reason/by_embassy.rb +22 -0
- data/lib/spy_alley_application/models/move_card.rb +26 -0
- data/lib/spy_alley_application/models/player.rb +37 -0
- data/lib/spy_alley_application/models/sell_top_secret_information.rb +24 -0
- data/lib/spy_alley_application/models/validator/buying_equipment.rb +35 -0
- data/lib/spy_alley_application/models/validator/choosing_new_spy_identity.rb +33 -0
- data/lib/spy_alley_application/models/validator/confiscating_materials.rb +50 -0
- data/lib/spy_alley_application/models/validator/making_accusation.rb +31 -0
- data/lib/spy_alley_application/models/validator/moving.rb +30 -0
- data/lib/spy_alley_application/models/validator/passing.rb +24 -0
- data/lib/spy_alley_application/models/validator/rolling_die.rb +29 -0
- data/lib/spy_alley_application/models/validator/using_move_card.rb +31 -0
- data/lib/spy_alley_application/models/wild_card.rb +25 -0
- data/lib/spy_alley_application/new_game.rb +18 -0
- data/lib/spy_alley_application/new_game/assign_seats.rb +21 -0
- data/lib/spy_alley_application/new_game/assign_spy_identities.rb +24 -0
- data/lib/spy_alley_application/results/nodes/buy_equipment_option_node.rb +23 -0
- data/lib/spy_alley_application/results/nodes/choose_new_spy_identity_option_node.rb +23 -0
- data/lib/spy_alley_application/results/nodes/confiscate_materials_option_node.rb +22 -0
- data/lib/spy_alley_application/results/nodes/die_rolled_node.rb +21 -0
- data/lib/spy_alley_application/results/nodes/eliminated_player_node.rb +22 -0
- data/lib/spy_alley_application/results/nodes/equipment_gained_node.rb +28 -0
- data/lib/spy_alley_application/results/nodes/game_over_node.rb +24 -0
- data/lib/spy_alley_application/results/nodes/make_accusation_option_node.rb +20 -0
- data/lib/spy_alley_application/results/nodes/money_gained_node.rb +25 -0
- data/lib/spy_alley_application/results/nodes/money_lost_node.rb +21 -0
- data/lib/spy_alley_application/results/nodes/move_back_node.rb +21 -0
- data/lib/spy_alley_application/results/nodes/move_card_drawn_node.rb +22 -0
- data/lib/spy_alley_application/results/nodes/move_card_used_node.rb +22 -0
- data/lib/spy_alley_application/results/nodes/move_option_node.rb +20 -0
- data/lib/spy_alley_application/results/nodes/new_spy_identity_chosen_node.rb +21 -0
- data/lib/spy_alley_application/results/nodes/next_player_node.rb +20 -0
- data/lib/spy_alley_application/results/nodes/pass_option_node.rb +16 -0
- data/lib/spy_alley_application/results/nodes/player_movement_node.rb +21 -0
- data/lib/spy_alley_application/results/nodes/player_passed_node.rb +19 -0
- data/lib/spy_alley_application/results/nodes/reached_embassy_with_all_equipment_node.rb +20 -0
- data/lib/spy_alley_application/results/nodes/result_game_board_node.rb +21 -0
- data/lib/spy_alley_application/results/nodes/roll_die_option_node.rb +16 -0
- data/lib/spy_alley_application/results/nodes/use_move_card_option_node.rb +20 -0
- data/lib/spy_alley_application/results/nodes/wild_card_gained_node.rb +27 -0
- data/lib/spy_alley_application/results/process_buy_equipment_options.rb +25 -0
- data/lib/spy_alley_application/results/process_eliminating_player.rb +36 -0
- data/lib/spy_alley_application/results/process_landing_on_space.rb +232 -0
- data/lib/spy_alley_application/results/process_move_options.rb +65 -0
- data/lib/spy_alley_application/results/process_next_turn_options.rb +87 -0
- data/lib/spy_alley_application/results/process_passing_spaces.rb +68 -0
- data/lib/spy_alley_application/results/process_proceeding_to_next_state.rb +23 -0
- data/lib/spy_alley_application/types/array_of_equipment.rb +7 -0
- data/lib/spy_alley_application/types/array_of_free_gifts.rb +7 -0
- data/lib/spy_alley_application/types/array_of_move_cards.rb +6 -0
- data/lib/spy_alley_application/types/array_of_players.rb +6 -0
- data/lib/spy_alley_application/types/board_space.rb +4 -0
- data/lib/spy_alley_application/types/coercible_integer_one_to_six.rb +9 -0
- data/lib/spy_alley_application/types/equipment.rb +32 -0
- data/lib/spy_alley_application/types/equipment_type.rb +9 -0
- data/lib/spy_alley_application/types/free_gift.rb +22 -0
- data/lib/spy_alley_application/types/game_board.rb +52 -0
- data/lib/spy_alley_application/types/game_state.rb +19 -0
- data/lib/spy_alley_application/types/move_card.rb +21 -0
- data/lib/spy_alley_application/types/nationality.rb +5 -0
- data/lib/spy_alley_application/types/player.rb +123 -0
- data/lib/spy_alley_application/types/validation_builder.rb +21 -0
- data/lib/spy_alley_application/types/validator/non_admin.rb +21 -0
- data/lib/spy_alley_application/types/wild_card.rb +14 -0
- data/lib/spy_alley_application/validator/builder.rb +119 -0
- data/lib/spy_alley_application/validator/buy_equipment.rb +39 -0
- data/lib/spy_alley_application/validator/choose_new_spy_identity.rb +24 -0
- data/lib/spy_alley_application/validator/confiscate_materials.rb +22 -0
- data/lib/spy_alley_application/validator/confiscate_materials/full_validator.rb +39 -0
- data/lib/spy_alley_application/validator/confiscate_materials/validate_target_player_id.rb +24 -0
- data/lib/spy_alley_application/validator/make_accusation.rb +24 -0
- data/lib/spy_alley_application/validator/move.rb +24 -0
- data/lib/spy_alley_application/validator/new_game.rb +35 -0
- data/lib/spy_alley_application/validator/new_game_builder.rb +32 -0
- data/lib/spy_alley_application/validator/no_options.rb +7 -0
- data/lib/spy_alley_application/validator/use_move_card.rb +23 -0
- data/lib/spy_alley_application/version.rb +3 -0
- data/spy_alley_application.gemspec +40 -0
- metadata +343 -0
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen string literal: true
|
2
|
+
|
3
|
+
require 'dry-struct'
|
4
|
+
|
5
|
+
module SpyAlleyApplication
|
6
|
+
module Models
|
7
|
+
module AcquisitionMethod
|
8
|
+
class ByConfiscation < Dry::Struct
|
9
|
+
@@can_handle_by_confiscation = ::Types.Interface(:handle_by_confiscation)
|
10
|
+
attribute :name, ::Types.Value('by_confiscation')
|
11
|
+
attribute :target_player_id, ::Types::Coercible::Integer
|
12
|
+
attribute :amount_paid, ::Types::CoercibleNonnegativeInteger
|
13
|
+
|
14
|
+
def accept(visitor, **args)
|
15
|
+
@can_handle_by_confiscation.(visitor)
|
16
|
+
visitor.handle_by_confiscation(self, args)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen string literal: true
|
2
|
+
|
3
|
+
require 'dry-struct'
|
4
|
+
|
5
|
+
module SpyAlleyApplication
|
6
|
+
module Models
|
7
|
+
module AcquisitionMethod
|
8
|
+
class ByFreeGift < Dry::Struct
|
9
|
+
@@can_handle_by_free_gift = ::Types.Interface(:handle_by_free_gift)
|
10
|
+
attribute :name, ::Types.Value('by_free_gift')
|
11
|
+
|
12
|
+
def accept(visitor, **args)
|
13
|
+
@can_handle_by_free_gift.(visitor)
|
14
|
+
visitor.handle_by_free_gift(self, args)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen string literal: true
|
2
|
+
|
3
|
+
require 'dry-struct'
|
4
|
+
|
5
|
+
module SpyAlleyApplication
|
6
|
+
module Models
|
7
|
+
module AcquisitionMethod
|
8
|
+
class ByPassingStart < Dry::Struct
|
9
|
+
@@can_handle_by_passing_start = ::Types.Interface(:handle_by_passing_start)
|
10
|
+
attribute :name, ::Types.Value('by_passing_start')
|
11
|
+
|
12
|
+
def accept(visitor, **args)
|
13
|
+
@can_handle_by_passing_start.(visitor)
|
14
|
+
visitor.handle_by_passing_start(self, args)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen string literal: true
|
2
|
+
|
3
|
+
require 'dry-struct'
|
4
|
+
|
5
|
+
module SpyAlleyApplication
|
6
|
+
module Models
|
7
|
+
module AcquisitionMethod
|
8
|
+
class ByPurchase < Dry::Struct
|
9
|
+
@@can_handle_by_purchase = ::Types.Interface(:handle_by_purchase)
|
10
|
+
attribute :name, ::Types.Value('by_purchase')
|
11
|
+
attribute :amount_paid, ::Types::CoercibleNonnegativeInteger
|
12
|
+
|
13
|
+
def accept(visitor, **args)
|
14
|
+
@can_handle_by_purchase.(visitor)
|
15
|
+
visitor.handle_by_purchase(self, args)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen string literal: true
|
2
|
+
|
3
|
+
require 'dry-struct'
|
4
|
+
|
5
|
+
module SpyAlleyApplication
|
6
|
+
module Models
|
7
|
+
module AcquisitionMethod
|
8
|
+
class BySellingTopSecretInformation < Dry::Struct
|
9
|
+
@@can_handle_by_selling_top_secret_information =
|
10
|
+
::Types.Interface(:handle_by_selling_top_secret_information)
|
11
|
+
attribute :name, ::Types.Value('by_selling_top_secret_information')
|
12
|
+
|
13
|
+
def accept(visitor, **args)
|
14
|
+
@can_handle_by_selling_top_secret_information.(visitor)
|
15
|
+
visitor.handle_by_selling_top_secret_information(self, args)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen string_literal: true
|
2
|
+
|
3
|
+
require 'dry-struct'
|
4
|
+
require 'spy_alley_application/types/board_space'
|
5
|
+
|
6
|
+
module SpyAlleyApplication
|
7
|
+
module Models
|
8
|
+
module BoardSpaces
|
9
|
+
class BlackMarket < Dry::Struct
|
10
|
+
@@can_handle_black_market = ::Types.Interface(:handle_black_market)
|
11
|
+
attribute :id, ::Types::Coercible::Integer
|
12
|
+
attribute :next_space, ::SpyAlleyApplication::Types::BoardSpace
|
13
|
+
|
14
|
+
def accept(visitor, **args)
|
15
|
+
@@can_handle_black_market.(visitor)
|
16
|
+
visitor.handle_black_market(self, args)
|
17
|
+
end
|
18
|
+
|
19
|
+
def in_spy_alley?;false;end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen string_literal: true
|
2
|
+
|
3
|
+
require 'dry-struct'
|
4
|
+
require 'spy_alley_application/types/board_space'
|
5
|
+
|
6
|
+
module SpyAlleyApplication
|
7
|
+
module Models
|
8
|
+
module BoardSpaces
|
9
|
+
class BorderCrossing < Dry::Struct
|
10
|
+
@@can_handle_border_crossing = ::Types.Interface(:handle_draw_move_card)
|
11
|
+
attribute :id, ::Types::Coercible::Integer
|
12
|
+
attribute :next_space, ::SpyAlleyApplication::Types::BoardSpace
|
13
|
+
|
14
|
+
def accept(visitor, **args)
|
15
|
+
@@can_handle_border_crossing.(visitor)
|
16
|
+
visitor.handle_border_crossing(self, args)
|
17
|
+
end
|
18
|
+
|
19
|
+
def in_spy_alley?;false;end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen string_literal: true
|
2
|
+
|
3
|
+
require 'dry-struct'
|
4
|
+
require 'spy_alley_application/types/board_space'
|
5
|
+
require 'spy_alley_application/types/equipment_type'
|
6
|
+
|
7
|
+
module SpyAlleyApplication
|
8
|
+
module Models
|
9
|
+
module BoardSpaces
|
10
|
+
class BuyEquipment < Dry::Struct
|
11
|
+
@@can_handle_buy_equipment = ::Types.Interface(:handle_buy_equipment)
|
12
|
+
attribute :id, ::Types::Coercible::Integer
|
13
|
+
attribute :next_space, SpyAlleyApplication::Types::BoardSpace
|
14
|
+
attribute :equipment_type, SpyAlleyApplication::Types::EquipmentType
|
15
|
+
|
16
|
+
def accept(visitor, **args)
|
17
|
+
@@can_handle_buy_equipment.(visitor)
|
18
|
+
visitor.handle_buy_equipment(self, args)
|
19
|
+
end
|
20
|
+
|
21
|
+
def in_spy_alley?;false;end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen string_literal: true
|
2
|
+
|
3
|
+
require 'dry-struct'
|
4
|
+
require 'spy_alley_application/types/board_space'
|
5
|
+
require 'spy_alley_application/types/nationality'
|
6
|
+
|
7
|
+
module SpyAlleyApplication
|
8
|
+
module Models
|
9
|
+
module BoardSpaces
|
10
|
+
class BuyPassword < Dry::Struct
|
11
|
+
@@can_handle_buy_password = ::Types.Interface(:handle_buy_password)
|
12
|
+
attribute :id, ::Types::Coercible::Integer
|
13
|
+
attribute :next_space, SpyAlleyApplication::Types::BoardSpace
|
14
|
+
attribute :nationality, SpyAlleyApplication::Types::Nationality
|
15
|
+
|
16
|
+
def accept(visitor, **args)
|
17
|
+
@@can_handle_buy_password.(visitor)
|
18
|
+
visitor.handle_buy_password(self, args)
|
19
|
+
end
|
20
|
+
|
21
|
+
def in_spy_alley?;false;end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen string_literal: true
|
2
|
+
|
3
|
+
require 'dry-struct'
|
4
|
+
require 'spy_alley_application/types/board_space'
|
5
|
+
|
6
|
+
module SpyAlleyApplication
|
7
|
+
module Models
|
8
|
+
module BoardSpaces
|
9
|
+
class ConfiscateMaterials < Dry::Struct
|
10
|
+
@@can_handle_confiscate_materials = ::Types.Interface(:handle_confiscate_materials)
|
11
|
+
attribute :id, ::Types::Coercible::Integer
|
12
|
+
attribute :next_space, ::SpyAlleyApplication::Types::BoardSpace
|
13
|
+
|
14
|
+
def accept(visitor, **args)
|
15
|
+
@@can_handle_confiscate_materials.(visitor)
|
16
|
+
visitor.handle_confiscate_materials(self, args)
|
17
|
+
end
|
18
|
+
|
19
|
+
def in_spy_alley?;true;end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen string_literal: true
|
2
|
+
|
3
|
+
require 'dry-struct'
|
4
|
+
require 'spy_alley_application/types/board_space'
|
5
|
+
|
6
|
+
module SpyAlleyApplication
|
7
|
+
module Models
|
8
|
+
module BoardSpaces
|
9
|
+
class DrawFreeGift < Dry::Struct
|
10
|
+
@@can_handle_draw_free_gift = ::Types.Interface(:handle_draw_free_gift)
|
11
|
+
attribute :id, ::Types::Coercible::Integer
|
12
|
+
attribute :next_space, ::SpyAlleyApplication::Types::BoardSpace
|
13
|
+
|
14
|
+
def accept(visitor, **args)
|
15
|
+
@@can_handle_draw_free_gift.(visitor)
|
16
|
+
visitor.handle_draw_free_gift(self, args)
|
17
|
+
end
|
18
|
+
|
19
|
+
def in_spy_alley?;false;end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen string_literal: true
|
2
|
+
|
3
|
+
require 'dry-struct'
|
4
|
+
require 'spy_alley_application/types/board_space'
|
5
|
+
|
6
|
+
module SpyAlleyApplication
|
7
|
+
module Models
|
8
|
+
module BoardSpaces
|
9
|
+
class DrawMoveCard < Dry::Struct
|
10
|
+
@@can_handle_draw_move_card = ::Types.Interface(:handle_draw_move_card)
|
11
|
+
attribute :id, ::Types::Coercible::Integer
|
12
|
+
attribute :next_space, SpyAlleyApplication::Types::BoardSpace
|
13
|
+
|
14
|
+
def accept(visitor, **args)
|
15
|
+
@@can_handle_draw_move_card.(visitor)
|
16
|
+
visitor.handle_draw_move_card(self, args)
|
17
|
+
end
|
18
|
+
|
19
|
+
def in_spy_alley?;false;end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen string_literal: true
|
2
|
+
|
3
|
+
require 'dry-struct'
|
4
|
+
require 'spy_alley_application/types/board_space'
|
5
|
+
require 'spy_alley_application/types/nationality'
|
6
|
+
|
7
|
+
module SpyAlleyApplication
|
8
|
+
module Models
|
9
|
+
module BoardSpaces
|
10
|
+
class Embassy < Dry::Struct
|
11
|
+
@@can_handle_embassy = ::Types.Interface(:handle_embassy)
|
12
|
+
attribute :id, ::Types::Coercible::Integer
|
13
|
+
attribute :next_space, SpyAlleyApplication::Types::BoardSpace
|
14
|
+
attribute :nationality, SpyAlleyApplication::Types::Nationality
|
15
|
+
|
16
|
+
def accept(visitor, **args)
|
17
|
+
@@can_handle_embassy.(visitor)
|
18
|
+
visitor.handle_embassy(self, args)
|
19
|
+
end
|
20
|
+
|
21
|
+
def in_spy_alley?;true;end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen string_literal: true
|
2
|
+
|
3
|
+
require 'dry-struct'
|
4
|
+
require 'spy_alley_application/types/board_space'
|
5
|
+
|
6
|
+
module SpyAlleyApplication
|
7
|
+
module Models
|
8
|
+
module BoardSpaces
|
9
|
+
class MoveBack < Dry::Struct
|
10
|
+
@@can_handle_move_back = ::Types.Interface(:handle_move_back)
|
11
|
+
attribute :id, ::Types::Coercible::Integer
|
12
|
+
attribute :next_space, SpyAlleyApplication::Types::BoardSpace
|
13
|
+
attribute :move_back_space, SpyAlleyApplication::Types::BoardSpace
|
14
|
+
|
15
|
+
def accept(visitor, **args)
|
16
|
+
@@can_handle_move_back.(visitor)
|
17
|
+
visitor.handle_move_back(self, args)
|
18
|
+
end
|
19
|
+
|
20
|
+
def in_spy_alley?;false;end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen string_literal: true
|
2
|
+
|
3
|
+
require 'dry-struct'
|
4
|
+
require 'spy_alley_application/types/board_space'
|
5
|
+
require 'spy_alley_application/types/nationality'
|
6
|
+
|
7
|
+
module SpyAlleyApplication
|
8
|
+
module Models
|
9
|
+
module BoardSpaces
|
10
|
+
class SoldTopSecretInformation < Dry::Struct
|
11
|
+
@@can_handle_sold_top_secret_information =
|
12
|
+
::Types.Interface(:handle_sold_top_secret_information)
|
13
|
+
attribute :id, ::Types::Coercible::Integer
|
14
|
+
attribute :next_space, SpyAlleyApplication::Types::BoardSpace
|
15
|
+
attribute :money_gained, ::Types::CoercibleNonnegativeInteger
|
16
|
+
attribute :in_spy_alley, ::Types::Strict::Bool
|
17
|
+
alias_method :in_spy_alley?, :in_spy_alley
|
18
|
+
|
19
|
+
def accept(visitor, **args)
|
20
|
+
@@can_handle_sold_top_secret_information.(visitor)
|
21
|
+
visitor.handle_sold_top_secret_information(self, args)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'spy_alley_application/types/board_space'
|
2
|
+
|
3
|
+
module SpyAlleyApplication
|
4
|
+
module Models
|
5
|
+
module BoardSpaces
|
6
|
+
class SpyAlleyEntrance < Dry::Struct
|
7
|
+
@@can_handle_spy_alley_entrance = ::Types.Interface(:handle_spy_alley_entrance)
|
8
|
+
def self.new(id:, next_space:, branch_space: nil, &block)
|
9
|
+
o = SpyAlleyEntrance.allocate
|
10
|
+
branch_space ||= yield(o)
|
11
|
+
o.send(:initialize, **{id: id, next_space: next_space, branch_space: branch_space})
|
12
|
+
o
|
13
|
+
end
|
14
|
+
|
15
|
+
def initialize(id:, next_space:, branch_space:, &block)
|
16
|
+
@id = ::Types::Coercible::Integer.call(id)
|
17
|
+
@next_space = SpyAlleyApplication::Types::BoardSpace.call(next_space)
|
18
|
+
@branch_space = SpyAlleyApplication::Types::BoardSpace.call(branch_space)
|
19
|
+
end
|
20
|
+
|
21
|
+
def id;@id;end
|
22
|
+
def next_space;@next_space;end
|
23
|
+
def branch_space;@branch_space;end
|
24
|
+
def in_spy_alley?;false;end
|
25
|
+
def to_h;{id: id};end
|
26
|
+
def [](key)
|
27
|
+
id if key.to_sym.eql?(:id)
|
28
|
+
end
|
29
|
+
|
30
|
+
def accept(visitor, **args)
|
31
|
+
@@can_handle_spy_alley_entrance.(visitor)
|
32
|
+
visitor.handle_spy_alley_entrance(self, args)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen string_literal: true
|
2
|
+
|
3
|
+
require 'dry-struct'
|
4
|
+
require 'spy_alley_application/types/board_space'
|
5
|
+
|
6
|
+
module SpyAlleyApplication
|
7
|
+
module Models
|
8
|
+
module BoardSpaces
|
9
|
+
class SpyEliminator < Dry::Struct
|
10
|
+
@@can_handle_spy_eliminator = ::Types.Interface(:handle_spy_eliminator)
|
11
|
+
attribute :id, ::Types::Coercible::Integer
|
12
|
+
attribute :next_space, ::SpyAlleyApplication::Types::BoardSpace
|
13
|
+
|
14
|
+
def accept(visitor, **args)
|
15
|
+
@@can_handle_spy_eliminator.(visitor)
|
16
|
+
visitor.handle_spy_eliminator(self, args)
|
17
|
+
end
|
18
|
+
|
19
|
+
def in_spy_alley?;true;end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|