@@ -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 } '! \n Do 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
907912def 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 )
0 commit comments