extends Node

@onready var player_vars = get_node("/root/PlayerVariables")
var classroom_agent = preload("res://Rooms/Classroom.tscn")
var staffroom_agent = preload("res://Rooms/StaffRoom.tscn")
var cpdroom_agent = preload("res://Rooms/CPDRoom.tscn")

# Repeatable Buildings

func add_classroom():
	if player_vars.funds > (player_vars.classroom_cost - 1):
		var classroom = classroom_agent.instantiate()
		add_child(classroom)
		player_vars.funds -= player_vars.classroom_cost
		player_vars.classroom_count += 1

func add_staffroom():
	if player_vars.has_staffroom == false:
		if player_vars.funds > (player_vars.staffroom_cost - 1):
			var staffroom = staffroom_agent.instantiate()
			add_child(staffroom)
			player_vars.funds -= player_vars.staffroom_cost
			player_vars.has_staffroom = true

# Unique Buildings

func add_cpdroom():
	if player_vars.has_cpdroom == false:
		if player_vars.funds > (player_vars.cpdroom_cost - 1):
			var cpdroom = cpdroom_agent.instantiate()
			add_child(cpdroom)
			player_vars.funds -= player_vars.cpdroom_cost
			player_vars.has_cpdroom = true

func _on_ClassroomButton_pressed():
	add_classroom()

func _on_StaffroomButton_pressed():
	add_staffroom()

func _on_CPDRoomButton_pressed():
	add_cpdroom()
