• I’m using Sportspress for managing a billiards competition. Each player starts the competition with a handicap, and it rises and falls for each win or loss. The equation for this in player statistics is pretty simple:

    CurrentHcp = StartingHcp + (10 * (GamesWon – GamesLost))

    However, I don’t want the handicap fall below a minimum level (70) or rise above a maximum level (320), and I can’t see how to code this to happen automatically, so that if CurrentHcp calculates to a value below 70 then it becomes 70, or if above 320 then it becomes 320. Is this possible?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Contributor Savvas

    (@savvasha)

    Hi @nickjp ,

    Did you try something like
    Total = (CurrentHCP < 71)*70 + (CurrentHCP > 319)*320 ?

    Thanks,
    Savvas

    Thread Starter NickJP

    (@nickjp)

    Yes, that gives the correct result for the outlying cases, but not for those between the floor and ceiling. Without some sort of if > then conditional statement, I don’t see how I can have a formula that sets the value correctly for all players.

    Plugin Contributor Savvas

    (@savvasha)

    Well you can try the following:
    Total = (CurrentHCP > 70)*(CurrentHCP < 320)*CurrentHCP + (CurrentHCP ≤ 70)*70 + (CurrentHCP ≥ 320)*320

    Thanks,
    Savvas

    Thread Starter NickJP

    (@nickjp)

    Thanks, I’ve spent a while playing around with it, but can’t get it to work. I created a variable currenthcp in the hope that it would get populated with the result of my existing CurrentHcp = StartingHcp + (10 * (GamesWon – GamesLost)) equation, and then used currenthcp in your suggested equation. But it looks as though the currenthcp variable doesn’t get populated from the equation, as using it doesn’t give a valid result.

    Is it possible to use the output of one equation in another without reproducing the entirety of the first equation everywhere that its output value appears in the second?

    Also, is it possible to define additional constants beyond the default available values of 0-10 and 100? At the moment I’m using (7*10) for 70 and (8*4*10) for 320.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Conditional equation for calculating handicap’ is closed to new replies.