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,31 @@
|
|
1
|
+
# frozen string literal: true
|
2
|
+
|
3
|
+
require 'dry-struct'
|
4
|
+
require 'game_validator/validator/validate_to_action'
|
5
|
+
require 'spy_alley_application/types/nationality'
|
6
|
+
require 'spy_alley_application/validator/make_accusation'
|
7
|
+
|
8
|
+
module SpyAlleyApplication
|
9
|
+
module Models
|
10
|
+
module Validator
|
11
|
+
class MakingAccusation < Dry::Struct
|
12
|
+
attribute :name, ::Types.Value('make_accusation')
|
13
|
+
attribute :player_id_list, ::Types::ArrayOfStrictInteger
|
14
|
+
attribute :wrap_result, ::Types::Callable
|
15
|
+
|
16
|
+
def build(options={})
|
17
|
+
@validate_to_action ||= GameValidator::Validator::ValidateToAction::new(
|
18
|
+
validate: validate,
|
19
|
+
wrap: wrap_result)
|
20
|
+
@validate_to_action
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
def validate
|
25
|
+
SpyAlleyApplication::Validator::MakeAccusation::new(player_id_list: player_id_list)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen string literal: true
|
2
|
+
|
3
|
+
require 'dry-struct'
|
4
|
+
require 'game_validator/validator/validate_to_action'
|
5
|
+
require 'spy_alley_application/validator/move'
|
6
|
+
|
7
|
+
module SpyAlleyApplication
|
8
|
+
module Models
|
9
|
+
module Validator
|
10
|
+
class Moving < Dry::Struct
|
11
|
+
attribute :name, ::Types.Value('move')
|
12
|
+
attribute :options, ::Types::ArrayOfStrictInteger.constrained(size: 2)
|
13
|
+
attribute :wrap_result, ::Types::Callable
|
14
|
+
|
15
|
+
def build(options={})
|
16
|
+
@validate_to_action ||= GameValidator::Validator::ValidateToAction::new(
|
17
|
+
validate: validate,
|
18
|
+
wrap: wrap_result)
|
19
|
+
@validate_to_action
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
def validate
|
24
|
+
SpyAlleyApplication::Validator::Move::new(options: options)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen string literal: true
|
2
|
+
|
3
|
+
require 'dry-struct'
|
4
|
+
require 'game_validator/validator/validate_to_action'
|
5
|
+
require 'spy_alley_application/validator/no_options'
|
6
|
+
|
7
|
+
module SpyAlleyApplication
|
8
|
+
module Models
|
9
|
+
module Validator
|
10
|
+
class Passing < Dry::Struct
|
11
|
+
attribute :name, ::Types.Value('pass')
|
12
|
+
attribute :wrap_result, ::Types::Callable
|
13
|
+
|
14
|
+
def build(options={})
|
15
|
+
@validate_to_action ||= GameValidator::Validator::ValidateToAction::new(
|
16
|
+
validate: SpyAlleyApplication::Validator::NoOptions,
|
17
|
+
wrap: wrap_result)
|
18
|
+
@validate_to_action
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen string literal: true
|
2
|
+
|
3
|
+
require 'dry-struct'
|
4
|
+
require 'game_validator/validator/validate_to_action'
|
5
|
+
require 'spy_alley_application/validator/no_options'
|
6
|
+
|
7
|
+
module SpyAlleyApplication
|
8
|
+
module Models
|
9
|
+
module Validator
|
10
|
+
class RollingDie < Dry::Struct
|
11
|
+
attribute :name, ::Types.Value('roll_die')
|
12
|
+
attribute :wrap_result, ::Types::Callable
|
13
|
+
|
14
|
+
def build(options={})
|
15
|
+
@validate_to_action ||= GameValidator::Validator::ValidateToAction::new(
|
16
|
+
validate: validate,
|
17
|
+
wrap: wrap_result)
|
18
|
+
@validate_to_action
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
def validate
|
23
|
+
SpyAlleyApplication::Validator::NoOptions
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen string literal: true
|
2
|
+
|
3
|
+
require 'dry-struct'
|
4
|
+
require 'game_validator/validator/validate_to_action'
|
5
|
+
require 'spy_alley_application/types/nationality'
|
6
|
+
require 'spy_alley_application/validator/use_move_card'
|
7
|
+
|
8
|
+
module SpyAlleyApplication
|
9
|
+
module Models
|
10
|
+
module Validator
|
11
|
+
class UsingMoveCard < Dry::Struct
|
12
|
+
attribute :name, ::Types.Value('use_move_card')
|
13
|
+
attribute :card_list, ::Types::ArrayOfStrictInteger
|
14
|
+
attribute :wrap_result, ::Types::Callable
|
15
|
+
|
16
|
+
def build(options={})
|
17
|
+
@validate_to_action ||= GameValidator::Validator::ValidateToAction::new(
|
18
|
+
validate: validate,
|
19
|
+
wrap: wrap_result)
|
20
|
+
@validate_to_action
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
def validate
|
25
|
+
SpyAlleyApplication::Validator::UseMoveCard::new(card_list: card_list)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen string literal: true
|
2
|
+
|
3
|
+
module SpyAlleyApplication
|
4
|
+
module Models
|
5
|
+
class WildCard
|
6
|
+
@@can_handle_wild_cards = ::Types.Interface(:handle_wild_card)
|
7
|
+
|
8
|
+
def accept(visitor, **args)
|
9
|
+
@@can_handle_wild_cards.(visitor)
|
10
|
+
visitor.handle_wild_card(self, args)
|
11
|
+
end
|
12
|
+
|
13
|
+
def wild_card?
|
14
|
+
true
|
15
|
+
end
|
16
|
+
|
17
|
+
def inspect
|
18
|
+
'wild card'
|
19
|
+
end
|
20
|
+
alias_method :to_s, :inspect
|
21
|
+
alias_method :to_h, :to_s
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'dry-auto_inject'
|
4
|
+
require 'spy_alley_application/injection_container'
|
5
|
+
require 'spy_alley_application/types/game_board'
|
6
|
+
|
7
|
+
module SpyAlleyApplication
|
8
|
+
class NewGame
|
9
|
+
include Dry::AutoInject(SpyAlleyApplication::InjectionContainer)[
|
10
|
+
:change_orders_initializer, validate: :build_new_game_validator]
|
11
|
+
|
12
|
+
def call(action_hash:, user:)
|
13
|
+
execute_action = validate.(action_hash: action_hash, user: user)
|
14
|
+
execute_action.(change_orders: change_orders_initializer.())
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen string literal: true
|
2
|
+
|
3
|
+
module SpyAlleyApplication
|
4
|
+
class NewGame
|
5
|
+
class AssignSeats
|
6
|
+
def call(seat_assignments)
|
7
|
+
seat_assignments = seat_assignments.to_a
|
8
|
+
seats = [1, 2, 3, 4, 5, 6] - (seat_assignments.map{|s| s[:seat]}.reject(&:nil?))
|
9
|
+
seat_assignments.each do |seat|
|
10
|
+
if seat[:seat].nil?
|
11
|
+
index = rand(seats.size)
|
12
|
+
seat[:seat] = seats[index]
|
13
|
+
seats = seats - [seats[index]]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
seat_assignments
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen string literal: true
|
2
|
+
|
3
|
+
require 'spy_alley_application/types/nationality'
|
4
|
+
|
5
|
+
module SpyAlleyApplication
|
6
|
+
class NewGame
|
7
|
+
class AssignSpyIdentities
|
8
|
+
def call(seat_assignments)
|
9
|
+
seat_assignments = seat_assignments.to_a
|
10
|
+
spy_identities = SpyAlleyApplication::Types::Nationality.values -
|
11
|
+
(seat_assignments.map{|s| s[:spy_identity]}.reject(&:nil?))
|
12
|
+
seat_assignments.each do |seat|
|
13
|
+
if seat[:spy_identity].nil?
|
14
|
+
index = rand(spy_identities.size)
|
15
|
+
seat[:spy_identity] = spy_identities[index]
|
16
|
+
spy_identities = spy_identities - [spy_identities[index]]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
seat_assignments
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
@@ -0,0 +1,23 @@
|
|
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 Results
|
9
|
+
module Nodes
|
10
|
+
class BuyEquipmentOptionNode < Dry::Struct
|
11
|
+
@@can_handle_buy_equipment_option = ::Types.Interface(:handle_buy_equipment_option)
|
12
|
+
attribute :options, SpyAlleyApplication::Types::ArrayOfEquipment
|
13
|
+
attribute :limit, ::Types::CoercibleNonnegativeInteger
|
14
|
+
|
15
|
+
def accept(visitor, **args)
|
16
|
+
@can_handle_buy_equipment_option.(visitor)
|
17
|
+
visitor.handle_buy_equipment_option(self, args)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
@@ -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 Results
|
8
|
+
module Nodes
|
9
|
+
class ChooseNewSpyIdentityOptionNode < Dry::Struct
|
10
|
+
@@can_handle_choose_new_spy_identity_option =
|
11
|
+
::Types.Interface(:handle_choose_new_spy_identity_option)
|
12
|
+
attribute :options, ::Types::Array.of(SpyAlleyApplication::Types::Nationality)
|
13
|
+
.constrained(size: 2)
|
14
|
+
|
15
|
+
def accept(visitor, **args)
|
16
|
+
@can_handle_choose_new_spy_identity_option.(visitor)
|
17
|
+
visitor.handle_choose_new_spy_identity_option(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 Results
|
7
|
+
module Nodes
|
8
|
+
class ConfiscateMaterialsOptionNode < Dry::Struct
|
9
|
+
@@can_handle_confiscate_materials_option =
|
10
|
+
::Types.Interface(:handle_confiscate_materials_option)
|
11
|
+
attribute :target_player_id, ::Types::Strict::Integer
|
12
|
+
attribute :targetable_equipment, SpyAlleyApplication::Types::ArrayOfEquipment
|
13
|
+
|
14
|
+
def accept(visitor, **args)
|
15
|
+
@@can_handle_confiscate_materials_option.(visitor)
|
16
|
+
visitor.handle_confiscate_materials_option(self, args)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
@@ -0,0 +1,21 @@
|
|
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 Results
|
8
|
+
module Nodes
|
9
|
+
class DieRolledNode < Dry::Struct
|
10
|
+
@@can_handle_die_rolled = ::Types.Interface(:handle_die_rolled)
|
11
|
+
attribute :number_rolled, SpyAlleyApplication::Types::CoercibleIntegerOneToSix
|
12
|
+
|
13
|
+
def accept(visitor, **args)
|
14
|
+
@can_handle_die_rolled.(visitor)
|
15
|
+
visitor.handle_die_rolled(self, args)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'dry-struct'
|
4
|
+
require 'spy_alley_application/models/player'
|
5
|
+
|
6
|
+
module SpyAlleyApplication
|
7
|
+
module Results
|
8
|
+
module Nodes
|
9
|
+
class EliminatedPlayerNode < Dry::Struct
|
10
|
+
@@can_handle_eliminated_player = ::Types.Interface(:handle_eliminated_player)
|
11
|
+
attribute :eliminating_player, SpyAlleyApplication::Models::Player
|
12
|
+
attribute :eliminated_player, SpyAlleyApplication::Models::Player
|
13
|
+
|
14
|
+
def accept(visitor, **args)
|
15
|
+
@@can_handle_eliminated_player.(visitor)
|
16
|
+
visitor.handle_eliminated_player(self, args)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'dry-struct'
|
4
|
+
require 'spy_alley_application/models/acquisition_method/by_confiscation'
|
5
|
+
require 'spy_alley_application/models/acquisition_method/by_free_gift'
|
6
|
+
require 'spy_alley_application/models/acquisition_method/by_purchase'
|
7
|
+
require 'spy_alley_application/types/array_of_equipment'
|
8
|
+
|
9
|
+
module SpyAlleyApplication
|
10
|
+
module Results
|
11
|
+
module Nodes
|
12
|
+
class EquipmentGainedNode < Dry::Struct
|
13
|
+
@@can_handle_equipment_gained = ::Types.Interface(:handle_equipment_gained)
|
14
|
+
attribute :player_id, ::Types::Coercible::Integer
|
15
|
+
attribute :equipment, SpyAlleyApplication::Types::ArrayOfEquipment
|
16
|
+
attribute :reason, SpyAlleyApplication::Models::AcquisitionMethod::ByConfiscation |
|
17
|
+
SpyAlleyApplication::Models::AcquisitionMethod::ByFreeGift |
|
18
|
+
SpyAlleyApplication::Models::AcquisitionMethod::ByPurchase
|
19
|
+
|
20
|
+
def accept(visitor, **args)
|
21
|
+
@can_handle_equipment_gained.(visitor)
|
22
|
+
visitor.handle_equipment_gained(self, args)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
@@ -0,0 +1,24 @@
|
|
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
|
+
|
7
|
+
module SpyAlleyApplication
|
8
|
+
module Results
|
9
|
+
module Nodes
|
10
|
+
class GameOverNode < Dry::Struct
|
11
|
+
@@can_handle_game_over = ::Types.Interface(:handle_game_over)
|
12
|
+
attribute :winning_player_id, ::Types::Coercible::Integer
|
13
|
+
attribute :reason, SpyAlleyApplication::Models::GameState::VictoryReason::ByElimination |
|
14
|
+
SpyAlleyApplication::Models::GameState::VictoryReason::ByEmbassy
|
15
|
+
|
16
|
+
def accept(visitor, **args)
|
17
|
+
@can_handle_game_over.(visitor)
|
18
|
+
visitor.handle_game_over(self, args)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'dry-struct'
|
4
|
+
|
5
|
+
module SpyAlleyApplication
|
6
|
+
module Results
|
7
|
+
module Nodes
|
8
|
+
class MakeAccusationOptionNode < Dry::Struct
|
9
|
+
@@can_handle_make_accusation_option = ::Types.Interface(:handle_make_accusation_option)
|
10
|
+
attribute :player_id_list, ::Types::ArrayOfStrictInteger
|
11
|
+
|
12
|
+
def accept(visitor, **args)
|
13
|
+
@@can_handle_make_accusation_option.(visitor)
|
14
|
+
visitor.handle_make_accusation_option(self, args)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|