Added item sets and replacing original file.
This commit is contained in:
parent
5655685a0b
commit
f6611a724a
File diff suppressed because it is too large
Load Diff
|
@ -657,3 +657,4 @@
|
|||
3044 floor
|
||||
3366 Mild Alcohol
|
||||
3378 Grains and Hops
|
||||
3419 Augmentation Parts
|
|
@ -0,0 +1,7 @@
|
|||
# Block restock pack
|
||||
1759 50 # Hull blocks
|
||||
162 50 # Infrablocks
|
||||
930 40 # Techblocks
|
||||
1919 40 # Energy block
|
||||
1921 40 # Soft blocks
|
||||
1922 20 # Steel plates
|
|
@ -0,0 +1,7 @@
|
|||
# Basic food pack
|
||||
15 20 # Root vegetables
|
||||
706 20 # Fruits
|
||||
707 20 # Artificial meats
|
||||
712 30 # Space food
|
||||
2657 20 # Nuts and seeds
|
||||
71 20 # Biomatter
|
|
@ -0,0 +1,6 @@
|
|||
# Basic trade pack
|
||||
1925 20 # Quantronics components
|
||||
1924 20 # Optronics components
|
||||
173 20 # Electronic components
|
||||
3378 20 # Grains and hops
|
||||
1920 20 # Superblocks
|
84
sheditor.py
84
sheditor.py
|
@ -1,4 +1,4 @@
|
|||
import sys, argparse, copy
|
||||
import sys, argparse, copy, os, datetime
|
||||
from bs4 import BeautifulSoup
|
||||
|
||||
char_skills = {
|
||||
|
@ -214,7 +214,12 @@ class GameData:
|
|||
ship_tags = self.soup.find_all('ship')
|
||||
|
||||
for ship_tag in ship_tags:
|
||||
# Something strange is happening here
|
||||
# In some unexplored ships/derelicts (?fog="true" in the tag) the name appears in the game but NOWHERE in the file
|
||||
ship_name = "UNNAMED (?fogged)"
|
||||
if ship_tag.has_attr('sname'):
|
||||
ship_name = ship_tag['sname']
|
||||
# print(ship_name)
|
||||
|
||||
owner_node = ship_tag.find('settings', owner=True)
|
||||
ship_owner = owner_node['owner']
|
||||
|
@ -531,6 +536,21 @@ def list_ships(soup):
|
|||
|
||||
# print(settings_node)
|
||||
|
||||
def parse_item_file(filename):
|
||||
|
||||
results = []
|
||||
|
||||
for line in open(filename):
|
||||
line = line.strip()
|
||||
if line[0] == '#':
|
||||
continue
|
||||
components = line.split()
|
||||
item_code = int(components[0])
|
||||
item_quantity = int(components[1])
|
||||
results.append((item_code, item_quantity))
|
||||
|
||||
return results
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(prog="Space Haven Saved Game Inspector", description="As above.")
|
||||
|
@ -542,6 +562,10 @@ def main():
|
|||
parser.add_argument('--list_ships', required=False, action='store_true', help="List all ships with names and their respective owners")
|
||||
parser.add_argument('--test_gamedata', required=False, action='store_true', help="Test of new class-based system of storing game information")
|
||||
parser.add_argument('--clone_character', required=False, type=str, nargs=2, help="Clones a character of one name into another")
|
||||
parser.add_argument('--add_item_set', required=False, type=str, nargs=1, help="Takes a file containing a list of item codes and quantities (whitespace separated) and adds all of these to player storage")
|
||||
parser.add_argument('--detailed_items', required=False, action='store_true', help='Print a detailed item listing from player inventory')
|
||||
parser.add_argument('--detailed_chars', required=False, action='store_true', help='Print a comprehensive listing of player character details')
|
||||
parser.add_argument('--replace_original', required=False, action='store_true', help='Replace original file instead of creating edited alternative. Renames original for backup, but USE WITH CAUTION')
|
||||
|
||||
args = parser.parse_args()
|
||||
# print(args)
|
||||
|
@ -582,29 +606,22 @@ def main():
|
|||
if args.clone_character:
|
||||
game_data.clone_character(args.clone_character[0], args.clone_character[1])
|
||||
|
||||
if args.add_item_set:
|
||||
item_list = parse_item_file(args.add_item_set[0])
|
||||
# print(item_list)
|
||||
print ("Items to be added:")
|
||||
for (item_code, item_quantity) in item_list:
|
||||
print("{} : {}".format(item_code_database.get_name_from_code(item_code), item_quantity))
|
||||
game_data.add_item(item_code, item_quantity)
|
||||
|
||||
if args.detailed_items:
|
||||
game_data.print_detailed_item_summary()
|
||||
|
||||
if args.detailed_chars:
|
||||
game_data.print_detailed_character_summary()
|
||||
|
||||
game_data.writeback()
|
||||
|
||||
"""
|
||||
# print(soup.prettify())
|
||||
if args.buff_chars:
|
||||
print('Buffing all characters...')
|
||||
characters(soup)
|
||||
|
||||
if args.add_item:
|
||||
print('Adding items and listing storage contents...')
|
||||
add_code = args.add_item[0]
|
||||
add_quantity = args.add_item[1]
|
||||
inventory(soup, add_code, add_quantity)
|
||||
|
||||
if args.money:
|
||||
# print(args.money[0])
|
||||
print('Increasing money to the given amount...')
|
||||
give_money(soup, args.money[0])
|
||||
|
||||
if args.list_ships:
|
||||
list_ships(soup)
|
||||
|
||||
"""
|
||||
if args.test_gamedata:
|
||||
item_code_database = ItemCodeDatabase('item_ids.txt')
|
||||
print("Item code database successfully loaded")
|
||||
|
@ -615,11 +632,28 @@ def main():
|
|||
# game_data.buff_characters()
|
||||
# game_data.add_currency(10000)
|
||||
game_data.print_summary()
|
||||
# game_data.print_detailed_item_summary()
|
||||
game_data.clone_character("Byron", "Anthony")
|
||||
game_data.print_detailed_character_summary()
|
||||
game_data.print_detailed_item_summary()
|
||||
# game_data.clone_character("Byron", "Anthony")
|
||||
# game_data.print_detailed_character_summary()
|
||||
game_data.writeback()
|
||||
|
||||
if args.replace_original:
|
||||
print('Renaming original file')
|
||||
datetime_suffix = datetime.datetime.now().strftime('%Y-%m-%d-%H%M_%S_%f')
|
||||
new_filename = args.filename + "-" + datetime_suffix
|
||||
# print(datetime_suffix)
|
||||
os.rename(args.filename, new_filename)
|
||||
|
||||
print('Now rewriting game file with new information')
|
||||
text = soup.prettify()
|
||||
# Delete XML header - game doesn't have it
|
||||
sansfirstline = '\n'.join(text.split('\n')[1:])
|
||||
|
||||
f = open(args.filename, 'w')
|
||||
f.write(sansfirstline)
|
||||
f.close()
|
||||
print('Complete.')
|
||||
else:
|
||||
text = soup.prettify()
|
||||
# Delete XML header - game doesn't have it
|
||||
sansfirstline = '\n'.join(text.split('\n')[1:])
|
||||
|
|
Loading…
Reference in New Issue