8000 Use := operator more by tudddorrr · Pull Request #93 · TaloDev/godot · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
8000

Use := operator more #93

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 25, 2025
Merged
Show file tree
Hide file tree
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
18 changes: 9 additions & 9 deletions addons/talo/apis/channels_api.gd
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func _on_message_received(res: String, data: Dictionary) -> void:

## Get a channel by its ID.
func find(channel_id: int) -> TaloChannel:
var res = await client.make_request(HTTPClient.METHOD_GET, "/%s" % channel_id)
var res := await client.make_request(HTTPClient.METHOD_GET, "/%s" % channel_id)

match res.status:
200:
Expand All @@ -46,7 +46,7 @@ func find(channel_id: int) -> TaloChannel:

## Get a list of channels that players can join.
func get_channels(page: int) -> ChannelPage:
var res = await client.make_request(HTTPClient.METHOD_GET, "?page=%s" % page)
var res := await client.make_request(HTTPClient.METHOD_GET, "?page=%s" % page)

match res.status:
200:
Expand All @@ -61,7 +61,7 @@ func get_subscribed_channels() -> Array[TaloChannel]:
if Talo.identity_check() != OK:
return []

var res = await client.make_request(HTTPClient.METHOD_GET, "/subscriptions")
var res := await client.make_request(HTTPClient.METHOD_GET, "/subscriptions")

match res.status:
200:
Expand All @@ -76,9 +76,9 @@ func create(name: String, auto_cleanup: bool = false, props: Dictionary = {}) ->
if Talo.identity_check() != OK:
return

var props_to_send = props.keys().map(func (key: String): return { key = key, value = str(props[key]) })
var props_to_send := props.keys().map(func (key: String): return { key = key, value = str(props[key]) })

