package net.pokeranalytics.android.model

import android.content.Context
import net.pokeranalytics.android.R
import net.pokeranalytics.android.ui.view.RowRepresentable
import net.pokeranalytics.android.ui.view.RowViewType

class TableSize(var numberOfPlayer: Int, var rowViewType: Int = RowViewType.TITLE_GRID.ordinal) : RowRepresentable {

	companion object {

		val all: List<TableSize>
			get() {
				return Array(9, init =
				{ index -> TableSize(index + 2) }).toList()
			}

		fun valueForLabel(label: String) : Int? {
			return when (label) {
				"Full Ring", "Full-Ring" -> 10
				"Short-Handed", "Short Handed" -> 6
				"Heads-Up", "Heads Up" -> 2
				else -> null
			}
		}
	}

	override fun getDisplayName(context: Context): String {
		return if (this.numberOfPlayer == 2) {
			return "HU"
		} else {
			"${this.numberOfPlayer}-max"
		}
	}

	override val resId: Int?
		get() {
			return if (this.numberOfPlayer == 2) {
				R.string.heads_up
			} else {
				R.string.max
			}
		}

	override fun localizedTitle(context: Context): String {
		this.resId?.let {
			return if (this.numberOfPlayer == 2) {
				context.getString(it)
			} else {
				"${this.numberOfPlayer}-${context.getString(it)}"
			}
		}
		return super.localizedTitle(context)
	}

	override val viewType: Int
		get() = rowViewType

}
