feat: update creation to also set slots etc.
This commit is contained in:
parent
8b294dd1ca
commit
6bcf90bc87
1 changed files with 25 additions and 9 deletions
|
@ -28,8 +28,13 @@ public class CharacterCreationHandler : IPacketHandler<CharacterCreationPacket>
|
|||
public async Task HandleAsync(CharacterCreationPacket packet, TcpSession session)
|
||||
{
|
||||
var authSession = session as AuthSession;
|
||||
if (authSession is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var account =
|
||||
_wonderkingContext.Accounts.FirstOrDefault(a => authSession != null && a.Id == authSession.AccountId);
|
||||
_wonderkingContext.Accounts.FirstOrDefault(a => a.Id == authSession.AccountId);
|
||||
var mappedDefaultItems = _characterStatsMapping.DefaultCharacterMapping.Items
|
||||
.Select(i => _itemObjectPoolService.GetBaseInventoryItem(i.Id, i.Quantity)).ToArray();
|
||||
|
||||
|
@ -83,10 +88,10 @@ public class CharacterCreationHandler : IPacketHandler<CharacterCreationPacket>
|
|||
await _wonderkingContext.SaveChangesAsync().ConfigureAwait(true);
|
||||
|
||||
var amountOfCharacters = await _wonderkingContext.Characters.AsNoTrackingWithIdentityResolution()
|
||||
.CountAsync(c => authSession != null && c.Account.Id == authSession.AccountId).ConfigureAwait(true);
|
||||
.CountAsync(c => c.Account.Id == authSession.AccountId).ConfigureAwait(true);
|
||||
|
||||
var character = await _wonderkingContext.Characters.AsNoTrackingWithIdentityResolution()
|
||||
.Where(c => authSession != null && c.Account.Id == authSession.AccountId && c.Name == packet.Name)
|
||||
.Where(c => c.Account.Id == authSession.AccountId && c.Name == packet.Name)
|
||||
.Select(c =>
|
||||
new CharacterData
|
||||
{
|
||||
|
@ -99,13 +104,12 @@ public class CharacterCreationHandler : IPacketHandler<CharacterCreationPacket>
|
|||
Health = c.Health,
|
||||
Mana = c.Mana,
|
||||
EquippedItems =
|
||||
c.InventoryItems.Where(item => item.InventoryTab == InventoryTab.WornEquipment)
|
||||
.Select(item => item.ItemId)
|
||||
.ToArray(),
|
||||
EquippedCashItems = c.InventoryItems
|
||||
GetItemIDsByInventoryTab(c.InventoryItems
|
||||
.Where(item => item.InventoryTab == InventoryTab.WornEquipment)
|
||||
.Select(item => new Tuple<ushort, byte>(item.ItemId, item.Slot)).ToArray()),
|
||||
EquippedCashItems = GetItemIDsByInventoryTab(c.InventoryItems
|
||||
.Where(item => item.InventoryTab == InventoryTab.WornCashEquipment)
|
||||
.Select(item => item.ItemId)
|
||||
.ToArray(),
|
||||
.Select(item => new Tuple<ushort, byte>(item.ItemId, item.Slot)).ToArray()),
|
||||
}).FirstAsync().ConfigureAwait(true);
|
||||
await authSession.SendAsync(new CharacterCreationResponsePacket
|
||||
{
|
||||
|
@ -126,4 +130,16 @@ public class CharacterCreationHandler : IPacketHandler<CharacterCreationPacket>
|
|||
return (int)((level - 1) * firstJobConfig.DynamicStats.ManaPerLevel +
|
||||
firstJobConfig.BaseStats.Wisdom * firstJobConfig.DynamicStats.ManaPerWisdom);
|
||||
}
|
||||
|
||||
private static ushort[] GetItemIDsByInventoryTab(Tuple<ushort, byte>[] items)
|
||||
{
|
||||
var ids = new ushort[20];
|
||||
|
||||
for (var i = 0; i < 20; i++)
|
||||
{
|
||||
ids[i] = items.FirstOrDefault(item => item.Item2 == i)?.Item1 ?? 0;
|
||||
}
|
||||
|
||||
return ids;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue