Skip to content

Commit 5d1dff5

Browse files
authored
Merge pull request #228 from lxgr-linux/lint
Lint
2 parents 9ccb292 + 8d84bce commit 5d1dff5

26 files changed

+260
-197
lines changed

pokete.py

Lines changed: 56 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,12 @@ class NPCActions:
6969
npc: The NPC the method belongs to"""
7070

7171
@staticmethod
72-
def swap_poke(npc):
72+
def swap_poke(_):
7373
"""Swap_poke wrapper"""
7474
swap_poke()
7575

7676
@staticmethod
77-
def heal(npc):
77+
def heal(_):
7878
"""Heal wrapper"""
7979
figure.heal()
8080

@@ -275,8 +275,10 @@ def action(self, ob):
275275
elif action.triggers(Action.ACT_2):
276276
figure.heal()
277277
time.sleep(SPEED_OF_TIME * 0.5)
278-
mvp.movemap.text(int(mvp.movemap.width / 2), 3,
279-
["...", "Your Poketes are now healed!"])
278+
mvp.movemap.text(
279+
int(mvp.movemap.width / 2), 3,
280+
["...", "Your Poketes are now healed!"]
281+
)
280282
break
281283
elif action.triggers(Action.CANCEL, Action.ACT_3):
282284
break
@@ -550,7 +552,7 @@ def __call__(self):
550552
ask_ok(self.map,
551553
f"{poke.name} reached level "
552554
f"{poke.lvl()}!")
553-
elif type(obj) is LearnDisc:
555+
elif isinstance(obj, LearnDisc):
554556
if ask_bool(self.map, f"Do you want to teach '\
555557
{obj.attack_dict['name']}'?"):
556558
ex_cond = True
@@ -566,10 +568,13 @@ def __call__(self):
566568
obj.attack_dict['types'][0])\
567569
in poke.types:
568570
break
569-
else:
570-
ex_cond = ask_bool(self.map,
571-
f"You cant't \
572-
teach '{obj.attack_dict['name']}' to '{poke.name}'! \nDo you want to continue?")
571+
ex_cond = ask_bool(
572+
self.map,
573+
"You cant't teach "
574+
f"'{obj.attack_dict['name']}' to "
575+
f"'{poke.name}'! \n"
576+
"Do you want to continue?"
577+
)
573578
if not ex_cond:
574579
break
575580
if LearnAttack(poke, self.map)\
@@ -697,7 +702,7 @@ def __call__(self, pevm):
697702
time.sleep(SPEED_OF_TIME * 1.5)
698703
elif i == self.exit_label:
699704
save()
700-
exit()
705+
sys.exit()
701706
elif i == self.about_label:
702707
about()
703708
elif i == self.ach_label:
@@ -818,7 +823,6 @@ def exiter():
818823
print("\033[?1049l\033[1A")
819824
if audio.curr is not None:
820825
audio.kill()
821-
#sys.exit()
822826

823827

824828
# Functions needed for mvp.movemap
@@ -839,7 +843,7 @@ def codes(string):
839843
print(exc)
840844
return
841845
elif i == "q":
842-
exit()
846+
sys.exit()
843847

844848

845849
# Playmap extra action functions
@@ -895,13 +899,14 @@ def teleport(poke):
895899
poke: The Poke shown in the animation"""
896900
if (obj := roadmap(mvp.movemap, choose=True)) is None:
897901
return
898-
else:
899-
if settings("animations").val:
900-
animations.transition(mvp.movemap, poke)
901-
cen_d = p_data.map_data[obj.name]["hard_obs"]["pokecenter"]
902-
Door("", state="float", arg_proto={"map": obj.name,
903-
"x": cen_d["x"] + 5,
904-
"y": cen_d["y"] + 6}).action(figure)
902+
if settings("animations").val:
903+
animations.transition(mvp.movemap, poke)
904+
cen_d = p_data.map_data[obj.name]["hard_obs"]["pokecenter"]
905+
Door("", state="float", arg_proto={
906+
"map": obj.name,
907+
"x": cen_d["x"] + 5,
908+
"y": cen_d["y"] + 6
909+
}).action(figure)
905910

