Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<PackageVersion Include="NosCore.Analyzers" Version="2.3.0" />
<PackageVersion Include="NosCore.Dao" Version="6.1.1" />
<PackageVersion Include="NosCore.Networking" Version="9.2.0" />
<PackageVersion Include="NosCore.Packets" Version="41.3.1" />
<PackageVersion Include="NosCore.Packets" Version="43.0.0" />
<PackageVersion Include="NosCore.PathFinder" Version="3.0.0" />
<PackageVersion Include="NosCore.Shared" Version="7.0.1" />
<PackageVersion Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="11.0.0-rc.3" />
Expand Down
16 changes: 16 additions & 0 deletions documentation/manual-test-plan.md
Original file line number Diff line number Diff line change
Expand Up @@ -1177,6 +1177,22 @@ Needs two characters on the same channel. The commending one must be level 31 or
- [ ] Not verifiable yet: a move onto a taken slot being refused, since the client always picks
a free slot itself

### Item info windows

- [ ] Right-click each of these in the EQUIP tab and confirm an info window opens with its
values: a hat and a mask (defences), a costume suit and a costume hat (remaining time
for a timed one, "permanent" otherwise, tradable until worn), an amulet (remaining
time), a card holder with and without a card (the stored card's level, points and
upgrade), a fairy bead with and without a fairy (the fairy's element rate), a weapon or
wing skin, and a partner card (its three skills)
- [ ] From the ADDITIONAL tab, right-click a card in the card inventory (the specialist window
opens) and a costume in the costume inventory
- [ ] Open a partner's page (P) and right-click its card and its weapon
- [ ] At an NPC shop, right-click an item for sale: its info window opens
- [ ] Open one card's specialist window, close it, then right-click a different card: in the
browser client the second window did not open although its slinfo arrived. Check
whether the game client does the same

### Potions

- [ ] Take some damage, then use a Small Health Potion (`$CreateItem 1002`): the HP bar
Expand Down
16 changes: 0 additions & 16 deletions src/NosCore.Data/Enumerations/Battle/AttackType.cs

This file was deleted.

11 changes: 5 additions & 6 deletions src/NosCore.GameObject/Ecs/Extensions/PlayerBundleExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
using NosCore.Core.I18N;
using NosCore.Data.Dto;
using NosCore.Data.Enumerations;
using NosCore.Data.Enumerations.Battle;
using NosCore.GameObject.Ecs.Extensions;
using NosCore.GameObject.InterChannelCommunication.Hubs.BlacklistHub;
using NosCore.GameObject.InterChannelCommunication.Hubs.ChannelHub;
Expand Down Expand Up @@ -497,9 +496,9 @@ public static FdPacket GenerateFd(this PlayerComponentBundle player)
return new FdPacket
{
Reput = player.Reputation,
ReputIcon = (int)player.ReputIcon,
ReputIcon = player.ReputIcon,
Dignity = player.Dignity,
DignityIcon = (int)player.DignityIcon
DignityIcon = player.DignityIcon
};
}

