mirror of
https://github.com/Zenithsiz/dcb.git
synced 2026-02-03 08:12:26 +00:00
Added simple python script to unpack game.
This commit is contained in:
parent
4922c8ca15
commit
0a91758a7d
3
.gitignore
vendored
3
.gitignore
vendored
@ -8,6 +8,9 @@
|
||||
# Logs
|
||||
/latest.log
|
||||
|
||||
# Default output directory for unpack
|
||||
/game
|
||||
|
||||
# Resources
|
||||
/resources/*
|
||||
|
||||
|
||||
4
.style.yapf
Normal file
4
.style.yapf
Normal file
@ -0,0 +1,4 @@
|
||||
[style]
|
||||
based_on_style = yapf
|
||||
use_tabs = true
|
||||
column_limit = 120
|
||||
55
unpack.py
Normal file
55
unpack.py
Normal file
@ -0,0 +1,55 @@
|
||||
#!/bin/env python3
|
||||
|
||||
# Imports
|
||||
import sys
|
||||
import subprocess
|
||||
|
||||
|
||||
# Print usage
|
||||
def print_usage():
|
||||
print(f"Usage: {sys.argv[0]} <game-file> [output-dir]")
|
||||
|
||||
|
||||
# Retrieves the arguments
|
||||
def get_args():
|
||||
try:
|
||||
game_file = sys.argv[1]
|
||||
except:
|
||||
print_usage()
|
||||
exit(1)
|
||||
try:
|
||||
output_dir = sys.argv[2]
|
||||
except:
|
||||
output_dir = "./game"
|
||||
|
||||
return (game_file, output_dir)
|
||||
|
||||
|
||||
# Extracts the card table
|
||||
def extract_card_table(game_file, output_file):
|
||||
with open(output_file, 'w') as f:
|
||||
args = ["cargo", "run", "--bin", "dcb-extract-card-table", "--", game_file]
|
||||
proc = subprocess.Popen(args, stdout=f)
|
||||
if proc.wait() != 0:
|
||||
print("Failed to extract card table")
|
||||
exit(1)
|
||||
|
||||
|
||||
# Main
|
||||
def main():
|
||||
# Get arguments
|
||||
(game_file, output_dir) = get_args()
|
||||
|
||||
# If the game file isn't a `.bin`, exit
|
||||
if not game_file.lower().endswith('.bin'):
|
||||
print("The game file must bea `.bin` file")
|
||||
exit(1)
|
||||
|
||||
# Extract the card and deck table
|
||||
extract_card_table(game_file, f"{output_dir}/card_table.json")
|
||||
|
||||
print(game_file, output_dir)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Loading…
x
Reference in New Issue
Block a user