From 75618c1de1cfb03272c7a6085c252510fdb14047 Mon Sep 17 00:00:00 2001 From: Cory Date: Sun, 19 May 2024 00:52:09 -0400 Subject: [PATCH] I got the numbers to show up! Now I just need to add flag functionality and I think we're good? --- __pycache__/cursor.cpython-312.pyc | Bin 1387 -> 1407 bytes __pycache__/free_space.cpython-312.pyc | Bin 6358 -> 12693 bytes __pycache__/mine.cpython-312.pyc | Bin 1518 -> 1640 bytes __pycache__/spawner.cpython-312.pyc | Bin 2883 -> 2883 bytes cursor.py | 4 +- free_space.py | 66 ++++++++++++++++++++++--- mine.py | 4 ++ 7 files changed, 67 insertions(+), 7 deletions(-) diff --git a/__pycache__/cursor.cpython-312.pyc b/__pycache__/cursor.cpython-312.pyc index a657f0fc7258e60438dc6e44638055d1cfbcbaa3..d2a1cc8a045c029c6b4d25569a486e035f21f83a 100644 GIT binary patch delta 189 zcmaFO^`DFPG%qg~0}#kmd8W;n$m?sT0_03*NM(p(Oks#(N@0v*PGO2-Nnws+O<`$a zh+<1&1(NKQY?|!1*qlp?it~$Zu_Z%jM*onBleaK(ZT4WC$i&Dy`4;n8MvloVSWLKX zaTKMNr6%U2rcA!WqADr_w4;UL2Dfm7%MAhH2G1M(!VMmi1zF`7l_ndoN+>G>TZl jX-=wLkrI&02*kyLK;i>4BO~K?E-^-T#!n0&608LP$y_nu diff --git a/__pycache__/free_space.cpython-312.pyc b/__pycache__/free_space.cpython-312.pyc index e02ba76f9de0053f2dfc260b61f3ad1a69a72b77..808fb7fef18801d9915779b782f1cd92301e57c3 100644 GIT binary patch literal 12693 zcmeHNU2GHC6`rxji5(|#!eohq9dH(?aI%|_gr9{a{Ir2B+mJ26ki^+Aay%3NB({?o zvux7PA{D71u_7zAN_YaQN|5qE=nJ5&v`Kd*SoNVZaaMLmy!B}xDrJMJRk6$0|m+g?E7xkf%nMYR0Ob|Na1A-;a z5iEIArsg(fV)bqVOSubJ!#ToT$QA%K zvV}lRtPyAtYXWL!i+~ohW}qc(G0@VH5@)GwI>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HTKDSplw6AwP5m(iUgu?w50flW&@UM4t zdK6YI99(6Iq!$)%<)~x$JfXCaJ(FWmC^|_FTn<0IT2|Ms&Fn^Yuda8y>wVwbKK5HS zwEfnON28CY_{m4`3}#o9VO-B1DuYnqlF=g zD}@tCa#wO`a^GU{&CE-^#TXwlaqb32uFZao(-|3gCqHA_!zes?F>^hm*komvDn`l4 z^H}0IWq^hjDFBJdt66LnS&B3A%d0p+`t?9ed6;YwH<0D0$upUkRiEn?M^S27YGO`m z%48c>c}A7V;jD_9`alIO3^xRX8$56D3paRtVqs)e{KUq>D*cIvkyZ8+8zZX}h~S+( hoz+ZH3#ghAh>Q7w#0O?ZM#k?vQjENx7=Q%WE&%xFJ}LkJ delta 205 zcmaFC^NySMG%qg~0}xzK^GsVZk=Iwu1jw1rkjfCnn8Fanl)@OroWj(?FfmVozmh|f z^A?M5W?t$o#`t8W$$`vLlOHe(OuW*<$hkR^aXKR-&*YCxdl-c#uVb!f6rHTcQpG4S zc_mAnpfu3TA_Wk^4J7Q7$IDnI!&tE{{#P^^XFhJbK`=O-3MR>e scosc36z-G%qg~0}w3B*vMtc4FEM61i1hJ delta 19 ZcmX>sc36z-G%qg~0}yOZ-^gXj4FEM_1jPUV diff --git a/cursor.py b/cursor.py index 3d152b7..47ec299 100644 --- a/cursor.py +++ b/cursor.py @@ -5,6 +5,7 @@ class Cursor: name = "cursor" character = 'O' + revealed = True def __init__(self, position): self.position = position @@ -24,4 +25,5 @@ class Cursor: if game.on_board(new_position): if game.is_empty(new_position): self.position = new_position - game.log("The cursor is at " + str(self.position)) \ No newline at end of file + game.log("The cursor is at " + str(self.position)) + diff --git a/free_space.py b/free_space.py index 97ed419..8eecd14 100644 --- a/free_space.py +++ b/free_space.py @@ -17,16 +17,33 @@ class FreeSpace: def handle_keystroke(self, keystroke, game): if keystroke.name in ("KEY_ENTER"): if not game.is_empty(self.position): - game.log(str(self.position) + " is clear!") - self.revealed = True + board_width,board_height = game.board_size + for i in range(board_width): + for j in range(board_height): + try: + game.get_agent_by_name("freespace"+str(i)+str(j)).show() + except: + pass + self.reveal(game) + for i in range(board_width): + for j in range(board_height): + try: + game.get_agent_by_name("freespace"+str(i)+str(j)).hide() + except: + pass + def hide(self): - self.display = False + if self.revealed == False: + self.display = False + + def show(self): + self.display = True def play_turn(self, game): - if (not game.is_empty(self.position)) and self.revealed: + if (not game.is_empty(self.position)) and self.revealed and self.display == True: self.display = False - elif game.is_empty(self.position) and self.revealed and self.neighbors > 0: + elif game.is_empty(self.position) and self.revealed and self.neighbors > 0 and self.display == False: self.display = True def name_me(self, named): @@ -67,4 +84,41 @@ class FreeSpace: if game.get_agents_by_position()[(self.width - 1,self.height - 1)][0].name in names_of_mines: self.neighbors = self.neighbors + 1 if self.neighbors > 0: - self.character = str(self.neighbors) \ No newline at end of file + self.character = str(self.neighbors) + + def reveal(self,game): + game.log("Revealing " + str(self.position)) + self.revealed = True + if self.neighbors == 0: + if game.on_board((self.width + 1,self.height)): + if len(game.get_agents_by_position()[(self.width + 1,self.height)]) != 0: + if not game.get_agents_by_position()[(self.width + 1,self.height)][0].revealed: + game.get_agents_by_position()[(self.width + 1,self.height)][0].reveal(game) + if game.on_board((self.width - 1,self.height)): + if len(game.get_agents_by_position()[(self.width - 1,self.height)]) != 0: + if not game.get_agents_by_position()[(self.width - 1,self.height)][0].revealed: + game.get_agents_by_position()[(self.width - 1,self.height)][0].reveal(game) + if game.on_board((self.width,self.height + 1)): + if len(game.get_agents_by_position()[(self.width,self.height + 1)]) != 0: + if not game.get_agents_by_position()[(self.width,self.height + 1)][0].revealed: + game.get_agents_by_position()[(self.width,self.height + 1)][0].reveal(game) + if game.on_board((self.width,self.height - 1)): + if len(game.get_agents_by_position()[(self.width,self.height - 1)]) != 0: + if not game.get_agents_by_position()[(self.width,self.height - 1)][0].revealed: + game.get_agents_by_position()[(self.width,self.height - 1)][0].reveal(game) + if game.on_board((self.width + 1,self.height + 1)): + if len(game.get_agents_by_position()[(self.width + 1,self.height + 1)]) != 0: + if not game.get_agents_by_position()[(self.width + 1,self.height + 1)][0].revealed: + game.get_agents_by_position()[(self.width + 1,self.height + 1)][0].reveal(game) + if game.on_board((self.width + 1,self.height - 1)): + if len(game.get_agents_by_position()[(self.width + 1,self.height - 1)]) != 0: + if not game.get_agents_by_position()[(self.width + 1,self.height - 1)][0].revealed: + game.get_agents_by_position()[(self.width + 1,self.height - 1)][0].reveal(game) + if game.on_board((self.width - 1,self.height + 1)): + if len(game.get_agents_by_position()[(self.width - 1,self.height + 1)]) != 0: + if not game.get_agents_by_position()[(self.width - 1,self.height + 1)][0].revealed: + game.get_agents_by_position()[(self.width - 1,self.height + 1)][0].reveal(game) + if game.on_board((self.width - 1,self.height - 1)): + if len(game.get_agents_by_position()[(self.width - 1,self.height - 1)]) != 0: + if not game.get_agents_by_position()[(self.width - 1,self.height - 1)][0].revealed: + game.get_agents_by_position()[(self.width - 1,self.height - 1)][0].reveal(game) diff --git a/mine.py b/mine.py index 9afcf62..5c00940 100644 --- a/mine.py +++ b/mine.py @@ -5,6 +5,7 @@ class Mine: character = '_' + revealed = True def __init__(self, position): self.position = position @@ -25,4 +26,7 @@ class Mine: pass def reveal(): + pass + + def show(): pass \ No newline at end of file