var res = await client.make_request(HTTPClient.METHOD_POST, "", {
var res := await client.make_request(HTTPClient.METHOD_POST, "", {
name = name,
autoCleanup = auto_cleanup,
props = props_to_send
Expand All @@ -95,7 +95,7 @@ func join(channel_id: int) -> TaloChannel:
if Talo.identity_check() != OK:
return

var res = await client.make_request(HTTPClient.METHOD_POST, "/%s/join" % channel_id)
var res := await client.make_request(HTTPClient.METHOD_POST, "/%s/join" % channel_id)

match res.status:
200:
Expand All @@ -115,15 +115,15 @@ func update(channel_id: int, name: String = "", new_owner_alias_id: int = -1, pr
if Talo.identity_check() != OK:
return

var data = {}
var data := {}
if not name.is_empty():
data.name = name
if new_owner_alias_id != -1:
data.ownerAliasId = new_owner_alias_id
if props.size() > 0:
data.props = props

var res = await client.make_request(HTTPClient.METHOD_PUT, "/%s" % channel_id, data)
var res := await client.make_request(HTTPClient.METHOD_PUT, "/%s" % channel_id, data)

match res.status:
200:
Expand All @@ -139,7 +139,7 @@ func delete(channel_id: int) -> void:
if Talo.identity_check() != OK:
return

var res = await client.make_request(HTTPClient.METHOD_DELETE, "/%s" % channel_id)
var res := await client.make_request(HTTPClient.METHOD_DELETE, "/%s" % channel_id)

match res.status:
403:
Expand Down
8 changes: 4 additions & 4 deletions addons/talo/apis/events_api.gd
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ class_name EventsAPI extends TaloAPI
##
## @tutorial: https://docs.trytalo.com/docs/godot/events

var _queue = []
var _min_queue_size = 10
var _queue: = []
var _min_queue_size := 10

func _get_window_mode() -> String:
match DisplayServer.window_get_mode():
Expand Down Expand Up @@ -36,7 +36,7 @@ func track(name: String, props: Dictionary = {}) -> void:
if Talo.identity_check() != OK:
return

var final_props = _build_meta_props()
var final_props := _build_meta_props()
final_props.append_array(
props
.keys()
Expand All @@ -57,7 +57,7 @@ func flush() -> void:
if _queue.size() == 0:
return

var res = await client.make_request(HTTPClient.METHOD_POST, "/", { events = _queue })
var res := await client.make_request(HTTPClient.METHOD_POST, "/", { events = _queue })
_queue.clear()

match res.status:
Expand Down
2 changes: 1 addition & 1 deletion addons/talo/apis/feedback_api.gd
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class_name FeedbackAPI extends TaloAPI

## Get a list of feedback categories that are available for players to submit feedback.
func get_categories() -> Array[TaloFeedbackCategory]:
var res = await client.make_request(HTTPClient.METHOD_GET, "/categories")
var res := await client.make_request(HTTPClient.METHOD_GET, "/categories")

match res.status:
200:
Expand Down
2 changes: 1 addition & 1 deletion addons/talo/apis/game_config_api.gd
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func _on_message_received(res: String, data: Dictionary) -> void:

## Get the live config for your game.
func get_live_config() -> TaloLiveConfig:
var res = await client.make_request(HTTPClient.METHOD_GET, "/")
var res := await client.make_request(HTTPClient.METHOD_GET, "/")
match res.status:
200:
Talo.live_config = TaloLiveConfig.new(res.body.config)
Expand Down
2 changes: 1 addition & 1 deletion addons/talo/apis/health_check_api.gd
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ class_name HealthCheckAPI extends TaloAPI

## Ping the Talo Health Check API to check if Talo can be reached.
func ping() -> bool:
var res = await client.make_request(HTTPClient.METHOD_GET, "")
var res := await client.make_request(HTTPClient.METHOD_GET, "")
return res.status == 204
12 changes: 6 additions & 6 deletions addons/talo/apis/leaderboards_api.gd
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class_name LeaderboardsAPI extends TaloAPI
##
## @tutorial: https://docs.trytalo.com/docs/godot/leaderboards

var _entries_manager = TaloLeaderboardEntriesManager.new()
var _entries_manager := TaloLeaderboardEntriesManager.new()

## Get a list of all the entries that have been previously fetched or created for a leaderboard.
func get_cached_entries(internal_name: String) -> Array:
Expand All @@ -23,8 +23,8 @@ func get_cached_entries_for_current_player(internal_name: String) -> Array:

## Get a list of entries for a leaderboard. The page parameter is used for pagination.
func get_entries(internal_name: String, page: int, alias_id = -1, include_archived = false) -> EntriesPage:
var url = "/%s/entries?page=%s"
var url_data = [internal_name, page]
var url := "/%s/entries?page=%s"
var url_data := [internal_name, page]

if alias_id != -1:
url += "&aliasId=%s"
Expand All @@ -33,13 +33,13 @@ func get_entries(internal_name: String, page: int, alias_id = -1, include_archiv
if include_archived:
url += "&withDeleted=1"

var res = await client.make_request(HTTPClient.METHOD_GET, url % url_data)
var res := await client.make_request(HTTPClient.METHOD_GET, url % url_data)

match res.status:
200:
var entries: Array[TaloLeaderboardEntry] = Array(res.body.entries.map(
func(data: Dictionary):
var entry = TaloLeaderboardEntry.new(data)
var entry := TaloLeaderboardEntry.new(data)
_entries_manager.upsert_entry(internal_name, entry)

return entry
Expand All @@ -60,7 +60,7 @@ func add_entry(internal_name: String, score: float, props: Dictionary = {}) -> A
if Talo.identity_check() != OK:
return null

var props_to_send: Array = props.keys().map(func(key: String) -> Dictionary: return {key = key, value = str(props[key])})
var props_to_send := props.keys().map(func(key: String) -> Dictionary: return {key = key, value = str(props[key])})

var res := await client.make_request(HTTPClient.METHOD_POST, "/%s/entries" % internal_name, {
score = score,
Expand Down
20 changes: 10 additions & 10 deletions addons/talo/apis/player_auth_api.gd
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ enum LoginResult {
VERIFICATION_REQUIRED,
}

var session_manager = TaloSessionManager.new()
var session_manager := TaloSessionManager.new()
var last_error: TaloAuthError = null

func _handle_error(res: Dictionary, ret: Variant = FAILED) -> Variant:
Expand All @@ -28,7 +28,7 @@ func register(identifier: String, password: String, email: String = "", verifica
push_error("Email is required when verification is enabled")
return FAILED

var res = await client.make_request(HTTPClient.METHOD_POST, "/register", {
var res := await client.make_request(HTTPClient.METHOD_POST, "/register", {
identifier = identifier,
password = password,
email = email,
Expand All @@ -44,7 +44,7 @@ func register(identifier: String, password: String, email: String = "", verifica

## Log in to an existing player account. If verification is required, a verification code will be sent to the player's email.
func login(identifier: String, password: String) -> LoginResult:
var res = await client.make_request(HTTPClient.METHOD_POST, "/login", {
var res := await client.make_request(HTTPClient.METHOD_POST, "/login", {
identifier = identifier,
password = password
})
Expand All @@ -65,7 +65,7 @@ func login(identifier: String, password: String) -> LoginResult:

## Verify a player account using the verification code sent to the player's email.
func verify(verification_code: String) -> Error:
var res = await client.make_request(HTTPClient.METHOD_POST, "/verify", {
var res := await client.make_request(HTTPClient.METHOD_POST, "/verify", {
aliasId = session_manager.get_verification_alias_id(),
code = verification_code
})
Expand All @@ -85,7 +85,7 @@ func logout() -> void:

## Change the password of the current player account.
func change_password(current_password: String, new_password: String) -> Error:
var res = await client.make_request(HTTPClient.METHOD_POST, "/change_password", {
var res := await client.make_request(HTTPClient.METHOD_POST, "/change_password", {
currentPassword = current_password,
newPassword = new_password
})
Expand All @@ -98,7 +98,7 @@ func change_password(current_password: String, new_password: String) -> Error:

## Change the email of the current player account.
func change_email(current_password: String, new_email: String) -> Error:
var res = await client.make_request(HTTPClient.METHOD_POST, "/change_email", {
var res := await client.make_request(HTTPClient.METHOD_POST, "/change_email", {
currentPassword = current_password,
newEmail = new_email
})
Expand All @@ -111,7 +111,7 @@ func change_email(current_password: String, new_email: String) -> Error:

## Send a password reset email to the player's email.
func forgot_password(email: String) -> Error:
var res = await client.make_request(HTTPClient.METHOD_POST, "/forgot_password", {
var res := await client.make_request(HTTPClient.METHOD_POST, "/forgot_password", {
email = email
})

Expand All @@ -123,7 +123,7 @@ func forgot_password(email: String) -> Error:

## Reset the password of the player account using the code sent to the player's email.
func reset_password(code: String, password: String) -> Error:
var res = await client.make_request(HTTPClient.METHOD_POST, "/reset_password", {
var res := await client.make_request(HTTPClient.METHOD_POST, "/reset_password", {
code = code,
password = password
})
Expand All @@ -136,7 +136,7 @@ func reset_password(code: String, password: String) -> Error:

## Toggle email verification for the current player account.
func toggle_verification(current_password: String, verification_enabled: bool, email: String = "") -> Error:
var res = await client.make_request(HTTPClient.METHOD_PATCH, "/toggle_verification", {
var res := await client.make_request(HTTPClient.METHOD_PATCH, "/toggle_verification", {
currentPassword = current_password,
verificationEnabled = verification_enabled,
email = email
Expand All @@ -150,7 +150,7 @@ func toggle_verification(current_password: String, verification_enabled: bool, e

## Delete the current player account.
func delete_account(current_password: String) -> Error:
var res = await client.make_request(HTTPClient.METHOD_DELETE, "/", {
var res := await client.make_request(HTTPClient.METHOD_DELETE, "/", {
currentPassword = current_password
})

Expand Down
2 changes: 1 addition & 1 deletion addons/talo/apis/player_groups_api.gd
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class_name PlayerGroupsAPI extends TaloAPI

## Get the members of a group. If the group is public (as set in the dashboard), the members will be returned. If the group is private, only a membership count will be returned.
func get_group(group_id: String) -> TaloPlayerGroup:
var res = await client.make_request(HTTPClient.METHOD_GET, "/%s" % group_id)
var res := await client.make_request(HTTPClient.METHOD_GET, "/%s" % group_id)

match res.status:
200:
Expand Down
4 changes: 2 additions & 2 deletions addons/talo/apis/player_presence_api.gd
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func _on_message_received(res: String, data: Dictionary) -> void:

## Get the presence status for a specific player.
func get_presence(player_id: String) -> TaloPlayerPresence:
var res = await client.make_request(HTTPClient.METHOD_GET, "/%s" % player_id)
var res := await client.make_request(HTTPClient.METHOD_GET, "/%s" % player_id)

match res.status:
200:
Expand All @@ -32,7 +32,7 @@ func update_presence(online: bool, custom_status: String = "") -> TaloPlayerPres
if Talo.identity_check() != OK:
return null

var res = await client.make_request(HTTPClient.METHOD_PUT, "", {
var res := await client.make_request(HTTPClient.METHOD_PUT, "", {
>
customStatus = custom_status
})
Expand Down
14 changes: 7 additions & 7 deletions addons/talo/apis/players_api.gd
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ signal identified(player: TaloPlayer)

## Identify a player using a service (e.g. "username") and identifier (e.g. "bob").
func identify(service: String, identifier: String) -> TaloPlayer:
var res = await client.make_request(HTTPClient.METHOD_GET, "/identify?service=%s&identifier=%s" % [service, identifier])
var res := await client.make_request(HTTPClient.METHOD_GET, "/identify?service=%s&identifier=%s" % [service, identifier])
match res.status:
200:
Talo.current_alias = TaloPlayerAlias.new(res.body.alias)
Expand All @@ -31,7 +31,7 @@ func identify_steam(ticket: String, identity: String = "") -> TaloPlayer:

## Flush and sync the player's current data with Talo.
func update() -> TaloPlayer:
var res = await client.make_request(HTTPClient.METHOD_PATCH, "/%s" % Talo.current_player.id, { props = Talo.current_player.get_serialized_props() })
var res := await client.make_request(HTTPClient.METHOD_PATCH, "/%s" % Talo.current_player.id, { props = Talo.current_player.get_serialized_props() })
match res.status:
200:
if is_instance_valid(Talo.current_alias.player):
Expand All @@ -44,7 +44,7 @@ func update() -> TaloPlayer:

## Merge all of the data from player_id2 into player_id1 and delete player_id2.
func merge(player_id1: String, player_id2: String) -> TaloPlayer:
var res = await client.make_request(HTTPClient.METHOD_POST, "/merge", {
var res := await client.make_request(HTTPClient.METHOD_POST, "/merge", {
playerId1 = player_id1,
playerId2 = player_id2
})
Expand All @@ -57,7 +57,7 @@ func merge(player_id1: String, player_id2: String) -> TaloPlayer:

## Get a player by their ID.
func find(player_id: String) -> TaloPlayer:
var res = await client.make_request(HTTPClient.METHOD_GET, "/%s" % player_id)
var res := await client.make_request(HTTPClient.METHOD_GET, "/%s" % player_id)
match res.status:
200:
return TaloPlayer.new(res.body.player)
Expand All @@ -66,7 +66,7 @@ func find(player_id: String) -> TaloPlayer:

## Generate a mostly-unique identifier.
func generate_identifier() -> String:
var time_hash: String = str(TaloTimeUtils.get_timestamp_msec()).sha256_text()
var size = 12
var split_start: int = RandomNumberGenerator.new().randi_range(0, time_hash.length() - size)
var time_hash := str(TaloTimeUtils.get_timestamp_msec()).sha256_text()
var size := 12
var split_start := RandomNumberGenerator.new().randi_range(0, time_hash.length() - size)
return time_hash.substr(split_start, size)
Loading
0