@@ -320,8 +320,7 @@ def _check_damage_message_for_ability(self, split_message: List[str]):
320320 ability = split_message [4 ].split ("ability:" )[- 1 ]
321321 pkmn = split_message [5 ].split ("[of]" )[- 1 ].strip ()
322322 pkmn_object = self .get_pokemon (pkmn )
323- if pkmn_object .ability is None :
324- pkmn_object .ability = ability
323+ pkmn_object .ability = ability
325324
326325 def _check_heal_message_for_item (self , split_message : List [str ]):
327326 # Catches when a side heals from it's own item
@@ -349,13 +348,11 @@ def _check_heal_message_for_ability(self, split_message: List[str]):
349348 if ability == "hospitality" :
350349 pkmn = split_message [5 ].replace ("[of] " , "" ).strip ()
351350 pkmn_object = self .get_pokemon (pkmn )
352- if pkmn_object .ability is None :
353- pkmn_object .ability = ability
351+ pkmn_object .ability = ability
354352 else :
355353 pkmn = split_message [2 ]
356354 pkmn_object = self .get_pokemon (pkmn )
357- if pkmn_object .ability is None :
358- pkmn_object .ability = ability
355+ pkmn_object .ability = ability
359356
360357 @abstractmethod
361358 def end_illusion (self , pokemon_name : str , details : str ):
@@ -536,8 +533,7 @@ def parse_message(self, split_message: List[str]):
536533
537534 pokemon = event [2 ]
538535 mon = self .get_pokemon (pokemon )
539- if mon .ability is None :
540- mon .ability = revealed_ability
536+ mon .ability = revealed_ability
541537
542538 if revealed_ability == "Magic Bounce" :
543539 return
@@ -681,31 +677,30 @@ def parse_message(self, split_message: List[str]):
681677 elif event [1 ] == "-ability" :
682678 pokemon , cause = event [2 :4 ]
683679 mon = self .get_pokemon (pokemon )
684- if (
685- mon .ability is not None
686- and mon .ability in ["asoneglastrier" , "asonespectrier" ]
687- and event [3 ] in ["asone" , "unnerve" ]
688- ):
680+ # As One is a special case ability that combines two abilities
681+ if "calyrex" in mon .base_species and cause in [
682+ "As One" ,
683+ "Unnerve" ,
684+ "Chilling Neigh" ,
685+ "Grim Neigh" ,
686+ ]:
689687 return
690- if (
691- len (event ) > 4
692- and (
693- event [4 ].startswith ("[from] move:" )
694- or event [4 ].startswith ("[from] ability: Trace" )
695- )
696- ) or (
697- len (event ) > 5
698- and (
699- event [5 ].startswith ("[from] move:" )
700- or event [5 ].startswith ("[from] ability: Trace" )
701- )
688+ if (len (event ) > 4 and event [4 ].startswith ("[from] ability: Trace" )) or (
689+ len (event ) > 5 and event [5 ].startswith ("[from] ability: Trace" )
702690 ):
703- if mon .ability is None or mon ._ability == to_id_str (cause ):
691+ if mon .ability != "trace" :
692+ # correcting for bad PS ordering of logs, eg:
693+ # |-ability|p1a: Gardevoir|Intimidate|boost
694+ # |-ability|p1a: Gardevoir|Intimidate|[from] ability: Trace|[of] p2a: Luxray
695+ if mon .temporary_ability is not None :
696+ mon .temporary_ability = None
697+ elif mon ._ability is not None :
698+ mon ._ability = None
704699 mon .ability = "trace"
705- mon .temporary_ability = cause
700+ mon .ability = cause
706701 elif cause == "Neutralizing Gas" :
707702 self .field_start (cause )
708- elif mon . ability is None :
703+ else :
709704 mon .ability = cause
710705 elif split_message [1 ] == "-start" :
711706 pokemon , effect = event [2 :4 ]
@@ -823,17 +818,15 @@ def parse_message(self, split_message: List[str]):
823818 elif mon == self .opponent_active_pokemon :
824819 self .active_pokemon .item = to_id_str (item )
825820
826- if mon .ability is None :
827- mon .ability = "frisk"
821+ mon .ability = "frisk"
828822 elif cause == "[from] ability: Pickpocket" :
829823 pickpocket = event [2 ]
830824 pickpocketed = event [5 ].replace ("[of] " , "" )
831825 item = event [3 ]
832826
833827 pickpocketer = self .get_pokemon (pickpocket )
834828 pickpocketer .item = to_id_str (item )
835- if pickpocketer .ability is None :
836- pickpocketer .ability = "pickpocket"
829+ pickpocketer .ability = "pickpocket"
837830 self .get_pokemon (pickpocketed ).item = None
838831 elif cause == "[from] ability: Magician" :
839832 magician = event [2 ]
@@ -842,8 +835,7 @@ def parse_message(self, split_message: List[str]):
842835
843836 magicianer = self .get_pokemon (magician )
844837 magicianer .item = to_id_str (item )
845- if magicianer .ability is None :
846- magicianer .ability = "magician"
838+ magicianer .ability = "magician"
847839 self .get_pokemon (victim ).item = None
848840 elif cause in {"[from] move: Thief" , "[from] move: Covet" }:
849841 thief = event [2 ]
@@ -1022,8 +1014,7 @@ def parse_message(self, split_message: List[str]):
10221014 if cause .startswith ("[from] ability:" ):
10231015 cause = cause .replace ("[from] ability:" , "" )
10241016 mon = self .get_pokemon (pokemon )
1025- if mon .ability is None :
1026- mon .ability = cause
1017+ mon .ability = cause
10271018 elif event [1 ] == "-swapsideconditions" :
10281019 self ._side_conditions , self ._opponent_side_conditions = (
10291020 self ._opponent_side_conditions ,
0 commit comments