Skip to content

Commit 84ada24

Browse files
Mikkel Sørensenkirre-bylund
authored andcommitted
Add the hero requests and calls
1 parent d4ee99c commit 84ada24

File tree

2 files changed

+582
-89
lines changed

2 files changed

+582
-89
lines changed

Runtime/Game/LootLockerSDKManager.cs

Lines changed: 288 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ public static void StartGoogleSession(string idToken, Action<LootLockerGoogleSes
477477
onComplete(response);
478478
});
479479
}
480-
480+
481481
/// <summary>
482482
/// Start a Game session for a Google User
483483
/// The Google sign in platform must be enabled in the web console for this to work.
@@ -1139,94 +1139,6 @@ public static void WhiteLabelLoginAndStartSession(string email, string password,
11391139

11401140
#endregion
11411141

1142-
#if LOOTLOCKER_ENABLE_ACCOUNT_LINKING
1143-
1144-
#region Account Linking
1145-
1146-
/// <summary>
1147-
/// Start an account linking process on behalf of the currently signed in player
1148-
/// When you want to link an additional provider to a player, you start by initiating an account link.The player can then navigate to the online link flow using the code_page_url and code, or the qr_code and continue the linking process.
1149-
/// For the duration of the linking process you can check the status using the CheckAccountLinkingProcessStatus method.
1150-
/// Returned from this method is the ID of the linking process, make sure to save that so that you can check the status of the process later.
1151-
/// https://ref.lootlocker.com/game-api/#start-account-link
1152-
/// </summary>
1153-
/// <param name="onComplete">onComplete Action for handling the response of type LootLockerAccountLinkStartResponse</param>
1154-
public static void StartAccountLinkingProcess(Action<LootLockerAccountLinkStartResponse> onComplete)
1155-
{
1156-
if (!CheckInitialized())
1157-
{
1158-
onComplete?.Invoke(LootLockerResponseFactory.SDKNotInitializedError<LootLockerAccountLinkStartResponse>());
1159-
return;
1160-
}
1161-
1162-
var endpoint = LootLockerEndPoints.StartAccountLinkingProcess;
1163-
1164-
LootLockerServerRequest.CallAPI(endpoint.endPoint, endpoint.httpMethod, onComplete: (serverResponse) => { LootLockerResponse.Deserialize(onComplete, serverResponse); });
1165-
}
1166-
1167-
/// <summary>
1168-
/// Check the status of an ongoing account linking process
1169-
/// https://ref.lootlocker.com/game-api/#check-account-link-status
1170-
/// </summary>
1171-
/// <param name="LinkID">The ID of the account linking process which was returned when starting the linking process</param>
1172-
/// <param name="onComplete">onComplete Action for handling the response of type LootLockerAccountLinkProcessStatusResponse</param>
1173-
public static void CheckAccountLinkingProcessStatus(string LinkID, Action<LootLockerAccountLinkProcessStatusResponse> onComplete)
1174-
{
1175-
if (!CheckInitialized())
1176-
{
1177-
onComplete?.Invoke(LootLockerResponseFactory.SDKNotInitializedError<LootLockerAccountLinkProcessStatusResponse>());
1178-
return;
1179-
}
1180-
1181-
var endpoint = LootLockerEndPoints.CheckAccountLinkingProcessStatus;
1182-
1183-
LootLockerServerRequest.CallAPI(string.Format(endpoint.endPoint, LinkID), endpoint.httpMethod, onComplete: (serverResponse) => { LootLockerResponse.Deserialize(onComplete, serverResponse); });
1184-
}
1185-
1186-
/// <summary>
1187-
/// Cancel an ongoing account linking process
1188-
/// The response will be empty unless an error occurs
1189-
/// https://ref.lootlocker.com/game-api/#cancel-account-link
1190-
/// </summary>
1191-
/// <param name="LinkID">The ID of the account linking process which was returned when starting the linking process</param>
1192-
/// <param name="onComplete">onComplete Action for handling the response of type LootLockerCancelAccountLinkingProcessResponse</param>
1193-
public static void CancelAccountLinkingProcess(string LinkID, Action<LootLockerCancelAccountLinkingProcessResponse> onComplete)
1194-
{
1195-
if (!CheckInitialized())
1196-
{
1197-
onComplete?.Invoke(LootLockerResponseFactory.SDKNotInitializedError<LootLockerCancelAccountLinkingProcessResponse>());
1198-
return;
1199-
}
1200-
1201-
var endpoint = LootLockerEndPoints.CancelAccountLinkingProcess;
1202-
1203-
LootLockerServerRequest.CallAPI(string.Format(endpoint.endPoint, LinkID), endpoint.httpMethod, onComplete: (serverResponse) => { LootLockerResponse.Deserialize(onComplete, serverResponse); });
1204-
}
1205-
1206-
/// <summary>
1207-
/// Unlink a provider from the currently signed in player
1208-
/// The response will be empty unless an error occurs
1209-
/// https://ref.lootlocker.com/game-api/#unlink-provider
1210-
/// </summary>
1211-
/// <param name="Provider">What provider to unlink from the currently logged in player</param>
1212-
/// <param name="onComplete">onComplete Action for handling the response of type LootLockerUnlinkProviderFromAccountResponse</param>
1213-
public static void UnlinkProviderFromAccount(Platforms Provider, Action<LootLockerUnlinkProviderFromAccountResponse> onComplete)
1214-
{
1215-
if (!CheckInitialized())
1216-
{
1217-
onComplete?.Invoke(LootLockerResponseFactory.SDKNotInitializedError<LootLockerUnlinkProviderFromAccountResponse>());
1218-
return;
1219-
}
1220-
1221-
var endpoint = LootLockerEndPoints.UnlinkProviderFromAccount;
1222-
1223-
LootLockerServerRequest.CallAPI(string.Format(endpoint.endPoint, CurrentPlatform.GetPlatformRepresentation(Provider).PlatformString), endpoint.httpMethod, onComplete: (serverResponse) => { LootLockerResponse.Deserialize(onComplete, serverResponse); });
1224-
}
1225-
1226-
#endregion
1227-
1228-
#endif
1229-
12301142
#region Player
12311143
/// <summary>
12321144
/// Get general information about the current current player, such as the XP, Level information and their account balance.
@@ -2165,6 +2077,293 @@ public static void RegisterPlayerProgression(string progressionKey, Action<LootL
21652077

21662078
#endregion
21672079

2080+
2081+
#region Hero
2082+
2083+
/// <summary>
2084+
/// Create a hero with the provided type and name. The hero will be owned by the currently active player.
2085+
/// </summary>
2086+
/// <param name="heroId">The id of the hero</param>
2087+
/// <param name="name">The new name for the hero</param>
2088+
/// <param name="isDefault">Should this hero be the default hero?</param>
2089+
/// <param name="onComplete">onComplete Action for handling the response of type LootLockerHeroLoadoutResponse</param>
2090+
public static void CreateHero(int heroId, string name, bool isDefault, Action<LootLockerHeroLoadoutResponse> onComplete)
2091+
{
2092+
if (!CheckInitialized())
2093+
{
2094+
2095+
onComplete?.Invoke(LootLockerResponseFactory.SDKNotInitializedError<LootLockerHeroLoadoutResponse>());
2096+
return;
2097+
}
2098+
LootLockerCreateHeroRequest data = new LootLockerCreateHeroRequest();
2099+
2100+
data.hero_id = heroId;
2101+
data.name = name;
2102+
data.is_default = isDefault;
2103+
2104+
2105+
LootLockerAPIManager.CreateHero(data, onComplete);
2106+
}
2107+
2108+
/// <summary>
2109+
/// List the heroes with names and character information
2110+
/// </summary>
2111+
/// <param name="onComplete">onComplete Action for handling the response of type LootLockerGameHeroResponse</param>
2112+
public static void GetGameHeroes(Action<LootLockerGameHeroResponse> onComplete)
2113+
{
2114+
if (!CheckInitialized())
2115+
{
2116+
onComplete?.Invoke(LootLockerResponseFactory.SDKNotInitializedError<LootLockerGameHeroResponse>());
2117+
return;
2118+
}
2119+
LootLockerAPIManager.GetGameHeroes(onComplete);
2120+
}
2121+
2122+
/// <summary>
2123+
/// List the heroes that the current player owns
2124+
/// </summary>
2125+
/// <param name="onComplete">onComplete Action for handling the response of type LootLockerPlayerHeroResponse</param>
2126+
public static void ListPlayerHeroes(Action<LootLockerListHeroResponse> onComplete)
2127+
{
2128+
if (!CheckInitialized())
2129+
{
2130+
onComplete?.Invoke(LootLockerResponseFactory.SDKNotInitializedError<LootLockerListHeroResponse>());
2131+
return;
2132+
}
2133+
2134+
LootLockerAPIManager.ListPlayerHeroes(onComplete);
2135+
}
2136+
2137+
/// <summary>
2138+
/// List player that the player with the specified SteamID64 owns
2139+
/// </summary>
2140+
/// <param name="steamID64">Steam id of the requested player</param>
2141+
/// <param name="onComplete">onComplete Action for handling the response of type LootLockerPlayerHeroResponse</param>
2142+
public static void ListOtherPlayersHeroesBySteamID64(int steamID64, Action<LootLockerPlayerHeroResponse> onComplete)
2143+
{
2144+
if (!CheckInitialized())
2145+
{
2146+
onComplete?.Invoke(LootLockerResponseFactory.SDKNotInitializedError<LootLockerPlayerHeroResponse>());
2147+
return;
2148+
}
2149+
2150+
LootLockerAPIManager.ListOtherPlayersHeroesBySteamID64(steamID64, onComplete);
2151+
}
2152+
2153+
/// <summary>
2154+
/// Create a hero for the current player with the supplied name from the game hero specified with the supplied hero id, asset variation id, and whether to set as default.
2155+
/// </summary>
2156+
/// <param name="name">The new name for the hero</param>
2157+
/// <param name="heroId">The id of the hero</param>
2158+
/// <param name="assetVariationId">ID of the asset variation to use</param>
2159+
/// <param name="isDefault">Should this hero be the default hero?</param>
2160+
/// <param name="onComplete">onComplete Action for handling the response of type LootLockerHeroLoadoutResponse</param>
2161+
public static void CreateHeroWithVariation(string name, int heroId, int assetVariationId, bool isDefault, Action<LootLockerHeroLoadoutResponse> onComplete)
2162+
{
2163+
if (!CheckInitialized())
2164+
{
2165+
onComplete?.Invoke(LootLockerResponseFactory.SDKNotInitializedError<LootLockerHeroLoadoutResponse>());
2166+
return;
2167+
}
2168+
2169+
LootLockerCreateHeroWithVariationRequest data = new LootLockerCreateHeroWithVariationRequest();
2170+
2171+
data.name = name;
2172+
data.hero_id = heroId;
2173+
data.asset_variation_id = assetVariationId;
2174+
data.is_default = isDefault;
2175+
2176+
LootLockerAPIManager.CreateHeroWithVariation(data, onComplete);
2177+
}
2178+
2179+
/// <summary>
2180+
/// Return information about the requested hero on the current player
2181+
/// </summary>
2182+
/// <param name="heroId">The id of the hero to get</param>
2183+
/// <param name="onComplete">onComplete Action for handling the response of type LootLockerPlayerHeroResponse</param>
2184+
public static void GetHero(int heroId, Action<LootLockerPlayerHeroResponse> onComplete)
2185+
{
2186+
if (!CheckInitialized())
2187+
{
2188+
onComplete?.Invoke(LootLockerResponseFactory.SDKNotInitializedError<LootLockerPlayerHeroResponse>());
2189+
return;
2190+
}
2191+
2192+
LootLockerAPIManager.GetHero(heroId, onComplete);
2193+
}
2194+
2195+
/// <summary>
2196+
/// Get the default hero for the player with the specified SteamID64
2197+
/// </summary>
2198+
/// <param name="steamId">Steam Id of the requested player</param>
2199+
/// <param name="onComplete">onComplete Action for handling the response of type LootLockerPlayerHeroResponse</param>
2200+
public static void GetOtherPlayersDefaultHeroBySteamID64(int steamId, Action<LootLockerPlayerHeroResponse> onComplete)
2201+
{
2202+
if (!CheckInitialized())
2203+
{
2204+
onComplete?.Invoke(LootLockerResponseFactory.SDKNotInitializedError<LootLockerPlayerHeroResponse>());
2205+
return;
2206+
}
2207+
2208+
LootLockerAPIManager.GetOtherPlayersDefaultHeroBySteamID64(steamId, onComplete);
2209+
2210+
}
2211+
2212+
/// <summary>
2213+
/// Update the name of the hero with the specified id and/or set it as default for the current player
2214+
/// </summary>
2215+
/// <param name="heroId">Id of the hero</param>
2216+
/// <param name="name">The new name for the hero</param>
2217+
/// <param name="isDefault">Should this hero be the default hero?</param>
2218+
/// <param name="onComplete">onComplete Action for handling the response of type LootLockerPlayerHeroResponse</param>
2219+
public static void UpdateHero(string heroId, string name, bool isDefault, Action<LootLockerPlayerHeroResponse> onComplete)
2220+
{
2221+
if (!CheckInitialized())
2222+
{
2223+
onComplete?.Invoke(LootLockerResponseFactory.SDKNotInitializedError<LootLockerPlayerHeroResponse>());
2224+
return;
2225+
}
2226+
2227+
LootLockerGetRequest lootLockerGetRequest = new LootLockerGetRequest();
2228+
2229+
lootLockerGetRequest.getRequests.Add(heroId);
2230+
2231+
LootLockerUpdateHeroRequest data = new LootLockerUpdateHeroRequest();
2232+
data.name = name;
2233+
data.is_default = isDefault;
2234+
2235+
2236+
LootLockerAPIManager.UpdateHero(lootLockerGetRequest, data, onComplete);
2237+
}
2238+
2239+
/// <summary>
2240+
/// Remove the hero with the specified id from the current players list of heroes.
2241+
/// </summary>
2242+
/// <param name="heroID">HeroID Id of the hero</param>
2243+
/// <param name="onComplete">onComplete Action for handling the response of type LootLockerPlayerHeroResponse</param>
2244+
public static void DeleteHero(int heroID, Action<LootLockerPlayerHeroResponse> onComplete)
2245+
{
2246+
if (!CheckInitialized())
2247+
{
2248+
onComplete?.Invoke(LootLockerResponseFactory.SDKNotInitializedError<LootLockerPlayerHeroResponse>());
2249+
return;
2250+
}
2251+
2252+
LootLockerAPIManager.DeleteHero(heroID, onComplete);
2253+
}
2254+
2255+
/// <summary>
2256+
/// List Asset Instances owned by the specified hero
2257+
/// </summary>
2258+
/// <param name="heroID">HeroID Id of the hero</param>
2259+
/// <param name="onComplete">onComplete Action for handling the response of type LootLockerInventoryResponse</param>
2260+
public static void GetHeroInventory(int heroID, Action<LootLockerInventoryResponse> onComplete)
2261+
{
2262+
if (!CheckInitialized())
2263+
{
2264+
onComplete?.Invoke(LootLockerResponseFactory.SDKNotInitializedError<LootLockerInventoryResponse>());
2265+
return;
2266+
}
2267+
2268+
LootLockerAPIManager.GetHeroInventory(heroID, onComplete);
2269+
}
2270+
2271+
/// <summary>
2272+
/// List the loadout of the specified hero that the current player owns
2273+
/// </summary>
2274+
/// <param name="onComplete">onComplete Action for handling the response of type LootLockerHeroLoadoutResponse</param>
2275+
public static void GetHeroLoadout(Action<LootLockerHeroLoadoutResponse> onComplete)
2276+
{
2277+
if (!CheckInitialized())
2278+
{
2279+
onComplete?.Invoke(LootLockerResponseFactory.SDKNotInitializedError<LootLockerHeroLoadoutResponse>());
2280+
return;
2281+
}
2282+
2283+
LootLockerAPIManager.GetHeroLoadout(onComplete);
2284+
}
2285+
2286+
/// <summary>
2287+
/// List the loadout of the specified hero that the another player owns
2288+
/// </summary>
2289+
/// <param name="heroID">HeroID Id of the hero</param>
2290+
/// <param name="onComplete">onComplete Action for handling the response of type LootLockerHeroLoadoutResponse</param>
2291+
public static void GetOtherPlayersHeroLoadout(int heroID, Action<LootLockerHeroLoadoutResponse> onComplete)
2292+
{
2293+
if (!CheckInitialized())
2294+
{
2295+
onComplete?.Invoke(LootLockerResponseFactory.SDKNotInitializedError<LootLockerHeroLoadoutResponse>());
2296+
return;
2297+
}
2298+
2299+
LootLockerAPIManager.GetOtherPlayersHeroLoadout(heroID, onComplete);
2300+
}
2301+
2302+
/// <summary>
2303+
/// Equip the specified Asset Instance to the specified Hero that the current player owns
2304+
/// </summary>
2305+
/// <param name="heroID">Id of the hero</param>
2306+
/// <param name="assetInstanceID">Id of the asset instance to give</param>
2307+
/// <param name="onComplete">onComplete Action for handling the response of type LootLockerHeroLoadoutResponse</param>
2308+
public static void AddAssetToHeroLoadout(int heroID, int assetInstanceID, Action<LootLockerHeroLoadoutResponse> onComplete)
2309+
{
2310+
if (!CheckInitialized())
2311+
{
2312+
onComplete?.Invoke(LootLockerResponseFactory.SDKNotInitializedError<LootLockerHeroLoadoutResponse>());
2313+
return;
2314+
}
2315+
2316+
LootLockerAddAssetToHeroLoadoutRequest data = new LootLockerAddAssetToHeroLoadoutRequest();
2317+
2318+
data.asset_instance_id = assetInstanceID;
2319+
data.hero_id = heroID;
2320+
2321+
2322+
LootLockerAPIManager.AddAssetToHeroLoadout(data, onComplete);
2323+
}
2324+
2325+
/// <summary>
2326+
///
2327+
/// </summary>
2328+
/// <param name="heroID">Id of the hero</param>
2329+
/// <param name="assetID">Id of the asset</param>
2330+
/// <param name="assetInstanceID">Id of the asset instance to give</param>
2331+
/// <param name="onComplete">onComplete Action for handling the response of type LootLockerHeroLoadoutResponse</param>
2332+
public static void AddAssetVariationToHeroLoadout(int heroID, int assetID, int assetInstanceID, Action<LootLockerHeroLoadoutResponse> onComplete)
2333+
{
2334+
if (!CheckInitialized())
2335+
{
2336+
onComplete?.Invoke(LootLockerResponseFactory.SDKNotInitializedError<LootLockerHeroLoadoutResponse>());
2337+
return;
2338+
}
2339+
2340+
LootLockerAddAssetVariationToHeroLoadoutRequest data = new LootLockerAddAssetVariationToHeroLoadoutRequest();
2341+
2342+
data.hero_id = heroID;
2343+
data.asset_id = assetID;
2344+
data.asset_variation_id = assetInstanceID;
2345+
2346+
LootLockerAPIManager.AddAssetVariationToHeroLoadout(data, onComplete);
2347+
}
2348+
2349+
public static void RemoveAssetFromHeroLoadout(string assetID, string heroID, Action<LootLockerHeroLoadoutResponse> onComplete)
2350+
{
2351+
if (!CheckInitialized())
2352+
{
2353+
onComplete?.Invoke(LootLockerResponseFactory.SDKNotInitializedError<LootLockerHeroLoadoutResponse>());
2354+
return;
2355+
}
2356+
2357+
LootLockerGetRequest lootLockerGetRequest = new LootLockerGetRequest();
2358+
2359+
lootLockerGetRequest.getRequests.Add(assetID);
2360+
lootLockerGetRequest.getRequests.Add(heroID);
2361+
2362+
LootLockerAPIManager.RemoveAssetFromHeroLoadout(lootLockerGetRequest, onComplete);
2363+
}
2364+
2365+
#endregion
2366+
21682367
#region Character
21692368

21702369
/// <summary>

0 commit comments

Comments
 (0)