🛠️Arena
This commit is contained in:
parent
f7e0027b86
commit
5d3ed684a8
|
@ -14,29 +14,22 @@ namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers
|
||||||
private readonly ISessionKeyService sessionKeyService = _sessionKeyService;
|
private readonly ISessionKeyService sessionKeyService = _sessionKeyService;
|
||||||
private readonly SCHALEContext context = _context;
|
private readonly SCHALEContext context = _context;
|
||||||
|
|
||||||
private EquipmentDB GetEquipmentDB(long accountServerId, long equipmentServerId)
|
private EquipmentDB? GetEquipmentDB(long accountServerId, long equipmentServerId)
|
||||||
{
|
{
|
||||||
if (equipmentServerId == 0)
|
if (equipmentServerId == 0)
|
||||||
return new EquipmentDB();
|
return null;
|
||||||
var equipmentDB = context
|
return context.Equipment.First(c =>
|
||||||
.Equipment.OrderBy(row => row.ServerId)
|
c.AccountServerId == accountServerId && c.ServerId == equipmentServerId
|
||||||
.LastOrDefault(c =>
|
);
|
||||||
c.AccountServerId == accountServerId && c.ServerId == equipmentServerId
|
|
||||||
);
|
|
||||||
ArgumentNullException.ThrowIfNull(equipmentDB);
|
|
||||||
return equipmentDB;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private ArenaCharacterDB Convert(long accountServerId, long characterServerId)
|
private ArenaCharacterDB? Convert(long accountServerId, long characterServerId)
|
||||||
{
|
{
|
||||||
if (characterServerId == 0)
|
if (characterServerId == 0)
|
||||||
return new ArenaCharacterDB();
|
return null;
|
||||||
var characterDB = context
|
var characterDB = context.Characters.First(c =>
|
||||||
.Characters.OrderBy(row => row.ServerId)
|
c.AccountServerId == accountServerId && c.ServerId == characterServerId
|
||||||
.LastOrDefault(c =>
|
);
|
||||||
c.AccountServerId == accountServerId && c.ServerId == characterServerId
|
|
||||||
);
|
|
||||||
ArgumentNullException.ThrowIfNull(characterDB);
|
|
||||||
return Convert(characterDB);
|
return Convert(characterDB);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,7 +47,8 @@ namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers
|
||||||
LeaderSkillLevel = db.LeaderSkillLevel,
|
LeaderSkillLevel = db.LeaderSkillLevel,
|
||||||
EquipmentDBs = db
|
EquipmentDBs = db
|
||||||
.EquipmentServerIds.Select(i => GetEquipmentDB(db.AccountServerId, i))
|
.EquipmentServerIds.Select(i => GetEquipmentDB(db.AccountServerId, i))
|
||||||
.ToList()[..3],
|
.Where(i => i != null)
|
||||||
|
.ToList()!,
|
||||||
FavorRankInfo = new Dictionary<long, long>
|
FavorRankInfo = new Dictionary<long, long>
|
||||||
{
|
{
|
||||||
// TODO: add all
|
// TODO: add all
|
||||||
|
@ -62,18 +56,14 @@ namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers
|
||||||
},
|
},
|
||||||
PotentialStats = db.PotentialStats
|
PotentialStats = db.PotentialStats
|
||||||
};
|
};
|
||||||
var weaponDB = context
|
var weaponDB = context.Weapons.FirstOrDefault(w =>
|
||||||
.Weapons.OrderBy(row => row.ServerId)
|
w.AccountServerId == db.AccountServerId && w.BoundCharacterServerId == db.ServerId
|
||||||
.LastOrDefault(w =>
|
);
|
||||||
w.AccountServerId == db.ServerId && w.BoundCharacterServerId == db.ServerId
|
|
||||||
);
|
|
||||||
if (weaponDB != null)
|
if (weaponDB != null)
|
||||||
res.WeaponDB = weaponDB;
|
res.WeaponDB = weaponDB;
|
||||||
var gearDB = context
|
var gearDB = context.Gears.FirstOrDefault(w =>
|
||||||
.Gears.OrderBy(row => row.ServerId)
|
w.AccountServerId == db.AccountServerId && w.BoundCharacterServerId == db.ServerId
|
||||||
.LastOrDefault(w =>
|
);
|
||||||
w.AccountServerId == db.ServerId && w.BoundCharacterServerId == db.ServerId
|
|
||||||
);
|
|
||||||
if (gearDB != null)
|
if (gearDB != null)
|
||||||
res.GearDB = gearDB;
|
res.GearDB = gearDB;
|
||||||
return res;
|
return res;
|
||||||
|
@ -82,23 +72,23 @@ namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers
|
||||||
private ArenaTeamSettingDB Convert(EchelonDB db)
|
private ArenaTeamSettingDB Convert(EchelonDB db)
|
||||||
{
|
{
|
||||||
var LeaderCharacterId = context
|
var LeaderCharacterId = context
|
||||||
.Characters.OrderBy(row => row.ServerId)
|
.Characters.First(c =>
|
||||||
.LastOrDefault(c =>
|
|
||||||
c.AccountServerId == db.AccountServerId && c.ServerId == db.LeaderServerId
|
c.AccountServerId == db.AccountServerId && c.ServerId == db.LeaderServerId
|
||||||
)
|
)
|
||||||
?.UniqueId;
|
.UniqueId;
|
||||||
ArgumentNullException.ThrowIfNull(LeaderCharacterId);
|
|
||||||
|
|
||||||
return new ArenaTeamSettingDB()
|
return new ArenaTeamSettingDB()
|
||||||
{
|
{
|
||||||
EchelonType = db.EchelonType,
|
EchelonType = db.EchelonType,
|
||||||
LeaderCharacterId = LeaderCharacterId.Value,
|
LeaderCharacterId = LeaderCharacterId,
|
||||||
MainCharacters = db
|
MainCharacters = db
|
||||||
.MainSlotServerIds.Select(i => Convert(db.AccountServerId, i))
|
.MainSlotServerIds.Select(i => Convert(db.AccountServerId, i))
|
||||||
.ToList(),
|
.Where(i => i != null)
|
||||||
|
.ToList()!,
|
||||||
SupportCharacters = db
|
SupportCharacters = db
|
||||||
.SupportSlotServerIds.Select(i => Convert(db.AccountServerId, i))
|
.SupportSlotServerIds.Select(i => Convert(db.AccountServerId, i))
|
||||||
.ToList(),
|
.Where(i => i != null)
|
||||||
|
.ToList()!,
|
||||||
MapId = 1001,
|
MapId = 1001,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -110,7 +100,6 @@ namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers
|
||||||
LeaderCharacterId = 10065,
|
LeaderCharacterId = 10065,
|
||||||
MainCharacters =
|
MainCharacters =
|
||||||
[
|
[
|
||||||
new ArenaCharacterDB(),
|
|
||||||
new ArenaCharacterDB()
|
new ArenaCharacterDB()
|
||||||
{
|
{
|
||||||
UniqueId = 10065,
|
UniqueId = 10065,
|
||||||
|
@ -128,14 +117,12 @@ namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers
|
||||||
|
|
||||||
private ArenaTeamSettingDB? GetDefense(long accountId)
|
private ArenaTeamSettingDB? GetDefense(long accountId)
|
||||||
{
|
{
|
||||||
var defense = context
|
var defense = context.Echelons.FirstOrDefault(e =>
|
||||||
.Echelons.OrderBy(row => row.ServerId)
|
e.AccountServerId == accountId
|
||||||
.LastOrDefault(e =>
|
&& e.EchelonType == EchelonType.ArenaDefence
|
||||||
e.AccountServerId == accountId
|
&& e.EchelonNumber == 1
|
||||||
&& e.EchelonType == EchelonType.ArenaDefence
|
&& e.ExtensionType == EchelonExtensionType.Base
|
||||||
&& e.EchelonNumber == 1
|
);
|
||||||
&& e.ExtensionType == EchelonExtensionType.Base
|
|
||||||
);
|
|
||||||
if (defense == null)
|
if (defense == null)
|
||||||
return null;
|
return null;
|
||||||
return Convert(defense);
|
return Convert(defense);
|
||||||
|
@ -186,8 +173,7 @@ namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers
|
||||||
AllTimeRecord = 1
|
AllTimeRecord = 1
|
||||||
},
|
},
|
||||||
OpponentUserDBs = DummyOpponent(GetDefense(req.AccountId)),
|
OpponentUserDBs = DummyOpponent(GetDefense(req.AccountId)),
|
||||||
MapId = 1001,
|
MapId = 1001
|
||||||
AutoRefreshTime = DateTime.Parse("2099-01-01T00:00:00")
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,15 +196,12 @@ namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers
|
||||||
[ProtocolHandler(Protocol.Arena_EnterBattlePart1)]
|
[ProtocolHandler(Protocol.Arena_EnterBattlePart1)]
|
||||||
public ResponsePacket EnterBattlePart1Handler(ArenaEnterBattlePart1Request req)
|
public ResponsePacket EnterBattlePart1Handler(ArenaEnterBattlePart1Request req)
|
||||||
{
|
{
|
||||||
var attack = context
|
var attack = context.Echelons.First(e =>
|
||||||
.Echelons.OrderBy(row => row.ServerId)
|
e.AccountServerId == req.AccountId
|
||||||
.LastOrDefault(e =>
|
&& e.EchelonType == EchelonType.ArenaAttack
|
||||||
e.AccountServerId == req.AccountId
|
&& e.EchelonNumber == 1
|
||||||
&& e.EchelonType == EchelonType.ArenaAttack
|
&& e.ExtensionType == EchelonExtensionType.Base
|
||||||
&& e.EchelonNumber == 1
|
);
|
||||||
&& e.ExtensionType == EchelonExtensionType.Base
|
|
||||||
);
|
|
||||||
ArgumentNullException.ThrowIfNull(attack);
|
|
||||||
|
|
||||||
ArenaUserDB arenaUserDB =
|
ArenaUserDB arenaUserDB =
|
||||||
new()
|
new()
|
||||||
|
|
Loading…
Reference in New Issue