-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor to be more pythonic, refactor to use type hinting & py3 types #7
Comments
Currently waiting on feedback on the original design intentions. Recap of the discord messages below. The suggestion below could be punted to a separate ticket as well, with the current one only covering conversion to implement subclass methods _read_body and _write_body. Recap: @staticmethod
def create_tag_block(block_type, block_name, named_variables):
tmp_tag_block = TagBlock(Block().block_data)
tmp_tag_block.type = block_type
tmp_tag_block.name = block_name
tmp_tag_block.number_of_integer_variables = 0
tmp_tag_block.number_of_string_varaibles = 0
for variable in named_variables:
if type(variable[1] == int):
number_of_integer_variables = +1
tmp_tag_block.named_variables.append(variable)
elif type(variable[1 == str]):
number_of_string_varaibles = +1
tmp_tag_block.named_variables.append(variable)
return tmp_tag_block
raise NotImplementedError This is a fast way of handling multiple entries under the same name, but it's unclear whether c2e supports this edgecase, or if any existing agent files do this. >>> tag_block["Creature Age In Ticks"] = 0 It would also be friendlier for library end-users who might want to survey agent files. Another possibility would be to have |
I wrote a rough and completely untested version of the tag block that should get the ideas i had in mind across. It imitates existing behavior while being much cleaner. I think you had the right general idea with the MutableSequence subclass setting a flag when data is added or removed. However, I think that TagBlock itself should be the should be a MutableMapping/MutableSequence subclass. That could give is clean syntax like the following: >>> tag_block["Creature Age In Ticks"] = 0 However, that should probably be part of another ticket. The following issues should probably be other tickets as well:
|
Conversation with @KeyboardInterrupt has made it clear that this is originally a py2 codebase from 2016.
It needs type hinting as the start of cleanup, as well as replacing some of the int parsing with use of the struct module.
The text was updated successfully, but these errors were encountered: