package net.pokeranalytics.android.ui.graph

import android.content.Context
import com.github.mikephil.charting.data.Entry
import net.pokeranalytics.android.calculus.Stat
import net.pokeranalytics.android.calculus.TextFormat
import net.pokeranalytics.android.ui.fragment.GraphFragment
import net.pokeranalytics.android.ui.view.DefaultLegendValues
import net.pokeranalytics.android.ui.view.LegendContent

interface GraphUnderlyingEntry {

	val entryTitle: String
	fun formattedValue(stat: Stat): TextFormat

	fun legendValues(
		stat: Stat,
		entry: Entry,
		style: GraphFragment.Style,
		groupName: String,
		context: Context
	): LegendContent {

		return when (stat) {
			Stat.NUMBER_OF_SETS, Stat.NUMBER_OF_GAMES, Stat.WIN_RATIO, Stat.HOURLY_DURATION, Stat.AVERAGE_HOURLY_DURATION -> {
				val totalStatValue = stat.format(entry.y.toDouble(), currency = null)
				DefaultLegendValues(this.entryTitle, totalStatValue)
			}
			else -> {
				val entryValue = this.formattedValue(stat)
				val totalStatValue = stat.format(entry.y.toDouble(), currency = null)
				DefaultLegendValues(this.entryTitle, entryValue, totalStatValue)
			}
		}

	}

}