├── README.md ├── poetry.lock ├── pyproject.toml └── pythonopoly.py /README.md: -------------------------------------------------------------------------------- 1 | # Pythonopoly 2 | A monopoly game made with python. Hope you enjoy! 3 | 4 | Update Log: (3/24/22) 5 | 6 | - Added a system to detect if you own a property so you are not 7 | charged rent on your own property. 8 | 9 | - Added a system to detect when a players balance is < 1 so that 10 | the the game ends for a two player game. 11 | 12 | - Added dice animations, text speeds, and color coordinated player text. 13 | 14 | Future update plans: 15 | 16 | - The mortgage system isn't operational and I plan to fix that soon. 17 | 18 | - Players who own properties will receive rent when another player lands on it. 19 | 20 | - More COMMUNITY CHEST and CHANCE outcomes. 21 | 22 | Please note this game is not associated with ©Monopoly or ©Hasbro. 23 | -------------------------------------------------------------------------------- /poetry.lock: -------------------------------------------------------------------------------- 1 | [[package]] 2 | name = "colorama" 3 | version = "0.4.4" 4 | description = "Cross-platform colored terminal text." 5 | category = "main" 6 | optional = false 7 | python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" 8 | 9 | [[package]] 10 | name = "numpy" 11 | version = "1.22.2" 12 | description = "NumPy is the fundamental package for array computing with Python." 13 | category = "main" 14 | optional = false 15 | python-versions = ">=3.8" 16 | 17 | [metadata] 18 | lock-version = "1.1" 19 | python-versions = ">=3.8.0,<3.9" 20 | content-hash = "35524d79911bb3820a484947026ab458f8e3060ad09c539e953972fe2601f74a" 21 | 22 | [metadata.files] 23 | colorama = [ 24 | {file = "colorama-0.4.4-py2.py3-none-any.whl", hash = "sha256:9f47eda37229f68eee03b24b9748937c7dc3868f906e8ba69fbcbdd3bc5dc3e2"}, 25 | {file = "colorama-0.4.4.tar.gz", hash = "sha256:5941b2b48a20143d2267e95b1c2a7603ce057ee39fd88e7329b0c292aa16869b"}, 26 | ] 27 | numpy = [ 28 | {file = "numpy-1.22.2-cp310-cp310-macosx_10_14_x86_64.whl", hash = "sha256:515a8b6edbb904594685da6e176ac9fbea8f73a5ebae947281de6613e27f1956"}, 29 | {file = "numpy-1.22.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:76a4f9bce0278becc2da7da3b8ef854bed41a991f4226911a24a9711baad672c"}, 30 | {file = "numpy-1.22.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:168259b1b184aa83a514f307352c25c56af111c269ffc109d9704e81f72e764b"}, 31 | {file = "numpy-1.22.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3556c5550de40027d3121ebbb170f61bbe19eb639c7ad0c7b482cd9b560cd23b"}, 32 | {file = "numpy-1.22.2-cp310-cp310-win_amd64.whl", hash = "sha256:aafa46b5a39a27aca566198d3312fb3bde95ce9677085efd02c86f7ef6be4ec7"}, 33 | {file = "numpy-1.22.2-cp38-cp38-macosx_10_14_x86_64.whl", hash = "sha256:55535c7c2f61e2b2fc817c5cbe1af7cb907c7f011e46ae0a52caa4be1f19afe2"}, 34 | {file = "numpy-1.22.2-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:60cb8e5933193a3cc2912ee29ca331e9c15b2da034f76159b7abc520b3d1233a"}, 35 | {file = "numpy-1.22.2-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0b536b6840e84c1c6a410f3a5aa727821e6108f3454d81a5cd5900999ef04f89"}, 36 | {file = "numpy-1.22.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2638389562bda1635b564490d76713695ff497242a83d9b684d27bb4a6cc9d7a"}, 37 | {file = "numpy-1.22.2-cp38-cp38-win32.whl", hash = "sha256:6767ad399e9327bfdbaa40871be4254d1995f4a3ca3806127f10cec778bd9896"}, 38 | {file = "numpy-1.22.2-cp38-cp38-win_amd64.whl", hash = "sha256:03ae5850619abb34a879d5f2d4bb4dcd025d6d8fb72f5e461dae84edccfe129f"}, 39 | {file = "numpy-1.22.2-cp39-cp39-macosx_10_14_x86_64.whl", hash = "sha256:d76a26c5118c4d96e264acc9e3242d72e1a2b92e739807b3b69d8d47684b6677"}, 40 | {file = "numpy-1.22.2-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:15efb7b93806d438e3bc590ca8ef2f953b0ce4f86f337ef4559d31ec6cf9d7dd"}, 41 | {file = "numpy-1.22.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:badca914580eb46385e7f7e4e426fea6de0a37b9e06bec252e481ae7ec287082"}, 42 | {file = "numpy-1.22.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:94dd11d9f13ea1be17bac39c1942f527cbf7065f94953cf62dfe805653da2f8f"}, 43 | {file = "numpy-1.22.2-cp39-cp39-win32.whl", hash = "sha256:8cf33634b60c9cef346663a222d9841d3bbbc0a2f00221d6bcfd0d993d5543f6"}, 44 | {file = "numpy-1.22.2-cp39-cp39-win_amd64.whl", hash = "sha256:59153979d60f5bfe9e4c00e401e24dfe0469ef8da6d68247439d3278f30a180f"}, 45 | {file = "numpy-1.22.2-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:4a176959b6e7e00b5a0d6f549a479f869829bfd8150282c590deee6d099bbb6e"}, 46 | {file = "numpy-1.22.2.zip", hash = "sha256:076aee5a3763d41da6bef9565fdf3cb987606f567cd8b104aded2b38b7b47abf"}, 47 | ] 48 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [tool.poetry] 2 | name = "pythonopoly" 3 | version = "0.1.0" 4 | description = "NULL" 5 | authors = ["Alex Tomsovic "] 6 | 7 | [tool.poetry.dependencies] 8 | python = ">=3.8.0,<3.9" 9 | numpy = "^1.22.2" 10 | colorama = "^0.4.4" 11 | 12 | [tool.poetry.dev-dependencies] 13 | 14 | [build-system] 15 | requires = ["poetry-core>=1.0.0"] 16 | build-backend = "poetry.core.masonry.api" 17 | -------------------------------------------------------------------------------- /pythonopoly.py: -------------------------------------------------------------------------------- 1 | # Pythonpoly by Alex Tomsovic 2 | # linktr.ee/alextomsovic 3 | # This game is in no way related to or associated 4 | # with ©Monopoly or the ©Hasbro brand. 5 | 6 | #import libraries 7 | from colorama import Fore 8 | import sys,time 9 | import random 10 | import os 11 | 12 | # typing speed functions for animation 13 | def sprint(str): 14 | for c in str + '\n': 15 | sys.stdout.write(c) 16 | sys.stdout.flush() 17 | time.sleep(3/ 0.9) 18 | 19 | def typewrite(str): 20 | for letter in str: 21 | sys.stdout.write(letter) 22 | sys.stdout.flush() 23 | time.sleep(0.04) 24 | 25 | def rolling(str): 26 | for letter in str: 27 | sys.stdout.write(letter) 28 | sys.stdout.flush() 29 | time.sleep(0.09) 30 | 31 | # function for deleting the rolling dice text animation 32 | def delete_last_line(): 33 | sys.stdout.write('\x1b[1A') 34 | sys.stdout.write('\x1b[2K') 35 | 36 | # title + credit animation 37 | typewrite("Welcome to " + Fore.LIGHTGREEN_EX+"Pythonopoly\n" + Fore.WHITE+"This game was created by " + Fore.BLUE+"Alex Tomsovic.\n\n") 38 | 39 | # list where players are added 40 | players=[] 41 | 42 | # retrieving all players information and assigning them a color 43 | while True: 44 | try: 45 | numOfPlayers=int(input(Fore.WHITE+"How many players will be playing Pythonopoly today?: ")) 46 | if numOfPlayers>=2 and numOfPlayers<=8: 47 | if numOfPlayers >=2: 48 | p1=input(Fore.WHITE+"Player 1: "+Fore.LIGHTYELLOW_EX) 49 | players.append(Fore.LIGHTYELLOW_EX+p1) 50 | p2=input(Fore.WHITE+"Player 2: "+Fore.CYAN) 51 | players.append(Fore.CYAN+p2) 52 | if numOfPlayers >=3: 53 | p3=input(Fore.WHITE+"Player 3: "+Fore.RED) 54 | players.append(Fore.RED+p3) 55 | if numOfPlayers >=4: 56 | p4=input(Fore.WHITE+"Player 4: "+Fore.GREEN) 57 | players.append(Fore.GREEN+p4) 58 | if numOfPlayers >=5: 59 | p5=input(Fore.WHITE+"Player 5: "+Fore.MAGENTA) 60 | players.append(Fore.MAGENTA+p5) 61 | if numOfPlayers >=6: 62 | p6=input(Fore.WHITE+"Player 6: "+Fore.WHITE) 63 | players.append(Fore.WHITE+p6) 64 | if numOfPlayers >=7: 65 | p7=input(Fore.WHITE+"Player 7: "+Fore.BLACK) 66 | players.append(Fore.BLACK+p7) 67 | if numOfPlayers ==8: 68 | p8=input(Fore.WHITE+"Player 8: "+Fore.YELLOW) 69 | players.append(Fore.YELLOW+p8) 70 | break 71 | 72 | # error message for less than 2 players 73 | elif numOfPlayers < 2: 74 | print(Fore.RED+"Error occured. You must have atlest two players.") 75 | 76 | # error message for more than 8 players 77 | else: 78 | print(Fore.RED+"Error occured. You cannot have than 8 players. ") 79 | 80 | # error message for alternater unintended input 81 | except: 82 | print(Fore.RED+"Error occured. Please try again.") 83 | 84 | # 2D board list 85 | board=[["GO","no"],["Shoreline Pass",60],["Community Chest","cc"],["Trailhawk Lane",60],["Income Tax","no"],["Queens Crown Station",200],["Creighton Plaza",100],["CHANCE","ch"],["Tuscan Road",100],["Dreamville Lane",120],["Just Visiting","no"],["Grand View Mall",140],["Electric Company",150],["Pismo Court",140],["Swanson Avenue",160],["Kanto Station",200],["Morales Street",180],["COMMUNITY CHEST","cc"],["Palace Vinyard",180],["Cynthia Street",200],["Free Parking","no"],["Strand",220],["CHANCE","ch"],["Trojan Road",220],["Tralfamadore Square",240],["Spain Street Station",200],["John London Square",260],["Curry Street",260],["Water Works",150],["Tilted Towers",280],["Go To Jail","no"],["Berkeley Lane",300],["Lombard Street",300],["Community Chest","cc"],["Telegraph Avenue Station",200],["CHANCE","ch"],["Rocky Reels",350],["Super Tax","no"],["Palm Springs",400]] 86 | 87 | # showing what is available 88 | available=["GO","Shoreline Pass","Community Chest","Trailhawk Lane","Income Tax","Queens Crown Station","Creighton Plaza","CHANCE","Tuscan Road","Dreamville Lane","Just Visiting","Grand View Mall","Electric Company","Pismo Court","Swanson Avenue","Kanto Station","Morales Street","COMMUNITY CHEST","Palace Vinyard","Cynthia Street","Free Parking","Strand","CHANCE","Trojan Road","Tralfamadore Square","Spain Street Station","John London Square","Curry Street","Water Works","Tilted Towers","Go To Jail","Berkeley Lane","Lombard Street","Community Chest","Telegraph Avenue Station","CHANCE","Rocky Reels","Palm Springs"] 89 | 90 | # each players starting board position 91 | bPos=[0,0,0,0,0,0,0,0] 92 | 93 | # each players portfolio 94 | own=[[],[],[],[],[],[],[],[]] 95 | 96 | # balance of each player 97 | money=[1500,1500,1500,1500,1500,1500,1500,1500] 98 | 99 | # starting dice roll and sending current player to their rolled position 100 | while True: 101 | for x in range(numOfPlayers): 102 | os.system("clear") 103 | input(Fore.WHITE+"Click to begin your go... ") 104 | bPos[x]=random.randint(1,6)+random.randint(1,6)+bPos[x] 105 | if bPos[x] >= 39: 106 | bPos[x]=bPos[x]-39 107 | while True: 108 | os.system("clear") 109 | 110 | # rolling dice animation text 111 | rolling("Rolling Dice...") 112 | time.sleep(1) 113 | delete_last_line() 114 | 115 | #resetting color so that "Player:" will match players color 116 | print(players[x]) 117 | time.sleep(0) 118 | delete_last_line() 119 | 120 | # header stats (player , balance, board position) 121 | print("\nPlayer" + ":",players[x]) 122 | print("Balance: $",money[x]) 123 | print("You landed on",board[bPos[x]][0]) 124 | 125 | # if player lands on a space with board position index[1] == "no" (go to jail, free parking, etc) 126 | if board[bPos[x]][1]=="no": 127 | print("\nwhat would you like to do?\n(1)Buying is unavailable here!\n(2)Morgage(CURRENTLY UNAVAILABLE)\n(3)Check properties\n(4)End turn") 128 | 129 | # checks to see if the property the player landed on is available, and then to see if that player owns it. If they don't rent is subtracted fromt that players balance. 130 | if board[bPos[x]][0] != available[bPos[x]]: 131 | if board[bPos[x]][0] not in own[x]: 132 | rent_owed = random.randint(30,200) 133 | money[x] = money[x] - rent_owed 134 | print("\nUnfortunately",board[bPos[x]][0] + " is owned by another player. You paid $" + str(rent_owed) + " in rent.\nYour new balance is $" + str(money[x])) 135 | print("\nwhat would you like to do?\n(1)Buying is unavailable here!\n(2)Morgage(CURRENTLY UNAVAILABLE)\n(3)Check properties\n(4)End turn") 136 | 137 | # outcomes for landing on community chest 138 | elif board[bPos[x]][1]=="cc": 139 | cc_spin = random.randint(1,5) 140 | 141 | if cc_spin == 1: 142 | money[x]=money[x] + 100 143 | print("\nYou won $100 from the community sweepstakes! Maybe sometimes these do work...\nYour new balance is $" + str(money[x])) 144 | 145 | elif cc_spin == 2: 146 | money[x]=money[x] + 200 147 | print("\nYou received $200 for your birthday! Your grandma tells you not to spend it on alcohol.\nYour new balance is $" + str(money[x])) 148 | 149 | elif cc_spin == 3: 150 | lottery = random.randint(1,100) 151 | guess = int(("\nYou received a lottery ticket. Guess the correct number <1 - 100> to win $1,000,000!: ")) 152 | if lottery == guess: 153 | money[x]=money[x] + 1000000 154 | print("WOW! You actually won the lottery!\nYour new balance is $" + str(money[x])) 155 | else: 156 | print("Sorry. The correct number was " + str(lottery)) 157 | 158 | elif cc_spin == 4: 159 | money[x]=money[x] + 500 160 | print("\nYou won the national hot dog eating contest and won $500! Hope that'll cover your toilet repairs...\nYour new balance is $" + str(money[x])) 161 | 162 | elif cc_spin == 5: 163 | money[x]=money[x] + 50 164 | print("\nYou won Thursday bingo and were awarded $50. In other news the senior citizens have been plotting your kidnapping.\nYour new balance is $ " + str(money[x])) 165 | 166 | print("\nwhat would you like to do?\n(1)Buying is unavailable here!\n(2)Morgage(CURRENTLY UNAVAILABLE)\n(3)Check properties\n(4)End turn") 167 | 168 | # outcomes for landing on chance 169 | elif board[bPos[x]][1]=="ch": 170 | ch_spin = random.randint(1,5) 171 | 172 | if ch_spin == 1: 173 | money[x]=money[x] - 35 174 | print("\nYou were fined $35 dollars for speeding. Wait till your insurance hears about this.\nYour new balance is $" + str(money[x])) 175 | 176 | if ch_spin == 2: 177 | money[x]=money[x] - 150 178 | print("\nYou lost $150 gambling in Vegas. This better be a one time thing.../nYour new balance is $" + str(money[x])) 179 | 180 | if ch_spin == 3: 181 | moneyt[x] = money[x] - 100 182 | print("You just sent $100 to the Prince of Nigeria. I can't believe you fell for that.\nYour new balance is $" + str(money[x])) 183 | 184 | if ch_spin == 4: 185 | money[x] = money[x] + 100 186 | print("You discovered BitCoin mining! You mined 0.000023 BTC which is worth about $100!\nYour new balance is $" + str(money[x])) 187 | 188 | if ch_spin == 5: 189 | ch_lottery = random.randint(1,1000) - 50 190 | if ch_lottery < 1: 191 | lottery = 0 192 | 193 | money[x] = money[x] + ch_lottery 194 | print("\nYou just won $" + str(ch_lottery) + " playing blackjack. This is improbable, I can't believe it..\nYour new balance is $" + str(money[x])) 195 | 196 | print("\nwhat would you like to do?\n(1)Buying is unavailable here!\n(2)Morgage(CURRENTLY UNAVAILABLE)\n(3)Check properties\n(4)End turn") 197 | 198 | # landing on an unowned property 199 | else: 200 | print("\nwhat would you like to do?\n(1)Buy for $",board[bPos[x]][1],"\n(2)Morgage(CURRENTLY UNAVAILABLE)\n(3)Check properties\n(4)End turn") 201 | 202 | # player inputs what they want to do during their turn 203 | while True: 204 | try: 205 | wyd=int(input(">> ")) 206 | break 207 | # if input is invalid 208 | except: 209 | print("ERROR! TRY AGAIN") 210 | 211 | # message for trying to buy a position that isn't a property 212 | if wyd==1: 213 | if board[bPos[x]][1] == "no": 214 | print("This cannot be bought!") 215 | 216 | # message for trying to buy another players property 217 | elif board[bPos[x]][0] != available[bPos[x]]: 218 | print("This property is currently owned by another player!") 219 | 220 | # if the property is unowned and less than your balance, player can purchase the property 221 | else: 222 | if money[x] >= board[bPos[x]][1]: 223 | money[x]=money[x]-board[bPos[x]][1] 224 | own[x].append(available[bPos[x]]) 225 | available[bPos[x]]="" 226 | print("Congratulations! You bought",board[bPos[x]][0]) 227 | # message for if players balance is less than the property cost 228 | else: 229 | print("Uh oh! You can't afford this!") 230 | 231 | # mortgage option for a property (not yet operational) 232 | elif wyd==2: 233 | pass 234 | 235 | # checking real estate portfolio option 236 | elif wyd==3: 237 | print("You real estate portfolio includes: ",own[x]) 238 | 239 | # function for ending turn 240 | elif wyd==4: 241 | break 242 | 243 | # continuing a turn after an action 244 | else: 245 | print("Unavailable!") 246 | input(" to continue...") 247 | 248 | # checks for if a players balance is less than $1. If it is, then the other player is awarded the win 249 | if money[x] < 1: 250 | print(str(player[x]) + "has gone bankrupt! You lose.") 251 | if numOfPlayers < 3: 252 | if money[p1] < 1: 253 | print(str(p2) + " is the winner!") 254 | else: 255 | print(str(p1) + " is the winner!") 256 | --------------------------------------------------------------------------------