forked from Raphael/SCHALE.GameServer
Attempt to fix Campaign, pulling raid leaderboard data from api (WIP)
This commit is contained in:
parent
5f269c59d6
commit
90c92646a9
|
@ -5,6 +5,7 @@ using System.Collections.ObjectModel;
|
|||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace SCHALE.Common.Database
|
||||
|
@ -714,19 +715,223 @@ namespace SCHALE.Common.Database
|
|||
public int EnemyClearCount { get; set; }
|
||||
public int LastEnemyEntityId { get; set; }
|
||||
public int TacticRankSCount { get; set; }
|
||||
//public Dictionary<long, HexaUnit> EnemyInfos { get; set; }
|
||||
//public Dictionary<long, HexaUnit> EchelonInfos { get; set; }
|
||||
public Dictionary<long, HexaUnit> EnemyInfos { get; set; }
|
||||
public Dictionary<long, HexaUnit> EchelonInfos { get; set; }
|
||||
public Dictionary<long, List<long>> WithdrawInfos { get; set; }
|
||||
//public Dictionary<long, Strategy> StrategyObjects { get; set; }
|
||||
public Dictionary<long, Strategy> StrategyObjects { get; set; }
|
||||
public Dictionary<long, List<ParcelInfo>> StrategyObjectRewards { get; set; }
|
||||
public List<long> StrategyObjectHistory { get; set; }
|
||||
public Dictionary<long, List<long>> ActivatedHexaEventsAndConditions { get; set; }
|
||||
public Dictionary<long, List<long>> HexaEventDelayedExecutions { get; set; }
|
||||
//public Dictionary<int, HexaTileState> TileMapStates { get; set; }
|
||||
//public List<HexaDisplayInfo> DisplayInfos { get; set; }
|
||||
//public List<HexaUnit> DeployedEchelonInfos { get; set; }
|
||||
public Dictionary<int, HexaTileState> TileMapStates { get; set; }
|
||||
public List<HexaDisplayInfo> DisplayInfos { get; set; }
|
||||
public List<HexaUnit> DeployedEchelonInfos { get; set; }
|
||||
}
|
||||
|
||||
public class HexaTileState
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public bool IsHide { get; set; }
|
||||
public bool IsFog { get; set; }
|
||||
public bool CanNotMove { get; set; }
|
||||
}
|
||||
|
||||
public enum HexaDisplayType
|
||||
{
|
||||
None,
|
||||
EndBattle,
|
||||
PlayScenario,
|
||||
SpawnUnitFromUniqueId,
|
||||
StatBuff,
|
||||
DieUnit,
|
||||
HideStrategy,
|
||||
SpawnUnit,
|
||||
SpawnStrategy,
|
||||
SpawnTile,
|
||||
HideTile,
|
||||
ClearFogOfWar,
|
||||
MoveUnit,
|
||||
WarpUnit,
|
||||
SetTileMovablity,
|
||||
WarpUnitFromHideTile,
|
||||
BossExile
|
||||
}
|
||||
|
||||
public class StrategyClearRewardInfo
|
||||
{
|
||||
public List<ParcelInfo> FirstClearRewarde { get; set; }
|
||||
public List<ParcelInfo> ThreeStarRewarde { get; set; }
|
||||
public Dictionary<long, List<ParcelInfo>> StrategyObjectRewardse { get; set; }
|
||||
public ParcelResultDB ParcelResultDBe { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public List<ParcelInfo> ClearRewarde { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public List<ParcelInfo> ExpRewarde { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public List<ParcelInfo> TotalRewarde { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public List<ParcelInfo> EventContentRewarde { get; set; }
|
||||
|
||||
public List<ParcelInfo> EventContentBonusRewarde { get; set; }
|
||||
public CampaignStageHistoryDB CampaignStageHistoryDBe { get; set; }
|
||||
}
|
||||
|
||||
public class HexaDisplayInfo
|
||||
{
|
||||
public HexaDisplayType Type { get; set; }
|
||||
public long EntityId { get; set; }
|
||||
public long UniqueId { get; set; }
|
||||
public HexLocation Location { get; set; }
|
||||
public long Parameter { get; set; }
|
||||
public StrategyClearRewardInfo StageRewardInfo { get; set; }
|
||||
}
|
||||
|
||||
public class HexaUnit
|
||||
{
|
||||
public List<string> BuffGroupIds { get; set; }
|
||||
public SkillCardHand SkillCardHand { get; set; }
|
||||
public bool PlayAnimation { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public Dictionary<TacticEntityType, List<long>> RewardItems { get; set; }
|
||||
|
||||
public long EntityId { get; set; }
|
||||
|
||||
public Dictionary<long, long> HpInfos { get; set; }
|
||||
|
||||
public Dictionary<long, long> DyingInfos { get; set; }
|
||||
|
||||
public Dictionary<long, int> BuffInfos { get; set; }
|
||||
|
||||
public int ActionCountMax { get; set; }
|
||||
|
||||
public int ActionCount { get; set; }
|
||||
|
||||
public int Mobility { get; set; }
|
||||
|
||||
public int StrategySightRange { get; set; }
|
||||
|
||||
public long Id { get; set; }
|
||||
|
||||
public Vector3 Rotate { get; set; }
|
||||
|
||||
public HexLocation Location { get; set; }
|
||||
|
||||
public HexLocation AIDestination { get; set; }
|
||||
|
||||
public bool IsActionComplete { get; set; }
|
||||
|
||||
public bool IsPlayer { get; set; }
|
||||
|
||||
public bool IsFixedEchelon { get; set; }
|
||||
|
||||
public int MovementOrder { get; set; }
|
||||
|
||||
public Dictionary<TacticEntityType, List<ParcelInfo>> RewardParcelInfosWithDropTacticEntityType { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public CampaignUnitExcel CampaignUnitExcel { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public List<HexaTile> MovableTiles { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public List<List<HexaTile>> MovementMap { get; set; }
|
||||
}
|
||||
|
||||
public class HexaTile
|
||||
{
|
||||
public bool PlayAnimation { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public bool IsBattleReady { get; set; }
|
||||
|
||||
|
||||
[JsonIgnore]
|
||||
public bool StartTile { get; set; }
|
||||
public string ResourcePath { get; set; }
|
||||
public bool IsHide { get; set; }
|
||||
public bool IsFog { get; set; }
|
||||
public bool CanNotMove { get; set; }
|
||||
public HexLocation Location { get; set; }
|
||||
public Strategy Strategy { get; set; }
|
||||
public HexaUnit Unit { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public HexaUnit ChallengeUnit { get; set; }
|
||||
}
|
||||
|
||||
public class Strategy
|
||||
{
|
||||
public bool PlayAnimation { get; set; }
|
||||
public bool Activated { get; set; }
|
||||
public List<int> Values { get; set; }
|
||||
public int Index { get; set; }
|
||||
[JsonIgnore]
|
||||
public bool Movable { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public bool NeedValueType { get; set; }
|
||||
public long EntityId { get; set; }
|
||||
public Vector3 Rotate { get; set; }
|
||||
public long Id { get; set; }
|
||||
public HexLocation Location { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public CampaignStrategyObjectExcel CampaignStrategyExcel { get; set; }
|
||||
}
|
||||
|
||||
public struct HexLocation
|
||||
{
|
||||
public int x { get; set; }
|
||||
public int y { get; set; }
|
||||
public int z { get; set; }
|
||||
}
|
||||
|
||||
public class ForceSerializeZeroFloatConverter : JsonConverter<float>
|
||||
{
|
||||
public override float Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||
{
|
||||
return reader.GetSingle();
|
||||
}
|
||||
|
||||
public override void Write(Utf8JsonWriter writer, float value, JsonSerializerOptions options)
|
||||
{
|
||||
writer.WriteNumberValue(value);
|
||||
}
|
||||
}
|
||||
|
||||
public struct Vector3
|
||||
{
|
||||
[JsonConverter(typeof(ForceSerializeZeroFloatConverter))]
|
||||
public float x { get; set; }
|
||||
|
||||
[JsonConverter(typeof(ForceSerializeZeroFloatConverter))]
|
||||
public float y { get; set; }
|
||||
|
||||
[JsonConverter(typeof(ForceSerializeZeroFloatConverter))]
|
||||
public float z { get; set; }
|
||||
}
|
||||
|
||||
public class SkillCardHand
|
||||
{
|
||||
public float Cost { get; set; }
|
||||
|
||||
public List<SkillCardInfo> SkillCardsInHand { get; set; }
|
||||
|
||||
}
|
||||
|
||||
public struct SkillCardInfo
|
||||
{
|
||||
public long CharacterId { get; set; }
|
||||
public int HandIndex { get; set; }
|
||||
public string SkillId { get; set; }
|
||||
public int RemainCoolTime { get; set; }
|
||||
}
|
||||
|
||||
public class CampaignStageHistoryDB
|
||||
{
|
||||
|
@ -2396,7 +2601,7 @@ namespace SCHALE.Common.Database
|
|||
}
|
||||
|
||||
|
||||
public class SingleRaidUserDB
|
||||
public class SingleRaidUserDB : RaidUserDB
|
||||
{
|
||||
public RaidTeamSettingDB RaidTeamSettingDB { get; set; }
|
||||
}
|
||||
|
|
|
@ -104,14 +104,14 @@ namespace SCHALE.Common.Parcel
|
|||
[Serializable]
|
||||
public struct BasisPoint : IEquatable<BasisPoint>, IComparable<BasisPoint>
|
||||
{
|
||||
[JsonIgnore]
|
||||
public long RawValue
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.rawValue;
|
||||
}
|
||||
}
|
||||
//[JsonIgnore]
|
||||
//public long RawValue
|
||||
//{
|
||||
// get
|
||||
// {
|
||||
// return this.rawValue;
|
||||
// }
|
||||
//}
|
||||
|
||||
private static readonly long Multiplier;
|
||||
|
||||
|
@ -125,8 +125,7 @@ namespace SCHALE.Common.Parcel
|
|||
|
||||
public static readonly double DoubleEpsilon;
|
||||
|
||||
[JsonProperty]
|
||||
private long rawValue;
|
||||
public long rawValue { get; set; }
|
||||
|
||||
public BasisPoint(long rawValue)
|
||||
{
|
||||
|
@ -167,6 +166,7 @@ namespace SCHALE.Common.Parcel
|
|||
|
||||
public BasisPoint Multiplier { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public long MultipliedAmount
|
||||
{
|
||||
get
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -24,5 +24,23 @@ namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers
|
|||
|
||||
};
|
||||
}
|
||||
|
||||
[ProtocolHandler(Protocol.EventContent_AdventureList)]
|
||||
public ResponsePacket AdventureListHandler(EventContentAdventureListRequest req)
|
||||
{
|
||||
return new EventContentAdventureListResponse()
|
||||
{
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
[ProtocolHandler(Protocol.EventContent_ScenarioGroupHistoryUpdate)]
|
||||
public ResponsePacket AdventureListHandler(EventContentScenarioGroupHistoryUpdateRequest req)
|
||||
{
|
||||
return new EventContentScenarioGroupHistoryUpdateResponse()
|
||||
{
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ using SCHALE.Common.FlatData;
|
|||
using SCHALE.Common.NetworkProtocol;
|
||||
using SCHALE.GameServer.Managers;
|
||||
using SCHALE.GameServer.Services;
|
||||
using Serilog;
|
||||
|
||||
namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers
|
||||
{
|
||||
|
@ -11,12 +12,14 @@ namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers
|
|||
private readonly ISessionKeyService sessionKeyService;
|
||||
private readonly SCHALEContext context;
|
||||
private readonly ExcelTableService excelTableService;
|
||||
private readonly DatabaseAPIService databaseAPIService;
|
||||
|
||||
public Raid(IProtocolHandlerFactory protocolHandlerFactory, ISessionKeyService _sessionKeyService, SCHALEContext _context, ExcelTableService _excelTableService) : base(protocolHandlerFactory)
|
||||
public Raid(IProtocolHandlerFactory protocolHandlerFactory, ISessionKeyService _sessionKeyService, SCHALEContext _context, ExcelTableService _excelTableService, DatabaseAPIService _databaseAPIService) : base(protocolHandlerFactory)
|
||||
{
|
||||
sessionKeyService = _sessionKeyService;
|
||||
context = _context;
|
||||
excelTableService = _excelTableService;
|
||||
databaseAPIService = _databaseAPIService;
|
||||
}
|
||||
|
||||
[ProtocolHandler(Protocol.Raid_Lobby)]
|
||||
|
@ -111,9 +114,164 @@ namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers
|
|||
[ProtocolHandler(Protocol.Raid_OpponentList)]
|
||||
public ResponsePacket OpponentListHandler(RaidOpponentListRequest req)
|
||||
{
|
||||
Log.Information("rank: " + req.Rank);
|
||||
Log.Information("score: " + req.Score);
|
||||
Log.Information("isUpper: " + req.IsUpper);
|
||||
Log.Information("IsFirstRequest: " + req.IsFirstRequest);
|
||||
Log.Information("RankingSearchType: " + req.SearchType);
|
||||
|
||||
/*
|
||||
RaidData data = databaseAPIService.GetApiData();
|
||||
|
||||
List<SingleRaidUserDB> opponentUserDBs = new List<SingleRaidUserDB>();
|
||||
|
||||
Log.Information("raiddata count:" + data.RaidMembers.Count);
|
||||
Log.Information("raiddata name1:" + data.RaidMembers[0].Name);
|
||||
|
||||
for (int i = 0; i < data.RaidMembers.Count; i++)
|
||||
{
|
||||
RaidMember currMember = data.RaidMembers[i];
|
||||
|
||||
SingleRaidUserDB raidMember = new SingleRaidUserDB()
|
||||
{
|
||||
AccountId = i + 2,
|
||||
RepresentCharacterUniqueId = 19009113,
|
||||
Level = 1,
|
||||
Nickname = currMember.Name,
|
||||
Tier = 0,
|
||||
Rank = i + 1,
|
||||
BestRankingPoint = currMember.Score,
|
||||
BestRankingPointDetail = currMember.Score,
|
||||
AccountAttachmentDB = new()
|
||||
{
|
||||
AccountId = 2,
|
||||
EmblemUniqueId = 5100382
|
||||
},
|
||||
|
||||
RaidTeamSettingDB = new()
|
||||
{
|
||||
AccountId = i + 2,
|
||||
EchelonType = EchelonType.Raid,
|
||||
MainCharacterDBs = [
|
||||
new RaidCharacterDB() {
|
||||
ServerId = 3,
|
||||
UniqueId = 19090002,
|
||||
StarGrade = 5,
|
||||
Level = 1,
|
||||
HasWeapon = true,
|
||||
WeaponStarGrade = 3,
|
||||
},
|
||||
],
|
||||
SupportCharacterDBs = [
|
||||
new RaidCharacterDB() {
|
||||
ServerId = 1,
|
||||
UniqueId = 19090001,
|
||||
StarGrade = 5,
|
||||
Level = 1,
|
||||
HasWeapon = true,
|
||||
WeaponStarGrade = 3,
|
||||
SlotIndex = 1
|
||||
}
|
||||
],
|
||||
SkillCardMulliganCharacterIds = [10033],
|
||||
LeaderCharacterUniqueId = 10033
|
||||
}
|
||||
};
|
||||
|
||||
opponentUserDBs.Add(raidMember);
|
||||
}
|
||||
|
||||
return new RaidOpponentListResponse()
|
||||
{
|
||||
OpponentUserDBs = []
|
||||
OpponentUserDBs = opponentUserDBs
|
||||
};
|
||||
|
||||
*/
|
||||
|
||||
return new RaidOpponentListResponse()
|
||||
{
|
||||
OpponentUserDBs = [
|
||||
new()
|
||||
{
|
||||
AccountId = 2,
|
||||
RepresentCharacterUniqueId = 19009113,
|
||||
Level = 1,
|
||||
Nickname = "夏萝莉是小楠梁",
|
||||
Tier = 0,
|
||||
Rank = 1,
|
||||
BestRankingPoint = int.MaxValue,
|
||||
BestRankingPointDetail = int.MaxValue,
|
||||
AccountAttachmentDB = new() {
|
||||
AccountId = 2,
|
||||
EmblemUniqueId = 5100382
|
||||
},
|
||||
|
||||
RaidTeamSettingDB = new() {
|
||||
AccountId = 2,
|
||||
EchelonType = EchelonType.Raid,
|
||||
MainCharacterDBs = [
|
||||
new RaidCharacterDB() {
|
||||
ServerId = 3,
|
||||
UniqueId = 19090002,
|
||||
StarGrade = 5,
|
||||
Level = 1,
|
||||
HasWeapon = true,
|
||||
WeaponStarGrade = 3,
|
||||
},
|
||||
new RaidCharacterDB() {
|
||||
ServerId = 3,
|
||||
UniqueId = 7403700,
|
||||
StarGrade = 5,
|
||||
Level = 1,
|
||||
HasWeapon = true,
|
||||
WeaponStarGrade = 3,
|
||||
SlotIndex = 1
|
||||
},
|
||||
new RaidCharacterDB() {
|
||||
ServerId = 3,
|
||||
UniqueId = 610240702,
|
||||
StarGrade = 5,
|
||||
Level = 1,
|
||||
HasWeapon = true,
|
||||
WeaponStarGrade = 3,
|
||||
SlotIndex = 2
|
||||
},
|
||||
new RaidCharacterDB() {
|
||||
ServerId = 3,
|
||||
UniqueId = 19090001,
|
||||
StarGrade = 5,
|
||||
Level = 1,
|
||||
HasWeapon = true,
|
||||
WeaponStarGrade = 3,
|
||||
SlotIndex = 3
|
||||
},
|
||||
|
||||
],
|
||||
SupportCharacterDBs = [
|
||||
new RaidCharacterDB() {
|
||||
ServerId = 2,
|
||||
UniqueId = 19090002,
|
||||
StarGrade = 5,
|
||||
Level = 1,
|
||||
HasWeapon = true,
|
||||
WeaponStarGrade = 3,
|
||||
},
|
||||
new RaidCharacterDB() {
|
||||
ServerId = 1,
|
||||
UniqueId = 19090001,
|
||||
StarGrade = 5,
|
||||
Level = 1,
|
||||
HasWeapon = true,
|
||||
WeaponStarGrade = 3,
|
||||
SlotIndex = 1
|
||||
}
|
||||
],
|
||||
SkillCardMulliganCharacterIds = [10033],
|
||||
LeaderCharacterUniqueId = 10033
|
||||
}
|
||||
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -125,6 +125,18 @@ namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers
|
|||
var itemDict = new AccDict<long>();
|
||||
bool shouldDoGuaranteedSR = true;
|
||||
// itemDict[gpStoneID] = 10;
|
||||
//for (int i = 0; i < 10; ++i)
|
||||
//{
|
||||
// gachaList.Add(new(7403700)
|
||||
// {
|
||||
// Character = new()
|
||||
// {
|
||||
// AccountServerId = account.ServerId,
|
||||
// UniqueId = 7403700,
|
||||
// StarGrade = 3,
|
||||
// },
|
||||
// });
|
||||
//}
|
||||
|
||||
for (int i = 0; i < 10; ++i)
|
||||
{
|
||||
|
|
|
@ -7,6 +7,7 @@ using Microsoft.EntityFrameworkCore;
|
|||
using SCHALE.Common.Crypto;
|
||||
using SCHALE.Common.Database;
|
||||
using SCHALE.GameServer.Commands;
|
||||
using SCHALE.GameServer.Controllers;
|
||||
using SCHALE.GameServer.Controllers.Api.ProtocolHandlers;
|
||||
using SCHALE.GameServer.Services;
|
||||
using SCHALE.GameServer.Services.Irc;
|
||||
|
@ -89,6 +90,9 @@ namespace SCHALE.GameServer
|
|||
builder.Services.AddIrcService();
|
||||
builder.Services.AddSharedDataCache();
|
||||
|
||||
builder.Services.AddHttpClient<DatabaseAPIService>();
|
||||
builder.Services.AddSingleton<DatabaseAPIService>();
|
||||
|
||||
// Add all Handler Groups
|
||||
var handlerGroups = Assembly
|
||||
.GetExecutingAssembly()
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace SCHALE.GameServer.Managers
|
|||
RaidLobbyInfoDB = new SingleRaidLobbyInfoDB()
|
||||
{
|
||||
Tier = 0,
|
||||
Ranking = 1,
|
||||
Ranking = 123,
|
||||
SeasonId = raidInfo.SeasonId,
|
||||
BestRankingPoint = 0,
|
||||
TotalRankingPoint = 0,
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
using Newtonsoft.Json;
|
||||
|
||||
namespace SCHALE.GameServer.Services
|
||||
{
|
||||
public class DatabaseAPIService
|
||||
{
|
||||
private readonly HttpClient _httpClient;
|
||||
public static readonly string API_URL = "[redacted]";
|
||||
|
||||
public DatabaseAPIService(HttpClient httpClient)
|
||||
{
|
||||
_httpClient = httpClient;
|
||||
}
|
||||
|
||||
public RaidData GetApiData()
|
||||
{
|
||||
var response = _httpClient.GetAsync(API_URL).GetAwaiter().GetResult();
|
||||
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
var jsonData = response.Content.ReadAsStringAsync().GetAwaiter().GetResult();
|
||||
return JsonConvert.DeserializeObject<RaidData>(jsonData);
|
||||
} else
|
||||
{
|
||||
throw new Exception("Error retrieving data from API.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class RaidData
|
||||
{
|
||||
public List<RaidMember> RaidMembers { get; set; }
|
||||
}
|
||||
|
||||
public class RaidMember
|
||||
{
|
||||
[JsonProperty("name")]
|
||||
public string Name { get; set; }
|
||||
|
||||
[JsonProperty("score")]
|
||||
public long Score { get; set; }
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue