package me.zobrist.tichucounter

import java.io.Serializable

class Round() : Serializable
{
    var scoreA: Int=0
    var scoreB: Int=0

    constructor(score: Int , isScoreA: Boolean) : this()
    {
        if (isScoreA)
        {
            scoreA=score
            scoreB=calculateOtherScore(scoreA)
        }
        else
        {
            scoreB=score
            scoreA=calculateOtherScore(scoreB)
        }
    }

    constructor(scoreA: Int , scoreB: Int) : this()
    {
        this.scoreA=scoreA
        this.scoreB=scoreB
    }

    private fun calculateOtherScore(score: Int): Int
    {
        if (score.isMultipleOf100() && score != 0)
        {
            return 0
        }
        if (score in 101 ..125)
        {
            return 0 - (score % 100)
        }
        return 100 - (score % 100)
    }

    fun isValidRound(): Boolean
    {
        return (scoreA.isMultipleOf5()) && scoreB.isMultipleOf5() && (scoreA + scoreB).isMultipleOf100()
    }
}