Update keybindings and enhance loading screen functionality
- Refactor keybindings for gas spawning across multiple configurations - Implement new loading screen updates during game initialization - Add tests to ensure all weapon actions are exposed in keybinding profiles - Introduce new assets for explosion effects
This commit is contained in:
@@ -0,0 +1,87 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
from engine import controls
|
||||
|
||||
|
||||
class DummyBindings(controls.KeyBindings):
|
||||
def spawn_rat(self):
|
||||
pass
|
||||
|
||||
def toggle_audio(self):
|
||||
pass
|
||||
|
||||
def toggle_full_screen(self):
|
||||
pass
|
||||
|
||||
def start_scrolling(self, direction):
|
||||
pass
|
||||
|
||||
def stop_scrolling(self):
|
||||
pass
|
||||
|
||||
def spawn_new_bomb(self):
|
||||
pass
|
||||
|
||||
def spawn_new_nuclear_bomb(self):
|
||||
pass
|
||||
|
||||
def spawn_new_mine(self):
|
||||
pass
|
||||
|
||||
def spawn_new_gas(self):
|
||||
pass
|
||||
|
||||
def spawn_gas(self, parent_id=None):
|
||||
pass
|
||||
|
||||
def toggle_pause(self):
|
||||
pass
|
||||
|
||||
def reset_game(self):
|
||||
pass
|
||||
|
||||
def quit_game(self):
|
||||
pass
|
||||
|
||||
def menu_up(self):
|
||||
pass
|
||||
|
||||
def menu_down(self):
|
||||
pass
|
||||
|
||||
def menu_left(self):
|
||||
pass
|
||||
|
||||
def menu_right(self):
|
||||
pass
|
||||
|
||||
|
||||
class KeybindingProfileTests(unittest.TestCase):
|
||||
def test_shipped_profiles_expose_all_weapon_actions(self):
|
||||
dummy = DummyBindings()
|
||||
conf_dir = Path(__file__).resolve().parent / "conf"
|
||||
weapon_actions = {
|
||||
"spawn_new_bomb",
|
||||
"spawn_new_nuclear_bomb",
|
||||
"spawn_new_mine",
|
||||
"spawn_new_gas",
|
||||
}
|
||||
|
||||
for config_path in sorted(conf_dir.glob("keybindings*.json")) + sorted(conf_dir.glob("keybindings*.yaml")):
|
||||
bindings = controls._load_bindings_from_file(config_path)
|
||||
validated = dummy._validate_bindings(bindings, config_path)
|
||||
game_bindings = validated.get("keybinding_game", {})
|
||||
self.assertTrue(game_bindings, f"missing keybinding_game in {config_path.name}")
|
||||
|
||||
actions = set(game_bindings.values())
|
||||
self.assertTrue(
|
||||
weapon_actions.issubset(actions),
|
||||
f"incomplete weapon bindings in {config_path.name}: {sorted(actions)}",
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user