Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions config/misc.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
MAX_TURN SALDO_AWAL
15 1000
29 changes: 29 additions & 0 deletions config/property.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
ID KODE NAMA JENIS WARNA HARGA_LAHAN NILAI_GADAI UPG_RUMAH UPG_HT RENT_L0 RENT_L1 RENT_L2 RENT_L3 RENT_L4 RENT_L5
2 GRT GARUT STREET COKLAT 60 40 20 50 2 10 30 90 160 250
4 TSK TASIKMALAYA STREET COKLAT 60 40 50 50 4 20 60 180 320 450
6 GBR STASIUN_GAMBIR RAILROAD DEFAULT 0 20 0 0 0 0 0 0 0 0
7 BGR BOGOR STREET BIRU_MUDA 100 80 20 50 6 30 90 270 400 550
9 DPK DEPOK STREET BIRU_MUDA 100 80 20 50 6 30 90 270 400 550
10 BKS BEKASI STREET BIRU_MUDA 120 90 20 50 8 40 100 300 450 600
12 MGL MAGELANG STREET MERAH_MUDA 140 100 100 100 10 50 150 450 625 750
13 PLN PLN UTILITY ABU_ABU 0 25 0 0 0 0 0 0 0 0
14 SOL SOLO STREET MERAH_MUDA 140 100 100 100 10 50 150 450 625 750
15 YOG YOGYAKARTA STREET MERAH_MUDA 160 120 100 100 12 60 180 500 700 900
16 STB STASIUN_BANDUNG RAILROAD DEFAULT 0 40 0 0 0 0 0 0 0 0
17 MAL MALANG STREET ORANGE 180 135 100 100 14 70 200 550 750 950
19 SMG SEMARANG STREET ORANGE 180 140 100 100 14 70 200 550 750 950
20 SBY SURABAYA STREET ORANGE 200 150 100 100 16 80 220 600 800 1000
22 MKS MAKASSAR STREET MERAH 220 175 150 150 18 90 250 700 875 1050
24 BLP BALIKPAPAN STREET MERAH 220 175 150 150 18 90 250 700 875 1050
25 MND MANADO STREET MERAH 240 190 150 150 20 100 300 750 925 1100
26 TUG STASIUN_TUGU RAILROAD DEFAULT 0 50 0 0 0 0 0 0 0 0
27 PLB PALEMBANG STREET KUNING 260 200 150 150 22 110 330 800 975 1150
28 PKB PEKANBARU STREET KUNING 260 210 150 150 22 110 330 800 975 1150
29 PAM PAM UTILITY ABU_ABU 0 60 0 0 0 0 0 0 0 0
30 MED MEDAN STREET KUNING 280 225 150 150 24 120 360 850 1025 1200
32 BDG BANDUNG STREET HIJAU 300 250 200 200 26 130 390 900 1100 1275
33 DEN DENPASAR STREET HIJAU 300 260 200 200 26 130 390 900 1100 1275
35 MTR MATARAM STREET HIJAU 320 280 200 200 28 150 450 1000 1200 1400
36 GUB STASIUN_GUBENG RAILROAD DEFAULT 0 120 0 0 0 0 0 0 0 0
38 JKT JAKARTA STREET BIRU_TUA 350 300 200 200 35 175 500 1100 1300 1500
40 IKN IBU_KOTA_NUSANTARA STREET BIRU_TUA 400 350 200 200 50 200 600 1400 1700 2000
5 changes: 5 additions & 0 deletions config/railroad.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
JUMLAH_RAILROAD BIAYA_SEWA
1 25
2 50
3 100
4 200
2 changes: 2 additions & 0 deletions config/tax.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
PPH_FLAT PPH_PERSENTASE PBM_FLAT
150 10 200
3 changes: 3 additions & 0 deletions config/utility.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
JUMLAH_UTILITY FAKTOR_PENGALI
1 4
2 10
32 changes: 32 additions & 0 deletions include/core/Board.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#pragma once

