spy_alley_application 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- 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,26 @@
|
|
1
|
+
# frozen string literal: true
|
2
|
+
|
3
|
+
require 'dry-struct'
|
4
|
+
require 'spy_alley_application/types/array_of_equipment'
|
5
|
+
require 'spy_alley_application/types/coercible_integer_one_to_six'
|
6
|
+
|
7
|
+
module SpyAlleyApplication
|
8
|
+
module Models
|
9
|
+
module GameState
|
10
|
+
class BuyEquipment < Dry::Struct
|
11
|
+
@@can_handle_buy_equipment = ::Types.Interface(:handle_buy_equipment)
|
12
|
+
|
13
|
+
attribute :name, ::Types::Value('buy_equipment')
|
14
|
+
attribute :seat, SpyAlleyApplication::Types::CoercibleIntegerOneToSix
|
15
|
+
attribute :options, SpyAlleyApplication::Types::ArrayOfEquipment
|
16
|
+
attribute :limit, ::Types::CoercibleNonnegativeInteger
|
17
|
+
|
18
|
+
def accept(visitor, **args)
|
19
|
+
@@can_handle_buy_equipment.(visitor)
|
20
|
+
visitor.handle_buy_equipment(self, args)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen string literal: true
|
2
|
+
|
3
|
+
require 'dry-struct'
|
4
|
+
require 'spy_alley_application/models/game_state/start_of_turn'
|
5
|
+
require 'spy_alley_application/models/game_state/spy_eliminator'
|
6
|
+
|
7
|
+
module SpyAlleyApplication
|
8
|
+
module Models
|
9
|
+
module GameState
|
10
|
+
class ChooseNewSpyIdentity < Dry::Struct
|
11
|
+
new_spy_identity_type = ::Types::Array::of(SpyAlleyApplication::Types::Nationality)
|
12
|
+
.constrained(size: 2)
|
13
|
+
@@can_handle_choose_new_spy_identity =
|
14
|
+
::Types.Interface(:handle_choose_new_spy_identity)
|
15
|
+
|
16
|
+
attribute :name, ::Types::Value('choose_new_spy_identity')
|
17
|
+
attribute :seat, ::Types::Coercible::Integer
|
18
|
+
attribute :options, new_spy_identity_type
|
19
|
+
attribute :parent, StartOfTurn | SpyEliminator
|
20
|
+
|
21
|
+
def accept(visitor, **args)
|
22
|
+
@@can_handle_choose_new_spy_identity.(visitor)
|
23
|
+
visitor.handle_choose_new_spy_identity(self, args)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen string literal: true
|
2
|
+
|
3
|
+
require 'dry-struct'
|
4
|
+
require 'spy_alley_application/types/coercible_integer_one_to_six'
|
5
|
+
|
6
|
+
module SpyAlleyApplication
|
7
|
+
module Models
|
8
|
+
module GameState
|
9
|
+
class ConfiscateMaterials < Dry::Struct
|
10
|
+
class ConfiscationTarget < Dry::Struct
|
11
|
+
attribute :seat, SpyAlleyApplication::Types::CoercibleIntegerOneToSix
|
12
|
+
attribute :equipment, SpyAlleyApplication::Types::ArrayOfEquipment
|
13
|
+
end
|
14
|
+
|
15
|
+
@@can_handle_confiscate_materials = ::Types.Interface(:handle_confiscate_materials)
|
16
|
+
|
17
|
+
attribute :name, ::Types::Value('confiscate_materials')
|
18
|
+
attribute :seat, SpyAlleyApplication::Types::CoercibleIntegerOneToSix
|
19
|
+
attribute :targets, ::Types::Array::of(ConfiscationTarget)
|
20
|
+
|
21
|
+
def accept(visitor, **args)
|
22
|
+
@@can_handle_confiscate_materials.(visitor)
|
23
|
+
visitor.handle_confiscate_materials(self, args)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen string literal: true
|
2
|
+
|
3
|
+
require 'dry-struct'
|
4
|
+
require 'spy_alley_application/models/game_state/victory_reason/by_elimination'
|
5
|
+
require 'spy_alley_application/models/game_state/victory_reason/by_embassy'
|
6
|
+
require 'spy_alley_application/types/coercible_integer_one_to_six'
|
7
|
+
|
8
|
+
module SpyAlleyApplication
|
9
|
+
module Models
|
10
|
+
module GameState
|
11
|
+
class GameOver < Dry::Struct
|
12
|
+
@@can_handle_game_over = ::Types.Interface(:handle_game_over)
|
13
|
+
|
14
|
+
attribute :name, ::Types::Value('game_over')
|
15
|
+
attribute :seat, SpyAlleyApplication::Types::CoercibleIntegerOneToSix
|
16
|
+
attribute :reason, SpyAlleyApplication::Models::GameState::VictoryReason::ByElimination |
|
17
|
+
SpyAlleyApplication::Models::GameState::VictoryReason::ByEmbassy
|
18
|
+
|
19
|
+
def accept(visitor, **args)
|
20
|
+
@@can_handle_game_over.(visitor)
|
21
|
+
visitor.handle_game_over(self, args)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen string literal: true
|
2
|
+
|
3
|
+
require 'dry-struct'
|
4
|
+
require 'spy_alley_application/types/coercible_integer_one_to_six'
|
5
|
+
|
6
|
+
module SpyAlleyApplication
|
7
|
+
module Models
|
8
|
+
module GameState
|
9
|
+
class MoveOption < Dry::Struct
|
10
|
+
@@can_handle_move_option = ::Types.Interface(:handle_move_option)
|
11
|
+
|
12
|
+
attribute :name, ::Types::Value('move_option')
|
13
|
+
attribute :seat, SpyAlleyApplication::Types::CoercibleIntegerOneToSix
|
14
|
+
attribute :options, ::Types::Array::of(::Types::Coercible::Integer)
|
15
|
+
.constrained(min_size: 2, max_size: 2)
|
16
|
+
|
17
|
+
def accept(visitor, **args)
|
18
|
+
@@can_handle_move_option.(visitor)
|
19
|
+
visitor.handle_move_option(self, args)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen string literal: true
|
2
|
+
|
3
|
+
require 'dry-struct'
|
4
|
+
require 'spy_alley_application/models/game_state/start_of_turn'
|
5
|
+
|
6
|
+
module SpyAlleyApplication
|
7
|
+
module Models
|
8
|
+
module GameState
|
9
|
+
class SpyEliminator < Dry::Struct
|
10
|
+
@@can_handle_spy_eliminator = ::Types.Interface(:handle_spy_eliminator)
|
11
|
+
|
12
|
+
attribute :name, ::Types.Value('spy_eliminator')
|
13
|
+
attribute :seat, ::Types::Coercible::Integer
|
14
|
+
attribute :targetable_seats, ::Types::ArrayOfStrictInteger
|
15
|
+
attribute :parent, SpyAlleyApplication::Models::GameState::StartOfTurn
|
16
|
+
|
17
|
+
def accept(visitor, **args)
|
18
|
+
@@can_handle_spy_eliminator.(visitor)
|
19
|
+
visitor.handle_spy_eliminator(self, args)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen string literal: true
|
2
|
+
|
3
|
+
require 'dry-struct'
|
4
|
+
require 'spy_alley_application/types/coercible_integer_one_to_six'
|
5
|
+
|
6
|
+
module SpyAlleyApplication
|
7
|
+
module Models
|
8
|
+
module GameState
|
9
|
+
class StartOfTurn < Dry::Struct
|
10
|
+
@@can_handle_start_of_turn = ::Types.Interface(:handle_start_of_turn)
|
11
|
+
|
12
|
+
attribute :name, ::Types::Value('start_of_turn')
|
13
|
+
attribute :seat, SpyAlleyApplication::Types::CoercibleIntegerOneToSix
|
14
|
+
|
15
|
+
def accept(visitor, **args)
|
16
|
+
@@can_handle_start_of_turn.(visitor)
|
17
|
+
visitor.handle_start_of_turn(self, args)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen string literal: true
|
2
|
+
|
3
|
+
require 'dry-struct'
|
4
|
+
|
5
|
+
module SpyAlleyApplication
|
6
|
+
module Models
|
7
|
+
module GameState
|
8
|
+
module VictoryReason
|
9
|
+
class ByElimination < Dry::Struct
|
10
|
+
@@can_handle_by_elimination = ::Types.Interface(:handle_by_elimination)
|
11
|
+
attribute :name, ::Types.Value('by_elimination')
|
12
|
+
|
13
|
+
def accept(visitor, **args)
|
14
|
+
@can_handle_by_elimination.(visitor)
|
15
|
+
visitor.handle_by_elimination(self, args)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen string literal: true
|
2
|
+
|
3
|
+
require 'dry-struct'
|
4
|
+
|
5
|
+
module SpyAlleyApplication
|
6
|
+
module Models
|
7
|
+
module GameState
|
8
|
+
module VictoryReason
|
9
|
+
class ByEmbassy < Dry::Struct
|
10
|
+
@@can_handle_by_embassy = ::Types.Interface(:handle_by_embassy)
|
11
|
+
attribute :name, ::Types.Value('by_embassy')
|
12
|
+
|
13
|
+
def accept(visitor, **args)
|
14
|
+
@can_handle_by_embassy.(visitor)
|
15
|
+
visitor.handle_by_embassy(self, args)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen string literal: true
|
2
|
+
|
3
|
+
require 'dry-struct'
|
4
|
+
require 'spy_alley_application/types/coercible_integer_one_to_six'
|
5
|
+
|
6
|
+
module SpyAlleyApplication
|
7
|
+
module Models
|
8
|
+
class MoveCard < Dry::Struct
|
9
|
+
attribute :value, SpyAlleyApplication::Types::CoercibleIntegerOneToSix
|
10
|
+
|
11
|
+
def to_h
|
12
|
+
self
|
13
|
+
end
|
14
|
+
|
15
|
+
def to_s
|
16
|
+
value
|
17
|
+
end
|
18
|
+
|
19
|
+
def to_i
|
20
|
+
value
|
21
|
+
end
|
22
|
+
alias_method :transform_values, :to_s
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen string literal: true
|
2
|
+
|
3
|
+
require 'dry-struct'
|
4
|
+
require 'spy_alley_application/types/array_of_equipment'
|
5
|
+
require 'spy_alley_application/types/array_of_move_cards'
|
6
|
+
require 'spy_alley_application/types/board_space'
|
7
|
+
require 'spy_alley_application/types/nationality'
|
8
|
+
|
9
|
+
module SpyAlleyApplication
|
10
|
+
module Models
|
11
|
+
class Player < Dry::Struct::Value
|
12
|
+
attribute :id, ::Types::Coercible::Integer
|
13
|
+
attribute :seat, ::Types::Coercible::Integer
|
14
|
+
attribute :location, SpyAlleyApplication::Types::BoardSpace
|
15
|
+
attribute :spy_identity, SpyAlleyApplication::Types::Nationality
|
16
|
+
attribute :money, ::Types::CoercibleNonnegativeInteger
|
17
|
+
attribute :move_cards, SpyAlleyApplication::Types::ArrayOfMoveCards
|
18
|
+
attribute :equipment, SpyAlleyApplication::Types::ArrayOfEquipment
|
19
|
+
attribute :wild_cards, ::Types::CoercibleNonnegativeInteger
|
20
|
+
attribute :active, ::Types::Strict::Bool
|
21
|
+
alias_method :active?, :active
|
22
|
+
|
23
|
+
def to_h
|
24
|
+
location_id = location.id
|
25
|
+
super.map do |k, v|
|
26
|
+
[k.eql?(:active) ? :active? : k]
|
27
|
+
.push(k.eql?(:location) ? {id: location_id} : v)
|
28
|
+
end.to_h
|
29
|
+
end
|
30
|
+
|
31
|
+
def in_spy_alley?
|
32
|
+
location.in_spy_alley?
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
@@ -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 SellTopSecretInformation < Dry::Struct
|
10
|
+
@@can_handle_sell_top_secret_information =
|
11
|
+
::Types.Interface(:handle_sell_top_secret_information)
|
12
|
+
attribute :id, ::Types::Coercible::Integer
|
13
|
+
attribute :next_space, SpyAlleyApplication::Types::BoardSpace
|
14
|
+
attribute :money_gained, ::Types::Coercible::Integer.constrained(gte: 1)
|
15
|
+
|
16
|
+
def accept(visitor, **args)
|
17
|
+
@@can_handle_sell_top_secret_information.(visitor)
|
18
|
+
visitor.handle_sell_top_secret_information(self, args)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen string literal: true
|
2
|
+
|
3
|
+
require 'dry-struct'
|
4
|
+
require 'game_validator/validator/validate_to_action'
|
5
|
+
require 'spy_alley_application/types/array_of_equipment'
|
6
|
+
require 'spy_alley_application/types/coercible_integer_one_to_six'
|
7
|
+
require 'spy_alley_application/validator/buy_equipment'
|
8
|
+
|
9
|
+
module SpyAlleyApplication
|
10
|
+
module Models
|
11
|
+
module Validator
|
12
|
+
class BuyingEquipment < Dry::Struct
|
13
|
+
attribute :name, ::Types::Value('buy_equipment')
|
14
|
+
attribute :options, SpyAlleyApplication::Types::ArrayOfEquipment
|
15
|
+
attribute :limit, SpyAlleyApplication::Types::CoercibleIntegerOneToSix
|
16
|
+
attribute :wrap_result, ::Types::Callable
|
17
|
+
|
18
|
+
def build(options={})
|
19
|
+
@validate_to_action ||= GameValidator::Validator::ValidateToAction::new(
|
20
|
+
validate: validate,
|
21
|
+
wrap: wrap_result)
|
22
|
+
@validate_to_action
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
def validate
|
27
|
+
SpyAlleyApplication::Validator::BuyEquipment::new(
|
28
|
+
options: options,
|
29
|
+
limit: limit)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen string literal: true
|
2
|
+
|
3
|
+
require 'dry-struct'
|
4
|
+
require 'game_validator/validator/validate_to_action'
|
5
|
+
require 'spy_alley_application/types/array_of_equipment'
|
6
|
+
require 'spy_alley_application/types/coercible_integer_one_to_six'
|
7
|
+
require 'spy_alley_application/validator/choose_new_spy_identity'
|
8
|
+
|
9
|
+
module SpyAlleyApplication
|
10
|
+
module Models
|
11
|
+
module Validator
|
12
|
+
class ChoosingNewSpyIdentity < Dry::Struct
|
13
|
+
attribute :name, ::Types.Value('choose_new_spy_identity')
|
14
|
+
attribute :options, ::Types::Array::of(SpyAlleyApplication::Types::Nationality)
|
15
|
+
.constrained(size: 2)
|
16
|
+
attribute :wrap_result, ::Types::Callable
|
17
|
+
|
18
|
+
def build(options={})
|
19
|
+
@validate_to_action ||= GameValidator::Validator::ValidateToAction::new(
|
20
|
+
validate: validate,
|
21
|
+
wrap: wrap_result)
|
22
|
+
@validate_to_action
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
def validate
|
27
|
+
SpyAlleyApplication::Validator::ChooseNewSpyIdentity::new(options: options)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen string literal: true
|
2
|
+
|
3
|
+
require 'dry-struct'
|
4
|
+
require 'game_validator/validator/validate_to_action'
|
5
|
+
require 'spy_alley_application/types/array_of_equipment'
|
6
|
+
require 'spy_alley_application/validator/confiscate_materials'
|
7
|
+
require 'spy_alley_application/validator/confiscate_materials/full_validator'
|
8
|
+
require 'spy_alley_application/validator/confiscate_materials/validate_target_player_id'
|
9
|
+
|
10
|
+
module SpyAlleyApplication
|
11
|
+
module Models
|
12
|
+
module Validator
|
13
|
+
class ConfiscatingMaterials < Dry::Struct
|
14
|
+
attribute :name, ::Types::Value('confiscate_materials')
|
15
|
+
attribute :wrap_result, ::Types::Callable
|
16
|
+
attribute :target_player, ::Types::Array do
|
17
|
+
attribute :target_player_id, ::Types::Coercible::String
|
18
|
+
attribute :targetable_equipment, SpyAlleyApplication::Types::ArrayOfEquipment
|
19
|
+
end
|
20
|
+
|
21
|
+
def build(options={})
|
22
|
+
@validate_to_action ||= GameValidator::Validator::ValidateToAction::new(
|
23
|
+
validate: validate,
|
24
|
+
wrap: wrap_result)
|
25
|
+
@validate_to_action
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
def validate
|
30
|
+
validate_target_player_id =
|
31
|
+
SpyAlleyApplication::Validator::ConfiscateMaterials::ValidatetargetPlayerId::new(
|
32
|
+
target_player_id_list: target_player.map(&:target_player_id))
|
33
|
+
full_validator_for = target_player.map do |p|
|
34
|
+
[
|
35
|
+
p.target_player_id,
|
36
|
+
SpyAlleyApplication::Validator::ConfiscateMaterials::FullValidator::new(
|
37
|
+
target_player_id: p.target_player_id,
|
38
|
+
targetable_equipment: p.targetable_equipment)
|
39
|
+
]
|
40
|
+
end.to_h
|
41
|
+
|
42
|
+
SpyAlleyApplication::Validator::ConfiscateMaterials::new(
|
43
|
+
validate_target_player_id: validate_target_player_id,
|
44
|
+
full_validator_for: full_validator_for)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|