Closed zyr17 closed 4 months ago
Functions are implemented in query.py
, and have quick access interface in ObjectBase
and ObjectPosition
.
ObjectPosition.query
to return object lists and ObjectPosition.query_one
to return one object or None.
Match
and command_string
as arguments. command contains:both / our / opponent
to select player_table, or self
to select this character (caller area must be character or character_status). must appear first.[active / prev / next] or [deck / hand / character / team_status]
for player_table, [weapon / artifact / talent] or [status]
for character, to select an object (first group) or object lists (second group). Note with both
, select one object may also receive two objects.['key=value']
to filter current objects that x.key == value
. All types will be converted to str to compare. it can be used multiple times. command can be surrounded with single quotes, and if not space in key and value, quotes can be omitted.and
to make multiple queries, and their results are combined.samples:
self
to get self character when called by a character statusopponent active status 'name=Seed of Skandha'
to get statusopponent character status name=Refraction
to get status from all opponent charactersboth summon
to get all summons on fieldself and our active and our next
to select characterssatisfy
takes target ObjectPosition
, Match
and command_string
as input. target position and match is optional. and without match, related command string will raise error.
source / target
to select one position, or both
to compare between two positions[pidx=? / cidx=? / area=? / active=(true|false)]
to check if position fulfills the situation. for area names, they are case insensitive. can use multiple times, and all of them should pass.both
), [(pidx|cidx|area|id)=(same|diff)]
to compare two positions are same or not. can use multiple times, and all of them should pass.and
to make multiple checks. All check should pass.samples:
source area=support
is placed to supportsource area=character and target area=skill and both pidx=same cidx=same
is equipped to a character, and target is skill of this characterboth pidx=same and source area=hand and target area=skill
self in hand and target is this player use skill
Instead of implementing query functions everywhere, gather them to one interface, so we can re-use it and decrease bugs.
The query function should be:
self.position
andmatch
as input.check_position_valid
function).