v0.1.0-alpha: first playable
20 rooms, Crumb board token, Home and Game screens only.
This commit is contained in:
commit
f4b4a773f3
113 files changed
+4167
No files matched your search
@@ -0,0 +1,47 @@
|
||||
class_name Guests
|
||||
extends RefCounted
|
||||
|
||||
const PATH := "res://data/guests.json"
|
||||
|
||||
static var _cache: Array = []
|
||||
|
||||
|
||||
static func all() -> Array:
|
||||
if _cache.is_empty():
|
||||
if not FileAccess.file_exists(PATH):
|
||||
return []
|
||||
var file := FileAccess.open(PATH, FileAccess.READ)
|
||||
if file == null:
|
||||
return []
|
||||
var parsed = JSON.parse_string(file.get_as_text())
|
||||
file.close()
|
||||
if typeof(parsed) == TYPE_ARRAY:
|
||||
_cache = parsed
|
||||
return _cache
|
||||
|
||||
|
||||
static func by_id(id: String) -> Dictionary:
|
||||
for guest in all():
|
||||
if str(guest.get("id", "")) == id:
|
||||
return guest
|
||||
return {}
|
||||
|
||||
|
||||
static func ids() -> Array:
|
||||
var out: Array = []
|
||||
for guest in all():
|
||||
out.append(str(guest.get("id", "")))
|
||||
return out
|
||||
|
||||
|
||||
static func for_room(room_number: int) -> Dictionary:
|
||||
for guest in all():
|
||||
if int(guest.get("unlock_room", -1)) == room_number:
|
||||
return guest
|
||||
return {}
|
||||
|
||||
|
||||
static func portrait(id: String, size: String = "thumbs") -> String:
|
||||
if size == "full":
|
||||
return "res://art/guests/cards/%s.png" % id
|
||||
return "res://art/guests/%s/%s.png" % [size, id]
|
||||
Reference in new issue
Block a user