mirror of
https://github.com/MikuLeaks/MikuSB.git
synced 2026-06-04 18:03:58 +00:00
Compare commits
128 Commits
720f56c708
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3c045a79a9 | ||
|
|
ecf2446598 | ||
|
|
75d840974b | ||
|
|
d6f57053dd | ||
|
|
518c04fdb4 | ||
|
|
a9b57fc1b7 | ||
|
|
63dc993614 | ||
|
|
26e4d6fd0f | ||
|
|
5de3551ef3 | ||
|
|
5f81b5f6ec | ||
|
|
6063a3a0cd | ||
|
|
60101e75e2 | ||
|
|
6497bb1c66 | ||
|
|
e4fb4d7722 | ||
|
|
6bc9090c89 | ||
|
|
bc69a072e1 | ||
|
|
2f1b6d35da | ||
|
|
2047758c18 | ||
|
|
6b48c90783 | ||
|
|
a50b0563be | ||
|
|
b78c709f76 | ||
|
|
12094f6dd1 | ||
|
|
c3b675dc34 | ||
|
|
6f51e335de | ||
|
|
e4398e17b4 | ||
|
|
bc399f6afe | ||
|
|
4fdd093644 | ||
|
|
772c272fb4 | ||
|
|
55bfadbd3e | ||
|
|
589f7d6340 | ||
|
|
196b03718c | ||
|
|
b916ab5dfc | ||
|
|
1dca65f91a | ||
|
|
1051de8dcf | ||
|
|
72126da9a5 | ||
|
|
331d2dbcaa | ||
|
|
85df98c0ae | ||
|
|
a585232045 | ||
|
|
125dadd224 | ||
|
|
cfca2f970c | ||
|
|
9a9ae13da0 | ||
|
|
1938095ea5 | ||
|
|
132355d76b | ||
|
|
5a8e45a44c | ||
|
|
def4b8ae68 | ||
|
|
686794a68c | ||
|
|
3bc30812aa | ||
|
|
f8f7311997 | ||
|
|
e628a010be | ||
|
|
738a7d4e14 | ||
|
|
0058ba0db6 | ||
|
|
46d945f3ce | ||
|
|
e5ecdc7f2a | ||
|
|
30c52b6aa8 | ||
|
|
3ffb7ebf29 | ||
|
|
400db16f39 | ||
|
|
42b1ad1024 | ||
|
|
5aa5ef92d0 | ||
|
|
c34ad5eb1e | ||
|
|
8a597e24b6 | ||
|
|
9763f1f8d9 | ||
|
|
933ba097f9 | ||
|
|
c10d380e11 | ||
|
|
6c5d546026 | ||
|
|
9e518edb8e | ||
|
|
79fad7df2e | ||
|
|
68a7d6cc61 | ||
|
|
548c77850e | ||
|
|
d8c356a01f | ||
|
|
26991c9706 | ||
|
|
a555dd2930 | ||
|
|
85605a786c | ||
|
|
f3d6ff3873 | ||
|
|
41df375e21 | ||
|
|
5332d5fe1a | ||
|
|
da61f1e929 | ||
|
|
d9b16fb55d | ||
|
|
e92b214161 | ||
|
|
6740b8ecf7 | ||
|
|
4ee11618be | ||
|
|
233419eba3 | ||
|
|
a7a68418db | ||
|
|
f053359c41 | ||
|
|
0cf633a0e1 | ||
|
|
e4397f10ee | ||
|
|
bdb4ee3d51 | ||
|
|
7507d10072 | ||
|
|
8a7a919d04 | ||
|
|
2d1079a80d | ||
|
|
677e4027b9 | ||
|
|
4dc28ae423 | ||
|
|
1fce4ca2e6 | ||
|
|
93c59e5730 | ||
|
|
f7814b0537 | ||
|
|
2fdda3157f | ||
|
|
f07c5f77fd | ||
|
|
2883ac3d41 | ||
|
|
49f4fdfda5 | ||
|
|
bcc5716f97 | ||
|
|
4bd66621bf | ||
|
|
14a611bf8e | ||
|
|
283358f1ec | ||
|
|
5d8b3f2bad | ||
|
|
a992bc86c5 | ||
|
|
d97eae6f5b | ||
|
|
04121eb357 | ||
|
|
391879a483 | ||
|
|
8e3323dd94 | ||
|
|
7e83d2ccd2 | ||
|
|
408113963b | ||
|
|
fcf0bf0843 | ||
|
|
2bf7554c53 | ||
|
|
50121d619b | ||
|
|
e8bb77e90e | ||
|
|
5f173ce8d2 | ||
|
|
9b8fa5d7c8 | ||
|
|
1969c1ec89 | ||
|
|
e32319aa50 | ||
|
|
846139347a | ||
|
|
d1102b444c | ||
|
|
3611624073 | ||
|
|
c61ac08dd3 | ||
|
|
5f3fc0c746 | ||
|
|
2fe795d29a | ||
|
|
b256fe7b01 | ||
|
|
e93dadafe8 | ||
|
|
34b93ad55d | ||
|
|
3eca16a661 |
57
.github/workflows/release.yml
vendored
57
.github/workflows/release.yml
vendored
@@ -9,6 +9,9 @@ on:
|
|||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
|
|
||||||
|
env:
|
||||||
|
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-release:
|
build-release:
|
||||||
runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
@@ -18,7 +21,7 @@ jobs:
|
|||||||
|
|
||||||
- uses: actions/setup-dotnet@v4
|
- uses: actions/setup-dotnet@v4
|
||||||
with:
|
with:
|
||||||
dotnet-version: 9.0.x
|
dotnet-version: 10.0.x
|
||||||
|
|
||||||
- name: Read version
|
- name: Read version
|
||||||
id: version
|
id: version
|
||||||
@@ -54,3 +57,55 @@ jobs:
|
|||||||
files: |
|
files: |
|
||||||
artifacts/MikuSB-win-x64.zip
|
artifacts/MikuSB-win-x64.zip
|
||||||
artifacts/MikuSB-win-x64.zip.sha256
|
artifacts/MikuSB-win-x64.zip.sha256
|
||||||
|
|
||||||
|
build-release-linux:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- uses: actions/setup-dotnet@v4
|
||||||
|
with:
|
||||||
|
dotnet-version: '10.0.x'
|
||||||
|
|
||||||
|
- name: Publish server
|
||||||
|
run: |
|
||||||
|
dotnet publish ./MikuSB/MikuSB.csproj -c Release -r linux-x64 --self-contained true -p:PublishSingleFile=true --property:PublishDir=../artifacts/dist
|
||||||
|
|
||||||
|
- name: Read version
|
||||||
|
id: version
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
line=$(head -n 1 version.txt | xargs)
|
||||||
|
VERSION=${line#v=}
|
||||||
|
|
||||||
|
SHORT_HASH="$(git rev-parse --short=7 HEAD)"
|
||||||
|
if [ -z "$VERSION" ]; then
|
||||||
|
echo "version.txt is empty."
|
||||||
|
VERSION=${SHORT_HASH}
|
||||||
|
fi
|
||||||
|
if [[ "${{ env.BRANCH_NAME }}" == "main" ]]; then
|
||||||
|
echo "tag=v${VERSION}" >> $GITHUB_OUTPUT
|
||||||
|
else
|
||||||
|
SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
|
||||||
|
echo "tag=${SAFE_NAME}-v${VERSION}-${SHORT_HASH}" >> $GITHUB_OUTPUT
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Assemble release package
|
||||||
|
run: |
|
||||||
|
packageDir="./artifacts/dist/"
|
||||||
|
zipFile="MikuSB-linux-x64.zip"
|
||||||
|
cp ./version.txt ${packageDir}
|
||||||
|
pushd ${packageDir}
|
||||||
|
zip -r ../${zipFile} .
|
||||||
|
popd
|
||||||
|
sha256sum ./artifacts/${zipFile} > ./artifacts/${zipFile}.sha256
|
||||||
|
|
||||||
|
- name: Create release
|
||||||
|
uses: softprops/action-gh-release@v2
|
||||||
|
with:
|
||||||
|
tag_name: ${{ steps.version.outputs.tag }}
|
||||||
|
name: ${{ steps.version.outputs.tag }}
|
||||||
|
generate_release_notes: true
|
||||||
|
files: |
|
||||||
|
./artifacts/MikuSB-linux-x64.zip
|
||||||
|
./artifacts/MikuSB-linux-x64.zip.sha256
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net9.0</TargetFramework>
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<CETCompat>false</CETCompat>
|
<CETCompat>false</CETCompat>
|
||||||
@@ -21,7 +21,6 @@
|
|||||||
<PackageReference Include="SQLitePCLRaw.provider.e_sqlite3" Version="2.1.10" />
|
<PackageReference Include="SQLitePCLRaw.provider.e_sqlite3" Version="2.1.10" />
|
||||||
<PackageReference Include="SqlSugarCore" Version="5.1.4.172" />
|
<PackageReference Include="SqlSugarCore" Version="5.1.4.172" />
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="7.2.0" />
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="7.2.0" />
|
||||||
<PackageReference Include="System.IO.Pipelines" Version="9.0.0" />
|
|
||||||
<PackageReference Include="System.Management" Version="9.0.0" />
|
<PackageReference Include="System.Management" Version="9.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ public class ConfigContainer
|
|||||||
public PathConfig Path { get; set; } = new();
|
public PathConfig Path { get; set; } = new();
|
||||||
public ServerOption ServerOption { get; set; } = new();
|
public ServerOption ServerOption { get; set; } = new();
|
||||||
public ProxyOptions Proxy { get; set; } = new();
|
public ProxyOptions Proxy { get; set; } = new();
|
||||||
|
public LoaderOptions Loader { get; set; } = new();
|
||||||
}
|
}
|
||||||
|
|
||||||
public class HttpServerConfig
|
public class HttpServerConfig
|
||||||
@@ -60,6 +61,7 @@ public class ServerOption
|
|||||||
public string FallbackLanguage { get; set; } = "EN";
|
public string FallbackLanguage { get; set; } = "EN";
|
||||||
public string[] DefaultPermissions { get; set; } = ["Admin"];
|
public string[] DefaultPermissions { get; set; } = ["Admin"];
|
||||||
public ServerProfile ServerProfile { get; set; } = new();
|
public ServerProfile ServerProfile { get; set; } = new();
|
||||||
|
public bool EnableGmMenu { get; set; } = false;
|
||||||
public bool AutoCreateUser { get; set; } = true;
|
public bool AutoCreateUser { get; set; } = true;
|
||||||
public bool SavePersonalDebugFile { get; set; } = false;
|
public bool SavePersonalDebugFile { get; set; } = false;
|
||||||
public bool AutoSendResponseWhenNoHandler { get; set; } = true;
|
public bool AutoSendResponseWhenNoHandler { get; set; } = true;
|
||||||
@@ -85,10 +87,13 @@ public class ServerProfile
|
|||||||
public class ProxyOptions
|
public class ProxyOptions
|
||||||
{
|
{
|
||||||
public bool Enabled { get; set; } = true;
|
public bool Enabled { get; set; } = true;
|
||||||
public int Port { get; set; } = 8888;
|
public int Port { get; set; } = 18888;
|
||||||
public int ServerHttpPort { get; set; } = 21500;
|
}
|
||||||
public bool InstallRootCertificate { get; set; } = true;
|
|
||||||
public bool ManageSystemProxy { get; set; } = true;
|
public class LoaderOptions
|
||||||
public bool RestoreSystemProxyOnStop { get; set; } = true;
|
{
|
||||||
public string ProxyOverride { get; set; } = "localhost;127.*;10.*;192.168.*;<local>";
|
public string GamePath { get; set; } = "";
|
||||||
|
public string[] PatchPaths { get; set; } = [@"Patch\MikuSB-Patch.dll"];
|
||||||
|
public string[] Arguments { get; set; } = ["-FeatureLevelES31", "-channelid=seasun", "-NoSplash"];
|
||||||
|
public bool SetAllProxy { get; set; } = true;
|
||||||
}
|
}
|
||||||
|
|||||||
24
Common/Data/Config/StringToUIntConverter.cs
Normal file
24
Common/Data/Config/StringToUIntConverter.cs
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace MikuSB.Data.Config;
|
||||||
|
|
||||||
|
public class StringToUIntConverter : JsonConverter<uint>
|
||||||
|
{
|
||||||
|
public override uint ReadJson(JsonReader reader, Type objectType, uint existingValue, bool hasExistingValue, JsonSerializer serializer)
|
||||||
|
{
|
||||||
|
if (reader.Value == null)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
var value = reader.Value.ToString();
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(value))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return uint.TryParse(value, out var result) ? result : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void WriteJson(JsonWriter writer, uint value, JsonSerializer serializer)
|
||||||
|
{
|
||||||
|
writer.WriteValue(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
namespace MikuSB.Data.Excel;
|
namespace MikuSB.Data.Excel;
|
||||||
|
|
||||||
[ResourceEntity("ar_item.json")]
|
[ResourceEntity("item/templates/ar_item.json")]
|
||||||
public class ArItemExcel : ExcelResource
|
public class ArItemExcel : ExcelResource
|
||||||
{
|
{
|
||||||
public uint Genre { get; set; }
|
public uint Genre { get; set; }
|
||||||
|
|||||||
23
Common/Data/Excel/BattlePassTimeExcel.cs
Normal file
23
Common/Data/Excel/BattlePassTimeExcel.cs
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace MikuSB.Data.Excel;
|
||||||
|
|
||||||
|
[ResourceEntity("battlepass/timelist.json")]
|
||||||
|
public class BattlePassTimeExcel : ExcelResource
|
||||||
|
{
|
||||||
|
[JsonProperty("ID")] public uint Id { get; set; }
|
||||||
|
[JsonProperty("StartTime")] public string StartTime { get; set; } = "";
|
||||||
|
[JsonProperty("EndTime")] public string EndTime { get; set; } = "";
|
||||||
|
[JsonProperty("BuyStartTime")] public string BuyStartTime { get; set; } = "";
|
||||||
|
[JsonProperty("BuyEndTime")] public string BuyEndTime { get; set; } = "";
|
||||||
|
[JsonProperty("Condition")] public string Condition { get; set; } = "";
|
||||||
|
[JsonProperty("ExpStep")] public uint ExpStep { get; set; }
|
||||||
|
[JsonProperty("MaxExPerWeek")] public uint MaxExPerWeek { get; set; }
|
||||||
|
|
||||||
|
public override uint GetId() => Id;
|
||||||
|
|
||||||
|
public override void Loaded()
|
||||||
|
{
|
||||||
|
GameData.BattlePassTimeData[Id] = this;
|
||||||
|
}
|
||||||
|
}
|
||||||
32
Common/Data/Excel/BossPvpBossChallengeExcel.cs
Normal file
32
Common/Data/Excel/BossPvpBossChallengeExcel.cs
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
using System.Globalization;
|
||||||
|
|
||||||
|
namespace MikuSB.Data.Excel;
|
||||||
|
|
||||||
|
[ResourceEntity("challenge/bosspvp/boss_challenge.json")]
|
||||||
|
public class BossPvpBossChallengeExcel : ExcelResource
|
||||||
|
{
|
||||||
|
public uint ID { get; set; }
|
||||||
|
public string StartTime { get; set; } = "";
|
||||||
|
public string EndTime { get; set; } = "";
|
||||||
|
public List<uint> tbTaskID { get; set; } = [];
|
||||||
|
|
||||||
|
[JsonExtensionData] public IDictionary<string, JToken> ExtraData { get; set; } = new Dictionary<string, JToken>();
|
||||||
|
|
||||||
|
[JsonIgnore] public List<uint> BossIds { get; private set; } = [];
|
||||||
|
|
||||||
|
public override uint GetId() => ID;
|
||||||
|
|
||||||
|
public override void Loaded()
|
||||||
|
{
|
||||||
|
BossIds = ExtraData
|
||||||
|
.Where(x => x.Key.StartsWith("Boss", StringComparison.Ordinal) && int.TryParse(x.Key[4..], out _))
|
||||||
|
.OrderBy(x => int.Parse(x.Key[4..], CultureInfo.InvariantCulture))
|
||||||
|
.Select(x => x.Value.Type == JTokenType.Integer ? x.Value.Value<uint>() : 0u)
|
||||||
|
.Where(x => x > 0)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
GameData.BossPvpBossChallengeData[ID] = this;
|
||||||
|
}
|
||||||
|
}
|
||||||
17
Common/Data/Excel/BossPvpBossExcel.cs
Normal file
17
Common/Data/Excel/BossPvpBossExcel.cs
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
namespace MikuSB.Data.Excel;
|
||||||
|
|
||||||
|
[ResourceEntity("challenge/bosspvp/boss.json")]
|
||||||
|
public class BossPvpBossExcel : ExcelResource
|
||||||
|
{
|
||||||
|
public uint ID { get; set; }
|
||||||
|
public uint LevelID { get; set; }
|
||||||
|
public uint BossID { get; set; }
|
||||||
|
public List<List<int>> BossLevel { get; set; } = [];
|
||||||
|
|
||||||
|
public override uint GetId() => ID;
|
||||||
|
|
||||||
|
public override void Loaded()
|
||||||
|
{
|
||||||
|
GameData.BossPvpBossData[ID] = this;
|
||||||
|
}
|
||||||
|
}
|
||||||
15
Common/Data/Excel/BossPvpNumExcel.cs
Normal file
15
Common/Data/Excel/BossPvpNumExcel.cs
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
namespace MikuSB.Data.Excel;
|
||||||
|
|
||||||
|
[ResourceEntity("challenge/bosspvp/num.json")]
|
||||||
|
public class BossPvpNumExcel : ExcelResource
|
||||||
|
{
|
||||||
|
public uint Week { get; set; }
|
||||||
|
public uint Num { get; set; }
|
||||||
|
|
||||||
|
public override uint GetId() => Week;
|
||||||
|
|
||||||
|
public override void Loaded()
|
||||||
|
{
|
||||||
|
GameData.BossPvpNumData[Week] = this;
|
||||||
|
}
|
||||||
|
}
|
||||||
34
Common/Data/Excel/BreakExcel.cs
Normal file
34
Common/Data/Excel/BreakExcel.cs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace MikuSB.Data.Excel;
|
||||||
|
|
||||||
|
[ResourceEntity("item/break.json")]
|
||||||
|
public class BreakExcel : ExcelResource
|
||||||
|
{
|
||||||
|
[JsonProperty("ID")] public int Id { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("Items1")] public List<List<int>> Items1 { get; set; } = [];
|
||||||
|
[JsonProperty("Items2")] public List<List<int>> Items2 { get; set; } = [];
|
||||||
|
[JsonProperty("Items3")] public List<List<int>> Items3 { get; set; } = [];
|
||||||
|
[JsonProperty("Items4")] public List<List<int>> Items4 { get; set; } = [];
|
||||||
|
[JsonProperty("Items5")] public List<List<int>> Items5 { get; set; } = [];
|
||||||
|
[JsonProperty("Items6")] public List<List<int>> Items6 { get; set; } = [];
|
||||||
|
|
||||||
|
public List<List<int>> GetItems(uint breakLevel) => breakLevel switch
|
||||||
|
{
|
||||||
|
1 => Items1,
|
||||||
|
2 => Items2,
|
||||||
|
3 => Items3,
|
||||||
|
4 => Items4,
|
||||||
|
5 => Items5,
|
||||||
|
6 => Items6,
|
||||||
|
_ => []
|
||||||
|
};
|
||||||
|
|
||||||
|
public override uint GetId() => (uint)Id;
|
||||||
|
|
||||||
|
public override void Loaded()
|
||||||
|
{
|
||||||
|
GameData.BreakData[Id] = this;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
namespace MikuSB.Data.Excel;
|
namespace MikuSB.Data.Excel;
|
||||||
|
|
||||||
[ResourceEntity("break_level_limit.json")]
|
[ResourceEntity("item/break_level_limit.json")]
|
||||||
public class BreakLevelLimitExcel : ExcelResource
|
public class BreakLevelLimitExcel : ExcelResource
|
||||||
{
|
{
|
||||||
public int ID { get; set; }
|
public int ID { get; set; }
|
||||||
|
|||||||
24
Common/Data/Excel/CallItemExcel.cs
Normal file
24
Common/Data/Excel/CallItemExcel.cs
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
|
||||||
|
namespace MikuSB.Data.Excel;
|
||||||
|
|
||||||
|
[ResourceEntity("item/templates/call_item.json")]
|
||||||
|
public class CallItemExcel : ExcelResource
|
||||||
|
{
|
||||||
|
public uint Genre { get; set; }
|
||||||
|
public uint Detail { get; set; }
|
||||||
|
public uint Particular { get; set; }
|
||||||
|
public uint Level { get; set; }
|
||||||
|
public string I18n { get; set; } = "";
|
||||||
|
|
||||||
|
public override uint GetId()
|
||||||
|
{
|
||||||
|
return (uint)I18n.GetHashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Loaded()
|
||||||
|
{
|
||||||
|
GameData.CallItemData.Add(GetId(), this);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace MikuSB.Data.Excel;
|
namespace MikuSB.Data.Excel;
|
||||||
|
|
||||||
[ResourceEntity("card.json")]
|
[ResourceEntity("item/templates/card.json")]
|
||||||
public class CardExcel : ExcelResource
|
public class CardExcel : ExcelResource
|
||||||
{
|
{
|
||||||
public uint Genre { get; set; }
|
public uint Genre { get; set; }
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace MikuSB.Data.Excel;
|
namespace MikuSB.Data.Excel;
|
||||||
|
|
||||||
[ResourceEntity("card_skin.json")]
|
[ResourceEntity("item/templates/card_skin.json")]
|
||||||
public class CardSkinExcel : ExcelResource
|
public class CardSkinExcel : ExcelResource
|
||||||
{
|
{
|
||||||
public uint Genre { get; set; }
|
public uint Genre { get; set; }
|
||||||
|
|||||||
27
Common/Data/Excel/CardSkinPartsExcel.cs
Normal file
27
Common/Data/Excel/CardSkinPartsExcel.cs
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace MikuSB.Data.Excel;
|
||||||
|
|
||||||
|
[ResourceEntity("item/templates/card_skin_parts.json")]
|
||||||
|
public class CardSkinPartsExcel : ExcelResource
|
||||||
|
{
|
||||||
|
public uint Genre { get; set; }
|
||||||
|
public uint Detail { get; set; }
|
||||||
|
public uint Particular { get; set; }
|
||||||
|
public uint Level { get; set; }
|
||||||
|
public uint Icon { get; set; }
|
||||||
|
public int AppearID { get; set; }
|
||||||
|
[JsonProperty("profile")] public List<List<int>> CardSkinID { get; set; } = [];
|
||||||
|
public string I18n { get; set; } = "";
|
||||||
|
[JsonIgnore] public ulong TemplateId { get; set; }
|
||||||
|
public override uint GetId()
|
||||||
|
{
|
||||||
|
return (uint)I18n.GetHashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Loaded()
|
||||||
|
{
|
||||||
|
TemplateId = GameResourceTemplateId.FromGdpl(Genre, Detail, Particular, Level);
|
||||||
|
GameData.CardSkinPartsData.Add(Icon, this);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
namespace MikuSB.Data.Excel;
|
namespace MikuSB.Data.Excel;
|
||||||
|
|
||||||
[ResourceEntity("level.json")]
|
[ResourceEntity("chapter/level.json")]
|
||||||
public class ChapterLevelExcel : ExcelResource
|
public class ChapterLevelExcel : ExcelResource
|
||||||
{
|
{
|
||||||
public uint ID { get; set; }
|
public uint ID { get; set; }
|
||||||
|
|||||||
56
Common/Data/Excel/ClimbTowerAwardExcel.cs
Normal file
56
Common/Data/Excel/ClimbTowerAwardExcel.cs
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
|
||||||
|
namespace MikuSB.Data.Excel;
|
||||||
|
|
||||||
|
[ResourceEntity("challenge/climbtower/climb_tower_award.json")]
|
||||||
|
public class ClimbTowerAwardExcel : ExcelResource
|
||||||
|
{
|
||||||
|
[JsonProperty("ID")] public uint ID { get; set; }
|
||||||
|
[JsonProperty("Diff")] public JToken? DiffRaw { get; set; }
|
||||||
|
[JsonProperty("FirstAward")] public List<List<uint>> FirstAward { get; set; } = [];
|
||||||
|
[JsonProperty("StarCount1")] public int StarCount1 { get; set; }
|
||||||
|
[JsonProperty("StarAward1")] public List<List<uint>> StarAward1 { get; set; } = [];
|
||||||
|
[JsonProperty("StarCount2")] public int StarCount2 { get; set; }
|
||||||
|
[JsonProperty("StarAward2")] public List<List<uint>> StarAward2 { get; set; } = [];
|
||||||
|
[JsonProperty("StarCount3")] public int StarCount3 { get; set; }
|
||||||
|
[JsonProperty("StarAward3")] public List<List<uint>> StarAward3 { get; set; } = [];
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
public int Diff => DiffRaw?.Type switch
|
||||||
|
{
|
||||||
|
JTokenType.Integer => Math.Max(1, DiffRaw.Value<int>()),
|
||||||
|
JTokenType.String when int.TryParse(DiffRaw.Value<string>(), out var value) => Math.Max(1, value),
|
||||||
|
_ => 1
|
||||||
|
};
|
||||||
|
|
||||||
|
public override uint GetId() => (ID * 10u) + (uint)Diff;
|
||||||
|
|
||||||
|
public override void Loaded()
|
||||||
|
{
|
||||||
|
if (!GameData.ClimbTowerAwardData.TryGetValue(ID, out var diffMap))
|
||||||
|
{
|
||||||
|
diffMap = [];
|
||||||
|
GameData.ClimbTowerAwardData[ID] = diffMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
diffMap[Diff] = this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int GetStarCount(int group) => group switch
|
||||||
|
{
|
||||||
|
1 => StarCount1,
|
||||||
|
2 => StarCount2,
|
||||||
|
3 => StarCount3,
|
||||||
|
_ => 0
|
||||||
|
};
|
||||||
|
|
||||||
|
public IReadOnlyList<IReadOnlyList<uint>> GetRewards(int group) => group switch
|
||||||
|
{
|
||||||
|
0 => FirstAward,
|
||||||
|
1 => StarAward1,
|
||||||
|
2 => StarAward2,
|
||||||
|
3 => StarAward3,
|
||||||
|
_ => []
|
||||||
|
};
|
||||||
|
}
|
||||||
18
Common/Data/Excel/ClimbTowerDiffExcel.cs
Normal file
18
Common/Data/Excel/ClimbTowerDiffExcel.cs
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace MikuSB.Data.Excel;
|
||||||
|
|
||||||
|
[ResourceEntity("challenge/climbtower/climb_tower_diff.json")]
|
||||||
|
public class ClimbTowerDiffExcel : ExcelResource
|
||||||
|
{
|
||||||
|
[JsonProperty("ID")] public uint ID { get; set; }
|
||||||
|
[JsonProperty("Level1")] public int Level1 { get; set; }
|
||||||
|
[JsonProperty("Level2")] public int Level2 { get; set; }
|
||||||
|
|
||||||
|
public override uint GetId() => ID;
|
||||||
|
|
||||||
|
public override void Loaded()
|
||||||
|
{
|
||||||
|
GameData.ClimbTowerDiffData[ID] = this;
|
||||||
|
}
|
||||||
|
}
|
||||||
17
Common/Data/Excel/ClimbTowerLevelOrderExcel.cs
Normal file
17
Common/Data/Excel/ClimbTowerLevelOrderExcel.cs
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace MikuSB.Data.Excel;
|
||||||
|
|
||||||
|
[ResourceEntity("challenge/climbtower/climb_tower_levelorder.json")]
|
||||||
|
public class ClimbTowerLevelOrderExcel : ExcelResource
|
||||||
|
{
|
||||||
|
[JsonProperty("ID")] public uint ID { get; set; }
|
||||||
|
[JsonProperty("LevelID")] public uint LevelID { get; set; }
|
||||||
|
|
||||||
|
public override uint GetId() => ID;
|
||||||
|
|
||||||
|
public override void Loaded()
|
||||||
|
{
|
||||||
|
GameData.ClimbTowerLevelOrderData[ID] = this;
|
||||||
|
}
|
||||||
|
}
|
||||||
57
Common/Data/Excel/ClimbTowerTimeExcel.cs
Normal file
57
Common/Data/Excel/ClimbTowerTimeExcel.cs
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
using System.Globalization;
|
||||||
|
|
||||||
|
namespace MikuSB.Data.Excel;
|
||||||
|
|
||||||
|
[ResourceEntity("challenge/climbtower/climb_tower_time.json")]
|
||||||
|
public class ClimbTowerTimeExcel : ExcelResource
|
||||||
|
{
|
||||||
|
[JsonProperty("ID")] public uint ID { get; set; }
|
||||||
|
[JsonProperty("StartTime")] public string StartTime { get; set; } = "";
|
||||||
|
[JsonProperty("EndTime")] public string EndTime { get; set; } = "";
|
||||||
|
[JsonProperty("Level1")] public List<List<uint>> Level1 { get; set; } = [];
|
||||||
|
[JsonProperty("Level2")] public JToken? Level2Raw { get; set; }
|
||||||
|
|
||||||
|
public override uint GetId() => ID;
|
||||||
|
|
||||||
|
public override void Loaded()
|
||||||
|
{
|
||||||
|
GameData.ClimbTowerTimeData[ID] = this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IReadOnlyList<IReadOnlyList<uint>> GetLevelGroups(int type)
|
||||||
|
{
|
||||||
|
if (type == 1)
|
||||||
|
return Level1;
|
||||||
|
|
||||||
|
if (Level2Raw == null)
|
||||||
|
return [];
|
||||||
|
|
||||||
|
if (Level2Raw.Type == JTokenType.Array)
|
||||||
|
{
|
||||||
|
return Level2Raw
|
||||||
|
.Children()
|
||||||
|
.OfType<JArray>()
|
||||||
|
.Select(x => (IReadOnlyList<uint>)x.Values<uint>().ToList())
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Level2Raw.Type == JTokenType.Object)
|
||||||
|
{
|
||||||
|
return Level2Raw
|
||||||
|
.Children<JProperty>()
|
||||||
|
.Select(x => new
|
||||||
|
{
|
||||||
|
Key = uint.TryParse(x.Name, CultureInfo.InvariantCulture, out var key) ? key : 0u,
|
||||||
|
Value = x.Value.Type == JTokenType.Integer ? x.Value.Value<uint>() : 0u
|
||||||
|
})
|
||||||
|
.Where(x => x.Key > 0 && x.Value > 0)
|
||||||
|
.OrderBy(x => x.Key)
|
||||||
|
.Select(x => (IReadOnlyList<uint>)new List<uint> { x.Key, x.Value })
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
namespace MikuSB.Data.Excel;
|
namespace MikuSB.Data.Excel;
|
||||||
|
|
||||||
[ResourceEntity("daily_level.json")]
|
[ResourceEntity("daily/level.json")]
|
||||||
public class DailyLevelExcel : ExcelResource
|
public class DailyLevelExcel : ExcelResource
|
||||||
{
|
{
|
||||||
public uint ID { get; set; }
|
public uint ID { get; set; }
|
||||||
|
|||||||
21
Common/Data/Excel/DlcActivityExcel.cs
Normal file
21
Common/Data/Excel/DlcActivityExcel.cs
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace MikuSB.Data.Excel;
|
||||||
|
|
||||||
|
[ResourceEntity("dlc/dlc_activities.json")]
|
||||||
|
public class DlcActivityExcel : ExcelResource
|
||||||
|
{
|
||||||
|
[JsonProperty("ID")] public uint Id { get; set; }
|
||||||
|
[JsonProperty("StartTime")] public string StartTime { get; set; } = "";
|
||||||
|
[JsonProperty("EndTime")] public string EndTime { get; set; } = "";
|
||||||
|
[JsonProperty("EnterStartTime")] public string EnterStartTime { get; set; } = "";
|
||||||
|
[JsonProperty("CloseEndTime")] public string CloseEndTime { get; set; } = "";
|
||||||
|
[JsonProperty("Condition")] public string Condition { get; set; } = "";
|
||||||
|
|
||||||
|
public override uint GetId() => Id;
|
||||||
|
|
||||||
|
public override void Loaded()
|
||||||
|
{
|
||||||
|
GameData.DlcActivityData[Id] = this;
|
||||||
|
}
|
||||||
|
}
|
||||||
21
Common/Data/Excel/DormGiftExcel.cs
Normal file
21
Common/Data/Excel/DormGiftExcel.cs
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
namespace MikuSB.Data.Excel;
|
||||||
|
|
||||||
|
[ResourceEntity("item/templates/dorm_gift.json")]
|
||||||
|
public class DormGiftExcel : ExcelResource
|
||||||
|
{
|
||||||
|
public uint Genre { get; set; }
|
||||||
|
public uint Detail { get; set; }
|
||||||
|
public uint Particular { get; set; }
|
||||||
|
public uint Level { get; set; }
|
||||||
|
public string I18n { get; set; } = "";
|
||||||
|
|
||||||
|
public override uint GetId()
|
||||||
|
{
|
||||||
|
return (Genre << 24) | (Detail << 16) | (Particular << 8) | Level;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Loaded()
|
||||||
|
{
|
||||||
|
GameData.DormGiftData.Add(GetId(), this);
|
||||||
|
}
|
||||||
|
}
|
||||||
20
Common/Data/Excel/DreamCardActivityExcel.cs
Normal file
20
Common/Data/Excel/DreamCardActivityExcel.cs
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace MikuSB.Data.Excel;
|
||||||
|
|
||||||
|
[ResourceEntity("dlc/DreamCard/activity.json")]
|
||||||
|
public class DreamCardActivityExcel : ExcelResource
|
||||||
|
{
|
||||||
|
[JsonProperty("ID")] public uint ID { get; set; }
|
||||||
|
[JsonProperty("StartTime")] public string StartTime { get; set; } = "";
|
||||||
|
[JsonProperty("EndTime")] public string EndTime { get; set; } = "";
|
||||||
|
[JsonProperty("Condition")] public string Condition { get; set; } = "";
|
||||||
|
[JsonProperty("LevelListID")] public List<uint> LevelListID { get; set; } = [];
|
||||||
|
|
||||||
|
public override uint GetId() => ID;
|
||||||
|
|
||||||
|
public override void Loaded()
|
||||||
|
{
|
||||||
|
GameData.DreamCardActivityData[ID] = this;
|
||||||
|
}
|
||||||
|
}
|
||||||
89
Common/Data/Excel/FishingFoodExcel.cs
Normal file
89
Common/Data/Excel/FishingFoodExcel.cs
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
|
||||||
|
namespace MikuSB.Data.Excel;
|
||||||
|
|
||||||
|
[ResourceEntity("dlc/fishing/food.json")]
|
||||||
|
public class FishingFoodExcel : ExcelResource
|
||||||
|
{
|
||||||
|
[JsonProperty("ID")] public uint Id { get; set; }
|
||||||
|
[JsonProperty("FoodType")] public JToken? FoodTypeRaw { get; set; }
|
||||||
|
[JsonProperty("NeedItem")] public JToken? NeedItemRaw { get; set; }
|
||||||
|
[JsonProperty("CreateItems")] public JToken? CreateItemsRaw { get; set; }
|
||||||
|
[JsonProperty("EffectTime")] public JToken? EffectTimeRaw { get; set; }
|
||||||
|
[JsonProperty("FishingLevel")] public JToken? FishingLevelRaw { get; set; }
|
||||||
|
[JsonProperty("SeasonId")] public JToken? SeasonIdRaw { get; set; }
|
||||||
|
[JsonProperty("BaitNum")] public JToken? BaitNumRaw { get; set; }
|
||||||
|
[JsonProperty("FoodArea")] public JToken? FoodAreaRaw { get; set; }
|
||||||
|
|
||||||
|
[JsonIgnore] public uint FoodType => ReadUInt(FoodTypeRaw);
|
||||||
|
[JsonIgnore] public uint EffectTime => ReadUInt(EffectTimeRaw);
|
||||||
|
[JsonIgnore] public uint FishingLevel => ReadUInt(FishingLevelRaw);
|
||||||
|
[JsonIgnore] public uint SeasonId => ReadUInt(SeasonIdRaw);
|
||||||
|
[JsonIgnore] public List<List<uint>> NeedItem => ReadNestedUIntList(NeedItemRaw);
|
||||||
|
[JsonIgnore] public List<uint> CreateItems => ReadUIntList(CreateItemsRaw);
|
||||||
|
[JsonIgnore] public List<uint> BaitNum => ReadUIntList(BaitNumRaw);
|
||||||
|
[JsonIgnore] public List<uint> FoodArea => ReadUIntList(FoodAreaRaw);
|
||||||
|
|
||||||
|
public override uint GetId() => Id;
|
||||||
|
|
||||||
|
public override void Loaded()
|
||||||
|
{
|
||||||
|
GameData.FishingFoodData[Id] = this;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int ReadInt(JToken? token)
|
||||||
|
{
|
||||||
|
if (token == null)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return token.Type switch
|
||||||
|
{
|
||||||
|
JTokenType.Integer => token.Value<int>(),
|
||||||
|
JTokenType.Float => (int)token.Value<decimal>(),
|
||||||
|
JTokenType.String when int.TryParse(token.Value<string>(), out var value) => value,
|
||||||
|
_ => 0
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private static uint ReadUInt(JToken? token)
|
||||||
|
{
|
||||||
|
var value = ReadInt(token);
|
||||||
|
return value > 0 ? (uint)value : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<uint> ReadUIntList(JToken? token)
|
||||||
|
{
|
||||||
|
if (token is not JArray array)
|
||||||
|
return [];
|
||||||
|
|
||||||
|
var result = new List<uint>(array.Count);
|
||||||
|
foreach (var item in array)
|
||||||
|
{
|
||||||
|
var value = ReadUInt(item);
|
||||||
|
if (value > 0)
|
||||||
|
result.Add(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<List<uint>> ReadNestedUIntList(JToken? token)
|
||||||
|
{
|
||||||
|
if (token is not JArray array)
|
||||||
|
return [];
|
||||||
|
|
||||||
|
var result = new List<List<uint>>(array.Count);
|
||||||
|
foreach (var row in array.OfType<JArray>())
|
||||||
|
{
|
||||||
|
var values = new List<uint>(row.Count);
|
||||||
|
foreach (var item in row)
|
||||||
|
{
|
||||||
|
values.Add(ReadUInt(item));
|
||||||
|
}
|
||||||
|
result.Add(values);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
46
Common/Data/Excel/GachaExcel.cs
Normal file
46
Common/Data/Excel/GachaExcel.cs
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
using MikuSB.Util;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
|
||||||
|
namespace MikuSB.Data.Excel;
|
||||||
|
|
||||||
|
[ResourceEntity("gacha/gacha.json")]
|
||||||
|
public class GachaExcel : ExcelResource
|
||||||
|
{
|
||||||
|
public uint ID { get; set; }
|
||||||
|
public List<string>? Pool { get; set; }
|
||||||
|
public uint Probability { get; set; }
|
||||||
|
public uint ProbabilityTen { get; set; }
|
||||||
|
public JToken? ProtectNum { get; set; }
|
||||||
|
public JToken? UpNum { get; set; }
|
||||||
|
public uint? ProtectTag { get; set; }
|
||||||
|
public uint? ProtectType { get; set; }
|
||||||
|
public JToken? ProtectCount { get; set; }
|
||||||
|
public uint? UpSelect { get; set; }
|
||||||
|
|
||||||
|
public override uint GetId() => ID;
|
||||||
|
public override void Loaded() => GameData.GachaData[ID] = this;
|
||||||
|
|
||||||
|
public override void AfterAllDone()
|
||||||
|
{
|
||||||
|
foreach (var poolName in Pool ?? [])
|
||||||
|
{
|
||||||
|
if (GameData.GachaPoolData.ContainsKey(poolName)) continue;
|
||||||
|
var path = ConfigManager.Config.Path.ResourcePath + "/gacha/pool/" + poolName + ".json";
|
||||||
|
if (!File.Exists(path)) continue;
|
||||||
|
var json = File.ReadAllText(path);
|
||||||
|
var items = JsonConvert.DeserializeObject<List<GachaPoolItem>>(json) ?? [];
|
||||||
|
GameData.GachaPoolData[poolName] = items;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class GachaPoolItem
|
||||||
|
{
|
||||||
|
public int ID { get; set; }
|
||||||
|
public int Rarity { get; set; }
|
||||||
|
public List<uint> GDPL { get; set; } = [];
|
||||||
|
public int Weight { get; set; }
|
||||||
|
public int? UPTag { get; set; }
|
||||||
|
public int? UPSelectTag { get; set; }
|
||||||
|
}
|
||||||
18
Common/Data/Excel/GachaProbabilityExcel.cs
Normal file
18
Common/Data/Excel/GachaProbabilityExcel.cs
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
namespace MikuSB.Data.Excel;
|
||||||
|
|
||||||
|
[ResourceEntity("gacha/probability.json")]
|
||||||
|
public class GachaProbabilityExcel : ExcelResource
|
||||||
|
{
|
||||||
|
public uint ID { get; set; }
|
||||||
|
public int Rarity1 { get; set; }
|
||||||
|
public int Rarity2 { get; set; }
|
||||||
|
public int Rarity3 { get; set; }
|
||||||
|
public int Rarity4 { get; set; }
|
||||||
|
public int Rarity5 { get; set; }
|
||||||
|
public int Rarity6 { get; set; }
|
||||||
|
|
||||||
|
public int[] Weights => [Rarity1, Rarity2, Rarity3, Rarity4, Rarity5, Rarity6];
|
||||||
|
|
||||||
|
public override uint GetId() => ID;
|
||||||
|
public override void Loaded() => GameData.GachaProbabilityData[ID] = this;
|
||||||
|
}
|
||||||
21
Common/Data/Excel/GuideExcel.cs
Normal file
21
Common/Data/Excel/GuideExcel.cs
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
using MikuSB.Data.Config;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace MikuSB.Data.Excel;
|
||||||
|
|
||||||
|
[ResourceEntity("guide/guide.json")]
|
||||||
|
public class GuideExcel : ExcelResource
|
||||||
|
{
|
||||||
|
public uint ID { get; set; }
|
||||||
|
[JsonConverter(typeof(StringToUIntConverter))] public uint Group { get; set; }
|
||||||
|
|
||||||
|
public override uint GetId()
|
||||||
|
{
|
||||||
|
return (ID << 48) | (Group << 32);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Loaded()
|
||||||
|
{
|
||||||
|
GameData.GuideData.TryAdd(GetId(), this);
|
||||||
|
}
|
||||||
|
}
|
||||||
18
Common/Data/Excel/HouseFurniturePosData.cs
Normal file
18
Common/Data/Excel/HouseFurniturePosData.cs
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
namespace MikuSB.Data.Excel;
|
||||||
|
|
||||||
|
[ResourceEntity("house/FurniturePos.json")]
|
||||||
|
public class HouseFurniturePosExcel : ExcelResource
|
||||||
|
{
|
||||||
|
public uint AreaId { get; set; }
|
||||||
|
public uint GroupId { get; set; }
|
||||||
|
|
||||||
|
public override uint GetId()
|
||||||
|
{
|
||||||
|
return (AreaId << 48) | (GroupId << 32);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Loaded()
|
||||||
|
{
|
||||||
|
GameData.HouseFurniturePosData.TryAdd(GetId(), this);
|
||||||
|
}
|
||||||
|
}
|
||||||
76
Common/Data/Excel/IbGoodsExcel.cs
Normal file
76
Common/Data/Excel/IbGoodsExcel.cs
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
|
||||||
|
namespace MikuSB.Data.Excel;
|
||||||
|
|
||||||
|
[ResourceEntity("purchase/ibgoods.json")]
|
||||||
|
public class IbGoodsExcel : ExcelResource
|
||||||
|
{
|
||||||
|
[JsonProperty("GoodsId")] private JToken? GoodsIdRaw { get; set; }
|
||||||
|
[JsonProperty("Type")] private JToken? TypeRaw { get; set; }
|
||||||
|
[JsonProperty("PreId")] private JToken? PreIdRaw { get; set; }
|
||||||
|
[JsonProperty("LimitTimes")] private JToken? LimitTimesRaw { get; set; }
|
||||||
|
[JsonProperty("Item")] private JToken? ItemRaw { get; set; }
|
||||||
|
[JsonProperty("Cost")] private JToken? CostRaw { get; set; }
|
||||||
|
[JsonProperty("Cost2")] private JToken? Cost2Raw { get; set; }
|
||||||
|
[JsonProperty("PcId")] public string PcId { get; set; } = "";
|
||||||
|
[JsonProperty("IosId")] public string IosId { get; set; } = "";
|
||||||
|
[JsonProperty("AndroidId")] public string AndroidId { get; set; } = "";
|
||||||
|
|
||||||
|
public override uint GetId() => GoodsId;
|
||||||
|
|
||||||
|
public override void Loaded()
|
||||||
|
{
|
||||||
|
GameData.IbGoodsData[GoodsId] = this;
|
||||||
|
}
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
public uint GoodsId => ReadUInt(GoodsIdRaw);
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
public int Type => (int)ReadUInt(TypeRaw);
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
public uint PreId => ReadUInt(PreIdRaw);
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
public uint LimitTimes => ReadUInt(LimitTimesRaw);
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
public List<uint> Item => ReadUIntList(ItemRaw);
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
public List<uint> Cost => ReadUIntList(CostRaw);
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
public List<uint> Cost2 => ReadUIntList(Cost2Raw);
|
||||||
|
|
||||||
|
public string GetProductId() =>
|
||||||
|
!string.IsNullOrWhiteSpace(PcId) ? PcId :
|
||||||
|
!string.IsNullOrWhiteSpace(AndroidId) ? AndroidId :
|
||||||
|
IosId;
|
||||||
|
|
||||||
|
private static uint ReadUInt(JToken? token)
|
||||||
|
{
|
||||||
|
if (token == null || token.Type is JTokenType.Null or JTokenType.Undefined)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (token.Type == JTokenType.Integer)
|
||||||
|
return token.Value<uint>();
|
||||||
|
|
||||||
|
if (token.Type == JTokenType.String && uint.TryParse(token.Value<string>(), out var value))
|
||||||
|
return value;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<uint> ReadUIntList(JToken? token)
|
||||||
|
{
|
||||||
|
if (token is not JArray array)
|
||||||
|
return [];
|
||||||
|
|
||||||
|
return array
|
||||||
|
.Select(entry => entry.Type == JTokenType.Integer ? entry.Value<uint>() : 0u)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace MikuSB.Data.Excel;
|
namespace MikuSB.Data.Excel;
|
||||||
|
|
||||||
[ResourceEntity("manifestation.json")]
|
[ResourceEntity("item/templates/manifestation.json")]
|
||||||
public class ManifestationExcel : ExcelResource
|
public class ManifestationExcel : ExcelResource
|
||||||
{
|
{
|
||||||
public uint Genre { get; set; }
|
public uint Genre { get; set; }
|
||||||
|
|||||||
26
Common/Data/Excel/MonsterCardExcel.cs
Normal file
26
Common/Data/Excel/MonsterCardExcel.cs
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace MikuSB.Data.Excel;
|
||||||
|
|
||||||
|
[ResourceEntity("item/templates/monster_card.json")]
|
||||||
|
public class MonsterCardExcel : ExcelResource
|
||||||
|
{
|
||||||
|
[JsonProperty("Genre")] public uint Genre { get; set; }
|
||||||
|
[JsonProperty("Detail")] public uint Detail { get; set; }
|
||||||
|
[JsonProperty("Particular")] public uint Particular { get; set; }
|
||||||
|
[JsonProperty("Level")] public uint Level { get; set; }
|
||||||
|
[JsonProperty("Color")] public uint Color { get; set; }
|
||||||
|
[JsonProperty("RikiId")] public uint RikiId { get; set; }
|
||||||
|
[JsonProperty("CostValue")] public uint CostValue { get; set; }
|
||||||
|
[JsonProperty("Exp")] public uint Exp { get; set; }
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
public ulong TemplateId => GameResourceTemplateId.FromGdpl(Genre, Detail, Particular, Level);
|
||||||
|
|
||||||
|
public override uint GetId() => Particular;
|
||||||
|
|
||||||
|
public override void Loaded()
|
||||||
|
{
|
||||||
|
GameData.MonsterCardData[TemplateId] = this;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace MikuSB.Data.Excel;
|
namespace MikuSB.Data.Excel;
|
||||||
|
|
||||||
// nodecondition.json: NodeConditionId → NodeXCost per sub-node (1-9)
|
// nodecondition.json: NodeConditionId → NodeXCost per sub-node (1-9)
|
||||||
[ResourceEntity("nodecondition.json")]
|
[ResourceEntity("item/skill/nodecondition.json")]
|
||||||
public class NodeConditionExcel : ExcelResource
|
public class NodeConditionExcel : ExcelResource
|
||||||
{
|
{
|
||||||
[JsonProperty("ID")] public uint Id { get; set; }
|
[JsonProperty("ID")] public uint Id { get; set; }
|
||||||
|
|||||||
47
Common/Data/Excel/OtherItemExcel.cs
Normal file
47
Common/Data/Excel/OtherItemExcel.cs
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
|
||||||
|
namespace MikuSB.Data.Excel;
|
||||||
|
|
||||||
|
[ResourceEntity("item/templates/others.json")]
|
||||||
|
public class OtherItemExcel : ExcelResource
|
||||||
|
{
|
||||||
|
public uint Genre { get; set; }
|
||||||
|
public uint Detail { get; set; }
|
||||||
|
public uint Particular { get; set; }
|
||||||
|
public uint Level { get; set; }
|
||||||
|
public string LuaType { get; set; } = "";
|
||||||
|
[JsonProperty("UseMode")] public JToken? UseModeRaw { get; set; }
|
||||||
|
[JsonProperty("Param1")] public JToken? Param1Raw { get; set; }
|
||||||
|
[JsonProperty("GMnum")] public JToken? GMnumRaw { get; set; }
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
public uint UseMode => ReadUInt(UseModeRaw);
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
public uint Param1 => ReadUInt(Param1Raw);
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
public uint GMnum => ReadUInt(GMnumRaw);
|
||||||
|
|
||||||
|
public override uint GetId() => (uint)GameResourceTemplateId.FromGdpl(Genre, Detail, Particular, Level);
|
||||||
|
|
||||||
|
public override void Loaded()
|
||||||
|
{
|
||||||
|
GameData.OtherItemData[GetId()] = this;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static uint ReadUInt(JToken? token)
|
||||||
|
{
|
||||||
|
if (token == null)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return token.Type switch
|
||||||
|
{
|
||||||
|
JTokenType.Integer => token.Value<uint>(),
|
||||||
|
JTokenType.Float => (uint)Math.Max(0, token.Value<decimal>()),
|
||||||
|
JTokenType.String when uint.TryParse(token.Value<string>(), out var value) => value,
|
||||||
|
_ => 0
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
22
Common/Data/Excel/ProfileExcel.cs
Normal file
22
Common/Data/Excel/ProfileExcel.cs
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
namespace MikuSB.Data.Excel;
|
||||||
|
|
||||||
|
[ResourceEntity("item/templates/profile.json")]
|
||||||
|
public class ProfileExcel : ExcelResource
|
||||||
|
{
|
||||||
|
public uint Genre { get; set; }
|
||||||
|
public uint Detail { get; set; }
|
||||||
|
public uint Particular { get; set; }
|
||||||
|
public uint Level { get; set; }
|
||||||
|
public string I18n { get; set; } = "";
|
||||||
|
public string LuaType { get; set; } = "";
|
||||||
|
|
||||||
|
public override uint GetId()
|
||||||
|
{
|
||||||
|
return (uint)I18n.GetHashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Loaded()
|
||||||
|
{
|
||||||
|
GameData.ProfileData.Add(GetId(), this);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,11 +1,12 @@
|
|||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
|
|
||||||
namespace MikuSB.Data.Excel;
|
namespace MikuSB.Data.Excel;
|
||||||
|
|
||||||
[ResourceEntity("recycle.json")]
|
[ResourceEntity("item/recycle.json")]
|
||||||
public class RecycleExcel : ExcelResource
|
public class RecycleExcel : ExcelResource
|
||||||
{
|
{
|
||||||
public int ID { get; set; }
|
public int ID { get; set; }
|
||||||
|
public JToken? RecycleReward { get; set; }
|
||||||
public JToken? RecycleBase { get; set; }
|
public JToken? RecycleBase { get; set; }
|
||||||
public JToken? RecycleRatio { get; set; }
|
public JToken? RecycleRatio { get; set; }
|
||||||
|
|
||||||
|
|||||||
18
Common/Data/Excel/Rogue3DDailyBuffExcel.cs
Normal file
18
Common/Data/Excel/Rogue3DDailyBuffExcel.cs
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace MikuSB.Data.Excel;
|
||||||
|
|
||||||
|
[ResourceEntity("dlc/rogue3d/dailybuff.json")]
|
||||||
|
public class Rogue3DDailyBuffExcel : ExcelResource
|
||||||
|
{
|
||||||
|
[JsonProperty("ID")] public uint Id { get; set; }
|
||||||
|
[JsonProperty("GroupID")] public uint GroupId { get; set; }
|
||||||
|
[JsonProperty("ScoreBuffID")] public uint ScoreBuffId { get; set; }
|
||||||
|
|
||||||
|
public override uint GetId() => Id;
|
||||||
|
|
||||||
|
public override void Loaded()
|
||||||
|
{
|
||||||
|
GameData.Rogue3DDailyBuffData[Id] = this;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace MikuSB.Data.Excel;
|
namespace MikuSB.Data.Excel;
|
||||||
|
|
||||||
[ResourceEntity("server_01_difficult.json")]
|
[ResourceEntity("dlc/rogue3d/server_01_difficult.json")]
|
||||||
public class Rogue3DDifficultExcel : ExcelResource
|
public class Rogue3DDifficultExcel : ExcelResource
|
||||||
{
|
{
|
||||||
[JsonProperty("DifficultID")] public uint DifficultId { get; set; }
|
[JsonProperty("DifficultID")] public uint DifficultId { get; set; }
|
||||||
|
|||||||
19
Common/Data/Excel/Rogue3DSeasonExcel.cs
Normal file
19
Common/Data/Excel/Rogue3DSeasonExcel.cs
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace MikuSB.Data.Excel;
|
||||||
|
|
||||||
|
[ResourceEntity("dlc/rogue3d/server_10_season.json")]
|
||||||
|
public class Rogue3DSeasonExcel : ExcelResource
|
||||||
|
{
|
||||||
|
[JsonProperty("SeasonID")] public uint SeasonId { get; set; }
|
||||||
|
[JsonProperty("Type")] public int Type { get; set; }
|
||||||
|
[JsonProperty("OpenTime")] public string OpenTime { get; set; } = "";
|
||||||
|
[JsonProperty("CloseTime")] public string CloseTime { get; set; } = "";
|
||||||
|
|
||||||
|
public override uint GetId() => SeasonId;
|
||||||
|
|
||||||
|
public override void Loaded()
|
||||||
|
{
|
||||||
|
GameData.Rogue3DSeasonData[SeasonId] = this;
|
||||||
|
}
|
||||||
|
}
|
||||||
31
Common/Data/Excel/Rogue3DTalentExcel.cs
Normal file
31
Common/Data/Excel/Rogue3DTalentExcel.cs
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace MikuSB.Data.Excel;
|
||||||
|
|
||||||
|
[ResourceEntity("dlc/rogue3d/server_03_talent.json")]
|
||||||
|
public class Rogue3DTalentExcel : ExcelResource
|
||||||
|
{
|
||||||
|
[JsonProperty("TalentID")] public uint TalentId { get; set; }
|
||||||
|
[JsonProperty("UnlockCondition")] private object? UnlockConditionRaw { get; set; }
|
||||||
|
[JsonIgnore] public uint UnlockCondition { get; private set; }
|
||||||
|
|
||||||
|
public override uint GetId() => TalentId;
|
||||||
|
|
||||||
|
public override void Loaded()
|
||||||
|
{
|
||||||
|
UnlockCondition = ParseUnlockCondition(UnlockConditionRaw);
|
||||||
|
GameData.Rogue3DTalentData[TalentId] = this;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static uint ParseUnlockCondition(object? raw)
|
||||||
|
{
|
||||||
|
return raw switch
|
||||||
|
{
|
||||||
|
null => 0,
|
||||||
|
long value when value > 0 => (uint)value,
|
||||||
|
int value when value > 0 => (uint)value,
|
||||||
|
string text when uint.TryParse(text, out var value) => value,
|
||||||
|
_ => 0
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
14
Common/Data/Excel/RoleLevelExcel.cs
Normal file
14
Common/Data/Excel/RoleLevelExcel.cs
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
namespace MikuSB.Data.Excel;
|
||||||
|
|
||||||
|
[ResourceEntity("challenge/role/level.json")]
|
||||||
|
public class RoleLevelExcel : ExcelResource
|
||||||
|
{
|
||||||
|
public uint ID { get; set; }
|
||||||
|
|
||||||
|
public override uint GetId() => ID;
|
||||||
|
|
||||||
|
public override void Loaded()
|
||||||
|
{
|
||||||
|
GameData.RoleLevelData[ID] = this;
|
||||||
|
}
|
||||||
|
}
|
||||||
39
Common/Data/Excel/SpecialBreakExcel.cs
Normal file
39
Common/Data/Excel/SpecialBreakExcel.cs
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace MikuSB.Data.Excel;
|
||||||
|
|
||||||
|
[ResourceEntity("item/cardbreak/breaknew.json")]
|
||||||
|
public class SpecialBreakExcel : ExcelResource
|
||||||
|
{
|
||||||
|
[JsonProperty("ID")] public int Id { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("1Items1")] public List<List<int>> Items1 { get; set; } = [];
|
||||||
|
[JsonProperty("2Items1")] public List<List<int>> Items2 { get; set; } = [];
|
||||||
|
[JsonProperty("3Items1")] public List<List<int>> Items3 { get; set; } = [];
|
||||||
|
[JsonProperty("4Items1")] public List<List<int>> Items4 { get; set; } = [];
|
||||||
|
|
||||||
|
public List<List<int>> GetItems(uint breakLevel) => breakLevel switch
|
||||||
|
{
|
||||||
|
1 => Items1,
|
||||||
|
2 => Items2,
|
||||||
|
3 => Items3,
|
||||||
|
4 => Items4,
|
||||||
|
_ => []
|
||||||
|
};
|
||||||
|
|
||||||
|
public bool HasBreakLevel(uint breakLevel) => breakLevel switch
|
||||||
|
{
|
||||||
|
1 => Items1.Count > 0,
|
||||||
|
2 => Items2.Count > 0,
|
||||||
|
3 => Items3.Count > 0,
|
||||||
|
4 => Items4.Count > 0,
|
||||||
|
_ => false
|
||||||
|
};
|
||||||
|
|
||||||
|
public override uint GetId() => (uint)Id;
|
||||||
|
|
||||||
|
public override void Loaded()
|
||||||
|
{
|
||||||
|
GameData.SpecialBreakData[Id] = this;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace MikuSB.Data.Excel;
|
namespace MikuSB.Data.Excel;
|
||||||
|
|
||||||
// spine.json: SpineId → Node{i}Req (nodecondition ID per master node index)
|
// spine.json: SpineId → Node{i}Req (nodecondition ID per master node index)
|
||||||
[ResourceEntity("spine.json")]
|
[ResourceEntity("item/skill/spine.json")]
|
||||||
public class SpineExcel : ExcelResource
|
public class SpineExcel : ExcelResource
|
||||||
{
|
{
|
||||||
[JsonProperty("ID")] public uint Id { get; set; }
|
[JsonProperty("ID")] public uint Id { get; set; }
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
|
|
||||||
namespace MikuSB.Data.Excel;
|
namespace MikuSB.Data.Excel;
|
||||||
|
|
||||||
[ResourceEntity("suplies.json")]
|
[ResourceEntity("item/templates/suplies.json")]
|
||||||
public class SuppliesExcel : ExcelResource
|
public class SuppliesExcel : ExcelResource
|
||||||
{
|
{
|
||||||
public uint Genre { get; set; }
|
public uint Genre { get; set; }
|
||||||
|
|||||||
27
Common/Data/Excel/SupportAffixExcel.cs
Normal file
27
Common/Data/Excel/SupportAffixExcel.cs
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
|
||||||
|
namespace MikuSB.Data.Excel;
|
||||||
|
|
||||||
|
[ResourceEntity("item/support/affix.json")]
|
||||||
|
public class SupportAffixExcel : ExcelResource
|
||||||
|
{
|
||||||
|
[JsonProperty("ID")] public int Id { get; set; }
|
||||||
|
[JsonExtensionData] public IDictionary<string, JToken> ExtraData { get; set; } = new Dictionary<string, JToken>();
|
||||||
|
|
||||||
|
public int TierCount =>
|
||||||
|
ExtraData
|
||||||
|
.Where(x => x.Key != "ID" && x.Key != "Sift" && x.Key != "Comment")
|
||||||
|
.Select(x => x.Value)
|
||||||
|
.OfType<JObject>()
|
||||||
|
.Select(x => x.Count)
|
||||||
|
.DefaultIfEmpty(0)
|
||||||
|
.Max();
|
||||||
|
|
||||||
|
public override uint GetId() => (uint)Id;
|
||||||
|
|
||||||
|
public override void Loaded()
|
||||||
|
{
|
||||||
|
GameData.SupportAffixData[Id] = this;
|
||||||
|
}
|
||||||
|
}
|
||||||
35
Common/Data/Excel/SupportAffixPoolExcel.cs
Normal file
35
Common/Data/Excel/SupportAffixPoolExcel.cs
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace MikuSB.Data.Excel;
|
||||||
|
|
||||||
|
[ResourceEntity("item/support/affix_pool.json")]
|
||||||
|
public class SupportAffixPoolExcel : ExcelResource
|
||||||
|
{
|
||||||
|
[JsonProperty("ID")] public int Id { get; set; }
|
||||||
|
public List<int> AffixGroup1 { get; set; } = [];
|
||||||
|
public int Weight1 { get; set; }
|
||||||
|
public List<int> AffixGroup2 { get; set; } = [];
|
||||||
|
public int Weight2 { get; set; }
|
||||||
|
public List<int> AffixGroup3 { get; set; } = [];
|
||||||
|
public int Weight3 { get; set; }
|
||||||
|
public List<int> AffixGroup4 { get; set; } = [];
|
||||||
|
public int Weight4 { get; set; }
|
||||||
|
|
||||||
|
public IEnumerable<(IReadOnlyList<int> Affixs, int Weight)> Groups
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (AffixGroup1.Count > 0 && Weight1 > 0) yield return (AffixGroup1, Weight1);
|
||||||
|
if (AffixGroup2.Count > 0 && Weight2 > 0) yield return (AffixGroup2, Weight2);
|
||||||
|
if (AffixGroup3.Count > 0 && Weight3 > 0) yield return (AffixGroup3, Weight3);
|
||||||
|
if (AffixGroup4.Count > 0 && Weight4 > 0) yield return (AffixGroup4, Weight4);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override uint GetId() => (uint)Id;
|
||||||
|
|
||||||
|
public override void Loaded()
|
||||||
|
{
|
||||||
|
GameData.SupportAffixPoolData[Id] = this;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,8 +1,9 @@
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
|
||||||
namespace MikuSB.Data.Excel;
|
namespace MikuSB.Data.Excel;
|
||||||
|
|
||||||
[ResourceEntity("support_card.json")]
|
[ResourceEntity("item/templates/support_card.json")]
|
||||||
public class SupportCardExcel : ExcelResource
|
public class SupportCardExcel : ExcelResource
|
||||||
{
|
{
|
||||||
public uint Genre { get; set; }
|
public uint Genre { get; set; }
|
||||||
@@ -11,7 +12,13 @@ public class SupportCardExcel : ExcelResource
|
|||||||
public uint Level { get; set; }
|
public uint Level { get; set; }
|
||||||
public uint Icon { get; set; }
|
public uint Icon { get; set; }
|
||||||
public uint ProvideExp { get; set; }
|
public uint ProvideExp { get; set; }
|
||||||
|
public uint Color { get; set; }
|
||||||
|
[JsonProperty("RecycleID")] public int RecycleID { get; set; }
|
||||||
[JsonProperty("LevelLimitID")] public int LevelLimitId { get; set; }
|
[JsonProperty("LevelLimitID")] public int LevelLimitId { get; set; }
|
||||||
|
[JsonProperty("AffixPool")] public List<int> AffixPool { get; set; } = [];
|
||||||
|
[JsonProperty("AffixCost")] public JToken? AffixCostRaw { get; set; }
|
||||||
|
[JsonProperty("InitialAffixCost")] public JToken? InitialAffixCostRaw { get; set; }
|
||||||
|
[JsonProperty("FixedAffixCost")] public JToken? FixedAffixCostRaw { get; set; }
|
||||||
|
|
||||||
public uint MaxLevel => LevelLimitId switch
|
public uint MaxLevel => LevelLimitId switch
|
||||||
{
|
{
|
||||||
@@ -21,6 +28,19 @@ public class SupportCardExcel : ExcelResource
|
|||||||
_ => 10
|
_ => 10
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public int InitialAffixCount => Color >= 5 ? 2 : 1;
|
||||||
|
|
||||||
|
public int TotalAffixCount => Color >= 5 ? 3 : 2;
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
public IReadOnlyList<uint> AffixCost => ParseFlatCost(AffixCostRaw);
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
public IReadOnlyList<IReadOnlyList<uint>> InitialAffixCost => ParseNestedCost(InitialAffixCostRaw);
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
public IReadOnlyList<uint> FixedAffixCost => ParseFlatCost(FixedAffixCostRaw);
|
||||||
|
|
||||||
public ulong TemplateId => GameResourceTemplateId.FromGdpl(Genre, Detail, Particular, Level);
|
public ulong TemplateId => GameResourceTemplateId.FromGdpl(Genre, Detail, Particular, Level);
|
||||||
|
|
||||||
public override uint GetId() => Icon;
|
public override uint GetId() => Icon;
|
||||||
@@ -29,4 +49,23 @@ public class SupportCardExcel : ExcelResource
|
|||||||
{
|
{
|
||||||
GameData.SupportCardData.Add(this);
|
GameData.SupportCardData.Add(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static IReadOnlyList<uint> ParseFlatCost(JToken? token)
|
||||||
|
{
|
||||||
|
if (token is not JArray array)
|
||||||
|
return [];
|
||||||
|
|
||||||
|
return array.Select(x => x.Value<uint>()).ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static IReadOnlyList<IReadOnlyList<uint>> ParseNestedCost(JToken? token)
|
||||||
|
{
|
||||||
|
if (token is not JArray outer)
|
||||||
|
return [];
|
||||||
|
|
||||||
|
var result = new List<IReadOnlyList<uint>>();
|
||||||
|
foreach (var entry in outer.OfType<JArray>())
|
||||||
|
result.Add(entry.Select(x => x.Value<uint>()).ToArray());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
18
Common/Data/Excel/SupportFixedExcel.cs
Normal file
18
Common/Data/Excel/SupportFixedExcel.cs
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace MikuSB.Data.Excel;
|
||||||
|
|
||||||
|
[ResourceEntity("item/support/fixed.json")]
|
||||||
|
public class SupportFixedExcel : ExcelResource
|
||||||
|
{
|
||||||
|
[JsonProperty("ID")] public int Id { get; set; }
|
||||||
|
public int Num { get; set; }
|
||||||
|
public List<uint> Item { get; set; } = [];
|
||||||
|
|
||||||
|
public override uint GetId() => (uint)Id;
|
||||||
|
|
||||||
|
public override void Loaded()
|
||||||
|
{
|
||||||
|
GameData.SupportFixedData[Id] = this;
|
||||||
|
}
|
||||||
|
}
|
||||||
20
Common/Data/Excel/TowerEventLevelExcel.cs
Normal file
20
Common/Data/Excel/TowerEventLevelExcel.cs
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace MikuSB.Data.Excel;
|
||||||
|
|
||||||
|
[ResourceEntity("challenge/tower_event/level.json")]
|
||||||
|
public class TowerEventLevelExcel : ExcelResource
|
||||||
|
{
|
||||||
|
[JsonProperty("ID")] public uint ID { get; set; }
|
||||||
|
[JsonProperty("MapID")] public uint MapID { get; set; }
|
||||||
|
[JsonProperty("FightID")] public uint FightID { get; set; }
|
||||||
|
[JsonProperty("TaskPath")] public string TaskPath { get; set; } = "";
|
||||||
|
[JsonProperty("ConsumeVigor")] public List<int> ConsumeVigor { get; set; } = [];
|
||||||
|
|
||||||
|
public override uint GetId() => ID;
|
||||||
|
|
||||||
|
public override void Loaded()
|
||||||
|
{
|
||||||
|
GameData.TowerEventLevelData[ID] = this;
|
||||||
|
}
|
||||||
|
}
|
||||||
20
Common/Data/Excel/TowerLevelExcel.cs
Normal file
20
Common/Data/Excel/TowerLevelExcel.cs
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace MikuSB.Data.Excel;
|
||||||
|
|
||||||
|
[ResourceEntity("challenge/climbtower/level.json")]
|
||||||
|
public class TowerLevelExcel : ExcelResource
|
||||||
|
{
|
||||||
|
[JsonProperty("ID")] public uint ID { get; set; }
|
||||||
|
[JsonProperty("MapID")] public uint MapID { get; set; }
|
||||||
|
[JsonProperty("FightID")] public uint FightID { get; set; }
|
||||||
|
[JsonProperty("TaskPath")] public string TaskPath { get; set; } = "";
|
||||||
|
[JsonProperty("ConsumeVigor")] public List<int> ConsumeVigor { get; set; } = [];
|
||||||
|
|
||||||
|
public override uint GetId() => ID;
|
||||||
|
|
||||||
|
public override void Loaded()
|
||||||
|
{
|
||||||
|
GameData.TowerLevelData[ID] = this;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
|
|
||||||
namespace MikuSB.Data.Excel;
|
namespace MikuSB.Data.Excel;
|
||||||
|
|
||||||
[ResourceEntity("upgrade_exp.json")]
|
[ResourceEntity("item/upgrade_exp.json")]
|
||||||
public class UpgradeExpExcel : ExcelResource
|
public class UpgradeExpExcel : ExcelResource
|
||||||
{
|
{
|
||||||
public int Lv { get; set; }
|
public int Lv { get; set; }
|
||||||
|
|||||||
20
Common/Data/Excel/VirCaptureCaptureRegionExcel.cs
Normal file
20
Common/Data/Excel/VirCaptureCaptureRegionExcel.cs
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace MikuSB.Data.Excel;
|
||||||
|
|
||||||
|
[ResourceEntity("dlc/vircapture/captureregion.json")]
|
||||||
|
public class VirCaptureCaptureRegionExcel : ExcelResource
|
||||||
|
{
|
||||||
|
[JsonProperty("Id")] public uint Id { get; set; }
|
||||||
|
[JsonProperty("StartTime")] public string StartTime { get; set; } = "";
|
||||||
|
[JsonProperty("EndTime")] public string EndTime { get; set; } = "";
|
||||||
|
[JsonProperty("MapId")] public uint MapId { get; set; }
|
||||||
|
[JsonProperty("LevelRegionName")] public string LevelRegionName { get; set; } = "";
|
||||||
|
|
||||||
|
public override uint GetId() => Id;
|
||||||
|
|
||||||
|
public override void Loaded()
|
||||||
|
{
|
||||||
|
GameData.VirCaptureCaptureRegionData[Id] = this;
|
||||||
|
}
|
||||||
|
}
|
||||||
21
Common/Data/Excel/VirCaptureLevelListExcel.cs
Normal file
21
Common/Data/Excel/VirCaptureLevelListExcel.cs
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace MikuSB.Data.Excel;
|
||||||
|
|
||||||
|
[ResourceEntity("dlc/vircapture/levellist.json")]
|
||||||
|
public class VirCaptureLevelListExcel : ExcelResource
|
||||||
|
{
|
||||||
|
[JsonProperty("Level")] public uint Level { get; set; }
|
||||||
|
[JsonProperty("Exp")] public uint Exp { get; set; }
|
||||||
|
[JsonProperty("Num")] public uint Num { get; set; }
|
||||||
|
[JsonProperty("MaxCost")] public uint MaxCost { get; set; }
|
||||||
|
[JsonProperty("Rewards")] public List<List<uint>> Rewards { get; set; } = [];
|
||||||
|
[JsonProperty("ExpUp")] public double ExpUp { get; set; }
|
||||||
|
|
||||||
|
public override uint GetId() => Level;
|
||||||
|
|
||||||
|
public override void Loaded()
|
||||||
|
{
|
||||||
|
GameData.VirCaptureLevelListData[Level] = this;
|
||||||
|
}
|
||||||
|
}
|
||||||
18
Common/Data/Excel/VirCaptureSeasonExcel.cs
Normal file
18
Common/Data/Excel/VirCaptureSeasonExcel.cs
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace MikuSB.Data.Excel;
|
||||||
|
|
||||||
|
[ResourceEntity("dlc/vircapture/season.json")]
|
||||||
|
public class VirCaptureSeasonExcel : ExcelResource
|
||||||
|
{
|
||||||
|
[JsonProperty("Id")] public uint Id { get; set; }
|
||||||
|
[JsonProperty("StartTime")] public string StartTime { get; set; } = "";
|
||||||
|
[JsonProperty("EndTime")] public string EndTime { get; set; } = "";
|
||||||
|
|
||||||
|
public override uint GetId() => Id;
|
||||||
|
|
||||||
|
public override void Loaded()
|
||||||
|
{
|
||||||
|
GameData.VirCaptureSeasonData[Id] = this;
|
||||||
|
}
|
||||||
|
}
|
||||||
20
Common/Data/Excel/VirCaptureTimeExcel.cs
Normal file
20
Common/Data/Excel/VirCaptureTimeExcel.cs
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace MikuSB.Data.Excel;
|
||||||
|
|
||||||
|
[ResourceEntity("dlc/vircapture/timelist.json")]
|
||||||
|
public class VirCaptureTimeExcel : ExcelResource
|
||||||
|
{
|
||||||
|
[JsonProperty("Id")] public uint Id { get; set; }
|
||||||
|
[JsonProperty("StartTime")] public string StartTime { get; set; } = "";
|
||||||
|
[JsonProperty("EndTime")] public string EndTime { get; set; } = "";
|
||||||
|
[JsonProperty("CaptureRegionId")] public List<uint> CaptureRegionId { get; set; } = [];
|
||||||
|
[JsonProperty("MaxExp")] public uint MaxExp { get; set; }
|
||||||
|
|
||||||
|
public override uint GetId() => Id;
|
||||||
|
|
||||||
|
public override void Loaded()
|
||||||
|
{
|
||||||
|
GameData.VirCaptureTimeData[Id] = this;
|
||||||
|
}
|
||||||
|
}
|
||||||
44
Common/Data/Excel/VirCaptureTowerExcel.cs
Normal file
44
Common/Data/Excel/VirCaptureTowerExcel.cs
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
|
||||||
|
namespace MikuSB.Data.Excel;
|
||||||
|
|
||||||
|
[ResourceEntity("dlc/vircapture/tower.json")]
|
||||||
|
public class VirCaptureTowerExcel : ExcelResource
|
||||||
|
{
|
||||||
|
[JsonProperty("ID")] public uint Id { get; set; }
|
||||||
|
[JsonProperty("Condition")] public JToken? ConditionRaw { get; set; }
|
||||||
|
[JsonProperty("MapID")] public uint MapId { get; set; }
|
||||||
|
[JsonProperty("TrialCard")] public List<uint> TrialCard { get; set; } = [];
|
||||||
|
[JsonProperty("TaskPath")] public string TaskPath { get; set; } = "";
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
public Dictionary<int, uint> Condition { get; } = [];
|
||||||
|
|
||||||
|
public override uint GetId() => Id;
|
||||||
|
|
||||||
|
public override void Loaded()
|
||||||
|
{
|
||||||
|
Condition.Clear();
|
||||||
|
if (ConditionRaw is JObject obj)
|
||||||
|
{
|
||||||
|
foreach (var property in obj.Properties())
|
||||||
|
{
|
||||||
|
if (!int.TryParse(property.Name, out var key))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
uint value = 0;
|
||||||
|
if (property.Value.Type == JTokenType.Integer)
|
||||||
|
value = property.Value.Value<uint>();
|
||||||
|
else if (property.Value.Type == JTokenType.String &&
|
||||||
|
uint.TryParse(property.Value.Value<string>(), out var parsed))
|
||||||
|
value = parsed;
|
||||||
|
|
||||||
|
if (value > 0)
|
||||||
|
Condition[key] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GameData.VirCaptureTowerData[Id] = this;
|
||||||
|
}
|
||||||
|
}
|
||||||
19
Common/Data/Excel/VirCaptureTrialTimeExcel.cs
Normal file
19
Common/Data/Excel/VirCaptureTrialTimeExcel.cs
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace MikuSB.Data.Excel;
|
||||||
|
|
||||||
|
[ResourceEntity("dlc/vircapture/trial_timelist.json")]
|
||||||
|
public class VirCaptureTrialTimeExcel : ExcelResource
|
||||||
|
{
|
||||||
|
[JsonProperty("Id")] public uint Id { get; set; }
|
||||||
|
[JsonProperty("StartTime")] public string StartTime { get; set; } = "";
|
||||||
|
[JsonProperty("EndTime")] public string EndTime { get; set; } = "";
|
||||||
|
[JsonProperty("AwardTime")] public string AwardTime { get; set; } = "";
|
||||||
|
|
||||||
|
public override uint GetId() => Id;
|
||||||
|
|
||||||
|
public override void Loaded()
|
||||||
|
{
|
||||||
|
GameData.VirCaptureTrialTimeData[Id] = this;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
|
|
||||||
namespace MikuSB.Data.Excel;
|
namespace MikuSB.Data.Excel;
|
||||||
|
|
||||||
[ResourceEntity("weapon.json")]
|
[ResourceEntity("item/templates/weapon.json")]
|
||||||
public class WeaponExcel : ExcelResource
|
public class WeaponExcel : ExcelResource
|
||||||
{
|
{
|
||||||
public uint Genre { get; set; }
|
public uint Genre { get; set; }
|
||||||
|
|||||||
24
Common/Data/Excel/WeaponPartsExcel.cs
Normal file
24
Common/Data/Excel/WeaponPartsExcel.cs
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace MikuSB.Data.Excel;
|
||||||
|
|
||||||
|
[ResourceEntity("item/templates/weapon_parts.json")]
|
||||||
|
public class WeaponPartsExcel : ExcelResource
|
||||||
|
{
|
||||||
|
public uint Genre { get; set; }
|
||||||
|
public uint Detail { get; set; }
|
||||||
|
public uint Particular { get; set; }
|
||||||
|
public uint Level { get; set; }
|
||||||
|
public uint Icon { get; set; }
|
||||||
|
public int AppearID { get; set; }
|
||||||
|
public string I18n { get; set; } = "";
|
||||||
|
public override uint GetId()
|
||||||
|
{
|
||||||
|
return (uint)I18n.GetHashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Loaded()
|
||||||
|
{
|
||||||
|
GameData.WeaponPartsData.Add(GetId(), this);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,7 +3,7 @@ using Newtonsoft.Json.Linq;
|
|||||||
|
|
||||||
namespace MikuSB.Data.Excel;
|
namespace MikuSB.Data.Excel;
|
||||||
|
|
||||||
[ResourceEntity("weapon_skin.json")]
|
[ResourceEntity("item/templates/weapon_skin.json")]
|
||||||
public class WeaponSkinExcel : ExcelResource
|
public class WeaponSkinExcel : ExcelResource
|
||||||
{
|
{
|
||||||
public uint Genre { get; set; }
|
public uint Genre { get; set; }
|
||||||
|
|||||||
@@ -13,15 +13,55 @@ public static class GameData
|
|||||||
public static Dictionary<int, BreakLevelLimitExcel> BreakLevelLimitData { get; private set; } = [];
|
public static Dictionary<int, BreakLevelLimitExcel> BreakLevelLimitData { get; private set; } = [];
|
||||||
public static Dictionary<int, RecycleExcel> RecycleData { get; private set; } = [];
|
public static Dictionary<int, RecycleExcel> RecycleData { get; private set; } = [];
|
||||||
public static Dictionary<uint, ChapterLevelExcel> ChapterLevelData { get; private set; } = [];
|
public static Dictionary<uint, ChapterLevelExcel> ChapterLevelData { get; private set; } = [];
|
||||||
|
public static Dictionary<uint, RoleLevelExcel> RoleLevelData { get; private set; } = [];
|
||||||
public static Dictionary<uint, ArItemExcel> ArItemData { get; private set; } = [];
|
public static Dictionary<uint, ArItemExcel> ArItemData { get; private set; } = [];
|
||||||
public static Dictionary<uint, ManifestationExcel> ManifestationData { get; private set; } = [];
|
public static Dictionary<uint, ManifestationExcel> ManifestationData { get; private set; } = [];
|
||||||
public static Dictionary<uint, Rogue3DDifficultExcel> Rogue3DDifficultData { get; private set; } = [];
|
public static Dictionary<uint, Rogue3DDifficultExcel> Rogue3DDifficultData { get; private set; } = [];
|
||||||
|
public static Dictionary<uint, Rogue3DSeasonExcel> Rogue3DSeasonData { get; private set; } = [];
|
||||||
|
public static Dictionary<uint, Rogue3DTalentExcel> Rogue3DTalentData { get; private set; } = [];
|
||||||
|
public static Dictionary<uint, Rogue3DDailyBuffExcel> Rogue3DDailyBuffData { get; private set; } = [];
|
||||||
|
public static Dictionary<int, BreakExcel> BreakData { get; private set; } = [];
|
||||||
|
public static Dictionary<int, SpecialBreakExcel> SpecialBreakData { get; private set; } = [];
|
||||||
public static Dictionary<uint, SpineExcel> SpineData { get; private set; } = [];
|
public static Dictionary<uint, SpineExcel> SpineData { get; private set; } = [];
|
||||||
public static Dictionary<uint, NodeConditionExcel> NodeConditionData { get; private set; } = [];
|
public static Dictionary<uint, NodeConditionExcel> NodeConditionData { get; private set; } = [];
|
||||||
public static List<SupportCardExcel> SupportCardData { get; private set; } = [];
|
public static List<SupportCardExcel> SupportCardData { get; private set; } = [];
|
||||||
|
public static Dictionary<int, SupportAffixExcel> SupportAffixData { get; private set; } = [];
|
||||||
|
public static Dictionary<int, SupportAffixPoolExcel> SupportAffixPoolData { get; private set; } = [];
|
||||||
|
public static Dictionary<int, SupportFixedExcel> SupportFixedData { get; private set; } = [];
|
||||||
public static Dictionary<uint, WeaponSkinExcel> WeaponSkinData { get; private set; } = [];
|
public static Dictionary<uint, WeaponSkinExcel> WeaponSkinData { get; private set; } = [];
|
||||||
public static Dictionary<uint, DailyLevelExcel> DailyLevelData { get; private set; } = [];
|
public static Dictionary<uint, DailyLevelExcel> DailyLevelData { get; private set; } = [];
|
||||||
|
public static Dictionary<uint, BossPvpBossChallengeExcel> BossPvpBossChallengeData { get; private set; } = [];
|
||||||
|
public static Dictionary<uint, BossPvpBossExcel> BossPvpBossData { get; private set; } = [];
|
||||||
|
public static Dictionary<uint, BossPvpNumExcel> BossPvpNumData { get; private set; } = [];
|
||||||
|
public static Dictionary<uint, ClimbTowerTimeExcel> ClimbTowerTimeData { get; private set; } = [];
|
||||||
|
public static Dictionary<uint, ClimbTowerDiffExcel> ClimbTowerDiffData { get; private set; } = [];
|
||||||
|
public static Dictionary<uint, Dictionary<int, ClimbTowerAwardExcel>> ClimbTowerAwardData { get; private set; } = [];
|
||||||
|
public static Dictionary<uint, ClimbTowerLevelOrderExcel> ClimbTowerLevelOrderData { get; private set; } = [];
|
||||||
|
public static Dictionary<uint, TowerLevelExcel> TowerLevelData { get; private set; } = [];
|
||||||
|
public static Dictionary<uint, TowerEventLevelExcel> TowerEventLevelData { get; private set; } = [];
|
||||||
|
public static Dictionary<uint, OtherItemExcel> OtherItemData { get; private set; } = [];
|
||||||
|
public static Dictionary<uint, ProfileExcel> ProfileData { get; private set; } = [];
|
||||||
|
public static Dictionary<uint, CardSkinPartsExcel> CardSkinPartsData { get; private set; } = [];
|
||||||
|
public static Dictionary<uint, CallItemExcel> CallItemData { get; private set; } = [];
|
||||||
|
public static Dictionary<uint, WeaponPartsExcel> WeaponPartsData { get; private set; } = [];
|
||||||
|
public static Dictionary<uint, GuideExcel> GuideData { get; private set; } = [];
|
||||||
|
public static Dictionary<uint, DormGiftExcel> DormGiftData { get; private set; } = [];
|
||||||
|
public static Dictionary<uint, HouseFurniturePosExcel> HouseFurniturePosData { get; private set; } = [];
|
||||||
|
public static Dictionary<uint, GachaExcel> GachaData { get; private set; } = [];
|
||||||
|
public static Dictionary<uint, GachaProbabilityExcel> GachaProbabilityData { get; private set; } = [];
|
||||||
|
public static Dictionary<string, List<GachaPoolItem>> GachaPoolData { get; private set; } = [];
|
||||||
|
public static Dictionary<uint, VirCaptureTimeExcel> VirCaptureTimeData { get; private set; } = [];
|
||||||
|
public static Dictionary<uint, VirCaptureSeasonExcel> VirCaptureSeasonData { get; private set; } = [];
|
||||||
|
public static Dictionary<uint, VirCaptureTrialTimeExcel> VirCaptureTrialTimeData { get; private set; } = [];
|
||||||
|
public static Dictionary<uint, VirCaptureCaptureRegionExcel> VirCaptureCaptureRegionData { get; private set; } = [];
|
||||||
|
public static Dictionary<uint, VirCaptureLevelListExcel> VirCaptureLevelListData { get; private set; } = [];
|
||||||
|
public static Dictionary<ulong, MonsterCardExcel> MonsterCardData { get; private set; } = [];
|
||||||
|
public static Dictionary<uint, FishingFoodExcel> FishingFoodData { get; private set; } = [];
|
||||||
|
public static Dictionary<uint, VirCaptureTowerExcel> VirCaptureTowerData { get; private set; } = [];
|
||||||
|
public static Dictionary<uint, DreamCardActivityExcel> DreamCardActivityData { get; private set; } = [];
|
||||||
|
public static Dictionary<uint, DlcActivityExcel> DlcActivityData { get; private set; } = [];
|
||||||
|
public static Dictionary<uint, BattlePassTimeExcel> BattlePassTimeData { get; private set; } = [];
|
||||||
|
public static Dictionary<uint, IbGoodsExcel> IbGoodsData { get; private set; } = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class GameResourceTemplateId
|
public static class GameResourceTemplateId
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ public class ResourceManager
|
|||||||
foreach (var fileName in attribute.FileName)
|
foreach (var fileName in attribute.FileName)
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var path = ConfigManager.Config.Path.ResourcePath + "/ExcelOutput/" + fileName;
|
var path = ConfigManager.Config.Path.ResourcePath + "/" + fileName;
|
||||||
var file = new FileInfo(path);
|
var file = new FileInfo(path);
|
||||||
if (!file.Exists)
|
if (!file.Exists)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -26,11 +26,14 @@ public class AccountData : BaseDatabaseDataHelper
|
|||||||
AccountData? result = null;
|
AccountData? result = null;
|
||||||
DatabaseHelper.GetAllInstance<AccountData>()?.ForEach(account =>
|
DatabaseHelper.GetAllInstance<AccountData>()?.ForEach(account =>
|
||||||
{
|
{
|
||||||
if (account.Username == username) result = account;
|
if (string.Equals(account.Username, username, StringComparison.OrdinalIgnoreCase)) result = account;
|
||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static AccountData? GetAccountByEmail(string email)
|
||||||
|
=> GetAccountByUserName(email);
|
||||||
|
|
||||||
public static AccountData? GetAccountByUid(int uid, bool force = false)
|
public static AccountData? GetAccountByUid(int uid, bool force = false)
|
||||||
{
|
{
|
||||||
var result = DatabaseHelper.GetInstance<AccountData>(uid, force);
|
var result = DatabaseHelper.GetInstance<AccountData>(uid, force);
|
||||||
@@ -61,8 +64,15 @@ public class AccountData : BaseDatabaseDataHelper
|
|||||||
|
|
||||||
#region Account
|
#region Account
|
||||||
|
|
||||||
public static void CreateAccount(string username, int uid, string password)
|
public static AccountData CreateAccount(string username, int uid, string password)
|
||||||
{
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(username))
|
||||||
|
throw new ArgumentException("Username cannot be empty.", nameof(username));
|
||||||
|
if (GetAccountByUserName(username) != null)
|
||||||
|
throw new InvalidOperationException($"Account '{username}' already exists.");
|
||||||
|
if (uid != 0 && GetAccountByUid(uid) != null)
|
||||||
|
throw new InvalidOperationException($"UID '{uid}' is already in use.");
|
||||||
|
|
||||||
var newUid = uid;
|
var newUid = uid;
|
||||||
if (uid == 0)
|
if (uid == 0)
|
||||||
{
|
{
|
||||||
@@ -84,6 +94,7 @@ public class AccountData : BaseDatabaseDataHelper
|
|||||||
SetPassword(account, password);
|
SetPassword(account, password);
|
||||||
|
|
||||||
DatabaseHelper.CreateInstance(account);
|
DatabaseHelper.CreateInstance(account);
|
||||||
|
return account;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void DeleteAccount(int uid)
|
public static void DeleteAccount(int uid)
|
||||||
|
|||||||
@@ -24,13 +24,13 @@ public class CharacterInfo
|
|||||||
public uint WeaponUniqueId { get; set; }
|
public uint WeaponUniqueId { get; set; }
|
||||||
public uint SkinId { get; set; }
|
public uint SkinId { get; set; }
|
||||||
public uint WeaponSkinId { get; set; }
|
public uint WeaponSkinId { get; set; }
|
||||||
|
public uint SupportTeamIndex { get; set; } = 1;
|
||||||
public ItemFlagEnum Flag { get; set; } = ItemFlagEnum.FLAG_READED;
|
public ItemFlagEnum Flag { get; set; } = ItemFlagEnum.FLAG_READED;
|
||||||
public uint Expiration { get; set; }
|
public uint Expiration { get; set; }
|
||||||
[SugarColumn(IsJson = true)] public List<uint> UnlockedSkin { get; set; } = [];
|
[SugarColumn(IsJson = true)] public List<uint> UnlockedSkin { get; set; } = [];
|
||||||
[SugarColumn(IsJson = true)] public List<uint> Spines { get; set; } = [];
|
[SugarColumn(IsJson = true)] public List<uint> Spines { get; set; } = [];
|
||||||
[SugarColumn(IsJson = true)] public List<uint> Affixs { get; set; } = [];
|
[SugarColumn(IsJson = true)] public List<uint> Affixs { get; set; } = [];
|
||||||
// Key = EqSlot (= support card Detail), Value = support card UniqueId
|
[SugarColumn(IsJson = true)] public Dictionary<uint, uint> SupportSlots { get; set; } = []; // Key = EqSlot (= support card Detail), Value = support card UniqueId
|
||||||
[SugarColumn(IsJson = true)] public Dictionary<uint, uint> SupportSlots { get; set; } = [];
|
|
||||||
public long Timestamp { get; set; }
|
public long Timestamp { get; set; }
|
||||||
public uint Count { get; set; } = 1;
|
public uint Count { get; set; } = 1;
|
||||||
|
|
||||||
@@ -56,9 +56,10 @@ public class CharacterInfo
|
|||||||
proto.Enhance.Spines.AddRange(Spines.Select(x => (ulong)x));
|
proto.Enhance.Spines.AddRange(Spines.Select(x => (ulong)x));
|
||||||
proto.Enhance.Affixs.AddRange(Affixs);
|
proto.Enhance.Affixs.AddRange(Affixs);
|
||||||
|
|
||||||
proto.Slots[4] = WeaponUniqueId;
|
proto.Slots[(uint)ItemCardSlotTypeEnum.SLOT_WEAPON] = WeaponUniqueId;
|
||||||
proto.Slots[5] = SkinId;
|
proto.Slots[(uint)ItemCardSlotTypeEnum.SLOT_SKIN] = SkinId;
|
||||||
proto.Slots[6] = WeaponSkinId;
|
proto.Slots[(uint)ItemCardSlotTypeEnum.SLOT_WEAPON_SKIN] = WeaponSkinId;
|
||||||
|
proto.Slots[(uint)ItemCardSlotTypeEnum.SLOT_SUPPORTERINDEX] = SupportTeamIndex;
|
||||||
foreach (var (slot, uid) in SupportSlots)
|
foreach (var (slot, uid) in SupportSlots)
|
||||||
proto.Slots[slot] = uid;
|
proto.Slots[slot] = uid;
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,10 @@ public class DatabaseHelper
|
|||||||
public static readonly ConcurrentDictionary<int, List<BaseDatabaseDataHelper>> UidInstanceMap = [];
|
public static readonly ConcurrentDictionary<int, List<BaseDatabaseDataHelper>> UidInstanceMap = [];
|
||||||
public static readonly List<int> ToSaveUidList = [];
|
public static readonly List<int> ToSaveUidList = [];
|
||||||
public static long LastSaveTick = DateTime.UtcNow.Ticks;
|
public static long LastSaveTick = DateTime.UtcNow.Ticks;
|
||||||
public static Thread? SaveThread;
|
|
||||||
|
private static int _saving = 0;
|
||||||
|
private static Task? _saveTask;
|
||||||
|
private static CancellationTokenSource? _cts;
|
||||||
public static bool LoadAccount;
|
public static bool LoadAccount;
|
||||||
public static bool LoadAllData;
|
public static bool LoadAllData;
|
||||||
|
|
||||||
@@ -77,15 +80,11 @@ public class DatabaseHelper
|
|||||||
|
|
||||||
while (!res.IsCompleted)
|
while (!res.IsCompleted)
|
||||||
{
|
{
|
||||||
|
Thread.Sleep(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
LastSaveTick = DateTime.UtcNow.Ticks;
|
_cts = new CancellationTokenSource();
|
||||||
|
_saveTask = RunAutoSave(_cts.Token);
|
||||||
SaveThread = new Thread(() =>
|
|
||||||
{
|
|
||||||
while (true) CalcSaveDatabase();
|
|
||||||
});
|
|
||||||
SaveThread.Start();
|
|
||||||
|
|
||||||
LoadAllData = true;
|
LoadAllData = true;
|
||||||
}
|
}
|
||||||
@@ -248,6 +247,35 @@ public class DatabaseHelper
|
|||||||
ToSaveUidList.RemoveAll(x => x == key);
|
ToSaveUidList.RemoveAll(x => x == key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void Stop()
|
||||||
|
{
|
||||||
|
_cts?.Cancel();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async Task WaitAsync()
|
||||||
|
{
|
||||||
|
if (_saveTask != null)
|
||||||
|
await _saveTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static async Task RunAutoSave(CancellationToken token)
|
||||||
|
{
|
||||||
|
LastSaveTick = DateTime.UtcNow.Ticks;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
while (!token.IsCancellationRequested)
|
||||||
|
{
|
||||||
|
CalcSaveDatabase();
|
||||||
|
await Task.Delay(100, token);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (OperationCanceledException)
|
||||||
|
{
|
||||||
|
// exit normally
|
||||||
|
// Console.WriteLine($"RunAutoSave exit! - OperationCanceledException");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Auto save per 5 min
|
// Auto save per 5 min
|
||||||
public static void CalcSaveDatabase()
|
public static void CalcSaveDatabase()
|
||||||
{
|
{
|
||||||
@@ -257,6 +285,10 @@ public class DatabaseHelper
|
|||||||
|
|
||||||
public static void SaveDatabase()
|
public static void SaveDatabase()
|
||||||
{
|
{
|
||||||
|
// ensure only one SaveDatabase() runnig
|
||||||
|
if (Interlocked.Exchange(ref _saving, 1) == 1)
|
||||||
|
return;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var prev = DateTime.Now;
|
var prev = DateTime.Now;
|
||||||
@@ -281,11 +313,18 @@ public class DatabaseHelper
|
|||||||
Math.Round(t, 2).ToString(CultureInfo.InvariantCulture)));
|
Math.Round(t, 2).ToString(CultureInfo.InvariantCulture)));
|
||||||
|
|
||||||
ToSaveUidList.Clear();
|
ToSaveUidList.Clear();
|
||||||
|
|
||||||
|
// Thread.Sleep(5000); // for test if saving process taking too long
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
logger.Error("An error occurred while saving the database", e);
|
logger.Error("An error occurred while saving the database", e);
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
// release lock
|
||||||
|
Volatile.Write(ref _saving, 0);
|
||||||
|
}
|
||||||
|
|
||||||
LastSaveTick = DateTime.UtcNow.Ticks;
|
LastSaveTick = DateTime.UtcNow.Ticks;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using MikuSB.Enums.Item;
|
using MikuSB.Enums.Item;
|
||||||
using MikuSB.Proto;
|
using MikuSB.Proto;
|
||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
|
|
||||||
@@ -10,19 +10,19 @@ public class InventoryData : BaseDatabaseDataHelper
|
|||||||
public uint NextUniqueUid { get; set; } = 100000;
|
public uint NextUniqueUid { get; set; } = 100000;
|
||||||
|
|
||||||
[SugarColumn(IsJson = true)]
|
[SugarColumn(IsJson = true)]
|
||||||
public Dictionary<uint, BaseGameItemInfo> Items { get; set; } = []; // Key: UniqueId
|
public Dictionary<uint, BaseGameItemInfo> Items { get; set; } = [];
|
||||||
|
|
||||||
[SugarColumn(IsJson = true)]
|
[SugarColumn(IsJson = true)]
|
||||||
public Dictionary<uint, GameWeaponInfo> Weapons { get; set; } = []; // Key: UniqueId
|
public Dictionary<uint, GameWeaponInfo> Weapons { get; set; } = [];
|
||||||
|
|
||||||
[SugarColumn(IsJson = true)]
|
[SugarColumn(IsJson = true)]
|
||||||
public Dictionary<uint, GameSkinInfo> Skins { get; set; } = []; // Key: UniqueId
|
public Dictionary<uint, GameSkinInfo> Skins { get; set; } = [];
|
||||||
|
|
||||||
[SugarColumn(IsJson = true)]
|
[SugarColumn(IsJson = true)]
|
||||||
public Dictionary<uint, GameSupportCardInfo> SupportCards { get; set; } = []; // Key: UniqueId
|
public Dictionary<uint, GameSupportCardInfo> SupportCards { get; set; } = [];
|
||||||
|
|
||||||
[SugarColumn(IsJson = true)]
|
[SugarColumn(IsJson = true)]
|
||||||
public Dictionary<uint, uint> SkinTypesBySkinId { get; set; } = []; // Key: nSkinId, Value: client nType
|
public Dictionary<uint, uint> SkinTypesBySkinId { get; set; } = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
public class BaseGameItemInfo
|
public class BaseGameItemInfo
|
||||||
@@ -56,11 +56,14 @@ public abstract class GrowableItemInfo : BaseGameItemInfo
|
|||||||
public new uint Level { get; set; }
|
public new uint Level { get; set; }
|
||||||
public new uint Exp { get; set; }
|
public new uint Exp { get; set; }
|
||||||
public uint Break { get; set; }
|
public uint Break { get; set; }
|
||||||
|
public uint Evolue { get; set; }
|
||||||
public uint EquipAvatarId { get; set; }
|
public uint EquipAvatarId { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class GameWeaponInfo : GrowableItemInfo
|
public class GameWeaponInfo : GrowableItemInfo
|
||||||
{
|
{
|
||||||
|
[SugarColumn(IsJson = true)] public Dictionary<uint, ulong> PartSlots { get; set; } = [];
|
||||||
|
|
||||||
public override Item ToProto()
|
public override Item ToProto()
|
||||||
{
|
{
|
||||||
var proto = new Item
|
var proto = new Item
|
||||||
@@ -73,15 +76,21 @@ public class GameWeaponInfo : GrowableItemInfo
|
|||||||
{
|
{
|
||||||
Level = Level,
|
Level = Level,
|
||||||
Exp = Exp,
|
Exp = Exp,
|
||||||
Break = Break
|
Break = Break,
|
||||||
|
Evolue = Evolue
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
foreach (var (slot, uid) in PartSlots)
|
||||||
|
proto.Slots[slot] = uid;
|
||||||
return proto;
|
return proto;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class GameSkinInfo : BaseGameItemInfo
|
public class GameSkinInfo : BaseGameItemInfo
|
||||||
{
|
{
|
||||||
|
[SugarColumn(IsJson = true)] public Dictionary<uint, ulong> PartSlots { get; set; } = [];
|
||||||
public uint SkinType { get; set; }
|
public uint SkinType { get; set; }
|
||||||
|
|
||||||
public override Item ToProto()
|
public override Item ToProto()
|
||||||
{
|
{
|
||||||
var proto = new Item
|
var proto = new Item
|
||||||
@@ -91,15 +100,18 @@ public class GameSkinInfo : BaseGameItemInfo
|
|||||||
Count = ItemCount,
|
Count = ItemCount,
|
||||||
Flag = (uint)Flag,
|
Flag = (uint)Flag,
|
||||||
};
|
};
|
||||||
proto.Slots[11] = Math.Min(SkinType, 1);
|
proto.Slots[(uint)ItemSkinSlotTypeEnum.SLOT_CARD_SKIL_TYPE] = Math.Min(SkinType, 1);
|
||||||
|
foreach (var (slot, uid) in PartSlots)
|
||||||
|
proto.Slots[slot] = uid;
|
||||||
return proto;
|
return proto;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public class GameSupportCardInfo : BaseGameItemInfo
|
public class GameSupportCardInfo : BaseGameItemInfo
|
||||||
{
|
{
|
||||||
public uint AffixId { get; set; }
|
public uint AffixId { get; set; }
|
||||||
|
[SugarColumn(IsJson = true)] public List<uint> Affixs { get; set; } = [];
|
||||||
|
|
||||||
public override Item ToProto()
|
public override Item ToProto()
|
||||||
{
|
{
|
||||||
var proto = new Item
|
var proto = new Item
|
||||||
@@ -114,7 +126,8 @@ public class GameSupportCardInfo : BaseGameItemInfo
|
|||||||
Exp = Exp
|
Exp = Exp
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
proto.Slots[1] = AffixId;
|
proto.Enhance.Affixs.AddRange(Affixs);
|
||||||
|
proto.Slots[(uint)ItemSupportCardSlotTypeEnum.SLOT_AFFIXINDEX] = AffixId;
|
||||||
return proto;
|
return proto;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +0,0 @@
|
|||||||
namespace MikuSB.Enums.Item;
|
|
||||||
|
|
||||||
public enum ItemFlagEnum
|
|
||||||
{
|
|
||||||
FLAG_USE = 1,// 使用中
|
|
||||||
FLAG_LOCK = 2,// 锁定中
|
|
||||||
FLAG_READED = 4,// 道具已查看
|
|
||||||
FLAG_LEAVE = 8,// 角色大招后离场
|
|
||||||
FLAG_WEAPON_DEFAULT = 16,// 武器显示原始样式
|
|
||||||
FLAG_WEAPON_AUDIO = 32,// 武器消音器音效
|
|
||||||
FLAG_ROLE_LIKE = 64,// 心选角色
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -26,3 +26,55 @@ public enum ItemTypeEnum
|
|||||||
TYPE_AR = 24, //AR道具
|
TYPE_AR = 24, //AR道具
|
||||||
TYPE_CALL = 25, //电话陪伴道具
|
TYPE_CALL = 25, //电话陪伴道具
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum ItemCardSlotTypeEnum
|
||||||
|
{
|
||||||
|
SLOT_SUPPORTERCARD1 = 1, // 后勤卡
|
||||||
|
SLOT_SUPPORTERCARD2 = 2, // 后勤卡
|
||||||
|
SLOT_SUPPORTERCARD3 = 3, // 后勤卡
|
||||||
|
SLOT_WEAPON = 4, // 武器
|
||||||
|
SLOT_SKIN = 5, // 时装
|
||||||
|
SLOT_WEAPON_SKIN = 6, // 武器时装
|
||||||
|
SLOT_SUPPORTERINDEX = 7, // 当前使用的后勤组
|
||||||
|
SLOT_SUPPORTERCARD4 = 8, // 后勤卡
|
||||||
|
SLOT_SUPPORTERCARD5 = 9, // 后勤卡
|
||||||
|
SLOT_SUPPORTERCARD6 = 10, // 后勤卡
|
||||||
|
SLOT_SUPPORTERCARD7 = 11, // 后勤卡
|
||||||
|
SLOT_SUPPORTERCARD8 = 12, // 后勤卡
|
||||||
|
SLOT_SUPPORTERCARD9 = 13, // 后勤卡
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum ItemSkinPartSlotTypeEnum
|
||||||
|
{
|
||||||
|
SLOT_SkinPartSlot1 = 1,
|
||||||
|
SLOT_SkinPartSlot2 = 2,
|
||||||
|
SLOT_SkinPartSlot3 = 3,
|
||||||
|
SLOT_SkinPartSlot4 = 4,
|
||||||
|
SLOT_SkinPartSlot5 = 5,
|
||||||
|
SLOT_SkinPartSlot6 = 6,
|
||||||
|
SLOT_SkinPartSlot7 = 7,
|
||||||
|
SLOT_SkinPartSlot8 = 8,
|
||||||
|
SLOT_SkinPartSlot9 = 9,
|
||||||
|
SLOT_SkinPartSlot10 = 10,
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum ItemSkinSlotTypeEnum
|
||||||
|
{
|
||||||
|
SLOT_CARD_SKIL_TYPE = 11
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum ItemSupportCardSlotTypeEnum
|
||||||
|
{
|
||||||
|
SLOT_AFFIXINDEX = 1 // 可洗练的初始词缀索引
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum ItemFlagEnum
|
||||||
|
{
|
||||||
|
FLAG_USE = 1, // 使用中
|
||||||
|
FLAG_LOCK = 2, // 锁定中
|
||||||
|
FLAG_READED = 4, // 道具已查看
|
||||||
|
FLAG_LEAVE = 8, // 角色大招后离场
|
||||||
|
FLAG_WEAPON_DEFAULT = 16, // 武器显示原始样式
|
||||||
|
FLAG_WEAPON_AUDIO = 32, // 武器消音器音效
|
||||||
|
FLAG_ROLE_LIKE = 64, // 心选角色
|
||||||
|
}
|
||||||
24
Common/Enums/Player/ProfileTypeEnum.cs
Normal file
24
Common/Enums/Player/ProfileTypeEnum.cs
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
namespace MikuSB.Enums.Player;
|
||||||
|
|
||||||
|
public enum ProfileShowItemTypeEnum
|
||||||
|
{
|
||||||
|
SHOWITEM_CARD1 = 1, //第1个展示卡
|
||||||
|
SHOWITEM_CARD2 = 2, //第2个展示卡
|
||||||
|
SHOWITEM_CARD3 = 3, //第3个展示卡
|
||||||
|
SHOWITEM_GIRL = 4, //看板娘
|
||||||
|
SHOWITEM_FACE = 5, //头像
|
||||||
|
SHOWITEM_FRAME = 6, //头像框
|
||||||
|
SHOWITEM_CARD4 = 7, //第4个展示卡
|
||||||
|
SHOWITEM_CARD5 = 8, //第5个展示卡
|
||||||
|
SHOWITEM_SKIN1 = 9, //第1个展示皮肤
|
||||||
|
SHOWITEM_SKIN2 = 10, //第2个展示皮肤
|
||||||
|
SHOWITEM_SKIN3 = 11, //第3个展示皮肤
|
||||||
|
SHOWITEM_SKIN4 = 12, //第4个展示皮肤
|
||||||
|
SHOWITEM_SKIN5 = 13, //第5个展示皮肤
|
||||||
|
SHOWITEM_BADGE1 = 14, //第一个展示勋章
|
||||||
|
SHOWITEM_BADGE2 = 15, //第二个展示勋章
|
||||||
|
SHOWITEM_BADGE3 = 16, //第三个展示勋章
|
||||||
|
SHOWITEM_COVER = 17, //展示封面
|
||||||
|
SHOWITEM_NAMECARD = 18, //展示名片
|
||||||
|
SHOWITEM_BUBBLE = 19, //聊天气泡
|
||||||
|
}
|
||||||
@@ -35,6 +35,12 @@ public class ServerTextCHS
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class WordTextCHS
|
public class WordTextCHS
|
||||||
{
|
{
|
||||||
|
public string Furniture => "家具";
|
||||||
|
public string Skin => "皮肤";
|
||||||
|
public string WeaponPart => "武器部件";
|
||||||
|
public string CallItem => "召唤道具";
|
||||||
|
public string SkinPart => "皮肤部件";
|
||||||
|
public string Profile => "个人资料";
|
||||||
public string WeaponSkin => "武器皮肤";
|
public string WeaponSkin => "武器皮肤";
|
||||||
public string SupportCard => "支援卡";
|
public string SupportCard => "支援卡";
|
||||||
public string Weapon => "武器";
|
public string Weapon => "武器";
|
||||||
@@ -122,9 +128,11 @@ public class CommandTextCHS
|
|||||||
{
|
{
|
||||||
public NoticeTextCHS Notice { get; } = new();
|
public NoticeTextCHS Notice { get; } = new();
|
||||||
public HelpTextCHS Help { get; } = new();
|
public HelpTextCHS Help { get; } = new();
|
||||||
|
public AccountTextCHS Account { get; } = new();
|
||||||
public GirlTextCHS Girl { get; } = new();
|
public GirlTextCHS Girl { get; } = new();
|
||||||
public GiveAllTextCHS GiveAll { get; } = new();
|
public GiveAllTextCHS GiveAll { get; } = new();
|
||||||
public DebugTextCHS Debug { get; } = new();
|
public DebugTextCHS Debug { get; } = new();
|
||||||
|
public GameCommandTextCHS Game { get; } = new();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@@ -211,6 +219,21 @@ public class HelpTextCHS
|
|||||||
public string CommandAlias => "命令别名: ";
|
public string CommandAlias => "命令别名: ";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class AccountTextCHS
|
||||||
|
{
|
||||||
|
public string Desc => "管理 SDK 登录使用的账号映射";
|
||||||
|
public string Usage =>
|
||||||
|
"用法: /account create <邮箱> <UID>\n" +
|
||||||
|
"用法: /account delete <邮箱|UID>\n" +
|
||||||
|
"用法: /account list";
|
||||||
|
public string Created => "已创建账号映射: {0} -> UID {1}";
|
||||||
|
public string CreateFailed => "创建账号映射失败: {0}";
|
||||||
|
public string Deleted => "已删除账号映射: {0} -> UID {1}";
|
||||||
|
public string DeleteFailed => "删除账号映射失败: {0}";
|
||||||
|
public string DeleteOnline => "账号在线时无法删除: {0} -> UID {1}";
|
||||||
|
public string NotFound => "未找到账号: {0}";
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// path: Game.Command.Girl
|
/// path: Game.Command.Girl
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -223,12 +246,14 @@ public class GirlTextCHS
|
|||||||
public string Usage =>
|
public string Usage =>
|
||||||
"用法: /girl add <detail/-1> -p<particular> -l<level> -s<star>\n" +
|
"用法: /girl add <detail/-1> -p<particular> -l<level> -s<star>\n" +
|
||||||
"用法: /girl level <guid/-1> <level>\n" +
|
"用法: /girl level <guid/-1> <level>\n" +
|
||||||
"用法: /girl neuronic <guid/-1> <level>";
|
"用法: /girl neuronic <guid/-1> <level>\n" +
|
||||||
|
"用法: /girl break <guid/-1> <level>";
|
||||||
|
|
||||||
public string NotFound => "角色不存在!";
|
public string NotFound => "角色不存在!";
|
||||||
public string Added => "已为玩家添加 {0} 个角色!";
|
public string Added => "已为玩家添加 {0} 个角色!";
|
||||||
public string UpdateLevel => "已将 {1} 个角色等级设置为 {0}!";
|
public string UpdateLevel => "已将 {1} 个角色等级设置为 {0}!";
|
||||||
public string UpdateNeuronicLevel => "已将 {1} 个角色的神经元等级设置为 {0}!";
|
public string UpdateNeuronicLevel => "已将 {1} 个角色的神经元等级设置为 {0}!";
|
||||||
|
public string UpdateBreakLevel => "已将 {1} 个角色的天启/武格等级设置为 {0}!";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -240,7 +265,11 @@ public class GiveAllTextCHS
|
|||||||
"注意:-1 表示全部";
|
"注意:-1 表示全部";
|
||||||
public string Usage => "用法:/giveall weapon <detail/-1> -p<特定> -l<等級>\n" +
|
public string Usage => "用法:/giveall weapon <detail/-1> -p<特定> -l<等級>\n" +
|
||||||
"用法:/giveall weaponskin <detail/-1> -p<特定>\n" +
|
"用法:/giveall weaponskin <detail/-1> -p<特定>\n" +
|
||||||
"用法:/giveall card <detail/-1> -p<特定> -l<等級>";
|
"用法:/giveall card <detail/-1> -p<特定> -l<等級>" +
|
||||||
|
"用法:/giveall profile <detail/-1> -g<类型> -p<特定> -l<等级>" +
|
||||||
|
"用法:/giveall skinpart <detail/-1> -g<類型> -p<特定> -l<等級>" +
|
||||||
|
"用法:/giveall weaponpart <detail/-1> -g<類型> -p<特定> -l<等級>" +
|
||||||
|
"用法:/giveall call <detail/-1> -g<類型> -p<特定> -l<等級>";
|
||||||
public string NotFound => "未找到 {0}!";
|
public string NotFound => "未找到 {0}!";
|
||||||
public string GiveAllItems => "已向玩家添加 {0} 个 {1}!";
|
public string GiveAllItems => "已向玩家添加 {0} 个 {1}!";
|
||||||
}
|
}
|
||||||
@@ -260,6 +289,14 @@ public class DebugTextCHS
|
|||||||
public string FileDisabled => "个人调试文件输出已禁用。";
|
public string FileDisabled => "个人调试文件输出已禁用。";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class GameCommandTextCHS
|
||||||
|
{
|
||||||
|
public string Desc => "使用补丁注入启动已配置的游戏";
|
||||||
|
public string Usage => "用法: /game [额外游戏参数]";
|
||||||
|
public string Started => "游戏已启动。PID: {0}";
|
||||||
|
public string Failed => "游戏启动失败: {0}";
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@@ -35,6 +35,12 @@ public class ServerTextCHT
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class WordTextCHT
|
public class WordTextCHT
|
||||||
{
|
{
|
||||||
|
public string Furniture => "傢俱";
|
||||||
|
public string Skin => "皮膚";
|
||||||
|
public string WeaponPart => "武器部件";
|
||||||
|
public string CallItem => "召喚道具";
|
||||||
|
public string SkinPart => "外觀部件";
|
||||||
|
public string Profile => "個人資料";
|
||||||
public string WeaponSkin => "武器外觀";
|
public string WeaponSkin => "武器外觀";
|
||||||
public string SupportCard => "支援卡";
|
public string SupportCard => "支援卡";
|
||||||
public string Weapon => "武器";
|
public string Weapon => "武器";
|
||||||
@@ -122,9 +128,11 @@ public class CommandTextCHT
|
|||||||
{
|
{
|
||||||
public NoticeTextCHT Notice { get; } = new();
|
public NoticeTextCHT Notice { get; } = new();
|
||||||
public HelpTextCHT Help { get; } = new();
|
public HelpTextCHT Help { get; } = new();
|
||||||
|
public AccountTextCHT Account { get; } = new();
|
||||||
public GirlTextCHT Girl { get; } = new();
|
public GirlTextCHT Girl { get; } = new();
|
||||||
public GiveAllTextCHT GiveAll { get; } = new();
|
public GiveAllTextCHT GiveAll { get; } = new();
|
||||||
public DebugTextCHT Debug { get; } = new();
|
public DebugTextCHT Debug { get; } = new();
|
||||||
|
public GameCommandTextCHT Game { get; } = new();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@@ -211,6 +219,21 @@ public class HelpTextCHT
|
|||||||
public string CommandAlias => "命令別名: ";
|
public string CommandAlias => "命令別名: ";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class AccountTextCHT
|
||||||
|
{
|
||||||
|
public string Desc => "管理 SDK 登入使用的帳號映射";
|
||||||
|
public string Usage =>
|
||||||
|
"用法: /account create <郵箱> <UID>\n" +
|
||||||
|
"用法: /account delete <郵箱|UID>\n" +
|
||||||
|
"用法: /account list";
|
||||||
|
public string Created => "已建立帳號映射: {0} -> UID {1}";
|
||||||
|
public string CreateFailed => "建立帳號映射失敗: {0}";
|
||||||
|
public string Deleted => "已刪除帳號映射: {0} -> UID {1}";
|
||||||
|
public string DeleteFailed => "刪除帳號映射失敗: {0}";
|
||||||
|
public string DeleteOnline => "帳號在線時無法刪除: {0} -> UID {1}";
|
||||||
|
public string NotFound => "未找到帳號: {0}";
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// path: Game.Command.Girl
|
/// path: Game.Command.Girl
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -223,12 +246,14 @@ public class GirlTextCHT
|
|||||||
public string Usage =>
|
public string Usage =>
|
||||||
"用法: /girl add <detail/-1> -p<particular> -l<level> -s<star>\n" +
|
"用法: /girl add <detail/-1> -p<particular> -l<level> -s<star>\n" +
|
||||||
"用法: /girl level <guid/-1> <level>\n" +
|
"用法: /girl level <guid/-1> <level>\n" +
|
||||||
"用法: /girl neuronic <guid/-1> <level>";
|
"用法: /girl neuronic <guid/-1> <level>\n" +
|
||||||
|
"用法: /girl break <guid/-1> <level>";
|
||||||
|
|
||||||
public string NotFound => "角色不存在!";
|
public string NotFound => "角色不存在!";
|
||||||
public string Added => "已為玩家新增 {0} 個角色!";
|
public string Added => "已為玩家新增 {0} 個角色!";
|
||||||
public string UpdateLevel => "已將 {1} 個角色等級設為 {0}!";
|
public string UpdateLevel => "已將 {1} 個角色等級設為 {0}!";
|
||||||
public string UpdateNeuronicLevel => "已將 {1} 個角色的神經元等級設置為 {0}!";
|
public string UpdateNeuronicLevel => "已將 {1} 個角色的神經元等級設置為 {0}!";
|
||||||
|
public string UpdateBreakLevel => "已将 {1} 个角色的天啟/武格等级设置为 {0}!";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -240,7 +265,11 @@ public class GiveAllTextCHT
|
|||||||
"注意:-1 表示全部";
|
"注意:-1 表示全部";
|
||||||
public string Usage => "用法:/giveall weapon <detail/-1> -p<特定> -l<等級>\n" +
|
public string Usage => "用法:/giveall weapon <detail/-1> -p<特定> -l<等級>\n" +
|
||||||
"用法:/giveall weaponskin <detail/-1> -p<特定>\n" +
|
"用法:/giveall weaponskin <detail/-1> -p<特定>\n" +
|
||||||
"用法:/giveall card <detail/-1> -p<特定> -l<等級>";
|
"用法:/giveall card <detail/-1> -p<特定> -l<等級>" +
|
||||||
|
"用法:/giveall profile <detail/-1> -g<類型> -p<特定> -l<等級>" +
|
||||||
|
"用法:/giveall skinpart <detail/-1> -g<類型> -p<特定> -l<等級>" +
|
||||||
|
"用法:/giveall weaponpart <detail/-1> -g<類型> -p<特定> -l<等級>" +
|
||||||
|
"用法:/giveall call <detail/-1> -g<類型> -p<特定> -l<等級>";
|
||||||
public string NotFound => "未找到 {0}!";
|
public string NotFound => "未找到 {0}!";
|
||||||
public string GiveAllItems => "已向玩家添加 {0} 個 {1}!";
|
public string GiveAllItems => "已向玩家添加 {0} 個 {1}!";
|
||||||
}
|
}
|
||||||
@@ -260,6 +289,14 @@ public class DebugTextCHT
|
|||||||
public string FileDisabled => "個人調試檔案輸出已停用。";
|
public string FileDisabled => "個人調試檔案輸出已停用。";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class GameCommandTextCHT
|
||||||
|
{
|
||||||
|
public string Desc => "使用補丁注入啟動已配置的遊戲";
|
||||||
|
public string Usage => "用法: /game [額外遊戲參數]";
|
||||||
|
public string Started => "遊戲已啟動。PID: {0}";
|
||||||
|
public string Failed => "遊戲啟動失敗: {0}";
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@@ -35,6 +35,12 @@ public class ServerTextEN
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class WordTextEN
|
public class WordTextEN
|
||||||
{
|
{
|
||||||
|
public string Furniture => "Furniture";
|
||||||
|
public string Skin => "Skin";
|
||||||
|
public string WeaponPart => "Weapon Part";
|
||||||
|
public string CallItem => "Call Item";
|
||||||
|
public string SkinPart => "Skin Part";
|
||||||
|
public string Profile => "Profile";
|
||||||
public string WeaponSkin => "Weapon Skin";
|
public string WeaponSkin => "Weapon Skin";
|
||||||
public string Valk => "Valkyrie";
|
public string Valk => "Valkyrie";
|
||||||
public string Material => "Material";
|
public string Material => "Material";
|
||||||
@@ -81,9 +87,11 @@ public class CommandTextEN
|
|||||||
{
|
{
|
||||||
public NoticeTextEN Notice { get; } = new();
|
public NoticeTextEN Notice { get; } = new();
|
||||||
public HelpTextEN Help { get; } = new();
|
public HelpTextEN Help { get; } = new();
|
||||||
|
public AccountTextEN Account { get; } = new();
|
||||||
public GirlTextEN Girl { get; } = new();
|
public GirlTextEN Girl { get; } = new();
|
||||||
public GiveAllTextEN GiveAll { get; } = new();
|
public GiveAllTextEN GiveAll { get; } = new();
|
||||||
public DebugTextEN Debug { get; } = new();
|
public DebugTextEN Debug { get; } = new();
|
||||||
|
public GameCommandTextEN Game { get; } = new();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@@ -177,6 +185,21 @@ public class HelpTextEN
|
|||||||
public string CommandAlias => "Command Alias:";
|
public string CommandAlias => "Command Alias:";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class AccountTextEN
|
||||||
|
{
|
||||||
|
public string Desc => "Manage account mappings for SDK logins";
|
||||||
|
public string Usage =>
|
||||||
|
"Usage: /account create <email> <uid>\n" +
|
||||||
|
"Usage: /account delete <email|uid>\n" +
|
||||||
|
"Usage: /account list";
|
||||||
|
public string Created => "Created account mapping: {0} -> UID {1}";
|
||||||
|
public string CreateFailed => "Failed to create account mapping: {0}";
|
||||||
|
public string Deleted => "Deleted account mapping: {0} -> UID {1}";
|
||||||
|
public string DeleteFailed => "Failed to delete account mapping: {0}";
|
||||||
|
public string DeleteOnline => "Cannot delete account while online: {0} -> UID {1}";
|
||||||
|
public string NotFound => "Account not found: {0}";
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// path: Game.Command.Girl
|
/// path: Game.Command.Girl
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -189,12 +212,14 @@ public class GirlTextEN
|
|||||||
public string Usage =>
|
public string Usage =>
|
||||||
"Usage: /girl add <detail/-1> -p<particular> -l<level> -s<star>\n" +
|
"Usage: /girl add <detail/-1> -p<particular> -l<level> -s<star>\n" +
|
||||||
"Usage: /girl level <guid/-1> <level>\n" +
|
"Usage: /girl level <guid/-1> <level>\n" +
|
||||||
"Usage: /girl neuronic <guid/-1> <level>";
|
"Usage: /girl neuronic <guid/-1> <level>\n" +
|
||||||
|
"Usage: /girl break <guid/-1> <level>";
|
||||||
|
|
||||||
public string NotFound => "Character not found!";
|
public string NotFound => "Character not found!";
|
||||||
public string Added => "Granted {0} character(s) to player!";
|
public string Added => "Granted {0} character(s) to player!";
|
||||||
public string UpdateLevel => "Set {1} character(s) to level {0}!";
|
public string UpdateLevel => "Set {1} character(s) to level {0}!";
|
||||||
public string UpdateNeuronicLevel => "Set {1} character(s) Neuronic to level {0}!";
|
public string UpdateNeuronicLevel => "Set {1} character(s) Neuronic to level {0}!";
|
||||||
|
public string UpdateBreakLevel => "Set {1} character(s) Manifestation to level {0}!";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -206,7 +231,11 @@ public class GiveAllTextEN
|
|||||||
"Note: -1 means all";
|
"Note: -1 means all";
|
||||||
public string Usage => "Usage: /giveall weapon <detail/-1> -p<particular> -l<level>\n" +
|
public string Usage => "Usage: /giveall weapon <detail/-1> -p<particular> -l<level>\n" +
|
||||||
"Usage: /giveall weaponskin <detail/-1> -p<particular>\n" +
|
"Usage: /giveall weaponskin <detail/-1> -p<particular>\n" +
|
||||||
"Usage: /giveall card <detail/-1> -p<particular> -l<level>";
|
"Usage: /giveall card <detail/-1> -p<particular> -l<level>" +
|
||||||
|
"Usage: /giveall profile <detail/-1> -g<genre> -p<particular> -l<level>" +
|
||||||
|
"Usage: /giveall skinpart <detail/-1> -g<genre> -p<particular> -l<level>" +
|
||||||
|
"Usage: /giveall weaponpart <detail/-1> -g<genre> -p<particular> -l<level>" +
|
||||||
|
"Usage: /giveall call <detail/-1> -g<genre> -p<particular> -l<level>";
|
||||||
public string NotFound => "{0} not found!";
|
public string NotFound => "{0} not found!";
|
||||||
public string GiveAllItems => "Added {0} {1} to player!";
|
public string GiveAllItems => "Added {0} {1} to player!";
|
||||||
}
|
}
|
||||||
@@ -226,6 +255,14 @@ public class DebugTextEN
|
|||||||
public string FileDisabled => "Personal debug file output disabled.";
|
public string FileDisabled => "Personal debug file output disabled.";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class GameCommandTextEN
|
||||||
|
{
|
||||||
|
public string Desc => "Launch the configured game with patch injection";
|
||||||
|
public string Usage => "Usage: /game [extra game args]";
|
||||||
|
public string Started => "Game launched. PID: {0}";
|
||||||
|
public string Failed => "Failed to launch game: {0}";
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@@ -19,6 +19,11 @@ public static class ConfigManager
|
|||||||
//LoadHotfixData();
|
//LoadHotfixData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void SaveConfig()
|
||||||
|
{
|
||||||
|
SaveData(Config, ConfigFilePath);
|
||||||
|
}
|
||||||
|
|
||||||
private static void LoadConfigData()
|
private static void LoadConfigData()
|
||||||
{
|
{
|
||||||
var file = new FileInfo(ConfigFilePath);
|
var file = new FileInfo(ConfigFilePath);
|
||||||
@@ -43,9 +48,26 @@ public static class ConfigManager
|
|||||||
Config = JsonConvert.DeserializeObject<ConfigContainer>(json)!;
|
Config = JsonConvert.DeserializeObject<ConfigContainer>(json)!;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Config.Loader.Arguments = NormalizeLoaderArguments(Config.Loader.Arguments);
|
||||||
SaveData(Config, ConfigFilePath);
|
SaveData(Config, ConfigFilePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static string[] NormalizeLoaderArguments(string[]? arguments)
|
||||||
|
{
|
||||||
|
var result = new List<string>(arguments ?? []);
|
||||||
|
var userDataDirectory = Path.GetFullPath(Path.Combine(AppContext.BaseDirectory, "Client_User_Data"));
|
||||||
|
Directory.CreateDirectory(userDataDirectory);
|
||||||
|
|
||||||
|
var userDirArgument = $"-userdir={userDataDirectory}";
|
||||||
|
var existingIndex = result.FindIndex(x => x.StartsWith("-userdir=", StringComparison.OrdinalIgnoreCase));
|
||||||
|
if (existingIndex >= 0)
|
||||||
|
result[existingIndex] = userDirArgument;
|
||||||
|
else
|
||||||
|
result.Add(userDirArgument);
|
||||||
|
|
||||||
|
return result.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
private static void LoadHotfixData()
|
private static void LoadHotfixData()
|
||||||
{
|
{
|
||||||
var file = new FileInfo(HotfixFilePath);
|
var file = new FileInfo(HotfixFilePath);
|
||||||
|
|||||||
@@ -148,13 +148,29 @@ public class IConsole
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
public static string ListenConsole()
|
public static async Task ListenConsole(CancellationToken exitToken)
|
||||||
{
|
{
|
||||||
while (true)
|
while (!exitToken.IsCancellationRequested)
|
||||||
{
|
{
|
||||||
ConsoleKeyInfo keyInfo;
|
ConsoleKeyInfo keyInfo;
|
||||||
try { keyInfo = Console.ReadKey(true); }
|
try
|
||||||
catch (InvalidOperationException) { continue; }
|
{
|
||||||
|
if (!Console.KeyAvailable)
|
||||||
|
{
|
||||||
|
await Task.Delay(10, exitToken);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
keyInfo = Console.ReadKey(true);
|
||||||
|
}
|
||||||
|
catch (OperationCanceledException)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
catch (InvalidOperationException)
|
||||||
|
{
|
||||||
|
await Task.Delay(50, exitToken);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
switch (keyInfo.Key)
|
switch (keyInfo.Key)
|
||||||
{
|
{
|
||||||
|
|||||||
46
Common/Util/PatchDownloadService.cs
Normal file
46
Common/Util/PatchDownloadService.cs
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
using System.Net.Http.Headers;
|
||||||
|
|
||||||
|
namespace MikuSB.Util;
|
||||||
|
|
||||||
|
public static class PatchDownloadService
|
||||||
|
{
|
||||||
|
private static readonly Logger Logger = new("PatchDownloader");
|
||||||
|
private const string PatchRelativePath = @"Patch\MikuSB-Patch.dll";
|
||||||
|
private const string PatchDownloadUrl = "https://github.com/Kei-Luna/MikuSB-Patch/releases/download/MikuSB-Patch/MikuSB-Patch.dll";
|
||||||
|
private const int DownloadTimeoutSeconds = 60;
|
||||||
|
|
||||||
|
public static void EnsurePatchPresent()
|
||||||
|
{
|
||||||
|
var patchPath = Path.GetFullPath(Path.Combine(AppContext.BaseDirectory, PatchRelativePath));
|
||||||
|
if (File.Exists(patchPath))
|
||||||
|
return;
|
||||||
|
|
||||||
|
Directory.CreateDirectory(Path.GetDirectoryName(patchPath)!);
|
||||||
|
Logger.Warn($"Patch DLL not found. Downloading to {patchPath}.");
|
||||||
|
|
||||||
|
using var client = CreateHttpClient();
|
||||||
|
using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(DownloadTimeoutSeconds));
|
||||||
|
using var response = client.GetAsync(PatchDownloadUrl, HttpCompletionOption.ResponseHeadersRead, cts.Token)
|
||||||
|
.GetAwaiter().GetResult();
|
||||||
|
response.EnsureSuccessStatusCode();
|
||||||
|
|
||||||
|
using var source = response.Content.ReadAsStreamAsync(cts.Token).GetAwaiter().GetResult();
|
||||||
|
using var destination = File.Create(patchPath);
|
||||||
|
source.CopyTo(destination);
|
||||||
|
|
||||||
|
Logger.Info("Patch DLL download completed.");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static HttpClient CreateHttpClient()
|
||||||
|
{
|
||||||
|
var client = new HttpClient
|
||||||
|
{
|
||||||
|
Timeout = Timeout.InfiniteTimeSpan
|
||||||
|
};
|
||||||
|
|
||||||
|
client.DefaultRequestHeaders.UserAgent.Add(
|
||||||
|
new ProductInfoHeaderValue("MikuSB-PatchDownloader", BuildVersion.Current));
|
||||||
|
|
||||||
|
return client;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -38,5 +38,21 @@
|
|||||||
"DebugMessage": true,
|
"DebugMessage": true,
|
||||||
"DebugDetailMessage": true,
|
"DebugDetailMessage": true,
|
||||||
"DebugNoHandlerPacket": true
|
"DebugNoHandlerPacket": true
|
||||||
|
},
|
||||||
|
"Proxy": {
|
||||||
|
"Enabled": true,
|
||||||
|
"Port": 18888
|
||||||
|
},
|
||||||
|
"Loader": {
|
||||||
|
"GamePath": "",
|
||||||
|
"PatchPaths": [
|
||||||
|
"Patch\\MikuSB-Patch.dll"
|
||||||
|
],
|
||||||
|
"Arguments": [
|
||||||
|
"-FeatureLevelES31",
|
||||||
|
"-channelid=seasun",
|
||||||
|
"-NoSplash"
|
||||||
|
],
|
||||||
|
"SetAllProxy": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -38,9 +38,9 @@ public class PlayerCommandSender(PlayerInstance player) : ICommandSender
|
|||||||
Type = ChatType.Friend,
|
Type = ChatType.Friend,
|
||||||
Sender = (uint)ConfigManager.Config.ServerOption.ServerProfile.Uid,
|
Sender = (uint)ConfigManager.Config.ServerOption.ServerProfile.Uid,
|
||||||
Recver = (uint)Player.Uid,
|
Recver = (uint)Player.Uid,
|
||||||
Text = msg,
|
Text = ChatMessageHelper.NormalizeForClient(msg),
|
||||||
Profile = Player.ToServerFriendProto(),
|
Profile = Player.ToServerFriendProto(),
|
||||||
TimeStamp = (uint)Extensions.GetUnixMs()
|
TimeStamp = ChatMessageHelper.BuildClientTimestamp()
|
||||||
};
|
};
|
||||||
await Player.SendPacket(CmdIds.NtfFriendChat, data);
|
await Player.SendPacket(CmdIds.NtfFriendChat, data);
|
||||||
}
|
}
|
||||||
|
|||||||
97
GameServer/Command/Commands/CommandAccount.cs
Normal file
97
GameServer/Command/Commands/CommandAccount.cs
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
using MikuSB.Database;
|
||||||
|
using MikuSB.Database.Account;
|
||||||
|
using MikuSB.Enums.Player;
|
||||||
|
using MikuSB.Internationalization;
|
||||||
|
using MikuSB.GameServer.Server;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace MikuSB.GameServer.Command.Commands;
|
||||||
|
|
||||||
|
[CommandInfo("account", "Game.Command.Account.Desc", "Game.Command.Account.Usage", [], [PermEnum.Admin, PermEnum.Support])]
|
||||||
|
public class CommandAccount : ICommands
|
||||||
|
{
|
||||||
|
[CommandMethod("create")]
|
||||||
|
public async ValueTask Create(CommandArg arg)
|
||||||
|
{
|
||||||
|
if (!await arg.CheckArgCnt(2))
|
||||||
|
return;
|
||||||
|
|
||||||
|
var email = arg.Args[0].Trim();
|
||||||
|
if (!int.TryParse(arg.Args[1], out var uid) || uid <= 0)
|
||||||
|
{
|
||||||
|
await arg.SendMsg(I18NManager.Translate("Game.Command.Notice.InvalidArguments"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var account = AccountData.CreateAccount(email, uid, "");
|
||||||
|
await arg.SendMsg(I18NManager.Translate("Game.Command.Account.Created", account.Username, account.Uid.ToString()));
|
||||||
|
}
|
||||||
|
catch (InvalidOperationException ex)
|
||||||
|
{
|
||||||
|
await arg.SendMsg(I18NManager.Translate("Game.Command.Account.CreateFailed", ex.Message));
|
||||||
|
}
|
||||||
|
catch (ArgumentException ex)
|
||||||
|
{
|
||||||
|
await arg.SendMsg(I18NManager.Translate("Game.Command.Account.CreateFailed", ex.Message));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[CommandMethod("delete")]
|
||||||
|
public async ValueTask Delete(CommandArg arg)
|
||||||
|
{
|
||||||
|
if (!await arg.CheckArgCnt(1))
|
||||||
|
return;
|
||||||
|
|
||||||
|
var identifier = arg.Args[0].Trim();
|
||||||
|
var account = int.TryParse(identifier, out var uid) && uid > 0
|
||||||
|
? AccountData.GetAccountByUid(uid)
|
||||||
|
: AccountData.GetAccountByUserName(identifier);
|
||||||
|
|
||||||
|
if (account == null)
|
||||||
|
{
|
||||||
|
await arg.SendMsg(I18NManager.Translate("Game.Command.Account.NotFound", identifier));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (Listener.GetActiveConnection(account.Uid) != null)
|
||||||
|
{
|
||||||
|
await arg.SendMsg(I18NManager.Translate("Game.Command.Account.DeleteOnline", account.Username,
|
||||||
|
account.Uid.ToString()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
AccountData.DeleteAccount(account.Uid);
|
||||||
|
await arg.SendMsg(I18NManager.Translate("Game.Command.Account.Deleted", account.Username,
|
||||||
|
account.Uid.ToString()));
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await arg.SendMsg(I18NManager.Translate("Game.Command.Account.DeleteFailed", ex.Message));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[CommandMethod("list")]
|
||||||
|
public async ValueTask List(CommandArg arg)
|
||||||
|
{
|
||||||
|
var accounts = DatabaseHelper.GetAllInstance<AccountData>()?
|
||||||
|
.OrderBy(account => account.Uid)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
if (accounts == null || accounts.Count == 0)
|
||||||
|
{
|
||||||
|
await arg.SendMsg("No accounts found.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var builder = new StringBuilder();
|
||||||
|
builder.AppendLine("Accounts:");
|
||||||
|
foreach (var account in accounts)
|
||||||
|
builder.AppendLine($"{account.Username} -> UID {account.Uid}");
|
||||||
|
|
||||||
|
await arg.SendMsg(builder.ToString().TrimEnd());
|
||||||
|
}
|
||||||
|
}
|
||||||
29
GameServer/Command/Commands/CommandGame.cs
Normal file
29
GameServer/Command/Commands/CommandGame.cs
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
using MikuSB.Enums.Player;
|
||||||
|
using MikuSB.Internationalization;
|
||||||
|
using MikuSB.Loader;
|
||||||
|
using MikuSB.Util;
|
||||||
|
|
||||||
|
namespace MikuSB.GameServer.Command.Commands;
|
||||||
|
|
||||||
|
[CommandInfo("game", "Game.Command.Game.Desc", "Game.Command.Game.Usage", [], [PermEnum.Admin, PermEnum.Support])]
|
||||||
|
public class CommandGame : ICommands
|
||||||
|
{
|
||||||
|
private static readonly Logger Logger = new("CommandManager");
|
||||||
|
|
||||||
|
[CommandDefault]
|
||||||
|
public async ValueTask Launch(CommandArg arg)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var pid = GameLaunchService.Launch(arg.Args.ToArray());
|
||||||
|
var message = I18NManager.Translate("Game.Command.Game.Started", pid.ToString());
|
||||||
|
Logger.Info(message);
|
||||||
|
await arg.SendMsg(message);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger.Error("Failed to launch game.", ex);
|
||||||
|
await arg.SendMsg(I18NManager.Translate("Game.Command.Game.Failed", ex.Message));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -129,4 +129,41 @@ public class CommandGirl : ICommands
|
|||||||
level.ToString(),
|
level.ToString(),
|
||||||
girls.Count.ToString()));
|
girls.Count.ToString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[CommandMethod("break")]
|
||||||
|
public async ValueTask UpdateBreakLevel(CommandArg arg)
|
||||||
|
{
|
||||||
|
if (!await arg.CheckOnlineTarget()) return;
|
||||||
|
if (!await arg.CheckArgCnt(2)) return;
|
||||||
|
|
||||||
|
var guid = arg.GetInt(0);
|
||||||
|
var level = Math.Clamp(arg.GetInt(1), 0, 45);
|
||||||
|
var player = arg.Target!.Player!;
|
||||||
|
List<CharacterInfo> girls = [];
|
||||||
|
|
||||||
|
if (guid == -1)
|
||||||
|
{
|
||||||
|
foreach (var girl in player.CharacterManager.CharacterData.Characters)
|
||||||
|
{
|
||||||
|
girl.Break = (uint)level;
|
||||||
|
girls.Add(girl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var girl = player.CharacterManager.GetCharacterByGUID((uint)guid);
|
||||||
|
if (girl == null)
|
||||||
|
{
|
||||||
|
await arg.SendMsg(I18NManager.Translate("Game.Command.Girl.NotFound"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
girl.Break = (uint)level;
|
||||||
|
girls.Add(girl);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (girls.Count > 0) await player.SendPacket(new PacketNtfCallScript(girls));
|
||||||
|
await arg.SendMsg(I18NManager.Translate("Game.Command.Girl.UpdateBreakLevel",
|
||||||
|
level.ToString(),
|
||||||
|
girls.Count.ToString()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
using MikuSB.Data;
|
using MikuSB.Data;
|
||||||
|
using MikuSB.Database;
|
||||||
using MikuSB.Database.Inventory;
|
using MikuSB.Database.Inventory;
|
||||||
using MikuSB.Enums.Item;
|
using MikuSB.Enums.Item;
|
||||||
using MikuSB.Enums.Player;
|
using MikuSB.Enums.Player;
|
||||||
@@ -42,6 +43,7 @@ public class CommandGiveAll : ICommands
|
|||||||
weapons.Add(weapon);
|
weapons.Add(weapon);
|
||||||
}
|
}
|
||||||
if (weapons.Count > 0) await player.SendPacket(new PacketNtfCallScript(weapons));
|
if (weapons.Count > 0) await player.SendPacket(new PacketNtfCallScript(weapons));
|
||||||
|
DatabaseHelper.SaveDatabaseType(player.InventoryManager.InventoryData);
|
||||||
await arg.SendMsg(I18NManager.Translate("Game.Command.GiveAll.GiveAllItems",
|
await arg.SendMsg(I18NManager.Translate("Game.Command.GiveAll.GiveAllItems",
|
||||||
I18NManager.Translate("Word.Weapon"), weapons.Count.ToString()));
|
I18NManager.Translate("Word.Weapon"), weapons.Count.ToString()));
|
||||||
}
|
}
|
||||||
@@ -77,6 +79,7 @@ public class CommandGiveAll : ICommands
|
|||||||
supportCards.Add(supportCard);
|
supportCards.Add(supportCard);
|
||||||
}
|
}
|
||||||
if (supportCards.Count > 0) await player.SendPacket(new PacketNtfCallScript(supportCards));
|
if (supportCards.Count > 0) await player.SendPacket(new PacketNtfCallScript(supportCards));
|
||||||
|
DatabaseHelper.SaveDatabaseType(player.InventoryManager.InventoryData);
|
||||||
await arg.SendMsg(I18NManager.Translate("Game.Command.GiveAll.GiveAllItems",
|
await arg.SendMsg(I18NManager.Translate("Game.Command.GiveAll.GiveAllItems",
|
||||||
I18NManager.Translate("Word.SupportCard"), supportCards.Count.ToString()));
|
I18NManager.Translate("Word.SupportCard"), supportCards.Count.ToString()));
|
||||||
}
|
}
|
||||||
@@ -96,7 +99,7 @@ public class CommandGiveAll : ICommands
|
|||||||
foreach (var config in GameData.WeaponSkinData.Values)
|
foreach (var config in GameData.WeaponSkinData.Values)
|
||||||
{
|
{
|
||||||
var weaponSkin = await player.InventoryManager!
|
var weaponSkin = await player.InventoryManager!
|
||||||
.AddWeaponSkinItem((ItemTypeEnum)config.Genre, config.Detail, config.Particular, 1, false);
|
.AddWeaponSkinItem((ItemTypeEnum)config.Genre, config.Detail, config.Particular, config.Level, false);
|
||||||
if (weaponSkin != null) weaponSkins.Add(weaponSkin);
|
if (weaponSkin != null) weaponSkins.Add(weaponSkin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -111,7 +114,230 @@ public class CommandGiveAll : ICommands
|
|||||||
weaponSkins.Add(weaponSkin);
|
weaponSkins.Add(weaponSkin);
|
||||||
}
|
}
|
||||||
if (weaponSkins.Count > 0) await player.SendPacket(new PacketNtfCallScript(weaponSkins));
|
if (weaponSkins.Count > 0) await player.SendPacket(new PacketNtfCallScript(weaponSkins));
|
||||||
|
DatabaseHelper.SaveDatabaseType(player.InventoryManager.InventoryData);
|
||||||
await arg.SendMsg(I18NManager.Translate("Game.Command.GiveAll.GiveAllItems",
|
await arg.SendMsg(I18NManager.Translate("Game.Command.GiveAll.GiveAllItems",
|
||||||
I18NManager.Translate("Word.WeaponSkin"), weaponSkins.Count.ToString()));
|
I18NManager.Translate("Word.WeaponSkin"), weaponSkins.Count.ToString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[CommandMethod("profile")]
|
||||||
|
public async ValueTask GiveAllProfile(CommandArg arg)
|
||||||
|
{
|
||||||
|
if (!await arg.CheckOnlineTarget()) return;
|
||||||
|
if (await arg.GetOption('p') is not int particular) return;
|
||||||
|
if (await arg.GetOption('l') is not int level) return;
|
||||||
|
if (await arg.GetOption('g') is not int genre) return;
|
||||||
|
|
||||||
|
var detail = arg.GetInt(0);
|
||||||
|
var player = arg.Target!.Player!;
|
||||||
|
List<BaseGameItemInfo> profileItems = [];
|
||||||
|
if (detail == -1)
|
||||||
|
{
|
||||||
|
// add all
|
||||||
|
foreach (var config in GameData.ProfileData.Values)
|
||||||
|
{
|
||||||
|
var profile = await player.InventoryManager!
|
||||||
|
.AddProfileItem((ItemTypeEnum)config.Genre, config.Detail, config.Particular, config.Level, false);
|
||||||
|
if (profile != null) profileItems.Add(profile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var profile = await player.InventoryManager!.AddProfileItem((ItemTypeEnum)genre, (uint)detail, (uint)particular, (uint)level, false);
|
||||||
|
if (profile == null)
|
||||||
|
{
|
||||||
|
await arg.SendMsg(I18NManager.Translate("Game.Command.GiveAll.NotFound", I18NManager.Translate("Word.Profile")));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
profileItems.Add(profile);
|
||||||
|
}
|
||||||
|
if (profileItems.Count > 0) await player.SendPacket(new PacketNtfCallScript(profileItems));
|
||||||
|
DatabaseHelper.SaveDatabaseType(player.InventoryManager.InventoryData);
|
||||||
|
await arg.SendMsg(I18NManager.Translate("Game.Command.GiveAll.GiveAllItems",
|
||||||
|
I18NManager.Translate("Word.Profile"), profileItems.Count.ToString()));
|
||||||
|
}
|
||||||
|
|
||||||
|
[CommandMethod("skinpart")]
|
||||||
|
public async ValueTask GiveAllSkinPart(CommandArg arg)
|
||||||
|
{
|
||||||
|
if (!await arg.CheckOnlineTarget()) return;
|
||||||
|
if (await arg.GetOption('p') is not int particular) return;
|
||||||
|
if (await arg.GetOption('l') is not int level) return;
|
||||||
|
if (await arg.GetOption('g') is not int genre) return;
|
||||||
|
|
||||||
|
var detail = arg.GetInt(0);
|
||||||
|
var player = arg.Target!.Player!;
|
||||||
|
List<BaseGameItemInfo> skinPartItems = [];
|
||||||
|
if (detail == -1)
|
||||||
|
{
|
||||||
|
// add all
|
||||||
|
foreach (var config in GameData.CardSkinPartsData.Values)
|
||||||
|
{
|
||||||
|
var skinPart = await player.InventoryManager!
|
||||||
|
.AddSkinPartItem((ItemTypeEnum)config.Genre, config.Detail, config.Particular, config.Level, false);
|
||||||
|
if (skinPart != null) skinPartItems.Add(skinPart);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var skinPart = await player.InventoryManager!.AddSkinPartItem((ItemTypeEnum)genre, (uint)detail, (uint)particular, (uint)level, false);
|
||||||
|
if (skinPart == null)
|
||||||
|
{
|
||||||
|
await arg.SendMsg(I18NManager.Translate("Game.Command.GiveAll.NotFound", I18NManager.Translate("Word.SkinPart")));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
skinPartItems.Add(skinPart);
|
||||||
|
}
|
||||||
|
if (skinPartItems.Count > 0) await player.SendPacket(new PacketNtfCallScript(skinPartItems));
|
||||||
|
DatabaseHelper.SaveDatabaseType(player.InventoryManager.InventoryData);
|
||||||
|
await arg.SendMsg(I18NManager.Translate("Game.Command.GiveAll.GiveAllItems",
|
||||||
|
I18NManager.Translate("Word.SkinPart"), skinPartItems.Count.ToString()));
|
||||||
|
}
|
||||||
|
|
||||||
|
[CommandMethod("call")]
|
||||||
|
public async ValueTask GiveAllCallItem(CommandArg arg)
|
||||||
|
{
|
||||||
|
if (!await arg.CheckOnlineTarget()) return;
|
||||||
|
if (await arg.GetOption('p') is not int particular) return;
|
||||||
|
if (await arg.GetOption('l') is not int level) return;
|
||||||
|
if (await arg.GetOption('g') is not int genre) return;
|
||||||
|
|
||||||
|
var detail = arg.GetInt(0);
|
||||||
|
var player = arg.Target!.Player!;
|
||||||
|
List<BaseGameItemInfo> callItems = [];
|
||||||
|
if (detail == -1)
|
||||||
|
{
|
||||||
|
// add all
|
||||||
|
foreach (var config in GameData.CallItemData.Values)
|
||||||
|
{
|
||||||
|
var callItem = await player.InventoryManager!
|
||||||
|
.AddCallItem((ItemTypeEnum)config.Genre, config.Detail, config.Particular, config.Level, false);
|
||||||
|
if (callItem != null) callItems.Add(callItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var callItem = await player.InventoryManager!.AddCallItem((ItemTypeEnum)genre, (uint)detail, (uint)particular, (uint)level, false);
|
||||||
|
if (callItem == null)
|
||||||
|
{
|
||||||
|
await arg.SendMsg(I18NManager.Translate("Game.Command.GiveAll.NotFound", I18NManager.Translate("Word.CallItem")));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
callItems.Add(callItem);
|
||||||
|
}
|
||||||
|
if (callItems.Count > 0) await player.SendPacket(new PacketNtfCallScript(callItems));
|
||||||
|
DatabaseHelper.SaveDatabaseType(player.InventoryManager.InventoryData);
|
||||||
|
await arg.SendMsg(I18NManager.Translate("Game.Command.GiveAll.GiveAllItems",
|
||||||
|
I18NManager.Translate("Word.CallItem"), callItems.Count.ToString()));
|
||||||
|
}
|
||||||
|
|
||||||
|
[CommandMethod("weaponpart")]
|
||||||
|
public async ValueTask GiveAllWeaponPart(CommandArg arg)
|
||||||
|
{
|
||||||
|
if (!await arg.CheckOnlineTarget()) return;
|
||||||
|
if (await arg.GetOption('p') is not int particular) return;
|
||||||
|
if (await arg.GetOption('l') is not int level) return;
|
||||||
|
if (await arg.GetOption('g') is not int genre) return;
|
||||||
|
|
||||||
|
var detail = arg.GetInt(0);
|
||||||
|
var player = arg.Target!.Player!;
|
||||||
|
List<BaseGameItemInfo> weaponPartItems = [];
|
||||||
|
if (detail == -1)
|
||||||
|
{
|
||||||
|
// add all
|
||||||
|
foreach (var config in GameData.WeaponPartsData.Values)
|
||||||
|
{
|
||||||
|
var weaponPart = await player.InventoryManager!
|
||||||
|
.AddWeaponPartItem((ItemTypeEnum)config.Genre, config.Detail, config.Particular, config.Level, false);
|
||||||
|
if (weaponPart != null) weaponPartItems.Add(weaponPart);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var weaponPart = await player.InventoryManager!.AddWeaponPartItem((ItemTypeEnum)genre, (uint)detail, (uint)particular, (uint)level, false);
|
||||||
|
if (weaponPart == null)
|
||||||
|
{
|
||||||
|
await arg.SendMsg(I18NManager.Translate("Game.Command.GiveAll.NotFound", I18NManager.Translate("Word.WeaponPart")));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
weaponPartItems.Add(weaponPart);
|
||||||
|
}
|
||||||
|
if (weaponPartItems.Count > 0) await player.SendPacket(new PacketNtfCallScript(weaponPartItems));
|
||||||
|
DatabaseHelper.SaveDatabaseType(player.InventoryManager.InventoryData);
|
||||||
|
await arg.SendMsg(I18NManager.Translate("Game.Command.GiveAll.GiveAllItems",
|
||||||
|
I18NManager.Translate("Word.WeaponPart"), weaponPartItems.Count.ToString()));
|
||||||
|
}
|
||||||
|
|
||||||
|
[CommandMethod("skin")]
|
||||||
|
public async ValueTask GiveAllSkin(CommandArg arg)
|
||||||
|
{
|
||||||
|
if (!await arg.CheckOnlineTarget()) return;
|
||||||
|
if (await arg.GetOption('p') is not int particular) return;
|
||||||
|
if (await arg.GetOption('l') is not int level) return;
|
||||||
|
if (await arg.GetOption('g') is not int genre) return;
|
||||||
|
|
||||||
|
var detail = arg.GetInt(0);
|
||||||
|
var player = arg.Target!.Player!;
|
||||||
|
List<GameSkinInfo> skinItems = [];
|
||||||
|
if (detail == -1)
|
||||||
|
{
|
||||||
|
// add all
|
||||||
|
foreach (var config in GameData.CardSkinData.Values)
|
||||||
|
{
|
||||||
|
var skin = await player.InventoryManager!
|
||||||
|
.AddSkinItem((ItemTypeEnum)config.Genre, config.Detail, config.Particular, config.Level, false);
|
||||||
|
if (skin != null) skinItems.Add(skin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var skin = await player.InventoryManager!.AddSkinItem((ItemTypeEnum)genre, (uint)detail, (uint)particular, (uint)level, false);
|
||||||
|
if (skin == null)
|
||||||
|
{
|
||||||
|
await arg.SendMsg(I18NManager.Translate("Game.Command.GiveAll.NotFound", I18NManager.Translate("Word.Skin")));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
skinItems.Add(skin);
|
||||||
|
}
|
||||||
|
if (skinItems.Count > 0) await player.SendPacket(new PacketNtfCallScript(skinItems));
|
||||||
|
DatabaseHelper.SaveDatabaseType(player.InventoryManager.InventoryData);
|
||||||
|
await arg.SendMsg(I18NManager.Translate("Game.Command.GiveAll.GiveAllItems",
|
||||||
|
I18NManager.Translate("Word.Skin"), skinItems.Count.ToString()));
|
||||||
|
}
|
||||||
|
|
||||||
|
[CommandMethod("furniture")]
|
||||||
|
public async ValueTask GiveAllHouseFurniture(CommandArg arg)
|
||||||
|
{
|
||||||
|
if (!await arg.CheckOnlineTarget()) return;
|
||||||
|
if (await arg.GetOption('p') is not int particular) return;
|
||||||
|
if (await arg.GetOption('l') is not int level) return;
|
||||||
|
if (await arg.GetOption('g') is not int genre) return;
|
||||||
|
|
||||||
|
var detail = arg.GetInt(0);
|
||||||
|
var player = arg.Target!.Player!;
|
||||||
|
List<BaseGameItemInfo> furnitureItems = [];
|
||||||
|
if (detail == -1)
|
||||||
|
{
|
||||||
|
// add all
|
||||||
|
foreach (var config in GameData.DormGiftData.Values)
|
||||||
|
{
|
||||||
|
var furniture = await player.InventoryManager!
|
||||||
|
.AddHouseFurnitureItem((ItemTypeEnum)config.Genre, config.Detail, config.Particular, config.Level, false);
|
||||||
|
if (furniture != null) furnitureItems.Add(furniture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var furniture = await player.InventoryManager!.AddHouseFurnitureItem((ItemTypeEnum)genre, (uint)detail, (uint)particular, (uint)level, false);
|
||||||
|
if (furniture == null)
|
||||||
|
{
|
||||||
|
await arg.SendMsg(I18NManager.Translate("Game.Command.GiveAll.NotFound", I18NManager.Translate("Word.Furniture")));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
furnitureItems.Add(furniture);
|
||||||
|
}
|
||||||
|
if (furnitureItems.Count > 0) await player.SendPacket(new PacketNtfCallScript(furnitureItems));
|
||||||
|
DatabaseHelper.SaveDatabaseType(player.InventoryManager.InventoryData);
|
||||||
|
await arg.SendMsg(I18NManager.Translate("Game.Command.GiveAll.GiveAllItems",
|
||||||
|
I18NManager.Translate("Word.Furniture"), furnitureItems.Count.ToString()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
498
GameServer/Game/BossPvp/BossPvpService.cs
Normal file
498
GameServer/Game/BossPvp/BossPvpService.cs
Normal file
@@ -0,0 +1,498 @@
|
|||||||
|
using MikuSB.Data;
|
||||||
|
using MikuSB.Data.Excel;
|
||||||
|
using MikuSB.Database.Inventory;
|
||||||
|
using MikuSB.GameServer.Game.Player;
|
||||||
|
using MikuSB.Proto;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.Text.Json;
|
||||||
|
using System.Text.Json.Nodes;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace MikuSB.GameServer.Game.BossPvp;
|
||||||
|
|
||||||
|
internal static class BossPvpService
|
||||||
|
{
|
||||||
|
private const uint GroupId = 51;
|
||||||
|
private const uint ActivitySubId = 0;
|
||||||
|
private const uint ChallengeNumSid = 1;
|
||||||
|
private const uint DiffStartId = 10;
|
||||||
|
private const uint LevelStartSid = 100;
|
||||||
|
private const uint LevelStride = 10;
|
||||||
|
private const uint BossLineup1 = 15;
|
||||||
|
private const uint BossLineup2 = 16;
|
||||||
|
|
||||||
|
private static readonly JsonSerializerOptions JsonOptions = new()
|
||||||
|
{
|
||||||
|
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull
|
||||||
|
};
|
||||||
|
|
||||||
|
public static async ValueTask<(object Response, NtfSyncPlayer Sync)> HandleGetOpenIdAsync(PlayerInstance player)
|
||||||
|
{
|
||||||
|
await EnsureBossLineupsAsync(player);
|
||||||
|
|
||||||
|
var sync = new NtfSyncPlayer();
|
||||||
|
var season = GetOpenSeason();
|
||||||
|
var seasonId = season?.ID ?? 1u;
|
||||||
|
|
||||||
|
SetStr(player, ActivitySubId, seasonId.ToString(CultureInfo.InvariantCulture), sync);
|
||||||
|
SetStr(player, ChallengeNumSid, GetDailyChallengeNum().ToString(CultureInfo.InvariantCulture), sync);
|
||||||
|
|
||||||
|
if (season != null)
|
||||||
|
{
|
||||||
|
for (var index = 0; index < season.BossIds.Count; index++)
|
||||||
|
{
|
||||||
|
var bossLevelId = season.BossIds[index];
|
||||||
|
EnsureStr(player, DiffStartId + (uint)(index + 1), "0", sync);
|
||||||
|
EnsureStr(player, GetBossSid(bossLevelId, 1), EmptySnapshotJson(), sync);
|
||||||
|
EnsureStr(player, GetBossSid(bossLevelId, 2), EmptySnapshotJson(), sync);
|
||||||
|
EnsureStr(player, GetBossSid(bossLevelId, 3), EmptySnapshotJson(), sync);
|
||||||
|
EnsureStr(player, GetBossSid(bossLevelId, 4), "0", sync);
|
||||||
|
EnsureStr(player, GetBossSid(bossLevelId, 5), "0", sync);
|
||||||
|
EnsureStr(player, GetBossSid(bossLevelId, 6), "0", sync);
|
||||||
|
EnsureStr(player, GetBossSid(bossLevelId, 7), "0", sync);
|
||||||
|
EnsureStr(player, GetBossSid(bossLevelId, 8), "0", sync);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var response = new
|
||||||
|
{
|
||||||
|
nID = seasonId,
|
||||||
|
tbTimeCfg = new[]
|
||||||
|
{
|
||||||
|
new
|
||||||
|
{
|
||||||
|
nStartTime = -1,
|
||||||
|
nEndTime = -1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (response, sync);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static object HandleEnterLevel(string? param)
|
||||||
|
{
|
||||||
|
var req = Deserialize<EnterLevelParam>(param);
|
||||||
|
return new
|
||||||
|
{
|
||||||
|
nSeed = Random.Shared.Next(1, int.MaxValue),
|
||||||
|
nID = req?.NId ?? 0
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static (object Response, NtfSyncPlayer Sync) HandleRecord(PlayerInstance player, string? param)
|
||||||
|
{
|
||||||
|
var req = Deserialize<RecordParam>(param);
|
||||||
|
if (req == null)
|
||||||
|
{
|
||||||
|
return (new { bRecord = false }, new NtfSyncPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
|
var sync = new NtfSyncPlayer();
|
||||||
|
if (req.BRecord)
|
||||||
|
{
|
||||||
|
var historyScore = ReadInt(player, GetBossSid(req.NId, 4));
|
||||||
|
var currentScore = ComputeIntegral(req.NId, req.NDiff, req.ResidueTime);
|
||||||
|
if (currentScore >= historyScore)
|
||||||
|
{
|
||||||
|
WriteBestRun(player, req.NId, req.NTeamId, req.NTime, currentScore, sync);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (new { bRecord = req.BRecord }, sync);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static (JsonNode Response, NtfSyncPlayer Sync) HandleSettlement(PlayerInstance player, JsonNode? param)
|
||||||
|
{
|
||||||
|
var req = param?.Deserialize<SettlementParam>(JsonOptions);
|
||||||
|
var sync = new NtfSyncPlayer();
|
||||||
|
if (req == null)
|
||||||
|
{
|
||||||
|
return (new JsonObject(), sync);
|
||||||
|
}
|
||||||
|
|
||||||
|
var totalSid = GetBossSid(req.NId, 7);
|
||||||
|
var successSid = GetBossSid(req.NId, 6);
|
||||||
|
var diffSid = GetBossSid(req.NId, 8);
|
||||||
|
|
||||||
|
SetStr(player, totalSid, (ReadInt(player, totalSid) + 1).ToString(CultureInfo.InvariantCulture), sync);
|
||||||
|
SetStr(player, successSid, (ReadInt(player, successSid) + 1).ToString(CultureInfo.InvariantCulture), sync);
|
||||||
|
|
||||||
|
var clearedDiff = Math.Max(ReadInt(player, diffSid), req.NDiff);
|
||||||
|
SetStr(player, diffSid, clearedDiff.ToString(CultureInfo.InvariantCulture), sync);
|
||||||
|
|
||||||
|
var positionSid = TryGetPositionDiffSid(req.NId);
|
||||||
|
if (positionSid != null)
|
||||||
|
{
|
||||||
|
var newPositionDiff = Math.Max(ReadInt(player, positionSid.Value), req.NDiff);
|
||||||
|
SetStr(player, positionSid.Value, newPositionDiff.ToString(CultureInfo.InvariantCulture), sync);
|
||||||
|
}
|
||||||
|
|
||||||
|
var score = ComputeIntegral(req.NId, req.NDiff, req.ResidueTime);
|
||||||
|
if (score > ReadInt(player, GetBossSid(req.NId, 4)))
|
||||||
|
{
|
||||||
|
WriteBestRun(player, req.NId, req.NTeamId, req.NTime, score, sync);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (new JsonObject(), sync);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static (JsonNode Response, NtfSyncPlayer Sync) HandleFail(PlayerInstance player, JsonNode? param)
|
||||||
|
{
|
||||||
|
var req = param?.Deserialize<FailParam>(JsonOptions);
|
||||||
|
var sync = new NtfSyncPlayer();
|
||||||
|
if (req == null)
|
||||||
|
{
|
||||||
|
return (new JsonObject(), sync);
|
||||||
|
}
|
||||||
|
|
||||||
|
var totalSid = GetBossSid(req.NId, 7);
|
||||||
|
SetStr(player, totalSid, (ReadInt(player, totalSid) + 1).ToString(CultureInfo.InvariantCulture), sync);
|
||||||
|
|
||||||
|
return (new JsonObject(), sync);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static (object Response, NtfSyncPlayer Sync) HandleMopup(PlayerInstance player, string? param)
|
||||||
|
{
|
||||||
|
var req = Deserialize<MopupParam>(param);
|
||||||
|
var sync = new NtfSyncPlayer();
|
||||||
|
if (req == null)
|
||||||
|
{
|
||||||
|
return (new { }, sync);
|
||||||
|
}
|
||||||
|
|
||||||
|
var totalSid = GetBossSid(req.NId, 7);
|
||||||
|
var successSid = GetBossSid(req.NId, 6);
|
||||||
|
var diffSid = GetBossSid(req.NId, 8);
|
||||||
|
|
||||||
|
SetStr(player, totalSid, (ReadInt(player, totalSid) + 1).ToString(CultureInfo.InvariantCulture), sync);
|
||||||
|
SetStr(player, successSid, (ReadInt(player, successSid) + 1).ToString(CultureInfo.InvariantCulture), sync);
|
||||||
|
|
||||||
|
var clearedDiff = Math.Max(ReadInt(player, diffSid), req.NDiff);
|
||||||
|
SetStr(player, diffSid, clearedDiff.ToString(CultureInfo.InvariantCulture), sync);
|
||||||
|
|
||||||
|
var positionSid = TryGetPositionDiffSid(req.NId);
|
||||||
|
if (positionSid != null)
|
||||||
|
{
|
||||||
|
var newPositionDiff = Math.Max(ReadInt(player, positionSid.Value), req.NDiff + 1);
|
||||||
|
SetStr(player, positionSid.Value, newPositionDiff.ToString(CultureInfo.InvariantCulture), sync);
|
||||||
|
}
|
||||||
|
|
||||||
|
var score = ComputeIntegral(req.NId, req.NDiff, 0);
|
||||||
|
if (score > ReadInt(player, GetBossSid(req.NId, 4)))
|
||||||
|
{
|
||||||
|
WriteBestRun(player, req.NId, 0, 0, score, sync);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (new { }, sync);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static object HandleGetReward(string? param)
|
||||||
|
{
|
||||||
|
_ = Deserialize<RewardParam>(param);
|
||||||
|
return new { tbAward = Array.Empty<object>() };
|
||||||
|
}
|
||||||
|
|
||||||
|
private static async ValueTask EnsureBossLineupsAsync(PlayerInstance player)
|
||||||
|
{
|
||||||
|
var lineups = player.LineupManager.LineupData.LineupInfo;
|
||||||
|
var baseLineup = lineups.GetValueOrDefault(1) ?? lineups.Values.FirstOrDefault();
|
||||||
|
if (baseLineup == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!lineups.ContainsKey((int)BossLineup1))
|
||||||
|
{
|
||||||
|
await player.LineupManager.UpdateLineup((int)BossLineup1, baseLineup.Member1, baseLineup.Member2, baseLineup.Member3, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!lineups.ContainsKey((int)BossLineup2))
|
||||||
|
{
|
||||||
|
await player.LineupManager.UpdateLineup((int)BossLineup2, baseLineup.Member1, baseLineup.Member2, baseLineup.Member3, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void WriteBestRun(PlayerInstance player, uint bossLevelId, uint lineupId, double finishTime, int score, NtfSyncPlayer sync)
|
||||||
|
{
|
||||||
|
var snapshots = CaptureLineupSnapshots(player, lineupId);
|
||||||
|
SetStr(player, GetBossSid(bossLevelId, 1), System.Text.Json.JsonSerializer.Serialize(snapshots[0], JsonOptions), sync);
|
||||||
|
SetStr(player, GetBossSid(bossLevelId, 2), System.Text.Json.JsonSerializer.Serialize(snapshots[1], JsonOptions), sync);
|
||||||
|
SetStr(player, GetBossSid(bossLevelId, 3), System.Text.Json.JsonSerializer.Serialize(snapshots[2], JsonOptions), sync);
|
||||||
|
SetStr(player, GetBossSid(bossLevelId, 4), score.ToString(CultureInfo.InvariantCulture), sync);
|
||||||
|
SetStr(player, GetBossSid(bossLevelId, 5), Math.Max(0, (int)Math.Floor(finishTime)).ToString(CultureInfo.InvariantCulture), sync);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static BossPvpRoleSnapshot[] CaptureLineupSnapshots(PlayerInstance player, uint lineupId)
|
||||||
|
{
|
||||||
|
var lineups = player.LineupManager.LineupData.LineupInfo;
|
||||||
|
var lineup = lineups.GetValueOrDefault((int)lineupId)
|
||||||
|
?? lineups.GetValueOrDefault((int)BossLineup1)
|
||||||
|
?? lineups.GetValueOrDefault(1)
|
||||||
|
?? lineups.Values.FirstOrDefault();
|
||||||
|
|
||||||
|
if (lineup == null)
|
||||||
|
{
|
||||||
|
return [new(), new(), new()];
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
[
|
||||||
|
CaptureRoleSnapshot(player, lineup.Member1),
|
||||||
|
CaptureRoleSnapshot(player, lineup.Member2),
|
||||||
|
CaptureRoleSnapshot(player, lineup.Member3)
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
private static BossPvpRoleSnapshot CaptureRoleSnapshot(PlayerInstance player, uint characterGuid)
|
||||||
|
{
|
||||||
|
if (characterGuid == 0)
|
||||||
|
{
|
||||||
|
return new BossPvpRoleSnapshot();
|
||||||
|
}
|
||||||
|
|
||||||
|
var character = player.CharacterManager.GetCharacterByGUID(characterGuid);
|
||||||
|
if (character == null)
|
||||||
|
{
|
||||||
|
return new BossPvpRoleSnapshot();
|
||||||
|
}
|
||||||
|
|
||||||
|
var snapshot = new BossPvpRoleSnapshot
|
||||||
|
{
|
||||||
|
Role = character.Guid,
|
||||||
|
Weapon = character.WeaponUniqueId
|
||||||
|
};
|
||||||
|
|
||||||
|
var weapon = player.InventoryManager.GetWeaponItem(character.WeaponUniqueId);
|
||||||
|
if (weapon != null)
|
||||||
|
{
|
||||||
|
snapshot.Wgdpl = BuildWeaponGdpl(weapon);
|
||||||
|
snapshot.Wslot = weapon.PartSlots;
|
||||||
|
}
|
||||||
|
|
||||||
|
var supports = character.SupportSlots
|
||||||
|
.OrderBy(x => x.Key)
|
||||||
|
.Select(x => x.Value)
|
||||||
|
.Where(x => x != 0)
|
||||||
|
.Take(3)
|
||||||
|
.ToArray();
|
||||||
|
|
||||||
|
if (supports.Length > 0)
|
||||||
|
{
|
||||||
|
snapshot.S1 = supports[0];
|
||||||
|
snapshot.Sgdpl1 = BuildSupportGdpl(player.InventoryManager.GetSupportCardItem(supports[0]));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (supports.Length > 1)
|
||||||
|
{
|
||||||
|
snapshot.S2 = supports[1];
|
||||||
|
snapshot.Sgdpl2 = BuildSupportGdpl(player.InventoryManager.GetSupportCardItem(supports[1]));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (supports.Length > 2)
|
||||||
|
{
|
||||||
|
snapshot.S3 = supports[2];
|
||||||
|
snapshot.Sgdpl3 = BuildSupportGdpl(player.InventoryManager.GetSupportCardItem(supports[2]));
|
||||||
|
}
|
||||||
|
|
||||||
|
return snapshot;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<uint> BuildWeaponGdpl(GameWeaponInfo weapon)
|
||||||
|
{
|
||||||
|
var gdpl = DecodeGdpl(weapon.TemplateId);
|
||||||
|
gdpl.Add(weapon.Level);
|
||||||
|
gdpl.Add(weapon.Evolue);
|
||||||
|
return gdpl;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<uint> BuildSupportGdpl(GameSupportCardInfo? support)
|
||||||
|
{
|
||||||
|
if (support == null)
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
var gdpl = DecodeGdpl(support.TemplateId);
|
||||||
|
gdpl.Add(support.Level);
|
||||||
|
gdpl.Add(0);
|
||||||
|
return gdpl;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<uint> DecodeGdpl(ulong templateId)
|
||||||
|
{
|
||||||
|
return
|
||||||
|
[
|
||||||
|
(uint)(templateId & 0xFFFF),
|
||||||
|
(uint)((templateId >> 16) & 0xFFFF),
|
||||||
|
(uint)((templateId >> 32) & 0xFFFF),
|
||||||
|
(uint)((templateId >> 48) & 0xFFFF)
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int ComputeIntegral(uint bossLevelId, int diff, int residueTime)
|
||||||
|
{
|
||||||
|
if (!GameData.BossPvpBossData.TryGetValue(bossLevelId, out var boss) || diff <= 0 || diff > boss.BossLevel.Count)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
var info = boss.BossLevel[diff - 1];
|
||||||
|
if (info.Count == 0)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
var multiplier = info.Count > 2 ? info[2] : 0;
|
||||||
|
var baseScore = info.Count > 3 ? info[3] : 0;
|
||||||
|
var residueScore = info.Count > 4 ? info[4] : 0;
|
||||||
|
var total = (baseScore + residueScore * Math.Max(0, residueTime)) * multiplier;
|
||||||
|
return (int)Math.Floor(total + 0.5);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static uint? TryGetPositionDiffSid(uint bossLevelId)
|
||||||
|
{
|
||||||
|
var season = GetOpenSeason();
|
||||||
|
if (season == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
var index = season.BossIds.FindIndex(x => x == bossLevelId);
|
||||||
|
return index >= 0 ? DiffStartId + (uint)(index + 1) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static BossPvpBossChallengeExcel? GetOpenSeason()
|
||||||
|
{
|
||||||
|
var now = DateTimeOffset.Now;
|
||||||
|
var current = GameData.BossPvpBossChallengeData.Values
|
||||||
|
.OrderBy(x => x.ID)
|
||||||
|
.FirstOrDefault(x =>
|
||||||
|
{
|
||||||
|
var startAt = ParseBossTime(x.StartTime);
|
||||||
|
var endAt = ParseBossTime(x.EndTime);
|
||||||
|
return startAt != null && endAt != null && now >= startAt && now <= endAt;
|
||||||
|
});
|
||||||
|
|
||||||
|
return current ?? GameData.BossPvpBossChallengeData.Values.OrderBy(x => x.ID).FirstOrDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static uint GetDailyChallengeNum()
|
||||||
|
{
|
||||||
|
var now = DateTime.Now;
|
||||||
|
if (now.Hour < 4)
|
||||||
|
{
|
||||||
|
now = now.AddHours(-4);
|
||||||
|
}
|
||||||
|
|
||||||
|
var week = now.DayOfWeek == DayOfWeek.Sunday ? 7 : (int)now.DayOfWeek;
|
||||||
|
return GameData.BossPvpNumData.TryGetValue((uint)week, out var count) ? count.Num : 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int ReadInt(PlayerInstance player, uint sid)
|
||||||
|
{
|
||||||
|
var attr = player.Data.StrAttrs.FirstOrDefault(x => x.Gid == GroupId && x.Sid == sid)?.Val;
|
||||||
|
return int.TryParse(attr, NumberStyles.Integer, CultureInfo.InvariantCulture, out var value) ? value : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void EnsureStr(PlayerInstance player, uint sid, string value, NtfSyncPlayer sync)
|
||||||
|
{
|
||||||
|
var attr = player.Data.StrAttrs.FirstOrDefault(x => x.Gid == GroupId && x.Sid == sid);
|
||||||
|
if (attr != null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SetStr(player, sid, value, sync);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void SetStr(PlayerInstance player, uint sid, string value, NtfSyncPlayer sync)
|
||||||
|
{
|
||||||
|
player.SetStrAttr(GroupId, sid, value);
|
||||||
|
sync.CustomStr[player.ToShiftedAttrKey(GroupId, sid)] = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static uint GetBossSid(uint bossLevelId, uint offset) => (LevelStride * bossLevelId) + LevelStartSid + offset;
|
||||||
|
|
||||||
|
private static string EmptySnapshotJson() => System.Text.Json.JsonSerializer.Serialize(new BossPvpRoleSnapshot(), JsonOptions);
|
||||||
|
|
||||||
|
private static T? Deserialize<T>(string? param)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(param))
|
||||||
|
{
|
||||||
|
return default;
|
||||||
|
}
|
||||||
|
|
||||||
|
return System.Text.Json.JsonSerializer.Deserialize<T>(param, JsonOptions);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static DateTimeOffset? ParseBossTime(string? value)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(value))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
var raw = value.Trim().Trim('[', ']');
|
||||||
|
if (!DateTime.TryParseExact(raw, "yyyyMMddHHmm", CultureInfo.InvariantCulture, DateTimeStyles.None, out var localTime))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new DateTimeOffset(localTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
private sealed class EnterLevelParam
|
||||||
|
{
|
||||||
|
[JsonPropertyName("nID")] public uint NId { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
private sealed class RecordParam
|
||||||
|
{
|
||||||
|
[JsonPropertyName("nID")] public uint NId { get; set; }
|
||||||
|
[JsonPropertyName("nDiff")] public int NDiff { get; set; }
|
||||||
|
[JsonPropertyName("nTime")] public double NTime { get; set; }
|
||||||
|
[JsonPropertyName("ResidueTime")] public int ResidueTime { get; set; }
|
||||||
|
[JsonPropertyName("bRecord")] public bool BRecord { get; set; }
|
||||||
|
[JsonPropertyName("nTeamID")] public uint NTeamId { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
private sealed class SettlementParam
|
||||||
|
{
|
||||||
|
[JsonPropertyName("nID")] public uint NId { get; set; }
|
||||||
|
[JsonPropertyName("nDiff")] public int NDiff { get; set; }
|
||||||
|
[JsonPropertyName("nTime")] public double NTime { get; set; }
|
||||||
|
[JsonPropertyName("ResidueTime")] public int ResidueTime { get; set; }
|
||||||
|
[JsonPropertyName("nTeamID")] public uint NTeamId { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
private sealed class FailParam
|
||||||
|
{
|
||||||
|
[JsonPropertyName("nID")] public uint NId { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
private sealed class MopupParam
|
||||||
|
{
|
||||||
|
[JsonPropertyName("nID")] public uint NId { get; set; }
|
||||||
|
[JsonPropertyName("nDiff")] public int NDiff { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
private sealed class RewardParam
|
||||||
|
{
|
||||||
|
[JsonPropertyName("tbTaskID")] public List<uint> TaskIds { get; set; } = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
private sealed class BossPvpRoleSnapshot
|
||||||
|
{
|
||||||
|
[JsonPropertyName("role")] public uint Role { get; set; }
|
||||||
|
[JsonPropertyName("weapon")] public uint Weapon { get; set; }
|
||||||
|
[JsonPropertyName("s1")] public uint S1 { get; set; }
|
||||||
|
[JsonPropertyName("s2")] public uint S2 { get; set; }
|
||||||
|
[JsonPropertyName("s3")] public uint S3 { get; set; }
|
||||||
|
[JsonPropertyName("wgdpl")] public List<uint> Wgdpl { get; set; } = [];
|
||||||
|
[JsonPropertyName("wslot")] public Dictionary<uint, ulong> Wslot { get; set; } = [];
|
||||||
|
[JsonPropertyName("sgdpl1")] public List<uint> Sgdpl1 { get; set; } = [];
|
||||||
|
[JsonPropertyName("sgdpl2")] public List<uint> Sgdpl2 { get; set; } = [];
|
||||||
|
[JsonPropertyName("sgdpl3")] public List<uint> Sgdpl3 { get; set; } = [];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -27,11 +27,11 @@ public class CharacterManager(PlayerInstance player) : BasePlayerManager(player)
|
|||||||
Timestamp = Extensions.GetUnixSec()
|
Timestamp = Extensions.GetUnixSec()
|
||||||
};
|
};
|
||||||
|
|
||||||
var weaponInfo = await Player.InventoryManager!.AddWeaponItem((ItemTypeEnum)CharacterExcel.DefaultWeaponGPDL[0], CharacterExcel.DefaultWeaponGPDL[1], CharacterExcel.DefaultWeaponGPDL[2], CharacterExcel.DefaultWeaponGPDL[3],sendPacket:false);
|
var weaponInfo = await Player.InventoryManager!.AddWeaponItem((ItemTypeEnum)CharacterExcel.DefaultWeaponGPDL[0], CharacterExcel.DefaultWeaponGPDL[1], CharacterExcel.DefaultWeaponGPDL[2], CharacterExcel.DefaultWeaponGPDL[3],sendPacket: true);
|
||||||
if (weaponInfo != null) character.WeaponUniqueId = weaponInfo.UniqueId;
|
if (weaponInfo != null) character.WeaponUniqueId = weaponInfo.UniqueId;
|
||||||
|
|
||||||
var skinInfo = Player.InventoryManager!.GetSkinItemGDPL(ItemTypeEnum.TYPE_CARD_SKIN, detail, particular, level)
|
var skinInfo = Player.InventoryManager!.GetSkinItemGDPL(ItemTypeEnum.TYPE_CARD_SKIN, detail, particular, level)
|
||||||
?? await Player.InventoryManager!.AddSkinItem(ItemTypeEnum.TYPE_CARD_SKIN, detail, particular, level, false);
|
?? await Player.InventoryManager!.AddSkinItem(ItemTypeEnum.TYPE_CARD_SKIN, detail, particular, level, true);
|
||||||
if (skinInfo != null) character.SkinId = skinInfo.UniqueId;
|
if (skinInfo != null) character.SkinId = skinInfo.UniqueId;
|
||||||
|
|
||||||
if (sendPacket) await Player.SendPacket(new PacketNtfCallScript([character]));
|
if (sendPacket) await Player.SendPacket(new PacketNtfCallScript([character]));
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using MikuSB.Database;
|
|||||||
using MikuSB.Database.Inventory;
|
using MikuSB.Database.Inventory;
|
||||||
using MikuSB.Enums.Item;
|
using MikuSB.Enums.Item;
|
||||||
using MikuSB.GameServer.Game.Player;
|
using MikuSB.GameServer.Game.Player;
|
||||||
|
using MikuSB.GameServer.Game.Support;
|
||||||
using MikuSB.GameServer.Server.Packet.Send.Misc;
|
using MikuSB.GameServer.Server.Packet.Send.Misc;
|
||||||
|
|
||||||
namespace MikuSB.GameServer.Game.Inventory;
|
namespace MikuSB.GameServer.Game.Inventory;
|
||||||
@@ -25,7 +26,7 @@ public class InventoryManager(PlayerInstance player) : BasePlayerManager(player)
|
|||||||
UniqueId = InventoryData.NextUniqueUid++,
|
UniqueId = InventoryData.NextUniqueUid++,
|
||||||
Level = weaponLevel,
|
Level = weaponLevel,
|
||||||
Break = GetWeaponBreak(weaponLevel),
|
Break = GetWeaponBreak(weaponLevel),
|
||||||
ItemType = ItemTypeEnum.TYPE_WEAPON,
|
ItemType = genre,
|
||||||
ItemCount = 1
|
ItemCount = 1
|
||||||
};
|
};
|
||||||
InventoryData.Weapons[weaponInfo.UniqueId] = weaponInfo;
|
InventoryData.Weapons[weaponInfo.UniqueId] = weaponInfo;
|
||||||
@@ -67,13 +68,13 @@ public class InventoryManager(PlayerInstance player) : BasePlayerManager(player)
|
|||||||
if (genre != ItemTypeEnum.TYPE_CARD_SKIN) return null;
|
if (genre != ItemTypeEnum.TYPE_CARD_SKIN) return null;
|
||||||
var skinData = GameData.CardSkinData.Values.FirstOrDefault(x => x.Genre == (int)genre && x.Detail == detail && x.Particular == particular && x.Level == level);
|
var skinData = GameData.CardSkinData.Values.FirstOrDefault(x => x.Genre == (int)genre && x.Detail == detail && x.Particular == particular && x.Level == level);
|
||||||
if (skinData == null) return null;
|
if (skinData == null) return null;
|
||||||
|
|
||||||
var templateId = GameResourceTemplateId.FromGdpl((uint)genre,detail,particular,level);
|
var templateId = GameResourceTemplateId.FromGdpl((uint)genre,detail,particular,level);
|
||||||
|
if (InventoryData.Items.Values.Any(x => x.TemplateId == templateId)) return null;
|
||||||
var skinInfo = new GameSkinInfo
|
var skinInfo = new GameSkinInfo
|
||||||
{
|
{
|
||||||
TemplateId = templateId,
|
TemplateId = templateId,
|
||||||
UniqueId = InventoryData.NextUniqueUid++,
|
UniqueId = InventoryData.NextUniqueUid++,
|
||||||
ItemType = ItemTypeEnum.TYPE_CARD_SKIN,
|
ItemType = genre,
|
||||||
ItemCount = 1
|
ItemCount = 1
|
||||||
};
|
};
|
||||||
InventoryData.Skins[skinInfo.UniqueId] = skinInfo;
|
InventoryData.Skins[skinInfo.UniqueId] = skinInfo;
|
||||||
@@ -111,7 +112,7 @@ public class InventoryManager(PlayerInstance player) : BasePlayerManager(player)
|
|||||||
{
|
{
|
||||||
TemplateId = templateId,
|
TemplateId = templateId,
|
||||||
UniqueId = InventoryData.NextUniqueUid++,
|
UniqueId = InventoryData.NextUniqueUid++,
|
||||||
ItemType = ItemTypeEnum.TYPE_AR,
|
ItemType = genre,
|
||||||
ItemCount = 1
|
ItemCount = 1
|
||||||
};
|
};
|
||||||
InventoryData.Items[arInfo.UniqueId] = arInfo;
|
InventoryData.Items[arInfo.UniqueId] = arInfo;
|
||||||
@@ -135,7 +136,17 @@ public class InventoryManager(PlayerInstance player) : BasePlayerManager(player)
|
|||||||
ItemType = genre,
|
ItemType = genre,
|
||||||
ItemCount = 1,
|
ItemCount = 1,
|
||||||
Level = cardLevel,
|
Level = cardLevel,
|
||||||
|
AffixId = 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var affixCount = cardLevel >= spCard.MaxLevel ? spCard.TotalAffixCount : spCard.InitialAffixCount;
|
||||||
|
for (int i = 0; i < affixCount && i < spCard.AffixPool.Count; i++)
|
||||||
|
{
|
||||||
|
var (affixId, tier) = SupportAffixService.GenerateRandomAffix(spCard.AffixPool[i]);
|
||||||
|
if (affixId == 0) continue;
|
||||||
|
SupportAffixStateService.SetAffix(info, i + 1, affixId, tier);
|
||||||
|
}
|
||||||
|
|
||||||
InventoryData.SupportCards[info.UniqueId] = info;
|
InventoryData.SupportCards[info.UniqueId] = info;
|
||||||
|
|
||||||
if (sendPacket) await Player.SendPacket(new PacketNtfCallScript([info]));
|
if (sendPacket) await Player.SendPacket(new PacketNtfCallScript([info]));
|
||||||
@@ -171,7 +182,7 @@ public class InventoryManager(PlayerInstance player) : BasePlayerManager(player)
|
|||||||
{
|
{
|
||||||
TemplateId = templateId,
|
TemplateId = templateId,
|
||||||
UniqueId = InventoryData.NextUniqueUid++,
|
UniqueId = InventoryData.NextUniqueUid++,
|
||||||
ItemType = ItemTypeEnum.TYPE_MANIFESTATION,
|
ItemType = genre,
|
||||||
ItemCount = 1
|
ItemCount = 1
|
||||||
};
|
};
|
||||||
InventoryData.Items[manifestInfo.UniqueId] = manifestInfo;
|
InventoryData.Items[manifestInfo.UniqueId] = manifestInfo;
|
||||||
@@ -197,6 +208,27 @@ public class InventoryManager(PlayerInstance player) : BasePlayerManager(player)
|
|||||||
return InventoryData.Items.Values.FirstOrDefault(x => x.TemplateId == templateId);
|
return InventoryData.Items.Values.FirstOrDefault(x => x.TemplateId == templateId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async ValueTask<BaseGameItemInfo?> AddMonsterCardItem(uint detail, uint particular, uint level = 1, bool sendPacket = true)
|
||||||
|
{
|
||||||
|
const ItemTypeEnum genre = ItemTypeEnum.TYPE_MONSTER_CARD;
|
||||||
|
var templateId = GameResourceTemplateId.FromGdpl((uint)genre, detail, particular, level);
|
||||||
|
if (!GameData.MonsterCardData.ContainsKey(templateId))
|
||||||
|
return null;
|
||||||
|
|
||||||
|
var monsterInfo = new BaseGameItemInfo
|
||||||
|
{
|
||||||
|
TemplateId = templateId,
|
||||||
|
UniqueId = InventoryData.NextUniqueUid++,
|
||||||
|
ItemType = genre,
|
||||||
|
ItemCount = 1
|
||||||
|
};
|
||||||
|
InventoryData.Items[monsterInfo.UniqueId] = monsterInfo;
|
||||||
|
|
||||||
|
if (sendPacket) await Player.SendPacket(new PacketNtfCallScript([monsterInfo]));
|
||||||
|
|
||||||
|
return monsterInfo;
|
||||||
|
}
|
||||||
|
|
||||||
private static uint GetSuppliesMaxCount(SuppliesExcel suppliesData) =>
|
private static uint GetSuppliesMaxCount(SuppliesExcel suppliesData) =>
|
||||||
suppliesData.Genre == 5 && suppliesData.Detail == 4 ? 999999u : 99999u;
|
suppliesData.Genre == 5 && suppliesData.Detail == 4 ? 999999u : 99999u;
|
||||||
|
|
||||||
@@ -240,7 +272,7 @@ public class InventoryManager(PlayerInstance player) : BasePlayerManager(player)
|
|||||||
{
|
{
|
||||||
TemplateId = templateId,
|
TemplateId = templateId,
|
||||||
UniqueId = InventoryData.NextUniqueUid++,
|
UniqueId = InventoryData.NextUniqueUid++,
|
||||||
ItemType = ItemTypeEnum.TYPE_WEAPON_SKIN,
|
ItemType = genre,
|
||||||
ItemCount = 1
|
ItemCount = 1
|
||||||
};
|
};
|
||||||
InventoryData.Items[skinInfo.UniqueId] = skinInfo;
|
InventoryData.Items[skinInfo.UniqueId] = skinInfo;
|
||||||
@@ -249,4 +281,109 @@ public class InventoryManager(PlayerInstance player) : BasePlayerManager(player)
|
|||||||
|
|
||||||
return skinInfo;
|
return skinInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async ValueTask<BaseGameItemInfo?> AddProfileItem(ItemTypeEnum genre, uint detail, uint particular, uint level = 1, bool sendPacket = true)
|
||||||
|
{
|
||||||
|
if (genre < ItemTypeEnum.TYPE_PROFILE || genre > ItemTypeEnum.TYPE_ANALYST) return null;
|
||||||
|
var profileData = GameData.ProfileData.Values.FirstOrDefault(x => x.Genre == (int)genre && x.Detail == detail && x.Particular == particular && x.Level == level);
|
||||||
|
if (profileData == null) return null;
|
||||||
|
var templateId = GameResourceTemplateId.FromGdpl((uint)genre, detail, particular, level);
|
||||||
|
if (InventoryData.Items.Values.Any(x => x.TemplateId == templateId)) return null;
|
||||||
|
var profileInfo = new BaseGameItemInfo
|
||||||
|
{
|
||||||
|
TemplateId = templateId,
|
||||||
|
UniqueId = InventoryData.NextUniqueUid++,
|
||||||
|
ItemType = genre,
|
||||||
|
ItemCount = 1
|
||||||
|
};
|
||||||
|
InventoryData.Items[profileInfo.UniqueId] = profileInfo;
|
||||||
|
|
||||||
|
if (sendPacket) await Player.SendPacket(new PacketNtfCallScript([profileInfo]));
|
||||||
|
|
||||||
|
return profileInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async ValueTask<BaseGameItemInfo?> AddSkinPartItem(ItemTypeEnum genre, uint detail, uint particular, uint level = 1, bool sendPacket = true)
|
||||||
|
{
|
||||||
|
if (genre != ItemTypeEnum.TYPE_CARD_SKIN_PART) return null;
|
||||||
|
var skinPartData = GameData.CardSkinPartsData.Values.FirstOrDefault(x => x.Genre == (int)genre && x.Detail == detail && x.Particular == particular && x.Level == level);
|
||||||
|
if (skinPartData == null) return null;
|
||||||
|
var templateId = GameResourceTemplateId.FromGdpl((uint)genre, detail, particular, level);
|
||||||
|
if (InventoryData.Items.Values.Any(x => x.TemplateId == templateId)) return null;
|
||||||
|
var skinPartInfo = new BaseGameItemInfo
|
||||||
|
{
|
||||||
|
TemplateId = templateId,
|
||||||
|
UniqueId = InventoryData.NextUniqueUid++,
|
||||||
|
ItemType = genre,
|
||||||
|
ItemCount = 1
|
||||||
|
};
|
||||||
|
InventoryData.Items[skinPartInfo.UniqueId] = skinPartInfo;
|
||||||
|
|
||||||
|
if (sendPacket) await Player.SendPacket(new PacketNtfCallScript([skinPartInfo]));
|
||||||
|
|
||||||
|
return skinPartInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async ValueTask<BaseGameItemInfo?> AddCallItem(ItemTypeEnum genre, uint detail, uint particular, uint level = 1, bool sendPacket = true)
|
||||||
|
{
|
||||||
|
if (genre != ItemTypeEnum.TYPE_CALL) return null;
|
||||||
|
var callData = GameData.CallItemData.Values.FirstOrDefault(x => x.Genre == (int)genre && x.Detail == detail && x.Particular == particular && x.Level == level);
|
||||||
|
if (callData == null) return null;
|
||||||
|
var templateId = GameResourceTemplateId.FromGdpl((uint)genre, detail, particular, level);
|
||||||
|
if (InventoryData.Items.Values.Any(x => x.TemplateId == templateId)) return null;
|
||||||
|
var callInfo = new BaseGameItemInfo
|
||||||
|
{
|
||||||
|
TemplateId = templateId,
|
||||||
|
UniqueId = InventoryData.NextUniqueUid++,
|
||||||
|
ItemType = genre,
|
||||||
|
ItemCount = 1
|
||||||
|
};
|
||||||
|
InventoryData.Items[callInfo.UniqueId] = callInfo;
|
||||||
|
|
||||||
|
if (sendPacket) await Player.SendPacket(new PacketNtfCallScript([callInfo]));
|
||||||
|
|
||||||
|
return callInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async ValueTask<BaseGameItemInfo?> AddWeaponPartItem(ItemTypeEnum genre, uint detail, uint particular, uint level = 1, bool sendPacket = true)
|
||||||
|
{
|
||||||
|
if (genre != ItemTypeEnum.TYPE_WEAPON_PART) return null;
|
||||||
|
var weaponPartData = GameData.WeaponPartsData.Values.FirstOrDefault(x => x.Genre == (int)genre && x.Detail == detail && x.Particular == particular && x.Level == level);
|
||||||
|
if (weaponPartData == null) return null;
|
||||||
|
var templateId = GameResourceTemplateId.FromGdpl((uint)genre, detail, particular, level);
|
||||||
|
if (InventoryData.Items.Values.Any(x => x.TemplateId == templateId)) return null;
|
||||||
|
var weaponPartInfo = new BaseGameItemInfo
|
||||||
|
{
|
||||||
|
TemplateId = templateId,
|
||||||
|
UniqueId = InventoryData.NextUniqueUid++,
|
||||||
|
ItemType = genre,
|
||||||
|
ItemCount = 1
|
||||||
|
};
|
||||||
|
InventoryData.Items[weaponPartInfo.UniqueId] = weaponPartInfo;
|
||||||
|
|
||||||
|
if (sendPacket) await Player.SendPacket(new PacketNtfCallScript([weaponPartInfo]));
|
||||||
|
|
||||||
|
return weaponPartInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async ValueTask<BaseGameItemInfo?> AddHouseFurnitureItem(ItemTypeEnum genre, uint detail, uint particular, uint level = 1, bool sendPacket = true)
|
||||||
|
{
|
||||||
|
if (genre != ItemTypeEnum.TYPE_HOUSE) return null;
|
||||||
|
var houseFurnitureData = GameData.DormGiftData.Values.FirstOrDefault(x => x.Genre == (int)genre && x.Detail == detail && x.Particular == particular && x.Level == level);
|
||||||
|
if (houseFurnitureData == null) return null;
|
||||||
|
var templateId = GameResourceTemplateId.FromGdpl((uint)genre, detail, particular, level);
|
||||||
|
if (InventoryData.Items.Values.Any(x => x.TemplateId == templateId)) return null;
|
||||||
|
var furnitureInfo = new BaseGameItemInfo
|
||||||
|
{
|
||||||
|
TemplateId = templateId,
|
||||||
|
UniqueId = InventoryData.NextUniqueUid++,
|
||||||
|
ItemType = genre,
|
||||||
|
ItemCount = 1
|
||||||
|
};
|
||||||
|
InventoryData.Items[furnitureInfo.UniqueId] = furnitureInfo;
|
||||||
|
|
||||||
|
if (sendPacket) await Player.SendPacket(new PacketNtfCallScript([furnitureInfo]));
|
||||||
|
|
||||||
|
return furnitureInfo;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
27
GameServer/Game/Player/ChatMessageHelper.cs
Normal file
27
GameServer/Game/Player/ChatMessageHelper.cs
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
|
namespace MikuSB.GameServer.Game.Player;
|
||||||
|
|
||||||
|
public static partial class ChatMessageHelper
|
||||||
|
{
|
||||||
|
[GeneratedRegex(@"\s+")]
|
||||||
|
private static partial Regex MultiWhitespaceRegex();
|
||||||
|
|
||||||
|
public static uint BuildClientTimestamp()
|
||||||
|
{
|
||||||
|
return (uint)MikuSB.Util.Extensions.Extensions.GetUnixSec();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string NormalizeForClient(string? text)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(text))
|
||||||
|
return string.Empty;
|
||||||
|
|
||||||
|
var normalized = text
|
||||||
|
.Replace("\r\n", " ")
|
||||||
|
.Replace('\r', ' ')
|
||||||
|
.Replace('\n', ' ');
|
||||||
|
|
||||||
|
return MultiWhitespaceRegex().Replace(normalized, " ").Trim();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
using Google.Protobuf;
|
using Google.Protobuf;
|
||||||
using MikuSB.Data;
|
using MikuSB.Data;
|
||||||
using MikuSB.Database;
|
using MikuSB.Database;
|
||||||
using MikuSB.Database.Account;
|
using MikuSB.Database.Account;
|
||||||
@@ -160,9 +160,9 @@ public class PlayerInstance(PlayerGameData data)
|
|||||||
Sender = sendUid,
|
Sender = sendUid,
|
||||||
Recver = recvUid,
|
Recver = recvUid,
|
||||||
Emoji = emojiId ?? 0,
|
Emoji = emojiId ?? 0,
|
||||||
Text = message ?? "",
|
Text = ChatMessageHelper.NormalizeForClient(message),
|
||||||
Profile = Data.ToProfileProto(),
|
Profile = Data.ToProfileProto(),
|
||||||
TimeStamp = (uint)Extensions.GetUnixMs()
|
TimeStamp = ChatMessageHelper.BuildClientTimestamp()
|
||||||
};
|
};
|
||||||
|
|
||||||
await SendPacket(CmdIds.NtfFriendChat, data);
|
await SendPacket(CmdIds.NtfFriendChat, data);
|
||||||
@@ -196,7 +196,7 @@ public class PlayerInstance(PlayerGameData data)
|
|||||||
return proto;
|
return proto;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Proto.Player ToPlayerProto()
|
public Proto.Player ToPlayerProto(bool includeSupportCards = true)
|
||||||
{
|
{
|
||||||
BuildPlayerAttr();
|
BuildPlayerAttr();
|
||||||
var displayName = PlayerGameData.NormalizeDisplayName(Data.Name);
|
var displayName = PlayerGameData.NormalizeDisplayName(Data.Name);
|
||||||
@@ -205,14 +205,24 @@ public class PlayerInstance(PlayerGameData data)
|
|||||||
Pid = (ulong)Data.Uid,
|
Pid = (ulong)Data.Uid,
|
||||||
Account = displayName,
|
Account = displayName,
|
||||||
Provider = displayName,
|
Provider = displayName,
|
||||||
|
Channel = "gm",
|
||||||
|
Subchannel = "gm",
|
||||||
Name = displayName,
|
Name = displayName,
|
||||||
Level = Data.Level,
|
Level = Data.Level,
|
||||||
Sex = Data.Gender,
|
Sex = Data.Gender,
|
||||||
Vigor = Data.Vigor,
|
Vigor = Data.Vigor,
|
||||||
Solutions = { LineupManager.LineupData.LineupInfo.Values.Select(x => x.ToProto()) },
|
Solutions = { LineupManager.LineupData.LineupInfo.Values.Select(x => x.ToProto()) },
|
||||||
|
Badges = { InventoryManager.InventoryData.Items.Values.Where(x => x.ItemType == ItemTypeEnum.TYPE_BADGE).Select(x => (ulong)x.UniqueId) }
|
||||||
};
|
};
|
||||||
|
|
||||||
foreach (var chara in CharacterManager.CharacterData.Characters) proto.Items.Add(chara.ToProto());
|
foreach (var chara in CharacterManager.CharacterData.Characters) proto.Items.Add(chara.ToProto());
|
||||||
|
foreach (var item in InventoryManager.InventoryData.Items.Values) proto.Items.Add(item.ToProto());
|
||||||
|
foreach (var skin in InventoryManager.InventoryData.Skins.Values) proto.Items.Add(skin.ToProto());
|
||||||
|
foreach (var weapon in InventoryManager.InventoryData.Weapons.Values) proto.Items.Add(weapon.ToProto());
|
||||||
|
if (includeSupportCards)
|
||||||
|
{
|
||||||
|
foreach (var card in InventoryManager.InventoryData.SupportCards.Values) proto.Items.Add(card.ToProto());
|
||||||
|
}
|
||||||
foreach (var x in Data.Attrs)
|
foreach (var x in Data.Attrs)
|
||||||
{
|
{
|
||||||
uint gid = x.Gid;
|
uint gid = x.Gid;
|
||||||
@@ -229,6 +239,16 @@ public class PlayerInstance(PlayerGameData data)
|
|||||||
proto.Attrs[ToShiftedAttrKey(gid, sid)] = val;
|
proto.Attrs[ToShiftedAttrKey(gid, sid)] = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach (var x in Data.StrAttrs)
|
||||||
|
{
|
||||||
|
proto.StrAttrs[ToShiftedAttrKey(x.Gid, x.Sid)] = x.Val;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var (key, value) in BuildMoneySync())
|
||||||
|
{
|
||||||
|
proto.Money[key] = value;
|
||||||
|
}
|
||||||
|
|
||||||
proto.ShowItems.AddRange(Data.ShowItems);
|
proto.ShowItems.AddRange(Data.ShowItems);
|
||||||
|
|
||||||
return proto;
|
return proto;
|
||||||
@@ -250,6 +270,22 @@ public class PlayerInstance(PlayerGameData data)
|
|||||||
Data.ShowItems[index - 1] = itemId;
|
Data.ShowItems[index - 1] = itemId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetStrAttr(uint gid, uint sid, string value)
|
||||||
|
{
|
||||||
|
var attr = Data.StrAttrs.FirstOrDefault(x => x.Gid == gid && x.Sid == sid);
|
||||||
|
if (attr == null)
|
||||||
|
{
|
||||||
|
attr = new PlayerStrAttr
|
||||||
|
{
|
||||||
|
Gid = gid,
|
||||||
|
Sid = sid
|
||||||
|
};
|
||||||
|
Data.StrAttrs.Add(attr);
|
||||||
|
}
|
||||||
|
|
||||||
|
attr.Val = value;
|
||||||
|
}
|
||||||
|
|
||||||
public uint ToPackedAttrKey(uint gid, uint sid)
|
public uint ToPackedAttrKey(uint gid, uint sid)
|
||||||
{
|
{
|
||||||
if (gid == 0)
|
if (gid == 0)
|
||||||
@@ -266,9 +302,28 @@ public class PlayerInstance(PlayerGameData data)
|
|||||||
return (gid << 16) | sid;
|
return (gid << 16) | sid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void BuildPlayerAttr()
|
public Dictionary<string, int> BuildMoneySync()
|
||||||
{
|
{
|
||||||
var bootstrapAttrs = BuildLobbyBootstrapAttrs();
|
var currentMoney = (int)Math.Min(int.MaxValue, GetAttrValue(1, 3));
|
||||||
|
var sync = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase)
|
||||||
|
{
|
||||||
|
["."] = currentMoney,
|
||||||
|
["gm.gm"] = currentMoney,
|
||||||
|
["jinshan.jinshan"] = currentMoney,
|
||||||
|
["pc_jinshan.pc_jinshan"] = currentMoney
|
||||||
|
};
|
||||||
|
return sync;
|
||||||
|
}
|
||||||
|
|
||||||
|
private uint GetAttrValue(uint gid, uint sid)
|
||||||
|
{
|
||||||
|
return Data.Attrs.FirstOrDefault(x => x.Gid == gid && x.Sid == sid)?.Val ?? 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void BuildPlayerAttr(bool additional = false)
|
||||||
|
{
|
||||||
|
var bootstrapAttrs = BuildLobbyBootstrapAttrs().ToList();
|
||||||
|
if (additional) bootstrapAttrs.AddRange(BuildGirlFurnitureAttrs());
|
||||||
var existingAttrs = Data.Attrs
|
var existingAttrs = Data.Attrs
|
||||||
.ToDictionary(x => (x.Gid, x.Sid));
|
.ToDictionary(x => (x.Gid, x.Sid));
|
||||||
var seenAttrs = new HashSet<(uint Gid, uint Sid)>();
|
var seenAttrs = new HashSet<(uint Gid, uint Sid)>();
|
||||||
@@ -298,6 +353,53 @@ public class PlayerInstance(PlayerGameData data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static IEnumerable<(uint Gid, uint Sid, uint Value)> BuildGirlFurnitureAttrs()
|
||||||
|
{
|
||||||
|
const uint furnitureUnlockedValue = 153391689;
|
||||||
|
var groupFurnitureByArea = new Dictionary<uint, uint>();
|
||||||
|
foreach (var pos in GameData.HouseFurniturePosData.Values)
|
||||||
|
{
|
||||||
|
var areaId = pos.AreaId;
|
||||||
|
var groupId = pos.GroupId;
|
||||||
|
uint selectedIndex = 1;
|
||||||
|
var shift = (groupId - 1) * 3;
|
||||||
|
if (!groupFurnitureByArea.TryGetValue(areaId, out var packed)) packed = 0;
|
||||||
|
packed |= (selectedIndex << (int)shift);
|
||||||
|
groupFurnitureByArea[areaId] = packed;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (uint girlId = 0; girlId <= 50; girlId++)
|
||||||
|
{
|
||||||
|
var baseSid = girlId * 50;
|
||||||
|
for (uint offset = 10; offset <= 19; offset++)
|
||||||
|
yield return (101, baseSid + offset, furnitureUnlockedValue);
|
||||||
|
|
||||||
|
if (groupFurnitureByArea.TryGetValue(girlId, out var groupValue))
|
||||||
|
yield return (101, baseSid + 20, groupValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Massage room furniture
|
||||||
|
// 10010..10019
|
||||||
|
for (uint sid = 10010; sid <= 10019; sid++)
|
||||||
|
yield return (101, sid, furnitureUnlockedValue);
|
||||||
|
|
||||||
|
// Massage room group state
|
||||||
|
yield return (101, 10020, 1);
|
||||||
|
|
||||||
|
// Hot spring furniture
|
||||||
|
// 15001..15010
|
||||||
|
for (uint sid = 15001; sid <= 15010; sid++)
|
||||||
|
yield return (101, sid, furnitureUnlockedValue);
|
||||||
|
|
||||||
|
// Beach furniture
|
||||||
|
// 17101..17110
|
||||||
|
for (uint sid = 17101; sid <= 17110; sid++)
|
||||||
|
yield return (101, sid, furnitureUnlockedValue);
|
||||||
|
|
||||||
|
for (uint sid = 30000; sid < 31000; sid++)
|
||||||
|
yield return (101, sid, furnitureUnlockedValue);
|
||||||
|
}
|
||||||
|
|
||||||
private static IEnumerable<(uint Gid, uint Sid, uint Value)> BuildLobbyBootstrapAttrs()
|
private static IEnumerable<(uint Gid, uint Sid, uint Value)> BuildLobbyBootstrapAttrs()
|
||||||
{
|
{
|
||||||
// GuideLogic uses group 4. Value 999 is safely above every configured step count,
|
// GuideLogic uses group 4. Value 999 is safely above every configured step count,
|
||||||
@@ -348,6 +450,22 @@ public class PlayerInstance(PlayerGameData data)
|
|||||||
yield return (22, levelId, 1_700_000_000);
|
yield return (22, levelId, 1_700_000_000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Role fragment chapters use Condition.PRE_LEVEL against Launch.GPASSID as well.
|
||||||
|
// Mark every role level as cleared so character-specific stages beyond the first one unlock.
|
||||||
|
foreach (var levelId in GameData.RoleLevelData.Keys)
|
||||||
|
{
|
||||||
|
yield return (21, levelId, 7);
|
||||||
|
yield return (22, levelId, 1_700_000_000);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var guide in GameData.GuideData.Values)
|
||||||
|
{
|
||||||
|
yield return (4, guide.ID, 999);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (uint favor = 0; favor <= 50; favor++)
|
||||||
|
yield return (101, favor * 50, 500);
|
||||||
|
|
||||||
// Main Scene 0 mean default scene
|
// Main Scene 0 mean default scene
|
||||||
yield return (132, 1, 0);
|
yield return (132, 1, 0);
|
||||||
}
|
}
|
||||||
|
|||||||
50
GameServer/Game/Support/SupportAffixService.cs
Normal file
50
GameServer/Game/Support/SupportAffixService.cs
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
using MikuSB.Data;
|
||||||
|
|
||||||
|
namespace MikuSB.GameServer.Game.Support;
|
||||||
|
|
||||||
|
public static class SupportAffixService
|
||||||
|
{
|
||||||
|
public static (uint AffixId, uint Tier) GenerateRandomAffix(int poolId, IEnumerable<uint>? excludedAffixIds = null)
|
||||||
|
{
|
||||||
|
if (!GameData.SupportAffixPoolData.TryGetValue(poolId, out var pool))
|
||||||
|
return (0, 0);
|
||||||
|
|
||||||
|
var groups = pool.Groups.ToList();
|
||||||
|
if (groups.Count == 0)
|
||||||
|
return (0, 0);
|
||||||
|
|
||||||
|
var totalWeight = groups.Sum(x => x.Weight);
|
||||||
|
var roll = Random.Shared.Next(totalWeight);
|
||||||
|
var cumulative = 0;
|
||||||
|
var selectedAffixs = groups[0].Affixs;
|
||||||
|
|
||||||
|
foreach (var (affixIds, weight) in groups)
|
||||||
|
{
|
||||||
|
cumulative += weight;
|
||||||
|
if (roll < cumulative)
|
||||||
|
{
|
||||||
|
selectedAffixs = affixIds;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (selectedAffixs.Count == 0)
|
||||||
|
return (0, 0);
|
||||||
|
|
||||||
|
var excluded = excludedAffixIds?.ToHashSet() ?? [];
|
||||||
|
var candidates = selectedAffixs.Where(x => !excluded.Contains((uint)x)).ToList();
|
||||||
|
if (candidates.Count == 0)
|
||||||
|
candidates = selectedAffixs.ToList();
|
||||||
|
|
||||||
|
var affixId = candidates[Random.Shared.Next(candidates.Count)];
|
||||||
|
var tierCount = GameData.SupportAffixData.GetValueOrDefault(affixId)?.TierCount ?? 5;
|
||||||
|
var tier = (uint)(Random.Shared.Next(tierCount) + 1);
|
||||||
|
return ((uint)affixId, tier);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static uint GenerateTier(uint affixId)
|
||||||
|
{
|
||||||
|
var tierCount = GameData.SupportAffixData.GetValueOrDefault((int)affixId)?.TierCount ?? 5;
|
||||||
|
return (uint)(Random.Shared.Next(tierCount) + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
70
GameServer/Game/Support/SupportAffixStateService.cs
Normal file
70
GameServer/Game/Support/SupportAffixStateService.cs
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
using MikuSB.Database.Inventory;
|
||||||
|
|
||||||
|
namespace MikuSB.GameServer.Game.Support;
|
||||||
|
|
||||||
|
public static class SupportAffixStateService
|
||||||
|
{
|
||||||
|
public const int PairSize = 2;
|
||||||
|
public const int MaxLogicalSlots = 5;
|
||||||
|
public const int ActiveThirdAffixSlot = 3;
|
||||||
|
public const int PendingMaxAffixSlot = 4;
|
||||||
|
public const int PendingInitialAffixSlot = 5;
|
||||||
|
|
||||||
|
public static void EnsureCapacity(GameSupportCardInfo card, int logicalSlot = MaxLogicalSlots)
|
||||||
|
{
|
||||||
|
var minCount = Math.Clamp(logicalSlot, 1, MaxLogicalSlots) * PairSize;
|
||||||
|
while (card.Affixs.Count < minCount)
|
||||||
|
card.Affixs.Add(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static (uint AffixId, uint Tier) GetAffix(GameSupportCardInfo card, int logicalSlot)
|
||||||
|
{
|
||||||
|
if (logicalSlot < 1 || logicalSlot > MaxLogicalSlots)
|
||||||
|
return (0, 0);
|
||||||
|
|
||||||
|
var index = (logicalSlot - 1) * PairSize;
|
||||||
|
if (card.Affixs.Count <= index + 1)
|
||||||
|
return (0, 0);
|
||||||
|
|
||||||
|
return (card.Affixs[index], card.Affixs[index + 1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool HasAffix(GameSupportCardInfo card, int logicalSlot)
|
||||||
|
{
|
||||||
|
var (affixId, tier) = GetAffix(card, logicalSlot);
|
||||||
|
return affixId > 0 && tier > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void SetAffix(GameSupportCardInfo card, int logicalSlot, uint affixId, uint tier)
|
||||||
|
{
|
||||||
|
if (logicalSlot < 1 || logicalSlot > MaxLogicalSlots)
|
||||||
|
return;
|
||||||
|
|
||||||
|
EnsureCapacity(card, logicalSlot);
|
||||||
|
var index = (logicalSlot - 1) * PairSize;
|
||||||
|
card.Affixs[index] = affixId;
|
||||||
|
card.Affixs[index + 1] = tier;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void ClearAffix(GameSupportCardInfo card, int logicalSlot)
|
||||||
|
{
|
||||||
|
SetAffix(card, logicalSlot, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void CopyAffix(GameSupportCardInfo card, int fromSlot, int toSlot)
|
||||||
|
{
|
||||||
|
var (affixId, tier) = GetAffix(card, fromSlot);
|
||||||
|
SetAffix(card, toSlot, affixId, tier);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static uint GetVisibleInitialAffixIndex(GameSupportCardInfo card)
|
||||||
|
{
|
||||||
|
return HasAffix(card, PendingInitialAffixSlot) ? card.AffixId : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void NormalizePendingState(GameSupportCardInfo card)
|
||||||
|
{
|
||||||
|
if (!HasAffix(card, PendingInitialAffixSlot))
|
||||||
|
card.AffixId = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Library</OutputType>
|
<OutputType>Library</OutputType>
|
||||||
<TargetFramework>net9.0</TargetFramework>
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<CETCompat>false</CETCompat>
|
<CETCompat>false</CETCompat>
|
||||||
@@ -20,9 +20,9 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Common\Common.csproj" />
|
<ProjectReference Include="..\Common\Common.csproj" />
|
||||||
|
<ProjectReference Include="..\MikuSB.Loader\MikuSB.Loader.csproj" />
|
||||||
<ProjectReference Include="..\TcpSharp\TcpSharp.csproj" />
|
<ProjectReference Include="..\TcpSharp\TcpSharp.csproj" />
|
||||||
<ProjectReference Include="..\Proto\Proto.csproj" />
|
<ProjectReference Include="..\Proto\Proto.csproj" />
|
||||||
<PackageReference Include="System.IO.Pipelines" Version="9.0.0" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ public static class CallGSRouter
|
|||||||
{
|
{
|
||||||
private static readonly Logger Logger = new("CallGS");
|
private static readonly Logger Logger = new("CallGS");
|
||||||
private static readonly Dictionary<string, ICallGSHandler> Handlers = [];
|
private static readonly Dictionary<string, ICallGSHandler> Handlers = [];
|
||||||
|
private const string UnavailableTipKey = "ui.TxtNotOpen";
|
||||||
|
|
||||||
public static void Init()
|
public static void Init()
|
||||||
{
|
{
|
||||||
@@ -32,11 +33,13 @@ public static class CallGSRouter
|
|||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Logger.Error($"[{req.Api}] {e.Message}", e);
|
Logger.Error($"[{req.Api}] {e.Message}", e);
|
||||||
|
await SendUnavailableResponse(connection, req.Api);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger.Error($"No handler for CallGS API: {req.Api}");
|
Logger.Error($"No handler for CallGS API: {req.Api}");
|
||||||
|
await SendUnavailableResponse(connection, req.Api);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task SendScript(Connection connection, string api, string arg, NtfSyncPlayer extra = null!)
|
public static async Task SendScript(Connection connection, string api, string arg, NtfSyncPlayer extra = null!)
|
||||||
@@ -44,4 +47,11 @@ public static class CallGSRouter
|
|||||||
var rsp = new NtfCallScript { Api = api, Arg = arg, ExtraSync = extra };
|
var rsp = new NtfCallScript { Api = api, Arg = arg, ExtraSync = extra };
|
||||||
await connection.SendPacket(CmdIds.NtfScript, rsp);
|
await connection.SendPacket(CmdIds.NtfScript, rsp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Task SendUnavailableResponse(Connection connection, string api)
|
||||||
|
{
|
||||||
|
// Many client Lua handlers treat sErr/sError as a recoverable failure path,
|
||||||
|
// which is preferable to leaving the request hanging forever.
|
||||||
|
return SendScript(connection, api, $$"""{"sErr":"{{UnavailableTipKey}}","sError":"{{UnavailableTipKey}}"}""");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,113 @@
|
|||||||
|
using MikuSB.Data;
|
||||||
|
using MikuSB.Data.Excel;
|
||||||
|
using MikuSB.Database.Player;
|
||||||
|
using MikuSB.GameServer.Game.Player;
|
||||||
|
using MikuSB.Proto;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.Text.Json.Nodes;
|
||||||
|
|
||||||
|
namespace MikuSB.GameServer.Server.CallGS.Handlers.BattlePass;
|
||||||
|
|
||||||
|
[CallGSApi("BattlePassLogic_ClientRefresh")]
|
||||||
|
public class BattlePassLogic_ClientRefresh : ICallGSHandler
|
||||||
|
{
|
||||||
|
private const uint GroupId = 25;
|
||||||
|
private const uint CurIdSid = 1;
|
||||||
|
|
||||||
|
public async Task Handle(Connection connection, string param, ushort seqNo)
|
||||||
|
{
|
||||||
|
var now = DateTime.Now;
|
||||||
|
var battlePass = ResolveCurrent(GameData.BattlePassTimeData.Values, now);
|
||||||
|
var player = connection.Player!;
|
||||||
|
var sync = new NtfSyncPlayer();
|
||||||
|
|
||||||
|
if (battlePass == null)
|
||||||
|
{
|
||||||
|
SetAttr(player, CurIdSid, 0, sync);
|
||||||
|
await CallGSRouter.SendScript(connection, "BattlePassLogic_ClientRefresh", "{}", sync);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SetAttr(player, CurIdSid, battlePass.Id, sync);
|
||||||
|
|
||||||
|
var response = new JsonObject
|
||||||
|
{
|
||||||
|
["nId"] = battlePass.Id,
|
||||||
|
["nStartTime"] = ToUnixSeconds(ParseConfigTime(battlePass.StartTime)),
|
||||||
|
["nEndTime"] = ToUnixSeconds(ParseConfigTime(battlePass.EndTime))
|
||||||
|
};
|
||||||
|
|
||||||
|
await CallGSRouter.SendScript(connection, "BattlePassLogic_ClientRefresh", response.ToJsonString(), sync);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static BattlePassTimeExcel? ResolveCurrent(IEnumerable<BattlePassTimeExcel> configs, DateTime now)
|
||||||
|
{
|
||||||
|
var parsed = configs
|
||||||
|
.Select(x => new
|
||||||
|
{
|
||||||
|
Config = x,
|
||||||
|
Start = ParseConfigTime(x.StartTime),
|
||||||
|
End = ParseConfigTime(x.EndTime)
|
||||||
|
})
|
||||||
|
.Where(x => x.Start.HasValue && x.End.HasValue)
|
||||||
|
.OrderBy(x => x.Start)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
var current = parsed.FirstOrDefault(x => x.Start <= now && now < x.End);
|
||||||
|
if (current != null)
|
||||||
|
return current.Config;
|
||||||
|
|
||||||
|
var latestStarted = parsed.LastOrDefault(x => x.Start <= now && x.End > x.Start);
|
||||||
|
return latestStarted?.Config;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static DateTime? ParseConfigTime(string? raw)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(raw))
|
||||||
|
return null;
|
||||||
|
|
||||||
|
var normalized = raw.Trim().Trim('[', ']');
|
||||||
|
if (normalized.Length != 12)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return DateTime.TryParseExact(
|
||||||
|
normalized,
|
||||||
|
"yyyyMMddHHmm",
|
||||||
|
CultureInfo.InvariantCulture,
|
||||||
|
DateTimeStyles.None,
|
||||||
|
out var value)
|
||||||
|
? value
|
||||||
|
: null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static long ToUnixSeconds(DateTime? value)
|
||||||
|
{
|
||||||
|
return value.HasValue ? new DateTimeOffset(value.Value).ToUnixTimeSeconds() : 0L;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void SetAttr(PlayerInstance player, uint sid, uint value, NtfSyncPlayer sync)
|
||||||
|
{
|
||||||
|
var attr = GetOrCreateAttr(player, sid);
|
||||||
|
if (attr.Val != value)
|
||||||
|
{
|
||||||
|
attr.Val = value;
|
||||||
|
sync.Custom[player.ToPackedAttrKey(GroupId, sid)] = value;
|
||||||
|
sync.Custom[player.ToShiftedAttrKey(GroupId, sid)] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static PlayerAttr GetOrCreateAttr(PlayerInstance player, uint sid)
|
||||||
|
{
|
||||||
|
var attr = player.Data.Attrs.FirstOrDefault(x => x.Gid == GroupId && x.Sid == sid);
|
||||||
|
if (attr != null)
|
||||||
|
return attr;
|
||||||
|
|
||||||
|
attr = new PlayerAttr
|
||||||
|
{
|
||||||
|
Gid = GroupId,
|
||||||
|
Sid = sid
|
||||||
|
};
|
||||||
|
player.Data.Attrs.Add(attr);
|
||||||
|
return attr;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
using MikuSB.GameServer.Game.BossPvp;
|
||||||
|
|
||||||
|
namespace MikuSB.GameServer.Server.CallGS.Handlers.BossPvp;
|
||||||
|
|
||||||
|
[CallGSApi("BossPvpLogic_EnterLevel")]
|
||||||
|
public class BossPvpLogic_EnterLevel : ICallGSHandler
|
||||||
|
{
|
||||||
|
public async Task Handle(Connection connection, string param, ushort seqNo)
|
||||||
|
{
|
||||||
|
var response = BossPvpService.HandleEnterLevel(param);
|
||||||
|
await CallGSRouter.SendScript(connection, "BossPvpLogic_EnterLevel", System.Text.Json.JsonSerializer.Serialize(response));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
using MikuSB.GameServer.Game.BossPvp;
|
||||||
|
|
||||||
|
namespace MikuSB.GameServer.Server.CallGS.Handlers.BossPvp;
|
||||||
|
|
||||||
|
[CallGSApi("BossPvpLogic_GetOpenID")]
|
||||||
|
public class BossPvpLogic_GetOpenID : ICallGSHandler
|
||||||
|
{
|
||||||
|
public async Task Handle(Connection connection, string param, ushort seqNo)
|
||||||
|
{
|
||||||
|
var (response, sync) = await BossPvpService.HandleGetOpenIdAsync(connection.Player!);
|
||||||
|
await CallGSRouter.SendScript(connection, "BossPvpLogic_GetOpenID", System.Text.Json.JsonSerializer.Serialize(response), sync);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
using MikuSB.GameServer.Game.BossPvp;
|
||||||
|
|
||||||
|
namespace MikuSB.GameServer.Server.CallGS.Handlers.BossPvp;
|
||||||
|
|
||||||
|
[CallGSApi("BossPvpLogic_GetReward")]
|
||||||
|
public class BossPvpLogic_GetReward : ICallGSHandler
|
||||||
|
{
|
||||||
|
public async Task Handle(Connection connection, string param, ushort seqNo)
|
||||||
|
{
|
||||||
|
var response = BossPvpService.HandleGetReward(param);
|
||||||
|
await CallGSRouter.SendScript(connection, "BossPvpLogic_GetReward", System.Text.Json.JsonSerializer.Serialize(response));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
using MikuSB.GameServer.Game.BossPvp;
|
||||||
|
|
||||||
|
namespace MikuSB.GameServer.Server.CallGS.Handlers.BossPvp;
|
||||||
|
|
||||||
|
[CallGSApi("BossPvpLogic_LevelFail")]
|
||||||
|
public class BossPvpLogic_LevelFail : ICallGSHandler
|
||||||
|
{
|
||||||
|
public async Task Handle(Connection connection, string param, ushort seqNo)
|
||||||
|
{
|
||||||
|
var node = System.Text.Json.Nodes.JsonNode.Parse(param);
|
||||||
|
var (response, sync) = BossPvpService.HandleFail(connection.Player!, node);
|
||||||
|
await CallGSRouter.SendScript(connection, "BossPvpLogic_LevelFail", response.ToJsonString(), sync);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
using MikuSB.GameServer.Game.BossPvp;
|
||||||
|
|
||||||
|
namespace MikuSB.GameServer.Server.CallGS.Handlers.BossPvp;
|
||||||
|
|
||||||
|
[CallGSApi("BossPvpLogic_LevelMopup")]
|
||||||
|
public class BossPvpLogic_LevelMopup : ICallGSHandler
|
||||||
|
{
|
||||||
|
public async Task Handle(Connection connection, string param, ushort seqNo)
|
||||||
|
{
|
||||||
|
var (response, sync) = BossPvpService.HandleMopup(connection.Player!, param);
|
||||||
|
await CallGSRouter.SendScript(connection, "BossPvpLogic_LevelMopup", System.Text.Json.JsonSerializer.Serialize(response), sync);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
using MikuSB.GameServer.Game.BossPvp;
|
||||||
|
|
||||||
|
namespace MikuSB.GameServer.Server.CallGS.Handlers.BossPvp;
|
||||||
|
|
||||||
|
[CallGSApi("BossPvpLogic_LevelSettlement")]
|
||||||
|
public class BossPvpLogic_LevelSettlement : ICallGSHandler
|
||||||
|
{
|
||||||
|
public async Task Handle(Connection connection, string param, ushort seqNo)
|
||||||
|
{
|
||||||
|
var node = System.Text.Json.Nodes.JsonNode.Parse(param);
|
||||||
|
var (response, sync) = BossPvpService.HandleSettlement(connection.Player!, node);
|
||||||
|
await CallGSRouter.SendScript(connection, "BossPvpLogic_LevelSettlement", response.ToJsonString(), sync);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
using MikuSB.GameServer.Game.BossPvp;
|
||||||
|
|
||||||
|
namespace MikuSB.GameServer.Server.CallGS.Handlers.BossPvp;
|
||||||
|
|
||||||
|
[CallGSApi("BossPvpLogic_Record")]
|
||||||
|
public class BossPvpLogic_Record : ICallGSHandler
|
||||||
|
{
|
||||||
|
public async Task Handle(Connection connection, string param, ushort seqNo)
|
||||||
|
{
|
||||||
|
var (response, sync) = BossPvpService.HandleRecord(connection.Player!, param);
|
||||||
|
await CallGSRouter.SendScript(connection, "BossPvpLogic_Record", System.Text.Json.JsonSerializer.Serialize(response), sync);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,11 @@
|
|||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Text.Json.Nodes;
|
using System.Text.Json.Nodes;
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
|
using MikuSB.GameServer.Game.BossPvp;
|
||||||
|
using MikuSB.Proto;
|
||||||
|
using MikuSB.GameServer.Server.CallGS.Handlers.DreamCard;
|
||||||
|
using MikuSB.GameServer.Server.CallGS.Handlers.Tower;
|
||||||
|
using MikuSB.GameServer.Server.CallGS.Handlers.VirCapture;
|
||||||
|
|
||||||
namespace MikuSB.GameServer.Server.CallGS.Handlers.Chapter;
|
namespace MikuSB.GameServer.Server.CallGS.Handlers.Chapter;
|
||||||
|
|
||||||
@@ -10,17 +15,20 @@ public class Chapter_DealLevelSettlement : ICallGSHandler
|
|||||||
public async Task Handle(Connection connection, string param, ushort seqNo)
|
public async Task Handle(Connection connection, string param, ushort seqNo)
|
||||||
{
|
{
|
||||||
var req = JsonSerializer.Deserialize<DealLevelSettlementParam>(param);
|
var req = JsonSerializer.Deserialize<DealLevelSettlementParam>(param);
|
||||||
|
NtfSyncPlayer? extraSync = null;
|
||||||
var response = new JsonObject
|
var response = new JsonObject
|
||||||
{
|
{
|
||||||
["sCmd"] = req?.SCmd ?? "Chapter_LevelSettlement",
|
["sCmd"] = req?.SCmd ?? "Chapter_LevelSettlement",
|
||||||
["tbParam"] = BuildSettlementPayload(req?.SCmd, req?.TbParam)
|
["tbParam"] = BuildSettlementPayload(connection, req?.SCmd, req?.TbParam, out extraSync)
|
||||||
};
|
};
|
||||||
|
|
||||||
await CallGSRouter.SendScript(connection, "Chapter_DealLevelSettlement", response.ToJsonString());
|
await CallGSRouter.SendScript(connection, "Chapter_DealLevelSettlement", response.ToJsonString(), extraSync!);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static JsonNode BuildSettlementPayload(string? sCmd, JsonNode? tbParam)
|
private static JsonNode BuildSettlementPayload(Connection connection, string? sCmd, JsonNode? tbParam, out NtfSyncPlayer? extraSync)
|
||||||
{
|
{
|
||||||
|
extraSync = null;
|
||||||
|
|
||||||
if (string.Equals(sCmd, "Chapter_LevelSettlement", StringComparison.Ordinal))
|
if (string.Equals(sCmd, "Chapter_LevelSettlement", StringComparison.Ordinal))
|
||||||
{
|
{
|
||||||
return new JsonArray();
|
return new JsonArray();
|
||||||
@@ -37,8 +45,67 @@ public class Chapter_DealLevelSettlement : ICallGSHandler
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (string.Equals(sCmd, "BossPvpLogic_LevelSettlement", StringComparison.Ordinal))
|
||||||
|
{
|
||||||
|
var normalized = NormalizeBossPvpSettlement(tbParam);
|
||||||
|
var (response, sync) = BossPvpService.HandleSettlement(connection.Player!, normalized);
|
||||||
|
extraSync = sync;
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.Equals(sCmd, "BossPvpLogic_LevelFail", StringComparison.Ordinal))
|
||||||
|
{
|
||||||
|
var (response, sync) = BossPvpService.HandleFail(connection.Player!, tbParam);
|
||||||
|
extraSync = sync;
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.Equals(sCmd, "TowerLevel_LevelSettlement", StringComparison.Ordinal))
|
||||||
|
{
|
||||||
|
var (response, sync) = TowerLevel_LevelSettlement.HandleSettlement(connection.Player!, tbParam);
|
||||||
|
extraSync = sync;
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.Equals(sCmd, "TowerEventChapter_LevelSettlement", StringComparison.Ordinal))
|
||||||
|
{
|
||||||
|
var (response, sync) = TowerEventChapter_LevelSettlement.HandleSettlement(connection.Player!, tbParam);
|
||||||
|
extraSync = sync;
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.Equals(sCmd, "VirCaptureTower_LevelSettlement", StringComparison.Ordinal))
|
||||||
|
{
|
||||||
|
var (response, sync) = VirCaptureTower_LevelSettlement.HandleSettlement(connection.Player!, tbParam);
|
||||||
|
extraSync = sync;
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.Equals(sCmd, "DreamCard_LevelSettlement", StringComparison.Ordinal))
|
||||||
|
{
|
||||||
|
var (response, sync) = DreamCard_LevelSettlement.HandleSettlement(connection.Player!, tbParam);
|
||||||
|
extraSync = sync;
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
return tbParam?.DeepClone() ?? new JsonObject();
|
return tbParam?.DeepClone() ?? new JsonObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static JsonNode? NormalizeBossPvpSettlement(JsonNode? tbParam)
|
||||||
|
{
|
||||||
|
if (tbParam is not JsonObject obj)
|
||||||
|
return tbParam;
|
||||||
|
|
||||||
|
var clone = obj.DeepClone() as JsonObject ?? obj;
|
||||||
|
if (clone.TryGetPropertyValue("ResidueTime", out var residueNode) &&
|
||||||
|
residueNode is JsonValue residueValue &&
|
||||||
|
residueValue.TryGetValue<double>(out var residueTime))
|
||||||
|
{
|
||||||
|
clone["ResidueTime"] = (int)Math.Max(0, Math.Round(residueTime, MidpointRounding.AwayFromZero));
|
||||||
|
}
|
||||||
|
|
||||||
|
return clone;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal sealed class DealLevelSettlementParam
|
internal sealed class DealLevelSettlementParam
|
||||||
|
|||||||
112
GameServer/Server/CallGS/Handlers/DLC/DLCLogic_CheckOpenAct.cs
Normal file
112
GameServer/Server/CallGS/Handlers/DLC/DLCLogic_CheckOpenAct.cs
Normal file
@@ -0,0 +1,112 @@
|
|||||||
|
using MikuSB.Data;
|
||||||
|
using MikuSB.Data.Excel;
|
||||||
|
using MikuSB.Database.Player;
|
||||||
|
using MikuSB.GameServer.Game.Player;
|
||||||
|
using MikuSB.Proto;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.Text.Json.Nodes;
|
||||||
|
|
||||||
|
namespace MikuSB.GameServer.Server.CallGS.Handlers.DLC;
|
||||||
|
|
||||||
|
[CallGSApi("DLCLogic_CheckOpenAct")]
|
||||||
|
public class DLCLogic_CheckOpenAct : ICallGSHandler
|
||||||
|
{
|
||||||
|
private const uint GroupId = 15;
|
||||||
|
private const uint ActIdSid = 1;
|
||||||
|
|
||||||
|
public async Task Handle(Connection connection, string param, ushort seqNo)
|
||||||
|
{
|
||||||
|
var now = DateTime.Now;
|
||||||
|
var act = ResolveCurrent(GameData.DlcActivityData.Values, now);
|
||||||
|
if (act == null)
|
||||||
|
{
|
||||||
|
await CallGSRouter.SendScript(connection, "DLCLogic_CheckOpenAct", "{\"bOpen\":false}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var player = connection.Player!;
|
||||||
|
var sync = new NtfSyncPlayer();
|
||||||
|
SetAttr(player, ActIdSid, act.Id, sync);
|
||||||
|
|
||||||
|
var response = new JsonObject
|
||||||
|
{
|
||||||
|
["bOpen"] = true,
|
||||||
|
["nId"] = act.Id,
|
||||||
|
["nStartTime"] = ToUnixSeconds(ParseConfigTime(act.EnterStartTime)),
|
||||||
|
["nEndTime"] = ToUnixSeconds(ParseConfigTime(act.CloseEndTime))
|
||||||
|
};
|
||||||
|
|
||||||
|
await CallGSRouter.SendScript(connection, "DLCLogic_CheckOpenAct", response.ToJsonString(), sync);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static DlcActivityExcel? ResolveCurrent(IEnumerable<DlcActivityExcel> configs, DateTime now)
|
||||||
|
{
|
||||||
|
var parsed = configs
|
||||||
|
.Select(x => new
|
||||||
|
{
|
||||||
|
Config = x,
|
||||||
|
Start = ParseConfigTime(x.EnterStartTime),
|
||||||
|
End = ParseConfigTime(x.CloseEndTime)
|
||||||
|
})
|
||||||
|
.Where(x => x.Start.HasValue && x.End.HasValue)
|
||||||
|
.OrderBy(x => x.Start)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
var current = parsed.FirstOrDefault(x => x.Start <= now && now < x.End);
|
||||||
|
if (current != null)
|
||||||
|
return current.Config;
|
||||||
|
|
||||||
|
var latestStarted = parsed.LastOrDefault(x => x.Start <= now && x.End > x.Start);
|
||||||
|
return latestStarted?.Config;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static DateTime? ParseConfigTime(string? raw)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(raw))
|
||||||
|
return null;
|
||||||
|
|
||||||
|
var normalized = raw.Trim().Trim('[', ']');
|
||||||
|
if (normalized.Length != 12)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return DateTime.TryParseExact(
|
||||||
|
normalized,
|
||||||
|
"yyyyMMddHHmm",
|
||||||
|
CultureInfo.InvariantCulture,
|
||||||
|
DateTimeStyles.None,
|
||||||
|
out var value)
|
||||||
|
? value
|
||||||
|
: null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static long ToUnixSeconds(DateTime? value)
|
||||||
|
{
|
||||||
|
return value.HasValue ? new DateTimeOffset(value.Value).ToUnixTimeSeconds() : 0L;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void SetAttr(PlayerInstance player, uint sid, uint value, NtfSyncPlayer sync)
|
||||||
|
{
|
||||||
|
var attr = GetOrCreateAttr(player, sid);
|
||||||
|
if (attr.Val != value)
|
||||||
|
{
|
||||||
|
attr.Val = value;
|
||||||
|
sync.Custom[player.ToPackedAttrKey(GroupId, sid)] = value;
|
||||||
|
sync.Custom[player.ToShiftedAttrKey(GroupId, sid)] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static PlayerAttr GetOrCreateAttr(PlayerInstance player, uint sid)
|
||||||
|
{
|
||||||
|
var attr = player.Data.Attrs.FirstOrDefault(x => x.Gid == GroupId && x.Sid == sid);
|
||||||
|
if (attr != null)
|
||||||
|
return attr;
|
||||||
|
|
||||||
|
attr = new PlayerAttr
|
||||||
|
{
|
||||||
|
Gid = GroupId,
|
||||||
|
Sid = sid
|
||||||
|
};
|
||||||
|
player.Data.Attrs.Add(attr);
|
||||||
|
return attr;
|
||||||
|
}
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user