From f82d6657ef531e4b4c2a816fcb2cf52eb83fe172 Mon Sep 17 00:00:00 2001 From: Jakub Danilewicz Date: Fri, 7 May 2021 19:02:09 +0200 Subject: [PATCH] =?UTF-8?q?Dodany=20Enum=20Terrain;=20Dodany=20koszt=20na?= =?UTF-8?q?=20Tile;=20U=C5=BCywana=20jest=20nowa=20mapa=20testowa=20(reski?= =?UTF-8?q?n=20secondmap)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- display_assets.py | 2 +- project_constants.py | 8 +- resources/minefields/fourthmap.json | 500 ++++++++++++++++++++++++++++ tile.py | 20 +- 4 files changed, 526 insertions(+), 4 deletions(-) create mode 100644 resources/minefields/fourthmap.json diff --git a/display_assets.py b/display_assets.py index b3fb554..33a710f 100644 --- a/display_assets.py +++ b/display_assets.py @@ -15,7 +15,7 @@ tile_asset_options = { "RED": const.ASSET_TILE_RED, "WHITE": const.ASSET_TILE_WHITE, "YELLOW": const.ASSET_TILE_YELLOW -} + } mine_asset_options = { 'A': const.ASSET_MINE_A, diff --git a/project_constants.py b/project_constants.py index 6f63163..381ee18 100644 --- a/project_constants.py +++ b/project_constants.py @@ -70,6 +70,12 @@ class Coords(Enum): Y = 1 +class Terrain(Enum): + CONCRETE = 1 + GRASS = 2 + MUD = 4 + + # =============== # # === STRUCTS === # # =============== # @@ -118,7 +124,7 @@ STRUCT_MINE_ATTRIBUTE_TYPES = { # ==== MAPS ==== # # ============== # -MAP_RANDOM_10x10 = os.path.join("resources", "minefields", "secondmap.json") +MAP_RANDOM_10x10 = os.path.join("resources", "minefields", "fourthmap.json") # ============== # diff --git a/resources/minefields/fourthmap.json b/resources/minefields/fourthmap.json new file mode 100644 index 0000000..644d011 --- /dev/null +++ b/resources/minefields/fourthmap.json @@ -0,0 +1,500 @@ +{ + "0,0": { + "color": "BLUE", + "mine": null + }, + "0,1": { + "color": "BLUE", + "mine": null + }, + "0,2": { + "color": "GREEN", + "mine": null + }, + "0,3": { + "color": "BLUE", + "mine": { + "asset": "B", + "mine_type": "chained", + "predecessor": null + } + }, + "0,4": { + "color": "BLUE", + "mine": { + "asset": "B", + "mine_type": "chained", + "predecessor": null + } + }, + "0,5": { + "color": "BLUE", + "mine": null + }, + "0,6": { + "color": "ORANGE", + "mine": null + }, + "0,7": { + "color": "GREEN", + "mine": null + }, + "0,8": { + "color": "BLUE", + "mine": { + "asset": "B", + "mine_type": "chained", + "predecessor": "0,3" + } + }, + "0,9": { + "color": "ORANGE", + "mine": { + "asset": "F", + "mine_type": "time", + "timer": 20 + } + }, + "1,0": { + "color": "GREEN", + "mine": null + }, + "1,1": { + "color": "GREEN", + "mine": { + "asset": "A", + "mine_type": "standard" + } + }, + "1,2": { + "color": "GREEN", + "mine": null + }, + "1,3": { + "color": "BLUE", + "mine": { + "asset": "B", + "mine_type": "chained", + "predecessor": null + } + }, + "1,4": { + "color": "ORANGE", + "mine": null + }, + "1,5": { + "color": "GREEN", + "mine": null + }, + "1,6": { + "color": "GREEN", + "mine": null + }, + "1,7": { + "color": "GREEN", + "mine": null + }, + "1,8": { + "color": "ORANGE", + "mine": null + }, + "1,9": { + "color": "ORANGE", + "mine": null + }, + "2,0": { + "color": "ORANGE", + "mine": null + }, + "2,1": { + "color": "BLUE", + "mine": { + "asset": "A", + "mine_type": "standard" + } + }, + "2,2": { + "color": "ORANGE", + "mine": null + }, + "2,3": { + "color": "ORANGE", + "mine": { + "asset": "B", + "mine_type": "chained", + "predecessor": null + } + }, + "2,4": { + "color": "GREEN", + "mine": null + }, + "2,5": { + "color": "ORANGE", + "mine": { + "asset": "A", + "mine_type": "standard" + } + }, + "2,6": { + "color": "BLUE", + "mine": null + }, + "2,7": { + "color": "BLUE", + "mine": null + }, + "2,8": { + "color": "ORANGE", + "mine": { + "asset": "B", + "mine_type": "chained", + "predecessor": null + } + }, + "2,9": { + "color": "BLUE", + "mine": null + }, + "3,0": { + "color": "BLUE", + "mine": null + }, + "3,1": { + "color": "ORANGE", + "mine": { + "asset": "F", + "mine_type": "time", + "timer": 19 + } + }, + "3,2": { + "color": "GREEN", + "mine": null + }, + "3,3": { + "color": "ORANGE", + "mine": { + "asset": "B", + "mine_type": "chained", + "predecessor": "1,3" + } + }, + "3,4": { + "color": "ORANGE", + "mine": null + }, + "3,5": { + "color": "BLUE", + "mine": null + }, + "3,6": { + "color": "ORANGE", + "mine": { + "asset": "B", + "mine_type": "chained", + "predecessor": null + } + }, + "3,7": { + "color": "ORANGE", + "mine": null + }, + "3,8": { + "color": "GREEN", + "mine": null + }, + "3,9": { + "color": "GREEN", + "mine": null + }, + "4,0": { + "color": "BLUE", + "mine": null + }, + "4,1": { + "color": "ORANGE", + "mine": null + }, + "4,2": { + "color": "BLUE", + "mine": { + "asset": "A", + "mine_type": "standard" + } + }, + "4,3": { + "color": "BLUE", + "mine": null + }, + "4,4": { + "color": "ORANGE", + "mine": null + }, + "4,5": { + "color": "ORANGE", + "mine": null + }, + "4,6": { + "color": "BLUE", + "mine": null + }, + "4,7": { + "color": "BLUE", + "mine": { + "asset": "B", + "mine_type": "chained", + "predecessor": null + } + }, + "4,8": { + "color": "BLUE", + "mine": null + }, + "4,9": { + "color": "ORANGE", + "mine": null + }, + "5,0": { + "color": "BLUE", + "mine": null + }, + "5,1": { + "color": "ORANGE", + "mine": { + "asset": "B", + "mine_type": "chained", + "predecessor": "2,3" + } + }, + "5,2": { + "color": "ORANGE", + "mine": null + }, + "5,3": { + "color": "GREEN", + "mine": null + }, + "5,4": { + "color": "BLUE", + "mine": { + "asset": "B", + "mine_type": "chained", + "predecessor": "2,8" + } + }, + "5,5": { + "color": "BLUE", + "mine": null + }, + "5,6": { + "color": "ORANGE", + "mine": null + }, + "5,7": { + "color": "ORANGE", + "mine": null + }, + "5,8": { + "color": "GREEN", + "mine": null + }, + "5,9": { + "color": "ORANGE", + "mine": null + }, + "6,0": { + "color": "GREEN", + "mine": null + }, + "6,1": { + "color": "BLUE", + "mine": null + }, + "6,2": { + "color": "ORANGE", + "mine": null + }, + "6,3": { + "color": "BLUE", + "mine": null + }, + "6,4": { + "color": "BLUE", + "mine": null + }, + "6,5": { + "color": "GREEN", + "mine": { + "asset": "A", + "mine_type": "standard" + } + }, + "6,6": { + "color": "GREEN", + "mine": null + }, + "6,7": { + "color": "BLUE", + "mine": null + }, + "6,8": { + "color": "BLUE", + "mine": null + }, + "6,9": { + "color": "BLUE", + "mine": { + "asset": "A", + "mine_type": "standard" + } + }, + "7,0": { + "color": "BLUE", + "mine": { + "asset": "B", + "mine_type": "chained", + "predecessor": "4,7" + } + }, + "7,1": { + "color": "BLUE", + "mine": null + }, + "7,2": { + "color": "GREEN", + "mine": null + }, + "7,3": { + "color": "ORANGE", + "mine": null + }, + "7,4": { + "color": "GREEN", + "mine": null + }, + "7,5": { + "color": "GREEN", + "mine": { + "asset": "A", + "mine_type": "standard" + } + }, + "7,6": { + "color": "BLUE", + "mine": { + "asset": "F", + "mine_type": "time", + "timer": 39 + } + }, + "7,7": { + "color": "ORANGE", + "mine": null + }, + "7,8": { + "color": "GREEN", + "mine": null + }, + "7,9": { + "color": "GREEN", + "mine": null + }, + "8,0": { + "color": "GREEN", + "mine": null + }, + "8,1": { + "color": "GREEN", + "mine": { + "asset": "F", + "mine_type": "time", + "timer": 24 + } + }, + "8,2": { + "color": "GREEN", + "mine": null + }, + "8,3": { + "color": "BLUE", + "mine": { + "asset": "A", + "mine_type": "standard" + } + }, + "8,4": { + "color": "BLUE", + "mine": null + }, + "8,5": { + "color": "GREEN", + "mine": null + }, + "8,6": { + "color": "GREEN", + "mine": null + }, + "8,7": { + "color": "BLUE", + "mine": null + }, + "8,8": { + "color": "GREEN", + "mine": { + "asset": "B", + "mine_type": "chained", + "predecessor": "3,6" + } + }, + "8,9": { + "color": "GREEN", + "mine": null + }, + "9,0": { + "color": "ORANGE", + "mine": null + }, + "9,1": { + "color": "GREEN", + "mine": null + }, + "9,2": { + "color": "BLUE", + "mine": null + }, + "9,3": { + "color": "BLUE", + "mine": null + }, + "9,4": { + "color": "BLUE", + "mine": null + }, + "9,5": { + "color": "GREEN", + "mine": { + "asset": "B", + "mine_type": "chained", + "predecessor": "0,4" + } + }, + "9,6": { + "color": "BLUE", + "mine": null + }, + "9,7": { + "color": "ORANGE", + "mine": null + }, + "9,8": { + "color": "ORANGE", + "mine": null + }, + "9,9": { + "color": "ORANGE", + "mine": null + }, + "agent_starting_position": "0,0" + + } \ No newline at end of file diff --git a/tile.py b/tile.py index ee31c23..c28209f 100644 --- a/tile.py +++ b/tile.py @@ -1,7 +1,23 @@ +from project_constants import Terrain as t + +#Assume_cost function assumes colour as an argument (colour that is already given to a tile) and depending +#on what it is returns value of Terrein Enum +#It is used in Tile.cost (giving the value to the tile) + + +def assume_cost(color): + if (color == "BLUE"): + return t.CONCRETE + elif (color == "GREEN"): + return t.GRASS + elif (color == "ORANGE"): + return t.MUD + + class Tile: def __init__(self, position, color=None, mine=None): self.position = position self.color = color - + self.cost = assume_cost(color) # mine is an instance of Mine class - self.mine = mine + self.mine = mine \ No newline at end of file