-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsummary.py
More file actions
77 lines (57 loc) · 2.47 KB
/
summary.py
File metadata and controls
77 lines (57 loc) · 2.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
"""This file contains Summary class, which contains a read-in summary.txt.
Imports From:
typing
autogenerated_vessel_list.py
Classes:
Summary
"""
from typing import Optional
from autogenerated_vessel_list import AutogeneratedVesselList
class Summary:
"""This class stores the data for the summary.txt file.
Attributes:
autogenerate_player_vessel_list: AutogeneratedVesselList
player_vessel_list: list[str]
Methods:
None
"""
def __init__(self, campaign_directory: str) -> None:
self.rpg_mode = False
self.prestige_mode = False
if self.prestige_mode:
self.prestige_values: dict[str, tuple[int, int]]
try:
with open(
f"{campaign_directory}\\summary.txt", mode="r", encoding="utf-8"
) as summary_file:
reading_prestige = False
self.rpg_mode = False
self.prestige_values = {}
for line in summary_file:
if reading_prestige:
self.prestige_values[line.strip().split("=")[0]] = (
int(line.strip().split("=")[1]),
int(line.strip().split("=")[2]),
)
continue
if line.startswith("Loadout"):
self.loadout = int(line.strip().split("=")[1])
if line.startswith("AutogeneratePlayerVesselList"):
self.autogenerate_player_vessel_list: Optional[
AutogeneratedVesselList
] = AutogeneratedVesselList(line.strip().split("=")[1])
self.player_vessels = []
if line.startswith("PlayerVessels"):
self.player_vessels = line.strip().split("=")[1].split(",")
self.autogenerate_player_vessel_list = None
if line.startswith("RPGMode"):
self.rpg_mode = bool(line.strip().split("=")[1].capitalize())
if line.startswith("PrestigeMode"):
self.prestige_mode = bool(
line.strip().split("=")[1].lower().capitalize()
)
if line.startswith("[Prestige Cost]"):
reading_prestige = True
self.parsed = True
except FileNotFoundError:
self.parsed = False