1
0
mirror of synced 2024-11-23 22:10:59 +01:00

Fix unlock music and saving time

This commit is contained in:
asesidaa 2023-03-03 19:03:13 +08:00
parent 0fd5fc7227
commit cd5c06c97d
7 changed files with 473 additions and 40 deletions

View File

@ -1,4 +1,6 @@
using System.Diagnostics.CodeAnalysis;
using ChoETL;
using Domain.Enums;
using Microsoft.Extensions.Logging;
namespace Application.Api;
@ -19,21 +21,30 @@ public class UnlockAllMusicCommandHandler : RequestHandlerBase<UnlockAllMusicCom
[SuppressMessage("ReSharper.DPA", "DPA0006: Large number of DB commands")]
public override async Task<ServiceResult<bool>> Handle(UnlockAllMusicCommand request, CancellationToken cancellationToken)
{
var unlocks = await CardDbContext.CardDetails.Where(
detail => detail.CardId == request.CardId &&
detail.Pcol1 == 10 &&
detail.ScoreUi6 == 1).ToListAsync(cancellationToken: cancellationToken);
if (unlocks.Count == 0)
var exists = await CardDbContext.CardDetails.AnyAsync(
detail => detail.CardId == request.CardId, cancellationToken);
if (!exists)
{
logger.LogWarning("Attempt to unlock for card {Card} that does not exist or is empty!", request.CardId);
return ServiceResult.Failed<bool>(ServiceError.CustomMessage("Unlock failed"));
}
foreach (var unlock in unlocks)
{
unlock.ScoreUi2 = 1;
}
CardDbContext.CardDetails.UpdateRange(unlocks);
var unlockables = Config.UnlockRewards
.Where(config => config.RewardType == RewardType.Music)
.Select(config => new CardDetailDto
{
CardId = request.CardId,
Pcol1 = 10,
Pcol2 = config.TargetId,
Pcol3 = 0,
LastPlayTenpoId = "1337",
LastPlayTime = DateTime.Now,
ScoreUi2 = 1,
ScoreUi6 = 1
}.DtoToCardDetail());
await CardDbContext.CardDetails.UpsertRange(unlockables).RunAsync(cancellationToken);
await CardDbContext.SaveChangesAsync(cancellationToken);
return new ServiceResult<bool>(true);

View File

@ -21,7 +21,8 @@ public class ReadMusicQueryHandler : RequestHandlerBase<ReadMusicQuery, string>
{
var dto = unlock.MusicToDto();
dto.Id = i;
dto.CalcFlag = Random.Shared.NextDouble() >= 0.5 ? 1 : 0;
dto.CalcFlag = dto.NewFlag;
dto.NewFlag = 0;
return dto;
});

View File

@ -1,5 +1,8 @@
using System.Diagnostics.CodeAnalysis;
using Domain.Config;
using Domain.Enums;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Quartz;
namespace Application.Jobs;
@ -10,12 +13,15 @@ public class MaintainNullValuesJob : IJob
private readonly ICardDbContext cardDbContext;
private readonly GameConfig config;
public static readonly JobKey KEY = new("MaintainNullValuesJob");
public MaintainNullValuesJob(ILogger<MaintainNullValuesJob> logger, ICardDbContext cardDbContext)
public MaintainNullValuesJob(ILogger<MaintainNullValuesJob> logger, ICardDbContext cardDbContext, IOptions<GameConfig> options)
{
this.logger = logger;
this.cardDbContext = cardDbContext;
config = options.Value;
}
[SuppressMessage("ReSharper.DPA", "DPA0007: Large number of DB records",
@ -46,5 +52,23 @@ public class MaintainNullValuesJob : IJob
count = await cardDbContext.SaveChangesAsync(new CancellationToken());
logger.LogInformation("Closed {Count} matches", count);
logger.LogInformation("Starting to remove previously new songs");
var unlockables = config.UnlockRewards
.Where(c => c.RewardType == RewardType.Music).ToDictionary(rewardConfig => rewardConfig.TargetId);
var targets = await cardDbContext.CardDetails.Where(detail => detail.Pcol1 == 10).ToListAsync();
foreach (var target in targets)
{
if (unlockables.ContainsKey((int)target.Pcol2))
{
continue;
}
target.ScoreUi2 = 0;
target.ScoreUi6 = 0;
}
cardDbContext.CardDetails.UpdateRange(targets);
count = await cardDbContext.SaveChangesAsync(new CancellationToken());
logger.LogInformation("Fixed {Count} records", count);
}
}

