Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions addons/talo/apis/leaderboards_api.gd
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func get_entries(internal_name: String, options := GetEntriesOptions.new()) -> E
## Add an entry to a leaderboard. The props (key-value pairs) parameter is used to store additional data with the entry.
func add_entry(internal_name: String, score: float, props: Dictionary[String, Variant] = {}) -> AddEntryResult:
if Talo.identity_check() != OK:
return AddEntryResult.new(null, false)
return AddEntryResult.new(false, null, false)

var res := await client.make_request(HTTPClient.METHOD_POST, "/%s/entries" % internal_name, {
score = score,
Expand All @@ -85,12 +85,12 @@ func add_entry(internal_name: String, score: float, props: Dictionary[String, Va
var entry := TaloLeaderboardEntry.new(res.body.entry)
_entries_manager.upsert_entry(internal_name, entry, true)

return AddEntryResult.new(entry, res.body.updated)
return AddEntryResult.new(true, entry, res.body.updated)
400:
var rejected_props := TaloRejectedProp.from_response(res.body)
return AddEntryResult.new(null, false, rejected_props)
return AddEntryResult.new(false, null, false, rejected_props)
_:
return AddEntryResult.new(null, false)
return AddEntryResult.new(false, null, false)

class EntriesPage:
var entries: Array[TaloLeaderboardEntry]
Expand All @@ -105,11 +105,13 @@ class EntriesPage:
self.is_last_page = is_last_page

class AddEntryResult:
var success: bool
var entry: TaloLeaderboardEntry
var updated: bool
var rejected_props: Array[TaloRejectedProp]

func _init(entry: TaloLeaderboardEntry, updated: bool, rejected_props: Array[TaloRejectedProp] = []) -> void:
func _init(result_success: bool, entry: TaloLeaderboardEntry, updated: bool, rejected_props: Array[TaloRejectedProp] = []) -> void:
self.success = result_success
self.entry = entry
self.updated = updated
self.rejected_props = rejected_props
Expand Down