#include <map>
#include <string>
#include <vector>

class Player;
class Tile;

class Board {
private:
static std::vector<Tile*> tiles;
static std::map<int, Player*> playerPos;
static int tileCount;
static int goIndex;
static int jailIndex;

public:
Board() = default;

static Tile* getTile(int);
static Tile* getJailTile();
static Tile* goToTile(Tile&, int);
static std::vector<Tile*> getColorGroup(const std::string&);
static bool canBuildHouse(Player, Tile*);
static int getRailroadLevel(Tile*);
static int getUtilityLevel(Tile*);
static Player* getNextPlayer(int currentIndex);
static int stringToIndex(const std::string&);
static Tile* goToTile(const std::string&, int);
static void addTile(Tile*);
};
124 changes: 124 additions & 0 deletions include/core/Card.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
#pragma once

#include <string>
#include <vector>

class Player;

class Card {
protected:
std::string cardName;
std::string cardDescription;

public:
Card(const std::string& cardName, const std::string& cardDescription);
virtual ~Card() = default;

std::string getCardName() const;
std::string getCardDescription() const;
virtual void useCard(Player*, std::vector<Player*>) = 0;
};

enum CARD_TYPE {
AUTO_USE,
SKILL
};

class AutoUseCard : public Card {
private:
CARD_TYPE cardType;
public:
AutoUseCard(const std::string& cardName, const std::string& cardDescription);
virtual ~AutoUseCard() = default;

CARD_TYPE getCardType() const;
void useCard(Player*, std::vector<Player*>) override = 0;
};

class BirthDayCard : public AutoUseCard {
public:
BirthDayCard();
void useCard(Player*, std::vector<Player*>) override;
};

class DoctorCard : public AutoUseCard {
public:
DoctorCard();
void useCard(Player*, std::vector<Player*>) override;
};

class CampaignCard : public AutoUseCard {
public:
CampaignCard();
void useCard(Player*, std::vector<Player*>) override;
};

class NearestStationCard : public AutoUseCard {
public:
NearestStationCard();
void useCard(Player*, std::vector<Player*>) override;
};

class MoveBackCard : public AutoUseCard {
public:
MoveBackCard();
void useCard(Player*, std::vector<Player*>) override;
};

class ToJailCard : public AutoUseCard {
public:
ToJailCard();
void useCard(Player*, std::vector<Player*>) override;
};

class SkillCard : public Card {
public:
SkillCard(const std::string& cardName, const std::string& cardDescription);
virtual ~SkillCard() = default;

CARD_TYPE getCardType() const;
void useCard(Player*, std::vector<Player*>) override = 0;
};

class MoveCard : public SkillCard {
private:
int moveTileMax;

public:
MoveCard(int);
int getMoveTileMax() const;
void setMoveTileMax(int);
void useCard(Player*, std::vector<Player*>) override;
};

class DiscountCard : public SkillCard {
private:
float discount;
public:
DiscountCard(float);
void useCard(Player*, std::vector<Player*>) override;
};

class ShieldCard : public SkillCard {
public:
ShieldCard();
void useCard(Player*, std::vector<Player*>) override;
};

class TeleportCard : public SkillCard {
public:
TeleportCard();
void useCard(Player*, std::vector<Player*>) override;
};

class LassoCard : public SkillCard {
public:
LassoCard();
void useCard(Player*, std::vector<Player*>) override;
};

class DemolitionCard : public SkillCard {
public:
DemolitionCard();
void useCard(Player*, std::vector<Player*>) override;
};
20 changes: 20 additions & 0 deletions include/core/DataManager.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#pragma once

#include <string>

class GameManager;

class DataManager {
private:
std::string configMisc;
std::string configProperty;
std::string configTax;
std::string configUtility;
std::string configRailroad;

public:
DataManager(const std::string&, const std::string&, const std::string&, const std::string&, const std::string&);

void load(GameManager& game);
void save(GameManager& game);
};
26 changes: 26 additions & 0 deletions include/core/Deck.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#pragma once

