Skip to content

Commit

Permalink
Send correct team rating to SPADS
Browse files Browse the repository at this point in the history
  • Loading branch information
L-e-x-o-n committed Jun 4, 2024
1 parent 6c8b614 commit 3a92dcb
Showing 1 changed file with 9 additions and 18 deletions.
27 changes: 9 additions & 18 deletions lib/teiserver_web/controllers/api/spads_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ defmodule TeiserverWeb.API.SpadsController do

target_id = int_parse(target_id_str)
lobby = get_member_lobby(target_id)
host_ip = get_lobby_host_ip(lobby)
host_ip = case lobby do
nil -> nil
_ -> Account.get_client_by_id(lobby.founder_id).ip
end

actual_type =
case type do
Expand Down Expand Up @@ -219,32 +222,20 @@ defmodule TeiserverWeb.API.SpadsController do
end
end

def get_member_of_lobby_host_ip(nil), do: nil
defp get_member_lobby(nil), do: nil

def get_member_lobby(userid) do
@spec get_member_lobby(non_neg_integer()) :: T.lobby() | nil
defp get_member_lobby(userid) do
case Account.get_client_by_id(userid) do
nil ->
nil

client ->
Battle.get_lobby(userid)
end
end

def get_lobby_host_ip(nil), do: nil

def get_lobby_host_ip(lobby_id) do
case Battle.get_lobby(lobby_id) do
nil ->
nil

lobby ->
host = Account.get_client_by_id(lobby.founder_id)
host.ip
Battle.get_lobby(client.lobby_id)
end
end

def get_lobby_host_ip(nil), do: "Big Team"
defp get_team_subtype(nil), do: "Big Team"

defp get_team_subtype(lobby) do
teams =
Expand Down

0 comments on commit 3a92dcb

Please sign in to comment.