示例#1
0
 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
示例#2
0
    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
示例#3
0
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")
示例#4
0
 def _field_start(self, field):
     field = Field.from_showdown_message(field)
     self._fields.add(field)
示例#5
0
 def _field_end(self, field):
     field = Field.from_showdown_message(field)
     assert field in self.fields
     self._fields.remove(field)
示例#6
0
 def _field_start(self, field):
     field = Field.from_showdown_message(field)
     self._fields[field] = self.turn
示例#7
0
 def _field_end(self, field):
     field = Field.from_showdown_message(field)
     if field is not Field._UNKNOWN:
         self._fields.pop(field)