def terrain(self) -> Optional[Field]: """ :return: Terrain started by the move. :rtype: Optional[Field] """ terrain = self.entry.get("terrain", None) if terrain is not None: terrain = Field.from_showdown_message(terrain) return terrain
def _field_start(self, field): field = Field.from_showdown_message(field) if field.is_terrain: self._fields = { field: turn for field, turn in self._fields.items() if not field.is_terrain } self._fields[field] = self.turn
def test_field_build(): assert Field["ELECTRIC_TERRAIN"] == Field.from_showdown_message( "electric terrain") assert Field["ELECTRIC_TERRAIN"] == Field.from_showdown_message( "move: electric terrain") assert Field["_UNKNOWN"] == Field.from_showdown_message("weird thing")
def _field_start(self, field): field = Field.from_showdown_message(field) self._fields.add(field)
def _field_end(self, field): field = Field.from_showdown_message(field) assert field in self.fields self._fields.remove(field)
def _field_start(self, field): field = Field.from_showdown_message(field) self._fields[field] = self.turn
def _field_end(self, field): field = Field.from_showdown_message(field) if field is not Field._UNKNOWN: self._fields.pop(field)