#include <vector>

class SkillCard;
class AutoUseCard;

template <typename T>
class CardDeck {
private:
std::vector<T*> availableCards;
std::vector<T*> usedCard;

public:
CardDeck() = default;
virtual ~CardDeck() = default;

void addCard(T* card);
void shuffleDeck();
void printDeck() const;
T* topDeck();
T* getRandomCard();
};

extern template class CardDeck<SkillCard>;
extern template class CardDeck<AutoUseCard>;
50 changes: 50 additions & 0 deletions include/core/GameManager.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#pragma once

#include <string>
#include <vector>

#include "Board.hpp"
#include "Card.hpp"
#include "Deck.hpp"
#include "Logger.hpp"

class Player;
class Tile;

class GameManager {
private:
int turn;
int maxTurn;
int activePlayerCount;
int playerCount;
std::vector<Player*> players;
Board board;
CardDeck<SkillCard> deckSkill;
CardDeck<AutoUseCard> deckChance;
CardDeck<AutoUseCard> deckCurrency;
Logger logger;
Player* currentTurnPlayer;
static std::vector<int> dice;

public:
GameManager();
static GameManager& getInstance() {
static GameManager instance;
return instance;
}

bool isGameValid();
void runGame();
void auction(Tile*);
void initBoard();
void initPlayers();
void initStateLogs();
void initSkillDeck();
Board& getBoard() {
return board;
}
const Board& getBoard() const {
return board;
}
Logger& getLogger();
};
39 changes: 39 additions & 0 deletions include/core/Logger.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#pragma once

#include <string>
#include <vector>

class StateLog {
public:
enum ACTION_TYPE {
BUY,
DICE,
USECARD,
GETCARD,
PAYRENT,
PAYTAX
};

private:
int turn;
std::string username;
ACTION_TYPE action;
std::string detail;

public:
StateLog(int, const std::string&, ACTION_TYPE, const std::string&);

int getTurn() const;
std::string getUsername() const;
ACTION_TYPE getAction() const;
std::string getDetail() const;
};

class Logger {
private:
static std::vector<StateLog> logs;

public:
static void log(int, const std::string&, StateLog::ACTION_TYPE, const std::string&);
static void printLog();
};
46 changes: 46 additions & 0 deletions include/core/Player.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#pragma once

#include <string>
#include <vector>
#include "Tile.hpp"
#include "Card.hpp"
#include "Deck.hpp"

using namespace std;

enum PLAYER_STATUS { ACTIVE, BANKRUPT, JAILED };
enum CARD_EFFECT { NOEFFECT, DISCOUNT, SHIELD };

class Player {
private:
string username;
int currency;
PLAYER_STATUS currentStatus;
CardDeck<SkillCard> deck;
Tile* currentTile;
vector<Tile*> ownedProperties;
float discountValue;
int jailTurnCount;
bool canUseCard;
public:
// getter

string getUsername() const { return username; };
int getCurrency() const { return currency; };
PLAYER_STATUS getStatus() const { return currentStatus; };
CardDeck<SkillCard> getDeck() const { return deck; };
Tile* getCurrentTile() const { return currentTile; }
vector<Tile*> getOwnedProperties() const { return ownedProperties; };
float getDiscount() const { return discountValue; };
int getJailTurn() const { return jailTurnCount; };
bool canUseCard() const { return canUseCard; };

// specific method

void buyBackMortgaged(Tile* mortgaged);
Player* operator+=(int money); // untuk proses penambahan currency
Player* operator-=(int money); // untuk proses pengurangan currency
void moveTo(Tile* destination, bool getPayment);
void mortgageProperty(Tile* property); // ubah status Tile jadi mortgaged
void setToJailed();
};
Loading