Skip to content

Commit

Permalink
Merge pull request #35 from TaloDev/develop
Browse files Browse the repository at this point in the history
Release 0.11.0
  • Loading branch information
tudddorrr authored Oct 20, 2024
2 parents 1a61ae6 + 5bcb9e5 commit effad38
Show file tree
Hide file tree
Showing 50 changed files with 577 additions and 508 deletions.
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"editor.detectIndentation": true,
"editor.insertSpaces": false,
"editor.indentSize": "tabSize",
"editor.tabSize": 4
}
2 changes: 1 addition & 1 deletion addons/talo/apis/events_api.gd
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func _build_meta_props() -> Array[TaloProp]:
func _has_errors(errors: Array) -> bool:
return errors.any((func (err: Array): return err.size() > 0))

func track(name: String, props: Dictionary) -> void:
func track(name: String, props: Dictionary = {}) -> void:
if Talo.identity_check() != OK:
return

Expand Down
10 changes: 10 additions & 0 deletions addons/talo/apis/player_groups_api.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class_name PlayerGroupsAPI extends TaloAPI

func get_group(group_id: String) -> TaloPlayerGroup:
var res = await client.make_request(HTTPClient.METHOD_GET, "/%s" % [group_id])

match (res.status):
200:
return TaloPlayerGroup.new(res.body.group)
_:
return null
2 changes: 1 addition & 1 deletion addons/talo/apis/players_api.gd
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ func merge(player_id1: String, player_id2: String) -> TaloPlayer:

match (res.status):
200:
return res.body.player
return TaloPlayer.new(res.body.player)
_:
return null
30 changes: 15 additions & 15 deletions addons/talo/entities/entity_with_props.gd
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,26 @@ class_name TaloEntityWithProps extends Node
var props: Array[TaloProp] = []

func _init(props: Array) -> void:
self.props.assign(props)
self.props.assign(props)

func get_prop(key: String, fallback: String = "") -> String:
var filtered = props.filter(func (prop: TaloProp): return prop.key == key && prop.value != null)
return fallback if filtered.is_empty() else filtered.front().value
var filtered = props.filter(func (prop: TaloProp): return prop.key == key && prop.value != null)
return fallback if filtered.is_empty() else filtered.front().value

func set_prop(key: String, value: String) -> void:
var filtered = props.filter(func (prop: TaloProp): return prop.key == key)
if filtered.is_empty():
props.push_back(TaloProp.new(key, value))
else:
filtered.front().value = value
var filtered = props.filter(func (prop: TaloProp): return prop.key == key)
if filtered.is_empty():
props.push_back(TaloProp.new(key, value))
else:
filtered.front().value = value

func delete_prop(key: String) -> void:
props.assign(props.map(
func (prop: TaloProp):
if prop.key == key:
prop.value = null
return prop
))
props.assign(props.map(
func (prop: TaloProp):
if prop.key == key:
prop.value = null
return prop
))

func get_serialized_props() -> Array:
return props.map(func (prop: TaloProp): return prop.to_dictionary())
return props.map(func (prop: TaloProp): return prop.to_dictionary())
14 changes: 7 additions & 7 deletions addons/talo/entities/feedback_category.gd
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ var created_at: String
var updated_at: String

func _init(data: Dictionary):
id = data.id
internal_name = data.internalName
display_name = data.name
description = data.description
anonymised = data.anonymised
created_at = data.createdAt
updated_at = data.updatedAt
id = data.id
internal_name = data.internalName
display_name = data.name
description = data.description
anonymised = data.anonymised
created_at = data.createdAt
updated_at = data.updatedAt
14 changes: 7 additions & 7 deletions addons/talo/entities/leaderboard_entry.gd
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ var created_at: String
var updated_at: String

func _init(data: Dictionary):
super._init(data.props.map(func (prop): return TaloProp.new(prop.key, prop.value)))
super._init(data.props.map(func (prop): return TaloProp.new(prop.key, prop.value)))

id = data.id
position = data.position
score = data.score
player_alias = TaloPlayerAlias.new(data.playerAlias)
created_at = data.createdAt
updated_at = data.updatedAt
id = data.id
position = data.position
score = data.score
player_alias = TaloPlayerAlias.new(data.playerAlias)
created_at = data.createdAt
updated_at = data.updatedAt
6 changes: 3 additions & 3 deletions addons/talo/entities/live_config.gd
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ class_name TaloLiveConfig extends Node
var props: Array[TaloProp] = []

func _init(props: Array):
self.props.assign(props.map(func (prop): return TaloProp.new(prop.key, prop.value)))
self.props.assign(props.map(func (prop): return TaloProp.new(prop.key, prop.value)))

func get_prop(key: String, fallback: String) -> String:
var filtered = props.filter(func (prop: TaloProp): return prop.key == key)
return fallback if filtered.is_empty() else filtered.front()
var filtered = props.filter(func (prop: TaloProp): return prop.key == key)
return fallback if filtered.is_empty() else filtered.front()
54 changes: 27 additions & 27 deletions addons/talo/entities/loadable.gd
Original file line number Diff line number Diff line change
Expand Up @@ -4,51 +4,51 @@ class_name TaloLoadable extends Node
var _saved_fields: Dictionary

