Spaces:
Sleeping
Sleeping
Download nodes.py from sqfoo/Mini_DungeonGame: direct link, hf CLI and curl.
- Browser
- Download file 1.18 kB
-
https://huggingface.co/spaces/sqfoo/Mini_DungeonGame/resolve/ccef4f75d3396d2c62de856476f48383c8b7e2d4/nodes.py
- Command line
-
hf download hf://spaces/sqfoo/Mini_DungeonGame@ccef4f75d3396d2c62de856476f48383c8b7e2d4/nodes.py
-
curl -L -o nodes.py https://huggingface.co/spaces/sqfoo/Mini_DungeonGame/resolve/ccef4f75d3396d2c62de856476f48383c8b7e2d4/nodes.py
1.18 kB
| from player import Player | |
| from utils import * | |
| class Node: | |
| def __init__(self, title: str, description: str, filelist: list[str], effect: dict = None, route = None, default: int = -1): | |
| self.title = title | |
| self.description = description | |
| self.filelist = filelist | |
| self.effect = effect | |
| self.route = route | |
| self.default = default | |
| def _next(self, result: str, player: Player) -> int: | |
| result = result.upper() | |
| paired = self.effect.get(result, None) if self.effect is not None else None | |
| if paired is not None: | |
| for (change, attr, amount) in paired: | |
| change(player, attr, amount) | |
| if self.route is None: | |
| return -1 | |
| if isinstance(self.route, dict): | |
| next_node = self.route.get(result, self.default) | |
| else: | |
| print('Here') | |
| next_node = self.route(player) | |
| return next_node - 1 if next_node >= 0 else -1 | |
| def get_title(self) -> str: | |
| return self.title | |
| def get_description(self) -> str: | |
| return self.description | |
| def get_images(self) -> list[str]: | |
| return self.filelist |