import store from 'store'
import text from './text'

import toplist from '../logic/toplist'

export default () => {
	text({ text: 'Top list', x: 130, y: 100, size: 24 })

	const size = 16
	text({ text: 'место |      счет      |    линии   ', x: 20, y: 140, size })

	toplist.list().forEach((item, i) => {
		const y = 170 + i * 30

		text({ text: i + 1, x: 60, y, size, align: 'right' })
		text({ text: item.total, x: 165, y, size, align: 'center'})
		text({ text: item.lines, x: 310, y, size, align: 'center' })
	})


	if (store.keyboard.pressedActions.exit()) {
		store.options.current.stage = 0
	}
}

