From b0075ab5194655c0f72125b36b27ec329dd6d602 Mon Sep 17 00:00:00 2001 From: Jeremy Saklad Date: Tue, 3 Aug 2021 14:23:52 -0500 Subject: [PATCH] Move remaining enumerations to different files This makes it possible to split the central script up further. Importing enum is no longer necessary for the central script, so it has been removed. --- Bone Market Solver.py | 38 +++-------------------------------- data/diplomat_fascinations.py | 14 +++++++++++++ data/fluctuations.py | 11 ++++++++++ data/occasional_buyers.py | 23 +++++++++++++++++++++ 4 files changed, 51 insertions(+), 35 deletions(-) create mode 100644 data/diplomat_fascinations.py create mode 100644 data/fluctuations.py create mode 100644 data/occasional_buyers.py diff --git a/Bone Market Solver.py b/Bone Market Solver.py index b122f3e..90a5293 100644 --- a/Bone Market Solver.py +++ b/Bone Market Solver.py @@ -5,7 +5,6 @@ __author__ = "Jeremy Saklad" import argparse import curses -from enum import Enum from functools import reduce from os import cpu_count @@ -16,7 +15,10 @@ from data.appendages import Appendage from data.buyers import Buyer from data.costs import Cost from data.declarations import Declaration +from data.diplomat_fascinations import DiplomatFascination from data.embellishments import Embellishment +from data.fluctuations import Fluctuation +from data.occasional_buyers import OccasionalBuyer from data.skulls import Skull from data.torsos import Torso from objects.enumaction import EnumAction @@ -74,40 +76,6 @@ cp_model.CpModel.AddGeneralMultiplicationEquality = AddGeneralMultiplicationEqua del AddGeneralMultiplicationEquality -class Fluctuation(Enum): - """Which skeleton attribute is currently boosted.""" - - ANTIQUITY = 1 - AMALGAMY = 2 - MENACE = 3 - -class OccasionalBuyer(Enum): - """Which of several unusual buyers are available.""" - - AN_ENTHUSIAST_IN_SKULLS = [Buyer.AN_ENTHUSIAST_IN_SKULLS] - - A_DREARY_MIDNIGHTER = [Buyer.A_DREARY_MIDNIGHTER] - - A_COLOURFUL_PHANTASIST = [ - Buyer.A_COLOURFUL_PHANTASIST_BAZAARINE, - Buyer.A_COLOURFUL_PHANTASIST_NOCTURNAL, - Buyer.A_COLOURFUL_PHANTASIST_CELESTIAL, - ] - - AN_INGENUOUS_MALACOLOGIST = [Buyer.AN_INGENUOUS_MALACOLOGIST] - - AN_ENTERPRISING_BOOT_SALESMAN = [Buyer.AN_ENTERPRISING_BOOT_SALESMAN] - - -DiplomatFascination = Enum( - 'DiplomatFascination', - ( (diplomat.name[22:], diplomat) for diplomat in Buyer - if diplomat.name.startswith('THE_TRIFLING_DIPLOMAT_') ), - module = __name__ - ) -DiplomatFascination.__doc__ = "The current fascination of the Trifling Diplomat." - - def Solve(shadowy_level, bone_market_fluctuations = None, zoological_mania = None, occasional_buyer = None, diplomat_fascination = None, desired_buyers = [], maximum_cost = cp_model.INT32_MAX, maximum_exhaustion = cp_model.INT32_MAX, time_limit = float('inf'), workers = cpu_count(), stdscr = None): model = cp_model.CpModel() diff --git a/data/diplomat_fascinations.py b/data/diplomat_fascinations.py new file mode 100644 index 0000000..9a2cb86 --- /dev/null +++ b/data/diplomat_fascinations.py @@ -0,0 +1,14 @@ +__all__ = ['DiplomatFascination'] +__author__ = "Jeremy Saklad" + +from enum import Enum + +from data.buyers import Buyer + +DiplomatFascination = Enum( + 'DiplomatFascination', + ( (diplomat.name[22:], diplomat) for diplomat in Buyer + if diplomat.name.startswith('THE_TRIFLING_DIPLOMAT_') ), + module = __name__ + ) +DiplomatFascination.__doc__ = "The current fascination of the Trifling Diplomat." diff --git a/data/fluctuations.py b/data/fluctuations.py new file mode 100644 index 0000000..14392f0 --- /dev/null +++ b/data/fluctuations.py @@ -0,0 +1,11 @@ +__all__ = ['Fluctuation'] +__author__ = "Jeremy Saklad" + +from enum import Enum + +class Fluctuation(Enum): + """Which skeleton attribute is currently boosted.""" + + ANTIQUITY = 1 + AMALGAMY = 2 + MENACE = 3 diff --git a/data/occasional_buyers.py b/data/occasional_buyers.py new file mode 100644 index 0000000..18a0708 --- /dev/null +++ b/data/occasional_buyers.py @@ -0,0 +1,23 @@ +__all__ = ['OccasionalBuyer'] +__author__ = "Jeremy Saklad" + +from enum import Enum + +from data.buyers import Buyer + +class OccasionalBuyer(Enum): + """Which of several unusual buyers are available.""" + + AN_ENTHUSIAST_IN_SKULLS = [Buyer.AN_ENTHUSIAST_IN_SKULLS] + + A_DREARY_MIDNIGHTER = [Buyer.A_DREARY_MIDNIGHTER] + + A_COLOURFUL_PHANTASIST = [ + Buyer.A_COLOURFUL_PHANTASIST_BAZAARINE, + Buyer.A_COLOURFUL_PHANTASIST_NOCTURNAL, + Buyer.A_COLOURFUL_PHANTASIST_CELESTIAL, + ] + + AN_INGENUOUS_MALACOLOGIST = [Buyer.AN_INGENUOUS_MALACOLOGIST] + + AN_ENTERPRISING_BOOT_SALESMAN = [Buyer.AN_ENTERPRISING_BOOT_SALESMAN]