func _ready() -> void:
Talo.saves.save_chosen.connect(_load_data)
Talo.saves.register(self)
Talo.saves.save_chosen.connect(_load_data)
Talo.saves.register(self)

func _load_data(save: TaloGameSave) -> void:
if not save:
return
if not save:
return

var fields = {}
var fields = {}

var filtered = save.content.objects.filter(func (obj: Dictionary): return obj.id == id)
if filtered.is_empty():
push_warning("Loadable with id '%s' not found in save '%s'" % [id, save.display_name])
return
var filtered = save.content.objects.filter(func (obj: Dictionary): return obj.id == id)
if filtered.is_empty():
push_warning("Loadable with id '%s' not found in save '%s'" % [id, save.display_name])
return

var saved_object = filtered.front()
var saved_object = filtered.front()

for item in saved_object.data:
fields[item.key] = type_convert(item.value, int(item.type))
for item in saved_object.data:
fields[item.key] = type_convert(item.value, int(item.type))

on_loaded(fields)
on_loaded(fields)

Talo.saves.set_object_loaded(id)
Talo.saves.set_object_loaded(id)

func clear_saved_fields() -> void:
_saved_fields.clear()
_saved_fields.clear()

func register_fields() -> void:
assert(false, "register_fields() must be implemented")
assert(false, "register_fields() must be implemented")

func register_field(key: String, value: Variant) -> void:
_saved_fields[key] = value
_saved_fields[key] = value

func on_loaded(data: Dictionary) -> void:
assert(false, "on_loaded() must be implemented")
assert(false, "on_loaded() must be implemented")

func handle_destroyed(data: Dictionary) -> bool:
var destroyed = data.has("meta.destroyed")
if destroyed:
queue_free()
var destroyed = data.has("meta.destroyed")
if destroyed:
queue_free()

return destroyed
return destroyed

func get_saved_object_data() -> Array:
return _saved_fields.keys().map(
func (key: String):
var value = _saved_fields[key]
return {key = key, value = str(value), type = str(typeof(value))}
)
return _saved_fields.keys().map(
func (key: String):
var value = _saved_fields[key]
return {key = key, value = str(value), type = str(typeof(value))}
)
24 changes: 12 additions & 12 deletions addons/talo/entities/player.gd
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
class_name TaloPlayer extends TaloEntityWithProps

var id: String
var groups: Array[TaloGroup] = []
var groups: Array[TaloPlayerGroupStub] = []

func _init(data: Dictionary):
super._init(data.props.map(func (prop): return TaloProp.new(prop.key, prop.value)))
super._init(data.props.map(func (prop): return TaloProp.new(prop.key, prop.value)))

id = data.id
groups.assign(data.groups.map(func (group): return TaloGroup.new(group.id, group.name)))
id = data.id
groups.assign(data.groups.map(func (group): return TaloPlayerGroupStub.new(group.id, group.name)))

func set_prop(key: String, value: String, update: bool = true) -> void:
super.set_prop(key, value)
if update:
await Talo.players.update()
super.set_prop(key, value)
if update:
await Talo.players.update()

func delete_prop(key: String, update: bool = true) -> void:
super.delete_prop(key)
if update:
await Talo.players.update()
super.delete_prop(key)
if update:
await Talo.players.update()

func is_in_talo_group_id(group_id: String) -> bool:
return not groups.filter(func (group: TaloGroup): return group.id == group_id).is_empty()
return not groups.filter(func (group: TaloPlayerGroupStub): return group.id == group_id).is_empty()

func is_in_talo_group_name(group_name: String) -> bool:
return not groups.filter(func (group: TaloGroup): return group.name == group_name).is_empty()
return not groups.filter(func (group: TaloPlayerGroupStub): return group.name == group_name).is_empty()
25 changes: 25 additions & 0 deletions addons/talo/entities/player_group.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
class_name TaloPlayerGroup extends Node

var id: String
var display_name: String
var description: String
var rules: Array
var rule_mode: String
var members_visible: bool
var count: int
var members: Array[TaloPlayer]
var updated_at: String

func _init(data: Dictionary):
id = data.id
display_name = data.name
description = data.description
rules = data.rules
rule_mode = data.ruleMode
members_visible = data.membersVisible
count = data.count
if data.has("members"):
members.assign(data.members.map(func (member): return TaloPlayer.new(member)))
else:
members = []
updated_at = data.updatedAt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class_name TaloGroup extends Node
class_name TaloPlayerGroupStub extends Node

var id: String
var display_name: String
Expand Down
26 changes: 13 additions & 13 deletions addons/talo/entities/saved_object.gd
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@ var object_name: String
var loadable: TaloLoadable

