2023-11-16 15:54:50 +01:00
|
|
|
#include "game_state.h"
|
|
|
|
#include "game_interface.h"
|
|
|
|
|
2023-11-16 16:20:04 +01:00
|
|
|
namespace Hanabi
|
|
|
|
{
|
2023-11-16 15:54:50 +01:00
|
|
|
std::unique_ptr<Hanabi::HanabiStateIF> make_game_state(
|
2024-01-09 02:21:01 +01:00
|
|
|
std::size_t num_suits, Hanabi::player_t num_players, std::vector<Hanabi::Card> const & deck,
|
|
|
|
clue_t num_clues_gained_on_discard_or_stack_finished, std::optional<
|
2023-11-16 16:20:04 +01:00
|
|
|
uint8_t> score_goal
|
|
|
|
)
|
2023-11-16 15:54:50 +01:00
|
|
|
{
|
|
|
|
uint8_t actual_score_goal = score_goal.value_or(5 * num_suits);
|
2023-11-16 16:20:04 +01:00
|
|
|
switch (num_players)
|
|
|
|
{
|
2023-11-16 15:54:50 +01:00
|
|
|
case 2:
|
2023-11-16 16:20:04 +01:00
|
|
|
switch (num_suits)
|
|
|
|
{
|
2023-11-16 15:54:50 +01:00
|
|
|
case 3:
|
2024-01-09 02:21:01 +01:00
|
|
|
return std::unique_ptr<Hanabi::HanabiStateIF>(new Hanabi::HanabiState<3, 2, 5>(deck, actual_score_goal, num_clues_gained_on_discard_or_stack_finished));
|
2023-11-16 15:54:50 +01:00
|
|
|
case 4:
|
2024-01-09 02:21:01 +01:00
|
|
|
return std::unique_ptr<Hanabi::HanabiStateIF>(new Hanabi::HanabiState<4, 2, 5>(deck, actual_score_goal, num_clues_gained_on_discard_or_stack_finished));
|
2023-11-16 15:54:50 +01:00
|
|
|
case 5:
|
2024-01-09 02:21:01 +01:00
|
|
|
return std::unique_ptr<Hanabi::HanabiStateIF>(new Hanabi::HanabiState<5, 2, 5>(deck, actual_score_goal, num_clues_gained_on_discard_or_stack_finished));
|
2023-11-16 15:54:50 +01:00
|
|
|
case 6:
|
2024-01-09 02:21:01 +01:00
|
|
|
return std::unique_ptr<Hanabi::HanabiStateIF>(new Hanabi::HanabiState<6, 2, 5>(deck, actual_score_goal, num_clues_gained_on_discard_or_stack_finished));
|
2023-11-16 15:54:50 +01:00
|
|
|
default:
|
|
|
|
throw std::runtime_error("Invalid number of suits: " + std::to_string(num_suits));
|
|
|
|
}
|
|
|
|
case 3:
|
2023-11-16 16:20:04 +01:00
|
|
|
switch (num_suits)
|
|
|
|
{
|
2023-11-16 15:54:50 +01:00
|
|
|
case 3:
|
2024-01-09 02:21:01 +01:00
|
|
|
return std::unique_ptr<Hanabi::HanabiStateIF>(new Hanabi::HanabiState<3, 3, 5>(deck, actual_score_goal, num_clues_gained_on_discard_or_stack_finished));
|
2023-11-16 15:54:50 +01:00
|
|
|
case 4:
|
2024-01-09 02:21:01 +01:00
|
|
|
return std::unique_ptr<Hanabi::HanabiStateIF>(new Hanabi::HanabiState<4, 3, 5>(deck, actual_score_goal, num_clues_gained_on_discard_or_stack_finished));
|
2023-11-16 15:54:50 +01:00
|
|
|
case 5:
|
2024-01-09 02:21:01 +01:00
|
|
|
return std::unique_ptr<Hanabi::HanabiStateIF>(new Hanabi::HanabiState<5, 3, 5>(deck, actual_score_goal, num_clues_gained_on_discard_or_stack_finished));
|
2023-11-16 15:54:50 +01:00
|
|
|
case 6:
|
2024-01-09 02:21:01 +01:00
|
|
|
return std::unique_ptr<Hanabi::HanabiStateIF>(new Hanabi::HanabiState<6, 3, 5>(deck, actual_score_goal, num_clues_gained_on_discard_or_stack_finished));
|
2023-11-16 15:54:50 +01:00
|
|
|
default:
|
|
|
|
throw std::runtime_error("Invalid number of suits: " + std::to_string(num_suits));
|
|
|
|
}
|
|
|
|
case 4:
|
2023-11-16 16:20:04 +01:00
|
|
|
switch (num_suits)
|
|
|
|
{
|
2023-11-16 15:54:50 +01:00
|
|
|
case 3:
|
2024-01-09 02:21:01 +01:00
|
|
|
return std::unique_ptr<Hanabi::HanabiStateIF>(new Hanabi::HanabiState<3, 4, 4>(deck, actual_score_goal, num_clues_gained_on_discard_or_stack_finished));
|
2023-11-16 15:54:50 +01:00
|
|
|
case 4:
|
2024-01-09 02:21:01 +01:00
|
|
|
return std::unique_ptr<Hanabi::HanabiStateIF>(new Hanabi::HanabiState<4, 4, 4>(deck, actual_score_goal, num_clues_gained_on_discard_or_stack_finished));
|
2023-11-16 15:54:50 +01:00
|
|
|
case 5:
|
2024-01-09 02:21:01 +01:00
|
|
|
return std::unique_ptr<Hanabi::HanabiStateIF>(new Hanabi::HanabiState<5, 4, 4>(deck, actual_score_goal, num_clues_gained_on_discard_or_stack_finished));
|
2023-11-16 15:54:50 +01:00
|
|
|
case 6:
|
2024-01-09 02:21:01 +01:00
|
|
|
return std::unique_ptr<Hanabi::HanabiStateIF>(new Hanabi::HanabiState<6, 4, 4>(deck, actual_score_goal, num_clues_gained_on_discard_or_stack_finished));
|
2023-11-16 15:54:50 +01:00
|
|
|
default:
|
|
|
|
throw std::runtime_error("Invalid number of suits: " + std::to_string(num_suits));
|
|
|
|
}
|
|
|
|
case 5:
|
2023-11-16 16:20:04 +01:00
|
|
|
switch (num_suits)
|
|
|
|
{
|
2023-11-16 15:54:50 +01:00
|
|
|
case 3:
|
2024-01-09 02:21:01 +01:00
|
|
|
return std::unique_ptr<Hanabi::HanabiStateIF>(new Hanabi::HanabiState<3, 5, 4>(deck, actual_score_goal, num_clues_gained_on_discard_or_stack_finished));
|
2023-11-16 15:54:50 +01:00
|
|
|
case 4:
|
2024-01-09 02:21:01 +01:00
|
|
|
return std::unique_ptr<Hanabi::HanabiStateIF>(new Hanabi::HanabiState<4, 5, 4>(deck, actual_score_goal, num_clues_gained_on_discard_or_stack_finished));
|
2023-11-16 15:54:50 +01:00
|
|
|
case 5:
|
2024-01-09 02:21:01 +01:00
|
|
|
return std::unique_ptr<Hanabi::HanabiStateIF>(new Hanabi::HanabiState<5, 5, 4>(deck, actual_score_goal, num_clues_gained_on_discard_or_stack_finished));
|
2023-11-16 15:54:50 +01:00
|
|
|
case 6:
|
2024-01-09 02:21:01 +01:00
|
|
|
return std::unique_ptr<Hanabi::HanabiStateIF>(new Hanabi::HanabiState<6, 5, 4>(deck, actual_score_goal, num_clues_gained_on_discard_or_stack_finished));
|
2023-11-16 15:54:50 +01:00
|
|
|
default:
|
|
|
|
throw std::runtime_error("Invalid number of suits: " + std::to_string(num_suits));
|
|
|
|
}
|
|
|
|
case 6:
|
2023-11-16 16:20:04 +01:00
|
|
|
switch (num_suits)
|
|
|
|
{
|
2023-11-16 15:54:50 +01:00
|
|
|
case 3:
|
2024-01-09 02:21:01 +01:00
|
|
|
return std::unique_ptr<Hanabi::HanabiStateIF>(new Hanabi::HanabiState<3, 6, 3>(deck, actual_score_goal, num_clues_gained_on_discard_or_stack_finished));
|
2023-11-16 15:54:50 +01:00
|
|
|
case 4:
|
2024-01-09 02:21:01 +01:00
|
|
|
return std::unique_ptr<Hanabi::HanabiStateIF>(new Hanabi::HanabiState<4, 6, 3>(deck, actual_score_goal, num_clues_gained_on_discard_or_stack_finished));
|
2023-11-16 15:54:50 +01:00
|
|
|
case 5:
|
2024-01-09 02:21:01 +01:00
|
|
|
return std::unique_ptr<Hanabi::HanabiStateIF>(new Hanabi::HanabiState<5, 6, 3>(deck, actual_score_goal, num_clues_gained_on_discard_or_stack_finished));
|
2023-11-16 15:54:50 +01:00
|
|
|
case 6:
|
2024-01-09 02:21:01 +01:00
|
|
|
return std::unique_ptr<Hanabi::HanabiStateIF>(new Hanabi::HanabiState<6, 6, 3>(deck, actual_score_goal, num_clues_gained_on_discard_or_stack_finished));
|
2023-11-16 15:54:50 +01:00
|
|
|
default:
|
|
|
|
throw std::runtime_error("Invalid number of suits: " + std::to_string(num_suits));
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
throw std::runtime_error("Invalid number of players: " + std::to_string(num_players));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|