Hi!
Thanks for reaching out!
Let’s translate this rule into a conditional logic. Breaking it into pieces:
“If the team with less goals”
So we need a conditional check: ( ms > t )
Or if this team has more goals awarded than made
” has scored only one goal less than the other team”
This is almost like you wrote: ( (t – ms) = 1 )
Otherwise, it’ll always be negative one or less
“the losing team must take 1 defensive bonus”
Now we just glue it all together:
bd = ( ms > t ) * ( (t – ms) = 1 )
Let’s try this and let us know how it works for you.
Thanks!
Unfortunately I always get zero as a result of the BD.
In the event I set:
Team1 4t and 3ms
Team2 3t and 4ms
The result:
Team1: BO = 1, BD = 0.
Team2: BO = 0, BD = 0.
I specify that I am using the free version 2.6.20
Checking on modules/sportspress-conditional-equations.php on line 80 I see that it does not handle the operation suggested by you (as it did not manage the one I created).
Code:
// Find all parentheses with conditional operators
$re = '/([^[\(|\)]*[<=>][^[\(|\)]*)/';
if ( preg_match_all( $re, $equation, $matches ) ) {
foreach ( $matches[1] as $match ) {
etc…..
In this way it sees only the first equation ms>t, it does not handle the second operation.
Here you can see the evidence more clearly:
LINK TO PHP LIVE REGEX SCREENSHOT
Plugin Contributor
Savvas
(@savvasha)
Hi @angelo_de_lorenzo ,
Maybe the double () confuses the “system”. Can you try to create a variable like the following:
var = t – ms
and then use something like:
bd = ( ms > t ) * ( var == 1 )
Thanks,
Savvas
Hi Angelo!
Another option is debugging each individual component. For example, set
bd = ms > t
Check if it’s one for losing team. Then
bd = ( (t – ms) = 1 )
or the var version Savvas suggested, this shows if the last part is correct.
Thanks!