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.model.interfaces.Timed
import net.pokeranalytics.android.ui.fragment.GraphFragment
import net.pokeranalytics.android.ui.view.DefaultLegendValues
import net.pokeranalytics.android.ui.view.LegendContent
import net.pokeranalytics.android.util.TextFormat

class ObjectIdentifier(var id: String, var clazz: Class<out Timed>) {

}

interface GraphUnderlyingEntry {

	fun entryTitle(context: Context): String
	fun formattedValue(stat: Stat): TextFormat

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

		val leftName = stat.localizedTitle(context)
		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(context), totalStatValue, leftName = leftName)
			}
			else -> {
				val entryValue = this.formattedValue(stat)
				val totalStatValue = stat.format(entry.y.toDouble(), currency = null)
				DefaultLegendValues(this.entryTitle(context), entryValue, totalStatValue, leftName = leftName)
			}
		}

	}

}