mirror of
https://github.com/MarioSpore/Grinch-AP.git
synced 2025-10-21 20:21:32 -06:00
Options: various fixes to get_option_name falsely giving get_current_option_name instead.
This commit is contained in:
@@ -68,10 +68,14 @@ class FactorioContext(CommonContext):
|
|||||||
raise Exception("Cannot connect to a server with unknown own identity, "
|
raise Exception("Cannot connect to a server with unknown own identity, "
|
||||||
"bridge to Factorio first.")
|
"bridge to Factorio first.")
|
||||||
|
|
||||||
await self.send_msgs([{"cmd": 'Connect',
|
await self.send_msgs([{
|
||||||
'password': self.password, 'name': self.auth, 'version': Utils.version_tuple,
|
"cmd": 'Connect',
|
||||||
|
'password': self.password,
|
||||||
|
'name': self.auth,
|
||||||
|
'version': Utils.version_tuple,
|
||||||
'tags': ['AP'],
|
'tags': ['AP'],
|
||||||
'uuid': Utils.get_unique_identifier(), 'game': "Factorio"
|
'uuid': Utils.get_unique_identifier(),
|
||||||
|
'game': "Factorio"
|
||||||
}])
|
}])
|
||||||
|
|
||||||
def on_print(self, args: dict):
|
def on_print(self, args: dict):
|
||||||
|
10
Options.py
10
Options.py
@@ -181,6 +181,8 @@ class Choice(Option):
|
|||||||
return other != self.value
|
return other != self.value
|
||||||
elif isinstance(other, bool):
|
elif isinstance(other, bool):
|
||||||
return other != bool(self.value)
|
return other != bool(self.value)
|
||||||
|
elif other is None:
|
||||||
|
return False
|
||||||
else:
|
else:
|
||||||
raise TypeError(f"Can't compare {self.__class__.__name__} with {other.__class__.__name__}")
|
raise TypeError(f"Can't compare {self.__class__.__name__} with {other.__class__.__name__}")
|
||||||
|
|
||||||
@@ -217,7 +219,7 @@ class Range(Option, int):
|
|||||||
return cls.from_text(str(data))
|
return cls.from_text(str(data))
|
||||||
|
|
||||||
def get_option_name(self, value):
|
def get_option_name(self, value):
|
||||||
return str(self.value)
|
return str(value)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return str(self.value)
|
return str(self.value)
|
||||||
@@ -256,7 +258,7 @@ class OptionDict(Option):
|
|||||||
raise NotImplementedError(f"Cannot Convert from non-dictionary, got {type(data)}")
|
raise NotImplementedError(f"Cannot Convert from non-dictionary, got {type(data)}")
|
||||||
|
|
||||||
def get_option_name(self, value):
|
def get_option_name(self, value):
|
||||||
return ", ".join(f"{key}: {value}" for key, value in self.value.items())
|
return ", ".join(f"{key}: {v}" for key, v in value.items())
|
||||||
|
|
||||||
def __contains__(self, item):
|
def __contains__(self, item):
|
||||||
return item in self.value
|
return item in self.value
|
||||||
@@ -282,7 +284,7 @@ class OptionList(Option):
|
|||||||
return cls.from_text(str(data))
|
return cls.from_text(str(data))
|
||||||
|
|
||||||
def get_option_name(self, value):
|
def get_option_name(self, value):
|
||||||
return ", ".join(self.value)
|
return ", ".join(value)
|
||||||
|
|
||||||
def __contains__(self, item):
|
def __contains__(self, item):
|
||||||
return item in self.value
|
return item in self.value
|
||||||
@@ -310,7 +312,7 @@ class OptionSet(Option):
|
|||||||
return cls.from_text(str(data))
|
return cls.from_text(str(data))
|
||||||
|
|
||||||
def get_option_name(self, value):
|
def get_option_name(self, value):
|
||||||
return ", ".join(self.value)
|
return ", ".join(value)
|
||||||
|
|
||||||
def __contains__(self, item):
|
def __contains__(self, item):
|
||||||
return item in self.value
|
return item in self.value
|
||||||
|
Reference in New Issue
Block a user