从 Qud roguelike 洞穴中提取游戏数据
项目描述
哈加迪亚斯
用于从Qud roguelike洞穴中提取游戏数据的 Python 包。
这个库构成了几个项目的基础:
- 构建和更新官方 Caves of Qud wiki的 Caves of Qud wiki 机器人
- 在Qud discord 服务器上运行的 Discord 机器人(邀请链接)
它有什么作用?
hagadias 允许用户以《 Caves of Qud》 roguelike RPG使用的原始格式读取游戏数据 ,包括对象树、全彩色图块和角色数据。它需要传递到游戏本地安装的路径才能执行任何操作。
安装
hagadias 需要 Python 3.10。
要在没有包管理器的情况下从此 GitHub 存储库安装包,请运行
pip install git+https://github.com/trashmonks/hagadias@main#egg=hagadias
如果您使用 pipenv 管理依赖项,
pipenv install -e git+https://github.com/trashmonks/hagadias.git@main#egg=hagadias
如果您使用 Poetry 管理依赖项,
poetry add git+https://github.com/trashmonks/hagadias#main
瓷砖支撑
平铺支持需要将来自 Qud 洞穴的纹理文件解压缩到正在导入 hagadias 的项目的工作目录下的“纹理”目录中。您可以使用 Brinedump 游戏模组从游戏中导出这些纹理。
示例用法
启动
import hagadias
from pprint import pprint
GAMEPATH = 'C:\\Steam\\steamapps\\common\\Caves of Qud' # Windows
# GAMEPATH = '~/.local/share/Steam/steamapps/common/Caves of Qud' # Linux
# GAMEPATH = '~/Library/Application Support/Steam/steamapps/common/Caves of Qud' # macOS
root = hagadias.gameroot.GameRoot(GAMEPATH)
print(root.gamever) # output version of the game
2.0.203.56
对象(蓝图)
qud_object_root, qindex = root.get_object_tree()
# The above gives you two items:
# - a `qud_object_root` object of type `QudObjectProps` that is the root of the CoQ object hierarchy, allowing you to traverse the entire object tree and retrieve information about the items, characters, tiles, etc.
# - a `qindex` which is a dictionary that simply maps the Name (ingame object ID or wish ID) of each ingame object, as a string, to the Python object representing it.
# Example use of qud_object_root:
>>> qud_object_root.source
'<object Name="Object">\n <part Name="Physics" Conductivity="0" IsReal="true" Solid="false" Weight="0"></part>\n </object>'
# But what you really want is the qindex:
>>> snapjaw = qindex['Snapjaw']
>>> snapjaw.desc
'Tussocks of fur dress skin stretched over taut muscle. Upright =pronouns.subjective= =verb:stand:afterpronoun=, but =pronouns.subjective= =verb:look:afterpronoun= ready to drop onto fours. =pronouns.Possessive= snout snarls and =pronouns.possessive= ears twitch. =pronouns.Subjective= =verb:bark:afterpronoun=, and =pronouns.possessive= hyena tribesmen answer.'
>>> snapjaw.dv
6
>>> help(snapjaw)
# will give detailed help on all properties and methods, including a long list of properties that objects can have, like below:
...
| butcheredinto
| What a corpse item can be butchered into.
|
| canbuild
| Whether or not the player can tinker up this item.
|
| candisassemble
| Whether or not the player can disassemble this item.
|
| carrybonus
| The carry weight bonus.
# and so on.
# Tile support requires you to download the modding tile toolkit, described in the section above. But with it, you can do:
>>> youngivory = qindex['Young Ivory']
>>> youngivory.tile
<hagadias.qudtile.QudTile object at 0x0000018F898C3BA8>
>>> youngivory.tile.image
<PIL.PngImagePlugin.PngImageFile image mode=RGBA size=16x24 at 0x18F890B3320>
# for a PIL library format PNG image. There are other methods for retrieving BytesIO PNG binary data, see
>>> help(youngivory.tile)
# for details.
字符代码
gamecodes = root.get_character_codes()
# A dictionary containing some helpful information used to calculate the results of character builds.
# `gamecodes` contains the following items:
# 'class_bonuses': a dictionary mapping castes+callings to lists of stat bonuses
# 'class_skills': a dictionary mapping castes+callings to lists of skills (e.g. 'Horticulturalist': ['Meal Preparation', ...]
# 'class_tiles': a dictionary mapping castes+callings to tuples of (tile path, detail color) for that caste/calling's art
print(hagadias.character_codes.STAT_NAMES)
print(gamecodes["class_bonuses"]["Horticulturist"]) # 3-point Intelligence bonus
print(gamecodes["class_skills"]["Horticulturist"])
print(gamecodes["class_tiles"]["Horticulturist"])
('Strength', 'Agility', 'Toughness', 'Intelligence', 'Willpower', 'Ego')
[0, 0, 0, 3, 0, 0]
['Meal Preparation', 'Harvestry', '(Axe)', '(Bow and Rifle)', 'Wilderness Lore: Jungles']
('creatures/caste_1.bmp', 'g')
贡献
见CONTRIBUTING.md。
贡献者
感谢以下为本项目贡献代码的人:
- 自我加勒比
- 残骸站
- 图书管理员
- 海拉多德布朗尼
- 精灵
- 罗比布鲁姆
项目详情
下载文件
下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。
源分布
hagadias-1.1.2.tar.gz
(97.5 kB
查看哈希)
内置分布
hagadias-1.1.2-py3-none-any.whl
(102.7 kB
查看哈希)