Skip to content

Commit

Permalink
Merge pull request #228 from lxgr-linux/lint
Browse files Browse the repository at this point in the history
Lint
  • Loading branch information
lxgr-linux committed Aug 4, 2022
2 parents 9ccb292 + 8d84bce commit 5d1dff5
Show file tree
Hide file tree
Showing 26 changed files with 260 additions and 197 deletions.
107 changes: 56 additions & 51 deletions pokete.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ class NPCActions:
npc: The NPC the method belongs to"""

@staticmethod
def swap_poke(npc):
def swap_poke(_):
"""Swap_poke wrapper"""
swap_poke()

@staticmethod
def heal(npc):
def heal(_):
"""Heal wrapper"""
figure.heal()

Expand Down Expand Up @@ -275,8 +275,10 @@ def action(self, ob):
elif action.triggers(Action.ACT_2):
figure.heal()
time.sleep(SPEED_OF_TIME * 0.5)
mvp.movemap.text(int(mvp.movemap.width / 2), 3,
["...", "Your Poketes are now healed!"])
mvp.movemap.text(
int(mvp.movemap.width / 2), 3,
["...", "Your Poketes are now healed!"]
)
break
elif action.triggers(Action.CANCEL, Action.ACT_3):
break
Expand Down Expand Up @@ -550,7 +552,7 @@ def __call__(self):
ask_ok(self.map,
f"{poke.name} reached level "
f"{poke.lvl()}!")
elif type(obj) is LearnDisc:
elif isinstance(obj, LearnDisc):
if ask_bool(self.map, f"Do you want to teach '\
{obj.attack_dict['name']}'?"):
ex_cond = True
Expand All @@ -566,10 +568,13 @@ def __call__(self):
obj.attack_dict['types'][0])\
in poke.types:
break
else:
ex_cond = ask_bool(self.map,
f"You cant't \
teach '{obj.attack_dict['name']}' to '{poke.name}'! \nDo you want to continue?")
ex_cond = ask_bool(
self.map,
"You cant't teach "
f"'{obj.attack_dict['name']}' to "
f"'{poke.name}'! \n"
"Do you want to continue?"
)
if not ex_cond:
break
if LearnAttack(poke, self.map)\
Expand Down Expand Up @@ -697,7 +702,7 @@ def __call__(self, pevm):
time.sleep(SPEED_OF_TIME * 1.5)
elif i == self.exit_label:
save()
exit()
sys.exit()
elif i == self.about_label:
about()
elif i == self.ach_label:
Expand Down Expand Up @@ -818,7 +823,6 @@ def exiter():
print("\033[?1049l\033[1A")
if audio.curr is not None:
audio.kill()
#sys.exit()


# Functions needed for mvp.movemap
Expand All @@ -839,7 +843,7 @@ def codes(string):
print(exc)
return
elif i == "q":
exit()
sys.exit()


# Playmap extra action functions
Expand Down Expand Up @@ -895,13 +899,14 @@ def teleport(poke):
poke: The Poke shown in the animation"""
if (obj := roadmap(mvp.movemap, choose=True)) is None:
return
else:
if settings("animations").val:
animations.transition(mvp.movemap, poke)
cen_d = p_data.map_data[obj.name]["hard_obs"]["pokecenter"]
Door("", state="float", arg_proto={"map": obj.name,
"x": cen_d["x"] + 5,
"y": cen_d["y"] + 6}).action(figure)
if settings("animations").val:
animations.transition(mvp.movemap, poke)
cen_d = p_data.map_data[obj.name]["hard_obs"]["pokecenter"]
Door("", state="float", arg_proto={
"map": obj.name,
"x": cen_d["x"] + 5,
"y": cen_d["y"] + 6
}).action(figure)


