import store from 'store'

export default class {
	snake() {
		const segments = store.options.objects.snake.segments
		const score = store.options.current.score

		const check = (i1, i2) => segments[i1].x === segments[i2].x

		let counter = 0

		const end = segments.length - 2
		for (let i = 0; i < end; i++) {
			counter += check(i, i + 1) !== check(i + 1, i + 2)
		}

		score.total += (counter + 1) * segments.length
	}

	lines(count) {
		const score = store.options.current.score

		score.total += count * count
		score.lines += count

		store.options.current.snakeLength = (score.lines | 0) + 3
		store.options.current.speed = score.lines * .5 + 1
	}
}
