diff --git a/research2.tsv b/research2.tsv index 891f5aa..dcab711 100644 --- a/research2.tsv +++ b/research2.tsv @@ -5,25 +5,25 @@ 2539 Botany 2559 Medical Bed 2563 Arcade Machine -2564 Unknown +2564 Jukebox 2565 Solar Panel 2566 X2 Power Generator -2567 Unknown +2567 X3 Power Generator 2568 Power Capacity Node 2569 Item Fabricator -2570 Unknown +2570 Microweaver 2571 Assembler -2572 Unknown -2573 Unknown -2575 Unknown -2576 Unknown -2577 Unknown +2572 Energy Refinery +2573 Chemical Refinery +2575 Advanced Assember +2576 Composter +2577 Hypersleep Chamber 2589 Weapons Console 2590 Shields Console -2591 Unknown -2592 Unknown +2591 Rocket Turret +2592 Energy Turret 2594 X1 Power Generator -2595 Unknown +2595 X1 Hyperdrive 2596 Unknown 2597 Unknown 2598 Unknown @@ -32,24 +32,24 @@ 2601 Targeting Jammer 2602 Unknown 2604 Unknown -2605 Unknown -2606 Unknown +2605 Logistics Robot Station +2606 Plasma Weapons 2607 Unknown 2612 Metal Refinery 2613 Unknown 2614 Unknown 2617 Unknown -2619 Unknown -2622 Unknown -2623 Unknown -2626 Unknown -2628 Unknown +2619 Fibres +2622 Bulletproof Vest +2623 Autopsy Table +2626 Advanced Nutrition +2628 Artificial Meat 2629 Alcoholic Bar Machine -2630 Unknown +2630 Grains and Hops 2694 Optotronics Fabricator 2847 Unknown -3024 Unknown -3025 Unknown +3024 Laser Weapons +3025 Salvage Robot Station 3114 Unknown 3115 Research Workbench 3116 Unknown @@ -57,16 +57,16 @@ 3122 Operations Console 3124 Unknown 3125 Unknown -3127 Unknown +3127 Robotics 01 3128 Industry 01 3129 Industry 02 -3130 Unknown -3417 Unknown +3130 Botany 02 +3417 Armored Vest 3420 Unknown 3421 Unknown 3422 Unknown 3423 Unknown -3464 Unknown +3464 Sentry Gun X1 3704 Unknown 3705 Unknown 3706 Unknown diff --git a/sheditor.py b/sheditor.py index e28d9f4..d2d4fa9 100644 --- a/sheditor.py +++ b/sheditor.py @@ -78,12 +78,13 @@ class ResearchItem: def get_name_from_code(cls, code): return cls.research_ids.get(code, None) if cls.research_ids is not None else None - def __init__(self, id, active_stage, paused, states): + def __init__(self, id, active_stage, paused, states, tag): self.id = id self.name = ResearchItem.get_name_from_code(id) self.paused = paused self.active_stage = active_stage self.stage_states = states + self.tag = tag def __str__(self): return "{} : {} : {}".format(self.id, self.name, self.active_stage) @@ -112,6 +113,9 @@ class StorageArea: def add_item(self, item): self.items.append(item) + def get_capacity(self): + return storage_ids[self.type_id]['capacity'] + # Returns how full the storage area is based on its contents def get_total_occupancy(self): total_quantity = 0 @@ -279,6 +283,53 @@ class Ship: console.print("Total used: {}".format(total)) console.print("Total actual capacity: {}".format(area_capacity)) + # Consolidate items + console.print("Consolidating items for {}".format(self.name)) + unique_codes = [] + new_items = [] + for area in normal_storage_areas: + console.print("----- New storage area") + for item in area.items: + if item.code not in unique_codes: + unique_codes.append(item.code) + console.print("Considering item with code {}".format(item.code)) + old_item_found = False + for new_item in new_items: + if new_item.code == item.code: + new_item.quantity += item.quantity + old_item_found = True + # console.print("Adding new item with code {}".format(item.code)) + if old_item_found is False: + new_items.append(item) + console.print("Total number of new items: {}".format(len(new_items))) + console.print("Total number of unique codes: {}".format(len(unique_codes))) + + + new_amount = 0 + for item in new_items: + new_amount += item.quantity + console.print(new_amount) + + for area in normal_storage_areas: + area.items = [] + + for item in new_items: + console.print("{} : {} : {}".format(item.code, item.name, item.quantity)) + min_occupancy = 2000 + min_area = None + for area in normal_storage_areas: + if area.get_total_occupancy() < min_occupancy: + min_area = area + min_area.items.append(item) + + item_number = 0 + for area in normal_storage_areas: + for item in area.items: + item_number += 1 + console.print("{} : {} : {}".format(item.code, item.name, item.quantity)) + console.print("Item number: {}".format(item_number)) + + def consolidate_weapons(self): normal_storage_areas = [sa for sa in self.storage_areas if sa.is_normal_storage] for area in normal_storage_areas: @@ -403,7 +454,7 @@ class GameData: blocksdone = [int(blocksdone_tag['level1']), int(blocksdone_tag['level2']), int(blocksdone_tag['level3'])] ris = ResearchItemState(done, stage_no, blocksdone) stages.append(ris) - ri = ResearchItem(techId, active_stage, paused, stages) + ri = ResearchItem(techId, active_stage, paused, stages, item) self.research.append(ri) """ @@ -579,9 +630,9 @@ class GameData: def redistribute(self): for ship in self.ships: - if ship.owner != 'Player': + if ship.owner != 'Player' or ship.state != 'Normal': continue - console.print(ship.name) + console.print(ship.name, ship.state) ship.redistribute_storage() def list_research(self): @@ -735,17 +786,17 @@ def main(): if edits_made: if args.replace_original: console.print('Renaming original file') + filename = os.path.join(DEFAULT_SAVEGAMEPATH, args.filename, "save", "game") datetime_suffix = datetime.datetime.now().strftime('%Y-%m-%d-%H%M_%S_%f') - new_filename = args.filename + "-" + datetime_suffix + new_filename = os.path.join(DEFAULT_SAVEGAMEPATH, args.filename, "save", "game" + '-' + datetime_suffix) # console.print(datetime_suffix) - # os.rename(args.filename, new_filename) + os.rename(filename, new_filename) console.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:]) - filename = os.path.join(DEFAULT_SAVEGAMEPATH, args.filename, "save", "game") f = open(filename, 'w') f.write(sansfirstline) diff --git a/weapons_list.txt b/weapons_list.txt new file mode 100644 index 0000000..bf965ae --- /dev/null +++ b/weapons_list.txt @@ -0,0 +1,10 @@ +725 # Assault Rifle +728 # SMG +729 # Shotgun +760 # Five-Seven Pistol +3069 # Laser Rifle +3070 # Laser Pistol +3071 # Plasma Clustergun +3072 # Plasma Rifle +3383 # Bulletproof Vest +3384 # Armored Vest \ No newline at end of file