diff options
author | nokoe <nokoe@mailbox.org> | 2025-09-29 17:50:47 +0200 |
---|---|---|
committer | nokoe <nokoe@mailbox.org> | 2025-09-29 17:50:47 +0200 |
commit | 12c0f5e6a5b06953126ae38e1e9c4127bdea231c (patch) | |
tree | 82125fde91afb252dffaa07208d992954e1624fa /client/serialize.gd | |
parent | c6efe3e4ac60db4b746dadd03fb24eed8a3720e3 (diff) | |
download | hurrycurry-12c0f5e6a5b06953126ae38e1e9c4127bdea231c.tar hurrycurry-12c0f5e6a5b06953126ae38e1e9c4127bdea231c.tar.bz2 hurrycurry-12c0f5e6a5b06953126ae38e1e9c4127bdea231c.tar.zst |
Revert "add class to serialize objects"
This reverts commit c4de2cca4311e211fe3b22c4e2ea0b2cb7e96c80.
Diffstat (limited to 'client/serialize.gd')
-rw-r--r-- | client/serialize.gd | 64 |
1 files changed, 0 insertions, 64 deletions
diff --git a/client/serialize.gd b/client/serialize.gd deleted file mode 100644 index 23dd895d..00000000 --- a/client/serialize.gd +++ /dev/null @@ -1,64 +0,0 @@ -# Hurry Curry! - a game about cooking -# Copyright (C) 2025 Hurry Curry! contributors -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, version 3 of the License only. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see <https://www.gnu.org/licenses/>. -# -class_name Serialize -extends Object - -func serialize() -> String: - return JSON.stringify(to_dict()) - -func to_dict() -> Dictionary: - var dict: Dictionary = {} - for i in get_property_list(): - var type = i["type"] - var v = get(i["name"]) - if v == null: - continue - match type: - TYPE_NIL || TYPE_CALLABLE: pass - TYPE_OBJECT: - if v is Serialize: - dict[i["name"]] = v.to_dict() - TYPE_ARRAY: - dict[i["name"]] = v.map(func(e): return e.to_dict() if e is Serialize else e) - _: - dict[i["name"]] = v - return dict - -func deserialize(de: String): - return from_dict(JSON.parse_string(de)) - -func from_dict(dict: Dictionary): - for i in get_property_list(): - var type = i["type"] - var name = i["name"] - if !dict.has(name) || dict[name] == null: - continue - match type: - TYPE_NIL || TYPE_CALLABLE: pass - TYPE_OBJECT: - var copy = new() - copy.from_dict(dict[name]) - set(name, copy) - TYPE_ARRAY: - set(name, dict[name].map(func(e): if e is Dictionary: - var copy = new() - copy.from_dict(e) - return copy - else: return e - ) - ) - _: - set(name, dict[name]) |