Support » Plugin: SportsPress - Sports Club & League Manager » Conditional equations problem

• Angelo_De_Lorenzo

(@angelo_de_lorenzo)

I’m creating a rugby league.
On the player’s performance I created the variables “t” (goals made) and “ms” (goals conceded).
On event results I created an offensive bonus called “bo” and a defensive bonus called “bd”.
With the “bo” I have no problems, I set the equation t >= 4.
So if a team scores 4 or more goals it takes 1 offensive bonus.
On “bd” if the team with less goals has scored only one goal less than the other team the losing team must take 1 defensive bonus.
I set the following equation, (ms – t) = 1.
This doesn’t work because in the results of the event on “bd” I always find 0.
What am I doing wrong?
Am I misinterpreting the sign “=” ?

Viewing 4 replies - 1 through 4 (of 4 total)
• Plugin Support Roch

(@rochesterj)

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!

Angelo_De_Lorenzo

(@angelo_de_lorenzo)

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)

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

Plugin Support Roch

(@rochesterj)

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!

Viewing 4 replies - 1 through 4 (of 4 total)
• You must be logged in to reply to this topic.