Migration and daily login change
This commit is contained in:
@@ -7,7 +7,9 @@ namespace TOOHUCardAPI.Data
|
|||||||
{
|
{
|
||||||
public static int PointsPerLevel { get; set; }
|
public static int PointsPerLevel { get; set; }
|
||||||
public static int PointsPerLevelNormal { get; set; }
|
public static int PointsPerLevelNormal { get; set; }
|
||||||
public static int FirstWinBonusPoints { get; set; }
|
public static int FirstWinBonusPointsMin { get; set; }
|
||||||
|
public static int FirstWinBonusPointsMax { get; set; }
|
||||||
|
public static int DailyKeyBonus { get; set; }
|
||||||
public static int PointsPerKey { get; set; }
|
public static int PointsPerKey { get; set; }
|
||||||
public static int MaxKeyPurchaseAmount { get; set; }
|
public static int MaxKeyPurchaseAmount { get; set; }
|
||||||
public static void Init(IConfiguration configuration)
|
public static void Init(IConfiguration configuration)
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ namespace TOOHUCardAPI.Data.Models
|
|||||||
public bool Ban { get; set; }
|
public bool Ban { get; set; }
|
||||||
public int Point { get; set; }
|
public int Point { get; set; }
|
||||||
public DateTime LastFirstWin { get; set; }
|
public DateTime LastFirstWin { get; set; }
|
||||||
|
public DateTime LastDailyLoginBonus { get; set; }
|
||||||
public int PowerMaxTotal { get; set; }
|
public int PowerMaxTotal { get; set; }
|
||||||
public string PetModel { get; set; }
|
public string PetModel { get; set; }
|
||||||
public string PetEffect { get; set; }
|
public string PetEffect { get; set; }
|
||||||
|
|||||||
@@ -99,11 +99,13 @@ namespace TOOHUCardAPI.Data.Services
|
|||||||
{
|
{
|
||||||
throw new NotFirstWinException();
|
throw new NotFirstWinException();
|
||||||
}
|
}
|
||||||
await AddPoints(AppSettings.FirstWinBonusPoints, user);
|
|
||||||
|
int points = new Random().Next(AppSettings.FirstWinBonusPointsMin, AppSettings.FirstWinBonusPointsMax + 1);
|
||||||
|
await AddPoints(points, user);
|
||||||
user.LastFirstWin = DateTime.Now;
|
user.LastFirstWin = DateTime.Now;
|
||||||
await _userRepository.UpdateUser(user);
|
await _userRepository.UpdateUser(user);
|
||||||
_logger.LogInformation($"User with steamid {user.SteamId} received first win of the day bonus, earning {AppSettings.FirstWinBonusPoints} points. New value: {user.Point}");
|
_logger.LogInformation($"User with steamid {user.SteamId} received first win of the day bonus, earning {points} points. New value: {user.Point}");
|
||||||
return AppSettings.FirstWinBonusPoints;
|
return points;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
@@ -20,7 +21,20 @@ namespace TOOHUCardAPI.Data.Services
|
|||||||
public async Task<User> LoginUser(string steamId)
|
public async Task<User> LoginUser(string steamId)
|
||||||
{
|
{
|
||||||
_logger.LogInformation($"User {steamId} just logged in");
|
_logger.LogInformation($"User {steamId} just logged in");
|
||||||
return await _userRepository.GetOrCreateUser(steamId);
|
User user = await _userRepository.GetOrCreateUser(steamId);
|
||||||
|
if (user.LastDailyLoginBonus.AddDays(1) <= DateTime.Now)
|
||||||
|
{
|
||||||
|
user = await HandleDailyLoginBonus(user);
|
||||||
|
}
|
||||||
|
|
||||||
|
return user;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task<User> HandleDailyLoginBonus(User user)
|
||||||
|
{
|
||||||
|
user.KeyTotal += AppSettings.DailyKeyBonus;
|
||||||
|
await _userRepository.UpdateUser(user);
|
||||||
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task SaveCardGroup(string steamId, string groupKey, string groupData)
|
public async Task SaveCardGroup(string steamId, string groupKey, string groupData)
|
||||||
|
|||||||
1026
TOOHUCardAPI/Migrations/20211031154114_playerdata done for front facing.Designer.cs
generated
Normal file
1026
TOOHUCardAPI/Migrations/20211031154114_playerdata done for front facing.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,33 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
namespace TOOHUCardAPI.Migrations
|
||||||
|
{
|
||||||
|
public partial class playerdatadoneforfrontfacing : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "PetEffect",
|
||||||
|
table: "Users",
|
||||||
|
type: "TEXT",
|
||||||
|
nullable: true);
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "PetModel",
|
||||||
|
table: "Users",
|
||||||
|
type: "TEXT",
|
||||||
|
nullable: true);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "PetEffect",
|
||||||
|
table: "Users");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "PetModel",
|
||||||
|
table: "Users");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -965,9 +965,15 @@ namespace TOOHUCardAPI.Migrations
|
|||||||
b.Property<int>("MaxWave")
|
b.Property<int>("MaxWave")
|
||||||
.HasColumnType("INTEGER");
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("PetEffect")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
b.Property<int>("PetLevel")
|
b.Property<int>("PetLevel")
|
||||||
.HasColumnType("INTEGER");
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("PetModel")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
b.Property<int>("Point")
|
b.Property<int>("Point")
|
||||||
.HasColumnType("INTEGER");
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,8 @@
|
|||||||
"PointsPerLevel": "10",
|
"PointsPerLevel": "10",
|
||||||
"PointsPerLevelNormal": "5",
|
"PointsPerLevelNormal": "5",
|
||||||
"PointsPerKey": "2",
|
"PointsPerKey": "2",
|
||||||
"FirstWinBonusPoints": "2",
|
"FirstWinBonusPointsMin": "1",
|
||||||
|
"FirstWinBonusPointsMax": "5",
|
||||||
|
"DailyKeyBonus": "2",
|
||||||
"MaxKeyPurchaseAmount": "200"
|
"MaxKeyPurchaseAmount": "200"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user