From cdefdbf7227b82b6d90968c062af34e4bb58e5f5 Mon Sep 17 00:00:00 2001 From: Ali Mohiuddin <54055822+somethingdevs@users.noreply.github.com> Date: Sun, 7 May 2023 02:14:37 -0400 Subject: [PATCH 1/4] refactor: fixed player class --- __pycache__/board.cpython-39.pyc | Bin 6504 -> 6504 bytes board.py | 23 --- database/__pycache__/Dao.cpython-39.pyc | Bin 0 -> 2489 bytes .../__pycache__/DaoConstants.cpython-39.pyc | Bin 0 -> 1602 bytes game_driver.py | 5 +- models/__pycache__/player.cpython-39.pyc | Bin 3233 -> 3157 bytes models/__pycache__/tile.cpython-39.pyc | Bin 0 -> 726 bytes models/player.py | 33 ++-- .../monopoly_Instance.cpython-39.pyc | Bin 0 -> 4863 bytes service/__pycache__/room.cpython-39.pyc | Bin 0 -> 1525 bytes service/monopoly_Instance.py | 142 +++++++++--------- service/room.py | 2 +- utils/__pycache__/loging.cpython-39.pyc | Bin 0 -> 1475 bytes utils/driver.py | 24 ++- utils/loging.py | 45 +++--- 15 files changed, 131 insertions(+), 143 deletions(-) create mode 100644 database/__pycache__/Dao.cpython-39.pyc create mode 100644 database/__pycache__/DaoConstants.cpython-39.pyc create mode 100644 models/__pycache__/tile.cpython-39.pyc create mode 100644 service/__pycache__/monopoly_Instance.cpython-39.pyc create mode 100644 service/__pycache__/room.cpython-39.pyc create mode 100644 utils/__pycache__/loging.cpython-39.pyc diff --git a/__pycache__/board.cpython-39.pyc b/__pycache__/board.cpython-39.pyc index 6b40ac55d367ce28dee7d0a2932cec6b5e625256..5e7cdf11cdfa96a3c2e2116eb8872514e3d87e19 100644 GIT binary patch delta 126 zcmaE1^umZck(ZZ?0SJ1T!!~jY@-p7qEX&)<$bO4CC^e-hbMs2R04C{MY>}xsIr-(8 zEQ|~cFPng>HCc+hfK*Y=W)Z=+jH0(#-HTFF^NQjiQhp$*g3V&WLQITBlQl&@FlKF* V68pu-SUy=)!i%wdbAkj1BLJcHB2@qY delta 126 zcmaE1^umZck(ZZ?0SE#g2W{jQ|O_m}rAXSvLSw!$Hqi7VXdr@j?UQrxG$`2%!yID+Fh>0<8vZm+<#>~x9 VV!s#}izkapcrg}lPLSYW1OPkDAmRW3 diff --git a/board.py b/board.py index 3102275..83c54c8 100644 --- a/board.py +++ b/board.py @@ -1,19 +1,6 @@ -import random - - # Global variables -def dice_roll(player): - first_dice = random.randint(1, 6) - second_dice = random.randint(1, 6) - total_dice = first_dice + second_dice - # if first_dice == second_dice: - # print(f'{player.username} rolled doubles of {first_dice}!') # Change player name - # print(f'{player.username} rolled {total_dice}', end='\n\n') # Change player name - return total_dice - - # models board: # testVar = 20 @@ -155,16 +142,6 @@ def dice_roll(player): # Moves list, change this to display on the web page -def display_moves(): - # Display player stats(name, cash in hand, rounds played, position) - print('-------------Moves-------------') - - print("{:<30}{}".format('Roll dice', 'r')) - print("{:<30}{}".format('Build a house', 'h')) - print("{:<30}{}".format('Build a hotel', 'f')) - print("{:<30}{}".format('View assets owned', 'v')) - print("{:<30}{}".format('Sell property', 's')) - print("{:<30}{}".format('End turn', 'x'), end='\n\n\n') # display_moves() diff --git a/database/__pycache__/Dao.cpython-39.pyc b/database/__pycache__/Dao.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..4107a7f57e3c0d7612605837c456d22695703826 GIT binary patch literal 2489 zcmbW3O>Z1E7{~1y&#ZT|Nw%*v0m@RUiUk@4gea;IYG~3T4r#;&0;8bOWbL#YW@omx zLz`vNOL{FIpr_>6ufc&c;)JZ;IIYA9ajL}2^LTgLO;nIzBLDZX$8Tf*{CASc$qIqz z`s2^Vx08hYf|>Ehhs+g7`V$aA1WieYM1*4OrL^Nk{xD_{gEBu2I$;#LGM1J)JmQpG zCn6BxeImj=FDeVKNgAa-^hX-hhTX1eXJ#3~>SB^#%`sZ?=>5=34cVf`+wvhXNCBi! z&8TO-*!jF`!teM)u%N_w-VESQ-pf<3wi_14Ijut>YXy&yX`_?;*71jc1JZUODx zY^D!jU7Jw*Sq{d-dAc|AgM|*3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A0hP7L#cLs=O{%tCFc}cqV7=|xpE!#MUzXkt#BUFFFwV1L@~|~sVjU*v$(+rCo{um zCjK9$6T8Ut*bAnn%MZ}IBR_UN=5wPWz!N z_i@N#Yzr$gMy_y+f^H1V%%nL}h?A3)aT1OBbB;K6#2d(AN|`LXmvK0F!f`t|*BAAX zXR*mm(u1~UQw?Sgl>erIa+YGbB+|*xAjaoQReGY|ev=MKHatGS?qKCuoiiCz(+$Qm zj%hTBQz8>ZY0M8ad@6;e5aaYePZvU=XR&CcdFR1S-B^q;1?ua_SZP1>+KSf1y+;@X?MAqm>?~pi0;(ZcioTQX1KOsSPSj9DYiE0#u@^cbX{Zx%YUXq9C zRvA&4S==gE70a}8_zHMUOUG-fS-9Jp@nH{FO-cNf6dSEt=P-I4Y_!8}*K5b2Y~@r( a8nm?c>wcP8U!~T4O?MRKmnCj#mi{ji$d7>l diff --git a/models/__pycache__/tile.cpython-39.pyc b/models/__pycache__/tile.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..8da2db740c4d3056e55e15a1cd9b752c161e229a GIT binary patch literal 726 zcmY+B&1&2*5XVQh?DcN4q0PB3;6nn15=tp0(3ISk!iEMGgD{qw8vL=9yoCncHZPO6 z=yQnP`Ut)C)c<&suo*Kyk47`2(WsoyX9T(Y{YC#0M1Od(FEJM9Pt31WbJfPBbm)UM%t~Oa>HJwGPwK=*rfF18rPo>-A9gU657p zh9Ir!hA{iqZ=6x12lil^2fKF4txZ*zO+F3MndYnInOMn47%5}I$QXPB%R{{AF#!3av@RF+0N%0h z9p+eu=@`Oi@r4{GlDIt@4}aQPUh4H$Y!HwfyUUo7d literal 0 HcmV?d00001 diff --git a/models/player.py b/models/player.py index a6fb750..ed4321c 100644 --- a/models/player.py +++ b/models/player.py @@ -1,8 +1,6 @@ from typing import List, Any import mysql.connector -import board - class Player: def __init__(self, room_id, player_id, username,money,position,game_round): @@ -22,10 +20,7 @@ def player_moves(self, dice_value): self.add_balance(200) self.game_round += 1 # print(player.position) - print(f'You are now at {board.BOARD_TILES[self.position]}') - print( - f'Description - {board.BOARD_TILES_INFO[board.BOARD_TILES[self.position]][0]}', - end='\n\n\n') + return self.position def display_player_details(self): print(f'Name - {self.username}') @@ -34,20 +29,22 @@ def display_player_details(self): print(f'Assets owned - {self.assets_owned}') def buy_tile(self, tile): - self.assets_owned.append(tile) - price = board.BOARD_TILES_INFO[tile][2] + # Adding name of the tile to the list of assets owned + self.assets_owned.append(tile.tile_name) + price = tile.cost self.balance = self.balance - price def sell_tile(self, tile): - self.assets_owned.remove(tile) - price = board.BOARD_TILES_INFO[tile][2] + # Removing name of the tile from list of assets owned + self.assets_owned.remove(tile.tile_name) + price = tile.cost / 2 self.balance = self.balance + price print(f'Property Sold! New Balance - {self.balance}') def build_house(self, tile): if tile in self.assets_owned: - self.balance -= board.BOARD_TILES_INFO[tile][5] - print(f'House built on {tile}') + self.balance -= tile.house_cost + print(f'House built on {tile.tile_name}') else: print('Asset is not owned!') return False @@ -55,16 +52,16 @@ def build_house(self, tile): def build_hotel(self, tile): if tile in self.assets_owned: - self.balance -= board.BOARD_TILES_INFO[tile][6] - print(f'Hotel built on {tile}') + self.balance -= tile.hotel_cost + print(f'Hotel built on {tile.tile_name}') else: print('Asset is not owned!') return False pass def charge_rent(self, tile): - rent = board.BOARD_TILES_INFO[board.BOARD_TILES[tile]][4][0] - print(rent) + rent = tile.rent + # print(rent) self.balance -= rent return rent @@ -75,7 +72,7 @@ def reduce_balance(self, reduced_amount): self.balance -= reduced_amount def check_balance(self, tile): - if self.balance > board.BOARD_TILES_INFO[board.BOARD_TILES[tile]][2]: + if self.balance > tile.cost: return True else: return False @@ -85,7 +82,7 @@ def go_to_jail(self): print('Sent to Jail!', end='\n\n') self.game_round += 2 - def printPlayer(self): + def print_player(self): print(vars(self)) diff --git a/service/__pycache__/monopoly_Instance.cpython-39.pyc b/service/__pycache__/monopoly_Instance.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..3ca55a48d7560b43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Jk aitFpPnwj@?{Rvg$r0 zE>%E+d{VCY2R%r~{-FZhYft(MxwJF8vZ1sqaP)CVejLs#Xf$dBzQ0~v%0E3q{>I7n zXTjt<7}*aXB#|^CG3AVw*otlLY_J?S?7o_d1 zfsb_CG2c=6%pA!l@*jNh;azv|zKjB^~L$CEP9;E4i)HG%hH$G83Kj z=@uVi2ICcs>?sICmUKntL@;A5?E*QH!rYYv3}oFk9%)zdx(rNk9c1e4dYD^BL7Kbr zx(8R~K1^PvNoGEr1&PUWUv96tXxhmUJlD=tbn^$%O(1{&_0i$gxlRW z^rXE4w8d4u=VIf1V6jZC-p^S%OErmj@C`8TV-};Et9r}X_y?`e`^N_H0Fp#w8rFWyS#z{ z5TWGN@+83An?U@MAXeOgXsRi%4PYX4I!R!0lxA>Un#`K#I!ua-qcAgvZKi$T% zRJM0DMx6VQMXGPac%t-FV^sN*8s5Foei! zLd2<@M2LL>-VCC0MehKy{uBik>XtwYH1?(nj0}^=qfNiiv>SYHQ>X|3^M%Hqqdx%w z9dOf74xoQ% highest_balance: highest_balance = player.balance winner = player - #Write a dao stuff for updating winner for the room + # Write a dao stuff for updating winner for the room return winner - def game_start(self): - #global is_game_over - # print('This is playerLIst',self.player_list) + # global is_game_over + # print('This is playerLIst',self.player_list) while not self.is_game_over: - correct_move= True + correct_move = True turn_ended = False for player in self.player_list: # Displays player details - message= "%s's turn" % player.username + message = "%s's turn" % player.username self.logger.log_info(message) - self.db.insertion_query(self.daoConst.INSERT_LOG, (message.replace("'","''") , player.room_id)) + self.db.insertion_query(self.daoConst.INSERT_LOG, (message.replace("'", "''"), player.room_id)) - print(f'Cash - {player.balance}\t Rounds played - {player.game_round}\t Player position - {player.position}') + print( + f'Cash - {player.balance}\t Rounds played - {player.game_round}\t Player position - {player.position}') print('----------------------------------------------------------------') - display_moves() + moves_list() turn_ended = False has_rolled = False # Move validation while not turn_ended: - game_input = input('Enter your choice: ') # insert in log and display. - # game_input = await request.body() + game_input = input('Enter your choice: ') # insert in log and display. + # game_input = await request.body() # Roll dice if game_input.casefold() == 'r': if not has_rolled: has_rolled = True - player.player_moves(dice_roll(player)) #diceroll rolls 2 dices for a player and moves them - - current_tile=self.tiles[player.position] - - asset_owned = False # assign this by - - #Execute to get the tile_owner - tileInput=[current_tile.tile_id,player.room_id] - #tileOWNERInput - tileOWNERInput=self.db.select_query( self.daoConst.GET_PROPERTY_OWNER,tileInput) - print('This is tile owner',tileOWNERInput) - tile_owner=None - if tileOWNERInput : - tile_owner = Player(room_id=tileOWNERInput[0][0], player_id=tileOWNERInput[0][1], username=tileOWNERInput[0][2], money=tileOWNERInput[0][3], position=tileOWNERInput[0][4], game_round=tileOWNERInput[0][5]) - - if current_tile.cost != None : - if tile_owner is None: + player.player_moves(dice_roll(player)) # diceroll rolls 2 dices for a player and moves them + + current_tile = self.tiles[player.position] + + print(f'{player.username} landed on {current_tile.tile_name} - {current_tile.description}') + + print(player.print_player()) + + asset_owned = False # assign this by + + # Execute to get the tile_owner + tileInput = [current_tile.tile_id, player.room_id] + # tileOWNERInput + tileOWNERInput = self.db.select_query(self.daoConst.GET_PROPERTY_OWNER, tileInput) + print('This is tile owner', tileOWNERInput) + tile_owner = None + if tileOWNERInput: + tile_owner = Player(room_id=tileOWNERInput[0][0], player_id=tileOWNERInput[0][1], + username=tileOWNERInput[0][2], money=tileOWNERInput[0][3], + position=tileOWNERInput[0][4], game_round=tileOWNERInput[0][5]) + + if current_tile.cost != None: + if tile_owner is None: print('The current tile owner is None') - #BUYs LOGIC + # Nobody owns the tile, player can buy is_buy = input(f'Buy {current_tile.tile_name}? [Y/N]') if is_buy.casefold() == 'y': @@ -105,36 +110,36 @@ def game_start(self): print("insufficient Funds !!") elif tile_owner.player_id != player.player_id: - print('The current tile cost is: ',tile_owner.player_id ) + print('The current tile cost is: ', tile_owner.player_id) # Deduct from current player - rent = player.charge_rent(player.position) + rent = player.charge_rent(player.position) print(f'{tile_owner.username} charges you {rent} as rent') - tile_owner.add_balance(rent)# insert updated money in DB - asset_owned = True # create entry in player_property - break + tile_owner.add_balance(rent) # insert updated money in DB + asset_owned = True # create entry in player_property + break else: - - print('Player is on his own tile') - #asset_owned = True - break - else : - print('SPECIAL CARD!!!' ,vars(current_tile)) + + print('Player is on his own tile') + # asset_owned = True + break + else: + print('SPECIAL CARD!!!', vars(current_tile)) # Insert non-buyable logic special card self.special_cards(current_tile, player) else: - print('You have already rolled the dice')# insert in log and display. + print('You have already rolled the dice') # insert in log and display. continue - + # The house and hotel are designed in such a way that only if you step on the tile, you can build them # Build a house elif game_input.casefold() == 'h': # Insert house logic here - current_tile = board.BOARD_TILES[player.position] - house_cost = board.BOARD_TILES_INFO[current_tile][4][1] + current_tile = self.tiles[player.position] + house_cost = current_tile.house_cost if player.balance > house_cost: player.build_house(current_tile) @@ -144,10 +149,10 @@ def game_start(self): # Build a hotel elif game_input.casefold() == 'f': # Insert hotel logic here - current_tile = board.BOARD_TILES[player.position] - house_cost = board.BOARD_TILES_INFO[current_tile][4][1] + current_tile = self.tiles[player.position] + hotel_cost = current_tile.hotel_cost - if player.balance > house_cost: + if player.balance > hotel_cost: player.build_house(current_tile) else: print('Insufficient Funds!') @@ -169,7 +174,7 @@ def game_start(self): if player.assets_owned: [print(i, end=', ') for i in player.assets_owned] print(end='\n\n') - sell_property = int(input(f'Enter 0 - {len(player.assets_owned)-1}: ')) + sell_property = int(input(f'Enter 0 - {len(player.assets_owned) - 1}: ')) player.sell_tile(player.assets_owned[sell_property]) print(end='\n\n') else: @@ -187,26 +192,23 @@ def game_start(self): else: print('Error! Incorrect Input') - # Game over condition self.is_game_over = self.game_over(player) - if(self.is_game_over): + if (self.is_game_over): self.game_winner(self) break - # Displays game stats at the end - def getGameStats(self): + def getGameStats(self): for player in self.player_list: player.display_player_details() print('------------------------', end='\n') - #Check if 15 rounds are reached - def game_over(self,player): + # Check if 15 rounds are reached + def game_over(self, player): if player.game_round == 15 or player.balance <= 0: print('Game Over!') return True else: return False - diff --git a/service/room.py b/service/room.py index af2d3da..73ddadc 100644 --- a/service/room.py +++ b/service/room.py @@ -38,7 +38,7 @@ def play(self): # Modify this insert to fetch position player_list.append(player.Player(room_id=player_details[i][0], player_id= player_details[i][1],username= usernames[i][0], money=player_details[i][2],game_round=player_details[i][5],position= player_details[i][4])) - print('Printing list:',player_list[0].printPlayer()) + print('Printing list:', player_list[0].print_player()) m=monopoly.monopoly_Instance(roomID=1,player_list=player_list) # need to get roomid over here from web m.game_start() diff --git a/utils/__pycache__/loging.cpython-39.pyc b/utils/__pycache__/loging.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..709f4cd469ac1aa60fc56f36328c4e263e011b71 GIT binary patch literal 1475 zcma)6TWi!n6rPzRn@h88RS*?~AQYO17F19vMMQhiQnu2f!m=>LophTemv)k^So+rf zkln}PKN@`V$-m%}=S+6nwOVj?b8>ETX1;IEBx*K20%P<0NAb-f&>F&kx=m%IMXyVzYNC#1-@sFDfvCukR%}F12{%ADM+7uWpxpr5 zJ|+Ezjyj-OLl>koq7<_F#?V6_T7tlGtaTDDEJkIwO0qaCgQZ|$F^!MoG>qzWW2qd@F`IMMz$kc{dzFl%>}`~b6wJA9k(Wgp^MkR&gFL=p z$SkUqyP@9|e+DhlWEP67^GT2vV@6$Se z_Tq7;jJpFFFM%&v%8I<`45}n8JFqZhEgycxT|=zm9J+y&J_tg6>d^+Bh2Mz}nah)u zRu}o74Af0{rp^PnXJc~J8hB>8?3 zd`YT<;5d>&Xe;YbCV3?tSY0_l(Ka5H#0@F)U29`UHnfWKE(|$~hCMz$WhD8b=ByU; zx&|HuX5R*DOoFEgFzGz2NtmSE%t0F_0}|bpePfK=#2&4!iVZD@Lr-dkOx>YGTTE_2 z#2h+*aH8!ACl|C8x*D>)0}It?t+n;nA2u~yi5FYCD4HOYCF0M6p1g|=Y>_FrE@IK) zhY%={AEMFvY?f-oO~_cj%(@x!Hq88Q$V{$kkoGl@U{65G2T(9{{(`x_ySuY{4W_bU zDGPZsLLCmF;P^zbq5W(4>Kvf9{@W6-f$})d3Ne7I%9YRg(IC str: print(f"{current_player.username} chooses {move}!") # Roll dice - roll_value = board.dice_roll(current_player) + roll_value = dice_roll(current_player) current_player.player_moves(roll_value) # print(f'{player1.username} rolled {roll_value}') @@ -139,3 +141,23 @@ def game_over(player): return False +def dice_roll(player): + first_dice = random.randint(1, 6) + second_dice = random.randint(1, 6) + total_dice = first_dice + second_dice + # if first_dice == second_dice: + # print(f'{player.username} rolled doubles of {first_dice}!') # Change player name + # print(f'{player.username} rolled {total_dice}', end='\n\n') # Change player name + return total_dice + + +def moves_list(): + # Display player stats(name, cash in hand, rounds played, position) + print('-------------Moves-------------') + + print("{:<30}{}".format('Roll dice', 'r')) + print("{:<30}{}".format('Build a house', 'h')) + print("{:<30}{}".format('Build a hotel', 'f')) + print("{:<30}{}".format('View assets owned', 'v')) + print("{:<30}{}".format('Sell property', 's')) + print("{:<30}{}".format('End turn', 'x'), end='\n\n\n') diff --git a/utils/loging.py b/utils/loging.py index 1f89a78..664e07b 100644 --- a/utils/loging.py +++ b/utils/loging.py @@ -1,50 +1,41 @@ import logging import sqlite3 + class log: def __init__(self): self.logger = logging.getLogger(__name__) self.console_handler = logging.StreamHandler() self.log_format = '%(asctime)s - %(levelname)s - %(message)s' - self.formatter=logging.Formatter(self.log_format) + self.formatter = logging.Formatter(self.log_format) self.console_handler.setFormatter(self.formatter) self.logger.addHandler(self.console_handler) - - - - - - def log_info(self,message,inp=None): - print('in logger info with var ',inp) - self.console_handler.setLevel(logging.INFO) + def log_info(self, message, inp=None): + # print('in logger info with var ',inp) + self.console_handler.setLevel(logging.INFO) self.logger.setLevel(logging.INFO) - if(inp): - self.logger.info(message,inp) + if (inp): + self.logger.info(message, inp) else: - self.logger.info(message) - - + self.logger.info(message) - def log_debug(self,message,inp=None): - self.console_handler.setLevel(logging.DEBUG) + def log_debug(self, message, inp=None): + self.console_handler.setLevel(logging.DEBUG) self.logger.setLevel(logging.DEBUG) logging.Formatter(self.log_format) self.logger.addHandler(self.console_handler) - if(inp): - self.logger.debug(message,inp) + if (inp): + self.logger.debug(message, inp) else: - self.logger.debug(message) - + self.logger.debug(message) - def log_error(self,message,inp=None): - self.console_handler.setLevel(logging.ERROR) + def log_error(self, message, inp=None): + self.console_handler.setLevel(logging.ERROR) self.logger.setLevel(logging.ERROR) logging.Formatter(self.log_format) - if(inp): - self.logger.error(message,inp) + if (inp): + self.logger.error(message, inp) else: - self.logger.error(message) - - + self.logger.error(message) From 31cc71c4cbd8456f5d549a31a805ac472cfe8b6d Mon Sep 17 00:00:00 2001 From: Ali Mohiuddin <54055822+somethingdevs@users.noreply.github.com> Date: Sun, 7 May 2023 20:39:46 -0400 Subject: [PATCH 2/4] fix: removed board.py --- __pycache__/board.cpython-310.pyc | Bin 6859 -> 0 bytes __pycache__/board.cpython-311.pyc | Bin 10487 -> 0 bytes __pycache__/board.cpython-39.pyc | Bin 6504 -> 0 bytes board.py | 151 ------------ database/Dao.py | 1 - database/DaoConstants.py | 7 +- database/__pycache__/Dao.cpython-39.pyc | Bin 2489 -> 2472 bytes .../__pycache__/DaoConstants.cpython-39.pyc | Bin 1602 -> 1656 bytes game_driver.py | 2 +- models/__pycache__/player.cpython-39.pyc | Bin 3157 -> 3188 bytes models/player.py | 6 +- .../monopoly_Instance.cpython-39.pyc | Bin 4863 -> 5647 bytes service/monopoly_Instance.py | 136 +++++++---- utils/__pycache__/driver.cpython-39.pyc | Bin 2864 -> 1046 bytes utils/__pycache__/loging.cpython-39.pyc | Bin 1475 -> 1432 bytes utils/driver.py | 230 +++++++++--------- 16 files changed, 218 insertions(+), 315 deletions(-) delete mode 100644 __pycache__/board.cpython-310.pyc delete mode 100644 __pycache__/board.cpython-311.pyc delete mode 100644 __pycache__/board.cpython-39.pyc delete mode 100644 board.py diff --git a/__pycache__/board.cpython-310.pyc b/__pycache__/board.cpython-310.pyc deleted file mode 100644 index 1af7b95d14c20b74b0efd1a8e36bc3c3bce0e4a4..0000000000000000000000000000000000000000 GIT binary patch literal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5e3(jxkfk_;+FWH_mO4XI)+#tpgqP(hnpcaal`GVFH8?76ClO&2OSEGx{W$K(!t`VA37@=K;^0?FRlaK}s z1!sWp%zUI84as3f9;IEzgA<{1irDB3kA?7b3bV%|&CAHbOKZ_+xg-!)xfEEUltn@j{bzZTt;U7E5~_SMrQPDhXMmoqdnSY8}@PZ+);wq}A53sK$J zYC~+v((|Eo^F)yaXRle#>S9Yvu13Ae0P%4)D1ycmVSqz$ci1b;l(lIjBrM#Q1zsGY zx?a3%8ul9Z&rkc8ulQGI{p-2#%aPvUk1Kx19qiQ>nj!Rt@N`@uA@0he7OO=!lmxMD pC@DgVicP3Br>yrxC^1N7;7e`mXCu)F3eE~>YmT7m+zLeD`+vc7$YlTk diff --git a/__pycache__/board.cpython-39.pyc b/__pycache__/board.cpython-39.pyc deleted file mode 100644 index 5e7cdf11cdfa96a3c2e2116eb8872514e3d87e19..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6504 zcmZ`-J8&Dv8ODPIK}eJ(*_Px-?6oY*rcFUlzhp%b9}-20FOw8y)3TTa_JCXB9`N2B zA)KYeu^p$0Cz;7i(s&X(U8*!LQ>99s@+OleP0(agq(Wim`}aWdKpt^}4|j|IcK`SP z@A8q6QU;$d^Q+?TFJ&_SqKD+?WjtKN*Sng}WJE?}t;||RhL!u~# zMd_=;T235T%Zr0zL>v;2iNoTEI4T|&PlzYQF>zd+5KoDx#WUhr@dNRkcwR8^f;cH& z6sN>X;IdNWG!01JcUc&V{M&C%K zeRG@ktpx4c;<9*0T)_-K?9EFvTopeOSHvZZUQ5u9r;biwbW)rL?NoyH`W_x=-Wy_C z+!QmQy#?AUxM=it>gX&+=fpf{7ZS9Ksr&DNtArMk92eh9hXg`M+4~n0QFAymOkzLM={-Q&XHDArrPwz8;U;0ks>zxAlnXk#)bKm41 zWfS+ghuMd@3YiMr>eF5g>JZe4NPmQMZN^4;s}Z@hK>9$pKSaRy`Z zjO{w^y^70~C^y^DFwMKJT+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Iaz~KeR3FQC=W=2hYyi=Grk(ZZ?0SMghgr!tZ`?+K98rQPoKZq4Tv5U)+)*MaJSn_$7*qIC_*+<_L^p1Fz|1H)c`}O$j4Cj0;Z delta 112 zcmeytbBKp8k(ZZ?0SMghgr$68oyh0M7&b9h#gI9QGleCJD}^9o5om5P z2gr0LK1Mc1p2^&-7a27t-(~&4XfXL4+X}{8lgru77%eBSW3Oe@nXJPh&*(JShoha* zWAYV_5JtVpnw*x5-jkC#yBYl^zvtY`7&3V+S2JVeWJB&$KW(6~MYk$jG8=+ z-Hg$6@>%v;M(xSo9P*5Ile0P68C@oS<_KZbo$SGB$>=`0iL;y0Yce0#UdDjQXSkXf zLnjAtr}}9D4K30E5t1N64@BsL2tyEI3?leZ2>}q71xSD#Su6!4I2buNIk-63IM^mL J^As>L0{}^;Fq!}W diff --git a/models/player.py b/models/player.py index ed4321c..7c592f1 100644 --- a/models/player.py +++ b/models/player.py @@ -1,13 +1,15 @@ from typing import List, Any import mysql.connector +# Add an insert query at the end of all of these functions before something is being returned + class Player: def __init__(self, room_id, player_id, username,money,position,game_round): self.room_id = room_id self.player_id = player_id self.username = username - self.position =position + self.position = position self.game_round = game_round self.balance = money self.assets_owned = [] @@ -33,6 +35,8 @@ def buy_tile(self, tile): self.assets_owned.append(tile.tile_name) price = tile.cost self.balance = self.balance - price + print(f'{tile.tile_name} bought!') + def sell_tile(self, tile): # Removing name of the tile from list of assets owned diff --git a/service/__pycache__/monopoly_Instance.cpython-39.pyc b/service/__pycache__/monopoly_Instance.cpython-39.pyc index 3ca55a48d7560b43e9e43b44313fbdb023e2e920..d2638b74d2cc08faefbcd3d5db460b88162ab7e9 100644 GIT binary patch delta 2909 zcma)8O>7(25#IN9xm+%nD@vAWN~Y)JT90k%tML*4@%{OddRr;RKPNv$K1{gPHLon1_4?4MBb{U#QNq zNFa&fM7802BB(YS<(-x%c7;V!^V*HuZ{B*h{PsInhjGztZk4NUl+>IPnwX?{EvVML zp}sAvG>mU~zF&FZM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)u!3S+022b10R!?ygZX_N< zl0t%a9`8khS5>+Va;?mr;<;=pBOOU<|SK+G7$I+<=$q^)z zNG6a_AdOJo*(!StZ8huKYo#Jf8+d^RTk!~ygPpi#HVkngXIl5_gZS0uF7#1Uu2nFsqEUp ziT2mkA@EJL2X?y^>qnUIrtP}fbvyX1J!hnKVVJ@0?j_!=J_ZX()`$W>L)M8wENT&r zsuU!$LNwVVD(FmV&_P&=Y|sRJ1{9FaQUf@RCMal$L3L^ZHAqtE6-A>8XiP*`(IU~b zl3(Co1$Y1f6P*ADDviW}9|YP2#NbI;R}95~kUH5J2%d$ygV~N8jQi`3Q}FrurNbgW z2G2Y8QerG(Kw?z$P#fsXk0u} i8qqYZQ!})x)TgN&bt#jdhb<^|?ZpjY6324!NB;$FyaKTR diff --git a/service/monopoly_Instance.py b/service/monopoly_Instance.py index dbd3339..81d0e35 100644 --- a/service/monopoly_Instance.py +++ b/service/monopoly_Instance.py @@ -1,10 +1,8 @@ from utils.driver import dice_roll, moves_list from models.player import Player -from utils.loging import log - import database.Dao as databaseObj import database.DaoConstants as DaoConst - +from utils.loging import log class monopoly_Instance: def __init__(self, roomID, player_list): @@ -28,38 +26,44 @@ def special_cards(self, tile, player): elif tile == 'GO TO JAIL': player.go_to_jail() + message = 'Sent to jail. Skipping two rounds...' + self.db.insertion_query(self.daoConst.INSERT_LOG, (message, player.room_id)) elif tile == 'Income Tax': player.reduce_balance(200) self.logger.log_info('Income Tax of 200 has been deducted. Remove this print statement at the end') print('Income Tax of 200 has been deducted. Remove this print statement at the end') + def game_winner(self): highest_balance = 0 - winner = None # add proper logic to get the sume of all property values(money) owned plus money and evaluate for each + winner = None #add proper logic to get the sume of all property values(money) owned plus money and evaluate for each for player in self.player_list: if player.balance > highest_balance: highest_balance = player.balance winner = player - # Write a dao stuff for updating winner for the room + #Write a dao stuff for updating winner for the room return winner + def game_start(self): - # global is_game_over - # print('This is playerLIst',self.player_list) + #global is_game_over + # print('This is playerLIst',self.player_list) while not self.is_game_over: - correct_move = True + correct_move= True turn_ended = False for player in self.player_list: # Displays player details - message = "%s's turn" % player.username + message= "%s's turn" % player.username self.logger.log_info(message) - self.db.insertion_query(self.daoConst.INSERT_LOG, (message.replace("'", "''"), player.room_id)) + self.db.insertion_query(self.daoConst.INSERT_LOG, (message.replace("'","''"), player.room_id)) + + message = 'Cash - %s \t Rounds played - %s \t Player position - %s' % (player.balance, player.game_round, player.position) + self.db.insertion_query(self.daoConst.INSERT_LOG, (message, player.room_id)) - print( - f'Cash - {player.balance}\t Rounds played - {player.game_round}\t Player position - {player.position}') + print(f'Cash - {player.balance}\t Rounds played - {player.game_round}\t Player position - {player.position}') print('----------------------------------------------------------------') moves_list() @@ -69,67 +73,84 @@ def game_start(self): # Move validation while not turn_ended: - game_input = input('Enter your choice: ') # insert in log and display. - # game_input = await request.body() + game_input = input('Enter your choice: ') # insert in log and display. + + message = 'Enter your choice - %s' % game_input + self.db.insertion_query(self.daoConst.INSERT_LOG, (message, player.room_id)) + + # game_input = await request.body() # Roll dice if game_input.casefold() == 'r': if not has_rolled: has_rolled = True - player.player_moves(dice_roll(player)) # diceroll rolls 2 dices for a player and moves them - - current_tile = self.tiles[player.position] + player.player_moves(dice_roll(player)) + current_tile=self.tiles[player.position] print(f'{player.username} landed on {current_tile.tile_name} - {current_tile.description}') - print(player.print_player()) + message = '%s landed on %s - %s' % (player.username, current_tile.tile_name, current_tile.description) + self.db.insertion_query(self.daoConst.INSERT_LOG, (message, player.room_id)) - asset_owned = False # assign this by + asset_owned = False # assign this by - # Execute to get the tile_owner - tileInput = [current_tile.tile_id, player.room_id] - # tileOWNERInput - tileOWNERInput = self.db.select_query(self.daoConst.GET_PROPERTY_OWNER, tileInput) - print('This is tile owner', tileOWNERInput) - tile_owner = None + #Execute to get the tile_owner + tileInput=[current_tile.tile_id,player.room_id] + #tileOWNERInput + tileOWNERInput=self.db.select_query( self.daoConst.GET_PROPERTY_OWNER,tileInput) + # print('This is tile owner',tileOWNERInput) + tile_owner=None if tileOWNERInput: - tile_owner = Player(room_id=tileOWNERInput[0][0], player_id=tileOWNERInput[0][1], - username=tileOWNERInput[0][2], money=tileOWNERInput[0][3], - position=tileOWNERInput[0][4], game_round=tileOWNERInput[0][5]) + tile_owner = Player(room_id=tileOWNERInput[0][0], player_id=tileOWNERInput[0][1], username=tileOWNERInput[0][2], money=tileOWNERInput[0][3], position=tileOWNERInput[0][4], game_round=tileOWNERInput[0][5]) if current_tile.cost != None: - if tile_owner is None: + if tile_owner is None: print('The current tile owner is None') # Nobody owns the tile, player can buy is_buy = input(f'Buy {current_tile.tile_name}? [Y/N]') + message = 'Buy %s? [Y/N] - %s' % (current_tile.tile_name, is_buy) + self.db.insertion_query(self.daoConst.INSERT_LOG, (message, player.room_id)) + if is_buy.casefold() == 'y': # Check for balance if player.check_balance(current_tile): player.buy_tile(current_tile) + # insert message that says tile bought + # message = '%s bought for %s' % (current_tile.tile_name,current_tile.cost) else: - print("insufficient Funds !!") + print("Insufficient Funds!!") + message = 'Insufficient Funds!!' + self.db.insertion_query(self.daoConst.INSERT_LOG, (message, player.room_id)) elif tile_owner.player_id != player.player_id: - print('The current tile cost is: ', tile_owner.player_id) # Deduct from current player rent = player.charge_rent(player.position) + print(f'{tile_owner.username} charges you {rent} as rent') - tile_owner.add_balance(rent) # insert updated money in DB - asset_owned = True # create entry in player_property + message = '%s charges you %s as rent' % (tile_owner.username, rent) + self.db.insertion_query(self.daoConst.INSERT_LOG, (message, player.room_id)) + + tile_owner.add_balance(rent) # insert updated money in DB + asset_owned = True # create entry in player_property break else: - print('Player is on his own tile') - # asset_owned = True - break + print('Player is on his own tile') + message = 'Player is on his own tile' + self.db.insertion_query(self.daoConst.INSERT_LOG, (message, player.room_id)) + #asset_owned = True + break + else: - print('SPECIAL CARD!!!', vars(current_tile)) + # print('SPECIAL CARD!!!' ,vars(current_tile)) # Insert non-buyable logic special card self.special_cards(current_tile, player) else: - print('You have already rolled the dice') # insert in log and display. + print('You have already rolled the dice')# insert in log and display. + message = 'You have already rolled the dice' + self.db.insertion_query(self.daoConst.INSERT_LOG, (message, player.room_id)) continue @@ -143,8 +164,13 @@ def game_start(self): if player.balance > house_cost: player.build_house(current_tile) + message = 'House built!' + self.db.insertion_query(self.daoConst.INSERT_LOG, (message, player.room_id)) + else: print('Insufficient Funds!') + message = 'Insufficient Funds!' + self.db.insertion_query(self.daoConst.INSERT_LOG, (message, player.room_id)) # Build a hotel elif game_input.casefold() == 'f': @@ -154,18 +180,28 @@ def game_start(self): if player.balance > hotel_cost: player.build_house(current_tile) + message = 'Hotel built!' + self.db.insertion_query(self.daoConst.INSERT_LOG, (message, player.room_id)) else: print('Insufficient Funds!') + message = 'Insufficient Funds!' + self.db.insertion_query(self.daoConst.INSERT_LOG, (message, player.room_id)) # View assets owned elif game_input.casefold() == 'v': if not bool(player.assets_owned): print('No assets owned!') + message = 'No assets owned!' + self.db.insertion_query(self.daoConst.INSERT_LOG, (message, player.room_id)) else: print('----------Assets Owned----------') + message = '----------Assets Owned----------' + self.db.insertion_query(self.daoConst.INSERT_LOG, (message, player.room_id)) for assets in player.assets_owned: print(f'{assets}') + message = '%s' % assets + self.db.insertion_query(self.daoConst.INSERT_LOG, (message, player.room_id)) print(end='\n\n') # Sell property @@ -174,41 +210,55 @@ def game_start(self): if player.assets_owned: [print(i, end=', ') for i in player.assets_owned] print(end='\n\n') - sell_property = int(input(f'Enter 0 - {len(player.assets_owned) - 1}: ')) + sell_property = int(input(f'Enter 0 - {len(player.assets_owned)-1}: ')) player.sell_tile(player.assets_owned[sell_property]) print(end='\n\n') else: print('No assets owned!') + message = 'No assets owned!' + self.db.insertion_query(self.daoConst.INSERT_LOG, (message, player.room_id)) # End turn elif game_input.casefold() == 'x': if has_rolled: turn_ended = True print(f'{player.username}\'s turn ended!', end='\n\n') + message = '%s turn ended!' % player.username + self.db.insertion_query(self.daoConst.INSERT_LOG, (message, player.room_id)) else: print("You need to first roll the dice!") + message = 'You need to first roll the dice!' + self.db.insertion_query(self.daoConst.INSERT_LOG, (message, player.room_id)) # Incorrect input else: print('Error! Incorrect Input') + message = 'Error! Incorrect Input' + self.db.insertion_query(self.daoConst.INSERT_LOG, (message, player.room_id)) + + # Update player details in the table at the end of every round - # Game over condition + # Game over condition self.is_game_over = self.game_over(player) - if (self.is_game_over): + if(self.is_game_over): self.game_winner(self) break + # Displays game stats at the end def getGameStats(self): for player in self.player_list: player.display_player_details() print('------------------------', end='\n') - # Check if 15 rounds are reached - def game_over(self, player): + # Display logs? + + #Check if 15 rounds are reached + def game_over(self,player): if player.game_round == 15 or player.balance <= 0: print('Game Over!') return True else: return False + diff --git a/utils/__pycache__/driver.cpython-39.pyc b/utils/__pycache__/driver.cpython-39.pyc index 9ee48ac47f2b75868365a43ece68cfccd8fdbee6..68eb16d7ffb922937cbb885816f2f74170846a33 100644 GIT binary patch literal 1046 zcmZuwOK;Oa5Z+xoj_oFWNEP&kkvNb;Do`arRaGHq%ZY#p0u)7xwwZ0~){kg+-BLF> z0Y^A=N;Z`h6HJQ;{*J)^kJF zw#l9&tNSR%i6TF&HihdA4;C4adz16zTX`@dh)QZ z#ITT}jlQ^@=2_k^beyO@$QV2eDLo0P#@t z7O?I-gKH4#T=S%|t7fl7fZv$FzK!Eal5Yras&CK+^<8O)Iz*nM8ltND5gHm7WY>Y3 zVIK~-muv>tz?;K(4|6zxa1Jj(V-7cA@shz3EPt);3@5SDDetsr=_L+c%{tnpf3dl> z@nCW>DT6oIS7bXhRF=(WMVvsyqoce~=sBA8XptCtP_Dd-#aYCa5?V$1Sth{H)3VtW z7-uB&k&yb_P*wW78AQ5}nV}y`Ck(?DHIB%j#bh1lV!VS~rd-cV+unt&MjocN=0OrG z{T-cZ5d~pBTc&>>xrUxrAe*R+m*yZ6Rjt@GfNQ?bl~~{5IsUJ1kZHtf@b3<*v#YjO c1^RCh{uYKU60vO$OEpmVcIj*Gu^;&1AL&}}+5i9m literal 2864 zcmbtW&2JmW72lct;BxsPiu$nCrs=3a+7O5ZI|16j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In5iJDGQYn8Cd%&5qvdguLs8`#l{wH zyyoTDNWV>VJn!r@(mApaR6kqAtE$_^r_@QjM%D`VtZ zH#;W3Z$ewWj^caZRs9hb%kfA+9OBR_tO0e%vK^4XuF|(?6?jb=kSYzFx}mEDO{yT_ zgI=BBj!zme!rz89pn+W{9$0GHfgOMac^`b-C{{e@v0%;F{w@%3Zo|2LOw}S#1O_(_ zKUxfJ4u#8IxS+OM-sUUJoHU;#!Ef*@WDAO6b$6p>OFSP8N(KJt;f)N)4}kY)xDGT@847u(>$Ar} z2uGySbF-s*DjgX$XeNP J{95D79{_X6;)MVJ diff --git a/utils/__pycache__/loging.cpython-39.pyc b/utils/__pycache__/loging.cpython-39.pyc index 709f4cd469ac1aa60fc56f36328c4e263e011b71..fe31f08556f0c117261350f6fa637e3b25a78e33 100644 GIT binary patch delta 172 zcmX@iJ%gJ!k(ZZ?0SGef!&4eI^71h;vQ3s@vSoCb9LOTCS;JIhP{WYLvVgUQv4&|O z6C*<&4~)N%k&z*VA(&w$qn{?*=B4E; zlxLP?D3m1@DQL3aVl61j%quD409tyBqd2w1XYyJm4_+Z4x0nY=Ffej4PGat3UdiY; zc`|blqwM5o%o7-;CYQ4WFltUd!4lyh3sh9303!HN2>}q72}rO2aWTjO4n_`ME^aO! Tu&5?;5i?Ni*5m|Mb4Dfr5wkhl diff --git a/utils/driver.py b/utils/driver.py index 4bb64f1..abeb2b3 100644 --- a/utils/driver.py +++ b/utils/driver.py @@ -1,23 +1,21 @@ import random - -import board from models import player import database.Dao -players_query = 'select room_id, player_id from player where room_id = %s' -players_params = (1,) - -usernames_query = 'SELECT u.username FROM user u JOIN player p ON u.user_id = p.player_id WHERE p.room_id = %s;' - -player_list = [] -get_players = database.db_connect -usernames = get_players.select_query(usernames_query, players_params) -value = get_players.select_query(players_query, players_params) - - -# player_list is being populated, -for i in range(len(value)): - player_list.append(player.Player(value[i][0], value[i][1], usernames[i][0])) +# players_query = 'select room_id, player_id from player where room_id = %s' +# players_params = (1,) +# +# usernames_query = 'SELECT u.username FROM user u JOIN player p ON u.user_id = p.player_id WHERE p.room_id = %s;' +# +# player_list = [] +# get_players = database.db_connect +# usernames = get_players.select_query(usernames_query, players_params) +# value = get_players.select_query(players_query, players_params) +# +# +# # player_list is being populated, +# for i in range(len(value)): +# player_list.append(player.Player(value[i][0], value[i][1], usernames[i][0])) # In case wanna know if the players are working or not, go ahead and uncomment this @@ -30,106 +28,106 @@ # messages = [] -def display_moves(current_player): - # messages = [] - - print(f'{current_player.username}\'s turn ') - print(f'Cash - {current_player.balance}\t Rounds played - {current_player.game_round}\t Player position - {current_player.position}') - print('----------------------------------------------------------------') - - for key, value in board.moves.items(): - print("{:<30}{}".format(key, value)) - print('\n') - return '\n'.join(messages) - - -def process_move(move: str) -> str: - global is_game_over - global messages - - while not is_game_over: - for current_player in player_list: - messages = [] - has_rolled = False - - if move.casefold() == 'r': - if has_rolled: - print('You have already rolled the dice') - else: - has_rolled = True - print(f"{current_player.username} chooses {move}!") - - # Roll dice - roll_value = dice_roll(current_player) - current_player.player_moves(roll_value) - # print(f'{player1.username} rolled {roll_value}') - - current_tile = board.BOARD_TILES[current_player.position] - - print(f'{current_player.username} rolled {roll_value} and lands on {current_tile}') - - elif move.casefold() == 'h': - - current_tile = board.BOARD_TILES[player1.position] - house_cost = board.BOARD_TILES_INFO[current_tile][4][1] - - if current_player.balance > house_cost: - current_player.build_house(current_tile) - else: - print('Insufficient Funds!') - - - # Build a hotel - elif move.casefold() == 'f': - # Insert hotel logic here - current_tile = board.BOARD_TILES[current_player.position] - house_cost = board.BOARD_TILES_INFO[current_tile][4][1] - - if current_player.balance > house_cost: - current_player.build_house(current_tile) - else: - print('Insufficient Funds!\n\n') - - - # View assets owned - elif move.casefold() == 'v': - if not bool(current_player.assets_owned): - print('No assets owned!') - - else: - print('----------Assets Owned----------') - for assets in current_player.assets_owned: - print(f'{assets}') - print('\n\n') - - - # Sell property - elif move.casefold() == 's': - # Insert sell property logic here - if current_player.assets_owned: - [print(i) for i in current_player.assets_owned] - print('\n\n') - sell_property = int(input(f'Enter 0 - {len(player1.assets_owned) - 1}: ')) - current_player.sell_tile(current_player.assets_owned[sell_property]) - print('\n\n') - else: - print('No assets owned!\n') - - # End turn - elif move.casefold() == 'x': - if has_rolled: - turn_ended = True - print(f'{current_player.username}\'s turn ended!\n\n') - - else: - print("You need to first roll the dice!\n\n") - - else: - print("You need to first roll the dice!\n\n") - - is_game_over = board.game_over(current_player) - # Append the move chosen by the player - return '\n'.join(messages) +# def display_moves(current_player): +# # messages = [] +# +# print(f'{current_player.username}\'s turn ') +# print(f'Cash - {current_player.balance}\t Rounds played - {current_player.game_round}\t Player position - {current_player.position}') +# print('----------------------------------------------------------------') +# +# for key, value in board.moves.items(): +# print("{:<30}{}".format(key, value)) +# print('\n') +# return '\n'.join(messages) + + +# def process_move(move: str) -> str: +# global is_game_over +# global messages +# +# while not is_game_over: +# for current_player in player_list: +# messages = [] +# has_rolled = False +# +# if move.casefold() == 'r': +# if has_rolled: +# print('You have already rolled the dice') +# else: +# has_rolled = True +# print(f"{current_player.username} chooses {move}!") +# +# # Roll dice +# roll_value = dice_roll(current_player) +# current_player.player_moves(roll_value) +# # print(f'{player1.username} rolled {roll_value}') +# +# current_tile = board.BOARD_TILES[current_player.position] +# +# print(f'{current_player.username} rolled {roll_value} and lands on {current_tile}') +# +# elif move.casefold() == 'h': +# +# current_tile = board.BOARD_TILES[player1.position] +# house_cost = board.BOARD_TILES_INFO[current_tile][4][1] +# +# if current_player.balance > house_cost: +# current_player.build_house(current_tile) +# else: +# print('Insufficient Funds!') +# +# +# # Build a hotel +# elif move.casefold() == 'f': +# # Insert hotel logic here +# current_tile = board.BOARD_TILES[current_player.position] +# house_cost = board.BOARD_TILES_INFO[current_tile][4][1] +# +# if current_player.balance > house_cost: +# current_player.build_house(current_tile) +# else: +# print('Insufficient Funds!\n\n') +# +# +# # View assets owned +# elif move.casefold() == 'v': +# if not bool(current_player.assets_owned): +# print('No assets owned!') +# +# else: +# print('----------Assets Owned----------') +# for assets in current_player.assets_owned: +# print(f'{assets}') +# print('\n\n') +# +# +# # Sell property +# elif move.casefold() == 's': +# # Insert sell property logic here +# if current_player.assets_owned: +# [print(i) for i in current_player.assets_owned] +# print('\n\n') +# sell_property = int(input(f'Enter 0 - {len(player1.assets_owned) - 1}: ')) +# current_player.sell_tile(current_player.assets_owned[sell_property]) +# print('\n\n') +# else: +# print('No assets owned!\n') +# +# # End turn +# elif move.casefold() == 'x': +# if has_rolled: +# turn_ended = True +# print(f'{current_player.username}\'s turn ended!\n\n') +# +# else: +# print("You need to first roll the dice!\n\n") +# +# else: +# print("You need to first roll the dice!\n\n") +# +# is_game_over = board.game_over(current_player) +# # Append the move chosen by the player +# return '\n'.join(messages) def game_over(player): From cfc2c0a33876f244a991151a2ad887c0d7d584d4 Mon Sep 17 00:00:00 2001 From: Ali Mohiuddin <54055822+somethingdevs@users.noreply.github.com> Date: Mon, 8 May 2023 19:46:39 -0400 Subject: [PATCH 3/4] fix: minor stuff --- .idea/sqldialects.xml | 6 ++ database/Dao.py | 2 +- database/DaoConstants.py | 56 ++++++++++-------- database/__pycache__/Dao.cpython-39.pyc | Bin 2472 -> 2460 bytes .../__pycache__/DaoConstants.cpython-39.pyc | Bin 1656 -> 2473 bytes models/__pycache__/player.cpython-39.pyc | Bin 3188 -> 3201 bytes models/player.py | 3 +- .../monopoly_Instance.cpython-39.pyc | Bin 5647 -> 5920 bytes service/__pycache__/room.cpython-39.pyc | Bin 1525 -> 1536 bytes service/monopoly_Instance.py | 33 ++++++++--- service/room.py | 2 +- 11 files changed, 65 insertions(+), 37 deletions(-) create mode 100644 .idea/sqldialects.xml diff --git a/.idea/sqldialects.xml b/.idea/sqldialects.xml new file mode 100644 index 0000000..607c0cc --- /dev/null +++ b/.idea/sqldialects.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/database/Dao.py b/database/Dao.py index 886333f..39c43d2 100644 --- a/database/Dao.py +++ b/database/Dao.py @@ -76,7 +76,7 @@ def insertion_query(self,query, values): insertion_cursor = self.db.cursor() if(len(values)>1): print(values[0],values[1]) - formatted_query = query % (values[0],values[1]) + formatted_query = query % values print(formatted_query) insertion_cursor.execute(formatted_query) else: diff --git a/database/DaoConstants.py b/database/DaoConstants.py index f22c6be..04e7aab 100644 --- a/database/DaoConstants.py +++ b/database/DaoConstants.py @@ -1,27 +1,33 @@ class DaoConstants: - #Always list the columns u wanna fetch do not use * in any case - GET_PLAYERS_IN_ROOM = 'select room_id, player_id, player_balance, player_prop_id, player_position, player_round from player where room_id = %s; ' - ADD_PLAYER_IN_ROOM='' # This should have game_round = 0, position = 0, balance = 1500 and there is no need for assets in the player table. Write the query accordingly - CREATE_ROOM = '' - JOIN_ROOM = '' - CREATE_USER = '' - FETCH_USER = '' - #Always list the columns u wanna fetch do not use * in any case - BUY_PROPERTY=''#room id player id in player table - UPDATE_MONEY=''#room id player id player table - UPDATE_WINNER_FOR_ROOM=''#update winner with user id in room table - SELECT_LOGS_BY_ROOM_ID='select log_value where room_id= %s' - # Might remove this - GET_USERNAME_FROM_PLAYER = 'SELECT u.username FROM user u JOIN player p ON u.user_id = p.player_id WHERE p.room_id = %s;' - GET_PROPERTY_LIST='select pl.property_id,pl.property_name,pl.property_description,pl.property_cost,pl.property_rent,pl.property_house_cost,pl.property_hotel_cost,pl.is_property_special from property_list pl;' - GET_PROPERTY_OWNER='select p.room_id, p.player_id, u.username,p.player_balance, p.player_position, p.player_round from player p join user u on p.player_id=u.user_id where p.player_id= (select plpr.player_id from player_property plpr where plpr.property_id=%s and plpr.room_id=%s); ' - INSERT_LOG="INSERT INTO logs (log_value, room_id) VALUES ('%s', %s);" - #move them to a .env file and add it in gitignore - HOST='143.42.112.230' - USER='gokulprathin' - PASSWD='vIn9e:fW*ic^Y=_' - DATABASE='default_db' + # Always list the columns u wanna fetch do not use * in any case + GET_PLAYERS_IN_ROOM = 'select room_id, player_id, player_balance, player_prop_id, player_position, player_round from player where room_id = %s; ' + ADD_PLAYER_IN_ROOM = '' # This should have game_round = 0, position = 0, balance = 1500 and there is no need for assets in the player table. Write the query accordingly + DISPLAY_WIN_LOSS = "SELECT u.username, CONCAT('W = ', COALESCE(wins, 0), ', L = ', COALESCE(losses, 0)) AS win_loss FROM user u " \ + "LEFT JOIN (SELECT room_player, SUM(IF(room_winner = room_player, 1, 0)) AS wins, SUM(IF(room_winner != room_player, 1, 0)) AS losses FROM room " \ + "GROUP BY room_player) wl ON u.user_id = wl.room_player ORDER BY u.username;)" # should display number of wins and losses(total games - wins) of all playeres + CREATE_ROOM = '' + JOIN_ROOM = '' + CREATE_USER = '' + FETCH_USER = '' + GET_PLAYER_DETAILS = 'select u.username, p.player_position' + # Always list the columns u wanna fetch do not use * in any case + GET_PROPERTY_FROM_LIST = 'select property_id from property_list where property_name = %s' + BUY_PROPERTY = 'INSERT INTO player_property VALUES (%s, %s, %s);' # room id player id in player table + SELL_PROPERTY = 'DELETE FROM player_property WHERE room_id = %s AND player_id = %s AND property_id = %s' + UPDATE_MONEY = '' # room id player id player table + UPDATE_EVERYTHING = 'UPDATE player set player_balance = %s, player_position = %s, player_round = %s where room_id = %s and player_id = %s' + UPDATE_WINNER_FOR_ROOM = '' # update winner with user id in room table + SELECT_LOGS_BY_ROOM_ID = 'select log_value where room_id= %s' + # Might remove this + GET_USERNAME_FROM_PLAYER = 'SELECT u.username FROM user u JOIN player p ON u.user_id = p.player_id WHERE p.room_id = %s;' + GET_PROPERTY_LIST = 'select pl.property_id,pl.property_name,pl.property_description,pl.property_cost,pl.property_rent,pl.property_house_cost,pl.property_hotel_cost,pl.is_property_special from property_list pl;' + GET_PROPERTY_OWNER = 'select p.room_id, p.player_id, u.username,p.player_balance, p.player_position, p.player_round from player p join user u on p.player_id=u.user_id where p.player_id= (select plpr.player_id from player_property plpr where plpr.property_id=%s and plpr.room_id=%s); ' + INSERT_LOG = "INSERT INTO logs (log_value, room_id) VALUES ('%s', %s);" + # move them to a .env file and add it in gitignore + HOST = '143.42.112.230' + USER = 'gokulprathin' + PASSWD = 'vIn9e:fW*ic^Y=_' + DATABASE = 'default_db' - def __init__(self) -> None: - pass - \ No newline at end of file + def __init__(self) -> None: + pass diff --git a/database/__pycache__/Dao.cpython-39.pyc b/database/__pycache__/Dao.cpython-39.pyc index 666f83e565ff802df313edd1244693a0da1d746c..6ad713249330c253ed156bd81e667003fe7a9528 100644 GIT binary patch delta 81 zcmZ1>JV%%}k(ZZ?0SMGQBU0iv@=jypcmd>99jR)Xyqe8YET@E{hAD+vk^x9ENisAu hF*4LJ)=Xw&w_w~h*`D2>@xkPN_CJgqn|nB97y&5g&eTb2vmX(pAN~(lovK*86;>b>j znoTw!v8}R2V$GTr8y0N%hkOZ3u3v3IU~6pOGjr~__ssZL>C1Y>Dwm5HyqpgP`&PWF z$kTTi*%`{Q3|(Lx&9ViWV_BNVcLB#DjwKw+EJuqhPghuhme?XKBUWKcbQRxgY?)SB zk=ED>U1ue_!OC=#Rp=I5rFYmG-DXvKm(|$%Cys5f&G$KakJYqHV{2X#u6}-;T5T?q z(TGG^I*j&4f$jILp526&BDZ+GzIzUbup5TFM6?#EkDY$dg#AV{M5VtbT`vgiXu1Ks z2DsJ?Avji*QwVdz2qbc>!%Ib!p^mcCP}ldoo;h%>OWSXP);+C@$Mp!q1brkO{<-2w zsGka;+CLZ%|4WHWj4MKoX%E_}((S;Jaa*JTV;2-Tal~{O)-ZPWZWRiODiAfK-MDtp zm^=<_*S;9u0-G?{i+eK%Uf>KJuRnQ_tQz=JZ(#ew%TVEs@AUu%euB78Fof}2+qZA9 zaBHxVonW#r${JC15M^C~G<`yaGhXTv4eC2+PCOb1lQRJ~StoJl*Nj9T&QFL+Vh5sT zcLLyLAR-eaqYcppUz-s1(R`l5zBlTJE~9YV zbmVm^Y~ftOPoS>~r(`*pea=1N?$3VY+x delta 221 zcmZ1}{DX%tk(ZZ?0SFvSB2o^sP2}^dPXh8%8KM|d7^0X`7^9d|n4(yKm=%cGfS4VK zIe?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QNc%4lgJF6J#9kQt^taj|HzW|h17!d#f delta 910 zcmZ8gO-NKx6u$Sq-+A+9{CVRzn(3G}`P8(uA|fitP?92WVFWS`+`-hzocEqVa)*Lx z;ieio;iiHa2--vx)vkrB77>*M5iY~ENV_1Sb6=FugL}_CKi@guJ@>roz}^0ME*7&0 zekX=6^78PD_?ku;eAN2;8qpZRbsCr7trH^19I5Djn$r^Hti({KBc!5DZ9+zW$owR{ z)ejqogjP{}8<+v~J**n%V$Ay`qMR&|3iB3V+ZbaEgb3sUWbp~%U;XUHsp zDPk?8WC&w!PbrRCRK(}iisG$c$}U+B!QB!J2dqIiGtVlj*Yh8;yHpn<>kz4WOd=s} zO*VfD_M$ygrWMt{j8xo^iW_EIwOpEkHEa0BJ@oYR{kO4F@s-f44K>0Cu#V> z-H3)Q)UeWX*ov<77L(YdUZK>eAldLiJ>08(B1}@zi|HcaWP-RyUw*S)g?b1P*b>WD(jc~K^F`RK+V@OWSHi0E4O;uQR zhMBFxx|4{gs!3IvVk&GolfCuSW>RluajK(CP>Z%Ip(TuK(`>X`bh!=IwPv`VNFLGt z%_APqltE4LYTTn{gzo?lKuF_v;SsO24!JQXj7;!={&`iq6! z^{m|TUY6&B+-$-3Qt% Date: Wed, 10 May 2023 20:04:09 -0400 Subject: [PATCH 4/4] fix: idk --- .idea/sqldialects.xml | 2 +- __pycache__/main.cpython-310.pyc | Bin 1359 -> 2318 bytes __pycache__/websocket_test.cpython-310.pyc | Bin 0 -> 2138 bytes database/Dao.py | 8 +- database/DaoConstants.py | 21 +++--- database/__pycache__/Dao.cpython-310.pyc | Bin 0 -> 2470 bytes database/__pycache__/Dao.cpython-39.pyc | Bin 2460 -> 2430 bytes .../__pycache__/DaoConstants.cpython-310.pyc | Bin 0 -> 3148 bytes .../__pycache__/DaoConstants.cpython-39.pyc | Bin 2473 -> 3142 bytes main.py | 65 +++++++++++++--- models/__pycache__/player.cpython-310.pyc | Bin 0 -> 3125 bytes models/__pycache__/player.cpython-39.pyc | Bin 3201 -> 3201 bytes models/__pycache__/tile.cpython-310.pyc | Bin 0 -> 730 bytes models/player.py | 2 +- server.py | 10 +++ .../monopoly_Instance.cpython-310.pyc | Bin 0 -> 6044 bytes .../monopoly_Instance.cpython-39.pyc | Bin 5920 -> 6070 bytes service/__pycache__/room.cpython-39.pyc | Bin 1536 -> 1567 bytes service/monopoly_Instance.py | 26 +++++-- service/room.py | 27 ++++--- start.py | 3 + static/script.js | 14 +--- tls/ca-cert.pem | 36 +++++++++ tls/ca-key.pem | 54 +++++++++++++ utils/__pycache__/driver.cpython-310.pyc | Bin 635 -> 1148 bytes utils/__pycache__/driver.cpython-39.pyc | Bin 1046 -> 1150 bytes utils/__pycache__/loging.cpython-310.pyc | Bin 0 -> 1438 bytes utils/driver.py | 3 + websocket_test.py | 71 ++++++++++++++++++ 29 files changed, 290 insertions(+), 52 deletions(-) create mode 100644 __pycache__/websocket_test.cpython-310.pyc create mode 100644 database/__pycache__/Dao.cpython-310.pyc create mode 100644 database/__pycache__/DaoConstants.cpython-310.pyc create mode 100644 models/__pycache__/player.cpython-310.pyc create mode 100644 models/__pycache__/tile.cpython-310.pyc create mode 100644 server.py create mode 100644 service/__pycache__/monopoly_Instance.cpython-310.pyc create mode 100644 tls/ca-cert.pem create mode 100644 tls/ca-key.pem create mode 100644 utils/__pycache__/loging.cpython-310.pyc create mode 100644 websocket_test.py diff --git a/.idea/sqldialects.xml b/.idea/sqldialects.xml index 607c0cc..8bf3a6d 100644 --- a/.idea/sqldialects.xml +++ b/.idea/sqldialects.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/__pycache__/main.cpython-310.pyc b/__pycache__/main.cpython-310.pyc index b588b352f953e345b190f74e75b0bf35fcd19916..0f07ea150a6e1162c8b365cc77f852dee656e898 100644 GIT binary patch literal 2318 zcmZV<+inv_bY^yKuP;fQ#JPuJ0&V37Y>L{dLJ{JU06~x-oGN0JYPH#!gbjOfX2w7) z2L+keJoLG(lsxu3`WO4!Cw_sd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python-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..00302d743b363c502fdc3b0a5ba67e468449b273 GIT binary patch literal 2138 zcmaJ?-EJc_6tVkE!s-kQqiue9Ti2BvD1v084tG8 zY)gZ>YTp7OwU;~xZ!x!A@d)e%aO_N)WJ|H+nd4)hAAkOQ%oi4l2->si3BAlC^oJfy zHwy+|LYG(Yd5I{ZI6xtGa7Y}2^_T>i&~hvzXM(vf>tr!v_!>F6Q{?1XmXQw;D^RP2 z=$unzx!ZY~y~8v|^Ec=kJM*9^(E@0SjC2W|r==SU^b2%>m0?__i#L|DNS6*#efdww z0@X>9`^J^(tApL7aLhV~-1~v4I!;Q@kM>@C$7IYS$zW`~@TE#tTu=FDtnKkAVj#k# zi(y~I*2ml5ZXLZk*s*&m3^t3c(a(m~>M@sY7PY8bOZh5bn_E3swVET@%(a@6b*&Dk z=Tj!VC!6=V*&|C(OAW42LI?6s=cKHaEw$>cTO8tv_ciMU&8$3z_gO6@MGN7f{*gwrI9)}wz3I>#W{SaVmoHDf&FfD$4 zzDsM9&D8(T#k2=cFjukENv#_A)&DjHswoKb&{QAJKBwuyHmIxIhaS@08*UuK;cWH% zfYwrvk1m!ot5XlNtB13&j&Zaf^6e2!N3?q!&>05K#!k;shpHJjjWajsvxkeOCIP)_ z^})%Q8_|e``ERqX+YeN2*3akGCDI)63f z5kDEQjx@EZt(a7e_&mt~Cs%bi?V4QWiI@lBA_LbTDcmpjFet|@1Ay!lZn6AFM zP9@77!CmS>?QW+OO$s}&wG~vsBr90R&sZ`S3m>XpMwGNCOJ9-%vkBlrZ$DYNho=p! ziaD5k2737se8^Rq6fq$LmvK2u{wn8-_ye53B7ckbv~4bpJ_D>i`Z?$Z*iS*w$G?rf zUl`&`e2Xc-{0sV(+)d!iXh`a0|6*ltRC{f`OMBqTbsOknfGB9ro85!veI2|wd5GTG zlURiL9q1CCVoe7~+WN<6_v=eet_#4qu`hI{Li4~`PE`$&zIt**(kwg1): select_cursor.execute(query, (values[0],values[1])) @@ -44,7 +44,7 @@ def select_all_query(self,query,istile): user=DaoConstants.USER, passwd=DaoConstants.PASSWD, database=DaoConstants.DATABASE) - print(query) + # print(query) select_all_cursor = self.db.cursor() select_all_cursor.execute(query) rows = select_all_cursor.fetchall() @@ -72,7 +72,7 @@ def insertion_query(self,query, values): user=DaoConstants.USER, passwd=DaoConstants.PASSWD, database=DaoConstants.DATABASE) - print(query) + # print(query) insertion_cursor = self.db.cursor() if(len(values)>1): print(values[0],values[1]) diff --git a/database/DaoConstants.py b/database/DaoConstants.py index 04e7aab..67815e8 100644 --- a/database/DaoConstants.py +++ b/database/DaoConstants.py @@ -1,22 +1,25 @@ class DaoConstants: # Always list the columns u wanna fetch do not use * in any case GET_PLAYERS_IN_ROOM = 'select room_id, player_id, player_balance, player_prop_id, player_position, player_round from player where room_id = %s; ' - ADD_PLAYER_IN_ROOM = '' # This should have game_round = 0, position = 0, balance = 1500 and there is no need for assets in the player table. Write the query accordingly + ADD_PLAYER_IN_ROOM = 'INSERT INTO TABLE player (room_id, player_id, player_balance, player_position, player_round) VALUES (%s, %s, 1500, 0, 0)' # This should have game_round = 0, position = 0, balance = 1500 and there is no need for assets in the player table. Write the query accordingly DISPLAY_WIN_LOSS = "SELECT u.username, CONCAT('W = ', COALESCE(wins, 0), ', L = ', COALESCE(losses, 0)) AS win_loss FROM user u " \ "LEFT JOIN (SELECT room_player, SUM(IF(room_winner = room_player, 1, 0)) AS wins, SUM(IF(room_winner != room_player, 1, 0)) AS losses FROM room " \ "GROUP BY room_player) wl ON u.user_id = wl.room_player ORDER BY u.username;)" # should display number of wins and losses(total games - wins) of all playeres - CREATE_ROOM = '' - JOIN_ROOM = '' - CREATE_USER = '' - FETCH_USER = '' - GET_PLAYER_DETAILS = 'select u.username, p.player_position' + CREATE_ROOM = 'INSERT INTO TABLE user (room_player, room_status) VALUES (%s, %s)' # should pass room_player(player_id basically) and 'ACTIVE' in place of the params. room id is supposed to be auto_increment, if it throws an error it means that the table wasnt created properly + JOIN_ROOM = 'INSERT INTO TABLE user (room_id, room_player, room_status) VALUES (%s, %s, %s)' # should pass room_player(player_id basically) and 'ACTIVE' in place of the params. + CREATE_USER = 'INSERT INTO TABLE user (username, email, pass) VALUES(%s, %s, %s)' + FETCH_USER = 'SELECT username from TABLE user where user_id = %s' # pretty sure this is wrong, but idk what is needed here + # GET_PLAYER_DETAILS = 'select u.username, p.player_position' + GET_PROPERTY_OWNED = 'SELECT property_id from player_property where room_id = %s and player_id = %s' + # Always list the columns u wanna fetch do not use * in any case - GET_PROPERTY_FROM_LIST = 'select property_id from property_list where property_name = %s' + + GET_PROPERTY_FROM_PLAYER_OWNED = 'SELECT pl.property_name FROM player_property pp JOIN property_list pl ON pp.property_id = pl.property_id WHERE pp.room_id = %s AND pp.player_id = %s;' BUY_PROPERTY = 'INSERT INTO player_property VALUES (%s, %s, %s);' # room id player id in player table SELL_PROPERTY = 'DELETE FROM player_property WHERE room_id = %s AND player_id = %s AND property_id = %s' - UPDATE_MONEY = '' # room id player id player table + UPDATE_MONEY = 'UPDATE player set player_balance = %s where room_id = %s and player_id = %s' # room id player id player table UPDATE_EVERYTHING = 'UPDATE player set player_balance = %s, player_position = %s, player_round = %s where room_id = %s and player_id = %s' - UPDATE_WINNER_FOR_ROOM = '' # update winner with user id in room table + UPDATE_WINNER_FOR_ROOM = 'UPDATE room set room_status = %s, room_winner = %s where room_id = %s' # update winner with user id and set status to inactive in room table SELECT_LOGS_BY_ROOM_ID = 'select log_value where room_id= %s' # Might remove this GET_USERNAME_FROM_PLAYER = 'SELECT u.username FROM user u JOIN player p ON u.user_id = p.player_id WHERE p.room_id = %s;' diff --git a/database/__pycache__/Dao.cpython-310.pyc b/database/__pycache__/Dao.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..2ae2a39154c10d3b0d476d60b5333fac4c6c7e54 GIT binary patch literal 2470 zcmb7`U2hvj6ozMJXV+_cojB$^;9P{YY+x2ads<9wTV-sA5D<;1|;UaaLNbhp&oEBq*e zcP5I;*bROFr+xg|rSXe4&hPlb9&t77pnid%|6~8EA=}ijZ3hyEV#kb<)EmFS9K=s|6GH3J)64nJSz_LS^{~ z*3QVn-;$>NAWo8^ygKfza4ngIqm3%uc9Ln?^i&DEaUbqTwO4pQ$H|V=VGTfmAw;95 zxyp8RLFEZL%Ewy4sFJ(d*X{ znCT`?L4#;jAz5htfZ#sh(AWLjuLKUy`B6Ei$95@?DgcC=Gj%(6SIGC5_B~V0Jp>38 zVe$mG>RR=zmaO_#%L_zQp8ESGfGfyL*y_V~Q4zl) zMiX^JShhhLcV$r(QnyvdViy8x+Js!m)P$7>89*D^ClDK%jN*=tbWgTBangVPrO-Ay zX=Aj0Kw4xmXk2T~sX7cp&7t5R)jY}>l(Q)3P|l;ghO&UNh=LzecyX^MQ=wkRCvTv< ziEeA*T~r;;O$}s-t$G`Z6%MdFoR2&Aw$(e>)WiUX6xXL}+D~{7 z3hC=0Krx$Q*{xWzecE92)O!IG|H(amFav}m+3cX=aClZ>oCSaP&rZ=jnVnOFpR&bY zp}+nQ{m)*B?rB@RYAVx~h}MQCc^)hf-VDtQEHURut+mQ3zPDD1HX9&=6N)z`W?A_U zvvg0)a@rK3Wo*sbO?H=y%CiBAJ?xfwckJ$7)x0Xism`e%@ff3>yNEa91o`!tG*N)&Z7u>(6eDuM`x z6eq(s3O!L>Lb-y1y-(3>xkh7FXb5Np8hyhjKJ&T17+kc^VH2T!gtOf}{V-V?oi>>Y z%ahRV-{Rc(@LGZq-x~jou{%1f!T@EWmvHadZEKr;*;oqy`tV~u$J5UaC}1!-@SCUq E0Mg+$djJ3c literal 0 HcmV?d00001 diff --git a/database/__pycache__/Dao.cpython-39.pyc b/database/__pycache__/Dao.cpython-39.pyc index 6ad713249330c253ed156bd81e667003fe7a9528..af8be7dfa32702a8263ec9d8206c87ff00862760 100644 GIT binary patch delta 450 zcmY+Ay-Ncz7{>GFav!}m4z;M)4^hs7I0)6rO+-YTItZfZP`n~Vde-9{dgi9iU7A4$ zhjtbO=_b-yoE#jaQ)d_b2Nd5ct!P3X@;-z-55Jqq?<6mAZW3Ip9|unPo;SgG!71nk zj=a^fvIm^g1~~MTc}1bLO*sH7Zwe5!LxG?Z?~st~5qE_VKT*F15~@Igw9n-%wSmhG z`XCj>*3_C;aebLr4pR$JATTiS;Qlh0N#&KYo_I(9goH})8nj07v3Vv~J0_q57{}Ts z#;JmOEun6bqpeW$vX@Y0cFB4H?f ztyHU(UB}DfAfMFB)Dm8>A^p=)mHXO`F+e|f41zJ7{1}eon}RxuMNp|l8W9|XG=*?{ zQ-WTI-~FO75zVyR)tBK-HuPd{Sjobly<8+wxxRLMR;^ZiFDpOwi{v6&|A?vGx?#f) Dzg}e% delta 494 zcmZY5ze~eF6bJBocbDYaCJriUfBA!I2hqW9IyqQDr*1721+gk>8*4ZR<7Lsg({19= z{s|&DIE#y$IH)+d2+leyzO;%36Y}NVy(9PGef6I8Icts+CHQ2QN|n`frvc&tSN@G( z)sJkV$Yeyp2>_8%MNgnYcez(mtQk|FXobZICXJI#+M+;Q`?nLWu(n$y;6>u*IFZg_ z6G&hH@e?wl$E-m;O>KziIeKLpb#L31`h$+^VOAc>0!RGCE>}-*M z`Op3-0#i9DIzB~qtY##7kWcsB*RFB!7-l9wR(NSt>{bRXkZFA5KOzt2+o_!;tf0g zwSOF9NB?12*I27k=vy-mLcf|bu}g$>h9z)Vd3e!VRw4bTN#K9mq$hKIuU6ZZURvK< R2mO;BO4sZJT$Duyz5$6eZutNJ diff --git a/database/__pycache__/DaoConstants.cpython-310.pyc b/database/__pycache__/DaoConstants.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..1fc3279e2ffbec7c1aba6d8bf101dfc57fa95ad2 GIT binary patch literal 3148 zcmb7G-BQ~|6qb!4gcuS?LjKy$rX41B$MFD3J83AL2wQ+#BY7+nk9U~vC|&_-Wl5Ff zP&~bBUZD@scj%M&wljT*PA__PS1ZdvGpRuG?%DIZ=R0TDUtC;J;Q8gR9{p!YQ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 EUm0o5>;M1& literal 0 HcmV?d00001 diff --git a/database/__pycache__/DaoConstants.cpython-39.pyc b/database/__pycache__/DaoConstants.cpython-39.pyc index 32836d2481c674d910ceb23e48d781e83624fd39..711cb9ed0febaf96a7c3077d117325263bc98db4 100644 GIT binary patch delta 899 zcmaJ<%Wl&^6pib=+qiAgq-iN=Box{RQw0=OKqW&42qbotxQ#L!%j$I@QXZD=P#Pg+ z!-i!vV#fw{tn&|i1Ih=m1&J*S#?FJZ1uT!{xp&T)Gw00b#Fw<7$6`?*d)|C&z%OAa zyg2rgAOuJVf+P$f5`i#@LWC?sl&ruqiNOjHAVyX}AZxHn)?tmrVVxu(PBtJxlCVKi zkR+RsB5BwpTabpW4;*a6mA8Jf4e6RMyEFXyZm0jcDA#aRMMYUvkSaYaVPv-SGs8lA z!|x)!$tAC5(UDX-#5J^+u|?#L+jnz05xH-6bj+2xfpnRrXS*C$x7*exgd*}Lwxc^e z`yywyFaMXK2~+rAxds;nX6$VLpPF1{9ldRc$Y|@$mWWKGp(;<|Bw-^80B$BHoznHD3{6f8+4|b{Bdrmu~L{Xk(ZZ?0SGc%BU5&AP2@{YW{P4ID3KK2DA5$YD6tg&DDf15D2WuoD9IF|6yZ6H zDIzJNEi6$|DMG;vnqm`gbTZvy*nFGOm$6=@I5j6VxkRBrJ~KrjttdZNK>;q3lUZD%P@a)ml!_1o8K+>Y zpjupI;OQ6a8Wf`7=@;U!05ctE*kl9NqRH=B%QmlJ`^m({0t|^FmdUF*{TUS||K{AR z6D8#C8WJDi;~4206z}31;^^rUd`k>07UUlQG%zyWEy&+D-p4aIWbz}fTcYe>6Hp1Z b$rrg5m>F4^CV%195rEhMSHU*ffJY1f*gtV- diff --git a/main.py b/main.py index 8c8ce36..391b18d 100644 --- a/main.py +++ b/main.py @@ -1,18 +1,25 @@ # FastAPI import statements -from fastapi import FastAPI, Request +from fastapi import FastAPI, Request, WebSocket from pydantic import BaseModel from fastapi.staticfiles import StaticFiles from fastapi.responses import JSONResponse #from move import router as MoveRouter from fastapi.templating import Jinja2Templates -from database.Dao import Dao -from database.DaoConstants import DaoConstants +from starlette.websockets import WebSocketDisconnect + +from database.Dao import Dao +from database.DaoConstants import DaoConstants +import http.client +import ssl +import uvicorn # Game Logic import statements -from utils.driver import process_move +from service.monopoly_Instance import monopoly_Instance + app = FastAPI() -app.include_router(MoveRouter, tags=["moves"], prefix="/game") + +# app.include_router(MoveRouter, tags=["moves"], prefix="/game") app.mount("/static", StaticFiles(directory="static"), name="static") templates = Jinja2Templates(directory="static") @@ -21,13 +28,40 @@ class Move(BaseModel): move: str +@app.get('/') +async def read_main(request: Request): + return templates.TemplateResponse("index.html", {"request": request}) + + + +# @app.post("/submit_move") +# async def submit_move(move: Move): +# # Process the move using your existing Monopoly game logic +# # Replace this function with your actual game logic +# message = f'Player entered {move.move}' +# a = game_start(move) +# while a is not None: +# +# return message + +@app.websocket("/submit_move") +async def websocket_endpoint(websocket: WebSocket, move: Move): + await websocket.accept() + # room.add_player(websocket) + # await room.broadcast(f"Player joined the room: {websocket.client.host}") + try: + while True: + message = await websocket.receive_text() + print(message) + await print(message) + # await room.broadcast(message) + except Exception as e: + print('Error is ', e) + # room.remove_player(websocket) + # await room.broadcast(f"Player left the room: {websocket.client.host}") + +# @app.get() -@app.post("/submit_move") -async def submit_move(move: Move): - # Process the move using your existing Monopoly game logic - # Replace this function with your actual game logic - result = process_move(move.move) - return {"message": result} @app.get("/getLogs", response_class=JSONResponse) async def get_logs(request: Request, room_id: int): @@ -40,5 +74,14 @@ async def get_logs(request: Request, room_id: int): except Exception as e: return f"An exception occurred: {str(e)}" +# if __name__ == "__main__": +# context = ssl.create_default_context(purpose=ssl.Purpose.CLIENT_AUTH) +# context.load_cert_chain(certfile="./tls/ca-cert.pem", keyfile="./tls/ca-key.pem") +# uvicorn.run(app, host="0.0.0.0", port=8443, ssl_context=context) + # How to replace stuff in the output area # content = content.replace('', f'') + +if __name__ == "__main__": + uvicorn.run("main:app", host="0.0.0.0", port=8443, reload=True, ssl_keyfile="./tls/ca-key.pem", ssl_certfile="./tls/ca-cert.pem") + diff --git a/models/__pycache__/player.cpython-310.pyc b/models/__pycache__/player.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..9571a9efdd73c027094b6f77bd7bb8844be7f4e2 GIT binary patch literal 3125 zcma)8TW{P%6!!SG-upI5?*$yFfCU;Tpb}LGwX_tds%@lzkd{c+#xo?l_1fF9H`T6| zr}mX!P$8Aa{1bkIUwO)N-}->~&e)s1B$2S?Gq*G2bH4Me<{*^ym(X@Z4 zG5;87+`$)r1i>}V0I`Ec!%knM&LE1rNjD19(jMBLjD{gk3%i}56Z#^pbmCYfu@^lH1;=7$EP~&p4O1i; zCmo2?>PMj%$s%=76c067NAYI!{_UMD8STkVzuyh_cD8@{&bzgFb0-%5P>LJq>)ycB zXr~`>5yU&0eH(*O>UbUo6VIdd;~Ip`W^aj&>ls=bQ$3$xnm$xF@hR9^s7%o80lcq( zCg4MzvnQs!p4Bc8U|NE3Q>gy{pC;NXom+n~s$r(VZ8Z~s_W*0N&^mettBxD@qW&Nd ziQuk+ZT*d2Djl-a5FtPM8yZIpqG>8*QfnZ)VUm_RoO?OE3azFtt55@By1wuZI>AsV z_%hMJP+G|&*N+ZFd=5Pdk{TZ{F%im`7LH+u;epgY*RTM%` z(~_6)b48tuGi7R4AP$*=V%hx*yc?5OUhWzfNv9jcS1}_df;1StYi#^h4#DaA3mhRJ zj=}g64LGK~ViVTWRoq$6_?^HoC;BDghnZM3_7ad~U@7PI*4S}(qv76uvfi|n52@W5 z3_yUim~;c-sZD13QJhHSCb@oSC^u7+G}^=q|3t{0-Qmci@pVj4UeaR`P#%lOeaW5uOOnJH5)hb zm>w%FxJ&j;!}vOLmjZd9$%|_1s(^0Nwr7a}wzEa{qE9iO8*tZbjq5)|I2qmDVK+$J zD0JVfD)PGB*bO7}&?&h701PI!Dv#6BK27mdgcYyJ;lpfCOA6kyyJcFPdurNEjK8L} zN{Yg!>HKT5@k;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--git a/service/__pycache__/monopoly_Instance.cpython-39.pyc b/service/__pycache__/monopoly_Instance.cpython-39.pyc index 3aafe806df38c3fe929ab808d4506dbbc30af7c6..e0a1cbcca9a0565172e204f8f0f0222ba87afb40 100644 GIT binary patch delta 1528 zcmZuxT}&fY6ux(+otd^Xh5jL6S;}q~Xn<087sDbUF+f-)5d?I#i`xvnV=c5Z^v=`` zIt_8z7fnn`?u!Od_Ql|viZN>Zc`-&G^ufo*XyTepOnmmyc+Y??*=(DB(|dltbMBdQ z&O!Fm(Xg&*LBu~}*;VrE#BMl=ukQ{`rwAhc3aV;(4Wl_kBqHBJMBWkdVInT0jIw(( zr)6*}P%@lC)q2^mKl-?al`tpz0MR%b5|(k`Xj}LeKLqTpwz6p()G1qLp;kBO7S&kZ zmzj@%PN`U>LfL%L%J^s$1U{!+F4l$Jzw{nHWZy|+^0ThLDcV^k$aipx-IcH6Gi*w^mT0=6^8zO5MJuR6AtDf!T>ac!)T6(z;MXcIEYR zjj$UgsE(QFwR*YYq%1R~r%rm5D=A4?G)47t z<%Yh+&bED#8{=)6!L$n=LQBZzTDW|FlLsd&W!ouQ)y=8jnA-m1d>iyKv^gCCfB~XC z05E2>8$bhim_tjZ1|OoLL6aal3y=dC1?Xbw$Ovv{OOdV4VJ^sriZAK3WE7}jIExp@SzS}5NmNZ~&l(owLYC>@HXY@?zgd%8>; zqaBaE5&&DUYbA*8=xe%dWM_11+A?_^Ovk1w7=$?F)jHpZc9!qSvRR^jkV^m%=|L&9 Wl*y_^>J?)O>SzN|J68Yu3jYG8v2P#% delta 1377 zcmZux&u<$=6y6!zyXzmjabhP<8rN}2?8I{81o}e+q9TaXP$)`Cf)Y|HYwKAYJI*?p z-3Th#LMS~T1ju2EKq^tw6Cj~N6;#9>2_#fhRTT$Ihy#cI101-Z^4_{4q2QIjoq6wj z-+w|}+A#SLyTqi_gL*m)MfRft6aZ20_9oFRC z&g&9OuhOQMpB1sdVJ&@tKl~_vu+1NF`F}XTtqgCGrq_PY(OJgT%|J{)c}?sDhQ$3q zH_3{>0!J>~0{>Aq`aWdd_@>@g$$^TG|BM>&{+x}m@yim<@)9cTM>r!+m_6=f+S#s3 z?1>%E7TF@Kt5<4tvaI+lcs}w_-5NTu68OT=cCKTPOXhi~w9FH*8`QxXQP4WRL*128 zsL2UY2&I&h?suGo`ozWCp|rRi8Wvx}IIJat^2VJFiAm6<6MGZdQ-t*IIl4^5jgIfe zk3(Bz2=B!gZPDC#iV*^op-KM@fhHwewPM77WY5;)=mbW`UcQ!(&KE3ae`- z)-yA`P&hX?dv1De;nl+Fx!IQrXV1(ph#$Kq)Ip$SqHu8hk%a8_`G6RWRORO|d`eu4 zOin*?oC0p++m6AVV?eUK1kj@rFFYYnfP_erMoBMC5|zpntR5LgA{kA^X&2SOqtg&U zp8i1gVca3K2qT&j??z9Hd(n5|?nOY|Q~966C*JIi6TkSV`|5~W3%4q`2mB1ezgNp= zz!nxuJ+CZuqc@3w-^`y!cmV+^2f|zdyf`?VXGwv-jeDjNRaJXbO?^vRR2A2k(FKV; zZL7#dUaOlKj&aej&0OB7P1P(YlI7Suhy=U~mqVLQxoYR&#wuGS?n65!`M>Nfb#kr7 SHml|-tgnsXVW^q=(7yo^L^_H9 diff --git a/service/__pycache__/room.cpython-39.pyc b/service/__pycache__/room.cpython-39.pyc index 82a12e3e425fb5b5a65fbc86f7c138cd8fdad0b3..8c158497541682a66b009bf240ee23c8cb33f5ad 100644 GIT binary patch delta 315 zcmZqRna{(Q$ji&c00c$;(J9v48~N@r^05QC+(7IM#Kr$6|6){?NoS~KE@7)-YGzDf z%w{dJD`8CmvKbi)GYZuvn=@(Fs{vK8lyE`RG&8y|#0J!|*03z#F5$`ItzoKRm1IZ( zVknCZ$YMkjV~5MKz*&qyT^zk^3qdwj0PWvrj1n)%NvupQiZ3Y2FGwvashm8QMMGa466|asz7v E0Fxg=5dZ)H delta 291 zcmZ8cu}T9$5S=%-yPlW3H4%}dkq}f6^ar%mS}a8n6c&V7C2qNgfvYT1ZDD8bK0*8g zKSb~oY}4o*1`7w~@#f8&8D^2sa(i188A-gHU%Joq)qcPlDLays~{kpx?gu88Gol4dc5S9&NQ>> house_cost: + if house_cost is None: + print('House cannot be built on a special card or railway') + + elif player.balance > house_cost: player.build_house(current_tile) message = 'House built!' self.db.insertion_query(self.daoConst.INSERT_LOG, (message, player.room_id)) @@ -214,8 +223,12 @@ def game_start(self): [print(i, end=', ') for i in player.assets_owned] print(end='\n\n') sell_input = int(input(f'Enter 0 - {len(player.assets_owned)}: ')) - 1 + message = f'Enter 0 - {len(player.assets_owned) - 1}' + # Need to do some input here + + self.db.insertion_query(self.daoConst.INSERT_LOG, (message, player.room_id)) message = '%s' % player.assets_owned[sell_input] - selling_property_id = self.db.select_query(self.daoConst.GET_PROPERTY_FROM_LIST, (message, )) + selling_property_id = self.db.select_query(self.daoConst.GET_PROPERTY_OWNED, (message, )) current_tile = self.tiles[selling_property_id[0][0]] sell_property = player.sell_tile(current_tile) self.db.insertion_query(self.daoConst.SELL_PROPERTY, (player.room_id, player.player_id, sell_property)) @@ -277,3 +290,4 @@ def game_over(self, player): else: return False + diff --git a/service/room.py b/service/room.py index 37eacaf..9b086e6 100644 --- a/service/room.py +++ b/service/room.py @@ -7,10 +7,13 @@ class room: def __init__(self) -> None: self.dbRoom=databaseObj.Dao() - self.daoConstRoom=DaoConstRoom.DaoConstants() - self.roomID=1 # need to make this from website input + self.daoConstRoom=DaoConstRoom.DaoConstants() + self.roomID = 1 + # self.roomID = room_id + # self.roomID=self.dbRoom.insertion_query(self.daoConstRoom.JOIN_ROOM,(room_id, 'ACTIVE')) # need to make this from website input #insert logic to wait for players joining this - #as a player joins insert in player table + #as a player joins insert in player table + ''' as a player joins insert into room and player table with all values; @@ -21,6 +24,7 @@ def play(self): usernames = self.dbRoom.select_query( self.daoConstRoom.GET_USERNAME_FROM_PLAYER, (self.roomID,)) print(usernames) player_details=[] + player_property_details = [] while True: if (len(player_details)>=4): @@ -30,17 +34,22 @@ def play(self): print('Waiting for players to join..........') time.sleep(5) player_details= self.dbRoom.select_query( self.daoConstRoom.GET_PLAYERS_IN_ROOM, (self.roomID,)) - + #print('Printing list:',player_details[0].printPlayer()) player_list=[] for i in range(len(player_details)): # Modify this insert to fetch position - player_list.append(player.Player(room_id=player_details[i][0], player_id= player_details[i][1],username= usernames[i][0], - money=player_details[i][2],game_round=player_details[i][5],position= player_details[i][4])) + + # player_property_details.append(self.dbRoom.select_query(self.daoConstRoom.GET_PROPERTY_FROM_PLAYER_OWNED, + # (player_details[i][0], + # player_details[i][1]))) + + # print('this do be', player_property_details) + player_list.append(player.Player(room_id=player_details[i][0], player_id=player_details[i][1], username=usernames[i][0], + money=player_details[i][2], game_round=player_details[i][5], position=player_details[i][4], )) print('Printing list:', player_list[0].print_player()) - m=monopoly.monopoly_Instance(roomID=1,player_list=player_list) # need to get roomid over here from web + m=monopoly.monopoly_Instance(roomID=1, player_list=player_list) # need to get roomid over here from web m.game_start() - - m.game_end_player_details() + m.game_end_player_details() \ No newline at end of file diff --git a/start.py b/start.py index 9ce8d51..39823a9 100644 --- a/start.py +++ b/start.py @@ -1,4 +1,7 @@ import service.room as startRoom +from database.Dao import Dao, DaoConstants +# new_room = Dao.insertion_query(DaoConstants.CREATE_ROOM, (1, 'ACTIVE')) +# room = startRoom.room(new_room) room=startRoom.room() room.play() diff --git a/static/script.js b/static/script.js index 6a44471..b4815c5 100644 --- a/static/script.js +++ b/static/script.js @@ -9,19 +9,11 @@ document.getElementById("submit").addEventListener("click", async () => { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ move }), - }) + }); const result = await response.json(); - if (move === "x") { - outputBox.value += "\n" + result.message; - setTimeout(() => { - outputBox.value = ""; - }, 2000); // Clear after 3 seconds - } else { - outputBox.value += "\n" + JSON.stringify(result); - } - // inputBox.value = ""; + outputBox.value += "\n" + result.message.move; + move.value = ""; } - }); diff --git a/tls/ca-cert.pem b/tls/ca-cert.pem new file mode 100644 index 0000000..d04d8e1 ---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5uZan9ROlVf94UkzNPFnnqPHUN7yEL3DclP7uyPHwTaNyqCo952OMYvgv21upN +JmvY+vI= +-----END CERTIFICATE----- diff --git a/tls/ca-key.pem b/tls/ca-key.pem new file mode 100644 index 0000000..642e33e --- /dev/null +++ b/tls/ca-key.pem @@ -0,0 +1,54 @@ +-----BEGIN ENCRYPTED PRIVATE KEY----- +MIIJnDBOBgkqhkiG9w0BBQ0wQTApBgkqhkiG9w0BBQwwHAQI6lpV7o7Go1sCAggA +MAwGCCqGSIb3DQIJBQAwFAYIKoZIhvcNAwcECDNarEgkKn2eBIIJSI4W8dMfVFyL +02/ZKyQyytKKxRm0QdgtzZx96nrSNLu/Hp+7cEMEun+mrugB5fJTaRGYapOqdgWd +nC6sV8HYOZqezGhXcUdHhT3vPXfs/yBXeBT+ZEbBkUCf+GyJQvivCbF8ut/xbdbP +8aJg3UTOwHfryrCJiL9I9m4xqHy9cxm6j6ieN8ZChfMH3f4gUDZhaaYbdGvl2rS1 +0S1Fk7I8+7q5PVZA6Y7599Fo4JSWF7OG8eECgNrO3Py0D+7e6MF7QDyNTZtju+Ej +V4vDa2CNPsI2FaEJQnzo7wJOccfduo7KECYsWcWPY4WRe16dHJ1OqjnUnVXnFQBN +QliKpy5cF+186nwMwhOyrLhe+79xRvDB3p80fdKY02n75EmE3gaBzqEtBayueGf3 +bO3zz46DNjORFwls0p10hyYiwlvE5gUJOlRoI3oMXj1/5D4aPpj6SNUbt8URYFFA +dq3Yc9mR6TduebGPOXMsnXFu9ezxS3weGshcDS4EutxEkV8kzLCQtQIA4gmvfHR0 +qq4cNUDuP/mQ3UxaBLNHMICwNdUmfpfc6pjeX9kHE3XTRuENEuDE9cWZnnizgPMG +YRd0PIpL2s5hiOzajDaOxhPIZtniY89h5De0K/dtAhj9cSrCF0ztcQKhZo+4myfo ++TPjURdEZI47UQcevalY/6i9ZfYjbLR+9WeeGQds/kM/rt9uvjysLcCIT3oFv/DV +O1oLD2Nld0By+m4kpkzCoCiYGgy+J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fqxR/dHc6wVU+rvIsrwPKAaP0C9FyPMDKJpkppnImIONiyokm4g1N9TMR1e +FHepy08Dbj+KkBh6qPdRj9oEUXlwUZ988gRBlbfM5vAGSCjtO3rZS2PTbBFnb/us +9E3XALeyqMzmWQujPQZ/oxh2cLoHsWCvD9VOt6X+HuSxzbHvTtlHZQMj/J7eDvUW +66mGc2rKpsTEiFIMtkpcJwy8ImheStKoGHTVvWo1MBmrB6gtoccu0dT2wFkvXIvM +4HNHGwkzeLGuEdl2Yf+Lx2m081Jv+nhRuIwYjJVVtPo9BMTiIsWudlgFwQUngw0u +IHLWF++4phn7yEq9jXEo5w== +-----END ENCRYPTED PRIVATE KEY----- diff --git a/utils/__pycache__/driver.cpython-310.pyc b/utils/__pycache__/driver.cpython-310.pyc index c8a5cfc673175262455826ebdde15b30bc3591ca..be658f4c2e298c980f0ef5b958317f60327e5574 100644 GIT binary patch literal 1148 zcmZWn!EVz)5cRGd$958$N=Pjyg49b6sX$18stO@!%ZY#p0x3j_+{`w0YkQ;JO-tS6 z1RUYak&07)X|J5}3!IqUKuOA4JF{=Ro|*SNyjF`GT)P|Z!CiBlp9U;0ir@)uxq}8A zAgR+eo~9(DT}tLLx9fr1ErAE6PfphdAIj*<5I~4NfCwt+Lm(ZeS)E}fr+rDZKT6{> zCiVuzME)#uHbtM|mK$g$&JmV9rZU140eVbCT~Tm95-jd@94KK@zdc*QyTW{3M9<@l zHC~=Dap%om)78-sabNIp4!XP_r*S@Dx-=3=u7oLd>4*T`uZKHZy;p({MVw_xKJ0bg z?e-r$y4RCzFcz$Zv80vpocG2mNo5a2f+aRbXF9Y6IHJ#(N19|eNkBZ}xx&c1M9{;4 z*;fRW^PK<^yP#9DaHbP7p=-|6ow!KQZO;t1nUAJPwJ+ivc&5w7BafyhTzu1w4iX_% zACdvf7Hp-KxUlH2wtE6iB_kI!cal5s+UZC)DG0-Z4 z^R4ascc5LGL`0T%xJP5=M^ literal 635 zcmYjOOK;RL5FR_uqg`5F5^y6Yq(!t+F9lVADp5FApdOH-MUgjS(o{*jwY@Eic298S zKeR{wlCPZj1xN@XCJCU9HD5fR=Jh#xV`Cl27C+wL{o4TFy5OpD3iiqEBLW0uHDtq= zWvq{R79hvqGh_lq7M74j$c|tfey0jJEIRyWf-VvH3v#tk)57e;HBZCX{#jcTg4 zYILi!8$+CTMBXuD;l+?Yx61fvCapb3pP+PdDy{nXz^YmmE`6B3H@Zn@wOlBZo*yft zQX0|Z6{gS9opI#DW?@fjzgFnBr3!6){P*f3TEcdO`at_Q<-?h&T1UeLy$gT2XXqe~+j+PRz@y?vSQKG~TJI<`6;Tb+){+*P%mpsCK3*`6)@ zs8lW=dfJ#e*?R;L=WIC9uOwdQf+qptZ$tkZUX5cPPPH^h&(O>C*Lz9Z{}q{p^7>?d vt+IJ38D)7nEM&rCz&lyE_lOTbFB{W>z5lrwuVU(>h diff --git a/utils/__pycache__/driver.cpython-39.pyc b/utils/__pycache__/driver.cpython-39.pyc index 68eb16d7ffb922937cbb885816f2f74170846a33..921145e9e8f765b7002c67672bade2b55a51443b 100644 GIT binary patch delta 153 zcmbQn@sEQqk(ZZ?0SH`GqEnc~C-TWKx=hrz;pIxeqsOeC3{r&* z7=avTATDMB5-AKog^Yeh9Frd~OUQ7hrr-9f)rpAwN)=UJfX);nw#- z2qI`oTIG|r=r$2dIA=sS-&u?RuC23JX@D0JvNXrqCaD{h9 zTP`49Q~-H^0uci8g#&qKjFaZw4xP%07}LIiTfYZUkRdJDhzc|;JXhTg9*p4+%8_O%P?i5KT8+vJVX?Z1;Uu4>gFZ4`m9e2SC zhpWKhx=F8V!mccK083>8&M}&EyI&-!Zo|e9wRZd!PYu3;b05oE1yQ9D^=Tchd3suf$hApGvxD`Y zEW|F{wjb*NprW=TN6xs)F7{`vF|`1Gcjyi1fQ?vL_lafFhjZF&_$q*0CIIF;*a3z6 z824RsYggeJjhpli^K(blQK^i(Vw|LRY)es!IhzCPi_sXWaq#P`PF>(N$4X|CfSZZ6 z;jMoWD;Q9+gJuWIwPQzY0hoGV2?p0FgJnWl&BF$b(2`cS0hfHejm`Cs+m^7xgR2ll z4TSN8{M7HNJ7~b(PZ180k9FS#heq1i$11I}G3y%k^CIeI+D&-%ziBhIXo*&?5e3Vi zM1yNYH~02-_pT5%o>VGVH*>UZ{6*P`EjeCgSf;S$ttj}{5fgEq<)RN?AU9RcPx`U_ zzByO7z^xWg+(WU5;sl3kk|u?GY>j`*VuBat PF<#;?P2*5ws(I%(18FsO literal 0 HcmV?d00001 diff --git a/utils/driver.py b/utils/driver.py index abeb2b3..9402b12 100644 --- a/utils/driver.py +++ b/utils/driver.py @@ -159,3 +159,6 @@ def moves_list(): print("{:<30}{}".format('View assets owned', 'v')) print("{:<30}{}".format('Sell property', 's')) print("{:<30}{}".format('End turn', 'x'), end='\n\n\n') + +def get_moves(): + pass diff --git a/websocket_test.py b/websocket_test.py new file mode 100644 index 0000000..e123368 --- /dev/null +++ b/websocket_test.py @@ -0,0 +1,71 @@ +from fastapi import FastAPI, WebSocket +from fastapi.responses import HTMLResponse +from typing import List + +app = FastAPI() + +# List to store active WebSocket connections +active_connections: List[WebSocket] = [] + +html = """ + + + + Chat + + +

WebSocket Chat

+
+ + +
+
    +
+ + + +""" + + +@app.get("/") +async def get(): + return HTMLResponse(html) + + +@app.websocket("/ws") +async def websocket_endpoint(websocket: WebSocket): + await websocket.accept() + active_connections.append(websocket) # Add the new connection to the list + + try: + while True: + data = await websocket.receive_text() + # cash and all + # broadcast + # do your input + # Everything goes in here + # a = game_start(data) + await broadcast_message(data) # Broadcast the message to all clients + except Exception as e: + active_connections.remove(websocket) # Remove the disconnected client + print('Error is ', e) + + +async def broadcast_message(message: str): + for connection in active_connections: + await connection.send_text(f"Message text was: {message}")