Files
Jonathan Tinney 7971961166
Some checks failed
Analyze modified files / flake8 (push) Failing after 2m28s
Build / build-win (push) Has been cancelled
Build / build-ubuntu2204 (push) Has been cancelled
ctest / Test C++ ubuntu-latest (push) Has been cancelled
ctest / Test C++ windows-latest (push) Has been cancelled
Analyze modified files / mypy (push) Has been cancelled
Build and Publish Docker Images / Push Docker image to Docker Hub (push) Successful in 5m4s
Native Code Static Analysis / scan-build (push) Failing after 5m2s
type check / pyright (push) Successful in 1m7s
unittests / Test Python 3.11.2 ubuntu-latest (push) Failing after 16m23s
unittests / Test Python 3.12 ubuntu-latest (push) Failing after 28m19s
unittests / Test Python 3.13 ubuntu-latest (push) Failing after 14m49s
unittests / Test hosting with 3.13 on ubuntu-latest (push) Successful in 5m0s
unittests / Test Python 3.13 macos-latest (push) Has been cancelled
unittests / Test Python 3.11 windows-latest (push) Has been cancelled
unittests / Test Python 3.13 windows-latest (push) Has been cancelled
add schedule I, sonic 1/frontiers/heroes, spirit island
2026-04-02 23:46:36 -07:00

59 lines
2.1 KiB
Python

def camel_case(text: str) -> str:
if len(text) == 0:
return text
s = text.replace("-", " ").replace("_", " ").split()
return s[0] + "".join(i.capitalize() for i in s[1:])
def convert_value_to_digits(value: int) -> list[int]:
digits = []
while value > 0:
digits.append(0x30 + (value % 10))
value = int(value / 10)
# If list is empty, it means requirement was <= 0, so just display "0"
if len(digits) == 0:
digits = [0x30]
return list(reversed(digits))
def get_available_random_colors_from_sprite_name(sprite_filename: str) -> list[str]:
"""
Parse the sprite filename to detect a potential "accepted colors suffix" which uses the following format:
mysrite_<COLORS>.bin, where COLORS is a set of letters representing which colors can be rolled as random colors
for that sprite.
This was built for people who play with both random sprite & random color, but who want a subset of colors for
each sprite (e.g. if they play a Tokay, they only want it orange or red).
"""
CHARACTER_COLORS = {
"r": "red",
"g": "green",
"b": "blue",
"o": "orange",
}
filename_parts = sprite_filename.split("_")
if len(filename_parts) <= 1:
return list(CHARACTER_COLORS.values())
# Get the final part of the filename and remove the ".bin" extension
suffix = filename_parts[-1][0:-4]
if len(suffix) > len(CHARACTER_COLORS.values()):
return list(CHARACTER_COLORS.values()) # Too long, not a color suffix
return [color for letter, color in CHARACTER_COLORS.items() if letter in suffix]
def simple_hex(num: int, size: int = 2) -> str:
return hex(num)[2:].rjust(size, "0")
def script_delay(frames: int) -> str:
known_delays = [1, 4, 8, 10, 15, 20, 30, 40, 60, 90, 120, 180, 240]
if frames in known_delays:
delay_index = known_delays.index(frames)
return f"db $f{simple_hex(delay_index, 1)}\n"
elif frames > 0xff:
return script_delay(240) + script_delay(frames - 240)
else:
return f"db setcounter1,${simple_hex(frames)}\n"