Skip to content

Commit

Permalink
(Aegis) refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
ahyangyi committed Oct 27, 2023
1 parent 19565e9 commit 811ae9c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
18 changes: 17 additions & 1 deletion agrf/parameters/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,26 @@ def add(self, g, s):
name=s[f"STR_PARAM_{self.name}"],
description=s[f"STR_PARAM_{self.name}_DESC"],
default=self.default,
limits=(min(self.enum.keys()), max(self.enum.keys())),
limits=self.limits,
enum={k: s[f"STR_PARAM_{self.name}_{v}"] for k, v in self.enum.items()},
)

@property
def min_value(self):
return min(self.enum.keys())

@property
def max_value(self):
return max(self.enum.keys())

@property
def limits(self):
return (self.min_value, self.max_value)

@property
def range(self):
return (self.min_value, self.max_value + 1)

def set_index(self, index):
self.index = index

Expand Down
5 changes: 1 addition & 4 deletions industry/lib/industry/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ def __init__(self, variables, branches):
self.branches = branches


VARLEN = {0: 4, 9: 7}


class AIndustry(grf.SpriteGenerator):
def __init__(self, *, name, id=None, callbacks={}, **props):
super().__init__()
Expand Down Expand Up @@ -82,7 +79,7 @@ def dynamic_definitions(self, all_choices, parameters, i=0):
return []
ret = []
var_id = all_choices[i]
for choice in range(VARLEN[var_id]):
for choice in range(len(parameter_list.parameters[var_id].enum)):
parameters[var_id] = choice
actions = self.dynamic_definitions(all_choices, parameters, i + 1)
if len(actions) == 0:
Expand Down

0 comments on commit 811ae9c

Please sign in to comment.