LPSim / backend

LPSim: Genius Invokation TCG simulator 七圣召唤水皇模拟器 :sparkles: 4.5已更新
https://pypi.org/project/lpsim/
GNU Affero General Public License v3.0
16 stars 3 forks source link

Universal object query function #92

Closed zyr17 closed 4 months ago

zyr17 commented 5 months ago

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:

xqm32 commented 5 months ago

Maybe we can make something like Textual's DOM Queries^1 for the query function.

zyr17 commented 5 months ago

Maybe we can make something like Textual's DOM Queries1 for the query function.

Footnotes

1. https://textual.textualize.io/guide/queries/ [↩](#user-content-fnref-1-53e0da1da517b473c6fd1af6bf2ecce0)

Yes something like that, but with simpler grammars, as our target structures are fixed.

zyr17 commented 4 months ago

Functions are implemented in query.py, and have quick access interface in ObjectBase and ObjectPosition.

querying objects

ObjectPosition.query to return object lists and ObjectPosition.query_one to return one object or None.

samples:

position checking

satisfy takes target ObjectPosition, Match and command_string as input. target position and match is optional. and without match, related command string will raise error.

samples: