From 39383806577fef2da1ad2db0c60c2cb4da9200fc Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Wed, 21 Jun 2023 23:13:46 +0100 Subject: Check for the total gold limit of 1 byte --- tools/map.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'tools') diff --git a/tools/map.py b/tools/map.py index d4a23a0..5522a9e 100755 --- a/tools/map.py +++ b/tools/map.py @@ -45,6 +45,14 @@ def main(): out = list(map(lambda x: (x - tileset["firstgid"]) & 0xFF, map_layer["data"])) gold_layer = get_layer(data, "Gold") + + total_gold = 0 + for t in gold_layer["data"]: + if t != 0: + total_gold += 1 + if total_gold > 255: + parser.error("There are more than 255 gold pieces on the screen") + out.extend(map(lambda x: (x - tileset["firstgid"]) & 0xFF, gold_layer["data"])) # TODO: process map entities -- cgit v1.2.3