Files
MusicPlayer/song_object.gd
T
Sansan a0428e3475 Follow the GDScript style guide in every script
- Types on every parameter, return value and variable, and snake_case names
  (the player name limit is the constant MAX_NAME_LENGTH).
- Spelling fixes: *_triggered, character_selected, separator, caught_errors.
  The server's catched_errors key stays as the server sends it.
- Signals are connected with signal.connect() instead of by name.
- Code is ordered signals, constants, exported vars, vars, @onready vars,
  functions, with @onready on one line and two blank lines between functions.
- Every script starts with a ## description. Template comments, old LOC notes
  and commented-out code are gone, apart from the local play code.
- Lines are at most 100 characters, apart from the local play path.
- The screenshot tour turns off the blinking text cursor so pictures match.
2026-10-06 11:53:26 +02:00

60 lines
1.5 KiB
GDScript

extends RefCounted
class_name SongObject
var song_number: int
var song_title: String
var soundtrack_title: String
## Ids of the players who got a point for this song.
var players_given_point: Array[String] = []
var is_answered: bool = false
var has_played: bool = false
var is_playing: bool = false
var song: AudioStream
func get_soundtrack_title() -> String:
if is_answered:
return soundtrack_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), soundtrack_title, song_title, has_played,
is_answered]
elif is_answered:
var format_string: String = "%d. %s - %s"
return format_string % [(song_number + 1), soundtrack_title, song_title]
else:
return "??? - ???"
func add_point(player_id: String) -> void:
GameLog.debug("add_point")
if !players_given_point.has(player_id):
players_given_point.append(player_id)
func remove_point(player_id: String) -> void:
GameLog.debug("remove_point")
players_given_point.erase(player_id)
func _to_string() -> String:
var format_string: String = "song_number: %d | soundtrack_title: %s | song_title: %s" \
+ " | is_answered: %s | has_played: %s | is_playing: %s"
return format_string % [song_number, soundtrack_title, song_title, is_answered, has_played,
is_playing]