forked from Turonk/character_creation_module
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemp.py
More file actions
42 lines (32 loc) · 1.16 KB
/
Copy pathtemp.py
File metadata and controls
42 lines (32 loc) · 1.16 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
# Тестовые данные.
TEST_DATA: list[tuple[int, str, bool]] = [
(44, 'success', True),
(16, 'failure', True),
(4, 'success', False),
(21, 'failure', False),
]
BONUS: float = 1.1
ANTIBONUS: float = 0.8
def add_rep(current_rep: float, rep_points: int, buf_effect: bool) -> float:
current_rep += rep_points
if buf_effect:
return current_rep * BONUS
return current_rep
def remove_rep(current_rep: float,
rep_points: int,
debuf_effect: bool) -> float:
current_rep -= rep_points
if debuf_effect:
return current_rep * ANTIBONUS
return current_rep
def main(duel_res: list[tuple[int, str, bool]]) -> str:
current_rep: float = 0.0
for rep, result, effect in duel_res:
if result == 'success':
current_rep = add_rep(current_rep, rep, effect)
if result == 'failure':
current_rep = remove_rep(current_rep, rep, effect)
return (f'После {len(duel_res)} поединков, '
f'репутация персонажа — {current_rep:.3f} очков.')
# Тестовый вызов функции main.
print(main(TEST_DATA))