View File

@ -3,10 +3,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.32126.315
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GC-local-server-rewrite", "GC-local-server-rewrite\GC-local-server-rewrite.csproj", "{D5FFF2E8-6591-4967-8883-A28F453F0524}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharedProject", "SharedProject\SharedProject.csproj", "{C01D0576-9D4E-4535-8055-C4905433A1EB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GCRelayServer", "GCRelayServer\GCRelayServer.csproj", "{268178DF-6345-4D9E-A389-9E809CBF39C9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MainServer", "MainServer\MainServer.csproj", "{B8C6CA7E-5E58-43BC-8E03-84306916DE39}"
@ -27,14 +23,6 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D5FFF2E8-6591-4967-8883-A28F453F0524}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D5FFF2E8-6591-4967-8883-A28F453F0524}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D5FFF2E8-6591-4967-8883-A28F453F0524}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D5FFF2E8-6591-4967-8883-A28F453F0524}.Release|Any CPU.Build.0 = Release|Any CPU
{C01D0576-9D4E-4535-8055-C4905433A1EB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C01D0576-9D4E-4535-8055-C4905433A1EB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C01D0576-9D4E-4535-8055-C4905433A1EB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C01D0576-9D4E-4535-8055-C4905433A1EB}.Release|Any CPU.Build.0 = Release|Any CPU
{268178DF-6345-4D9E-A389-9E809CBF39C9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{268178DF-6345-4D9E-A389-9E809CBF39C9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{268178DF-6345-4D9E-A389-9E809CBF39C9}.Release|Any CPU.ActiveCfg = Release|Any CPU

View File

@ -8,37 +8,373 @@
"TitleCount": 5530,
"UnlockRewards": [
{
"RewardId" : 1,
"RewardType" : "Item",
"TargetId" : 1,
"RewardId": 1,
"RewardType": "Item",
"TargetId": 1,
"TargetNum": 1,
"KeyNum": 1
},
{
"RewardId" : 2,
"RewardType" : "Music",
"TargetId" : 11,
"RewardId": 3,
"RewardType": "Avatar",
"TargetId": 11,
"TargetNum": 1,
"KeyNum": 1
},
{
"RewardId" : 3,
"RewardType" : "Avatar",
"TargetId" : 11,
"RewardId": 4,
"RewardType": "Navigator",
"TargetId": 11,
"TargetNum": 1,
"KeyNum": 1
},
{
"RewardId" : 4,
"RewardType" : "Navigator",
"TargetId" : 11,
"RewardId": 5,
"RewardType": "Coin",
"TargetId": 1,
"TargetNum": 1,
"KeyNum": 1
},
{
"RewardId" : 5,
"RewardType" : "Coin",
"TargetId" : 1,
"RewardId": 6,
"RewardType": "Music",
"TargetId": 464,
"TargetNum": 1,
"KeyNum": 1
},
{
"RewardId": 7,
"RewardType": "Music",
"TargetId": 498,
"TargetNum": 1,
"KeyNum": 1
},
{
"RewardId": 8,
"RewardType": "Music",
"TargetId": 551,
"TargetNum": 1,
"KeyNum": 1
},
{
"RewardId": 9,
"RewardType": "Music",
"TargetId": 561,
"TargetNum": 1,
"KeyNum": 1
},
{
"RewardId": 10,
"RewardType": "Music",
"TargetId": 565,
"TargetNum": 1,
"KeyNum": 1
},
{
"RewardId": 11,
"RewardType": "Music",
"TargetId": 615,
"TargetNum": 1,
"KeyNum": 1
},
{
"RewardId": 12,
"RewardType": "Music",
"TargetId": 471,
"TargetNum": 1,
"KeyNum": 1
},
{
"RewardId": 13,
"RewardType": "Music",
"TargetId": 676,
"TargetNum": 1,
"KeyNum": 1
},
{
"RewardId": 14,
"RewardType": "Music",
"TargetId": 659,
"TargetNum": 1,
"KeyNum": 1
},
{
"RewardId": 15,
"RewardType": "Music",
"TargetId": 291,
"TargetNum": 1,
"KeyNum": 1
},
{
"RewardId": 16,
"RewardType": "Music",
"TargetId": 371,
"TargetNum": 1,
"KeyNum": 1
},
{
"RewardId": 17,
"RewardType": "Music",
"TargetId": 494,
"TargetNum": 1,
"KeyNum": 1
},
{
"RewardId": 18,
"RewardType": "Music",
"TargetId": 520,
"TargetNum": 1,
"KeyNum": 1
},
{
"RewardId": 19,
"RewardType": "Music",
"TargetId": 558,
"TargetNum": 1,
"KeyNum": 1
},
{
"RewardId": 20,
"RewardType": "Music",
"TargetId": 577,
"TargetNum": 1,
"KeyNum": 1
},
{
"RewardId": 21,
"RewardType": "Music",
"TargetId": 583,
"TargetNum": 1,
"KeyNum": 1
},
{
"RewardId": 22,
"RewardType": "Music",
"TargetId": 666,
"TargetNum": 1,
"KeyNum": 1
},
{
"RewardId": 23,
"RewardType": "Music",
"TargetId": 612,
"TargetNum": 1,
"KeyNum": 1
},
{
"RewardId": 24,
"RewardType": "Music",
"TargetId": 697,
"TargetNum": 1,
"KeyNum": 1
},
{
"RewardId": 25,
"RewardType": "Music",
"TargetId": 321,
"TargetNum": 1,
"KeyNum": 1
},
{
"RewardId": 26,
"RewardType": "Music",
"TargetId": 78,
"TargetNum": 1,
"KeyNum": 1
},
{
"RewardId": 27,
"RewardType": "Music",
"TargetId": 668,
"TargetNum": 1,
"KeyNum": 1
},
{
"RewardId": 28,
"RewardType": "Music",
"TargetId": 685,
"TargetNum": 1,
"KeyNum": 1
},
{
"RewardId": 29,
"RewardType": "Music",
"TargetId": 686,
"TargetNum": 1,
"KeyNum": 1
},
{
"RewardId": 30,
"RewardType": "Music",
"TargetId": 700,
"TargetNum": 1,
"KeyNum": 1
},
{
"RewardId": 31,
"RewardType": "Music",
"TargetId": 11,
"TargetNum": 1,
"KeyNum": 1
},
{
"RewardId": 32,
"RewardType": "Music",
"TargetId": 13,
"TargetNum": 1,
"KeyNum": 1
},
{
"RewardId": 33,
"RewardType": "Music",
"TargetId": 149,
"TargetNum": 1,
"KeyNum": 1
},
{
"RewardId": 34,
"RewardType": "Music",
"TargetId": 273,
"TargetNum": 1,
"KeyNum": 1
},
{
"RewardId": 35,
"RewardType": "Music",
"TargetId": 320,
"TargetNum": 1,
"KeyNum": 1
},
{
"RewardId": 36,
"RewardType": "Music",
"TargetId": 378,
"TargetNum": 1,
"KeyNum": 1
},
{
"RewardId": 37,
"RewardType": "Music",
"TargetId": 384,
"TargetNum": 1,
"KeyNum": 1
},
{
"RewardId": 38,
"RewardType": "Music",
"TargetId": 622,
"TargetNum": 1,
"KeyNum": 1
},
{
"RewardId": 39,
"RewardType": "Music",
"TargetId": 475,
"TargetNum": 1,
"KeyNum": 1
},
{
"RewardId": 40,
"RewardType": "Music",
"TargetId": 492,
"TargetNum": 1,
"KeyNum": 1
},
{
"RewardId": 41,
"RewardType": "Music",
"TargetId": 570,
"TargetNum": 1,
"KeyNum": 1
},
{
"RewardId": 42,
"RewardType": "Music",
"TargetId": 548,
"TargetNum": 1,
"KeyNum": 1
},
{
"RewardId": 43,
"RewardType": "Music",
"TargetId": 672,
"TargetNum": 1,
"KeyNum": 1
},
{
"RewardId": 44,
"RewardType": "Music",
"TargetId": 632,
"TargetNum": 1,
"KeyNum": 1
},
{
"RewardId": 45,
"RewardType": "Music",
"TargetId": 670,
"TargetNum": 1,
"KeyNum": 1
},
{
"RewardId": 46,
"RewardType": "Music",
"TargetId": 680,
"TargetNum": 1,
"KeyNum": 1
},
{
"RewardId": 47,
"RewardType": "Music",
"TargetId": 682,
"TargetNum": 1,
"KeyNum": 1
},
{
"RewardId": 48,
"RewardType": "Music",
"TargetId": 701,
"TargetNum": 1,
"KeyNum": 1
},
{
"RewardId": 49,
"RewardType": "Music",
"TargetId": 711,
"TargetNum": 1,
"KeyNum": 1
},
{
"RewardId": 50,
"RewardType": "Music",
"TargetId": 720,
"TargetNum": 1,
"KeyNum": 1
},
{
"RewardId": 51,
"RewardType": "Music",
"TargetId": 749,
"TargetNum": 1,
"KeyNum": 1
},
{
"RewardId": 52,
"RewardType": "Music",
"TargetId": 875,
"TargetNum": 1,
"KeyNum": 1
},
{
"RewardId": 53,
"RewardType": "Music",
"TargetId": 876,
"TargetNum": 1,
"KeyNum": 1
},
{
"RewardId": 54,
"RewardType": "Music",
"TargetId": 877,
"TargetNum": 1,
"KeyNum": 1
}

24
doc/genunlock.py Normal file
View File

@ -0,0 +1,24 @@
import csv
import sqlite3
import json
con = sqlite3.connect('music471omni.db3')
cur = con.cursor()
id = 6
with open('unlockables.csv', encoding='utf8') as csvfile:
reader = csv.reader(csvfile, delimiter=',')
for row in reader:
name = row[0]
res = cur.execute("SELECT music_id FROM music_unlock where title=:t", {"t":name})
for music_id in res:
config = {
"RewardId": id,
"RewardType": "Music",
"TargetId": music_id[0],
"TargetNum": 1,
"KeyNum": 1
}
id += 1
print(json.dumps(config, indent=4) + ",")

49
doc/unlockables.csv Normal file
View File

@ -0,0 +1,49 @@
曲名,アーティスト,収録日,必要キー数
Perverse Love Rock!,中沢伴行 (I've) feat. IA,先行配信2016/09/01通常配信2016/10/05,2
ネトゲ廃人シュプレヒコール,さつき が てんこもり feat. 初音ミク,先行配信2016/10/20通常配信2017/01/12,5
深海シティアンダーグラウンド,田中B feat. 鏡音リン,先行配信2017/04/13通常配信2017/07/21,2
あのね…実はわたし、夢眠ねむなんだ…,夢眠ネム,先行配信2017/06/12通常配信2017/09/07,5
月夜ノ森,ぼのりす feat. 初音ミク,先行配信2017/07/12通常配信2017/10/27,3
ビットチューン,out of service feat. IA,先行配信2018/01/18通常配信2018/07/02,2
Miraculous Encounter,インターネット社 feat. GUMI,先行配信2018/02/21通常配信2018/07/02,2
人生リセットボタン,kemu feat. GUMI,2018/07/02,8
ボロボロだ,n-buna feat. 初音ミク,先行配信2018/06/06通常配信2018/08/23,10
D+D→T+p,Minstrel feat. LIQU@。,2015/09/07,5
カミノヒ,COSIO(ZUNTATA) × ランコ(豚乙女),先行配信2016/05/30通常配信2016/08/12,5
"Help me, ERINNNNNN!! -Cranky remix-",ビートまりお × Cranky,先行配信2016/07/29通常配信2016/09/28,5
Dream Coaster,A-One,先行配信2016/12/01通常配信2017/02/27,3
コノハズク,豚乙女,先行配信2017/05/01通常配信2017/08/09,10
DIVINE PLACE,TatshMusicCircle,先行配信2017/08/09通常配信2017/11/08,10
東方輝仁裂,MASAKI,先行配信2017/11/08通常配信2018/03/20,30
秘神マターラ-HYPER TECHNO MIX-,Yu Shimoda(ZUNTATA),2018/07/25,15
揺蕩うLove (feat. らっぷびと),魂音泉,先行配信2018/05/01通常配信2018/08/02,10
Say Around,A-One,2018/10/10,10
2112410403927243233368,253215,先行配信2015/04/01通常配信2015/06/02,25
ピアノ・ソナタ「月光」第三楽章,ICON,2018/07/18,9
EZ Mode,Akira Complex,2018/10/17,15
UP & DOWN,KO3,2018/10/24,15
Never Stop (GC Mix),Relect,2018/11/21,15
Fun-House,COSIO (ZUNTATA),2016/03/10,5
Cardiac Rhythm,COSIO,2015/03/25,5
Flyaway,櫻井浩司,2016/03/10,5
メシアの邂逅,Tatsh,2015/04/22,15
Got noir forever.,E.G.G.,2015/02/25,25
orbital,namae.,2016/03/10,5
Got hive of Ra,E.G.G.,先行配信2016/09/28通常配信2016/12/14,25
Got recover run,E.G.G.,先行配信2017/12/14通常配信2018/04/16,25
Warrior,Cranky,先行配信2017/02/20通常配信2017/05/22,15
TECHNO COMPLEX,DJ MURASAME a.k.a. Tatsh,先行配信2017/03/16通常配信2017/06/19,10
"Good Night, Bad Luck.",t+pazolite,先行配信2017/06/26通常配信2017/09/22,30
Got more raves? -xiRemix-,xi,先行配信2018/03/29通常配信2018/07/02,25
MOVING FASTER FT. LINDSEY MARIE,Daniel Seven,2018/07/11,15
Crimson Phoenix,xi vs MASAKI,先行配信2018/03/29通常配信2018/08/02,15
HAPPY! LUCKY! FUTURE WORLD!,EmoCo.,2018/08/16,15
Cosmic Express,Snail's House,2018/08/30,15
Xand-Roid,Tatsh,2018/09/14,20
Pegasus,NaMiRa,2018/11/21,15
Little Higher,nora2r,2018/12/05,15
Got sorted view.,E.G.G.,2019/03/13,25
Lemegeton -little key of solomon-,Team Grimoire vs MASAKI,2019/03/28,30
希,technoplanet feat. Shun [RIGEL],2021/12/01,15
Valkyrja Requiem,iTIC,2021/12/08,15
コスモスタート,打打だいず,2021/12/15,15
1 曲名 アーティスト 収録日 必要キー数
2 Perverse Love Rock! 中沢伴行 (I've) feat. IA 先行配信2016/09/01通常配信2016/10/05 2
3 ネトゲ廃人シュプレヒコール さつき が てんこもり feat. 初音ミク 先行配信2016/10/20通常配信2017/01/12 5
4 深海シティアンダーグラウンド 田中B feat. 鏡音リン 先行配信2017/04/13通常配信2017/07/21 2
5 あのね…実はわたし、夢眠ねむなんだ… 夢眠ネム 先行配信2017/06/12通常配信2017/09/07 5
6 月夜ノ森 ぼのりす feat. 初音ミク 先行配信2017/07/12通常配信2017/10/27 3
7 ビットチューン out of service feat. IA 先行配信2018/01/18通常配信2018/07/02 2
8 Miraculous Encounter インターネット社 feat. GUMI 先行配信2018/02/21通常配信2018/07/02 2
9 人生リセットボタン kemu feat. GUMI 2018/07/02 8
10 ボロボロだ n-buna feat. 初音ミク 先行配信2018/06/06通常配信2018/08/23 10
11 D+D→T+p Minstrel feat. LIQU@。 2015/09/07 5
12 カミノヒ COSIO(ZUNTATA) × ランコ(豚乙女) 先行配信2016/05/30通常配信2016/08/12 5
13 Help me, ERINNNNNN!! -Cranky remix- ビートまりお × Cranky 先行配信2016/07/29通常配信2016/09/28 5
14 Dream Coaster A-One 先行配信2016/12/01通常配信2017/02/27 3
15 コノハズク 豚乙女 先行配信2017/05/01通常配信2017/08/09 10
16 DIVINE PLACE TatshMusicCircle 先行配信2017/08/09通常配信2017/11/08 10
17 東方輝仁裂 MASAKI 先行配信2017/11/08通常配信2018/03/20 30
18 秘神マターラ-HYPER TECHNO MIX- Yu Shimoda(ZUNTATA) 2018/07/25 15
19 揺蕩うLove (feat. らっぷびと) 魂音泉 先行配信2018/05/01通常配信2018/08/02 10
20 Say Around A-One 2018/10/10 10
21 2112410403927243233368 253215 先行配信2015/04/01通常配信2015/06/02 25
22 ピアノ・ソナタ「月光」第三楽章 ICON 2018/07/18 9
23 EZ Mode Akira Complex 2018/10/17 15
24 UP & DOWN KO3 2018/10/24 15
25 Never Stop (GC Mix) Relect 2018/11/21 15
26 Fun-House COSIO (ZUNTATA) 2016/03/10 5
27 Cardiac Rhythm COSIO 2015/03/25 5
28 Flyaway 櫻井浩司 2016/03/10 5
29 メシアの邂逅 Tatsh 2015/04/22 15
30 Got noir forever. E.G.G. 2015/02/25 25
31 orbital namae. 2016/03/10 5
32 Got hive of Ra E.G.G. 先行配信2016/09/28通常配信2016/12/14 25
33 Got recover run E.G.G. 先行配信2017/12/14通常配信2018/04/16 25
34 Warrior Cranky 先行配信2017/02/20通常配信2017/05/22 15
35 TECHNO COMPLEX DJ MURASAME a.k.a. Tatsh 先行配信2017/03/16通常配信2017/06/19 10
36 Good Night, Bad Luck. t+pazolite 先行配信2017/06/26通常配信2017/09/22 30
37 Got more raves? -xiRemix- xi 先行配信2018/03/29通常配信2018/07/02 25
38 MOVING FASTER FT. LINDSEY MARIE Daniel Seven 2018/07/11 15
39 Crimson Phoenix xi vs MASAKI 先行配信2018/03/29通常配信2018/08/02 15
40 HAPPY! LUCKY! FUTURE WORLD! EmoCo. 2018/08/16 15
41 Cosmic Express Snail's House 2018/08/30 15
42 Xand-Roid Tatsh 2018/09/14 20
43 Pegasus NaMiRa 2018/11/21 15
44 Little Higher nora2r 2018/12/05 15
45 Got sorted view. E.G.G. 2019/03/13 25
46 Lemegeton -little key of solomon- Team Grimoire vs MASAKI 2019/03/28 30
47 technoplanet feat. Shun [RIGEL] 2021/12/01 15
48 Valkyrja Requiem iTIC 2021/12/08 15
49 コスモスタート 打打だいず 2021/12/15 15