Skip to content

Commit

Permalink
Ready release 1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
CodePurble committed May 16, 2020
1 parent 65f5b9e commit 2d5b683
Show file tree
Hide file tree
Showing 15 changed files with 312 additions and 120 deletions.
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,24 @@
* Player scores are calculated
* Tile placement validation
* Logging of games

## Version 1.1

#### Breaking Changes
* The build system has been changed to Cmake

#### Bug fixes
* Premium squares are applied only if tiles from the current play are placed on them
* Players prompted only if their racks are not empty, avoiding unplayable game state
* Infinite game loop fixed

#### Feature Updates
* Perform input validation
* Show details of currently made play
* Play confirmation
* Added option to quit the game

#### Minor changes
* Remove lingering debug messages
* Correct board layout

2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ set(SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)

if(CMAKE_BUILD_TYPE MATCHES Debug)
add_definitions(-DLOG_PATH=\"$(HOME)/RPDATA/Repos/scrabble/logs/\")
add_definitions(-DDBG)
add_definitions(-DDEBUG)
else()
add_definitions(-DLOG_PATH=\"$(HOME)/.local/share/rp-scrabble/logs/\")
endif()
Expand Down
17 changes: 13 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
This is a command-line Scrabble game written in C++ to explore object oriented
programming.

# NOTICE for users of `v1.0`
* Users of `v1.0` **MUST** re-install the application as the update to `v1.1` contains breaking changes
* All future updates will conform to these changes

## Build requirements
* `cmake`
* `git`
* `make`
* `g++`
Expand All @@ -19,8 +24,12 @@ programming.
```

* Build

Run the install script with the appropriate argument-
```sh
$ make && make install
$ ./install.sh arch # for Arch based distributions (Manjaro, Void, etc)
$ ./install.sh debian # for Debian based distributions (Ubuntu, Pop_OS, etc)
$ ./install.sh custom # for other distributions
```
* Now, simply running `rp-scrabble` should launch the game.
* If it doesn't launch, check the output of `$ echo $PATH`. If it does not contain `your-home-dir/.local/bin`, add it to your `PATH` like this-
Expand All @@ -30,14 +39,14 @@ programming.
```

## Other notes
* Keep the repo up to date by running `git pull` every once in a while in the project directory. Remember to rebuild again after pulling to bring any changes into effect.
* Keep the repo up to date by running `git pull` every once in a while in the project directory. Remember to rerun the install script after pulling to bring any changes into effect.
* Log files are stored in
```sh
$HOME/.local/share/rp-scrabble/logs
```
* To uninstall, run this command in the project directory
* To uninstall, run the install script with the `uninstall` argument in the project directory
```sh
$ make uninstall
$ ./install.sh uninstall
```
**NOTE** This will also remove any log files created

5 changes: 0 additions & 5 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
# TODO

## Bugs
* Premium squares to be applied only if tiles from the current play are placed on them

## Features
* Perform input validation
* Add option to quit gracefully
* Show details of currently made play
* Add undo, fetch, skip functionality
* Add dictionary for checking words

## Other
* Remove lingering debug messages
Binary file removed assets/scrabble.png
Binary file not shown.
6 changes: 5 additions & 1 deletion include/play.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class Play {
int pointsMade;
Player* playMaker;
std::string playStr;
std::vector<std::vector<Tile*>> wordsInPlay;

public:
Play(Player* p);
Expand All @@ -31,8 +32,11 @@ class Play {
bool validate(std::string tileStr, Board* b, int r, int c, char dir);
std::vector<std::vector<Tile*>> getWords(std::vector<Tile*> tilesInStr, Board* b, int r, int c, char dir);
std::vector<Tile*> getConnectedWord(Tile* t, char dir);
void calculatePoints(std::vector<std::vector<Tile*>> words);
void calculatePoints(std::vector<std::vector<Tile*>> words, std::vector<Tile*> tileStrVec);
int getPointsMade();
bool confirmPlay();
void reset();
void show();
};

#endif
2 changes: 2 additions & 0 deletions include/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@ class Player {
void setName(std::string);
void toggleTurn();
void updateScore(int points);
int getScore();
Tile* tileFromRack(int index);

bool placeTile(Tile* t, Board* b, int r, int c);
std::vector<Tile*> placeTileStr(std::string str, Board* b, int r, int c, char dir);
void draw(int count, Bag* b);
bool rackIsEmpty();
void returnToRack(Tile* t, Board* b);
void show();
};

Expand Down
11 changes: 7 additions & 4 deletions include/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ class Tile;
class Square;
class Play;

#define DEBUG(x, y) std::cout << x << ":" << y << std::endl
#define DEBUG_PRINT(x, y) std::cout << x << ":" << y << std::endl
#define NUM_ROWS 15
#define NUM_COLS 15

const std::string alphabets = "abcdefghijklmnopqrstuvwxyz";

/*
* ANSI escape codes for colour
*
Expand Down Expand Up @@ -94,7 +96,7 @@ inline void RED_BG(std::string x)

inline void PINK_BG(std::string x)
{
std::cout << "\033[48;2;255;77;109m" + x + "\033[0m";
std::cout << "\033[48;2;225;0;109m" + x + "\033[0m";
}

inline void DARK_BLUE_BG(std::string x)
Expand All @@ -117,19 +119,20 @@ inline void OFF_WHITE_BG(std::string x)
*/
inline void TILE_COLOURS(std::string x)
{
std::cout << "\033[1;38;2;0;0;0;48;2;255;236;230m" + x + "\033[0m";
std::cout << "\033[1;38;2;0;0;0;48;2;255;255;255m" + x + "\033[0m";
}

inline void BOARD_COLOURS(std::string x)
{
std::cout << "\033[1;38;2;232;232;232;48;2;104;0;13m" + x + "\033[0m";
std::cout << "\033[1;38;2;232;232;232;48;2;77;0;9m" + x + "\033[0m";
}

/*
* Other helper functions
*/
bool squarePresent(std::vector<Square*> s, Square* target);
bool tilePresent(std::vector<Tile*> t, Tile* target);
bool charPresent(std::string str, char target);
std::vector<std::string> parsePlay(std::string in);
void log(std::string logFilePath, std::string str);
std::string RawTimeToString(const time_t& t);
Expand Down
4 changes: 1 addition & 3 deletions src/bag.cc
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,7 @@ void Bag::show()
for(Tile* i : bag) {
cout << i->getLetter();
}
cout << "\n";
BOLD(" " + to_string(bag.size()));
cout << " tiles remaining\n";
BOLD(" (" + to_string(bag.size()) + " tiles remaining)\n");
}

void Bag::shuffle()
Expand Down
2 changes: 1 addition & 1 deletion src/board.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ using namespace std;
Board::Board()
{
enum_sqType quarterBoard[7][7] = {
{ TWS, N , N , DWS, N , N , N },
{ TWS, N , N , DLS, N , N , N },
{ N , DWS, N , N , N , TLS, N },
{ N , N , DWS, N , N , N , DLS },
{ DLS, N , N , DWS, N , N , N },
Expand Down
Loading

0 comments on commit 2d5b683

Please sign in to comment.