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
1 change: 1 addition & 0 deletions documentation/dat/Item.dat.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
| RestoresPercent | Byte | SpecialPotions | HP and MP restored on use, in percent of the maximum |
| Sex | Byte | FLAG[16] + FLAG[17] | Genders allowed, one bit per GenderType: 1=male only, 2=female only, 0=any |
| ShellType | Nullable`1 | DATA[5] (shell only) | Shell kind, which decides the options it rolls |
| SpecialistUpgradeMaterial | SpecialistUpgradeMaterial | INDEX[7] (player SP only) | Materials the SP upgrade window takes, by the card's morph |
| Speed | Byte | DATA[varies] | Movement speed bonus / vehicle speed |
| SpType | Byte | DATA[varies] (SP only) | SP transformation type |
| Type | NoscorePocketType | DATA[0] + INDEX[0,1] | Pocket type: DATA[0]==1000 && INDEX[1]==4 -> Mount, else legacy INDEX[0] map |
Expand Down
19 changes: 19 additions & 0 deletions src/NosCore.Data/Enumerations/Items/SpecialistUpgradeMaterial.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// __ _ __ __ ___ __ ___ ___
// | \| |/__\ /' _/ / _//__\| _ \ __|
// | | ' | \/ |`._`.| \_| \/ | v / _|
// |_|\__|\__/ |___/ \__/\__/|_|_\___|
//

namespace NosCore.Data.Enumerations.Items
{
// Which materials a specialist card's upgrade takes. Item.dat does not say, so the parser sets it.
public enum SpecialistUpgradeMaterial : byte
{
None = 0,
Souls = 1,
DragonParts = 2,

// The cards of the other dimensions also take Dimensiolith shards from +15.
DragonPartsAndShards = 3,
}
}
2 changes: 2 additions & 0 deletions src/NosCore.Database/Entities/Item.cs
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,8 @@ public Item()

public byte SpType { get; set; }

public SpecialistUpgradeMaterial SpecialistUpgradeMaterial { get; set; }

// The name shown above a partner transformed with this card; 0 for none.
public Game18NConstString PartnerSpecialistName { get; set; }

Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ partial class NosCoreContextModelSnapshot : ModelSnapshot
// If you encounter a merge conflict in the line below, it means you need to
// discard one of the migration branches and recreate its migrations on top of
// the other branch. See https://aka.ms/efcore-docs-migrations-conflicts for more info.
public override string LastMigrationId => "20261129121213_AddTeleporterFares";
public override string LastMigrationId => "20261129151011_AddSpecialistUpgradeMaterial";

protected override void BuildModel(ModelBuilder modelBuilder)
{
Expand Down Expand Up @@ -71,6 +71,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "scripted_instance_type", new[] { "time_space", "raid", "raid_act4" });
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "skill_kind", new[] { "attack", "debuff", "support", "emote" });
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "sp_partner_rank", new[] { "not_identified_yet", "f", "e", "d", "c", "b", "a", "s" });
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "specialist_upgrade_material", new[] { "none", "souls", "dragon_parts", "dragon_parts_and_shards" });
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "static_bonus_type", new[] { "bazaar_medal_gold", "bazaar_medal_silver", "back_pack", "pet_basket", "pet_back_pack", "inventory_ticket_upgrade", "cuarry_bank_vip", "medal_of_erenia", "adventurers_medal", "medal_of_friendship", "mimis_medal", "family_experience_booster" });
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "teleporter_type", new[] { "teleporter", "teleporter_on_map", "teleporter_on_map_after_bar" });
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "upgrade_packet_type", new[] { "item_to_part", "upgrade_item", "cellon_item", "rarify_item", "sum_resistance", "upgrade_sp_no_protection", "upgrade_item_protected", "rarify_item_protected", "upgrade_sp_protected", "upgrade_sp_protected2", "upgrade_sp_chiken", "upgrade_sp_pyjama", "perfect_sp", "upgrade_sp_pirate", "upgrade_item_gold_scroll", "create_fairy_zenas", "create_fairy_erenia", "create_fairy_fernon", "fusion_item", "apply_tattoo" });
Expand Down Expand Up @@ -1782,6 +1783,9 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.Property<byte>("SpType")
.HasColumnType("smallint");

b.Property<byte>("SpecialistUpgradeMaterial")
.HasColumnType("smallint");

b.Property<byte>("Speed")
.HasColumnType("smallint");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,6 @@ public abstract class SpUpgradeOperationBase(
IItemCatalog itemCatalog)
: SpecialistCardOperation(random)
{
// Cards with a higher morph are upgraded with the dragon materials instead of souls.
private const short LastSoulMorph = 16;

// The cards of the other dimensions, which also take shards from +15.
private const short FirstDimensionMorph = 55;
private const short LastDimensionMorph = 58;

protected abstract bool IsProtected { get; }

protected override Game18NConstString SuccessMessage => Game18NConstString.UpgradeSuccessful;
Expand Down Expand Up @@ -87,7 +80,7 @@ protected virtual IReadOnlyList<MaterialCost> MaterialCosts(SpecialistInstance c
};
AddIfNeeded(materials, VNum(Soul(card)), spUpgradeService.GetSoulCost(upgrade));
AddIfNeeded(materials, VNum(MaterialType.DragonGem), spUpgradeService.GetDragonGemCost(upgrade));
if (card.Item.Morph is >= FirstDimensionMorph and <= LastDimensionMorph)
if (card.Item.SpecialistUpgradeMaterial == SpecialistUpgradeMaterial.DragonPartsAndShards)
{
AddIfNeeded(materials, VNum(MaterialType.DimensiolithShard), spUpgradeService.GetShardCost(upgrade));
}
Expand Down Expand Up @@ -210,7 +203,7 @@ protected override async Task EmitOutcomeEffectsAsync(ClientSession session, Upg

private static MaterialType Soul(SpecialistInstance card)
{
var dragon = card.Item.Morph > LastSoulMorph;
var dragon = card.Item.SpecialistUpgradeMaterial is SpecialistUpgradeMaterial.DragonParts or SpecialistUpgradeMaterial.DragonPartsAndShards;
return card.Upgrade switch
{
< 5 => dragon ? MaterialType.DragonSkin : MaterialType.GreenSoul,
Expand Down
18 changes: 18 additions & 0 deletions src/NosCore.Parser/Parsers/ItemParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ public FluentParserBuilder<ItemDto> BuildParser(string folder)
source: "DATA[varies]", description: "Movement speed bonus / vehicle speed")
.Field(x => x.SpType, chunk => ImportSpType(chunk),
source: "DATA[varies] (SP only)", description: "SP transformation type")
.Field(x => x.SpecialistUpgradeMaterial, chunk => ImportSpecialistUpgradeMaterial(chunk),
source: "INDEX[7] (player SP only)", description: "Materials the SP upgrade window takes, by the card's morph")
.Field(x => x.PartnerSkillSet, chunk => ImportPartnerSkillSet(chunk),
source: "DATA[14] (partner SP only)", description: "Partner SP skill set: the UpgradeType shared by its three partner skills, one more than the raw value")
.Field(x => x.LevelJobMinimum, chunk => ImportLevelJobMinimum(chunk),
Expand Down Expand Up @@ -577,6 +579,22 @@ private byte ImportSpType(Dictionary<string, string[][]> chunk)
_ => "0"
});
}
// Cards up to morph 16 take souls, later ones dragon parts; the four cards of the other
// dimensions (55-58) take Dimensiolith shards on top.
private SpecialistUpgradeMaterial ImportSpecialistUpgradeMaterial(Dictionary<string, string[][]> chunk)
{
if (ImportItemType(chunk) != ItemType.Specialist || chunk["INDEX"][0][4] == "4")
{
return SpecialistUpgradeMaterial.None;
}

return Convert.ToInt16(chunk["INDEX"][0][7]) switch
{
<= 16 => SpecialistUpgradeMaterial.Souls,
>= 55 and <= 58 => SpecialistUpgradeMaterial.DragonPartsAndShards,
_ => SpecialistUpgradeMaterial.DragonParts,
};
}
private byte ImportPartnerSkillSet(Dictionary<string, string[][]> chunk)
{
return ImportItemType(chunk) == ItemType.Specialist && chunk["INDEX"][0][4] == "4"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public async Task FromPlusFifteenACardSpendsDragonGemsInsteadOfSouls()
[TestMethod]
public async Task FromPlusFifteenACardOfAnotherDimensionAlsoSpendsShards()
{
PlaceCard(upgrade: 15, spLevel: 99, morph: 55);
PlaceCard(upgrade: 15, spLevel: 99, SpecialistUpgradeMaterial.DragonPartsAndShards);
AddMaterials();
Roll(0.999);

Expand All @@ -201,12 +201,12 @@ public async Task FromPlusFifteenACardOfAnotherDimensionAlsoSpendsShards()
Assert.AreEqual(100 - 1, Count(UpgradeMaterials.VNum(MaterialType.DimensiolithShard)));
}

private void PlaceCard(byte upgrade, byte spLevel, short morph = 1)
private void PlaceCard(byte upgrade, byte spLevel, SpecialistUpgradeMaterial materials = SpecialistUpgradeMaterial.Souls)
{
_card = new SpecialistInstance(new Item
{
VNum = 901, Type = NoscorePocketType.Equipment, ItemType = ItemType.Specialist,
EquipmentSlot = EquipmentType.Sp, Morph = morph,
EquipmentSlot = EquipmentType.Sp, SpecialistUpgradeMaterial = materials,
})
{
Amount = 1,
Expand Down
18 changes: 18 additions & 0 deletions test/NosCore.Parser.Tests/ItemParserTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,24 @@ public async Task ItemParser_TheSpeedBoosterGrantsItsCardAndAnimation()
Assert.AreEqual(885, _savedItems.Single().EffectValue);
}

[TestMethod]
public async Task ItemParser_SpecialistCardsTakeSoulsDragonPartsOrShardsByTheirMorph()
{
CreateTestFile(string.Join("\n#========================================================\n",
CreateItemData(vnum: 901, indexSubType: 4, look: 1),
CreateItemData(vnum: 4485, indexSubType: 4, look: 30),
CreateItemData(vnum: 4800, indexSubType: 4, look: 55),
CreateItemData(vnum: 1, indexSubType: 1, look: 55)));

var parser = new ItemParser(_itemDaoMock.Object, _bCardDaoMock.Object, NullLoggerFactory.Instance, _logLanguageMock.Object);
await parser.ParseAsync(_tempFolder);

Assert.AreEqual(SpecialistUpgradeMaterial.Souls, _savedItems.Single(i => i.VNum == 901).SpecialistUpgradeMaterial);
Assert.AreEqual(SpecialistUpgradeMaterial.DragonParts, _savedItems.Single(i => i.VNum == 4485).SpecialistUpgradeMaterial);
Assert.AreEqual(SpecialistUpgradeMaterial.DragonPartsAndShards, _savedItems.Single(i => i.VNum == 4800).SpecialistUpgradeMaterial);
Assert.AreEqual(SpecialistUpgradeMaterial.None, _savedItems.Single(i => i.VNum == 1).SpecialistUpgradeMaterial);
}

[TestMethod]
public async Task ItemParser_BothSoundFlowersStartAFlowerQuest()
{
Expand Down