Skip to content
Open

Dev #45

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
06156ec
feat: Add generics
SomeonesDads Apr 16, 2026
176b089
feat: Add Core Containers
SomeonesDads Apr 16, 2026
955e77f
feat: Add Abstract for property
SomeonesDads Apr 16, 2026
b5d3238
move files
SomeonesDads Apr 21, 2026
d29b2f9
move files
SomeonesDads Apr 21, 2026
a43daaa
feat: add rest of configs
SomeonesDads Apr 21, 2026
ea475ac
feat: add logger
SomeonesDads Apr 21, 2026
fff201e
move files
SomeonesDads Apr 21, 2026
7ce8fe0
feat: add carddeck
SomeonesDads Apr 21, 2026
ffe723a
feat: Add tiles classes
SomeonesDads Apr 21, 2026
0fb6063
feat: Add player class
SomeonesDads Apr 21, 2026
9dcbf10
feat: implement player
SomeonesDads Apr 21, 2026
97eb018
feat: Add centralized money management
SomeonesDads Apr 21, 2026
1dae191
feat: add Board
SomeonesDads Apr 21, 2026
32af170
feat: add Dice class
SomeonesDads Apr 21, 2026
9137706
feat: Add main Game class
SomeonesDads Apr 21, 2026
0117545
feat: Add save/load
SomeonesDads Apr 21, 2026
1da0c12
feat: add UI elements
SomeonesDads Apr 21, 2026
f457bd1
feat: add entry point
SomeonesDads Apr 21, 2026
77eae1d
refactor: capitalization mistakes
SomeonesDads Apr 21, 2026
4017a0a
refactor: fixed capitalized includes
SomeonesDads Apr 21, 2026
262ff56
feat: add makefile
SomeonesDads Apr 21, 2026
f980ad0
salah file
SomeonesDads Apr 21, 2026
2a399a9
feat: makefile + readme
SomeonesDads Apr 21, 2026
7754f6e
refactor: ngubah struct ke class
SomeonesDads Apr 21, 2026
4f296e5
Update README.md
SomeonesDads Apr 21, 2026
8e44f54
fix: typos
SomeonesDads Apr 21, 2026
43b0a5e
fix: add missing std:: prefix
SomeonesDads Apr 21, 2026
7d1d226
feat: implemented game.cpp
SomeonesDads Apr 21, 2026
a5b4630
Merge branch 'main' of https://github.com/Labpro-22/tugas-besar-1-omb
SomeonesDads Apr 21, 2026
3709b2d
Update README formatting and content
SomeonesDads Apr 21, 2026
631a7f9
feat: Add bin and config
MikhaelBenrael Apr 22, 2026
cd6cdc2
chore: added a space
ravasrgh Apr 22, 2026
a8e8d2e
refactor: put property logic from game.cpp into property.cpp
MikhaelBenrael Apr 23, 2026
bfc5bb4
fix: changed logic of turnOver for dice
MikhaelBenrael Apr 23, 2026
50f3a40
fix: bug (print out dice roll, print out auto purchase, random player…
MikhaelBenrael Apr 23, 2026
d8c75b0
refactor: put player logic from game.cpp into player.cpp
ravasrgh Apr 23, 2026
c1bfe48
Merge remote-tracking branch 'origin/main' into refactor/player
ravasrgh Apr 23, 2026
9ce1c8a
Merge pull request #2 from Labpro-22/refactor/player
SomeonesDads Apr 23, 2026
2235c0a
merge: player board and property refactor
MikhaelBenrael Apr 23, 2026
bd3b8e1
refactor: many things in game.cpp (property n player)
MikhaelBenrael Apr 23, 2026
a371afe
Refactor: implemen polymorpishm di card instead of switch case enum, …
Sakazu01 Apr 23, 2026
2404867
fix: jail - wrong card error message and forced pay on 4th turn
ziyanagil Apr 24, 2026
49945e9
fix: auto end turn after roll, jail options, card type print, auction…
ziyanagil Apr 24, 2026
31a05b0
fix: auction passes needed for 2-player bid
ziyanagil Apr 24, 2026
477f247
fix: triple double sends to jail and ends turn immediately
ziyanagil Apr 24, 2026
6d2e8d9
fix: expose lastJailWasTripleDouble for triple double jail detection
ziyanagil Apr 24, 2026
07e9d82
fix: savemanager header update
ziyanagil Apr 24, 2026
c5fe4ad
fix: boardprinter header update
ziyanagil Apr 24, 2026
d4eb3df
fix: savemanager implementation update
ziyanagil Apr 24, 2026
b44f75f
fix: board print format improvement
ziyanagil Apr 24, 2026
05f933e
Merge pull request #7 from Labpro-22/refactore/cards-new
SomeonesDads Apr 24, 2026
ee9bcb8
Merge pull request #8 from Labpro-22/fix/gameplay
MikhaelBenrael Apr 24, 2026
6484441
fix: inisialisasi deck di savemanager.cpp
MikhaelBenrael Apr 24, 2026
29b242c
fix: change turn logic
MikhaelBenrael Apr 24, 2026
2dde03b
feat: add auctionmanager class
SomeonesDads Apr 26, 2026
5d8e71b
refactor: moved functions from game
SomeonesDads Apr 26, 2026
7aa456e
refactor: transactionlog is now static
SomeonesDads Apr 26, 2026
c671548
fix: 'akta kepemilikan' print format
ziyanagil Apr 26, 2026
07d337e
Merge pull request #9 from Labpro-22/fix/gameplay
ziyanagil Apr 26, 2026
cbd35b1
refactor: separate auctionmanager implementation from header
ziyanagil Apr 26, 2026
6e3b0ab
feat: add transactionlogger
ziyanagil Apr 26, 2026
ffce1aa
fix: add iostream include and FreeParkingTile landing message
ziyanagil Apr 26, 2026
24f315d
fix: add informative landing messages for all tile types
ziyanagil Apr 26, 2026
79ddf53
fix: print movement, GO salary, and jail messages to console
ziyanagil Apr 26, 2026
45defa3
fix: print rent details and purchase confirmation to console
ziyanagil Apr 26, 2026
8e66ca1
fix: print card effect results for chance, community, and skill cards
ziyanagil Apr 26, 2026
9f16420
fix: print PBM tax deduction result and triple-double jail logic
ziyanagil Apr 26, 2026
99815d2
fix: remove redundant landing message and update autopurchase callback
ziyanagil Apr 26, 2026
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
160 changes: 157 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,158 @@
[![Review Assignment Due Date](https://classroom.github.com/assets/deadline-readme-button-22041afd0340ce965d47ae6ef1cefeee28c7c493a6346c4f15d667ab976d596c.svg)](https://classroom.github.com/a/b842RB8g)
# Tugas Besar 1 IF2010 Pemrograman Berorientasi Objek
# Nimonspoli **IF2010 Pemrograman Berorientasi Objek Tugas Besar 1**

Project Structure ini hanyalah referensi, Anda dapat menyesuaikannya dengan kebutuhan tim Anda
## Deskripsi

Nimonspoli adalah permainan papan (board game) bertema monopoli yang memungkinkan 2–4 pemain untuk saling berkompetisi dalam membeli properti, membayar sewa, mengikuti lelang, dan mengelola kekayaan. Permainan ini mensimulasikan seluruh mekanisme permainan monopoli, termasuk kartu kemampuan spesial, efek festival, sistem gadai, dan mekanisme kebangkrutan.

## Fitur Utama

- **Papan 40 petak** dengan properti, stasiun, utilitas, dan petak aksi
- **2–4 pemain** dengan urutan giliran acak
- **Sistem dadu** (random & manual via `ATUR_DADU`)
- **Kepemilikan properti**: Street (beli/lelang), Railroad & Utility (otomatis)
- **Pembangunan rumah & hotel** dengan aturan pemerataan color group
- **Sistem lelang** otomatis saat pemain menolak/tidak mampu membeli
- **Pajak** (PPH dengan opsi flat/persentase, PBM flat)
- **Festival** — melipatgandakan sewa properti hingga 8x
- **6 jenis Kartu Kemampuan Spesial**: MoveCard, DiscountCard, ShieldCard, TeleportCard, LassoCard, DemolitionCard
- **Kartu Kesempatan & Dana Umum**
- **Sistem Gadai & Tebus**
- **Mekanisme kebangkrutan & likuidasi aset**
- **Save/Load** ke file teks terstruktur
- **Transaction Logger** — mencatat semua kejadian dalam permainan
- **Papan berwarna** dengan ANSI color codes

---

## Struktur Proyek
```
tugas-besar-1-omb/
├── config/ # File konfigurasi permainan
│ ├── property.txt
│ ├── railroad.txt
│ ├── utility.txt
│ ├── tax.txt
│ ├── special.txt
│ └── misc.txt
├── include/ # Header files
│ ├── core/ # Game logic layer
│ │ ├── bank.h
│ │ ├── board.h
│ │ ├── carddeck.h # Generic class CardDeck<T>
│ │ ├── cards.h
│ │ ├── config.h
│ │ ├── dice.h
│ │ ├── festivaleffect.h
│ │ ├── game.h
│ │ ├── player.h
│ │ ├── property.h
│ │ ├── propertytypes.h
│ │ ├── tiles.h
│ │ ├── transactionlogger.h
│ │ └── types.h
│ ├── data/ # Data access layer
│ │ ├── configloader.h
│ │ └── savemanager.h
│ └── ui/ # User interaction layer
│ ├── boardprinter.h
│ └── gameCLI.h
├── src/ # Source files
│ ├── core/
│ │ ├── board.cpp
│ │ ├── cards.cpp
│ │ ├── player.cpp
│ │ ├── tiles.cpp
│ │ └── transactionlogger.cpp
│ ├── data/
│ │ ├── configloader.cpp
│ │ └── savemanager.cpp
│ ├── ui/
│ │ ├── boardprinter.cpp
│ │ └── gamecli.cpp
│ └── main.cpp
├── data/ # Save files (runtime)
├── makefile
└── README.md
```
---

## Arsitektur (Layered Architecture)

Program mengimplementasikan **3-layer architecture**:

| Layer | Direktori | Tanggung Jawab |
|-------|-----------|----------------|
| **UI Layer** | `include/ui/`, `src/ui/` | Input/output ke terminal (`GameCLI`, `BoardPrinter`) |
| **Core Layer** | `include/core/`, `src/core/` | Aturan permainan, state management (`Game`, `Board`, `Player`, `Tile`, `Card`, `Dice`, `Bank`) |
| **Data Layer** | `include/data/`, `src/data/` | Baca/tulis file konfigurasi dan save/load (`ConfigLoader`, `SaveManager`) |


## Konsep OOP yang Diimplementasikan

| # | Konsep | Implementasi |
|---|--------|--------------|
| 1 | **Inheritance & Polymorphism** | `Tile` → `PropertyTile`, `GoTile`, `JailTile`, dll. `Card` → `ChanceCard`, `CommunityCard`, `SkillCard` → 6 subclass. `Property` → `Street`, `Railroad`, `Utility` |
| 2 | **Exception Handling** | Validasi uang, slot kartu, input, file I/O dengan `try/catch` dan `throw` |
| 3 | **Operator Overloading** | `Player::operator+=/-=` untuk uang, `operator</>/` untuk perbandingan kekayaan |
| 4 | **Abstract Class & Virtual Function** | `Tile::onLanded()`, `Card::execute()`, `Property::calcRent()`, `SkillCard::use()` |
| 5 | **Generic Class (Template)** | `CardDeck<T>` untuk tumpukan kartu Chance, Community, dan Skill |
| 6 | **STL** | `vector` (pemain, petak, kartu), `map` (properti, rent table, multiplier table) |


## Prasyarat

- **Compiler**: `g++` dengan dukungan C++17
- **OS**: Linux / WSL / macOS
- **Tools**: `make`


## Cara Kompilasi & Menjalankan

```bash
# Kompilasi
make

# Jalankan
make run

# Bersihkan file hasil kompilasi
make clean

# Rebuild dari awal
make rebuild

# Kalau dari windows, ke root
g++ -Wall -Wextra -std=c++17 -I include (Get-ChildItem -Path src -Recurse -Filter *.cpp | ForEach-Object { $_.FullName }) -o bin/game.exe
.\bin\game.exe
```

## Daftar Perintah

| Perintah | Deskripsi |
|----------|-----------|
| `CETAK_PAPAN` | Tampilkan papan permainan |
| `LEMPAR_DADU` | Lempar dadu secara acak |
| `ATUR_DADU X Y` | Atur dadu manual (1–6) |
| `CETAK_AKTA [KODE]` | Tampilkan akta kepemilikan properti |
| `CETAK_PROPERTI` | Tampilkan properti milik pemain |
| `GADAI` | Gadaikan properti |
| `TEBUS` | Tebus properti yang digadaikan |
| `BANGUN` | Bangun rumah/hotel |
| `GUNAKAN_KEMAMPUAN` | Gunakan kartu kemampuan spesial |
| `BAYAR_DENDA` | Bayar denda keluar penjara |
| `SIMPAN [FILE]` | Simpan permainan ke file |
| `MUAT [FILE]` | Muat permainan dari file |
| `CETAK_LOG [N]` | Tampilkan N log terakhir |
| `SELESAI` | Akhiri giliran |
| `BANTUAN` | Tampilkan daftar perintah |


## Anggota Kelompok

| NIM | Nama |
|-----|------|
| — | — |
| — | — |
| — | — |
| — | — |
| — | — |
15 changes: 15 additions & 0 deletions config/aksi.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
aksi.txt
ID KODE NAMA JENIS_PETAK WARNA
1 GO Petak_Mulai SPESIAL DEFAULT
3 DNU Dana_Umum KARTU DEFAULT
5 PPH Pajak_Penghasilan PAJAK DEFAULT
8 FES Festival FESTIVAL DEFAULT
11 PEN Penjara SPESIAL DEFAULT
18 DNU Dana_Umum KARTU DEFAULT
21 BBP Bebas_Parkir SPESIAL DEFAULT
23 KSP Kesempatan KARTU DEFAULT
31 PPJ Petak_Pergi_ke_Penjara SPESIAL DEFAULT
34 FES Festival FESTIVAL DEFAULT
37 KSP Kesempatan KARTU DEFAULT
39 PBM Pajak_Barang_Mewah PAJAK DEFAULT

3 changes: 3 additions & 0 deletions config/misc.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
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_L5
2 GRT GARUT STREET COKLAT 60 40 20 50 2 … 250
4 TSK TASIKMALAYA STREET COKLAT 60 40 50 50 4 … 320
6 GBR STASIUN_GAMBIR RAILROAD DEFAULT 0 20
7 BGR BOGOR STREET BIRU_MUDA 100 80 20 50 6 … 400
9 DPK DEPOK STREET BIRU_MUDA 100 80 20 50 6 … 400
10 BKS BEKASI STREET BIRU_MUDA 120 90 20 50 8 … 450
12 MGL MAGELANG STREET MERAH_MUDA 140 100 100 100 10 … 750
13 PLN PLN UTILITY ABU_ABU 0 25
14 SOL SOLO STREET MERAH_MUDA 140 100 100 100 10 50 … 750
15 YOG YOGYAKARTA STREET MERAH_MUDA 160 120 100 100 12 … 900
16 STB STASIUN_BANDUNG RAILROAD DEFAULT 0 40
17 MAL MALANG STREET ORANGE 180 135 100 100 14 … 950
19 SMG SEMARANG STREET ORANGE 180 140 100 100 14 … 950
20 SBY SURABAYA STREET ORANGE 200 150 100 100 16 … 1000
22 MKS MAKASSAR STREET MERAH 220 175 150 150 18 … 1050
24 BLP BALIKPAPAN STREET MERAH 220 175 150 150 18 … 1050
25 MND MANADO STREET MERAH 240 190 150 150 20 … 1100
26 TUG STASIUN_TUGU RAILROAD DEFAULT 0 50
27 PLB PALEMBANG STREET KUNING 260 200 150 150 22 … 1150
28 PKB PEKANBARU STREET KUNING 260 210 150 150 22 … 1150
29 PAM PAM UTILITY ABU_ABU 0 60
30 MED MEDAN STREET KUNING 280 225 150 150 24 … 1200
32 BDG BANDUNG STREET HIJAU 300 250 200 200 26 … 1275
33 DEN DENPASAR STREET HIJAU 300 260 200 200 26 … 1275
35 MTR MATARAM STREET HIJAU 320 280 200 200 28 … 1400
36 GUB STASIUN_GUBENG RAILROAD DEFAULT 0 120
38 JKT JAKARTA STREET BIRU_TUA 350 300 200 200 35 … 1500
40 IKN IBU_KOTA_NUSANTARA STREET BIRU_TUA 400 350 200 200 50 … 2000
6 changes: 6 additions & 0 deletions config/railroad.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
JUMLAH_RAILROAD BIAYA_SEWA
1 25
2 50
3 100
4 200

3 changes: 3 additions & 0 deletions config/special.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
GO_SALARY JAIL_FINE
200 50

3 changes: 3 additions & 0 deletions config/tax.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
PPH_FLAT PPH_PERSENTASE PBM_FLAT
150 10 200

4 changes: 4 additions & 0 deletions config/utility.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
JUMLAH_UTILITY FAKTOR_PENGALI
1 4
2 10

43 changes: 43 additions & 0 deletions include/core/auctionmanager.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#pragma once
#include <vector>
#include "core/player.h"
#include "core/property.h"
#include "core/game.h"

namespace Nimonspoli {

class AuctionManager {
public:
AuctionManager(Property& prop, const std::vector<Player*>& order, int passesNeeded, Game& game);

Player* currentPlayer() const;
void processBid(int amount);
void processPass();

bool isFinished() const { return finished_; }
bool isFailed() const { return failed_; }
Player* winner() const { return winner_; }
int highBid() const { return highBid_; }
Property& property() const { return prop_; }

void finalizeAuction(Game& game);
void resetForRetry();

private:
void checkState();

Property& prop_;
Game& game_;
std::vector<Player*> order_;
int passesNeeded_;

int highBid_ = 0;
Player* winner_ = nullptr;
int passCount_ = 0;
size_t idx_ = 0;

bool finished_ = false;
bool failed_ = false;
};

} // namespace Nimonspoli
17 changes: 17 additions & 0 deletions include/core/bank.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#pragma once
#include "core/player.h"
using namespace std;
namespace Nimonspoli {

// Dari sini semua transaksi biar gampang dilog, itu aja sebenarnya
class Bank {
public:
void pay(Player& player, int amount) {player += amount;}
void collect(Player& player, int amount) {player -= amount;}
void transfer(Player& from, Player& to, int amount) {
from -= amount;
to += amount;
}
};

}
57 changes: 57 additions & 0 deletions include/core/board.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#pragma once
#include <vector>
#include <map>
#include <string>
#include <memory>
#include "core/tiles.h"
#include "core/property.h"
#include "core/propertytypes.h"
using namespace std;
namespace Nimonspoli {

class Player;

class Board {
public:
static constexpr int BOARD_SIZE = 40;

void addTile(unique_ptr<Tile> tile);
void addProperty(unique_ptr<Property> prop);

Tile* getTile(int index) const;
Property* getProperty(const string& code) const;
int size() const { return static_cast<int>(tiles_.size()); }

const vector<unique_ptr<Tile>>& tiles() const { return tiles_; }
const map<string, unique_ptr<Property>>& properties() const { return properties_; }

int advance(int currentPos, int steps) const {
return (currentPos + steps) % size();
}

int nearestRailroad(int currentPos) const;

// Call setiap perubahan owner
void recalcMonopoly(Player* player);
void recalcRailroadCount(Player* player);
void recalcUtilityCount(Player* player);

vector<Street*> colorGroupStreets(ColorGroup cg) const;
vector<Railroad*> railroadsOf(Player* player) const;
vector<Utility*> utilitiesOf(Player* player) const;

void tickFestivals(Player* player);

vector<Player*> auctionOrder(Player* trigger, const vector<Player*>& activePlayers) const;

int auctionPassesNeeded(const vector<Player*>& auctionParticipants) const;
int findTileIndex(TileType type) const;

string tileDescription(int index) const;

private:
vector<unique_ptr<Tile>> tiles_;
map<string, unique_ptr<Property>> properties_;
};

}
Loading