906911

907912
def swap_poke():
@@ -1008,21 +1013,24 @@ def _game(_map):
10081013
# Directions are not being used yet
10091014
action = get_action()
10101015
if action.triggers(*ACTION_DIRECTIONS):
1011-
figure.direction = '' #TODO
1012-
figure.set(figure.x + action.get_X_strength(), figure.y + action.get_Y_strength())
1016+
figure.direction = ''
1017+
figure.set(
1018+
figure.x + action.get_x_strength(),
1019+
figure.y + action.get_y_strength()
1020+
)
10131021
elif action.triggers(*inp_dict):
10141022
audio_before = settings("audio").val
1015-
for key in inp_dict:
1023+
for key, option in inp_dict.items():
10161024
if action.triggers(key):
1017-
inp_dict[key][0](*inp_dict[key][1])
1025+
option[0](*option[1])
10181026
_ev.clear()
10191027
if audio_before != settings("audio").val:
10201028
audio.switch(_map.song)
10211029
mvp.movemap.show(init=True)
10221030
elif action.triggers(Action.CANCEL, Action.EXIT_GAME):
10231031
if ask_bool(mvp.movemap, "Do you really wish to exit?"):
10241032
save()
1025-
exit()
1033+
sys.exit()
10261034
elif action.triggers(Action.CONSOLE):
10271035
inp = text_input(mvp.movemap.code_label, mvp.movemap, ":",
10281036
mvp.movemap.width,
@@ -1092,48 +1100,47 @@ def gen_obs():
10921100
trainers = p_data.trainers
10931101

10941102
# adding all trainer to map
1095-
for i in trainers:
1103+
for i, trainer_list in trainers.items():
10961104
_map = obmp.ob_maps[i]
1097-
for j in trainers[i]:
1105+
for j in trainer_list:
10981106
args = j["args"]
10991107
trainer = Trainer([Poke(*p, player=False) for p in j["pokes"]], *args[:-2])
11001108
trainer.add(_map, args[-2], args[-1])
11011109
_map.trainers.append(trainer)
11021110

11031111
# generating objects from map_data
1104-
for ob_map in map_data:
1112+
for ob_map, single_map in map_data.items():
11051113
_map = obmp.ob_maps[ob_map]
1106-
for hard_ob in map_data[ob_map]["hard_obs"]:
1114+
for hard_ob, single_hard_ob in single_map["hard_obs"].items():
11071115
parse_obj(_map, hard_ob,
1108-
se.Text(map_data[ob_map]["hard_obs"][hard_ob]["txt"],
1116+
se.Text(single_hard_ob["txt"],
11091117
ignore=" "),
1110-
map_data[ob_map]["hard_obs"][hard_ob])
1111-
for soft_ob in map_data[ob_map]["soft_obs"]:
1118+
single_hard_ob)
1119+
for soft_ob, single_soft_ob in single_map["soft_obs"].items():
11121120
cls = {
11131121
"sand": Sand,
11141122
"meadow": Meadow,
11151123
"water": Water,
1116-
}[map_data[ob_map]["soft_obs"][soft_ob].get("cls", "meadow")]
1124+
}[single_soft_ob.get("cls", "meadow")]
11171125
parse_obj(_map, soft_ob,
1118-
cls(map_data[ob_map]["soft_obs"][soft_ob]["txt"],
1126+
cls(single_soft_ob["txt"],
11191127
_map.poke_args
11201128
if cls != Water else _map.w_poke_args),
1121-
map_data[ob_map]["soft_obs"][soft_ob])
1122-
for door in map_data[ob_map]["dors"]:
1129+
single_soft_ob)
1130+
for door, single_door in single_map["dors"].items():
11231131
parse_obj(_map, door,
11241132
Door(" ", state="float",
1125-
arg_proto=map_data[ob_map]["dors"][door]["args"]),
1126-
map_data[ob_map]["dors"][door])
1127-
for ball in map_data[ob_map]["balls"]:
1133+
arg_proto=single_door["args"]),
1134+
single_door)
1135+
for ball, single_ball in single_map["balls"].items():
11281136
if f'{ob_map}.{ball}' not in figure.used_npcs or not \
11291137
settings("save_trainers").val:
11301138
parse_obj(_map, ball,
11311139
Poketeball(f"{ob_map}.{ball}"),
1132-
map_data[ob_map]["balls"][ball])
1140+
single_ball)
11331141
# NPCs
1134-
for npc in npcs:
1135-
_npc = npcs[npc]
1136-
NPC(npc, _npc["texts"], fn=_npc["fn"],
1142+
for npc, _npc in npcs.items():
1143+
NPC(npc, _npc["texts"], _fn=_npc["fn"],
11371144
chat=_npc.get("chat", None)).add(obmp.ob_maps[_npc["map"]],
11381145
_npc["x"], _npc["y"])
11391146

@@ -1143,8 +1150,7 @@ def gen_maps():
11431150
RETURNS:
11441151
Dict of all PlayMaps"""
11451152
maps = {}
1146-
for ob_map in p_data.maps:
1147-
args = p_data.maps[ob_map]
1153+
for ob_map, args in p_data.maps.items():
11481154
args["extra_actions"] = (getattr(ExtraActions, args["extra_actions"],
11491155
None)
11501156
if args["extra_actions"] is not None
@@ -1159,15 +1165,14 @@ def check_version(sinfo):
11591165
sinfo: session_info dict"""
11601166
if "ver" not in sinfo:
11611167
return False
1162-
else:
1163-
ver = sinfo["ver"]
1168+
ver = sinfo["ver"]
11641169
if VERSION != ver and sort_vers([VERSION, ver])[-1] == ver:
11651170
if not ask_bool(loading_screen.map,
11661171
liner(f"The save file was created \
11671172
on version '{ver}', the current version is '{VERSION}', \
11681173
such a downgrade may result in data loss! \
11691174
Do you want to continue?", int(width * 2 / 3))):
1170-
exit()
1175+
sys.exit()
11711176
return VERSION != ver
11721177

11731178

@@ -1467,8 +1472,8 @@ def recogniser():
14671472
if settings("load_mods").val:
14681473
try:
14691474
import mods
1470-
except ModError as err:
1471-
error_box = InfoBox(str(err), "Mod-loading Error")
1475+
except ModError as mod_err:
1476+
error_box = InfoBox(str(mod_err), "Mod-loading Error")
14721477
error_box.center_add(loading_screen.map)
14731478
loading_screen.map.show()
14741479
sys.exit(1)
@@ -1533,8 +1538,8 @@ def recogniser():
15331538

15341539
# Achievements
15351540
achievements.set_achieved(session_info.get("achievements", []))
1536-
for identifier, args in p_data.achievements.items():
1537-
achievements.add(identifier, **args)
1541+
for identifier, achievement_args in p_data.achievements.items():
1542+
achievements.add(identifier, **achievement_args)
15381543

15391544
# objects relevant for fm.fight()
15401545
fm.fightmap = fm.FightMap(height - 1, width)

pokete_classes/achievements.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def __call__(self, _map):
109109
else:
110110
if action.triggers(Action.CANCEL):
111111
break
112-
elif action.triggers(Action.ACCEPT):
112+
if action.triggers(Action.ACCEPT):
113113
ach = achievements.achievements[
114114
self.get_item(*self.index).ind
115115
]

pokete_classes/attack.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
import time
44
import scrap_engine as se
55
from pokete_data.attacks import attacks
6+
from release import SPEED_OF_TIME
67
from .effects import effects
78
from .types import types
89
from .color import Color
9-
from release import SPEED_OF_TIME
1010

1111

1212
class Attack:
@@ -59,12 +59,12 @@ def give_effect(self, enem):
5959
time.sleep(SPEED_OF_TIME * 1.5)
6060
getattr(effects, self.effect)().add(enem)
6161

62-
def set_ap(self, ap):
62+
def set_ap(self, _ap):
6363
"""Sets attack points
6464
ARGS:
6565
ap: Attack points"""
66-
if ap != "SKIP":
67-
self.ap = min(ap, self.max_ap)
66+
if _ap != "SKIP":
67+
self.ap = min(_ap, self.max_ap)
6868
self.label.rechar("")
6969
self.label += self.make_label()
7070

pokete_classes/attack_actions.py

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,55 +10,70 @@ class AttackActions:
1010
pattern:
1111
ARGS:
1212
obj: The Poke object that attacks
13-
enem: The Poke object that is attacked"""
13+
enem: The Poke object that is attacked
14+
providers: List of the current providers"""
1415

15-
def cry(self, obj, enem, _):
16+
def cry(self, _, enem, __):
17+
"""Cry attack action"""
1618
enem.miss_chance += 1
1719

18-
def eye_pick(self, obj, enem, _):
20+
def eye_pick(self, _, enem, __):
21+
"""Eye pick attack action"""
1922
enem.miss_chance += 2
2023

21-
def chocer(self, obj, enem, _):
24+
def chocer(self, _, enem, __):
25+
"""Chocer attack action"""
2226
enem.atc -= 1
2327

24-
def snooze(self, obj, enem, _):
28+
def snooze(self, _, enem, __):
29+
"""Snooze attack action"""
2530
enem.miss_chance += 0.5
2631
enem.atc -= 1
2732
enem.defense -= 1
2833

29-
def politure(self, obj, enem, _):
34+
def politure(self, obj, _, __):
35+
"""Politure attack action"""
3036
obj.defense += 1
3137
obj.atc += 1
3238

33-
def bark_hardening(self, obj, enem, _):
39+
def bark_hardening(self, obj, _, __):
40+
"""Bark hardening attack action"""
3441
obj.defense += 1
3542

36-
def dick_energy(self, obj, enem, _):
43+
def dick_energy(self, obj, _, __):
44+
"""Dick energy attack action"""
3745
obj.atc += 2
3846

39-
def hiding(self, obj, enem, _):
47+
def hiding(self, obj, _, __):
48+
"""Hiding attack action"""
4049
obj.defense += 2
4150

42-
def brooding(self, obj, enem, _):
51+
def brooding(self, obj, _, __):
52+
"""Brooding attack action"""
4353
obj.hp += 2 if obj.hp + 2 <= obj.full_hp else 0
4454

45-
def heart_touch(self, obj, enem, _):
55+
def heart_touch(self, _, enem, __):
56+
"""Heart touch attack action"""
4657
enem.defense -= 4
4758

4859
def super_sucker(self, obj, enem, _):
60+
"""Super sucker attack action"""
4961
enem.hp -= 2
5062
obj.hp += 2 if obj.hp+2 <= obj.full_hp else 0
5163

52-
def sucker(self, obj, enem, _):
64+
def sucker(self, obj, enem, __):
65+
"""Sucker attack action"""
5366
enem.hp -= 1
5467
obj.hp += 1 if obj.hp+1 <= obj.full_hp else 0
5568

56-
def rain_dance(self, obj, enem, providers):
69+
def rain_dance(self, obj, _, providers):
70+
"""Rain dance attack action"""
5771
providers[0].map.weather = Weather("rain")
5872
obj.ico.map.outp.outp("It started raining!")
5973
time.sleep(2)
6074

6175
def encouragement(self, obj, _, providers):
76+
"""Encouragement attack action"""
6277
for poke in next(
6378
prov for prov in providers if prov.curr == obj
6479
).pokes[:6]:

pokete_classes/audio.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
def audio_fn(song, play_audio):
1212
"""plays a song in loop"""
1313
import playsound
14+
15+
1416
while play_audio:
1517
playsound.playsound(str(MUSIC_PATH / song))
1618

@@ -43,4 +45,3 @@ def kill(self):
4345
self.curr.terminate()
4446

4547
audio = Audio()
46-

0 commit comments

Comments
 (0)