namespace CalledIt.Domain;

public static class BetScoringCalculator
{
    public static int Calculate(int betHome, int betAway, int actualHome, int actualAway)
    {
        int points = 0;

        if (betHome == actualHome && betAway == actualAway)
        {
            points += 5;
        }

        if (betHome == actualHome)
        {
            points += 1;
        }

        if (betAway == actualAway)
        {
            points += 1;
        }

        var betOutcome = Math.Sign(betHome - betAway);
        var actualOutcome = Math.Sign(actualHome - actualAway);

        if (betOutcome == actualOutcome)
        {
            points += 2;
            if ((betHome - betAway) == (actualHome - actualAway))
            {
                points += 2;
            }
        }

        return points;
    }
}
