More additions, lucky card based on day, redo of migrations because i messed up

This commit is contained in:
2021-11-01 14:59:36 -04:00
parent 685f09a889
commit 0b94455b4b
48 changed files with 284 additions and 7404 deletions

View File

@@ -26,28 +26,29 @@ namespace TOOHUCardAPI.Data.Services
{
user.Point = Math.Max(0, user.Point + points);
await _userRepository.UpdateUser(user);
_logger.LogInformation($"User with steamid {user.SteamId} was given {points} points. New total: {user.Point}");
_logger.LogInformation("User with steamid {SteamId} was given {PointsGiven} points. New total: {PointsTotal}", user.SteamId, points, user.Point);
}
public async Task<User> SaveKeyTotal(string steamId, int keyTotal, int keyUseCount)
public async Task<User> SaveKeyTotal(long steamId, int keyTotal, int keyUseCount)
{
User user = await _userRepository.GetUser(steamId);
_logger.LogInformation($"User {user.SteamId} just stored some key total data, previous total and use: ({user.KeyTotal},{user.KeyUseCount}). new ({keyTotal},{keyUseCount})");
_logger.LogInformation("User {SteamId} just stored some key total data, previous total and use: ({OldKeyTotal},{OldKeyUseCount}). new ({NewKeyTotal},{NewKeyUseCount})", user.SteamId, user.KeyTotal, user.KeyUseCount, keyTotal, keyUseCount);
user.KeyTotal = keyTotal;
user.KeyUseCount = keyUseCount;
await _userRepository.UpdateUser(user);
return user;
}
public async Task<int> ChangePowerMaxTotal(string steamId, int amt)
public async Task<int> ChangePowerMaxTotal(long steamId, int amt)
{
User user = await _userRepository.GetUser(steamId);
user.PowerMaxTotal = Math.Clamp(user.PowerMaxTotal + amt, 0, int.MaxValue);
await _userRepository.UpdateUser(user);
_logger.LogInformation("User {SteamId} changed the number of MaxPower items they had by {Amount}", user.SteamId, amt);
return user.PowerMaxTotal;
}
public async Task<int> LevelUpCard(string steamId, string itemName, int levelIncrease)
public async Task<int> LevelUpCard(long steamId, string itemName, int levelIncrease)
{
User user = await _userRepository.GetUser(steamId);
Card card = await _cardRepository.GetCardByItemCode(itemName);
@@ -57,7 +58,7 @@ namespace TOOHUCardAPI.Data.Services
Level = 0
};
int totalCost =
(card.Quality == Rarity.NORMAL ? AppSettings.PointsPerLevelNormal : AppSettings.PointsPerLevel) *
(card.Quality == Rarity.Normal ? AppSettings.PointsPerLevelNormal : AppSettings.PointsPerLevel) *
levelIncrease;
if (user.Point < totalCost)
{
@@ -70,11 +71,11 @@ namespace TOOHUCardAPI.Data.Services
await AddPoints(-totalCost, user);
userCardLevel.Level += levelIncrease;
await _userRepository.UpdateUser(user);
_logger.LogInformation($"User with steamid {user.SteamId} leveled up card {card.CardName} to level {userCardLevel.Level}");
_logger.LogInformation("User with steamid {SteamId} leveled up card {CardName} to level {Level}", user.SteamId, card.CardName, userCardLevel.Level);
return totalCost;
}
public async Task<int> PurchaseMagicKey(int amt, string steamId)
public async Task<int> PurchaseMagicKey(int amt, long steamId)
{
int totalCost = AppSettings.PointsPerKey * amt;
amt = Math.Clamp(amt, 0, AppSettings.MaxKeyPurchaseAmount);
@@ -87,11 +88,11 @@ namespace TOOHUCardAPI.Data.Services
await AddPoints(-totalCost, user);
user.KeyTotal += amt;
await _userRepository.UpdateUser(user);
_logger.LogInformation($"User with steamid {user.SteamId} purchased {amt} keys for {totalCost} points. New point value is {user.Point}");
_logger.LogInformation("User with steamid {SteamId} purchased {NumberKeys} keys for {TotalCost} points. New point value is {NewPoints}", user.SteamId, amt, totalCost, user.Point);
return totalCost;
}
public async Task<int> GiveFirstWinBonus(string steamId)
public async Task<int> GiveFirstWinBonus(long steamId)
{
User user = await _userRepository.GetUser(steamId);
@@ -104,7 +105,7 @@ namespace TOOHUCardAPI.Data.Services
await AddPoints(points, user);
user.LastFirstWin = DateTime.Now;
await _userRepository.UpdateUser(user);
_logger.LogInformation($"User with steamid {user.SteamId} received first win of the day bonus, earning {points} points. New value: {user.Point}");
_logger.LogInformation("User with steamid {SteamId} received first win of the day bonus, earning {BonusPoints} points. New value: {UserPoints}", user.SteamId, points, user.Point);
return points;
}
}