Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow value with formula in variable filter #1427

Merged
merged 1 commit into from
Nov 7, 2024
Merged

Conversation

Pablete1234
Copy link
Member

@Pablete1234 Pablete1234 commented Nov 7, 2024

Adds alternative syntax to variable filter where it will check for a formula's value instead of a single variable:

  <variables>
    <with-team id="red_score" var="score" team="red"/>
    <with-team id="blue_score" var="score" team="blue"/>
  </variables>

  <filters>
    <!--  Match-scoped checks for if either of the team is over the other, or tied -->
    <variable id="tied" scope="match" value="red_score-blue_score">0</variable>
    <variable id="red-winning" scope="match" value="red_score-blue_score">(0,oo)</variable>
    <variable id="blue-winning" scope="match" value="blue_score-red_score">(0,oo)</variable>

    <!-- The following use a single variable as the whole formula,
           meaning they're equivalent to their var counterpart, but could be more complex -->

    <!-- Team-scoped check for if you've gotten any score. 
         Players/teams would work, match would always abstain -->
    <variable id="has-scored" scope="team" value="score">(0,oo)</variable>
    <variable id="has-scored" var="score">(0,oo)</variable>

    <!-- Match-scoped check, which will redirect to checking for a specific team -->
    <variable id="red-has-scored" team="red" scope="team" value="score">(0,oo)</variable>
    <variable id="red-has-scored" team="red" var="score">(0,oo)</variable>

    <variable id="blue-has-scored" team="blue" scope="team" value="score">(0,oo)</variable>
    <variable id="blue-has-scored" team="blue" var="score">(0,oo)</variable>

    <!-- Match-scoped check, which will redirect to checking for all teams -->
    <variable id="any-has-scored" any="true" scope="team" value="score">(0,oo)</variable>
    <variable id="any-has-scored" any="true" var="score">(0,oo)</variable>
  </filters>

Before this would require an action that stored the result of red_score-blue_score in a tmp variable, then filtering on that tmp, now it can be automatically done by the filter.
Note that this can be combined with the team="x" and any="true" modifiers just like the normal variable filter.

Attributes:

value Required, the formula to check
scope Required, the scope that the formula runs against

These are an alternative to the original var. You can use either value+scope or var+index (if needed), but not both.

This type of variable filter is NOT dynamic.

@Pablete1234 Pablete1234 merged commit 96372f1 into dev Nov 7, 2024
2 checks passed
@Pablete1234 Pablete1234 deleted the value-variable-filter branch November 7, 2024 02:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants