diff --git a/data/nethack/logfile/electra.json b/data/nethack/logfile/electra.json index 8e320b7..82a917b 100644 --- a/data/nethack/logfile/electra.json +++ b/data/nethack/logfile/electra.json @@ -1,478 +1,8 @@ { - "generated": "2022-11-20T09:20:44.083781", + "generated": "2022-11-20T09:59:06.983143", "logfile": [ { - "score": 0, - "dungeon": { - "n": 0, - "name": "The Dungeons of Doom", - "level": { - "n": 1, - "descriptive": "Level 1" - } - }, - "end_date": "2022-04-05", - "start_date": "2022-04-05", - "character": { - "name": "Eryn", - "descriptor": "Eryn-Sam-Hum-Fem-Law", - "max_level": 1, - "hp": { - "n": 15, - "max": 15 - }, - "role": { - "short": "Sam", - "descriptive": "Samurai" - }, - "race": { - "short": "Hum", - "descriptive": "Human" - }, - "gender": { - "short": "Fem", - "descriptive": "Female" - }, - "alignment": { - "short": "Law", - "descriptive": "Lawful" - } - }, - "death": { - "n": 0, - "cause": "quit" - }, - "system": { - "hostname": "electra", - "user_id": 501, - "nethack_version": "3.6.6" - } - }, - { - "score": 1309, - "dungeon": { - "n": 0, - "name": "The Dungeons of Doom", - "level": { - "n": 7, - "descriptive": "Level 7" - } - }, - "end_date": "2022-04-05", - "start_date": "2022-04-05", - "character": { - "name": "Eryn", - "descriptor": "Eryn-Sam-Hum-Fem-Law", - "max_level": 7, - "hp": { - "n": 0, - "max": 46 - }, - "role": { - "short": "Sam", - "descriptive": "Samurai" - }, - "race": { - "short": "Hum", - "descriptive": "Human" - }, - "gender": { - "short": "Fem", - "descriptive": "Female" - }, - "alignment": { - "short": "Law", - "descriptive": "Lawful" - } - }, - "death": { - "n": 1, - "cause": "killed by a pony" - }, - "system": { - "hostname": "electra", - "user_id": 501, - "nethack_version": "3.6.6" - } - }, - { - "score": 148, - "dungeon": { - "n": 0, - "name": "The Dungeons of Doom", - "level": { - "n": 2, - "descriptive": "Level 2" - } - }, - "end_date": "2022-04-05", - "start_date": "2022-04-05", - "character": { - "name": "Eryn", - "descriptor": "Eryn-Mon-Hum-Fem-Neu", - "max_level": 2, - "hp": { - "n": 0, - "max": 20 - }, - "role": { - "short": "Mon", - "descriptive": "Monk" - }, - "race": { - "short": "Hum", - "descriptive": "Human" - }, - "gender": { - "short": "Fem", - "descriptive": "Female" - }, - "alignment": { - "short": "Neu", - "descriptive": "Neutral" - } - }, - "death": { - "n": 1, - "cause": "killed by a water moccasin" - }, - "system": { - "hostname": "electra", - "user_id": 501, - "nethack_version": "3.6.6" - } - }, - { - "score": 2, - "dungeon": { - "n": 0, - "name": "The Dungeons of Doom", - "level": { - "n": 1, - "descriptive": "Level 1" - } - }, - "end_date": "2022-04-05", - "start_date": "2022-04-05", - "character": { - "name": "Eryn", - "descriptor": "Eryn-Mon-Hum-Fem-Neu", - "max_level": 1, - "hp": { - "n": 8, - "max": 14 - }, - "role": { - "short": "Mon", - "descriptive": "Monk" - }, - "race": { - "short": "Hum", - "descriptive": "Human" - }, - "gender": { - "short": "Fem", - "descriptive": "Female" - }, - "alignment": { - "short": "Neu", - "descriptive": "Neutral" - } - }, - "death": { - "n": 0, - "cause": "quit" - }, - "system": { - "hostname": "electra", - "user_id": 501, - "nethack_version": "3.6.6" - } - }, - { - "score": 370, - "dungeon": { - "n": 0, - "name": "The Dungeons of Doom", - "level": { - "n": 4, - "descriptive": "Level 4" - } - }, - "end_date": "2022-04-07", - "start_date": "2022-04-05", - "character": { - "name": "Eryn", - "descriptor": "Eryn-Sam-Hum-Fem-Law", - "max_level": 4, - "hp": { - "n": 0, - "max": 28 - }, - "role": { - "short": "Sam", - "descriptive": "Samurai" - }, - "race": { - "short": "Hum", - "descriptive": "Human" - }, - "gender": { - "short": "Fem", - "descriptive": "Female" - }, - "alignment": { - "short": "Law", - "descriptive": "Lawful" - } - }, - "death": { - "n": 1, - "cause": "killed by a coyote, while fainted from lack of food" - }, - "system": { - "hostname": "electra", - "user_id": 501, - "nethack_version": "3.6.6" - } - }, - { - "score": 0, - "dungeon": { - "n": 0, - "name": "The Dungeons of Doom", - "level": { - "n": 1, - "descriptive": "Level 1" - } - }, - "end_date": "2022-04-09", - "start_date": "2022-04-09", - "character": { - "name": "Eryn", - "descriptor": "Eryn-Sam-Hum-Fem-Law", - "max_level": 1, - "hp": { - "n": 15, - "max": 15 - }, - "role": { - "short": "Sam", - "descriptive": "Samurai" - }, - "race": { - "short": "Hum", - "descriptive": "Human" - }, - "gender": { - "short": "Fem", - "descriptive": "Female" - }, - "alignment": { - "short": "Law", - "descriptive": "Lawful" - } - }, - "death": { - "n": 0, - "cause": "quit" - }, - "system": { - "hostname": "electra", - "user_id": 501, - "nethack_version": "3.6.6" - } - }, - { - "score": 737, - "dungeon": { - "n": 0, - "name": "The Dungeons of Doom", - "level": { - "n": 4, - "descriptive": "Level 4" - } - }, - "end_date": "2022-04-10", - "start_date": "2022-04-04", - "character": { - "name": "Eryn", - "descriptor": "Eryn-Rog-Hum-Fem-Cha", - "max_level": 4, - "hp": { - "n": 0, - "max": 31 - }, - "role": { - "short": "Rog", - "descriptive": "Rogue" - }, - "race": { - "short": "Hum", - "descriptive": "Human" - }, - "gender": { - "short": "Fem", - "descriptive": "Female" - }, - "alignment": { - "short": "Cha", - "descriptive": "Chaotic" - } - }, - "death": { - "n": 1, - "cause": "killed by a dwarf, while fainted from lack of food" - }, - "system": { - "hostname": "electra", - "user_id": 501, - "nethack_version": "3.6.6" - } - }, - { - "score": 1460, - "dungeon": { - "n": 0, - "name": "The Dungeons of Doom", - "level": { - "n": 6, - "descriptive": "Level 6" - } - }, - "end_date": "2022-04-18", - "start_date": "2022-04-12", - "character": { - "name": "Eryn", - "descriptor": "Eryn-Sam-Hum-Fem-Law", - "max_level": 6, - "hp": { - "n": 0, - "max": 58 - }, - "role": { - "short": "Sam", - "descriptive": "Samurai" - }, - "race": { - "short": "Hum", - "descriptive": "Human" - }, - "gender": { - "short": "Fem", - "descriptive": "Female" - }, - "alignment": { - "short": "Law", - "descriptive": "Lawful" - } - }, - "death": { - "n": 1, - "cause": "killed by a killer bee" - }, - "system": { - "hostname": "electra", - "user_id": 501, - "nethack_version": "3.6.6" - } - }, - { - "score": 1500, - "dungeon": { - "n": 2, - "name": "The Gnomish Mines", - "level": { - "n": 6, - "descriptive": "Level 6" - } - }, - "end_date": "2022-05-06", - "start_date": "2022-04-19", - "character": { - "name": "Eryn", - "descriptor": "Eryn-Sam-Hum-Fem-Law", - "max_level": 8, - "hp": { - "n": 0, - "max": 53 - }, - "role": { - "short": "Sam", - "descriptive": "Samurai" - }, - "race": { - "short": "Hum", - "descriptive": "Human" - }, - "gender": { - "short": "Fem", - "descriptive": "Female" - }, - "alignment": { - "short": "Law", - "descriptive": "Lawful" - } - }, - "death": { - "n": 1, - "cause": "killed by a dwarf" - }, - "system": { - "hostname": "electra", - "user_id": 501, - "nethack_version": "3.6.6" - } - }, - { - "score": 1136, - "dungeon": { - "n": 0, - "name": "The Dungeons of Doom", - "level": { - "n": 6, - "descriptive": "Level 6" - } - }, - "end_date": "2022-05-10", - "start_date": "2022-05-09", - "character": { - "name": "Eryn", - "descriptor": "Eryn-Sam-Hum-Fem-Law", - "max_level": 7, - "hp": { - "n": 0, - "max": 39 - }, - "role": { - "short": "Sam", - "descriptive": "Samurai" - }, - "race": { - "short": "Hum", - "descriptive": "Human" - }, - "gender": { - "short": "Fem", - "descriptive": "Female" - }, - "alignment": { - "short": "Law", - "descriptive": "Lawful" - } - }, - "death": { - "n": 1, - "cause": "killed by an invisible Uruk-hai" - }, - "system": { - "hostname": "electra", - "user_id": 501, - "nethack_version": "3.6.6" - } - }, - { - "score": 1413, + "score": 1395, "dungeon": { "n": 2, "name": "The Gnomish Mines", @@ -481,19 +11,19 @@ "descriptive": "Level 5" } }, - "end_date": "2022-05-25", - "start_date": "2022-05-15", + "end_date": "2022-11-19", + "start_date": "2022-11-18", "character": { "name": "Eryn", - "descriptor": "Eryn-Sam-Hum-Fem-Law", + "descriptor": "Eryn-Kni-Hum-Fem-Law", "max_level": 5, "hp": { "n": 0, - "max": 58 + "max": 45 }, "role": { - "short": "Sam", - "descriptive": "Samurai" + "short": "Kni", + "descriptive": "Knight" }, "race": { "short": "Hum", @@ -510,7 +40,101 @@ }, "death": { "n": 1, - "cause": "killed by a killer bee" + "cause": "killed by a black naga hatchling" + }, + "system": { + "hostname": "electra", + "user_id": 501, + "nethack_version": "3.6.6" + } + }, + { + "score": 0, + "dungeon": { + "n": 0, + "name": "The Dungeons of Doom", + "level": { + "n": 1, + "descriptive": "Level 1" + } + }, + "end_date": "2022-11-19", + "start_date": "2022-11-19", + "character": { + "name": "Eryn", + "descriptor": "Eryn-Arc-Hum-Fem-Neu", + "max_level": 1, + "hp": { + "n": 13, + "max": 13 + }, + "role": { + "short": "Arc", + "descriptive": "Archaeologist" + }, + "race": { + "short": "Hum", + "descriptive": "Human" + }, + "gender": { + "short": "Fem", + "descriptive": "Female" + }, + "alignment": { + "short": "Neu", + "descriptive": "Neutral" + } + }, + "death": { + "n": 0, + "cause": "quit" + }, + "system": { + "hostname": "electra", + "user_id": 501, + "nethack_version": "3.6.6" + } + }, + { + "score": 246, + "dungeon": { + "n": 0, + "name": "The Dungeons of Doom", + "level": { + "n": 3, + "descriptive": "Level 3" + } + }, + "end_date": "2022-11-19", + "start_date": "2022-11-19", + "character": { + "name": "Eryn", + "descriptor": "Eryn-Val-Hum-Fem-Law", + "max_level": 4, + "hp": { + "n": 0, + "max": 21 + }, + "role": { + "short": "Val", + "descriptive": "Valkyrie" + }, + "race": { + "short": "Hum", + "descriptive": "Human" + }, + "gender": { + "short": "Fem", + "descriptive": "Female" + }, + "alignment": { + "short": "Law", + "descriptive": "Lawful" + } + }, + "death": { + "n": 1, + "cause": "killed by a wand" }, "system": { "hostname": "electra", diff --git a/scripts/import-nethack-logfile.py b/scripts/import-nethack-logfile.py index 6591c7d..0b2e8e0 100755 --- a/scripts/import-nethack-logfile.py +++ b/scripts/import-nethack-logfile.py @@ -45,11 +45,14 @@ RACES = { } ROLES = { + 'Arc': 'Archaeologist', + 'Kni': 'Knight', 'Mon': 'Monk', 'Pri': 'Priest', 'Ran': 'Ranger', 'Rog': 'Rogue', 'Sam': 'Samurai', + 'Val': 'Valkyrie', } GENDERS = { @@ -64,7 +67,7 @@ ALIGNMENTS = { def parse_args(argv, *a, **kw): parser = argparse.ArgumentParser(*a, **kw) - parser.add_argument('-o', '--output',help='Path to the output file') + parser.add_argument('-o', '--output', help='Path to the output file') parser.add_argument('logfile', help='Path to the Nethack log file to convert') args = parser.parse_args(argv) return args @@ -133,15 +136,26 @@ def main(argv): 'logfile': records, } + logfile_has_changed = False output_path = args.output + output_file = None + if output_path and output_path != '-': - output_file = open(output_path, 'w') + with open(output_path, 'r') as existing_logfile: + existing_logfile_object = json.load(existing_logfile) + logfile_has_changed = existing_logfile_object.get('logfile', {}) != records + + if logfile_has_changed: + output_file = open(output_path, 'w') else: output_file = sys.stdout - json.dump(output_object, output_file, indent=2) - output_file.write('\n') - output_file.close() + if output_file: + json.dump(output_object, output_file, indent=2) + output_file.write('\n') + output_file.close() + else: + print('No changes to logfile') return 0