extends Node

class_name SongObject

var song_number: int

var song_title: String

var game_title: String

var players_given_point: Array[int] = []

var is_answered: bool = false

var has_played: bool = false

var is_playing: bool = false

var song: AudioStream

func get_game_title() -> String:
	if is_answered:
		return game_title
	else:
		return "????????"

func get_song_title() -> String:
	if is_answered:
		return song_title
	else:
		return "??????"

func get_song_info() -> String:
	if Settings.is_debug:
		var format_string: String = "%d. %s - %s | played: %s | answered: %s"
		return format_string % [(song_number + 1), game_title, song_title, has_played, is_answered]
	elif is_answered:
		var format_string: String = "%d. %s - %s"
		return format_string % [(song_number + 1), game_title, song_title]
	else:
		return "??? - ???"

func add_point(id: int) -> void:
	print("add_point")
	players_given_point.append(id)
	players_given_point.sort()

func remove_point(id: int) -> void:
	print("remove_point")
	if players_given_point.has(id):
		players_given_point.remove_at(players_given_point.find(id))
	players_given_point.sort()

func _to_string() -> String:
	var format_string: String = "song_number: %d | game_title: %s | song_title: %s | is_answered: %s | has_played: %s | is_playing: %s"
	return format_string % [(song_number), game_title, song_title, is_answered, has_played, is_playing]
