Skip to content

Commit

Permalink
more progress on getting tui sorted
Browse files Browse the repository at this point in the history
  • Loading branch information
r3w0p committed May 23, 2024
1 parent e979d4b commit 89ec04a
Show file tree
Hide file tree
Showing 25 changed files with 645 additions and 625 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/building.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ jobs:
os: ubuntu-latest
compiler: clang++

- name: MacOS GCC
os: macos-latest
compiler: g++
#- name: MacOS GCC
# os: macos-latest
# compiler: g++

#- name: MacOS Clang
# os: macos-latest
Expand Down
16 changes: 2 additions & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,6 @@ FetchContent_MakeAvailable(googletest)
# --- caravan libraries
include_directories(include)

add_library(controller
"include/caravan/controller/controller.h"
"include/caravan/controller/controller_tui.h"

"src/caravan/controller/controller.cpp"
"src/caravan/controller/controller_tui.cpp"
)

add_library(core
"include/caravan/core/common.h"
"include/caravan/core/exceptions.h"
Expand All @@ -59,20 +51,18 @@ add_library(model
"include/caravan/model/caravan.h"
"include/caravan/model/deck.h"
"include/caravan/model/game.h"
"include/caravan/model/model.h"
"include/caravan/model/model_tui.h"
"include/caravan/model/player.h"
"include/caravan/model/table.h"

"src/caravan/model/caravan.cpp"
"src/caravan/model/deck.cpp"
"src/caravan/model/game.cpp"
"src/caravan/model/model.cpp"
"src/caravan/model/model_tui.cpp"
"src/caravan/model/player.cpp"
"src/caravan/model/table.cpp"
)

target_link_libraries(model core)

add_library(user
"include/caravan/user/bot_easy.h"
"include/caravan/user/user.h"
Expand All @@ -85,7 +75,6 @@ add_library(view
"include/caravan/view/view.h"
"include/caravan/view/view_tui.h"

"src/caravan/view/view.cpp"
"src/caravan/view/view_tui.cpp"
)

Expand All @@ -102,7 +91,6 @@ add_executable(caravan
)

target_link_libraries(caravan
PRIVATE controller
PRIVATE core
PRIVATE model
PRIVATE user
Expand Down
30 changes: 0 additions & 30 deletions include/caravan/controller/controller.h

This file was deleted.

18 changes: 0 additions & 18 deletions include/caravan/controller/controller_tui.h

This file was deleted.

25 changes: 2 additions & 23 deletions include/caravan/core/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const uint8_t PLAYER_CARAVANS_MAX = 3;
*/

enum PlayerName {
NO_PLAYER, PLAYER_BOTTOM, PLAYER_TOP
NO_PLAYER, PLAYER_ABC, PLAYER_DEF
};
enum Direction {
ANY, ASCENDING, DESCENDING
Expand Down Expand Up @@ -101,16 +101,8 @@ typedef struct GameConfig {
PlayerName pn_first {NO_PLAYER};
} GameConfig;

typedef struct GameOption { // TODO remove
OptionType type {};
uint8_t pos_hand {};
CaravanName caravan_name {};
uint8_t pos_caravan {};
Card card {};
} GameOption;

typedef struct GameCommand {
OptionType type {NO_OPTION};
OptionType option {NO_OPTION};
uint8_t pos_hand {0};
CaravanName caravan_name {NO_CARAVAN};
uint8_t pos_caravan {0};
Expand All @@ -121,19 +113,6 @@ typedef struct GameCommand {
*/

bool is_numeral_card(Card c);

bool is_face_card(Card c);

/*
* CLASSES
*/

template <class T>
class Publisher {
protected:
std::vector<T*> subscribers;
public:
virtual void subscribe(T *sub) = 0;
};

#endif //CARAVAN_CORE_COMMON_H
10 changes: 5 additions & 5 deletions include/caravan/model/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ class Game {

int8_t compare_bids(CaravanName cvname1, CaravanName cvname2);
bool has_sold(CaravanName cvname);
void option_clear(Player *pptr, GameOption* go);
void option_discard(Player *pptr, GameOption* go);
void option_play(Player *pptr, GameOption* go);
void option_clear(Player *pptr, GameCommand* command);
void option_discard(Player *pptr, GameCommand* command);
void option_play(Player *pptr, GameCommand* command);

public:
explicit Game(GameConfig gc);
explicit Game(GameConfig config);

void close();

Expand All @@ -43,7 +43,7 @@ class Game {

bool is_closed();

void play_option(GameOption* go);
void play_option(GameCommand* command);
};

#endif //CARAVAN_MODEL_GAME_H
30 changes: 0 additions & 30 deletions include/caravan/model/model.h

This file was deleted.

18 changes: 0 additions & 18 deletions include/caravan/model/model_tui.h

This file was deleted.

2 changes: 1 addition & 1 deletion include/caravan/user/bot_easy.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class UserBotEasy : public UserBot {
public:
explicit UserBotEasy(PlayerName pn) : UserBot(pn) {};

GameOption generate_option(Game *g) override;
GameCommand generate_option(Game *g) override;
};

#endif //CARAVAN_USER_BOT_EASY_H
2 changes: 1 addition & 1 deletion include/caravan/user/user.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class UserBot : public User {
explicit UserBot(PlayerName pn) : User(pn) {};

bool is_human() override;
virtual GameOption generate_option(Game *g) = 0;
virtual GameCommand generate_option(Game *g) = 0;
};

#endif //CARAVAN_USER_H
24 changes: 10 additions & 14 deletions include/caravan/view/view.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,22 @@
#include "caravan/user/user.h"
#include "caravan/core/common.h"

class ViewSubscriber {
public:
virtual void on_view_user_input(std::string input, bool confirmed) = 0;
};

class View : public Publisher<ViewSubscriber> {
class View {
protected:
User *user_top_ptr;
User *user_bottom_ptr;
User *user_abc;
User *user_def;
Game *game;
bool closed;
public:
virtual ~View() = default;
explicit View(User *utop, User *ubottom) :
user_top_ptr(utop), user_bottom_ptr(ubottom), closed(false) {};
explicit View(User *user_abc, User *user_def, Game *game) :
user_abc(user_abc),
user_def(user_def),
game(game),
closed(false) {};

virtual void run() = 0;
void subscribe(ViewSubscriber *sub) override;
void close() { closed = true; };
virtual void close() = 0;
};



#endif //CARAVAN_VIEW_H
7 changes: 6 additions & 1 deletion include/caravan/view/view_tui.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,15 @@
#include "caravan/core/common.h"

class ViewTUI : public View {
protected:
GameCommand parse_user_input(std::string input, bool confirmed);

public:
explicit ViewTUI(User *utop, User *ubottom) : View(utop, ubottom) {};
explicit ViewTUI(User *user_abc, User *user_def, Game *game) :
View(user_abc, user_def, game) {};

void run() override;
void close() override;
};

#endif //CARAVAN_VIEW_TUI_H
9 changes: 0 additions & 9 deletions src/caravan/controller/controller.cpp

This file was deleted.

Loading

0 comments on commit 89ec04a

Please sign in to comment.