├── Chance ├── chance0.png ├── chance1.png ├── chance2.png ├── chance3.png ├── chance4.png ├── chance5.png ├── chance6.png ├── chance7.png ├── chance8.png ├── chance9.png └── chanceTemplate.jpg ├── Community Chest ├── .DS_Store ├── community0.png ├── community1.png ├── community2.png ├── community3.png ├── community4.png ├── community5.png ├── community6.png ├── community7.png ├── community8.png ├── community9.png └── communityTemplate.jpg ├── Dice ├── Dice.pro ├── Makefile ├── dice1.png ├── dice2.png ├── dice3.png ├── dice4.png ├── dice5.png └── dice6.png ├── Game_Board.cpp ├── Game_Board.h ├── Images └── Monopoly.jpg ├── Pieces ├── barrow.png ├── baseball.png ├── car.png ├── dog.png ├── dragon.png ├── hat.png ├── pretzel.png ├── ship.png ├── soccer.png ├── surfer.png └── thimble.png ├── README.md ├── action.cpp ├── action.h ├── bank.cpp ├── bank.h ├── boardgame.cpp ├── bottomBar.cpp ├── bottomBar.h ├── card.cpp ├── card.h ├── card_money.cpp ├── card_money.h ├── card_move.cpp ├── card_move.h ├── centralwidget.cpp ├── centralwidget.h ├── dice.cpp ├── dice.h ├── goToAction.cpp ├── goToAction.h ├── guiplayers.cpp ├── guiplayers.h ├── mainwindow.cpp ├── mainwindow.h ├── money_action.cpp ├── money_action.h ├── move_action.cpp ├── move_action.h ├── player.cpp ├── player.h ├── space.cpp ├── space.h └── textbox.h /Chance/chance0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/otherchen/Monopoly/3bd5e522ccffcf8ee982a8844c598d78f113e9ef/Chance/chance0.png -------------------------------------------------------------------------------- /Chance/chance1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/otherchen/Monopoly/3bd5e522ccffcf8ee982a8844c598d78f113e9ef/Chance/chance1.png -------------------------------------------------------------------------------- /Chance/chance2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/otherchen/Monopoly/3bd5e522ccffcf8ee982a8844c598d78f113e9ef/Chance/chance2.png -------------------------------------------------------------------------------- /Chance/chance3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/otherchen/Monopoly/3bd5e522ccffcf8ee982a8844c598d78f113e9ef/Chance/chance3.png -------------------------------------------------------------------------------- /Chance/chance4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/otherchen/Monopoly/3bd5e522ccffcf8ee982a8844c598d78f113e9ef/Chance/chance4.png -------------------------------------------------------------------------------- /Chance/chance5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/otherchen/Monopoly/3bd5e522ccffcf8ee982a8844c598d78f113e9ef/Chance/chance5.png -------------------------------------------------------------------------------- /Chance/chance6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/otherchen/Monopoly/3bd5e522ccffcf8ee982a8844c598d78f113e9ef/Chance/chance6.png -------------------------------------------------------------------------------- /Chance/chance7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/otherchen/Monopoly/3bd5e522ccffcf8ee982a8844c598d78f113e9ef/Chance/chance7.png -------------------------------------------------------------------------------- /Chance/chance8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/otherchen/Monopoly/3bd5e522ccffcf8ee982a8844c598d78f113e9ef/Chance/chance8.png -------------------------------------------------------------------------------- /Chance/chance9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/otherchen/Monopoly/3bd5e522ccffcf8ee982a8844c598d78f113e9ef/Chance/chance9.png -------------------------------------------------------------------------------- /Chance/chanceTemplate.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/otherchen/Monopoly/3bd5e522ccffcf8ee982a8844c598d78f113e9ef/Chance/chanceTemplate.jpg -------------------------------------------------------------------------------- /Community Chest/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/otherchen/Monopoly/3bd5e522ccffcf8ee982a8844c598d78f113e9ef/Community Chest/.DS_Store -------------------------------------------------------------------------------- /Community Chest/community0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/otherchen/Monopoly/3bd5e522ccffcf8ee982a8844c598d78f113e9ef/Community Chest/community0.png -------------------------------------------------------------------------------- /Community Chest/community1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/otherchen/Monopoly/3bd5e522ccffcf8ee982a8844c598d78f113e9ef/Community Chest/community1.png -------------------------------------------------------------------------------- /Community Chest/community2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/otherchen/Monopoly/3bd5e522ccffcf8ee982a8844c598d78f113e9ef/Community Chest/community2.png -------------------------------------------------------------------------------- /Community Chest/community3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/otherchen/Monopoly/3bd5e522ccffcf8ee982a8844c598d78f113e9ef/Community Chest/community3.png -------------------------------------------------------------------------------- /Community Chest/community4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/otherchen/Monopoly/3bd5e522ccffcf8ee982a8844c598d78f113e9ef/Community Chest/community4.png -------------------------------------------------------------------------------- /Community Chest/community5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/otherchen/Monopoly/3bd5e522ccffcf8ee982a8844c598d78f113e9ef/Community Chest/community5.png -------------------------------------------------------------------------------- /Community Chest/community6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/otherchen/Monopoly/3bd5e522ccffcf8ee982a8844c598d78f113e9ef/Community Chest/community6.png -------------------------------------------------------------------------------- /Community Chest/community7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/otherchen/Monopoly/3bd5e522ccffcf8ee982a8844c598d78f113e9ef/Community Chest/community7.png -------------------------------------------------------------------------------- /Community Chest/community8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/otherchen/Monopoly/3bd5e522ccffcf8ee982a8844c598d78f113e9ef/Community Chest/community8.png -------------------------------------------------------------------------------- /Community Chest/community9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/otherchen/Monopoly/3bd5e522ccffcf8ee982a8844c598d78f113e9ef/Community Chest/community9.png -------------------------------------------------------------------------------- /Community Chest/communityTemplate.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/otherchen/Monopoly/3bd5e522ccffcf8ee982a8844c598d78f113e9ef/Community Chest/communityTemplate.jpg -------------------------------------------------------------------------------- /Dice/Dice.pro: -------------------------------------------------------------------------------- 1 | ###################################################################### 2 | # Automatically generated by qmake (2.01a) Thu May 1 12:18:05 2014 3 | ###################################################################### 4 | 5 | TEMPLATE = subdirs 6 | 7 | # Directories 8 | -------------------------------------------------------------------------------- /Dice/Makefile: -------------------------------------------------------------------------------- 1 | ############################################################################# 2 | # Makefile for building: Dice 3 | # Generated by qmake (2.01a) (Qt 4.8.1) on: Thu May 1 12:18:06 2014 4 | # Project: Dice.pro 5 | # Template: subdirs 6 | # Command: /usr/bin/qmake -o Makefile Dice.pro 7 | ############################################################################# 8 | 9 | first: make_default 10 | MAKEFILE = Makefile 11 | QMAKE = /usr/bin/qmake 12 | DEL_FILE = rm -f 13 | CHK_DIR_EXISTS= test -d 14 | MKDIR = mkdir -p 15 | COPY = cp -f 16 | COPY_FILE = $(COPY) 17 | COPY_DIR = $(COPY) -r 18 | INSTALL_FILE = install -m 644 -p 19 | INSTALL_PROGRAM = install -m 755 -p 20 | INSTALL_DIR = $(COPY_DIR) 21 | DEL_FILE = rm -f 22 | SYMLINK = ln -f -s 23 | DEL_DIR = rmdir 24 | MOVE = mv -f 25 | CHK_DIR_EXISTS= test -d 26 | MKDIR = mkdir -p 27 | SUBTARGETS = 28 | 29 | 30 | Makefile: Dice.pro /usr/share/qt4/mkspecs/linux-g++-64/qmake.conf /usr/share/qt4/mkspecs/common/unix.conf \ 31 | /usr/share/qt4/mkspecs/common/linux.conf \ 32 | /usr/share/qt4/mkspecs/common/gcc-base.conf \ 33 | /usr/share/qt4/mkspecs/common/gcc-base-unix.conf \ 34 | /usr/share/qt4/mkspecs/common/g++-base.conf \ 35 | /usr/share/qt4/mkspecs/common/g++-unix.conf \ 36 | /usr/share/qt4/mkspecs/qconfig.pri \ 37 | /usr/share/qt4/mkspecs/modules/qt_webkit_version.pri \ 38 | /usr/share/qt4/mkspecs/features/qt_functions.prf \ 39 | /usr/share/qt4/mkspecs/features/qt_config.prf \ 40 | /usr/share/qt4/mkspecs/features/exclusive_builds.prf \ 41 | /usr/share/qt4/mkspecs/features/default_pre.prf \ 42 | /usr/share/qt4/mkspecs/features/release.prf \ 43 | /usr/share/qt4/mkspecs/features/default_post.prf \ 44 | /usr/share/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \ 45 | /usr/share/qt4/mkspecs/features/warn_on.prf \ 46 | /usr/share/qt4/mkspecs/features/qt.prf \ 47 | /usr/share/qt4/mkspecs/features/unix/thread.prf \ 48 | /usr/share/qt4/mkspecs/features/moc.prf \ 49 | /usr/share/qt4/mkspecs/features/resources.prf \ 50 | /usr/share/qt4/mkspecs/features/uic.prf \ 51 | /usr/share/qt4/mkspecs/features/yacc.prf \ 52 | /usr/share/qt4/mkspecs/features/lex.prf \ 53 | /usr/share/qt4/mkspecs/features/include_source_dir.prf 54 | $(QMAKE) -o Makefile Dice.pro 55 | /usr/share/qt4/mkspecs/common/unix.conf: 56 | /usr/share/qt4/mkspecs/common/linux.conf: 57 | /usr/share/qt4/mkspecs/common/gcc-base.conf: 58 | /usr/share/qt4/mkspecs/common/gcc-base-unix.conf: 59 | /usr/share/qt4/mkspecs/common/g++-base.conf: 60 | /usr/share/qt4/mkspecs/common/g++-unix.conf: 61 | /usr/share/qt4/mkspecs/qconfig.pri: 62 | /usr/share/qt4/mkspecs/modules/qt_webkit_version.pri: 63 | /usr/share/qt4/mkspecs/features/qt_functions.prf: 64 | /usr/share/qt4/mkspecs/features/qt_config.prf: 65 | /usr/share/qt4/mkspecs/features/exclusive_builds.prf: 66 | /usr/share/qt4/mkspecs/features/default_pre.prf: 67 | /usr/share/qt4/mkspecs/features/release.prf: 68 | /usr/share/qt4/mkspecs/features/default_post.prf: 69 | /usr/share/qt4/mkspecs/features/unix/gdb_dwarf_index.prf: 70 | /usr/share/qt4/mkspecs/features/warn_on.prf: 71 | /usr/share/qt4/mkspecs/features/qt.prf: 72 | /usr/share/qt4/mkspecs/features/unix/thread.prf: 73 | /usr/share/qt4/mkspecs/features/moc.prf: 74 | /usr/share/qt4/mkspecs/features/resources.prf: 75 | /usr/share/qt4/mkspecs/features/uic.prf: 76 | /usr/share/qt4/mkspecs/features/yacc.prf: 77 | /usr/share/qt4/mkspecs/features/lex.prf: 78 | /usr/share/qt4/mkspecs/features/include_source_dir.prf: 79 | qmake: qmake_all FORCE 80 | @$(QMAKE) -o Makefile Dice.pro 81 | 82 | qmake_all: FORCE 83 | 84 | make_default: FORCE 85 | make_first: FORCE 86 | all: FORCE 87 | clean: FORCE 88 | distclean: FORCE 89 | -$(DEL_FILE) Makefile 90 | install_subtargets: FORCE 91 | uninstall_subtargets: FORCE 92 | 93 | check: 94 | 95 | mocclean: compiler_moc_header_clean compiler_moc_source_clean 96 | 97 | mocables: compiler_moc_header_make_all compiler_moc_source_make_all 98 | install: install_subtargets FORCE 99 | 100 | uninstall: uninstall_subtargets FORCE 101 | 102 | FORCE: 103 | 104 | -------------------------------------------------------------------------------- /Dice/dice1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/otherchen/Monopoly/3bd5e522ccffcf8ee982a8844c598d78f113e9ef/Dice/dice1.png -------------------------------------------------------------------------------- /Dice/dice2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/otherchen/Monopoly/3bd5e522ccffcf8ee982a8844c598d78f113e9ef/Dice/dice2.png -------------------------------------------------------------------------------- /Dice/dice3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/otherchen/Monopoly/3bd5e522ccffcf8ee982a8844c598d78f113e9ef/Dice/dice3.png -------------------------------------------------------------------------------- /Dice/dice4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/otherchen/Monopoly/3bd5e522ccffcf8ee982a8844c598d78f113e9ef/Dice/dice4.png -------------------------------------------------------------------------------- /Dice/dice5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/otherchen/Monopoly/3bd5e522ccffcf8ee982a8844c598d78f113e9ef/Dice/dice5.png -------------------------------------------------------------------------------- /Dice/dice6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/otherchen/Monopoly/3bd5e522ccffcf8ee982a8844c598d78f113e9ef/Dice/dice6.png -------------------------------------------------------------------------------- /Game_Board.cpp: -------------------------------------------------------------------------------- 1 | #include "Game_Board.h" 2 | #include 3 | #include 4 | 5 | Game_Board::Game_Board(){ 6 | 7 | //Use functions in Space class to initialize each space 8 | 9 | //Space 0 10 | spaces[0].setName(" GO! ", " "); 11 | spaces[0].setType("START"); 12 | spaces[0].setPropertyCost(0); 13 | spaces[0].setFreeParking(0); 14 | spaces[0].setOccupied(true); 15 | spaces[0].setOwnership(-1); 16 | spaces[0].setMortgaged(false); 17 | spaces[0].setRent(0); 18 | spaces[0].setTax(0); 19 | spaces[0].setActionText("Pass Go! ", "Get $200 "); 20 | 21 | //Space 1 22 | spaces[1].setName(" Dorm ", " Room "); 23 | spaces[1].setType("Property"); 24 | spaces[1].setPropertyCost(60); 25 | spaces[1].setFreeParking(0); 26 | spaces[1].setOccupied(false); 27 | spaces[1].setOwnership(-1); 28 | spaces[1].setMortgaged(false); 29 | spaces[1].setRent(2); 30 | spaces[1].setTax(0); 31 | spaces[1].setActionText(" ", " $60 "); 32 | 33 | //Space 2 34 | spaces[2].setName("Community", " Chest "); 35 | spaces[2].setType("Community Chest"); 36 | spaces[2].setPropertyCost(0); 37 | spaces[2].setFreeParking(0); 38 | spaces[2].setOccupied(false); 39 | spaces[2].setOwnership(-1); 40 | spaces[2].setMortgaged(false); 41 | spaces[2].setRent(0); 42 | spaces[2].setTax(0); 43 | spaces[2].setActionText(" Draw a " ," Card "); 44 | 45 | //Space 3 46 | spaces[3].setName(" Leavey ", " Library "); 47 | spaces[3].setType("Property"); 48 | spaces[3].setPropertyCost(70); 49 | spaces[3].setFreeParking(0); 50 | spaces[3].setOccupied(false); 51 | spaces[3].setOwnership(-1); 52 | spaces[3].setMortgaged(false); 53 | spaces[3].setRent(4); 54 | spaces[3].setTax(0); 55 | spaces[3].setActionText(" ", " $60 "); 56 | 57 | 58 | //Space 4 59 | spaces[4].setName(" College ", " Tuition "); 60 | spaces[4].setType("Tax"); 61 | spaces[4].setPropertyCost(70); 62 | spaces[4].setFreeParking(0); 63 | spaces[4].setOccupied(false); 64 | spaces[4].setOwnership(-1); 65 | spaces[4].setMortgaged(false); 66 | spaces[4].setRent(4); 67 | spaces[4].setTax(200); 68 | spaces[4].setActionText(" ", "Pay $200 "); 69 | 70 | //Space 5 71 | spaces[5].setName(" Campus ", " Cruiser "); 72 | spaces[5].setType("RailRoad"); 73 | spaces[5].setPropertyCost(200); 74 | spaces[5].setFreeParking(0); 75 | spaces[5].setOccupied(false); 76 | spaces[5].setOwnership(-1); 77 | spaces[5].setMortgaged(false); 78 | spaces[5].setRent(25); 79 | spaces[5].setTax(0); 80 | spaces[5].setActionText(" ", " $200 "); 81 | 82 | //Space 6 83 | spaces[6].setName(" Trojan ", " Hall "); 84 | spaces[6].setType("Property"); 85 | spaces[6].setPropertyCost(100); 86 | spaces[6].setFreeParking(0); 87 | spaces[6].setOccupied(false); 88 | spaces[6].setOwnership(-1); 89 | spaces[6].setMortgaged(false); 90 | spaces[6].setRent(6); 91 | spaces[6].setTax(0); 92 | spaces[6].setActionText(" ", " $100 "); 93 | 94 | //Space 7 95 | spaces[7].setName(" Chance ", " "); 96 | spaces[7].setType("Chance"); 97 | spaces[7].setPropertyCost(0); 98 | spaces[7].setFreeParking(0); 99 | spaces[7].setOccupied(false); 100 | spaces[7].setOwnership(-1); 101 | spaces[7].setMortgaged(false); 102 | spaces[7].setRent(0); 103 | spaces[7].setTax(0); 104 | spaces[7].setActionText(" Draw a ", " card "); 105 | 106 | //Space 8 107 | spaces[8].setName(" Marks ", " Tower "); 108 | spaces[8].setType("Property"); 109 | spaces[8].setPropertyCost(100); 110 | spaces[8].setFreeParking(0); 111 | spaces[8].setOccupied(false); 112 | spaces[8].setOwnership(-1); 113 | spaces[8].setMortgaged(false); 114 | spaces[8].setRent(6); 115 | spaces[8].setTax(0); 116 | spaces[8].setActionText(" ", " $100 "); 117 | 118 | //Space 9 119 | spaces[9].setName(" Pardee ", " Tower "); 120 | spaces[9].setType("Property"); 121 | spaces[9].setPropertyCost(120); 122 | spaces[9].setFreeParking(0); 123 | spaces[9].setOccupied(false); 124 | spaces[9].setOwnership(-1); 125 | spaces[9].setMortgaged(false); 126 | spaces[9].setRent(8); 127 | spaces[9].setTax(0); 128 | spaces[9].setActionText(" ", " $120 "); 129 | 130 | 131 | //Space 10 132 | spaces[10].setName(" SJACS! ", " "); 133 | spaces[10].setType("Jail"); 134 | spaces[10].setPropertyCost(0); 135 | spaces[10].setFreeParking(0); 136 | spaces[10].setOccupied(false); 137 | spaces[10].setOwnership(-1); 138 | spaces[10].setMortgaged(false); 139 | spaces[10].setRent(0); 140 | spaces[10].setTax(0); 141 | spaces[10].setActionText(" Just ", "Visiting "); 142 | 143 | //Space 11 144 | spaces[11].setName(" Silent ", " Chapel "); 145 | spaces[11].setType("Property"); 146 | spaces[11].setPropertyCost(140); 147 | spaces[11].setFreeParking(0); 148 | spaces[11].setOccupied(false); 149 | spaces[11].setOwnership(-1); 150 | spaces[11].setMortgaged(false); 151 | spaces[11].setRent(10); 152 | spaces[11].setTax(0); 153 | spaces[11].setActionText(" ", " $140 "); 154 | 155 | //Space 12 156 | spaces[12].setName("Bathroom ", "Janitors "); 157 | spaces[12].setType("Utility"); 158 | spaces[12].setPropertyCost(150); 159 | spaces[12].setFreeParking(0); 160 | spaces[12].setOccupied(false); 161 | spaces[12].setOwnership(-1); 162 | spaces[12].setMortgaged(false); 163 | spaces[12].setRent(10); 164 | spaces[12].setTax(0); 165 | spaces[12].setActionText(" ", " $150 "); 166 | 167 | 168 | //Space 13 169 | spaces[13].setName("McCarthy ", " Quad "); 170 | spaces[13].setType("Property"); 171 | spaces[13].setPropertyCost(140); 172 | spaces[13].setFreeParking(0); 173 | spaces[13].setOccupied(false); 174 | spaces[13].setOwnership(-1); 175 | spaces[13].setMortgaged(false); 176 | spaces[13].setRent(10); 177 | spaces[13].setTax(0); 178 | spaces[13].setActionText(" ", " $140 "); 179 | 180 | //Space 14 181 | spaces[14].setName(" Alumni ", " House "); 182 | spaces[14].setType("Property"); 183 | spaces[14].setPropertyCost(160); 184 | spaces[14].setFreeParking(0); 185 | spaces[14].setOccupied(false); 186 | spaces[14].setOwnership(-1); 187 | spaces[14].setMortgaged(false); 188 | spaces[14].setRent(12); 189 | spaces[14].setTax(0); 190 | spaces[14].setActionText(" ", " $160 "); 191 | 192 | //Space 15 193 | spaces[15].setName("LA Metro ", " "); 194 | spaces[15].setType("RailRoad"); 195 | spaces[15].setPropertyCost(200); 196 | spaces[15].setFreeParking(0); 197 | spaces[15].setOccupied(false); 198 | spaces[15].setOwnership(-1); 199 | spaces[15].setMortgaged(false); 200 | spaces[15].setRent(25); 201 | spaces[15].setTax(0); 202 | spaces[15].setActionText(" ", " $200 "); 203 | 204 | //Space 16 205 | spaces[16].setName(" Fluor ", " Tower "); 206 | spaces[16].setType("Property"); 207 | spaces[16].setPropertyCost(180); 208 | spaces[16].setFreeParking(0); 209 | spaces[16].setOccupied(false); 210 | spaces[16].setOwnership(-1); 211 | spaces[16].setMortgaged(false); 212 | spaces[16].setRent(14); 213 | spaces[16].setTax(0); 214 | spaces[16].setActionText(" ", " $180 "); 215 | 216 | //Space 17 217 | spaces[17].setName("Community", " Chest "); 218 | spaces[17].setType("Community Chest"); 219 | spaces[17].setPropertyCost(0); 220 | spaces[17].setFreeParking(0); 221 | spaces[17].setOccupied(false); 222 | spaces[17].setOwnership(-1); 223 | spaces[17].setMortgaged(false); 224 | spaces[17].setRent(0); 225 | spaces[17].setTax(0); 226 | spaces[17].setActionText(" Draw a ", " Card "); 227 | 228 | //Space 18 229 | spaces[18].setName(" Webb ", " Tower "); 230 | spaces[18].setType("Property"); 231 | spaces[18].setPropertyCost(180); 232 | spaces[18].setFreeParking(0); 233 | spaces[18].setOccupied(false); 234 | spaces[18].setOwnership(-1); 235 | spaces[18].setMortgaged(false); 236 | spaces[18].setRent(14); 237 | spaces[18].setTax(0); 238 | spaces[18].setActionText(" ", " $180 "); 239 | 240 | //Space 19 241 | spaces[19].setName(" Lyon ", " Center "); 242 | spaces[19].setType("Property"); 243 | spaces[19].setPropertyCost(200); 244 | spaces[19].setFreeParking(0); 245 | spaces[19].setOccupied(false); 246 | spaces[19].setOwnership(-1); 247 | spaces[19].setMortgaged(false); 248 | spaces[19].setRent(16); 249 | spaces[19].setTax(0); 250 | spaces[19].setActionText(" ", " $200 "); 251 | 252 | //Space 20 253 | spaces[20].setName("Financial", " Aid "); 254 | spaces[20].setType("FreeParking"); 255 | spaces[20].setPropertyCost(0); 256 | spaces[20].setFreeParking(0); 257 | spaces[20].setOccupied(false); 258 | spaces[20].setOwnership(-1); 259 | spaces[20].setMortgaged(false); 260 | spaces[20].setRent(0); 261 | spaces[20].setTax(0); 262 | spaces[20].setActionText(" ", " "); 263 | 264 | //Space 21 265 | spaces[21].setName(" George ", "Tirebiter"); 266 | spaces[21].setType("Property"); 267 | spaces[21].setPropertyCost(220); 268 | spaces[21].setFreeParking(0); 269 | spaces[21].setOccupied(false); 270 | spaces[21].setOwnership(-1); 271 | spaces[21].setMortgaged(false); 272 | spaces[21].setRent(18); 273 | spaces[21].setTax(0); 274 | spaces[21].setActionText(" ", " $220 "); 275 | 276 | //Space 22 277 | spaces[22].setName(" Chance ", " "); 278 | spaces[22].setType("Chance"); 279 | spaces[22].setPropertyCost(0); 280 | spaces[22].setFreeParking(0); 281 | spaces[22].setOccupied(false); 282 | spaces[22].setOwnership(-1); 283 | spaces[22].setMortgaged(false); 284 | spaces[22].setRent(0); 285 | spaces[22].setTax(0); 286 | spaces[22].setActionText(" Draw a ", " Card "); 287 | 288 | //Space 23 289 | spaces[23].setName("Traveller", " Statue "); 290 | spaces[23].setType("Property"); 291 | spaces[23].setPropertyCost(220); 292 | spaces[23].setFreeParking(0); 293 | spaces[23].setOccupied(false); 294 | spaces[23].setOwnership(-1); 295 | spaces[23].setMortgaged(false); 296 | spaces[23].setRent(18); 297 | spaces[23].setTax(0); 298 | spaces[23].setActionText(" ", " $220 "); 299 | 300 | //Space 24 301 | spaces[24].setName("Knight's ", " Bench "); 302 | spaces[24].setType("Property"); 303 | spaces[24].setPropertyCost(240); 304 | spaces[24].setFreeParking(0); 305 | spaces[24].setOccupied(false); 306 | spaces[24].setOwnership(-1); 307 | spaces[24].setMortgaged(false); 308 | spaces[24].setRent(20); 309 | spaces[24].setTax(0); 310 | spaces[24].setActionText(" ", " $240 "); 311 | 312 | //Space 25 313 | spaces[25].setName("Lyft App ", " "); 314 | spaces[25].setType("RailRoad"); 315 | spaces[25].setPropertyCost(200); 316 | spaces[25].setFreeParking(0); 317 | spaces[25].setOccupied(false); 318 | spaces[25].setOwnership(-1); 319 | spaces[25].setMortgaged(false); 320 | spaces[25].setRent(25); 321 | spaces[25].setTax(0); 322 | spaces[25].setActionText(" ", " $200 "); 323 | 324 | //Space 26 325 | spaces[26].setName("Cromwell ", " Field "); 326 | spaces[26].setType("Property"); 327 | spaces[26].setPropertyCost(260); 328 | spaces[26].setFreeParking(0); 329 | spaces[26].setOccupied(false); 330 | spaces[26].setOwnership(-1); 331 | spaces[26].setMortgaged(false); 332 | spaces[26].setRent(22); 333 | spaces[26].setTax(0); 334 | spaces[26].setActionText(" ", " $260 "); 335 | 336 | //Space 27 337 | spaces[27].setName(" V.K.C. ", "Carillon "); 338 | spaces[27].setType("Property"); 339 | spaces[27].setPropertyCost(260); 340 | spaces[27].setFreeParking(0); 341 | spaces[27].setOccupied(false); 342 | spaces[27].setOwnership(-1); 343 | spaces[27].setMortgaged(false); 344 | spaces[27].setRent(22); 345 | spaces[27].setTax(0); 346 | spaces[27].setActionText(" ", " $260 "); 347 | 348 | //Space 28 349 | spaces[28].setName(" Laundry ", " Company "); 350 | spaces[28].setType("Utility"); 351 | spaces[28].setPropertyCost(150); 352 | spaces[28].setFreeParking(0); 353 | spaces[28].setOccupied(false); 354 | spaces[28].setOwnership(-1); 355 | spaces[28].setMortgaged(false); 356 | spaces[28].setRent(10); 357 | spaces[28].setTax(0); 358 | spaces[28].setActionText(" ", " $150 "); 359 | 360 | //Space 29 361 | spaces[29].setName(" Gallen ", " Center "); 362 | spaces[29].setType("Property"); 363 | spaces[29].setPropertyCost(280); 364 | spaces[29].setFreeParking(0); 365 | spaces[29].setOccupied(false); 366 | spaces[29].setOwnership(-1); 367 | spaces[29].setMortgaged(false); 368 | spaces[29].setRent(22); 369 | spaces[29].setTax(0); 370 | spaces[29].setActionText(" ", " $280 "); 371 | 372 | //Space 30 373 | spaces[30].setName("Caught by", " D.P.S. "); 374 | spaces[30].setType("GoJail"); 375 | spaces[30].setPropertyCost(0); 376 | spaces[30].setFreeParking(0); 377 | spaces[30].setOccupied(false); 378 | spaces[30].setOwnership(-1); 379 | spaces[30].setMortgaged(false); 380 | spaces[30].setRent(0); 381 | spaces[30].setTax(0); 382 | spaces[30].setActionText(" ", " "); 383 | 384 | //Space 31 385 | spaces[31].setName("Heritage ", " Hall "); 386 | spaces[31].setType("Property"); 387 | spaces[31].setPropertyCost(300); 388 | spaces[31].setFreeParking(0); 389 | spaces[31].setOccupied(false); 390 | spaces[31].setOwnership(-1); 391 | spaces[31].setMortgaged(false); 392 | spaces[31].setRent(26); 393 | spaces[31].setTax(0); 394 | spaces[31].setActionText(" ", " $300 "); 395 | 396 | //Space 32 397 | spaces[32].setName(" McKay ", " Center "); 398 | spaces[32].setType("Property"); 399 | spaces[32].setPropertyCost(300); 400 | spaces[32].setFreeParking(0); 401 | spaces[32].setOccupied(false); 402 | spaces[32].setOwnership(-1); 403 | spaces[32].setMortgaged(false); 404 | spaces[32].setRent(26); 405 | spaces[32].setTax(0); 406 | spaces[32].setActionText(" ", " $300 "); 407 | 408 | //Space 33 409 | spaces[33].setName("Community", " Chest "); 410 | spaces[33].setType("Community Chest"); 411 | spaces[33].setPropertyCost(0); 412 | spaces[33].setFreeParking(0); 413 | spaces[33].setOccupied(false); 414 | spaces[33].setOwnership(-1); 415 | spaces[33].setMortgaged(false); 416 | spaces[33].setRent(0); 417 | spaces[33].setTax(0); 418 | spaces[33].setActionText(" Draw a ", " Card "); 419 | 420 | //Space 34 421 | spaces[34].setName(" Bovard ", " Stage "); 422 | spaces[34].setType("Property"); 423 | spaces[34].setPropertyCost(320); 424 | spaces[34].setFreeParking(0); 425 | spaces[34].setOccupied(false); 426 | spaces[34].setOwnership(-1); 427 | spaces[34].setMortgaged(false); 428 | spaces[34].setRent(28); 429 | spaces[34].setTax(0); 430 | spaces[34].setActionText(" ", " $320 "); 431 | 432 | //Space 35 433 | spaces[35].setName(" USC ", " Shuttle "); 434 | spaces[35].setType("RailRoad"); 435 | spaces[35].setPropertyCost(200); 436 | spaces[35].setFreeParking(0); 437 | spaces[35].setOccupied(false); 438 | spaces[35].setOwnership(-1); 439 | spaces[35].setMortgaged(false); 440 | spaces[35].setRent(25); 441 | spaces[35].setTax(0); 442 | spaces[35].setActionText(" ", " $200 "); 443 | 444 | //Space 36 445 | spaces[36].setName(" Chance ", " "); 446 | spaces[36].setType("Chance"); 447 | spaces[36].setPropertyCost(0); 448 | spaces[36].setFreeParking(0); 449 | spaces[36].setOccupied(false); 450 | spaces[36].setOwnership(-1); 451 | spaces[36].setMortgaged(false); 452 | spaces[36].setRent(0); 453 | spaces[36].setTax(0); 454 | spaces[36].setActionText(" Draw a ", " Card "); 455 | 456 | //Space 37 457 | spaces[37].setName(" Trojan ", " Shrine "); 458 | spaces[37].setType("Property"); 459 | spaces[37].setPropertyCost(350); 460 | spaces[37].setFreeParking(0); 461 | spaces[37].setOccupied(false); 462 | spaces[37].setOwnership(-1); 463 | spaces[37].setMortgaged(false); 464 | spaces[37].setRent(35); 465 | spaces[37].setTax(0); 466 | spaces[37].setActionText(" ", " $350 "); 467 | 468 | //Space 38 469 | spaces[38].setName("Textbook ", " Fees "); 470 | spaces[38].setType("Tax"); 471 | spaces[38].setPropertyCost(0); 472 | spaces[38].setFreeParking(0); 473 | spaces[38].setOccupied(false); 474 | spaces[38].setOwnership(-1); 475 | spaces[38].setMortgaged(false); 476 | spaces[38].setRent(0); 477 | spaces[38].setTax(75); 478 | spaces[38].setActionText(" ", " Pay $75 "); 479 | 480 | //Space 39 481 | spaces[39].setName("Football ", "Coliseum "); 482 | spaces[39].setType("Property"); 483 | spaces[39].setPropertyCost(400); 484 | spaces[39].setFreeParking(0); 485 | spaces[39].setOccupied(false); 486 | spaces[39].setOwnership(-1); 487 | spaces[39].setMortgaged(false); 488 | spaces[39].setRent(50); 489 | spaces[39].setTax(0); 490 | spaces[39].setActionText(" ", " $400 "); 491 | 492 | for(int i = 0; i < 40; i++){ 493 | spaces[i].setHouses(0); 494 | } 495 | } 496 | 497 | void Game_Board::move(int numPlayer, int amountInput){ 498 | movement.move_amount(&(players[numPlayer]), amountInput); 499 | } 500 | 501 | void Game_Board::createPlayers(int numPlayers){ 502 | players = new Player[numPlayers]; 503 | } 504 | 505 | void Game_Board::setPlayerName(int playerNum, string inputName){ 506 | players[playerNum].setPlayerName(inputName); 507 | } 508 | 509 | void Game_Board::setGamePiece(int playerNum, string inputPiece){ 510 | players[playerNum].setGamePieceName(inputPiece); 511 | } 512 | 513 | string Game_Board::getPlayerName(int playerNum){ 514 | return players[playerNum].getPlayerName(); 515 | } 516 | 517 | string Game_Board::getGamePiece(int playerNum){ 518 | return players[playerNum].getGamePieceName(); 519 | } 520 | 521 | Player* Game_Board::getPlayer(int num){ 522 | return &players[num]; 523 | } 524 | 525 | int Game_Board::getPlayerLocation(int playerNum){ 526 | return players[playerNum].getLocation(); 527 | } 528 | 529 | int Game_Board::getPlayerMoney(int playerNum){ 530 | return players[playerNum].getMoneyAmount(); 531 | } 532 | 533 | string Game_Board::spaceType(int inputIndex){ 534 | return spaces[inputIndex].getType(); 535 | } 536 | 537 | int Game_Board::getSpaceOwnership(int spaceIndex){ 538 | return spaces[spaceIndex].getOwnership(); 539 | } 540 | 541 | int Game_Board::getSpacePropertyCost(int spaceIndex){ 542 | return spaces[spaceIndex].getPropertyCost(); 543 | } 544 | 545 | void Game_Board::setSpaceOwnership(int spaceIndex, int playerNum){ 546 | spaces[spaceIndex].setOwnership(playerNum); 547 | } 548 | 549 | int Game_Board::getSpaceRent(int spaceIndex){ 550 | return spaces[spaceIndex].getRent(); 551 | } 552 | 553 | int Game_Board::getSpaceTax(int spaceIndex){ 554 | return spaces[spaceIndex].getTax(); 555 | } 556 | 557 | int Game_Board::getSpaceFreeParking(int spaceIndex){ 558 | return spaces[spaceIndex].getFreeParking(); 559 | } 560 | 561 | string Game_Board::getSpaceName(int spaceIndex, int index){ 562 | return spaces[spaceIndex].getName(index); 563 | } 564 | 565 | void Game_Board::upgradeSpace(int spaceNum){ 566 | spaces[spaceNum].upgrade(); 567 | } 568 | 569 | bool Game_Board::isPlayerAlive(int playerNum){ 570 | return players[playerNum].isAlive(); 571 | } 572 | 573 | void Game_Board::playerLost(int playerNum){ 574 | players[playerNum].reset(); 575 | } 576 | 577 | //Display Game Board 578 | void Game_Board::displayHorizontal(int firstSpace, int lastSpace, int numPlayers){ 579 | 580 | int numSpaces = abs(lastSpace - firstSpace) + 1; 581 | 582 | //first line for all cards 583 | for(int i = 0; i < numSpaces; i++){ 584 | cout << "----------"; 585 | } 586 | 587 | cout << "-" << endl; 588 | 589 | //second line 590 | for(int i = 0; i < numSpaces; i++){ 591 | 592 | Space current; 593 | 594 | if(firstSpace < lastSpace) { 595 | current = spaces[firstSpace + i]; 596 | } else { 597 | current = spaces[firstSpace - i]; 598 | } 599 | 600 | if(current.getType() == "Property"){ 601 | cout << "|--"; 602 | for(int x = 0; x < current.getHouses(); x++){ 603 | cout << "X"; 604 | } 605 | for(int x = 0; x < 7-(current.getHouses()); x++){ 606 | cout << "-"; 607 | } 608 | } else { 609 | cout << "|" << current.getName(0); 610 | } 611 | } 612 | 613 | cout << "|" << endl; 614 | 615 | //third line 616 | for(int i = 0; i < numSpaces; i++){ 617 | 618 | Space current; 619 | 620 | if(firstSpace < lastSpace) { 621 | current = spaces[firstSpace + i]; 622 | } else { 623 | current = spaces[firstSpace - i]; 624 | } 625 | 626 | if(current.getType() == "Property"){ 627 | cout << "|" << current.getName(0); 628 | } else { 629 | cout << "|" << current.getName(1); 630 | } 631 | } 632 | 633 | cout << "|" << endl; 634 | 635 | //fourth line 636 | for(int i = 0; i < numSpaces; i++){ 637 | 638 | Space current; 639 | 640 | if(firstSpace < lastSpace) { 641 | current = spaces[firstSpace + i]; 642 | } else { 643 | current = spaces[firstSpace - i]; 644 | } 645 | 646 | if(current.getType() == "Property"){ 647 | cout << "|" << current.getName(1); 648 | } else { 649 | cout << "|" << " "; 650 | } 651 | } 652 | 653 | cout << "|" << endl; 654 | 655 | //fifth line 656 | 657 | for(int i = 0; i < numSpaces; i++){ 658 | 659 | int counter = 0; 660 | 661 | if(firstSpace < lastSpace) { 662 | 663 | cout << "| "; 664 | for(int j = 0; j < numPlayers; j++){ 665 | if((firstSpace + i) == (players[j].getLocation())){ 666 | cout << players[j].getGamePiece(); 667 | counter++; 668 | } 669 | } 670 | for(int x = 0; x < (6-counter); x++){ 671 | cout << " "; 672 | } 673 | 674 | } else { 675 | 676 | cout << "| "; 677 | for(int j = 0; j < numPlayers; j++){ 678 | if((firstSpace - i) == (players[j].getLocation())){ 679 | cout << players[j].getGamePiece(); 680 | counter++; 681 | } 682 | } 683 | for(int x = 0; x < (6-counter); x++){ 684 | cout << " "; 685 | } 686 | 687 | } 688 | } 689 | 690 | cout << "|" << endl; 691 | 692 | //sixth line 693 | for(int i = 0; i < numSpaces; i++){ 694 | 695 | Space current; 696 | 697 | if(firstSpace < lastSpace) { 698 | current = spaces[firstSpace + i]; 699 | } else { 700 | current = spaces[firstSpace - i]; 701 | } 702 | 703 | if(current.getType() == "Property"){ 704 | cout << "|" << current.getActionText(0); 705 | } else { 706 | cout << "|" << current.getActionText(0); 707 | } 708 | } 709 | 710 | cout << "|" << endl; 711 | 712 | //seventh line 713 | for(int i = 0; i < numSpaces; i++){ 714 | 715 | Space current; 716 | 717 | if(firstSpace < lastSpace) { 718 | current = spaces[firstSpace + i]; 719 | } else { 720 | current = spaces[firstSpace - i]; 721 | } 722 | 723 | if(current.getType() == "Property"){ 724 | cout << "|" << current.getActionText(1); 725 | } else { 726 | cout << "|" << current.getActionText(1); 727 | } 728 | } 729 | 730 | cout << "|" << endl; 731 | 732 | //eighth line 733 | for(int i = 0; i < numSpaces; i++){ 734 | cout << "----------"; 735 | } 736 | 737 | cout << "-" << endl; 738 | } 739 | 740 | void Game_Board::displayVertical(int firstSpace, int lastSpace, int numPlayers){ 741 | 742 | Space current = spaces[firstSpace]; 743 | Space current2 = spaces[lastSpace]; 744 | 745 | //toplines 746 | if(firstSpace != 19){ 747 | 748 | cout << "-----------"; 749 | 750 | for(int i = 0; i < 8; i++){ 751 | cout << " "; 752 | } 753 | 754 | cout << " "; 755 | cout << "-----------" << endl; 756 | 757 | } 758 | 759 | 760 | 761 | //first line 762 | if(current.getType() == "Property"){ 763 | cout << "|--"; 764 | for(int x = 0; x < current.getHouses(); x++){ 765 | cout << "X"; 766 | } 767 | for(int x = 0; x < 7-(current.getHouses()); x++){ 768 | cout << "-"; 769 | } 770 | } else{ 771 | cout << "|" << current.getName(0); 772 | } 773 | 774 | cout << "| "; 775 | 776 | for(int i = 0; i < 8; i++) { 777 | cout << " "; 778 | } 779 | 780 | if(current2.getType() == "Property"){ 781 | cout << "|--"; 782 | for(int x = 0; x < current2.getHouses(); x++){ 783 | cout << "X"; 784 | } 785 | for(int x = 0; x < 7-(current2.getHouses()); x++){ 786 | cout << "-"; 787 | } 788 | } else{ 789 | cout << "|" << current2.getName(0); 790 | } 791 | 792 | cout << "|" << endl; 793 | 794 | //second line 795 | 796 | if(current.getType() == "Property"){ 797 | cout << "|" << current.getName(0); 798 | } else{ 799 | cout << "|" << current.getName(1); 800 | } 801 | 802 | cout << "| "; 803 | 804 | for(int i = 0; i < 8; i++) { 805 | cout << " "; 806 | } 807 | 808 | if(current2.getType() == "Property"){ 809 | cout << "|" << current2.getName(0); 810 | } else{ 811 | cout << "|" << current2.getName(1); 812 | } 813 | 814 | cout << "|" << endl; 815 | 816 | //third line 817 | 818 | if(current.getType() == "Property"){ 819 | cout << "|" << current.getName(1); 820 | } else{ 821 | cout << "|" << " "; 822 | } 823 | 824 | cout << "| "; 825 | 826 | for(int i = 0; i < 8; i++) { 827 | cout << " "; 828 | } 829 | 830 | if(current2.getType() == "Property"){ 831 | cout << "|" << current2.getName(1); 832 | } else{ 833 | cout << "|" << " "; 834 | } 835 | 836 | cout << "|" << endl; 837 | 838 | //fourth line 839 | 840 | int counter = 0; 841 | 842 | cout << "| "; 843 | 844 | for(int j = 0; j < numPlayers; j++){ 845 | if((firstSpace) == (players[j].getLocation())){ 846 | cout << players[j].getGamePiece(); 847 | counter++; 848 | } 849 | } 850 | 851 | for(int x = 0; x < (6-counter); x++){ 852 | cout << " "; 853 | } 854 | 855 | cout << "| "; 856 | 857 | for(int z = 0; z < 8; z++){ 858 | cout << " "; 859 | } 860 | 861 | counter = 0; 862 | 863 | cout << "| "; 864 | 865 | for(int j = 0; j < numPlayers; j++){ 866 | if((lastSpace) == (players[j].getLocation())){ 867 | cout << players[j].getGamePiece(); 868 | counter++; 869 | } 870 | } 871 | 872 | for(int x = 0; x < (6-counter); x++){ 873 | cout << " "; 874 | } 875 | 876 | cout << "|" << endl; 877 | 878 | //fifth line 879 | 880 | if(current.getType() == "Property"){ 881 | cout << "|" << current.getActionText(0); 882 | } else{ 883 | cout << "|" << current.getActionText(0); 884 | } 885 | 886 | cout << "| "; 887 | 888 | for(int i = 0; i < 8; i++) { 889 | cout << " "; 890 | } 891 | 892 | if(current2.getType() == "Property"){ 893 | cout << "|" << current2.getActionText(0); 894 | } else{ 895 | cout << "|" << current2.getActionText(0); 896 | } 897 | 898 | cout << "|" << endl; 899 | 900 | //sixth line 901 | 902 | if(current.getType() == "Property"){ 903 | cout << "|" << current.getActionText(1); 904 | } else{ 905 | cout << "|" << current.getActionText(1); 906 | } 907 | 908 | cout << "| "; 909 | 910 | for(int i = 0; i < 8; i++) { 911 | cout << " "; 912 | } 913 | 914 | if(current2.getType() == "Property"){ 915 | cout << "|" << current2.getActionText(1); 916 | } else{ 917 | cout << "|" << current2.getActionText(1); 918 | } 919 | 920 | cout << "|" << endl; 921 | 922 | } 923 | 924 | 925 | 926 | 927 | 928 | -------------------------------------------------------------------------------- /Game_Board.h: -------------------------------------------------------------------------------- 1 | #ifndef GAME_BOARD_H 2 | #define GAME_BOARD_H 3 | 4 | #include "space.h" 5 | #include "move_action.h" 6 | #include "player.h" 7 | 8 | class Game_Board { 9 | 10 | private: 11 | Space spaces[40]; 12 | Player* players; 13 | MoveAction movement; 14 | 15 | public: 16 | //constructor 17 | Game_Board(); //initialize all 40 game spaces 18 | 19 | //methods called by user 20 | void displayHorizontal(int firstSpace, int lastSpace, int numPlayers); 21 | void displayVertical(int firstSpace, int lastSpace, int numPlayers); 22 | void createPlayers(int numPlayers); 23 | void setPlayerName(int playerNum, string inputName); 24 | void setGamePiece(int playerNum, string inputPiece); 25 | 26 | string getPlayerName(int playerNum); 27 | string getGamePiece(int playerNum); 28 | 29 | void move(int numPlayer, int amountMove); 30 | Player* getPlayer(int num); 31 | int getPlayerLocation(int playerNum); 32 | int getPlayerMoney(int playerNum); 33 | string spaceType(int inputIndex); 34 | int getSpaceOwnership(int spaceIndex); 35 | int getSpacePropertyCost(int spaceIndex); 36 | void setSpaceOwnership(int spaceIndex, int playerNum); 37 | int getSpaceRent(int spaceIndex); 38 | int getSpaceTax(int spaceIndex); 39 | int getSpaceFreeParking(int spaceIndex); 40 | string getSpaceName(int spaceIndex, int index); 41 | void upgradeSpace(int spaceNum); 42 | bool isPlayerAlive(int playerNum); 43 | void playerLost(int playerNum); 44 | 45 | }; 46 | #endif 47 | -------------------------------------------------------------------------------- /Images/Monopoly.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/otherchen/Monopoly/3bd5e522ccffcf8ee982a8844c598d78f113e9ef/Images/Monopoly.jpg -------------------------------------------------------------------------------- /Pieces/barrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/otherchen/Monopoly/3bd5e522ccffcf8ee982a8844c598d78f113e9ef/Pieces/barrow.png -------------------------------------------------------------------------------- /Pieces/baseball.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/otherchen/Monopoly/3bd5e522ccffcf8ee982a8844c598d78f113e9ef/Pieces/baseball.png -------------------------------------------------------------------------------- /Pieces/car.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/otherchen/Monopoly/3bd5e522ccffcf8ee982a8844c598d78f113e9ef/Pieces/car.png -------------------------------------------------------------------------------- /Pieces/dog.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/otherchen/Monopoly/3bd5e522ccffcf8ee982a8844c598d78f113e9ef/Pieces/dog.png -------------------------------------------------------------------------------- /Pieces/dragon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/otherchen/Monopoly/3bd5e522ccffcf8ee982a8844c598d78f113e9ef/Pieces/dragon.png -------------------------------------------------------------------------------- /Pieces/hat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/otherchen/Monopoly/3bd5e522ccffcf8ee982a8844c598d78f113e9ef/Pieces/hat.png -------------------------------------------------------------------------------- /Pieces/pretzel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/otherchen/Monopoly/3bd5e522ccffcf8ee982a8844c598d78f113e9ef/Pieces/pretzel.png -------------------------------------------------------------------------------- /Pieces/ship.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/otherchen/Monopoly/3bd5e522ccffcf8ee982a8844c598d78f113e9ef/Pieces/ship.png -------------------------------------------------------------------------------- /Pieces/soccer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/otherchen/Monopoly/3bd5e522ccffcf8ee982a8844c598d78f113e9ef/Pieces/soccer.png -------------------------------------------------------------------------------- /Pieces/surfer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/otherchen/Monopoly/3bd5e522ccffcf8ee982a8844c598d78f113e9ef/Pieces/surfer.png -------------------------------------------------------------------------------- /Pieces/thimble.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/otherchen/Monopoly/3bd5e522ccffcf8ee982a8844c598d78f113e9ef/Pieces/thimble.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Monopoly Project 2 | 3 | - **Name**: Andrew Chen 4 | - **Class**: CSCI103 (Introduction to Programming) 5 | 6 | This program allows up to 4 players to play together on the same computer together and functions much like the original Monopoly game. The Game Board and cards are customized but the game pieces are pulled from the real versions of Monopoly. Everything was created from scratch using Photoshop and C++. 7 | -------------------------------------------------------------------------------- /action.cpp: -------------------------------------------------------------------------------- 1 | #include "action.h" 2 | 3 | Action::Action(){ 4 | name = "Action Name"; 5 | } 6 | 7 | Action::Action(string inputName){ 8 | name = inputName; 9 | } 10 | 11 | -------------------------------------------------------------------------------- /action.h: -------------------------------------------------------------------------------- 1 | #ifndef ACTION_H 2 | #define ACTION_H 3 | 4 | #include 5 | #include "player.h" 6 | using namespace std; 7 | 8 | class Action { 9 | 10 | private: 11 | string name; 12 | 13 | public: 14 | //constructors 15 | Action(); 16 | Action(string inputName); 17 | 18 | //This class is abstract and cannot be compiled 19 | virtual void executeAction(Player* player1, Player* player2, int amount) = 0; 20 | }; 21 | #endif 22 | -------------------------------------------------------------------------------- /bank.cpp: -------------------------------------------------------------------------------- 1 | #include "bank.h" 2 | 3 | Bank::Bank(){ 4 | moneyAmount = 100000; 5 | } 6 | 7 | void Bank::give_money(int amount){ 8 | moneyAmount = moneyAmount + amount; 9 | } 10 | 11 | int Bank::getAmount(){ 12 | return moneyAmount; 13 | } 14 | 15 | void Bank::take_money(int amount){ 16 | moneyAmount = moneyAmount - amount; 17 | } 18 | 19 | -------------------------------------------------------------------------------- /bank.h: -------------------------------------------------------------------------------- 1 | #ifndef BANK_H 2 | #define BANK_H 3 | 4 | #include 5 | 6 | using namespace std; 7 | 8 | class Bank { 9 | 10 | private: 11 | int moneyAmount; 12 | 13 | public: 14 | //constructors 15 | Bank(); 16 | 17 | //functions to get values 18 | int getAmount(); 19 | 20 | //other functions 21 | void give_money(int amount); 22 | void take_money(int amount); 23 | 24 | }; 25 | #endif 26 | -------------------------------------------------------------------------------- /boardgame.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Andrew Chen 3 | Professor Crowley 4 | April 30, 2014 5 | PA6: Board Game 6 | */ 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include "player.h" 14 | #include "space.h" 15 | #include "Game_Board.h" 16 | #include "dice.h" 17 | #include "action.h" 18 | #include "move_action.h" 19 | #include "money_action.h" 20 | #include "goToAction.h" 21 | #include "card.h" 22 | #include "card_money.h" 23 | #include "card_move.h" 24 | #include "bank.h" 25 | #include "mainwindow.h" 26 | 27 | using namespace std; 28 | 29 | int main(int argv, char* argc[]) { 30 | 31 | //creating QApp 32 | QApplication app(argv, argc); 33 | 34 | //seeding the time 35 | srand(time(0)); 36 | 37 | //variables 38 | int numOfPlayers = 0; 39 | char gamePieces[10] = {'~', '!', '@', '#', '$', '%', '^', '&', '*', '?'}; 40 | int numOfPieces = 10; 41 | 42 | /************* setting up NUMBER OF PLAYERS pop up box *****************/ 43 | QMessageBox numPlayersBox; 44 | QPushButton *button2 = numPlayersBox.addButton(QPushButton::tr("Two"), QMessageBox::ActionRole); 45 | QPushButton *button3 = numPlayersBox.addButton(QPushButton::tr("Three"), QMessageBox::ActionRole); 46 | QPushButton *button4 = numPlayersBox.addButton(QPushButton::tr("Four"), QMessageBox::ActionRole); 47 | numPlayersBox.setText("How many people would like to play?"); 48 | numPlayersBox.exec(); 49 | 50 | if (numPlayersBox.clickedButton() == button2) { 51 | numOfPlayers = 2; 52 | 53 | } 54 | if (numPlayersBox.clickedButton() == button3) { 55 | numOfPlayers= 3; 56 | 57 | } 58 | if (numPlayersBox.clickedButton() == button4) { 59 | numOfPlayers = 4; 60 | 61 | } 62 | 63 | /*****************************************************************************/ 64 | 65 | //setting up the game 66 | MainWindow mainWindow(numOfPlayers); 67 | Game_Board gameBoard; 68 | gameBoard.createPlayers(numOfPlayers); 69 | Bank bank; 70 | Player freePark(0); 71 | MoneyAction moneyAction; 72 | GoToAction goToAction; 73 | Dice dice[2]; 74 | string gamePieceIcons[10] = {"hat.png", "baseball.png", "dog.png", "soccer.png", "surfer.png", "dragon.png", "barrow.png", "pretzel.png", "car.png", "ship.png"}; 75 | 76 | /************** Setting up Game Piece Choices ******************/ 77 | 78 | QPushButton *icon[10]; 79 | 80 | //giving game pieces to players 81 | for(int i = 0; i < numOfPlayers; i++){ 82 | 83 | stringstream ss; 84 | string tempPlayerNum; 85 | int indexPiece = 0; 86 | 87 | //allowing user to choose game piece 88 | for(int j = 0; j < numOfPieces; j++){ 89 | icon[j] = NULL; 90 | } 91 | 92 | ss << (i+1); 93 | ss >> tempPlayerNum; 94 | QString tempNum = QString::fromStdString(tempPlayerNum); 95 | 96 | QMessageBox gamePieceBox; 97 | gamePieceBox.setText("Player " + tempNum + ", please choose from the following game pieces."); 98 | 99 | for(int j = 0; j < numOfPieces; j++){ 100 | icon[j] = new QPushButton; 101 | icon[j]->setIcon(QIcon(QString(("Pieces/" + gamePieceIcons[j]).c_str()))); 102 | icon[j]->setIconSize(QSize(50,50)); 103 | gamePieceBox.addButton(icon[j], QMessageBox::ActionRole); 104 | } 105 | 106 | gamePieceBox.exec(); 107 | 108 | for( int j = 0; j < numOfPieces; j++){ 109 | 110 | if(gamePieceBox.clickedButton() == icon[j]){ 111 | //set guiPlayer's gamepiece to the chosen gamePieceIcon 112 | indexPiece = j; 113 | mainWindow.setGamePiece(i, "Pieces/" + gamePieceIcons[indexPiece]); 114 | break; 115 | } 116 | 117 | } 118 | 119 | numOfPieces--; 120 | 121 | //rearranging the game pieces to account for chosen piece 122 | for(int x = indexPiece; x < numOfPieces; x++){ 123 | string tempPiece = ""; 124 | tempPiece = gamePieceIcons[x]; 125 | gamePieceIcons[x] = gamePieceIcons[x+1]; 126 | gamePieceIcons[x+1] = tempPiece; 127 | } 128 | 129 | } 130 | 131 | /*****************************************************************************/ 132 | 133 | //setting up Full Game Board in Qt 134 | mainWindow.windowSetUp(); 135 | mainWindow.show(); 136 | return app.exec(); 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | //creating shuffled index 145 | int index[10] = {0,1,2,3,4,5,6,7,8,9}; 146 | int random1 = -1; 147 | int random2 = -1; 148 | int tempNum = -1; 149 | 150 | for(int i = 0; i < 50; i++){ 151 | random1 = rand()%10; 152 | random2 = rand()%10; 153 | 154 | tempNum = index[random1]; 155 | index[random1] = index[random2]; 156 | index[random2] = tempNum; 157 | } 158 | 159 | //setting up the Community Chest cards 160 | Card** community = new Card*[10]; 161 | 162 | community[index[0]] = new CardMove(); 163 | community[index[1]] = new CardMoney(); 164 | community[index[2]] = new CardMoney(); 165 | community[index[3]] = new CardMove(); 166 | community[index[4]] = new CardMoney(); 167 | community[index[5]] = new CardMoney(); 168 | community[index[6]] = new CardMove(); 169 | community[index[7]] = new CardMoney(); 170 | community[index[8]] = new CardMoney(); 171 | community[index[9]] = new CardMoney(); 172 | 173 | //Community Card 0 174 | community[index[0]]->setCardText("Advance to GO!"); 175 | community[index[0]]->setAmount(0); 176 | 177 | //Community Card 1 178 | community[index[1]]->setCardText("Cheap Books on Amazon!"); 179 | community[index[1]]->setAmount(75); 180 | 181 | //Community Card 2 182 | community[index[2]]->setCardText("It's your Birthday"); 183 | community[index[2]]->setAmount(150); 184 | 185 | //Community Card 3 186 | community[index[3]]->setCardText("Advance to The Knight's Bench!"); 187 | community[index[3]]->setAmount(24); 188 | 189 | //Community Card 4 190 | community[index[4]]->setCardText("You get a Research Position!"); 191 | community[index[4]]->setAmount(100); 192 | 193 | //Community Card 5 194 | community[index[5]]->setCardText("Won 2nd Place at Songfest!"); 195 | community[index[5]]->setAmount(20); 196 | 197 | //Community Card 6 198 | community[index[6]]->setCardText("March to the Coliseum!"); 199 | community[index[6]]->setAmount(39); 200 | 201 | //Community Card 7 202 | community[index[7]]->setCardText("Parents send you a care package!"); 203 | community[index[7]]->setAmount(15); 204 | 205 | //Community Card 8 206 | community[index[8]]->setCardText("You get a Paid Internship!"); 207 | community[index[8]]->setAmount(200); 208 | 209 | //Community Card 9 210 | community[index[9]]->setCardText("Given the Pell Grant!"); 211 | community[index[9]]->setAmount(20); 212 | 213 | 214 | //setting up the Chance cards 215 | Card** chance = new Card*[10]; 216 | 217 | chance[index[0]] = new CardMove(); 218 | chance[index[1]] = new CardMove(); 219 | chance[index[2]] = new CardMoney(); 220 | chance[index[3]] = new CardMove(); 221 | chance[index[4]] = new CardMoney(); 222 | chance[index[5]] = new CardMoney(); 223 | chance[index[6]] = new CardMove(); 224 | chance[index[7]] = new CardMoney(); 225 | chance[index[8]] = new CardMove(); 226 | chance[index[9]] = new CardMoney(); 227 | 228 | //Chance Card 0 229 | chance[index[0]]->setCardText("Advance to GO!"); 230 | chance[index[0]]->setAmount(0); 231 | 232 | //Chance Card 1 233 | chance[index[1]]->setCardText("Advance to Laundry"); 234 | chance[index[1]]->setAmount(28); 235 | 236 | //Chance Card 2 237 | chance[index[2]]->setCardText("You steal from charity!"); 238 | chance[index[2]]->setAmount(50); 239 | 240 | //Chance Card 3 241 | chance[index[3]]->setCardText("Advance to Silent Chapel"); 242 | chance[index[3]]->setAmount(11); 243 | 244 | //Chance Card 4 245 | chance[index[4]]->setCardText("Your parents give you money!"); 246 | chance[index[4]]->setAmount(100); 247 | 248 | //Chance Card 5 249 | chance[index[5]]->setCardText("There is an error with your banking!"); 250 | chance[index[5]]->setAmount(15); 251 | 252 | //Chance Card 6 253 | chance[index[6]]->setCardText("Take a trip to the LA Metro"); 254 | chance[index[6]]->setAmount(15); 255 | 256 | //Chance Card 7 257 | chance[index[7]]->setCardText("You found some printer ink!"); 258 | chance[index[7]]->setAmount(15); 259 | 260 | //Chance Card 8 261 | chance[index[8]]->setCardText("Advance to Campus Cruiser!"); 262 | chance[index[8]]->setAmount(5); 263 | 264 | //Chance Card 9 265 | chance[index[9]]->setCardText("Got a good grade in programming class!"); 266 | chance[index[9]]->setAmount(100); 267 | 268 | //print Game Board 269 | gameBoard.displayHorizontal(20, 30, numOfPlayers); 270 | gameBoard.displayVertical(19, 31, numOfPlayers); 271 | gameBoard.displayVertical(18, 32, numOfPlayers); 272 | gameBoard.displayVertical(17, 33, numOfPlayers); 273 | gameBoard.displayVertical(16, 34, numOfPlayers); 274 | gameBoard.displayVertical(15, 35, numOfPlayers); 275 | gameBoard.displayVertical(14, 36, numOfPlayers); 276 | gameBoard.displayVertical(13, 37, numOfPlayers); 277 | gameBoard.displayVertical(12, 38, numOfPlayers); 278 | gameBoard.displayVertical(11, 39, numOfPlayers); 279 | gameBoard.displayHorizontal(10, 0, numOfPlayers); 280 | 281 | //Begin Game 282 | stringstream ss; 283 | string enterBuffer; 284 | getline(cin, enterBuffer); 285 | int diceRoll1; 286 | int diceRoll2; 287 | int communityCount = 0; 288 | int chanceCount = 0; 289 | int numAlive = numOfPlayers; 290 | 291 | cout << endl; 292 | 293 | //as long as there are players, continue the game 294 | while(numAlive > 1){ 295 | 296 | //cycling through each player's turn 297 | for (int i = 0; i < numOfPlayers; i++){ 298 | 299 | if(gameBoard.isPlayerAlive(i) == true){ 300 | 301 | cout << "It's " << gameBoard.getPlayerName(i); 302 | cout << "'s turn!" << endl; 303 | 304 | int answer = 0; 305 | 306 | while(answer != 1){ 307 | do{ 308 | //print out menu 309 | cout << "Please choose one of the following options..." << endl; 310 | cout << " 1. Roll" << endl; 311 | cout << " 2. Upgrade" << endl; 312 | cout << " 3. Quit" << endl; 313 | cout << "Enter a number between 1 and 3: "; 314 | 315 | cin >> answer; 316 | 317 | if(cin.fail()){ 318 | cin.clear(); 319 | cin.ignore(10000, '\n'); 320 | cout << "Improper input! Try again!" << endl << endl; 321 | continue; 322 | } else if(answer < 1 || answer > 3){ 323 | cout << "\nNumber is out of range... Try again!" << endl << endl; 324 | continue; 325 | } 326 | 327 | getline(cin, enterBuffer); 328 | cout << endl; 329 | } while (answer < 1 || answer > 3); 330 | 331 | switch(answer){ 332 | case 1: 333 | continue; 334 | break; 335 | case 2: 336 | { 337 | int own[40]; 338 | int count = 0; 339 | int upgradeNum = 0; 340 | stringstream ss2; 341 | 342 | for(int x = 0; x < 40; x++){ 343 | if(gameBoard.getSpaceOwnership(x) == i && gameBoard.spaceType(x) == "Property"){ 344 | own[count] = x; 345 | count++; 346 | } 347 | } 348 | 349 | string tempName1; 350 | string tempName2; 351 | int j = 0; 352 | 353 | cout << "You own the following properties:" << endl; 354 | cout << " 1. Cancel" << endl; 355 | 356 | for(j = 0; j < count; j++){ 357 | int currentOwn = own[j]; 358 | tempName1 = ""; 359 | tempName2 = ""; 360 | 361 | ss2 << gameBoard.getSpaceName(currentOwn, 0); 362 | ss2 << gameBoard.getSpaceName(currentOwn, 1); 363 | ss2 >> tempName1; 364 | ss2 >> tempName2; 365 | ss2.clear(); 366 | 367 | cout << " " << j+2 << ". " << tempName1 << " " << tempName2 << ": $" << gameBoard.getSpacePropertyCost(currentOwn) << endl; 368 | } 369 | 370 | cout << endl << "What would you like to upgrade? (Max 4 upgrades): "; 371 | 372 | while(upgradeNum < 1 || upgradeNum > j+1){ 373 | 374 | cin >> upgradeNum; 375 | if(cin.fail()){ 376 | cin.clear(); 377 | cin.ignore(10000, '\n'); 378 | cout << "Invalid entry. Try again: "; 379 | continue; 380 | } else if (upgradeNum < 1 || upgradeNum > j+1){ 381 | cout << "Entry out of range...Try again: "; 382 | continue; 383 | } 384 | } 385 | 386 | if(upgradeNum == 1){ 387 | cout << endl; 388 | continue; 389 | } 390 | 391 | upgradeNum = upgradeNum - 2; 392 | 393 | string tempName3; 394 | string tempName4; 395 | 396 | ss.clear(); 397 | ss2 << gameBoard.getSpaceName(own[upgradeNum], 0); 398 | ss2 << gameBoard.getSpaceName(own[upgradeNum], 1); 399 | ss2 >> tempName3; 400 | ss2 >> tempName4; 401 | ss2.clear(); 402 | 403 | if(gameBoard.getPlayerMoney(i) - gameBoard.getSpacePropertyCost(own[upgradeNum]) <= 0) { 404 | cout << "You do not have enough money to upgrade this property!" << endl << endl; 405 | continue; 406 | } 407 | 408 | gameBoard.upgradeSpace(own[upgradeNum]); 409 | moneyAction.giveBank(gameBoard.getPlayer(i), &bank, gameBoard.getSpacePropertyCost(own[upgradeNum])); 410 | 411 | cout << "You have just upgraded " << tempName3 << " " << tempName4 << endl << endl; 412 | break; 413 | } 414 | case 3: 415 | return 0; 416 | break; 417 | } 418 | } 419 | 420 | //rolling the die and moving the player 421 | cin.clear(); 422 | diceRoll1 = dice[0].rollDice(); 423 | diceRoll2 = dice[1].rollDice(); 424 | cout << "You rolled...Move " << diceRoll1 + diceRoll2 << " steps." << endl << endl; 425 | int pastLocation = gameBoard.getPlayerLocation(i); 426 | gameBoard.move(i, diceRoll1 + diceRoll2); 427 | int currentLocation = gameBoard.getPlayerLocation(i); 428 | int currentOwnership = gameBoard.getSpaceOwnership(currentLocation); 429 | int futureLocation = 0; 430 | 431 | 432 | //if you pass GO collect $200 433 | if(pastLocation > currentLocation){ 434 | moneyAction.takeBank(gameBoard.getPlayer(i), &bank, 200); 435 | cout << "*** You Passed GO! Collect $200! ***" << endl << endl; 436 | } 437 | 438 | /********************** Actions for Specific Space Types **************************/ 439 | 440 | //if the space is some sort of property... 441 | if((gameBoard.spaceType(currentLocation) == "Property" || gameBoard.spaceType(currentLocation) == "RailRoad") || gameBoard.spaceType(currentLocation) == "Utility"){ 442 | 443 | //if the property is not owned... 444 | if(gameBoard.getSpaceOwnership(currentLocation) < 0) { 445 | 446 | char purchaseAnswer; 447 | string tempName1; 448 | string tempName2; 449 | ss << gameBoard.getSpaceName(currentLocation, 0); 450 | ss << gameBoard.getSpaceName(currentLocation, 1); 451 | ss >> tempName1; 452 | ss >> tempName2; 453 | ss.clear(); 454 | 455 | cout << "Would you like to purchase \"" << tempName1 << " " << tempName2 << "\" for " << gameBoard.getSpacePropertyCost(currentLocation) << "? (y or n): "; 456 | 457 | do{ 458 | cin >> purchaseAnswer; 459 | if(cin.fail()){ 460 | cin.clear(); 461 | cin.ignore(10000, '\n'); 462 | cout << "Improper Entry. Please enter 'y' or 'n': "; 463 | continue; 464 | } else if(purchaseAnswer != 'y' && purchaseAnswer != 'n'){ 465 | cout << "Error, please enter 'y' or 'n'! Try again: "; 466 | continue; 467 | } 468 | } while(purchaseAnswer!= 'y' && purchaseAnswer != 'n'); 469 | 470 | getline(cin, enterBuffer); 471 | cin.clear(); 472 | cout << endl; 473 | 474 | //you purchase the property 475 | if(purchaseAnswer == 'y'){ 476 | 477 | //if player cannot afford the property 478 | if(gameBoard.getPlayerMoney(i) - gameBoard.getSpacePropertyCost(currentLocation) <= 0) { 479 | cout << "You do not have enough money to purchase this property!" << endl << endl; 480 | 481 | //printing out player's money 482 | for(int j = 0; j < numOfPlayers; j++){ 483 | if(gameBoard.isPlayerAlive(j) == true){ 484 | cout << gameBoard.getPlayerName(j) << ": $"<< gameBoard.getPlayerMoney(j) << endl; 485 | } 486 | } 487 | 488 | cout << "~~~~~~~~~~~~~~~~~~" << endl << endl; 489 | continue; 490 | } 491 | 492 | //paying the money 493 | moneyAction.giveBank(gameBoard.getPlayer(i), &bank, gameBoard.getSpacePropertyCost(currentLocation)); 494 | gameBoard.setSpaceOwnership(currentLocation, i); 495 | 496 | //you do not purchase the property 497 | } else { 498 | cout << "You do not buy this property..." << endl << endl; 499 | } 500 | 501 | //if the property is owned... 502 | } else if(gameBoard.getSpaceOwnership(currentLocation) >= 0) { 503 | 504 | if(gameBoard.getPlayerName(i) != gameBoard.getPlayerName(gameBoard.getSpaceOwnership(currentLocation))){ 505 | cout << "You must pay $" << gameBoard.getSpaceRent(currentLocation) << " to " << gameBoard.getPlayerName(currentOwnership) << "." << endl << endl; 506 | moneyAction.executeAction(gameBoard.getPlayer(i), gameBoard.getPlayer(currentOwnership), gameBoard.getSpaceRent(currentLocation)); 507 | } 508 | 509 | //checking if players are out of money 510 | if(gameBoard.getPlayerMoney(i) <= 0 && gameBoard.isPlayerAlive(i) == true){ 511 | cout << "*************************************" << endl; 512 | cout << gameBoard.getPlayerName(i) << " is out of money! He drops out of the game!" << endl; 513 | gameBoard.playerLost(i); 514 | 515 | for(int j = 0; j < 40; j++){ 516 | if(gameBoard.getSpaceOwnership(j) == i){ 517 | gameBoard.setSpaceOwnership(j, -1); 518 | } 519 | } 520 | 521 | cout << "All of " << gameBoard.getPlayerName(i) << "'s properties are now returned to the bank." << endl; 522 | cout << "*************************************" << endl << endl; 523 | 524 | numAlive--; 525 | continue; 526 | } 527 | } 528 | 529 | //if the space is a Tax... 530 | } else if(gameBoard.spaceType(currentLocation) == "Tax"){ 531 | cout << "You must pay $" << gameBoard.getSpaceTax(currentLocation) << " in taxes!" << endl << endl; 532 | moneyAction.executeAction(gameBoard.getPlayer(i), &freePark, gameBoard.getSpaceTax(currentLocation)); 533 | 534 | //checking if players are out of money 535 | if(gameBoard.getPlayerMoney(i) <= 0 && gameBoard.isPlayerAlive(i) == true){ 536 | cout << "*************************************" << endl; 537 | cout << gameBoard.getPlayerName(i) << " is out of money! He drops out of the game!" << endl; 538 | gameBoard.playerLost(i); 539 | 540 | for(int j = 0; j < 40; j++){ 541 | if(gameBoard.getSpaceOwnership(j) == i){ 542 | gameBoard.setSpaceOwnership(j, -1); 543 | } 544 | } 545 | 546 | cout << "All of " << gameBoard.getPlayerName(i) << "'s properties are now returned to the bank." << endl; 547 | cout << "*************************************" << endl << endl; 548 | 549 | numAlive--; 550 | continue; 551 | } 552 | 553 | 554 | //if the space is Free Parking... 555 | } else if(gameBoard.spaceType(currentLocation) == "FreeParking"){ 556 | cout << "You landed on Financial Aid! Collect $" << freePark.getMoneyAmount() << "." << endl << endl; 557 | moneyAction.executeAction(&freePark, gameBoard.getPlayer(i), freePark.getMoneyAmount()); 558 | 559 | //if the space is Go To Jail... 560 | } else if(gameBoard.spaceType(currentLocation) == "GoJail"){ 561 | cout << "Go Directly to Jail and pay $100! >:D" << endl << endl; 562 | goToAction.executeAction(gameBoard.getPlayer(i), gameBoard.getPlayer(i), 10); 563 | 564 | moneyAction.executeAction(gameBoard.getPlayer(i), &freePark, 100); 565 | 566 | //if the space is Community Chest... 567 | } else if (gameBoard.spaceType(currentLocation) == "Community Chest"){ 568 | cout << "You landed on Community Chest!" << endl << endl; 569 | community[communityCount]->cardAction(&bank, gameBoard.getPlayer(i)); 570 | 571 | cout << community[communityCount]->getCardText(0) << endl; 572 | cout << community[communityCount]->getCardText(1) << endl << endl; 573 | 574 | futureLocation = gameBoard.getPlayerLocation(i); 575 | if(futureLocation < currentLocation){ 576 | moneyAction.takeBank(gameBoard.getPlayer(i), &bank, 200); 577 | cout << "*** You Passed GO! Collect $200! ***" << endl << endl; 578 | } 579 | 580 | communityCount++; 581 | if(communityCount > 9){ 582 | communityCount = 0; 583 | } 584 | 585 | //if the space is Chance... 586 | } else if (gameBoard.spaceType(currentLocation) == "Chance"){ 587 | cout << "You landed on Chance!" << endl << endl; 588 | chance[chanceCount]->cardAction(&bank, gameBoard.getPlayer(i)); 589 | 590 | cout << chance[chanceCount]->getCardText(0) << endl; 591 | cout << chance[chanceCount]->getCardText(1) << endl << endl; 592 | 593 | futureLocation = gameBoard.getPlayerLocation(i); 594 | if(futureLocation < currentLocation){ 595 | moneyAction.takeBank(gameBoard.getPlayer(i), &bank, 200); 596 | cout << "*** You Passed GO! Collect $200! ***" << endl << endl; 597 | } 598 | 599 | chanceCount++; 600 | if(chanceCount > 9){ 601 | chanceCount = 0; 602 | } 603 | } 604 | 605 | //printing out player's money 606 | for(int i = 0; i < numOfPlayers; i++){ 607 | if(gameBoard.isPlayerAlive(i) == true){ 608 | cout << gameBoard.getPlayerName(i) << ": $"<< gameBoard.getPlayerMoney(i) << endl; 609 | } 610 | } 611 | 612 | cout << "~~~~~~~~~~~~~~~~~~" << endl << endl; 613 | } 614 | } 615 | 616 | //checking if players are out of money 617 | for(int i = 0; i < numOfPlayers; i++){ 618 | if(gameBoard.getPlayerMoney(i) <= 0 && gameBoard.isPlayerAlive(i) == true){ 619 | cout << "*************************************" << endl; 620 | cout << gameBoard.getPlayerName(i) << " is out of money! He drops out of the game!" << endl; 621 | gameBoard.playerLost(i); 622 | 623 | for(int j = 0; j < 40; j++){ 624 | if(gameBoard.getSpaceOwnership(j) == i){ 625 | gameBoard.setSpaceOwnership(j, -1); 626 | } 627 | } 628 | 629 | cout << "All of " << gameBoard.getPlayerName(i) << "'s properties are now returned to the bank." << endl; 630 | cout << "*************************************" << endl << endl; 631 | 632 | numAlive--; 633 | continue; 634 | } 635 | } 636 | 637 | if(numAlive <= 1){ 638 | for(int x = 0; x < numOfPlayers; x++){ 639 | if(gameBoard.isPlayerAlive(x) == true){ 640 | cout << "****************************" << endl; 641 | cout << gameBoard.getPlayerName(x) << " is the winner! Congratulations!" << endl; 642 | cout << "****************************" << endl; 643 | } 644 | return 0; 645 | } 646 | } 647 | 648 | cout << "Press 'enter' to print the board." << endl; 649 | getline(cin, enterBuffer); 650 | 651 | if(cin.fail()){ 652 | cin.clear(); 653 | cin.ignore(10000, '\n'); 654 | cout << "Error with data entry. Terminating program!" << endl; 655 | return 1; 656 | } 657 | 658 | //print Game Board 659 | gameBoard.displayHorizontal(20, 30, numOfPlayers); 660 | gameBoard.displayVertical(19, 31, numOfPlayers); 661 | gameBoard.displayVertical(18, 32, numOfPlayers); 662 | gameBoard.displayVertical(17, 33, numOfPlayers); 663 | gameBoard.displayVertical(16, 34, numOfPlayers); 664 | gameBoard.displayVertical(15, 35, numOfPlayers); 665 | gameBoard.displayVertical(14, 36, numOfPlayers); 666 | gameBoard.displayVertical(13, 37, numOfPlayers); 667 | gameBoard.displayVertical(12, 38, numOfPlayers); 668 | gameBoard.displayVertical(11, 39, numOfPlayers); 669 | gameBoard.displayHorizontal(10, 0, numOfPlayers); 670 | 671 | } 672 | 673 | } 674 | -------------------------------------------------------------------------------- /bottomBar.cpp: -------------------------------------------------------------------------------- 1 | #include "bottomBar.h" 2 | #include "mainwindow.h" 3 | #include "dice.h" 4 | #include 5 | 6 | BottomBar::BottomBar() { 7 | 8 | currentPlayerNum = 0; 9 | bank = new Bank; 10 | freePark = new Player(0); 11 | communityCount = 0; 12 | chanceCount = 0; 13 | 14 | //creating shuffled index 15 | for( int i = 0; i < 10; i++){ 16 | index[i] = i; 17 | } 18 | int random1 = -1; 19 | int random2 = -1; 20 | int tempNum = -1; 21 | 22 | for(int i = 0; i < 50; i++){ 23 | random1 = rand()%10; 24 | random2 = rand()%10; 25 | 26 | tempNum = index[random1]; 27 | index[random1] = index[random2]; 28 | index[random2] = tempNum; 29 | } 30 | 31 | //setting up the Community Chest cards 32 | community = new Card*[10]; 33 | 34 | community[index[0]] = new CardMove(); 35 | community[index[1]] = new CardMoney(); 36 | community[index[2]] = new CardMoney(); 37 | community[index[3]] = new CardMove(); 38 | community[index[4]] = new CardMoney(); 39 | community[index[5]] = new CardMoney(); 40 | community[index[6]] = new CardMove(); 41 | community[index[7]] = new CardMoney(); 42 | community[index[8]] = new CardMoney(); 43 | community[index[9]] = new CardMoney(); 44 | 45 | //Community Card 0 46 | community[index[0]]->setCardText("./community/community0.png"); 47 | community[index[0]]->setAmount(0); 48 | 49 | //Community Card 1 50 | community[index[1]]->setCardText("./community/community1.png"); 51 | community[index[1]]->setAmount(75); 52 | 53 | //Community Card 2 54 | community[index[2]]->setCardText("./community/community2.png"); 55 | community[index[2]]->setAmount(150); 56 | 57 | //Community Card 3 58 | community[index[3]]->setCardText("./community/community3.png"); 59 | community[index[3]]->setAmount(24); 60 | 61 | //Community Card 4 62 | community[index[4]]->setCardText("./community/community4.png"); 63 | community[index[4]]->setAmount(100); 64 | 65 | //Community Card 5 66 | community[index[5]]->setCardText("./community/community5.png"); 67 | community[index[5]]->setAmount(20); 68 | 69 | //Community Card 6 70 | community[index[6]]->setCardText("./community/community6.png"); 71 | community[index[6]]->setAmount(39); 72 | 73 | //Community Card 7 74 | community[index[7]]->setCardText("./community/community7.png"); 75 | community[index[7]]->setAmount(15); 76 | 77 | //Community Card 8 78 | community[index[8]]->setCardText("./community/community8.png"); 79 | community[index[8]]->setAmount(200); 80 | 81 | //Community Card 9 82 | community[index[9]]->setCardText("./community/community9.png"); 83 | community[index[9]]->setAmount(20); 84 | 85 | 86 | //setting up the Chance cards 87 | chance = new Card*[10]; 88 | 89 | chance[index[0]] = new CardMove(); 90 | chance[index[1]] = new CardMove(); 91 | chance[index[2]] = new CardMoney(); 92 | chance[index[3]] = new CardMove(); 93 | chance[index[4]] = new CardMoney(); 94 | chance[index[5]] = new CardMoney(); 95 | chance[index[6]] = new CardMove(); 96 | chance[index[7]] = new CardMoney(); 97 | chance[index[8]] = new CardMove(); 98 | chance[index[9]] = new CardMoney(); 99 | 100 | //Chance Card 0 101 | chance[index[0]]->setCardText("./chance/chance0.png"); 102 | chance[index[0]]->setAmount(0); 103 | 104 | //Chance Card 1 105 | chance[index[1]]->setCardText("./chance/chance1.png"); 106 | chance[index[1]]->setAmount(28); 107 | 108 | //Chance Card 2 109 | chance[index[2]]->setCardText("./chance/chance2.png"); 110 | chance[index[2]]->setAmount(50); 111 | 112 | //Chance Card 3 113 | chance[index[3]]->setCardText("./chance/chance3.png"); 114 | chance[index[3]]->setAmount(11); 115 | 116 | //Chance Card 4 117 | chance[index[4]]->setCardText("./chance/chance4.png"); 118 | chance[index[4]]->setAmount(100); 119 | 120 | //Chance Card 5 121 | chance[index[5]]->setCardText("./chance/chance5.png"); 122 | chance[index[5]]->setAmount(15); 123 | 124 | //Chance Card 6 125 | chance[index[6]]->setCardText("./chance/chance6.png"); 126 | chance[index[6]]->setAmount(15); 127 | 128 | //Chance Card 7 129 | chance[index[7]]->setCardText("./chance/chance7.png"); 130 | chance[index[7]]->setAmount(15); 131 | 132 | //Chance Card 8 133 | chance[index[8]]->setCardText("./chance/chance8.png"); 134 | chance[index[8]]->setAmount(5); 135 | 136 | //Chance Card 9 137 | chance[index[9]]->setCardText("./chance/chance9.png"); 138 | chance[index[9]]->setAmount(100); 139 | 140 | 141 | 142 | //setting up all the buttons 143 | rollButton = new QPushButton("Roll Dice"); 144 | upgradeButton = new QPushButton("Upgrade"); 145 | purchaseButton = new QPushButton("Purchase"); 146 | player1Button = new QPushButton("See Player 1"); 147 | player2Button = new QPushButton("See Player 2"); 148 | player3Button = new QPushButton("See Player 3"); 149 | player4Button = new QPushButton("See Player 4"); 150 | endTurnButton = new QPushButton("End Turn"); 151 | 152 | layout = new QGridLayout; 153 | layout->addWidget(endTurnButton, 0, 0, 0); 154 | layout->addWidget(upgradeButton, 0, 1, 0); 155 | layout->addWidget(purchaseButton, 0, 2, 0); 156 | layout->addWidget(rollButton, 0, 3, 0); 157 | layout->addWidget(player1Button, 1, 0, 0); 158 | layout->addWidget(player2Button, 1, 1, 0); 159 | layout->addWidget(player3Button, 1, 2, 0); 160 | layout->addWidget(player4Button, 1, 3, 0); 161 | 162 | 163 | this->setMaximumSize(QSize(800, 100)); 164 | 165 | bottomWidget = new QWidget(this); 166 | bottomWidget->setLayout(layout); 167 | setWidget(bottomWidget); 168 | 169 | //connecting buttons 170 | connect(player1Button, SIGNAL(clicked()), this, SLOT(seePlayer1()) ); 171 | connect(player2Button, SIGNAL(clicked()), this, SLOT(seePlayer2()) ); 172 | connect(player3Button, SIGNAL(clicked()), this, SLOT(seePlayer3()) ); 173 | connect(player4Button, SIGNAL(clicked()), this, SLOT(seePlayer4()) ); 174 | connect(rollButton, SIGNAL(clicked()), this, SLOT(rollDice()) ); 175 | connect(endTurnButton, SIGNAL(clicked()), this, SLOT(endTurn()) ); 176 | connect(purchaseButton, SIGNAL(clicked()), this, SLOT(purchase()) ); 177 | connect(upgradeButton, SIGNAL(clicked()), this, SLOT(upgrade()) ); 178 | 179 | //disabling the endTurnButton 180 | endTurnButton->setEnabled(false); 181 | purchaseButton->setEnabled(false); 182 | upgradeButton->setEnabled(false); 183 | } 184 | 185 | void BottomBar::setPlayers(int numberPlayers, GUIPlayers* tempPlayers[]){ 186 | 187 | numberOfPlayers = numberPlayers; 188 | numAlive = numberPlayers; 189 | int NUM_PLAYERS = numberPlayers; 190 | allPlayers = new GUIPlayers*[NUM_PLAYERS]; 191 | allPlayers = tempPlayers; 192 | 193 | } 194 | 195 | void BottomBar::setCentralWidget(CentralWidget* tempBoard){ 196 | 197 | monopolyBoard = tempBoard; 198 | monopolyBoard->initializingCards(index); 199 | 200 | } 201 | 202 | void BottomBar::setMainWindow(MainWindow* tempWindow){ 203 | myWindow = new MainWindow(); 204 | myWindow = tempWindow; 205 | 206 | for(int i = 0; i < numberOfPlayers; i++){ 207 | allPlayers[i]->setBank(bank); 208 | } 209 | } 210 | 211 | void BottomBar::disableButtons(int num){ 212 | if(num == 1){ 213 | player4Button->setEnabled(false); 214 | } else if (num ==2){ 215 | player3Button->setEnabled(false); 216 | player4Button->setEnabled(false); 217 | } 218 | } 219 | 220 | void BottomBar::seePlayer1(){ 221 | myWindow->removeDockWidget( allPlayers[currentPlayerNum] ); 222 | myWindow->addDockWidget( Qt::RightDockWidgetArea, allPlayers[0] ); 223 | allPlayers[0]->show(); 224 | currentPlayerNum = 0; 225 | } 226 | 227 | void BottomBar::seePlayer2(){ 228 | myWindow->removeDockWidget( allPlayers[currentPlayerNum] ); 229 | myWindow->addDockWidget( Qt::RightDockWidgetArea, allPlayers[1] ); 230 | allPlayers[1]->show(); 231 | currentPlayerNum = 1; 232 | } 233 | 234 | void BottomBar::seePlayer3(){ 235 | if(numberOfPlayers > 2){ 236 | myWindow->removeDockWidget( allPlayers[currentPlayerNum] ); 237 | myWindow->addDockWidget( Qt::RightDockWidgetArea, allPlayers[2] ); 238 | allPlayers[2]->show(); 239 | currentPlayerNum = 2; 240 | } 241 | } 242 | 243 | void BottomBar::seePlayer4(){ 244 | if(numberOfPlayers > 3){ 245 | myWindow->removeDockWidget( allPlayers[currentPlayerNum] ); 246 | myWindow->addDockWidget( Qt::RightDockWidgetArea, allPlayers[3] ); 247 | allPlayers[3]->show(); 248 | currentPlayerNum = 3; 249 | } 250 | } 251 | 252 | void BottomBar::rollDice(){ 253 | 254 | //getting 2 random dice rolls 255 | Dice dice[2]; 256 | diceRoll1 = dice[0].rollDice(); 257 | diceRoll2 = dice[1].rollDice(); 258 | oldSpace = 0; 259 | newSpace = 0; 260 | int futureSpace = 0; 261 | 262 | //changing dice images on board 263 | monopolyBoard->changeDiceImg(diceRoll1, diceRoll2); 264 | 265 | //moving pieces 266 | oldSpace = myWindow->getPlayerLocation(currentPlayerNum); 267 | newSpace = oldSpace; 268 | newSpace += (diceRoll1 + diceRoll2); 269 | newSpace = newSpace % 40; 270 | myWindow->setPlayerLocation(currentPlayerNum, newSpace); 271 | monopolyBoard->movePieces(currentPlayerNum, myWindow->getPlayerPixels(currentPlayerNum)); 272 | 273 | if(oldSpace > newSpace) { 274 | moneyAction.takeBank(myWindow->getPlayer(currentPlayerNum), bank, 200); 275 | allPlayers[currentPlayerNum]->setMoneyText(); 276 | } 277 | 278 | /***************************** If new location is a Property *****************************/ 279 | 280 | int currentOwnership = myWindow->getSpaceOwnership(newSpace); 281 | 282 | //if the space is some sort of property... 283 | if((myWindow->spaceType(newSpace) == "Property" || myWindow->spaceType(newSpace) == "RailRoad") || myWindow->spaceType(newSpace) == "Utility"){ 284 | 285 | //if the property is not owned... 286 | if(myWindow->getSpaceOwnership(newSpace) < 0) { 287 | if(myWindow->getPlayerMoney(currentPlayerNum) - myWindow->getSpacePropertyCost(newSpace) <= 0) { 288 | purchaseButton->setEnabled(false); 289 | } else { 290 | purchaseButton->setEnabled(true); 291 | } 292 | 293 | //else if property is owned... 294 | } else if (myWindow->getSpaceOwnership(newSpace) >= 0) { 295 | 296 | if(myWindow->getPlayerName(currentPlayerNum) != myWindow->getPlayerName(myWindow->getSpaceOwnership(newSpace))){ 297 | 298 | moneyAction.executeAction(myWindow->getPlayer(currentPlayerNum), myWindow->getPlayer(currentOwnership), myWindow->getSpaceRent(newSpace)); 299 | allPlayers[currentPlayerNum]->setMoneyText(); 300 | } 301 | } 302 | 303 | 304 | //checking if players are out of money 305 | if(myWindow->getPlayerMoney(currentPlayerNum) <= 0 && myWindow->isPlayerAlive(currentPlayerNum) == true){ 306 | 307 | myWindow->playerLost(currentPlayerNum); 308 | 309 | for(int j = 0; j < 40; j++){ 310 | if(myWindow->getSpaceOwnership(j) == currentPlayerNum){ 311 | myWindow->setSpaceOwnership(j, -1); 312 | } 313 | } 314 | 315 | if(currentPlayerNum == 0) { 316 | player1Button->setEnabled(false); 317 | } else if (currentPlayerNum == 1) { 318 | player2Button->setEnabled(false); 319 | } else if (currentPlayerNum == 2) { 320 | player3Button->setEnabled(false); 321 | } else if (currentPlayerNum == 3) { 322 | player4Button->setEnabled(false); 323 | } 324 | 325 | monopolyBoard->hidePiece(currentPlayerNum); 326 | allPlayers[currentPlayerNum]->setMoneyText(); 327 | numAlive--; 328 | 329 | } 330 | 331 | /******************************* If new Location is a "Tax" **********************************/ 332 | 333 | //if the space is a Tax... 334 | } else if(myWindow->spaceType(newSpace) == "Tax"){ 335 | moneyAction.executeAction(myWindow->getPlayer(currentPlayerNum), freePark, myWindow->getSpaceTax(newSpace)); 336 | allPlayers[currentPlayerNum]->setMoneyText(); 337 | 338 | //checking if players are out of money 339 | if(myWindow->getPlayerMoney(currentPlayerNum) <= 0 && myWindow->isPlayerAlive(currentPlayerNum) == true){ 340 | 341 | myWindow->playerLost(currentPlayerNum); 342 | 343 | for(int j = 0; j < 40; j++){ 344 | if(myWindow->getSpaceOwnership(j) == currentPlayerNum){ 345 | myWindow->setSpaceOwnership(j, -1); 346 | } 347 | } 348 | 349 | if(currentPlayerNum == 0) { 350 | player1Button->setEnabled(false); 351 | } else if (currentPlayerNum == 1) { 352 | player2Button->setEnabled(false); 353 | } else if (currentPlayerNum == 2) { 354 | player3Button->setEnabled(false); 355 | } else if (currentPlayerNum == 3) { 356 | player4Button->setEnabled(false); 357 | } 358 | 359 | monopolyBoard->hidePiece(currentPlayerNum); 360 | allPlayers[currentPlayerNum]->setMoneyText(); 361 | numAlive--; 362 | } 363 | 364 | 365 | 366 | /******************************* If new Location is "Free Parking" **********************************/ 367 | 368 | //if the space is Free Parking... 369 | } else if(myWindow->spaceType(newSpace) == "FreeParking"){ 370 | moneyAction.executeAction(freePark, myWindow->getPlayer(currentPlayerNum), freePark->getMoneyAmount()); 371 | freePark->setMoneyAmount(0); 372 | allPlayers[currentPlayerNum]->setMoneyText(); 373 | 374 | 375 | /******************************* If new Location is "Go To Jail" **********************************/ 376 | 377 | //if the space is Go To Jail... 378 | } else if(myWindow->spaceType(newSpace) == "GoJail"){ 379 | myWindow->setPlayerLocation(currentPlayerNum, 10); 380 | moneyAction.executeAction(myWindow->getPlayer(currentPlayerNum), freePark, 200); 381 | monopolyBoard->movePieces(currentPlayerNum, myWindow->getPlayerPixels(currentPlayerNum)); 382 | 383 | 384 | /******************************* If new Location is "Community Chest" **********************************/ 385 | 386 | //if the space is Community Chest... 387 | } else if (myWindow->spaceType(newSpace) == "Community Chest"){ 388 | 389 | monopolyBoard->showCommunity(communityCount); 390 | 391 | community[communityCount]->cardAction(bank, myWindow->getPlayer(currentPlayerNum)); 392 | myWindow->setPlayerLocation(currentPlayerNum, myWindow->getPlayerLocation(currentPlayerNum)); 393 | monopolyBoard->movePieces(currentPlayerNum, myWindow->getPlayerPixels(currentPlayerNum)); 394 | 395 | 396 | futureSpace = myWindow->getPlayerLocation(currentPlayerNum); 397 | if(futureSpace < newSpace){ 398 | moneyAction.takeBank(myWindow->getPlayer(currentPlayerNum), bank, 200); 399 | } 400 | 401 | allPlayers[currentPlayerNum]->setMoneyText(); 402 | 403 | 404 | /******************************* If new Location is "Chance" **********************************/ 405 | 406 | //if the space is Chance... 407 | } else if (myWindow->spaceType(newSpace) == "Chance"){ 408 | 409 | monopolyBoard->showChance(chanceCount); 410 | 411 | chance[chanceCount]->cardAction(bank, myWindow->getPlayer(currentPlayerNum)); 412 | myWindow->setPlayerLocation(currentPlayerNum, myWindow->getPlayerLocation(currentPlayerNum)); 413 | monopolyBoard->movePieces(currentPlayerNum, myWindow->getPlayerPixels(currentPlayerNum)); 414 | 415 | 416 | futureSpace = myWindow->getPlayerLocation(currentPlayerNum); 417 | if(futureSpace < newSpace){ 418 | moneyAction.takeBank(myWindow->getPlayer(currentPlayerNum), bank, 200); 419 | } 420 | 421 | allPlayers[currentPlayerNum]->setMoneyText(); 422 | 423 | } 424 | 425 | //disabling and enabling buttons 426 | endTurnButton->setEnabled(true); 427 | rollButton->setEnabled(false); 428 | } 429 | 430 | void BottomBar::upgrade(){ 431 | 432 | allPlayers[currentPlayerNum]->enableUpgrade(); 433 | 434 | } 435 | 436 | void BottomBar::purchase(){ 437 | 438 | //if player cannot afford the property 439 | if(myWindow->getPlayerMoney(currentPlayerNum) - myWindow->getSpacePropertyCost(newSpace) <= 0) { 440 | //let Player know he can't purchase in GUI (pop up box) or disable button 441 | 442 | } else { 443 | 444 | //paying the money 445 | moneyAction.giveBank(myWindow->getPlayer(currentPlayerNum), bank, myWindow->getSpacePropertyCost(newSpace)); 446 | //moneyAction.giveBank(myWindow->getPlayer(currentPlayerNum), bank, 1000); 447 | myWindow->setSpaceOwnership(newSpace, currentPlayerNum); 448 | allPlayers[currentPlayerNum]->setMoneyText(); 449 | 450 | //if(myWindow->spaceType(newSpace) == "Property") { 451 | stringstream ss; 452 | string tempString1; 453 | string tempString2; 454 | 455 | ss << myWindow->getSpaceName(newSpace, 0); 456 | ss << myWindow->getSpaceName(newSpace, 1); 457 | ss >> tempString1; 458 | ss >> tempString2; 459 | ss.clear(); 460 | 461 | allPlayers[currentPlayerNum]->addProperty(newSpace, tempString1 + " " + tempString2, myWindow->getAllSpaces()); 462 | //} 463 | 464 | } 465 | 466 | //checking if players are out of money 467 | if(myWindow->getPlayerMoney(currentPlayerNum) <= 0 && myWindow->isPlayerAlive(currentPlayerNum) == true){ 468 | 469 | myWindow->playerLost(currentPlayerNum); 470 | 471 | for(int j = 0; j < 40; j++){ 472 | if(myWindow->getSpaceOwnership(j) == currentPlayerNum){ 473 | myWindow->setSpaceOwnership(j, -1); 474 | } 475 | } 476 | 477 | if(currentPlayerNum == 0) { 478 | player1Button->setEnabled(false); 479 | } else if (currentPlayerNum == 1) { 480 | player2Button->setEnabled(false); 481 | } else if (currentPlayerNum == 2) { 482 | player3Button->setEnabled(false); 483 | } else if (currentPlayerNum == 3) { 484 | player4Button->setEnabled(false); 485 | } 486 | 487 | monopolyBoard->hidePiece(currentPlayerNum); 488 | allPlayers[currentPlayerNum]->setMoneyText(); 489 | numAlive--; 490 | } 491 | 492 | purchaseButton->setEnabled(false); 493 | upgradeButton->setEnabled(true); 494 | } 495 | 496 | void BottomBar::endTurn(){ 497 | 498 | //incrimenting turn 499 | myWindow->nextTurn(); 500 | int next = myWindow->getPlayerTurn(); 501 | 502 | while (!(myWindow->isPlayerAlive(next))){ 503 | myWindow->nextTurn(); 504 | next = myWindow->getPlayerTurn(); 505 | } 506 | 507 | monopolyBoard->resetCommunity(communityCount); 508 | monopolyBoard->resetChance(chanceCount); 509 | 510 | communityCount++; 511 | if(communityCount > 9){ 512 | communityCount = 0; 513 | } 514 | chanceCount++; 515 | if(chanceCount > 9){ 516 | chanceCount = 0; 517 | } 518 | 519 | if(numAlive <= 1){ 520 | stringstream ss; 521 | string nextString; 522 | string fullText; 523 | string informativeText; 524 | 525 | rollButton->setEnabled(false); 526 | upgradeButton->setEnabled(false); 527 | purchaseButton->setEnabled(false); 528 | player1Button->setEnabled(false); 529 | player2Button->setEnabled(false); 530 | player3Button->setEnabled(false); 531 | player4Button->setEnabled(false); 532 | endTurnButton->setEnabled(false); 533 | allPlayers[next]->disableUpgrade(); 534 | 535 | ss << (next + 1); 536 | ss >> nextString; 537 | fullText = "Congratulations Player " + nextString + ", you have won the game!"; 538 | informativeText = "You are now the ruler of the universe."; 539 | QString qText = QString::fromStdString(fullText); 540 | QString qInfo = QString::fromStdString(informativeText); 541 | 542 | QMessageBox winnerDisplay; 543 | winnerDisplay.setText(qText); 544 | winnerDisplay.setInformativeText(qInfo); 545 | winnerDisplay.exec(); 546 | } 547 | 548 | myWindow->removeDockWidget( allPlayers[currentPlayerNum] ); 549 | myWindow->addDockWidget( Qt::RightDockWidgetArea, allPlayers[next] ); 550 | allPlayers[currentPlayerNum]->disableUpgrade(); 551 | allPlayers[next]->show(); 552 | currentPlayerNum = next; 553 | 554 | //disabling and enabling buttons 555 | endTurnButton->setEnabled(false); 556 | rollButton->setEnabled(true); 557 | purchaseButton->setEnabled(false); 558 | 559 | for(int i = 0; i < 40; i++){ 560 | if(myWindow->getSpaceOwnership(i) == currentPlayerNum && myWindow->spaceType(i) == "Property"){ 561 | upgradeButton->setEnabled(true); 562 | break; 563 | } else { 564 | upgradeButton->setEnabled(false); 565 | } 566 | } 567 | } 568 | 569 | 570 | 571 | 572 | 573 | 574 | 575 | 576 | -------------------------------------------------------------------------------- /bottomBar.h: -------------------------------------------------------------------------------- 1 | #ifndef BOTTOMBAR_H 2 | #define BOTTOMBAR_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "guiplayers.h" 9 | #include "centralwidget.h" 10 | #include "money_action.h" 11 | #include "bank.h" 12 | #include "card.h" 13 | #include "card_move.h" 14 | #include "card_money.h" 15 | 16 | class MainWindow; 17 | 18 | class BottomBar : public QDockWidget { 19 | Q_OBJECT 20 | 21 | protected: 22 | 23 | QPushButton* rollButton; 24 | QPushButton* upgradeButton; 25 | QPushButton* purchaseButton; 26 | QPushButton* endTurnButton; 27 | QPushButton* player1Button; 28 | QPushButton* player2Button; 29 | QPushButton* player3Button; 30 | QPushButton* player4Button; 31 | QGridLayout* layout; 32 | QWidget* bottomWidget; 33 | int diceRoll1; 34 | int diceRoll2; 35 | Bank* bank; 36 | Player* freePark; 37 | MoneyAction moneyAction; 38 | Card** community; 39 | Card** chance; 40 | int newSpace; 41 | int oldSpace; 42 | int numAlive; 43 | int communityCount; 44 | int chanceCount; 45 | int index[10]; 46 | 47 | //storing reference pointers 48 | GUIPlayers** allPlayers; 49 | CentralWidget* monopolyBoard; 50 | MainWindow* myWindow; 51 | int numberOfPlayers; 52 | int currentPlayerNum; 53 | 54 | private slots: 55 | //need to incorporate to make the buttons work 56 | 57 | void rollDice(); 58 | void upgrade(); 59 | void purchase(); 60 | void endTurn(); 61 | void seePlayer1(); 62 | void seePlayer2(); 63 | void seePlayer3(); 64 | void seePlayer4(); 65 | 66 | public: 67 | BottomBar(); 68 | void setPlayers(int numberPlayers, GUIPlayers* tempPlayers[]); 69 | void setCentralWidget(CentralWidget* tempBoard); 70 | void setMainWindow(MainWindow* tempWindow); 71 | void disableButtons(int num); 72 | 73 | 74 | }; 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /card.cpp: -------------------------------------------------------------------------------- 1 | #include "card.h" 2 | 3 | Card::Card(){ 4 | name = "Monopoly Card"; 5 | } 6 | -------------------------------------------------------------------------------- /card.h: -------------------------------------------------------------------------------- 1 | #ifndef CARD_H 2 | #define CARD_H 3 | 4 | #include 5 | #include "bank.h" 6 | #include "player.h" 7 | 8 | class Card { 9 | 10 | private: 11 | string name; 12 | 13 | public: 14 | Card(); 15 | virtual void setAmount(int num) = 0; 16 | virtual void setCardText(string text1) = 0; 17 | virtual void cardAction(Bank* bank1, Player* player1) = 0; 18 | virtual string getCardText(int num) = 0; 19 | 20 | }; 21 | #endif 22 | -------------------------------------------------------------------------------- /card_money.cpp: -------------------------------------------------------------------------------- 1 | #include "card_money.h" 2 | 3 | CardMoney::CardMoney() : Card(){ 4 | cardText = "Card Name"; 5 | moneyAmount = 0; 6 | } 7 | 8 | void CardMoney::setAmount(int num){ 9 | moneyAmount = num; 10 | } 11 | 12 | void CardMoney::setCardText(string text1){ 13 | cardText = text1; 14 | } 15 | 16 | void CardMoney::cardAction(Bank* bank1, Player* player1){ 17 | bank1->take_money(moneyAmount); 18 | player1->give_money(moneyAmount); 19 | } 20 | 21 | string CardMoney::getCardText(int num){ 22 | return cardText; 23 | } 24 | -------------------------------------------------------------------------------- /card_money.h: -------------------------------------------------------------------------------- 1 | #ifndef CARD_MONEY_H 2 | #define CARD_MONEY_H 3 | 4 | #include "card.h" 5 | 6 | class CardMoney : public Card { 7 | 8 | private: 9 | string cardText; 10 | int moneyAmount; 11 | 12 | public: 13 | CardMoney(); 14 | void setAmount(int num); 15 | void setCardText(string text1); 16 | void cardAction(Bank* bank1, Player* player1); 17 | string getCardText(int num); 18 | 19 | }; 20 | #endif 21 | -------------------------------------------------------------------------------- /card_move.cpp: -------------------------------------------------------------------------------- 1 | #include "card_move.h" 2 | 3 | CardMove::CardMove() : Card(){ 4 | cardText = "Card Name"; 5 | locationNum = -1; 6 | } 7 | 8 | void CardMove::setAmount(int num){ 9 | locationNum = num; 10 | } 11 | 12 | void CardMove::setCardText(string text1){ 13 | cardText = text1; 14 | } 15 | 16 | void CardMove::cardAction(Bank* bank1, Player* player1){ 17 | player1->setLocation(locationNum); 18 | } 19 | 20 | string CardMove::getCardText(int num){ 21 | return cardText; 22 | } 23 | -------------------------------------------------------------------------------- /card_move.h: -------------------------------------------------------------------------------- 1 | #ifndef CARD_MOVE_H 2 | #define CARD_MOVE_H 3 | 4 | #include "card.h" 5 | 6 | class CardMove : public Card { 7 | 8 | private: 9 | string cardText; 10 | int locationNum; 11 | 12 | public: 13 | CardMove(); 14 | void setAmount(int num); 15 | void setCardText(string text1); 16 | void cardAction(Bank* bank1, Player* player1); 17 | string getCardText(int num); 18 | 19 | }; 20 | #endif 21 | -------------------------------------------------------------------------------- /centralwidget.cpp: -------------------------------------------------------------------------------- 1 | #include "centralwidget.h" 2 | 3 | CentralWidget::CentralWidget(int tempNum, Player* tempPlayers): QWidget() { 4 | numPlayers = tempNum; 5 | 6 | //setting up the chance and community chest images 7 | boardLabel = new QLabel( this ); //adding current widget to another widget 8 | boardLabel->setPixmap( QPixmap("./Images/Monopoly.jpg") ); 9 | this->setGeometry(0, 0, 650, 650); 10 | 11 | //setting up the dice images 12 | dice1 = new QLabel(this); 13 | dice1->setPixmap(QPixmap("./Dice/dice1.png")); 14 | dice1->setGeometry(430, 370, 35, 35); 15 | dice1->setFixedWidth(35); 16 | dice1->setFixedHeight(35); 17 | dice1->setScaledContents(true); 18 | dice1->show(); 19 | 20 | dice2 = new QLabel(this); 21 | dice2->setPixmap(QPixmap("./Dice/dice1.png")); 22 | dice2->setGeometry(470, 370, 35, 35); 23 | dice2->setFixedWidth(35); 24 | dice2->setFixedHeight(35); 25 | dice2->setScaledContents(true); 26 | dice2->show(); 27 | 28 | 29 | //Create the covers for the card deck 30 | chanceCover = new QLabel(this); 31 | chanceCover->setPixmap(QPixmap("./Chance/chanceTemplate.jpg")); 32 | chanceCover->setGeometry(102, 102, 180, 100); 33 | chanceCover->setFixedWidth(180); 34 | chanceCover->setFixedHeight(100); 35 | chanceCover->setScaledContents(true); 36 | chanceCover->show(); 37 | 38 | communityCover = new QLabel(this); 39 | communityCover->setPixmap(QPixmap("./Community Chest/communityTemplate.jpg")); 40 | communityCover->setGeometry(366, 442, 180, 100); 41 | communityCover->setFixedWidth(180); 42 | communityCover->setFixedHeight(100); 43 | communityCover->setScaledContents(true); 44 | communityCover->show(); 45 | 46 | //setting up Player Icons 47 | playerIcons = new QLabel*[numPlayers]; 48 | int pieceCounter = 0; 49 | 50 | for(int i = 0; i < numPlayers; i++){ 51 | 52 | 53 | string tempName = tempPlayers[i].getGamePieceName(); 54 | QString qName = QString::fromStdString(tempName); 55 | 56 | playerIcons[i] = new QLabel(this); 57 | playerIcons[i]->setPixmap(QPixmap(qName)); 58 | 59 | Coordinates tempLocation = tempPlayers[i].getPixelLocation(); 60 | 61 | if(numPlayers == 2) { 62 | playerIcons[i]->setGeometry(tempLocation.x + (i*22), tempLocation.y, 25, 25); 63 | } else if (numPlayers == 3) { 64 | if(i < 2){ 65 | playerIcons[i]->setGeometry(tempLocation.x + (i*22), tempLocation.y, 25, 25); 66 | } else if (i == 2) { 67 | playerIcons[i]->setGeometry(tempLocation.x + (pieceCounter*22), tempLocation.y + (22), 25, 25); 68 | } 69 | 70 | } else if (numPlayers == 4) { 71 | if (i < 2) { 72 | playerIcons[i]->setGeometry(tempLocation.x + (i*22), tempLocation.y, 25, 25); 73 | } else if (i >= 2 && i < 4) { 74 | playerIcons[i]->setGeometry(tempLocation.x + (pieceCounter*22), tempLocation.y + (22), 25, 25); 75 | pieceCounter++; 76 | } 77 | } 78 | 79 | playerIcons[i]->setFixedWidth(25); 80 | playerIcons[i]->setFixedHeight(25); 81 | playerIcons[i]->setScaledContents(true); 82 | playerIcons[i]->show(); 83 | } 84 | 85 | 86 | } 87 | 88 | void CentralWidget::drawCard() { 89 | //draw card slot 90 | } 91 | 92 | void CentralWidget::movePieces(int playerNum, Coordinates tempCoordinates){ 93 | 94 | Coordinates tempLocation = tempCoordinates; 95 | 96 | if(playerNum == 0) { 97 | playerIcons[playerNum]->setGeometry(tempLocation.x, tempLocation.y, 25, 25); 98 | } else if (playerNum == 1){ 99 | playerIcons[playerNum]->setGeometry(tempLocation.x + (22), tempLocation.y, 25, 25); 100 | } else if (playerNum == 2) { 101 | playerIcons[playerNum]->setGeometry(tempLocation.x, tempLocation.y + (22), 25, 25); 102 | } else if (playerNum == 3) { 103 | playerIcons[playerNum]->setGeometry(tempLocation.x + (22), tempLocation.y + (22), 25, 25); 104 | } 105 | } 106 | 107 | void CentralWidget::changeDiceImg(int rollNum1, int rollNum2){ 108 | 109 | if(rollNum1 == 1) { 110 | dice1->setPixmap(QPixmap("./Dice/dice1.png")); 111 | } else if (rollNum1 == 2) { 112 | dice1->setPixmap(QPixmap("./Dice/dice2.png")); 113 | } else if (rollNum1 == 3) { 114 | dice1->setPixmap(QPixmap("./Dice/dice3.png")); 115 | } else if (rollNum1 == 4) { 116 | dice1->setPixmap(QPixmap("./Dice/dice4.png")); 117 | } else if (rollNum1 == 5) { 118 | dice1->setPixmap(QPixmap("./Dice/dice5.png")); 119 | } else if (rollNum1 == 6) { 120 | dice1->setPixmap(QPixmap("./Dice/dice6.png")); 121 | } 122 | 123 | if(rollNum2 == 1) { 124 | dice2->setPixmap(QPixmap("./Dice/dice1.png")); 125 | } else if (rollNum2 == 2) { 126 | dice2->setPixmap(QPixmap("./Dice/dice2.png")); 127 | } else if (rollNum2 == 3) { 128 | dice2->setPixmap(QPixmap("./Dice/dice3.png")); 129 | } else if (rollNum2 == 4) { 130 | dice2->setPixmap(QPixmap("./Dice/dice4.png")); 131 | } else if (rollNum2 == 5) { 132 | dice2->setPixmap(QPixmap("./Dice/dice5.png")); 133 | } else if (rollNum2 == 6) { 134 | dice2->setPixmap(QPixmap("./Dice/dice6.png")); 135 | } 136 | 137 | 138 | } 139 | 140 | void CentralWidget::hidePiece(int playerNum){ 141 | playerIcons[playerNum]->hide(); 142 | } 143 | 144 | void CentralWidget::showCommunity(int cardNum){ 145 | communityCover->hide(); 146 | communityCards[cardNum]->show(); 147 | } 148 | 149 | void CentralWidget::resetCommunity(int cardNum){ 150 | communityCards[cardNum]->hide(); 151 | communityCover->show(); 152 | } 153 | 154 | void CentralWidget::showChance(int cardNum){ 155 | chanceCover->hide(); 156 | chanceCards[cardNum]->show(); 157 | } 158 | 159 | void CentralWidget::resetChance(int cardNum){ 160 | chanceCards[cardNum]->hide(); 161 | chanceCover->show(); 162 | 163 | } 164 | 165 | void CentralWidget::initializingCards(int tempArray[]){ 166 | 167 | communityCards = new QLabel*[10]; 168 | chanceCards = new QLabel*[10]; 169 | 170 | 171 | //chance card 0 172 | chanceCards[tempArray[0]] = new QLabel(this); 173 | chanceCards[tempArray[0]]->setPixmap(QPixmap("./Chance/chance0.png")); 174 | chanceCards[tempArray[0]]->setGeometry(102, 102, 180, 100); 175 | chanceCards[tempArray[0]]->setFixedWidth(180); 176 | chanceCards[tempArray[0]]->setFixedHeight(100); 177 | chanceCards[tempArray[0]]->setScaledContents(true); 178 | chanceCards[tempArray[0]]->hide(); 179 | 180 | //chance card 1 181 | chanceCards[tempArray[1]] = new QLabel(this); 182 | chanceCards[tempArray[1]]->setPixmap(QPixmap("./Chance/chance1.png")); 183 | chanceCards[tempArray[1]]->setGeometry(102, 102, 180, 100); 184 | chanceCards[tempArray[1]]->setFixedWidth(180); 185 | chanceCards[tempArray[1]]->setFixedHeight(100); 186 | chanceCards[tempArray[1]]->setScaledContents(true); 187 | chanceCards[tempArray[1]]->hide(); 188 | 189 | //chance card 2 190 | chanceCards[tempArray[2]] = new QLabel(this); 191 | chanceCards[tempArray[2]]->setPixmap(QPixmap("./Chance/chance2.png")); 192 | chanceCards[tempArray[2]]->setGeometry(102, 102, 180, 100); 193 | chanceCards[tempArray[2]]->setFixedWidth(180); 194 | chanceCards[tempArray[2]]->setFixedHeight(100); 195 | chanceCards[tempArray[2]]->setScaledContents(true); 196 | chanceCards[tempArray[2]]->hide(); 197 | 198 | //chance card 3 199 | chanceCards[tempArray[3]] = new QLabel(this); 200 | chanceCards[tempArray[3]]->setPixmap(QPixmap("./Chance/chance3.png")); 201 | chanceCards[tempArray[3]]->setGeometry(102, 102, 180, 100); 202 | chanceCards[tempArray[3]]->setFixedWidth(180); 203 | chanceCards[tempArray[3]]->setFixedHeight(100); 204 | chanceCards[tempArray[3]]->setScaledContents(true); 205 | chanceCards[tempArray[3]]->hide(); 206 | 207 | //chance card 4 208 | chanceCards[tempArray[4]] = new QLabel(this); 209 | chanceCards[tempArray[4]]->setPixmap(QPixmap("./Chance/chance4.png")); 210 | chanceCards[tempArray[4]]->setGeometry(102, 102, 180, 100); 211 | chanceCards[tempArray[4]]->setFixedWidth(180); 212 | chanceCards[tempArray[4]]->setFixedHeight(100); 213 | chanceCards[tempArray[4]]->setScaledContents(true); 214 | chanceCards[tempArray[4]]->hide(); 215 | 216 | //chance card 5 217 | chanceCards[tempArray[5]] = new QLabel(this); 218 | chanceCards[tempArray[5]]->setPixmap(QPixmap("./Chance/chance5.png")); 219 | chanceCards[tempArray[5]]->setGeometry(102, 102, 180, 100); 220 | chanceCards[tempArray[5]]->setFixedWidth(180); 221 | chanceCards[tempArray[5]]->setFixedHeight(100); 222 | chanceCards[tempArray[5]]->setScaledContents(true); 223 | chanceCards[tempArray[5]]->hide(); 224 | 225 | //chance card 6 226 | chanceCards[tempArray[6]] = new QLabel(this); 227 | chanceCards[tempArray[6]]->setPixmap(QPixmap("./Chance/chance6.png")); 228 | chanceCards[tempArray[6]]->setGeometry(102, 102, 180, 100); 229 | chanceCards[tempArray[6]]->setFixedWidth(180); 230 | chanceCards[tempArray[6]]->setFixedHeight(100); 231 | chanceCards[tempArray[6]]->setScaledContents(true); 232 | chanceCards[tempArray[6]]->hide(); 233 | 234 | //chance card 7 235 | chanceCards[tempArray[7]] = new QLabel(this); 236 | chanceCards[tempArray[7]]->setPixmap(QPixmap("./Chance/chance7.png")); 237 | chanceCards[tempArray[7]]->setGeometry(102, 102, 180, 100); 238 | chanceCards[tempArray[7]]->setFixedWidth(180); 239 | chanceCards[tempArray[7]]->setFixedHeight(100); 240 | chanceCards[tempArray[7]]->setScaledContents(true); 241 | chanceCards[tempArray[7]]->hide(); 242 | 243 | //chance card 8 244 | chanceCards[tempArray[8]] = new QLabel(this); 245 | chanceCards[tempArray[8]]->setPixmap(QPixmap("./Chance/chance8.png")); 246 | chanceCards[tempArray[8]]->setGeometry(102, 102, 180, 100); 247 | chanceCards[tempArray[8]]->setFixedWidth(180); 248 | chanceCards[tempArray[8]]->setFixedHeight(100); 249 | chanceCards[tempArray[8]]->setScaledContents(true); 250 | chanceCards[tempArray[8]]->hide(); 251 | 252 | //chance card 9 253 | chanceCards[tempArray[9]] = new QLabel(this); 254 | chanceCards[tempArray[9]]->setPixmap(QPixmap("./Chance/chance9.png")); 255 | chanceCards[tempArray[9]]->setGeometry(102, 102, 180, 100); 256 | chanceCards[tempArray[9]]->setFixedWidth(180); 257 | chanceCards[tempArray[9]]->setFixedHeight(100); 258 | chanceCards[tempArray[9]]->setScaledContents(true); 259 | chanceCards[tempArray[9]]->hide(); 260 | 261 | //community card 0 262 | communityCards[tempArray[0]] = new QLabel(this); 263 | communityCards[tempArray[0]]->setPixmap(QPixmap("./Community Chest/community0.png")); 264 | communityCards[tempArray[0]]->setGeometry(366, 442, 180, 100); 265 | communityCards[tempArray[0]]->setFixedWidth(180); 266 | communityCards[tempArray[0]]->setFixedHeight(100); 267 | communityCards[tempArray[0]]->setScaledContents(true); 268 | communityCards[tempArray[0]]->hide(); 269 | 270 | //community card 1 271 | communityCards[tempArray[1]] = new QLabel(this); 272 | communityCards[tempArray[1]]->setPixmap(QPixmap("./Community Chest/community1.png")); 273 | communityCards[tempArray[1]]->setGeometry(366, 442, 180, 100); 274 | communityCards[tempArray[1]]->setFixedWidth(180); 275 | communityCards[tempArray[1]]->setFixedHeight(100); 276 | communityCards[tempArray[1]]->setScaledContents(true); 277 | communityCards[tempArray[1]]->hide(); 278 | 279 | //community card 2 280 | communityCards[tempArray[2]] = new QLabel(this); 281 | communityCards[tempArray[2]]->setPixmap(QPixmap("./Community Chest/community2.png")); 282 | communityCards[tempArray[2]]->setGeometry(366, 442, 180, 100); 283 | communityCards[tempArray[2]]->setFixedWidth(180); 284 | communityCards[tempArray[2]]->setFixedHeight(100); 285 | communityCards[tempArray[2]]->setScaledContents(true); 286 | communityCards[tempArray[2]]->hide(); 287 | 288 | //community card 3 289 | communityCards[tempArray[3]] = new QLabel(this); 290 | communityCards[tempArray[3]]->setPixmap(QPixmap("./Community Chest/community3.png")); 291 | communityCards[tempArray[3]]->setGeometry(366, 442, 180, 100); 292 | communityCards[tempArray[3]]->setFixedWidth(180); 293 | communityCards[tempArray[3]]->setFixedHeight(100); 294 | communityCards[tempArray[3]]->setScaledContents(true); 295 | communityCards[tempArray[3]]->hide(); 296 | 297 | //community card 4 298 | communityCards[tempArray[4]] = new QLabel(this); 299 | communityCards[tempArray[4]]->setPixmap(QPixmap("./Community Chest/community4.png")); 300 | communityCards[tempArray[4]]->setGeometry(366, 442, 180, 100); 301 | communityCards[tempArray[4]]->setFixedWidth(180); 302 | communityCards[tempArray[4]]->setFixedHeight(100); 303 | communityCards[tempArray[4]]->setScaledContents(true); 304 | communityCards[tempArray[4]]->hide(); 305 | 306 | //community card 5 307 | communityCards[tempArray[5]] = new QLabel(this); 308 | communityCards[tempArray[5]]->setPixmap(QPixmap("./Community Chest/community5.png")); 309 | communityCards[tempArray[5]]->setGeometry(366, 442, 180, 100); 310 | communityCards[tempArray[5]]->setFixedWidth(180); 311 | communityCards[tempArray[5]]->setFixedHeight(100); 312 | communityCards[tempArray[5]]->setScaledContents(true); 313 | communityCards[tempArray[5]]->hide(); 314 | 315 | //community card 6 316 | communityCards[tempArray[6]] = new QLabel(this); 317 | communityCards[tempArray[6]]->setPixmap(QPixmap("./Community Chest/community6.png")); 318 | communityCards[tempArray[6]]->setGeometry(366, 442, 180, 100); 319 | communityCards[tempArray[6]]->setFixedWidth(180); 320 | communityCards[tempArray[6]]->setFixedHeight(100); 321 | communityCards[tempArray[6]]->setScaledContents(true); 322 | communityCards[tempArray[6]]->hide(); 323 | 324 | //community card 7 325 | communityCards[tempArray[7]] = new QLabel(this); 326 | communityCards[tempArray[7]]->setPixmap(QPixmap("./Community Chest/community7.png")); 327 | communityCards[tempArray[7]]->setGeometry(366, 442, 180, 100); 328 | communityCards[tempArray[7]]->setFixedWidth(180); 329 | communityCards[tempArray[7]]->setFixedHeight(100); 330 | communityCards[tempArray[7]]->setScaledContents(true); 331 | communityCards[tempArray[7]]->hide(); 332 | 333 | //community card 8 334 | communityCards[tempArray[8]] = new QLabel(this); 335 | communityCards[tempArray[8]]->setPixmap(QPixmap("./Community Chest/community8.png")); 336 | communityCards[tempArray[8]]->setGeometry(366, 442, 180, 100); 337 | communityCards[tempArray[8]]->setFixedWidth(180); 338 | communityCards[tempArray[8]]->setFixedHeight(100); 339 | communityCards[tempArray[8]]->setScaledContents(true); 340 | communityCards[tempArray[8]]->hide(); 341 | 342 | //community card 9 343 | communityCards[tempArray[9]] = new QLabel(this); 344 | communityCards[tempArray[9]]->setPixmap(QPixmap("./Community Chest/community9.png")); 345 | communityCards[tempArray[9]]->setGeometry(366, 442, 180, 100); 346 | communityCards[tempArray[9]]->setFixedWidth(180); 347 | communityCards[tempArray[9]]->setFixedHeight(100); 348 | communityCards[tempArray[9]]->setScaledContents(true); 349 | communityCards[tempArray[9]]->hide(); 350 | } 351 | 352 | 353 | 354 | -------------------------------------------------------------------------------- /centralwidget.h: -------------------------------------------------------------------------------- 1 | #ifndef CENTRALWIDGET_H 2 | #define CENTRALWIDGET_H 3 | 4 | #include 5 | #include "player.h" 6 | 7 | class CentralWidget: public QWidget { 8 | Q_OBJECT 9 | 10 | private: 11 | QLabel* chanceCover; 12 | QLabel* communityCover; 13 | QLabel* boardLabel; 14 | QLabel* dice1; 15 | QLabel* dice2; 16 | QLabel** playerIcons; 17 | int numPlayers; 18 | QLabel** communityCards; 19 | QLabel** chanceCards; 20 | //Coordinates boardSpace[40]; 21 | //QPixmap* cardFaceDown; 22 | //QPixmap* cardFaceUp; 23 | //bool isFaceDown; 24 | 25 | private slots: 26 | void drawCard(); 27 | 28 | public: 29 | CentralWidget(int tempNum, Player* tempPlayers); 30 | void changeDiceImg(int rollNum1, int rollNum2); 31 | void movePieces(int playerNum, Coordinates tempCoordinates); 32 | void hidePiece(int playerNum); 33 | void showCommunity(int cardNum); 34 | void resetCommunity(int cardNum); 35 | void showChance(int cardNum); 36 | void resetChance(int cardNum); 37 | void initializingCards(int tempArray[]); 38 | 39 | }; 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /dice.cpp: -------------------------------------------------------------------------------- 1 | #include "dice.h" 2 | #include 3 | #include 4 | 5 | Dice::Dice(){ 6 | sides = 6; 7 | } 8 | 9 | int Dice::rollDice(){ 10 | 11 | int roll = 0; 12 | roll = rand() % sides + 1; 13 | 14 | return roll; 15 | } 16 | -------------------------------------------------------------------------------- /dice.h: -------------------------------------------------------------------------------- 1 | #ifndef DICE_H 2 | #define DICE_H 3 | 4 | class Dice { 5 | 6 | private: 7 | int sides; 8 | 9 | public: 10 | //constructor 11 | Dice(); 12 | 13 | //functions to get values 14 | int rollDice(); 15 | 16 | }; 17 | #endif 18 | -------------------------------------------------------------------------------- /goToAction.cpp: -------------------------------------------------------------------------------- 1 | #include "goToAction.h" 2 | 3 | GoToAction::GoToAction() : Action(){ 4 | spaceLocation = 0; 5 | } 6 | 7 | void GoToAction::executeAction(Player* player1, Player* player2, int amount){ 8 | player1->setLocation(amount); 9 | } 10 | 11 | -------------------------------------------------------------------------------- /goToAction.h: -------------------------------------------------------------------------------- 1 | #ifndef GOTOACTION_H 2 | #define GOTOACTION_H 3 | 4 | #include "action.h" 5 | #include "player.h" 6 | 7 | class GoToAction : public Action { 8 | 9 | private: 10 | int spaceLocation; 11 | 12 | public: 13 | GoToAction(); 14 | void executeAction(Player* player1, Player* player2, int amount); 15 | 16 | }; 17 | #endif 18 | -------------------------------------------------------------------------------- /guiplayers.cpp: -------------------------------------------------------------------------------- 1 | #include "guiplayers.h" 2 | 3 | GUIPlayers::GUIPlayers(Player* p, int playerNum){ 4 | 5 | player = p; 6 | stringstream ss; 7 | ownedProperties = new QPushButton*[40]; 8 | ownedCount = 0; 9 | 10 | //player's number 11 | string tempNum; 12 | ss << (playerNum + 1); 13 | ss >> tempNum; 14 | tempNum = "Player " + tempNum; 15 | ss.clear(); 16 | 17 | QString qNum = QString::fromStdString(tempNum); 18 | numLabel = new QLabel( this ); 19 | numLabel->setText( qNum ); 20 | 21 | //player's money 22 | ss << player->getMoneyAmount(); 23 | string tempMoney; 24 | ss >> tempMoney; 25 | tempMoney = ("$" + tempMoney); 26 | ss.clear(); 27 | 28 | QString qMoney = QString::fromStdString(tempMoney); 29 | moneyLabel = new QLabel( this ); 30 | moneyLabel->setText( qMoney ); 31 | 32 | //player's game piece 33 | string tempPiece = player->getGamePieceName(); 34 | QString qTempPiece = QString::fromStdString(tempPiece); 35 | gamePieceImg = new QLabel(this); 36 | gamePieceImg->setPixmap(qTempPiece); 37 | gamePieceImg->setFixedWidth(55); 38 | gamePieceImg->setFixedHeight(50); 39 | gamePieceImg->setScaledContents(true); 40 | 41 | //Adding all parts to layout 42 | layout = new QVBoxLayout; 43 | layout->addWidget(gamePieceImg); 44 | layout->addWidget(numLabel); 45 | layout->addWidget(moneyLabel); 46 | 47 | sideBar = new QWidget(this); 48 | sideBar->setLayout(layout); 49 | setWidget(sideBar); 50 | 51 | this->setMinimumSize(QSize(143, 650)); 52 | this->setMaximumSize(QSize(143, 650)); 53 | } 54 | 55 | GUIPlayers::GUIPlayers(){ 56 | 57 | } 58 | 59 | void GUIPlayers::setMoneyText(){ 60 | stringstream ss; 61 | ss << player->getMoneyAmount(); 62 | string tempMoney; 63 | ss >> tempMoney; 64 | tempMoney = ("$" + tempMoney); 65 | ss.clear(); 66 | 67 | QString qMoney = QString::fromStdString(tempMoney); 68 | moneyLabel->setText( qMoney ); 69 | } 70 | 71 | void GUIPlayers::addProperty(int propertyNum, string propertyName, Space** tempArray){ 72 | 73 | QString tempName = QString::fromStdString(propertyName); 74 | QPushButton* newButton = new QPushButton(tempName); 75 | ownedProperties[ownedCount] = newButton; 76 | ownedProperties[ownedCount]->setEnabled(false); 77 | currentPropertyNum = propertyNum; 78 | allProperties[ownedCount] = propertyNum; 79 | 80 | /* 81 | QSignalMapper* signalMapper = new QSignalMapper(this); 82 | 83 | for(int i = 0; i < ownedCount; i++){ 84 | 85 | connect(ownedProperties[ownedCount], SIGNAL(clicked(i)), this, SLOT(upgradeSpace(i)) ); 86 | 87 | //connect (ownedProperties[i], SIGNAL(clicked()), signalMapper, SLOT(map())); 88 | //signalMapper->setMapping(ownedProperties[i], i); 89 | 90 | 91 | //connect(ownedProperties[i], SIGNAL(clicked()), this, SLOT(upgradeSpace()) ); 92 | } 93 | //connect (signalMapper, SIGNAL(mapped(int)), this, SIGNAL(clicked(int))); 94 | //connect (signalMapper, SIGNAL(mapped(int)), this, SLOT(upgradeSpace(int))); 95 | 96 | */ 97 | 98 | 99 | connect(ownedProperties[ownedCount], SIGNAL(clicked()), this, SLOT(upgradeSpace()) ); 100 | 101 | 102 | 103 | 104 | 105 | 106 | layout->addWidget(ownedProperties[ownedCount]); 107 | sideBar->setLayout(layout); 108 | setWidget(sideBar); 109 | ownedCount++; 110 | 111 | } 112 | 113 | void GUIPlayers::enableUpgrade(){ 114 | 115 | for( int i = 0; i < ownedCount; i++){ 116 | if(((player->getMoneyAmount() - allSpaces[allProperties[i]]->getPropertyCost()) <= 0) || !(allSpaces[allProperties[i]]->getType() == "Property")) { 117 | ownedProperties[i]->setEnabled(false); 118 | } else { 119 | ownedProperties[i]->setEnabled(true); 120 | } 121 | } 122 | 123 | } 124 | 125 | void GUIPlayers::disableUpgrade(){ 126 | 127 | for( int i = 0; i < ownedCount; i++){ 128 | ownedProperties[i]->setEnabled(false); 129 | } 130 | 131 | } 132 | 133 | void GUIPlayers::upgradeSpace(){ 134 | bool isUpgraded; 135 | //int currentSpace = allProperties[num]; 136 | isUpgraded = allSpaces[currentPropertyNum]->upgrade(); 137 | 138 | if(isUpgraded == true){ 139 | 140 | if((player->getMoneyAmount() - allSpaces[currentPropertyNum]->getPropertyCost()) <= 0) { 141 | string text = "You do not have enough money to upgrade this property!"; 142 | QString qText = QString::fromStdString(text); 143 | 144 | QMessageBox UpGradeLimit; 145 | UpGradeLimit.setText(qText); 146 | UpGradeLimit.exec(); 147 | } else { 148 | moneyAction.giveBank(player, bankPointer, allSpaces[currentPropertyNum]->getPropertyCost()); 149 | } 150 | 151 | 152 | } else { 153 | 154 | string text = "Maximum (5) amount of upgrades reached for this property!"; 155 | QString qText = QString::fromStdString(text); 156 | 157 | QMessageBox maxUpgrade; 158 | maxUpgrade.setText(qText); 159 | maxUpgrade.exec(); 160 | } 161 | 162 | setMoneyText(); 163 | disableUpgrade(); 164 | 165 | } 166 | 167 | void GUIPlayers::setAllSpaces(Space** spaceArray){ 168 | allSpaces = new Space*[40]; 169 | allSpaces = spaceArray; 170 | } 171 | 172 | void GUIPlayers::setBank(Bank* tempBank){ 173 | bankPointer = new Bank; 174 | bankPointer = tempBank; 175 | } 176 | 177 | 178 | 179 | 180 | 181 | -------------------------------------------------------------------------------- /guiplayers.h: -------------------------------------------------------------------------------- 1 | #ifndef GUIPLAYERS_H 2 | #define GUIPLAYERS_H 3 | 4 | #include "player.h" 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include "space.h" 11 | #include "money_action.h" 12 | #include "bank.h" 13 | #include 14 | 15 | 16 | class GUIPlayers : public QDockWidget { 17 | Q_OBJECT 18 | 19 | protected: 20 | Player* player; 21 | QLabel *numLabel; 22 | QLabel *moneyLabel; 23 | QVBoxLayout* layout; 24 | QWidget* sideBar; 25 | QLabel* gamePieceImg; 26 | QPushButton** ownedProperties; 27 | int currentPropertyNum; 28 | int allProperties[40]; 29 | int ownedCount; 30 | Space** allSpaces; 31 | MoneyAction moneyAction; 32 | Bank* bankPointer; 33 | 34 | private slots: 35 | void upgradeSpace(); 36 | 37 | public: 38 | GUIPlayers(Player* p, int playerNum); 39 | GUIPlayers(); 40 | void setMoneyText(); 41 | void addProperty(int propertyNum, string propertyName, Space** spaceArray); 42 | void enableUpgrade(); 43 | void disableUpgrade(); 44 | void setAllSpaces(Space** spaceArray); 45 | void setBank(Bank* tempBank); 46 | 47 | }; 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /mainwindow.cpp: -------------------------------------------------------------------------------- 1 | #include "mainwindow.h" 2 | 3 | /************** Primary constructor ***************/ 4 | MainWindow::MainWindow(int numPlayers) { 5 | setFixedSize(800, 755); 6 | 7 | totalPlayers = numPlayers; 8 | playerTurn = 0; 9 | spaces = new Space*[40]; 10 | 11 | //Creating the players! 12 | players = new Player[totalPlayers]; 13 | if(totalPlayers == 2) { 14 | players[0].setPlayerName("Andrew"); 15 | players[1].setPlayerName("Jacky"); 16 | } else if (totalPlayers == 3){ 17 | players[0].setPlayerName("Andrew"); 18 | players[1].setPlayerName("Jacky"); 19 | players[2].setPlayerName("Justin"); 20 | } else if (totalPlayers == 4){ 21 | players[0].setPlayerName("Andrew"); 22 | players[1].setPlayerName("Jacky"); 23 | players[2].setPlayerName("Justin"); 24 | players[3].setPlayerName("Jason"); 25 | } 26 | 27 | //setting up space locations on the board 28 | boardSpace[0].x = 594; 29 | boardSpace[0].y = 590; 30 | 31 | boardSpace[1].x = 513; 32 | boardSpace[1].y = 590; 33 | 34 | boardSpace[2].x = 462; 35 | boardSpace[2].y = 590; 36 | 37 | boardSpace[3].x = 408; 38 | boardSpace[3].y = 590; 39 | 40 | boardSpace[4].x = 356; 41 | boardSpace[4].y = 590; 42 | 43 | boardSpace[5].x = 304; 44 | boardSpace[5].y = 590; 45 | 46 | boardSpace[6].x = 252; 47 | boardSpace[6].y = 590; 48 | 49 | boardSpace[7].x = 199; 50 | boardSpace[7].y = 590; 51 | 52 | boardSpace[8].x = 145; 53 | boardSpace[8].y = 590; 54 | 55 | boardSpace[9].x = 94; 56 | boardSpace[9].y = 590; 57 | 58 | boardSpace[10].x = 13; 59 | boardSpace[10].y = 590; 60 | 61 | boardSpace[11].x = 13; 62 | boardSpace[11].y = 511; 63 | 64 | boardSpace[12].x = 13; 65 | boardSpace[12].y = 460; 66 | 67 | boardSpace[13].x = 13; 68 | boardSpace[13].y = 408; 69 | 70 | boardSpace[14].x = 13; 71 | boardSpace[14].y = 356; 72 | 73 | boardSpace[15].x = 13; 74 | boardSpace[15].y = 303; 75 | 76 | boardSpace[16].x = 13; 77 | boardSpace[16].y = 251; 78 | 79 | boardSpace[17].x = 13; 80 | boardSpace[17].y = 198; 81 | 82 | boardSpace[18].x = 13; 83 | boardSpace[18].y = 146; 84 | 85 | boardSpace[19].x = 13; 86 | boardSpace[19].y = 93; 87 | 88 | boardSpace[20].x = 13; 89 | boardSpace[20].y = 15; 90 | 91 | boardSpace[21].x = 95; 92 | boardSpace[21].y = 15; 93 | 94 | boardSpace[22].x = 146; 95 | boardSpace[22].y = 15; 96 | 97 | boardSpace[23].x = 198; 98 | boardSpace[23].y = 15; 99 | 100 | boardSpace[24].x = 250; 101 | boardSpace[24].y = 15; 102 | 103 | boardSpace[25].x = 303; 104 | boardSpace[25].y = 15; 105 | 106 | boardSpace[26].x = 356; 107 | boardSpace[26].y = 15; 108 | 109 | boardSpace[27].x = 408; 110 | boardSpace[27].y = 15; 111 | 112 | boardSpace[28].x = 460; 113 | boardSpace[28].y = 15; 114 | 115 | boardSpace[29].x = 514; 116 | boardSpace[29].y = 15; 117 | 118 | boardSpace[30].x = 594; 119 | boardSpace[30].y = 15; 120 | 121 | boardSpace[31].x = 594; 122 | boardSpace[31].y = 93; 123 | 124 | boardSpace[32].x = 594; 125 | boardSpace[32].y = 145; 126 | 127 | boardSpace[33].x = 594; 128 | boardSpace[33].y = 197; 129 | 130 | boardSpace[34].x = 594; 131 | boardSpace[34].y = 249; 132 | 133 | boardSpace[35].x = 594; 134 | boardSpace[35].y = 302; 135 | 136 | boardSpace[36].x = 594; 137 | boardSpace[36].y = 354; 138 | 139 | boardSpace[37].x = 594; 140 | boardSpace[37].y = 407; 141 | 142 | boardSpace[38].x = 594; 143 | boardSpace[38].y = 459; 144 | 145 | boardSpace[39].x = 594; 146 | boardSpace[39].y = 511; 147 | 148 | //Use functions in Space class to initialize each space 149 | 150 | for( int i = 0; i < 40; i++){ 151 | spaces[i] = new Space; 152 | } 153 | 154 | //Space 0 155 | spaces[0]->setName(" GO! ", " "); 156 | spaces[0]->setType("START"); 157 | spaces[0]->setPropertyCost(0); 158 | spaces[0]->setFreeParking(0); 159 | spaces[0]->setOccupied(true); 160 | spaces[0]->setOwnership(-1); 161 | spaces[0]->setMortgaged(false); 162 | spaces[0]->setRent(0); 163 | spaces[0]->setTax(0); 164 | spaces[0]->setActionText("Pass Go! ", "Get $200 "); 165 | 166 | //Space 1 167 | spaces[1]->setName(" Dorm ", " Room "); 168 | spaces[1]->setType("Property"); 169 | spaces[1]->setPropertyCost(60); 170 | spaces[1]->setFreeParking(0); 171 | spaces[1]->setOccupied(false); 172 | spaces[1]->setOwnership(-1); 173 | spaces[1]->setMortgaged(false); 174 | spaces[1]->setRent(2); 175 | spaces[1]->setTax(0); 176 | spaces[1]->setActionText(" ", " $60 "); 177 | 178 | //Space 2 179 | spaces[2]->setName("Community", " Chest "); 180 | spaces[2]->setType("Community Chest"); 181 | spaces[2]->setPropertyCost(0); 182 | spaces[2]->setFreeParking(0); 183 | spaces[2]->setOccupied(false); 184 | spaces[2]->setOwnership(-1); 185 | spaces[2]->setMortgaged(false); 186 | spaces[2]->setRent(0); 187 | spaces[2]->setTax(0); 188 | spaces[2]->setActionText(" Draw a " ," Card "); 189 | 190 | //Space 3 191 | spaces[3]->setName(" Leavey ", " Library "); 192 | spaces[3]->setType("Property"); 193 | spaces[3]->setPropertyCost(70); 194 | spaces[3]->setFreeParking(0); 195 | spaces[3]->setOccupied(false); 196 | spaces[3]->setOwnership(-1); 197 | spaces[3]->setMortgaged(false); 198 | spaces[3]->setRent(4); 199 | spaces[3]->setTax(0); 200 | spaces[3]->setActionText(" ", " $60 "); 201 | 202 | 203 | //Space 4 204 | spaces[4]->setName(" College ", " Tuition "); 205 | spaces[4]->setType("Tax"); 206 | spaces[4]->setPropertyCost(70); 207 | spaces[4]->setFreeParking(0); 208 | spaces[4]->setOccupied(false); 209 | spaces[4]->setOwnership(-1); 210 | spaces[4]->setMortgaged(false); 211 | spaces[4]->setRent(4); 212 | spaces[4]->setTax(200); 213 | spaces[4]->setActionText(" ", "Pay $200 "); 214 | 215 | //Space 5 216 | spaces[5]->setName(" Campus ", " Cruiser "); 217 | spaces[5]->setType("RailRoad"); 218 | spaces[5]->setPropertyCost(200); 219 | spaces[5]->setFreeParking(0); 220 | spaces[5]->setOccupied(false); 221 | spaces[5]->setOwnership(-1); 222 | spaces[5]->setMortgaged(false); 223 | spaces[5]->setRent(25); 224 | spaces[5]->setTax(0); 225 | spaces[5]->setActionText(" ", " $200 "); 226 | 227 | //Space 6 228 | spaces[6]->setName(" Trojan ", " Hall "); 229 | spaces[6]->setType("Property"); 230 | spaces[6]->setPropertyCost(100); 231 | spaces[6]->setFreeParking(0); 232 | spaces[6]->setOccupied(false); 233 | spaces[6]->setOwnership(-1); 234 | spaces[6]->setMortgaged(false); 235 | spaces[6]->setRent(6); 236 | spaces[6]->setTax(0); 237 | spaces[6]->setActionText(" ", " $100 "); 238 | 239 | //Space 7 240 | spaces[7]->setName(" Chance ", " "); 241 | spaces[7]->setType("Chance"); 242 | spaces[7]->setPropertyCost(0); 243 | spaces[7]->setFreeParking(0); 244 | spaces[7]->setOccupied(false); 245 | spaces[7]->setOwnership(-1); 246 | spaces[7]->setMortgaged(false); 247 | spaces[7]->setRent(0); 248 | spaces[7]->setTax(0); 249 | spaces[7]->setActionText(" Draw a ", " card "); 250 | 251 | //Space 8 252 | spaces[8]->setName(" Marks ", " Tower "); 253 | spaces[8]->setType("Property"); 254 | spaces[8]->setPropertyCost(100); 255 | spaces[8]->setFreeParking(0); 256 | spaces[8]->setOccupied(false); 257 | spaces[8]->setOwnership(-1); 258 | spaces[8]->setMortgaged(false); 259 | spaces[8]->setRent(6); 260 | spaces[8]->setTax(0); 261 | spaces[8]->setActionText(" ", " $100 "); 262 | 263 | //Space 9 264 | spaces[9]->setName(" Pardee ", " Tower "); 265 | spaces[9]->setType("Property"); 266 | spaces[9]->setPropertyCost(120); 267 | spaces[9]->setFreeParking(0); 268 | spaces[9]->setOccupied(false); 269 | spaces[9]->setOwnership(-1); 270 | spaces[9]->setMortgaged(false); 271 | spaces[9]->setRent(8); 272 | spaces[9]->setTax(0); 273 | spaces[9]->setActionText(" ", " $120 "); 274 | 275 | 276 | //Space 10 277 | spaces[10]->setName(" SJACS! ", " "); 278 | spaces[10]->setType("Jail"); 279 | spaces[10]->setPropertyCost(0); 280 | spaces[10]->setFreeParking(0); 281 | spaces[10]->setOccupied(false); 282 | spaces[10]->setOwnership(-1); 283 | spaces[10]->setMortgaged(false); 284 | spaces[10]->setRent(0); 285 | spaces[10]->setTax(0); 286 | spaces[10]->setActionText(" Just ", "Visiting "); 287 | 288 | //Space 11 289 | spaces[11]->setName(" Silent ", " Chapel "); 290 | spaces[11]->setType("Property"); 291 | spaces[11]->setPropertyCost(140); 292 | spaces[11]->setFreeParking(0); 293 | spaces[11]->setOccupied(false); 294 | spaces[11]->setOwnership(-1); 295 | spaces[11]->setMortgaged(false); 296 | spaces[11]->setRent(10); 297 | spaces[11]->setTax(0); 298 | spaces[11]->setActionText(" ", " $140 "); 299 | 300 | //Space 12 301 | spaces[12]->setName("Bathroom ", "Janitors "); 302 | spaces[12]->setType("Utility"); 303 | spaces[12]->setPropertyCost(150); 304 | spaces[12]->setFreeParking(0); 305 | spaces[12]->setOccupied(false); 306 | spaces[12]->setOwnership(-1); 307 | spaces[12]->setMortgaged(false); 308 | spaces[12]->setRent(10); 309 | spaces[12]->setTax(0); 310 | spaces[12]->setActionText(" ", " $150 "); 311 | 312 | 313 | //Space 13 314 | spaces[13]->setName("McCarthy ", " Quad "); 315 | spaces[13]->setType("Property"); 316 | spaces[13]->setPropertyCost(140); 317 | spaces[13]->setFreeParking(0); 318 | spaces[13]->setOccupied(false); 319 | spaces[13]->setOwnership(-1); 320 | spaces[13]->setMortgaged(false); 321 | spaces[13]->setRent(10); 322 | spaces[13]->setTax(0); 323 | spaces[13]->setActionText(" ", " $140 "); 324 | 325 | //Space 14 326 | spaces[14]->setName(" Alumni ", " House "); 327 | spaces[14]->setType("Property"); 328 | spaces[14]->setPropertyCost(160); 329 | spaces[14]->setFreeParking(0); 330 | spaces[14]->setOccupied(false); 331 | spaces[14]->setOwnership(-1); 332 | spaces[14]->setMortgaged(false); 333 | spaces[14]->setRent(12); 334 | spaces[14]->setTax(0); 335 | spaces[14]->setActionText(" ", " $160 "); 336 | 337 | //Space 15 338 | spaces[15]->setName("LA Metro ", " "); 339 | spaces[15]->setType("RailRoad"); 340 | spaces[15]->setPropertyCost(200); 341 | spaces[15]->setFreeParking(0); 342 | spaces[15]->setOccupied(false); 343 | spaces[15]->setOwnership(-1); 344 | spaces[15]->setMortgaged(false); 345 | spaces[15]->setRent(25); 346 | spaces[15]->setTax(0); 347 | spaces[15]->setActionText(" ", " $200 "); 348 | 349 | //Space 16 350 | spaces[16]->setName(" Fluor ", " Tower "); 351 | spaces[16]->setType("Property"); 352 | spaces[16]->setPropertyCost(180); 353 | spaces[16]->setFreeParking(0); 354 | spaces[16]->setOccupied(false); 355 | spaces[16]->setOwnership(-1); 356 | spaces[16]->setMortgaged(false); 357 | spaces[16]->setRent(14); 358 | spaces[16]->setTax(0); 359 | spaces[16]->setActionText(" ", " $180 "); 360 | 361 | //Space 17 362 | spaces[17]->setName("Community", " Chest "); 363 | spaces[17]->setType("Community Chest"); 364 | spaces[17]->setPropertyCost(0); 365 | spaces[17]->setFreeParking(0); 366 | spaces[17]->setOccupied(false); 367 | spaces[17]->setOwnership(-1); 368 | spaces[17]->setMortgaged(false); 369 | spaces[17]->setRent(0); 370 | spaces[17]->setTax(0); 371 | spaces[17]->setActionText(" Draw a ", " Card "); 372 | 373 | //Space 18 374 | spaces[18]->setName(" Webb ", " Tower "); 375 | spaces[18]->setType("Property"); 376 | spaces[18]->setPropertyCost(180); 377 | spaces[18]->setFreeParking(0); 378 | spaces[18]->setOccupied(false); 379 | spaces[18]->setOwnership(-1); 380 | spaces[18]->setMortgaged(false); 381 | spaces[18]->setRent(14); 382 | spaces[18]->setTax(0); 383 | spaces[18]->setActionText(" ", " $180 "); 384 | 385 | //Space 19 386 | spaces[19]->setName(" Lyon ", " Center "); 387 | spaces[19]->setType("Property"); 388 | spaces[19]->setPropertyCost(200); 389 | spaces[19]->setFreeParking(0); 390 | spaces[19]->setOccupied(false); 391 | spaces[19]->setOwnership(-1); 392 | spaces[19]->setMortgaged(false); 393 | spaces[19]->setRent(16); 394 | spaces[19]->setTax(0); 395 | spaces[19]->setActionText(" ", " $200 "); 396 | 397 | //Space 20 398 | spaces[20]->setName("Financial", " Aid "); 399 | spaces[20]->setType("FreeParking"); 400 | spaces[20]->setPropertyCost(0); 401 | spaces[20]->setFreeParking(0); 402 | spaces[20]->setOccupied(false); 403 | spaces[20]->setOwnership(-1); 404 | spaces[20]->setMortgaged(false); 405 | spaces[20]->setRent(0); 406 | spaces[20]->setTax(0); 407 | spaces[20]->setActionText(" ", " "); 408 | 409 | //Space 21 410 | spaces[21]->setName(" George ", "Tirebiter"); 411 | spaces[21]->setType("Property"); 412 | spaces[21]->setPropertyCost(220); 413 | spaces[21]->setFreeParking(0); 414 | spaces[21]->setOccupied(false); 415 | spaces[21]->setOwnership(-1); 416 | spaces[21]->setMortgaged(false); 417 | spaces[21]->setRent(18); 418 | spaces[21]->setTax(0); 419 | spaces[21]->setActionText(" ", " $220 "); 420 | 421 | //Space 22 422 | spaces[22]->setName(" Chance ", " "); 423 | spaces[22]->setType("Chance"); 424 | spaces[22]->setPropertyCost(0); 425 | spaces[22]->setFreeParking(0); 426 | spaces[22]->setOccupied(false); 427 | spaces[22]->setOwnership(-1); 428 | spaces[22]->setMortgaged(false); 429 | spaces[22]->setRent(0); 430 | spaces[22]->setTax(0); 431 | spaces[22]->setActionText(" Draw a ", " Card "); 432 | 433 | //Space 23 434 | spaces[23]->setName("Traveller", " Statue "); 435 | spaces[23]->setType("Property"); 436 | spaces[23]->setPropertyCost(220); 437 | spaces[23]->setFreeParking(0); 438 | spaces[23]->setOccupied(false); 439 | spaces[23]->setOwnership(-1); 440 | spaces[23]->setMortgaged(false); 441 | spaces[23]->setRent(18); 442 | spaces[23]->setTax(0); 443 | spaces[23]->setActionText(" ", " $220 "); 444 | 445 | //Space 24 446 | spaces[24]->setName("Knight's ", " Bench "); 447 | spaces[24]->setType("Property"); 448 | spaces[24]->setPropertyCost(240); 449 | spaces[24]->setFreeParking(0); 450 | spaces[24]->setOccupied(false); 451 | spaces[24]->setOwnership(-1); 452 | spaces[24]->setMortgaged(false); 453 | spaces[24]->setRent(20); 454 | spaces[24]->setTax(0); 455 | spaces[24]->setActionText(" ", " $240 "); 456 | 457 | //Space 25 458 | spaces[25]->setName("Lyft App ", " "); 459 | spaces[25]->setType("RailRoad"); 460 | spaces[25]->setPropertyCost(200); 461 | spaces[25]->setFreeParking(0); 462 | spaces[25]->setOccupied(false); 463 | spaces[25]->setOwnership(-1); 464 | spaces[25]->setMortgaged(false); 465 | spaces[25]->setRent(25); 466 | spaces[25]->setTax(0); 467 | spaces[25]->setActionText(" ", " $200 "); 468 | 469 | //Space 26 470 | spaces[26]->setName("Cromwell ", " Field "); 471 | spaces[26]->setType("Property"); 472 | spaces[26]->setPropertyCost(260); 473 | spaces[26]->setFreeParking(0); 474 | spaces[26]->setOccupied(false); 475 | spaces[26]->setOwnership(-1); 476 | spaces[26]->setMortgaged(false); 477 | spaces[26]->setRent(22); 478 | spaces[26]->setTax(0); 479 | spaces[26]->setActionText(" ", " $260 "); 480 | 481 | //Space 27 482 | spaces[27]->setName(" V.K.C. ", "Carillon "); 483 | spaces[27]->setType("Property"); 484 | spaces[27]->setPropertyCost(260); 485 | spaces[27]->setFreeParking(0); 486 | spaces[27]->setOccupied(false); 487 | spaces[27]->setOwnership(-1); 488 | spaces[27]->setMortgaged(false); 489 | spaces[27]->setRent(22); 490 | spaces[27]->setTax(0); 491 | spaces[27]->setActionText(" ", " $260 "); 492 | 493 | //Space 28 494 | spaces[28]->setName(" Laundry ", " Company "); 495 | spaces[28]->setType("Utility"); 496 | spaces[28]->setPropertyCost(150); 497 | spaces[28]->setFreeParking(0); 498 | spaces[28]->setOccupied(false); 499 | spaces[28]->setOwnership(-1); 500 | spaces[28]->setMortgaged(false); 501 | spaces[28]->setRent(10); 502 | spaces[28]->setTax(0); 503 | spaces[28]->setActionText(" ", " $150 "); 504 | 505 | //Space 29 506 | spaces[29]->setName(" Gallen ", " Center "); 507 | spaces[29]->setType("Property"); 508 | spaces[29]->setPropertyCost(280); 509 | spaces[29]->setFreeParking(0); 510 | spaces[29]->setOccupied(false); 511 | spaces[29]->setOwnership(-1); 512 | spaces[29]->setMortgaged(false); 513 | spaces[29]->setRent(22); 514 | spaces[29]->setTax(0); 515 | spaces[29]->setActionText(" ", " $280 "); 516 | 517 | //Space 30 518 | spaces[30]->setName("Caught by", " D.P.S. "); 519 | spaces[30]->setType("GoJail"); 520 | spaces[30]->setPropertyCost(0); 521 | spaces[30]->setFreeParking(0); 522 | spaces[30]->setOccupied(false); 523 | spaces[30]->setOwnership(-1); 524 | spaces[30]->setMortgaged(false); 525 | spaces[30]->setRent(0); 526 | spaces[30]->setTax(0); 527 | spaces[30]->setActionText(" ", " "); 528 | 529 | //Space 31 530 | spaces[31]->setName("Heritage ", " Hall "); 531 | spaces[31]->setType("Property"); 532 | spaces[31]->setPropertyCost(300); 533 | spaces[31]->setFreeParking(0); 534 | spaces[31]->setOccupied(false); 535 | spaces[31]->setOwnership(-1); 536 | spaces[31]->setMortgaged(false); 537 | spaces[31]->setRent(26); 538 | spaces[31]->setTax(0); 539 | spaces[31]->setActionText(" ", " $300 "); 540 | 541 | //Space 32 542 | spaces[32]->setName(" McKay ", " Center "); 543 | spaces[32]->setType("Property"); 544 | spaces[32]->setPropertyCost(300); 545 | spaces[32]->setFreeParking(0); 546 | spaces[32]->setOccupied(false); 547 | spaces[32]->setOwnership(-1); 548 | spaces[32]->setMortgaged(false); 549 | spaces[32]->setRent(26); 550 | spaces[32]->setTax(0); 551 | spaces[32]->setActionText(" ", " $300 "); 552 | 553 | //Space 33 554 | spaces[33]->setName("Community", " Chest "); 555 | spaces[33]->setType("Community Chest"); 556 | spaces[33]->setPropertyCost(0); 557 | spaces[33]->setFreeParking(0); 558 | spaces[33]->setOccupied(false); 559 | spaces[33]->setOwnership(-1); 560 | spaces[33]->setMortgaged(false); 561 | spaces[33]->setRent(0); 562 | spaces[33]->setTax(0); 563 | spaces[33]->setActionText(" Draw a ", " Card "); 564 | 565 | //Space 34 566 | spaces[34]->setName(" Bovard ", " Stage "); 567 | spaces[34]->setType("Property"); 568 | spaces[34]->setPropertyCost(320); 569 | spaces[34]->setFreeParking(0); 570 | spaces[34]->setOccupied(false); 571 | spaces[34]->setOwnership(-1); 572 | spaces[34]->setMortgaged(false); 573 | spaces[34]->setRent(28); 574 | spaces[34]->setTax(0); 575 | spaces[34]->setActionText(" ", " $320 "); 576 | 577 | //Space 35 578 | spaces[35]->setName(" USC ", " Shuttle "); 579 | spaces[35]->setType("RailRoad"); 580 | spaces[35]->setPropertyCost(200); 581 | spaces[35]->setFreeParking(0); 582 | spaces[35]->setOccupied(false); 583 | spaces[35]->setOwnership(-1); 584 | spaces[35]->setMortgaged(false); 585 | spaces[35]->setRent(25); 586 | spaces[35]->setTax(0); 587 | spaces[35]->setActionText(" ", " $200 "); 588 | 589 | //Space 36 590 | spaces[36]->setName(" Chance ", " "); 591 | spaces[36]->setType("Chance"); 592 | spaces[36]->setPropertyCost(0); 593 | spaces[36]->setFreeParking(0); 594 | spaces[36]->setOccupied(false); 595 | spaces[36]->setOwnership(-1); 596 | spaces[36]->setMortgaged(false); 597 | spaces[36]->setRent(0); 598 | spaces[36]->setTax(0); 599 | spaces[36]->setActionText(" Draw a ", " Card "); 600 | 601 | //Space 37 602 | spaces[37]->setName(" Trojan ", " Shrine "); 603 | spaces[37]->setType("Property"); 604 | spaces[37]->setPropertyCost(350); 605 | spaces[37]->setFreeParking(0); 606 | spaces[37]->setOccupied(false); 607 | spaces[37]->setOwnership(-1); 608 | spaces[37]->setMortgaged(false); 609 | spaces[37]->setRent(35); 610 | spaces[37]->setTax(0); 611 | spaces[37]->setActionText(" ", " $350 "); 612 | 613 | //Space 38 614 | spaces[38]->setName("Textbook ", " Fees "); 615 | spaces[38]->setType("Tax"); 616 | spaces[38]->setPropertyCost(0); 617 | spaces[38]->setFreeParking(0); 618 | spaces[38]->setOccupied(false); 619 | spaces[38]->setOwnership(-1); 620 | spaces[38]->setMortgaged(false); 621 | spaces[38]->setRent(0); 622 | spaces[38]->setTax(75); 623 | spaces[38]->setActionText(" ", " Pay $75 "); 624 | 625 | //Space 39 626 | spaces[39]->setName("Football ", "Coliseum "); 627 | spaces[39]->setType("Property"); 628 | spaces[39]->setPropertyCost(400); 629 | spaces[39]->setFreeParking(0); 630 | spaces[39]->setOccupied(false); 631 | spaces[39]->setOwnership(-1); 632 | spaces[39]->setMortgaged(false); 633 | spaces[39]->setRent(50); 634 | spaces[39]->setTax(0); 635 | spaces[39]->setActionText(" ", " $400 "); 636 | 637 | for(int i = 0; i < 40; i++){ 638 | spaces[i]->setHouses(0); 639 | } 640 | 641 | 642 | } 643 | 644 | //Secondary constructor 645 | MainWindow::MainWindow(){ } 646 | 647 | /*********** Setting up the entire window ************/ 648 | void MainWindow::windowSetUp(){ 649 | 650 | //Displaying GUIPlayers 651 | for(int i = 0; i < 4; i++){ 652 | guiPlayers[i] = NULL; 653 | } 654 | 655 | for(int i = 0; i < totalPlayers; i++){ 656 | guiPlayers[i] = new GUIPlayers(&players[i], i); 657 | guiPlayers[i]->setFeatures(QDockWidget::NoDockWidgetFeatures); 658 | guiPlayers[i]->setAllSpaces(spaces); 659 | } 660 | 661 | addDockWidget( Qt::RightDockWidgetArea, guiPlayers[0]); 662 | 663 | //Displaying the board in the central widget 664 | centralWidget = new CentralWidget(totalPlayers, players); 665 | setCentralWidget( centralWidget ); 666 | 667 | //Displaying the Bottom Button bar 668 | bottomBar = new BottomBar(); 669 | bottomBar->setPlayers(totalPlayers, guiPlayers); 670 | bottomBar->setCentralWidget(centralWidget); 671 | bottomBar->setMainWindow(this); 672 | 673 | if(totalPlayers == 2){ 674 | bottomBar->disableButtons(2); 675 | } else if (totalPlayers == 3){ 676 | bottomBar->disableButtons(1); 677 | } 678 | 679 | bottomBar->setFeatures(QDockWidget::NoDockWidgetFeatures); 680 | addDockWidget( Qt::BottomDockWidgetArea, bottomBar ); 681 | 682 | //Create numPlayers of QLabels in central widget, 683 | //save images, and display the players on the board 684 | 685 | } 686 | 687 | 688 | /************ Rest of Regular Functions ************/ 689 | 690 | //assigning game pieces to players 691 | void MainWindow::setGamePiece(int playerNum, string pieceName){ 692 | players[playerNum].setGamePieceName(pieceName); 693 | } 694 | 695 | 696 | //incrimenting turn 697 | void MainWindow::nextTurn(){ 698 | 699 | if(playerTurn == (totalPlayers - 1)) { 700 | playerTurn = 0; 701 | 702 | } else { 703 | playerTurn++; 704 | } 705 | 706 | } 707 | 708 | //getting player's turn 709 | int MainWindow::getPlayerTurn(){ 710 | return playerTurn; 711 | } 712 | 713 | string MainWindow::getGamePiece(int playerNum){ 714 | return players[playerNum].getGamePieceName(); 715 | } 716 | 717 | void MainWindow::setPlayerLocation(int playerNum, int spaceNum){ 718 | players[playerNum].setLocation(spaceNum); 719 | players[playerNum].setPixelLocation(boardSpace[spaceNum]); 720 | } 721 | 722 | int MainWindow::getPlayerLocation(int playerNum){ 723 | return players[playerNum].getLocation(); 724 | } 725 | 726 | 727 | Coordinates MainWindow::getPlayerPixels(int playerNum){ 728 | return players[playerNum].getPixelLocation(); 729 | } 730 | 731 | int MainWindow::getSpaceOwnership(int spaceIndex){ 732 | return spaces[spaceIndex]->getOwnership(); 733 | } 734 | 735 | string MainWindow::spaceType(int inputIndex){ 736 | return spaces[inputIndex]->getType(); 737 | } 738 | 739 | Player* MainWindow::getPlayer(int num){ 740 | return &players[num]; 741 | } 742 | 743 | string MainWindow::getPlayerName(int playerNum){ 744 | return players[playerNum].getPlayerName(); 745 | } 746 | 747 | int MainWindow::getSpaceRent(int spaceIndex){ 748 | return spaces[spaceIndex]->getRent(); 749 | } 750 | 751 | int MainWindow::getPlayerMoney(int playerNum){ 752 | return players[playerNum].getMoneyAmount(); 753 | } 754 | 755 | int MainWindow::getSpacePropertyCost(int spaceIndex){ 756 | return spaces[spaceIndex]->getPropertyCost(); 757 | } 758 | 759 | 760 | void MainWindow::setSpaceOwnership(int spaceIndex, int playerNum){ 761 | spaces[spaceIndex]->setOwnership(playerNum); 762 | } 763 | 764 | void MainWindow::playerLost(int playerNum){ 765 | players[playerNum].reset(); 766 | } 767 | 768 | bool MainWindow::isPlayerAlive(int playerNum){ 769 | return players[playerNum].isAlive(); 770 | } 771 | 772 | int MainWindow::getSpaceTax(int spaceIndex){ 773 | return spaces[spaceIndex]->getTax(); 774 | } 775 | 776 | string MainWindow::getSpaceName(int spaceIndex, int index){ 777 | return spaces[spaceIndex]->getName(index); 778 | } 779 | 780 | Space** MainWindow::getAllSpaces(){ 781 | return spaces; 782 | } 783 | 784 | 785 | 786 | 787 | 788 | 789 | 790 | 791 | 792 | 793 | 794 | 795 | 796 | 797 | -------------------------------------------------------------------------------- /mainwindow.h: -------------------------------------------------------------------------------- 1 | #ifndef MAINWINDOW_H 2 | #define MAINWINDOW_H 3 | 4 | #include 5 | #include "centralwidget.h" 6 | #include "bottomBar.h" 7 | #include "guiplayers.h" 8 | #include "Game_Board.h" 9 | #include 10 | #include "player.h" 11 | #include "space.h" 12 | 13 | 14 | class MainWindow : public QMainWindow { 15 | Q_OBJECT 16 | 17 | private: 18 | GUIPlayers* guiPlayers[4]; 19 | CentralWidget* centralWidget; 20 | BottomBar* bottomBar; 21 | int playerTurn; 22 | int totalPlayers; 23 | Player* players; 24 | Coordinates boardSpace[40]; 25 | Space** spaces; 26 | 27 | public: 28 | MainWindow(int numPlayers); 29 | MainWindow(); 30 | void nextTurn(); 31 | int getPlayerTurn(); 32 | void setGamePiece(int playerNum, string pieceName); 33 | void windowSetUp(); 34 | string getGamePiece(int playerNum); 35 | void setPlayerLocation(int playerNum, int spaceNum); 36 | int getPlayerLocation(int playerNum); 37 | Coordinates getPlayerPixels(int playerNum); 38 | int getSpaceOwnership(int spaceIndex); 39 | string spaceType(int inputIndex); 40 | Player* getPlayer(int num); 41 | string getPlayerName(int playerNum); 42 | int getSpaceRent(int spaceIndex); 43 | int getPlayerMoney(int playerNum); 44 | int getSpacePropertyCost(int spaceIndex); 45 | void setSpaceOwnership(int spaceIndex, int playerNum); 46 | void playerLost(int playerNum); 47 | bool isPlayerAlive(int playerNum); 48 | int getSpaceTax(int spaceIndex); 49 | string getSpaceName(int spaceIndex, int index); 50 | Space** getAllSpaces(); 51 | }; 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /money_action.cpp: -------------------------------------------------------------------------------- 1 | #include "money_action.h" 2 | 3 | MoneyAction::MoneyAction(string nameChoice, int moneyInput) : Action(nameChoice){ 4 | money = moneyInput; 5 | } 6 | 7 | MoneyAction::MoneyAction(string nameChoice) : Action(nameChoice){ 8 | money = 0; 9 | } 10 | 11 | MoneyAction::MoneyAction() : Action(){ 12 | money = 0; 13 | } 14 | 15 | void MoneyAction::pay_money(Player *player1, Player *player2, int amount){ 16 | player1->take_money(amount); 17 | player2->give_money(amount); 18 | } 19 | 20 | int MoneyAction::get_money(){ 21 | return money; 22 | } 23 | 24 | void MoneyAction::executeAction(Player* player1, Player* player2, int amount){ 25 | player1->take_money(amount); 26 | player2->give_money(amount); 27 | } 28 | 29 | void MoneyAction::giveBank(Player* player1, Bank* bank1, int amount){ 30 | player1->take_money(amount); 31 | bank1->give_money(amount); 32 | } 33 | 34 | void MoneyAction::takeBank(Player* player1, Bank* bank1, int amount){ 35 | bank1->take_money(amount); 36 | player1->give_money(amount); 37 | } 38 | 39 | 40 | -------------------------------------------------------------------------------- /money_action.h: -------------------------------------------------------------------------------- 1 | #ifndef MONEY_ACTION_H 2 | #define MONEY_ACTION_H 3 | 4 | #include "player.h" 5 | #include "bank.h" 6 | #include "action.h" 7 | 8 | class MoneyAction : public Action { 9 | 10 | private: 11 | int money; 12 | 13 | public: 14 | //constructors 15 | MoneyAction(string nameChoice, int moneyInput); 16 | MoneyAction(string nameChoice); 17 | MoneyAction(); 18 | 19 | //other functions 20 | void pay_money(Player *player1, Player *player2, int amount); 21 | int get_money(); 22 | void setPlayers(Player *player1, Player *player2); 23 | void executeAction(Player* player1, Player* player2, int amount); 24 | void giveBank(Player* player1, Bank* bank1, int amount); 25 | void takeBank(Player* player1, Bank* bank1, int amount); 26 | 27 | }; 28 | #endif 29 | -------------------------------------------------------------------------------- /move_action.cpp: -------------------------------------------------------------------------------- 1 | #include "move_action.h" 2 | 3 | MoveAction::MoveAction(string nameChoice, int amountInput) : Action(nameChoice){ 4 | amount = amountInput; 5 | } 6 | 7 | MoveAction::MoveAction(string nameChoice) : Action(nameChoice){ 8 | amount = 0; 9 | } 10 | 11 | MoveAction::MoveAction() : Action (){ 12 | amount = 0; 13 | } 14 | 15 | void MoveAction::set_amount(int amountInput){ 16 | amount = amountInput; 17 | } 18 | 19 | void MoveAction::move_amount(Player *player, int amountInput){ 20 | player->move_player(amountInput); 21 | } 22 | 23 | int MoveAction::get_amount(){ 24 | return amount; 25 | } 26 | 27 | void MoveAction::executeAction(Player* player1, Player* player2, int amount){ 28 | //does nothing 29 | } 30 | 31 | -------------------------------------------------------------------------------- /move_action.h: -------------------------------------------------------------------------------- 1 | #ifndef MOVE_ACTION_H 2 | #define MOVE_ACTION_H 3 | 4 | #include "player.h" 5 | #include "action.h" 6 | 7 | class MoveAction : public Action { 8 | 9 | private: 10 | int amount; 11 | 12 | public: 13 | //constructors 14 | MoveAction(string nameChoice, int amountInput); 15 | MoveAction(string nameChoice); 16 | MoveAction(); 17 | 18 | //other functions 19 | void set_amount(int amountInput); 20 | void move_amount(Player *player, int amountInput); 21 | int get_amount(); 22 | void executeAction(Player* player1, Player* player2, int amount); 23 | }; 24 | #endif 25 | -------------------------------------------------------------------------------- /player.cpp: -------------------------------------------------------------------------------- 1 | #include "player.h" 2 | 3 | Player::Player(){ 4 | moneyAmount = 2500; 5 | location = 0; 6 | for(int i = 0; i < 40; i++){ 7 | indexOfProperties[i] = false; 8 | } 9 | alive = true; 10 | 11 | playerName = "John"; 12 | gamePieceName = "soccer.png"; 13 | pixelLocation.x = 594; 14 | pixelLocation.y = 590; 15 | } 16 | 17 | Player::Player(int money){ 18 | moneyAmount = money; 19 | location = 0; 20 | for(int i = 0; i < 40; i++){ 21 | indexOfProperties[i] = false; 22 | } 23 | alive = true; 24 | 25 | playerName = "John"; 26 | } 27 | 28 | void Player::setPixelLocation(Coordinates tempLocation){ 29 | pixelLocation = tempLocation; 30 | } 31 | 32 | Coordinates Player::getPixelLocation(){ 33 | return pixelLocation; 34 | } 35 | 36 | void Player::setPlayerName(string inputName){ 37 | playerName = inputName; 38 | } 39 | 40 | void Player::setGamePiece(char inputPiece){ 41 | gamePiece = inputPiece; 42 | } 43 | 44 | void Player::setGamePieceName(string inputPieceName){ 45 | gamePieceName = inputPieceName; 46 | } 47 | 48 | void Player::setLocation(int spaceNum){ 49 | location = spaceNum; 50 | 51 | } 52 | 53 | string Player::getPlayerName(){ 54 | return playerName; 55 | } 56 | 57 | char Player::getGamePiece(){ 58 | return gamePiece; 59 | } 60 | 61 | void Player::give_money(int amount){ 62 | moneyAmount = moneyAmount + amount; 63 | } 64 | 65 | int Player::getMoneyAmount(){ 66 | return moneyAmount; 67 | } 68 | 69 | void Player::take_money(int amount){ 70 | moneyAmount = moneyAmount - amount; 71 | } 72 | 73 | void Player::move_player(int amount){ 74 | location = (location + amount) % 40; 75 | } 76 | 77 | int Player::getLocation(){ 78 | return location; 79 | } 80 | 81 | string Player::getGamePieceName(){ 82 | return gamePieceName; 83 | } 84 | 85 | void Player::setOwnedProperty(int inputIndex, bool isOwned){ 86 | indexOfProperties[inputIndex] = isOwned; 87 | } 88 | 89 | bool Player::getOwnedProperty(int inputIndex){ 90 | return indexOfProperties[inputIndex]; 91 | } 92 | 93 | bool Player::isAlive(){ 94 | return alive; 95 | } 96 | 97 | void Player::reset(){ 98 | moneyAmount = 0; 99 | location = 0; 100 | gamePiece = ' '; 101 | alive = false; 102 | } 103 | 104 | void Player::setMoneyAmount(int inputNum){ 105 | moneyAmount = inputNum; 106 | } 107 | -------------------------------------------------------------------------------- /player.h: -------------------------------------------------------------------------------- 1 | #ifndef PLAYER_H 2 | #define PLAYER_H 3 | 4 | //#include "money_action.h" 5 | #include 6 | 7 | using namespace std; 8 | 9 | struct Coordinates{ 10 | int x; 11 | int y; 12 | }; 13 | 14 | class Player { 15 | 16 | private: 17 | string playerName; 18 | char gamePiece; 19 | int moneyAmount; 20 | int location; 21 | bool indexOfProperties[40]; 22 | bool alive; 23 | string gamePieceName; 24 | Coordinates pixelLocation; 25 | 26 | 27 | public: 28 | //constructors 29 | Player(); 30 | Player(int money); 31 | 32 | //functions to set values 33 | void setPlayerName(string inputName); 34 | void setGamePiece(char inputPiece); 35 | void setOwnedProperty(int inputIndex, bool isOwned); 36 | void setLocation(int spaceNum); 37 | void setGamePieceName(string inputPieceName); 38 | void setPixelLocation(Coordinates tempLocation); 39 | void setMoneyAmount(int inputNum); 40 | 41 | //functions to get values 42 | string getPlayerName(); 43 | char getGamePiece(); 44 | int getMoneyAmount(); 45 | bool getOwnedProperty(int inputIndex); 46 | int getLocation(); 47 | bool isAlive(); 48 | string getGamePieceName(); 49 | Coordinates getPixelLocation(); 50 | 51 | //other functions 52 | void give_money(int amount); 53 | void take_money(int amount); 54 | void move_player(int amount); 55 | void reset(); 56 | 57 | }; 58 | #endif 59 | -------------------------------------------------------------------------------- /space.cpp: -------------------------------------------------------------------------------- 1 | #include "space.h" 2 | #include 3 | 4 | //functions to set values 5 | void Space::setName(string inputName, string inputName2){ 6 | name[0] = inputName; 7 | name[1] = inputName2; 8 | houses = 0; 9 | } 10 | 11 | void Space::setActionText(string inputText, string inputText2){ 12 | actionText[0] = inputText; 13 | actionText[1] = inputText2; 14 | houses = 0; 15 | } 16 | 17 | void Space::setType(string inputType){ 18 | spaceType = inputType; 19 | } 20 | 21 | void Space::setPropertyCost(int inputCost){ 22 | propertyCost = inputCost; 23 | } 24 | 25 | void Space::setFreeParking(int inputMoney){ 26 | freeParking = inputMoney; 27 | } 28 | 29 | void Space::setOccupied(int inputOccupied){ 30 | occupied = inputOccupied; 31 | } 32 | 33 | void Space::setOwnership(int inputOwnership){ 34 | owned = inputOwnership; 35 | } 36 | 37 | void Space::setMortgaged(bool inputMortgage){ 38 | mortgaged = inputMortgage; 39 | } 40 | 41 | void Space::setRent(int inputRent){ 42 | rent = inputRent; 43 | } 44 | 45 | void Space::setTax(int inputTax){ 46 | tax = inputTax; 47 | } 48 | 49 | //functions to get values 50 | string Space::getName(int nameIndex){ 51 | return name[nameIndex]; 52 | } 53 | 54 | string Space::getActionText(int textIndex){ 55 | return actionText[textIndex]; 56 | } 57 | 58 | int Space::getPropertyCost(){ 59 | return propertyCost; 60 | } 61 | 62 | int Space::getFreeParking(){ 63 | return freeParking; 64 | } 65 | 66 | bool Space::getMortgaged(){ 67 | return mortgaged; 68 | } 69 | 70 | int Space::getRent(){ 71 | return rent; 72 | } 73 | 74 | int Space::getTax(){ 75 | return tax; 76 | } 77 | 78 | string Space::getType(){ 79 | return spaceType; 80 | } 81 | 82 | int Space::getOwnership(){ 83 | return owned; 84 | } 85 | 86 | int Space::getHouses(){ 87 | return houses; 88 | } 89 | 90 | void Space::setHouses(int inputHouses){ 91 | houses = inputHouses; 92 | } 93 | 94 | bool Space::upgrade(){ 95 | if(houses < 5){ 96 | rent = rent * 2; 97 | houses++; 98 | return true; 99 | } else { 100 | return false; 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /space.h: -------------------------------------------------------------------------------- 1 | #ifndef SPACE_H 2 | #define SPACE_H 3 | 4 | #include "action.h" 5 | 6 | 7 | class Space { 8 | 9 | private: 10 | string name[2]; 11 | string actionText[2]; 12 | string spaceType; //property, card, tax, railroads, jail, etc 13 | int propertyCost; 14 | int freeParking; 15 | bool occupied; 16 | int owned; 17 | bool mortgaged; 18 | int houses; 19 | int rent; 20 | int tax; 21 | 22 | public: 23 | //functions to set values 24 | void setName(string inputName, string inputName2); 25 | void setType(string inputType); 26 | void setPropertyCost(int inputCost); 27 | void setFreeParking(int inputMoney); 28 | void setOccupied(int inputOccupied); 29 | void setOwnership(int inputOwnership); 30 | void setMortgaged(bool inputMortgage); 31 | void setRent(int inputRent); 32 | void setTax(int inputTax); 33 | void setActionText(string textInput, string textInput2); 34 | void setHouses(int inputHouses); 35 | bool upgrade(); 36 | 37 | //functions to get values 38 | string getName(int nameIndex); 39 | int getPropertyCost(); 40 | int getFreeParking(); 41 | bool getMortgaged(); 42 | int getRent(); 43 | int getTax(); 44 | int getOwnership(); 45 | string getActionText(int textIndex); 46 | string getType(); 47 | int getHouses(); 48 | 49 | }; 50 | #endif 51 | 52 | -------------------------------------------------------------------------------- /textbox.h: -------------------------------------------------------------------------------- 1 | #ifndef TEXTBOX_H 2 | #define TEXTBOX_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | class TextBox : public QDockWidget { 10 | Q_OBJECT 11 | 12 | private: 13 | QPlainTextEdit textBox; 14 | 15 | public: 16 | TextBox(); 17 | }; 18 | 19 | #endif 20 | --------------------------------------------------------------------------------