generated from mwc/project_game
	I got the numbers to show up! Now I just need to
add flag functionality and I think we're good?
This commit is contained in:
		
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							@@ -5,6 +5,7 @@
 | 
				
			|||||||
class Cursor:
 | 
					class Cursor:
 | 
				
			||||||
    name = "cursor"
 | 
					    name = "cursor"
 | 
				
			||||||
    character = 'O'
 | 
					    character = 'O'
 | 
				
			||||||
 | 
					    revealed = True
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def __init__(self, position):
 | 
					    def __init__(self, position):
 | 
				
			||||||
        self.position = position
 | 
					        self.position = position
 | 
				
			||||||
@@ -25,3 +26,4 @@ class Cursor:
 | 
				
			|||||||
                if game.is_empty(new_position):
 | 
					                if game.is_empty(new_position):
 | 
				
			||||||
                    self.position = new_position
 | 
					                    self.position = new_position
 | 
				
			||||||
                    game.log("The cursor is at " + str(self.position))
 | 
					                    game.log("The cursor is at " + str(self.position))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -17,16 +17,33 @@ class FreeSpace:
 | 
				
			|||||||
    def handle_keystroke(self, keystroke, game):
 | 
					    def handle_keystroke(self, keystroke, game):
 | 
				
			||||||
        if keystroke.name in ("KEY_ENTER"):
 | 
					        if keystroke.name in ("KEY_ENTER"):
 | 
				
			||||||
            if not game.is_empty(self.position):
 | 
					            if not game.is_empty(self.position):
 | 
				
			||||||
                game.log(str(self.position) + " is clear!")
 | 
					                board_width,board_height = game.board_size
 | 
				
			||||||
                self.revealed = True
 | 
					                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):
 | 
					    def hide(self):
 | 
				
			||||||
 | 
					        if self.revealed == False:
 | 
				
			||||||
            self.display = False
 | 
					            self.display = False
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def show(self):
 | 
				
			||||||
 | 
					        self.display = True
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def play_turn(self, game):
 | 
					    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
 | 
					            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
 | 
					            self.display = True
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def name_me(self, named):
 | 
					    def name_me(self, named):
 | 
				
			||||||
@@ -68,3 +85,40 @@ class FreeSpace:
 | 
				
			|||||||
                    self.neighbors = self.neighbors + 1
 | 
					                    self.neighbors = self.neighbors + 1
 | 
				
			||||||
        if self.neighbors > 0:
 | 
					        if self.neighbors > 0:
 | 
				
			||||||
            self.character = str(self.neighbors)
 | 
					            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)
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										4
									
								
								mine.py
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								mine.py
									
									
									
									
									
								
							@@ -5,6 +5,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
class Mine:
 | 
					class Mine:
 | 
				
			||||||
    character = '_'
 | 
					    character = '_'
 | 
				
			||||||
 | 
					    revealed = True
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def __init__(self, position):
 | 
					    def __init__(self, position):
 | 
				
			||||||
        self.position = position
 | 
					        self.position = position
 | 
				
			||||||
@@ -26,3 +27,6 @@ class Mine:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    def reveal():
 | 
					    def reveal():
 | 
				
			||||||
        pass
 | 
					        pass
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def show():
 | 
				
			||||||
 | 
					        pass
 | 
				
			||||||
		Reference in New Issue
	
	Block a user