Expand Down Expand Up @@ -528,7 +527,7 @@ public static TcInfoPacket GenerateReqInfo(this PlayerComponentBundle player,
FamilyId = player.Family?.FamilyId ?? -1,
FamilyName = player.GenerateFamilyTag(localizer, viewerLanguage),
ReputationIco = (ExtendedReputationType)player.ReputIcon,
DignityIco = (CharacterDignity)player.DignityIcon,
DignityIco = player.DignityIcon,
HaveWeapon = weapon != null ? 1 : 0,
WeaponRare = weapon?.Rare ?? 0,
WeaponUpgrade = weapon?.Upgrade ?? 0,
Expand Down Expand Up @@ -708,14 +707,14 @@ public static ScPacket GenerateSc(this PlayerComponentBundle player, IBattleStat
};
return new ScPacket
{
Type = (byte)mainType,
Type = mainType,
MainWeaponUpgrade = (byte)stats.MeleeUpgrade,
MinHit = Math.Max(0, stats.MinHit),
MaxHit = Math.Max(0, stats.MaxHit),
HitRate = stats.HitRate,
CriticalHitRate = (short)stats.CriticalChance,
CriticalHitMultiplier = stats.CriticalRate,
Type2 = (byte)secondaryType,
Type2 = secondaryType,
SecondaryWeaponUpgrade = (short)stats.RangedUpgrade,
SecondaryMinHit = (short)Math.Max(0, stats.MinDistance),
SecondaryMaxHit = (short)Math.Max(0, stats.MaxDistance),
Expand Down
166 changes: 164 additions & 2 deletions src/NosCore.GameObject/Services/ItemInfoService/ItemInfoService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,16 @@
using NosCore.Data.Enumerations.Items;
using NosCore.Data.StaticEntities;
using NosCore.GameObject.Services.ItemGenerationService.Item;
using NosCore.GameObject.Services.FairyBeadService;
using NosCore.GameObject.Services.MateService;
using NosCore.GameObject.Services.SpecialistCardService;
using NosCore.GameObject.Services.SpecialistHolderService;
using NodaTime;
using NosCore.Packets.Enumerations;
using NosCore.GameObject.Services.SkillService;
using NosCore.Packets.Interfaces;
using NosCore.Packets.ServerPackets.Inventory;
using NosCore.Packets.ServerPackets.Mates;

namespace NosCore.GameObject.Services.ItemInfoService;

Expand All @@ -28,9 +33,15 @@ public sealed class ItemInfoService(
List<SkillDto> skills,
ISpExperienceService spExperienceService,
ISpecialistPointService specialistPointService,
ISpecialistCardService specialistCardService) : IItemInfoService
ISpecialistCardService specialistCardService,
ISpecialistHolderService specialistHolderService,
IFairyBeadService fairyBeadService,
IPartnerSpecialistService partnerSpecialistService,
IClock clock) : IItemInfoService
{
private const int ListedSpecialistSkills = 10;
private const byte PartnerSpecialistSubType = 4;
private const int PermanentHours = -1;

private const byte AdventurerClass = 1;
private const byte SwordsmanClass = 2;
Expand All @@ -41,13 +52,25 @@ public sealed class ItemInfoService(
{
return itemInstance switch
{
SpecialistInstance { Item.ItemSubType: PartnerSpecialistSubType } partnerCard => GeneratePartnerSpecialistInfo(partnerCard),
SpecialistInstance specialist => GenerateSpecialistInfo(specialist),
BoxInstance holder when specialistHolderService.IsSpecialistHolder(holder) => GenerateHolderInfo(holder),
BoxInstance bead when fairyBeadService.IsFairyBead(bead) => GenerateFairyBeadInfo(bead),
WearableInstance { Item.ItemType: ItemType.Shell } shell => GenerateShellInfo(shell),
WearableInstance wearable => wearable.Item.EquipmentSlot switch
{
EquipmentType.MainWeapon or EquipmentType.SecondaryWeapon => GenerateWeaponInfo(wearable),
EquipmentType.Armor => GenerateArmorInfo(wearable),
EquipmentType.Gloves or EquipmentType.Boots => GenerateAccessoryInfo(wearable),
EquipmentType.Gloves or EquipmentType.Boots or EquipmentType.Hat or EquipmentType.Mask => GenerateAccessoryInfo(wearable),
EquipmentType.CostumeSuit => GenerateCostumeInfo(wearable),
EquipmentType.CostumeHat or EquipmentType.WeaponSkin or EquipmentType.WingSkin => GenerateCostumeHatInfo(wearable),
EquipmentType.Amulet => new EInfoAmuletPacket
{
ItemVNum = wearable.ItemVNum,
LevelMinimum = wearable.Item.LevelMinimum,
RemainingTime = RemainingSeconds(wearable) * 10,
Price = wearable.Item.Price,
},
EquipmentType.Necklace or EquipmentType.Ring or EquipmentType.Bracelet => GenerateJewelryInfo(wearable),
EquipmentType.Fairy => new EInfoFairyPacket
{
Expand Down Expand Up @@ -139,6 +162,145 @@ private static EInfoAccessoryPacket GenerateAccessoryInfo(WearableInstance acces
};
}

private EInfoCostumePacket GenerateCostumeInfo(WearableInstance costume)
{
var item = costume.Item;
return new EInfoCostumePacket
{
ItemVNum = costume.ItemVNum,
Rare = costume.Rare,
Upgrade = costume.Upgrade,
IsFixed = costume.IsFixed ?? false,
LevelMinimum = item.LevelMinimum,
CloseDefence = (short)(item.CloseDefence + (costume.CloseDefence ?? 0)),
DistanceDefence = (short)(item.DistanceDefence + (costume.DistanceDefence ?? 0)),
MagicDefence = (short)(item.MagicDefence + (costume.MagicDefence ?? 0)),
DefenceDodge = (short)(item.DefenceDodge + (costume.DefenceDodge ?? 0)),
Price = item.Price,
IsTradable = IsTradable(costume),
RemainingHours = RemainingHours(costume),
};
}

private EInfoCostumeHatPacket GenerateCostumeHatInfo(WearableInstance costume)
{
var item = costume.Item;
return new EInfoCostumeHatPacket
{
ItemVNum = costume.ItemVNum,
LevelMinimum = item.LevelMinimum,
CloseDefence = (short)(item.CloseDefence + (costume.CloseDefence ?? 0)),
DistanceDefence = (short)(item.DistanceDefence + (costume.DistanceDefence ?? 0)),
MagicDefence = (short)(item.MagicDefence + (costume.MagicDefence ?? 0)),
DefenceDodge = (short)(item.DefenceDodge + (costume.DefenceDodge ?? 0)),
FireResistance = (short)(item.FireResistance + (costume.FireResistance ?? 0)),
WaterResistance = (short)(item.WaterResistance + (costume.WaterResistance ?? 0)),
LightResistance = (short)(item.LightResistance + (costume.LightResistance ?? 0)),
DarkResistance = (short)(item.DarkResistance + (costume.DarkResistance ?? 0)),
Price = item.Price,
IsTradable = IsTradable(costume),
RemainingHours = RemainingHours(costume),
};
}

private static bool IsTradable(IItemInstance item) => item.Item.IsTradable && item.BoundCharacterId == null;

// A worn time-limited item counts down from its delete time; one never worn still has its whole validity.
private long RemainingSeconds(IItemInstance item) => item.ItemDeleteTime is { } deleteTime
? Math.Max(0, (long)(deleteTime - clock.GetCurrentInstant()).TotalSeconds)
: item.Item.ItemValidTime;

private int RemainingHours(IItemInstance item) =>
item.ItemDeleteTime == null && item.Item.ItemValidTime <= 0 ? PermanentHours : (int)(RemainingSeconds(item) / 3600);

private EInfoSpecialistHolderPacket GenerateHolderInfo(BoxInstance holder)
{
if ((holder.HoldingVNum ?? 0) == 0)
{
return new EInfoSpecialistHolderPacket { ItemVNum = holder.ItemVNum };
}

var card = GenerateSpecialistInfo(specialistHolderService.TakeOut(holder));
return new EInfoSpecialistHolderPacket
{
ItemVNum = holder.ItemVNum,
IsFull = true,
HoldingVNum = card.ItemVnum,
SpLevel = card.SpLevel,
Xp = card.Xp,
XpMaximum = card.SpXpData,
Upgrade = card.Upgrade,
SlHit = card.SlHit,
SlDefence = card.SlDefense,
SlElement = card.SlElement,
SlHp = card.SlHp,
FreePoints = card.FreeSpPoints,
SpStoneUpgrade = card.SpStoneUpgrade,
FireResistance = card.FireResistance,
WaterResistance = card.WaterResistance,
LightResistance = card.LightResistance,
DarkResistance = card.DarkResistance,
AttackPoints = card.AttackPoints,
DefencePoints = card.DefensePoints,
ElementPoints = card.ElementPoints,
HpMpPoints = card.HpMpPoints,
FirePoints = card.SpFireResistance,
WaterPoints = card.SpWaterResistance,
LightPoints = card.SpLightResistance,
DarkPoints = card.SpDarkResistance,
};
}

private EInfoFairyBeadPacket GenerateFairyBeadInfo(BoxInstance bead)
{
if ((bead.HoldingVNum ?? 0) == 0)
{
return new EInfoFairyBeadPacket { ItemVNum = bead.ItemVNum };
}

var fairy = fairyBeadService.TakeOut(bead);
return new EInfoFairyBeadPacket
{
ItemVNum = bead.ItemVNum,
IsFull = true,
HoldingVNum = fairy.ItemVNum,
ElementRate = (short)(fairy.Item.ElementRate + (fairy.ElementRate ?? 0)),
};
}

private PslInfoPacket GeneratePartnerSpecialistInfo(SpecialistInstance card)
{
var item = card.Item;
var cardSkills = partnerSpecialistService.CardSkills(card);
ScnPacket.ScSkillDetails? SkillAt(int slot) => slot < cardSkills.Count
? new ScnPacket.ScSkillDetails { SkillId = cardSkills[slot].SkillVNum, Rank = SpPartnerRank.NotIdentifiedYet }
: null;
return new PslInfoPacket
{
ItemVNum = card.ItemVNum,
Element = (ElementType)item.Element,
ElementRate = item.ElementRate,
LevelMinimum = item.LevelMinimum,
Speed = item.Speed,
FireResistance = item.FireResistance,
WaterResistance = item.WaterResistance,
LightResistance = item.LightResistance,
DarkResistance = item.DarkResistance,
Skill1 = SkillAt(0),
Skill2 = SkillAt(1),
Skill3 = SkillAt(2),
Upgrade = card.Upgrade,
AttackPoints = card.SpDamage,
DefencePoints = card.SpDefence,
CriticalDamageReductionPoints = card.SpElement,
HpMpPoints = card.SpHp,
FirePoints = card.SpFire,
WaterPoints = card.SpWater,
LightPoints = card.SpLight,
DarkPoints = card.SpDark,
};
}

private EInfoShellPacket GenerateShellInfo(WearableInstance shell)
{
var options = LoadShellOptions(shell);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using NosCore.Data.StaticEntities;
using NosCore.GameObject.Ecs;
using NosCore.GameObject.Ecs.Interfaces;
using NosCore.GameObject.Services.ItemGenerationService.Item;

namespace NosCore.GameObject.Services.MateService
{
Expand All @@ -27,6 +28,9 @@ public interface IPartnerSpecialistService
/// <summary>The skills of the card a transformed partner wears, in skill bar order; none when it is not transformed.</summary>
IReadOnlyList<SkillDto> Skills(PlayerComponentBundle owner, Mate partner);

/// <summary>The skills a partner card gives, in skill bar order.</summary>
IReadOnlyList<SkillDto> CardSkills(SpecialistInstance card);

/// <summary>Casts the skill in a slot of a transformed partner's skill bar.</summary>
Task<bool> CastAsync(PlayerComponentBundle owner, long mateTransportId, int slot, IAliveEntity target);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
using NosCore.GameObject.Ecs.Interfaces;
using NosCore.GameObject.Infastructure;
using NosCore.GameObject.Services.BattleService;
using NosCore.GameObject.Services.ItemGenerationService.Item;
using NosCore.GameObject.Services.SkillService;
using NosCore.Networking;
using NosCore.Packets.ClientPackets.Mates;
Expand Down Expand Up @@ -44,9 +45,11 @@ public sealed class PartnerSpecialistService(IClock clock, List<SkillDto> skills

public IReadOnlyList<SkillDto> Skills(PlayerComponentBundle owner, Mate partner) =>
partner.SpecialistMorph != null && partner.Specialist(owner.InventoryService) is { } specialist
? _skillsBySet[specialist.Item.PartnerSkillSet].ToList()
? CardSkills(specialist)
: [];

public IReadOnlyList<SkillDto> CardSkills(SpecialistInstance card) => _skillsBySet[card.Item.PartnerSkillSet].ToList();

public async Task<bool> CastAsync(PlayerComponentBundle owner, long mateTransportId, int slot, IAliveEntity target)
{
if (!owner.Mates.TryGetValue(mateTransportId, out var partner)
Expand Down
Loading
Loading