def swap_poke():
Expand Down Expand Up @@ -1008,21 +1013,24 @@ def _game(_map):
# Directions are not being used yet
action = get_action()
if action.triggers(*ACTION_DIRECTIONS):
figure.direction = '' #TODO
figure.set(figure.x + action.get_X_strength(), figure.y + action.get_Y_strength())
figure.direction = ''
figure.set(
figure.x + action.get_x_strength(),
figure.y + action.get_y_strength()
)
elif action.triggers(*inp_dict):
audio_before = settings("audio").val
for key in inp_dict:
for key, option in inp_dict.items():
if action.triggers(key):
inp_dict[key][0](*inp_dict[key][1])
option[0](*option[1])
_ev.clear()
if audio_before != settings("audio").val:
audio.switch(_map.song)
mvp.movemap.show(init=True)
elif action.triggers(Action.CANCEL, Action.EXIT_GAME):
if ask_bool(mvp.movemap, "Do you really wish to exit?"):
save()
exit()
sys.exit()
elif action.triggers(Action.CONSOLE):
inp = text_input(mvp.movemap.code_label, mvp.movemap, ":",
mvp.movemap.width,
Expand Down Expand Up @@ -1092,48 +1100,47 @@ def gen_obs():
trainers = p_data.trainers

# adding all trainer to map
for i in trainers:
for i, trainer_list in trainers.items():
_map = obmp.ob_maps[i]
for j in trainers[i]:
for j in trainer_list:
args = j["args"]
trainer = Trainer([Poke(*p, player=False) for p in j["pokes"]], *args[:-2])
trainer.add(_map, args[-2], args[-1])
_map.trainers.append(trainer)

# generating objects from map_data
for ob_map in map_data:
for ob_map, single_map in map_data.items():
_map = obmp.ob_maps[ob_map]
for hard_ob in map_data[ob_map]["hard_obs"]:
for hard_ob, single_hard_ob in single_map["hard_obs"].items():
parse_obj(_map, hard_ob,
se.Text(map_data[ob_map]["hard_obs"][hard_ob]["txt"],
se.Text(single_hard_ob["txt"],
ignore=" "),
map_data[ob_map]["hard_obs"][hard_ob])
for soft_ob in map_data[ob_map]["soft_obs"]:
single_hard_ob)
for soft_ob, single_soft_ob in single_map["soft_obs"].items():
cls = {
"sand": Sand,
"meadow": Meadow,
"water": Water,
}[map_data[ob_map]["soft_obs"][soft_ob].get("cls", "meadow")]
}[single_soft_ob.get("cls", "meadow")]
parse_obj(_map, soft_ob,
cls(map_data[ob_map]["soft_obs"][soft_ob]["txt"],
cls(single_soft_ob["txt"],
_map.poke_args
if cls != Water else _map.w_poke_args),
map_data[ob_map]["soft_obs"][soft_ob])
for door in map_data[ob_map]["dors"]:
single_soft_ob)
for door, single_door in single_map["dors"].items():
parse_obj(_map, door,
Door(" ", state="float",
arg_proto=map_data[ob_map]["dors"][door]["args"]),
map_data[ob_map]["dors"][door])
for ball in map_data[ob_map]["balls"]:
arg_proto=single_door["args"]),
single_door)
for ball, single_ball in single_map["balls"].items():
if f'{ob_map}.{ball}' not in figure.used_npcs or not \
settings("save_trainers").val:
parse_obj(_map, ball,
Poketeball(f"{ob_map}.{ball}"),
map_data[ob_map]["balls"][ball])
single_ball)
# NPCs
for npc in npcs:
_npc = npcs[npc]
NPC(npc, _npc["texts"], fn=_npc["fn"],
for npc, _npc in npcs.items():
NPC(npc, _npc["texts"], _fn=_npc["fn"],
chat=_npc.get("chat", None)).add(obmp.ob_maps[_npc["map"]],
_npc["x"], _npc["y"])

Expand All @@ -1143,8 +1150,7 @@ def gen_maps():
RETURNS:
Dict of all PlayMaps"""
maps = {}
for ob_map in p_data.maps:
args = p_data.maps[ob_map]
for ob_map, args in p_data.maps.items():
args["extra_actions"] = (getattr(ExtraActions, args["extra_actions"],
None)
if args["extra_actions"] is not None
Expand All @@ -1159,15 +1165,14 @@ def check_version(sinfo):
sinfo: session_info dict"""
if "ver" not in sinfo:
return False
else:
ver = sinfo["ver"]
ver = sinfo["ver"]
if VERSION != ver and sort_vers([VERSION, ver])[-1] == ver:
if not ask_bool(loading_screen.map,
liner(f"The save file was created \
on version '{ver}', the current version is '{VERSION}', \
such a downgrade may result in data loss! \
Do you want to continue?", int(width * 2 / 3))):
exit()
sys.exit()
return VERSION != ver


Expand Down Expand Up @@ -1467,8 +1472,8 @@ def recogniser():
if settings("load_mods").val:
try:
import mods
except ModError as err:
error_box = InfoBox(str(err), "Mod-loading Error")
except ModError as mod_err:
error_box = InfoBox(str(mod_err), "Mod-loading Error")
error_box.center_add(loading_screen.map)
loading_screen.map.show()
sys.exit(1)
Expand Down Expand Up @@ -1533,8 +1538,8 @@ def recogniser():

# Achievements
achievements.set_achieved(session_info.get("achievements", []))
for identifier, args in p_data.achievements.items():
achievements.add(identifier, **args)
for identifier, achievement_args in p_data.achievements.items():
achievements.add(identifier, **achievement_args)

# objects relevant for fm.fight()
fm.fightmap = fm.FightMap(height - 1, width)
Expand Down
2 changes: 1 addition & 1 deletion pokete_classes/achievements.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def __call__(self, _map):
else:
if action.triggers(Action.CANCEL):
break
elif action.triggers(Action.ACCEPT):
if action.triggers(Action.ACCEPT):
ach = achievements.achievements[
self.get_item(*self.index).ind
]
Expand Down
8 changes: 4 additions & 4 deletions pokete_classes/attack.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
import time
import scrap_engine as se
from pokete_data.attacks import attacks
from release import SPEED_OF_TIME
from .effects import effects
from .types import types
from .color import Color
from release import SPEED_OF_TIME


class Attack:
Expand Down Expand Up @@ -59,12 +59,12 @@ def give_effect(self, enem):
time.sleep(SPEED_OF_TIME * 1.5)
getattr(effects, self.effect)().add(enem)

def set_ap(self, ap):
def set_ap(self, _ap):
"""Sets attack points
ARGS:
ap: Attack points"""
if ap != "SKIP":
self.ap = min(ap, self.max_ap)
if _ap != "SKIP":
self.ap = min(_ap, self.max_ap)
self.label.rechar("")
self.label += self.make_label()

Expand Down
41 changes: 28 additions & 13 deletions pokete_classes/attack_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,55 +10,70 @@ class AttackActions:
pattern:
ARGS:
obj: The Poke object that attacks
enem: The Poke object that is attacked"""
enem: The Poke object that is attacked
providers: List of the current providers"""

def cry(self, obj, enem, _):
def cry(self, _, enem, __):
"""Cry attack action"""
enem.miss_chance += 1

def eye_pick(self, obj, enem, _):
def eye_pick(self, _, enem, __):
"""Eye pick attack action"""
enem.miss_chance += 2

def chocer(self, obj, enem, _):
def chocer(self, _, enem, __):
"""Chocer attack action"""
enem.atc -= 1

def snooze(self, obj, enem, _):
def snooze(self, _, enem, __):
"""Snooze attack action"""
enem.miss_chance += 0.5
enem.atc -= 1
enem.defense -= 1

def politure(self, obj, enem, _):
def politure(self, obj, _, __):
"""Politure attack action"""
obj.defense += 1
obj.atc += 1

def bark_hardening(self, obj, enem, _):
def bark_hardening(self, obj, _, __):
"""Bark hardening attack action"""
obj.defense += 1

def dick_energy(self, obj, enem, _):
def dick_energy(self, obj, _, __):
"""Dick energy attack action"""
obj.atc += 2

def hiding(self, obj, enem, _):
def hiding(self, obj, _, __):
"""Hiding attack action"""
obj.defense += 2

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

def heart_touch(self, obj, enem, _):
def heart_touch(self, _, enem, __):
"""Heart touch attack action"""
enem.defense -= 4

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

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

def rain_dance(self, obj, enem, providers):
def rain_dance(self, obj, _, providers):
"""Rain dance attack action"""
providers[0].map.weather = Weather("rain")
obj.ico.map.outp.outp("It started raining!")
time.sleep(2)

def encouragement(self, obj, _, providers):
"""Encouragement attack action"""
for poke in next(
prov for prov in providers if prov.curr == obj
).pokes[:6]:
Expand Down
3 changes: 2 additions & 1 deletion pokete_classes/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
def audio_fn(song, play_audio):
"""plays a song in loop"""
import playsound


while play_audio:
playsound.playsound(str(MUSIC_PATH / song))

Expand Down Expand Up @@ -43,4 +45,3 @@ def kill(self):
self.curr.terminate()

audio = Audio()

Loading

0 comments on commit 5d1dff5

Please sign in to comment.