123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- //
- // Created by nositelshtanov on 11/11/2023.
- //
- #include "ttt_meta_session.h"
- #include "ttt_simple_session.h"
- #define TTT_SMPL_VARIANT "1 - play simple tic tac toe"
- #define TTT_META_VARIANT "2 - play meta (super) tic tac toe"
- #define TTT_RULES "coordinate is a number from 0 to 8:\n" \
- "(0) (1) (2)\n" \
- "(3) (4) (5)\n" \
- "(6) (7) (8)\n"
- #define TTT_GAME_KIND "game kind:"
- #define TTT_GAME_KIND_ERR "unknown game type"
- #define TTT_ERROR "sorry, an error was occured\n"
- #define SIMPLE_TTT 1
- #define META_TTT 2
- void print_greeting() {
- std::cout << TTT_RULES << std::endl;
- std::cout << TTT_SMPL_VARIANT << std::endl;
- std::cout << TTT_META_VARIANT << std::endl;
- }
- template <typename sess_type>
- void session_start() {
- sess_type game;
- game.play();
- }
- int main() {
- print_greeting();
- try {
- int game_king;
- std::cout << TTT_GAME_KIND;
- std::cin >> game_king;
- if (game_king == SIMPLE_TTT) {
- session_start<ttt_simple_session>();
- } else if (game_king == META_TTT) {
- session_start<ttt_meta_session>();
- } else {
- std::cout << TTT_GAME_KIND_ERR << std::endl;
- return 1;
- }
- } catch (const std::exception& excp) {
- std::cout << TTT_ERROR << excp.what() << std::endl;
- return 1;
- }
- return 0;
- }
|