func _init(loadable: TaloLoadable) -> void:
id = loadable.id
object_name = loadable.get_path()
self.loadable = loadable
id = loadable.id
object_name = loadable.get_path()
self.loadable = loadable

func register_loadable_fields():
if is_instance_valid(loadable):
loadable.clear_saved_fields()
loadable.register_fields()
if is_instance_valid(loadable):
loadable.clear_saved_fields()
loadable.register_fields()

func to_dictionary() -> Dictionary:
register_loadable_fields()
register_loadable_fields()

var destroyed_data = [{ key = "meta.destroyed", value = str(true), type = str(TYPE_BOOL) }]
var destroyed_data = [{ key = "meta.destroyed", value = str(true), type = str(TYPE_BOOL) }]

return {
id = id,
name = object_name,
data = destroyed_data if not is_instance_valid(loadable) else loadable.get_saved_object_data()
}
return {
id = id,
name = object_name,
data = destroyed_data if not is_instance_valid(loadable) else loadable.get_saved_object_data()
}
2 changes: 1 addition & 1 deletion addons/talo/plugin.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
name="Talo Game Services"
description="Talo (https://trytalo.com) is an open-source game backend with services designed to help you build games faster. You can currently:\n\n- Identify and authenticate players\n- Store persistent data across players\n- Track events (levelling up, finding loot, etc)\n- Display high scores with leaderboards\n- Store and load player saves\n- Load game config options and flags from the cloud\n- Get feedback directly from your players"
author="trytalo"
version="0.10.1"
version="0.11.0"
script="talo_autoload.gd"
46 changes: 23 additions & 23 deletions addons/talo/samples/authentication/scripts/authentication.gd
Original file line number Diff line number Diff line change
Expand Up @@ -12,38 +12,38 @@ extends Node2D
@onready var all_states = %States

func _ready() -> void:
_configure_signals()
_make_state_visible(login)
_configure_signals()
_make_state_visible(login)

func _make_state_visible(state: Node2D):
for child in all_states.get_children():
child.visible = child == state
for child in all_states.get_children():
child.visible = child == state

func _configure_signals():
login.verification_required.connect(func (): _make_state_visible(verify))
login.go_to_forgot_password.connect(func (): _make_state_visible(forgot_password))
login.go_to_register.connect(func (): _make_state_visible(register))
login.verification_required.connect(func (): _make_state_visible(verify))
login.go_to_forgot_password.connect(func (): _make_state_visible(forgot_password))
login.go_to_register.connect(func (): _make_state_visible(register))

register.go_to_login.connect(func (): _make_state_visible(login))
register.go_to_login.connect(func (): _make_state_visible(login))

in_game.go_to_change_password.connect(func (): _make_state_visible(change_password))
in_game.go_to_change_email.connect(func (): _make_state_visible(change_email))
in_game.go_to_delete.connect(func (): _make_state_visible(delete_account))
in_game.logout_success.connect(func (): _make_state_visible(login))
in_game.go_to_change_password.connect(func (): _make_state_visible(change_password))
in_game.go_to_change_email.connect(func (): _make_state_visible(change_email))
in_game.go_to_delete.connect(func (): _make_state_visible(delete_account))
in_game.logout_success.connect(func (): _make_state_visible(login))

change_password.password_change_success.connect(func (): _make_state_visible(in_game))
change_password.go_to_game.connect(func (): _make_state_visible(in_game))
change_password.password_change_success.connect(func (): _make_state_visible(in_game))
change_password.go_to_game.connect(func (): _make_state_visible(in_game))

change_email.email_change_success.connect(func (): _make_state_visible(in_game))
change_email.go_to_game.connect(func (): _make_state_visible(in_game))
change_email.email_change_success.connect(func (): _make_state_visible(in_game))
change_email.go_to_game.connect(func (): _make_state_visible(in_game))

forgot_password.forgot_password_success.connect(func (): _make_state_visible(reset_password))
forgot_password.go_to_login.connect(func (): _make_state_visible(login))
forgot_password.forgot_password_success.connect(func (): _make_state_visible(reset_password))
forgot_password.go_to_login.connect(func (): _make_state_visible(login))

reset_password.password_reset_success.connect(func (): _make_state_visible(login))
reset_password.go_to_forgot_password.connect(func (): _make_state_visible(forgot_password))
reset_password.password_reset_success.connect(func (): _make_state_visible(login))
reset_password.go_to_forgot_password.connect(func (): _make_state_visible(forgot_password))

delete_account.delete_account_success.connect(func (): _make_state_visible(login))
delete_account.go_to_game.connect(func (): _make_state_visible(in_game))
delete_account.delete_account_success.connect(func (): _make_state_visible(login))
delete_account.go_to_game.connect(func (): _make_state_visible(in_game))

Talo.players.identified.connect(func (player): _make_state_visible(in_game))
Talo.players.identified.connect(func (player): _make_state_visible(in_game))
Loading

0 comments on commit effad38

Please sign in to comment.