diff --git a/README.md b/README.md index 3a2db6b..ca55bd1 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,5 @@ BCCE is in active development and this may break at any time; see the first para These sections in the BCEX/BCCE spoiler logs currently have no logic and I'm aware of it. That doesn't mean sections *not* listed here have support; they may not and I'm not aware of them. -- SHOPS - TREASURE CHESTS - JUNCTIONS diff --git a/main.py b/main.py index f8145d5..fad53b5 100644 --- a/main.py +++ b/main.py @@ -15,7 +15,6 @@ class Parser: # noqa: PLR0904 BCEX/BCCE spoiler logfile parser. Sections missing support: - - SHOPS - TREASURE CHESTS - JUNCTIONS """ @@ -579,6 +578,36 @@ class Parser: # noqa: PLR0904 return result + @staticmethod + def parse_SHOPS(data: str) -> dict[str, dict]: + """ + Parse SHOPS section. + + For now this is just a dict of shop name => {item => cost}. I would like to split + this up better so you have, for example narshe["wob"]["after_kefka"]["weapons"] but + that's probably more lifting than is necessary. Most people will just be searching + for buyable items period. + """ + result = {} + shop = None + + for line in data.split("\n"): + if "-----" in line or not line.strip(): + continue + + if line == line.upper(): + shop = line.strip() + result[shop] = {"stock": {}, "female_discount": False} + elif line.startswith("Discounts for female characters"): + result[shop]["female_discount"] = True + else: + tok_line = line.split() + item = " ".join(tok_line[:-1]) + cost = tok_line[-1] + result[shop]["stock"][item.strip()] = int(cost.strip()) + + return result + @staticmethod def cleanup_STATS(data: dict) -> bool: """