-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathload_creature.py
52 lines (38 loc) · 1.42 KB
/
load_creature.py
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
from configparser import ConfigParser
from dataclasses import dataclass, field
from enum import IntEnum
from typing import List, Optional
from lib.intervals import Float, I
from utils import possible_inputs_from_rounded
class Status(IntEnum):
Wild = 1
Tamed = 2
Bred = 3
@dataclass(init=False)
class CreatureInput:
name: str
species_bp: str
status: Status
level: int
imprint: I
stats: List[I]
wild_levels: Optional[List[int]] = None
dom_levels: Optional[List[int]] = None
def load_export_init(filename: str):
parser = ConfigParser(inline_comment_prefixes='#;')
parser.optionxform = lambda v: v # keep exact case of mod names, please
parser.read(filename)
creature = CreatureInput()
creature.name = parser['Dino Data']['DinoNameTag']
creature.species_bp = parser['Dino Data']['DinoClass']
creature.status = Status.Tamed
if parser['Dino Data'].get('ImprinterName', '').strip():
creature.status = Status.Bred
if parser['Dino Data']['BabyAge'] != '1.000000':
raise ValueError("Not fully grown")
creature.level = int(parser['Dino Data']['CharacterLevel'])
creature.imprint = I(parser['Dino Data']['DinoImprintingQuality'])
creature.stats = [
possible_inputs_from_rounded(Float(txt), digits=6) for txt in parser['Max Character Status Values'].values()
]
return creature