public Task <bool> RedeemRewardAsync( Guid streamerUserId, Guid characterId, DataModels.UserLoyaltyReward reward, int amount) { return(Task.Run(() => { if (string.IsNullOrEmpty(reward.RewardData) || !Guid.TryParse(reward.RewardData, out var itemId)) { return false; } var streamer = gameData.GetUser(streamerUserId); if (streamer == null) { return false; } var character = gameData.GetCharacter(characterId); if (character == null) { return false; } var user = gameData.GetUser(character.UserId); if (user == null) { return false; } if (amount < 1) { return false; } var cost = reward.Points * amount; var loyalty = gameData.GetUserLoyalty(user.Id, streamerUserId); if (loyalty.Points < cost) { return false; } loyalty.Points -= cost ?? 0; playerManager.AddItem(characterId, itemId, amount); return true; })); }
public AddItemResult AddItem(string userId, Guid item) { return(playerManager.AddItem(AssertGetSessionToken(), userId, item)); }
public WebsitePlayer AddItem(Guid characterId, Item item) { playerManager.AddItem(characterId, item.Id); return(playerManager.GetWebsitePlayer(characterId)); }