Skip to content

Commit

Permalink
fix: Codegens ToT and replaces persistence with config (#1524)
Browse files Browse the repository at this point in the history
  • Loading branch information
kamronbatman authored Sep 30, 2023
1 parent 5ea5fb4 commit 7d05e3b
Show file tree
Hide file tree
Showing 40 changed files with 1,252 additions and 1,736 deletions.
418 changes: 180 additions & 238 deletions Projects/UOContent/Engines/Treasures of Tokuno/BasePigmentsOfTokuno.cs

Large diffs are not rendered by default.

767 changes: 288 additions & 479 deletions Projects/UOContent/Engines/Treasures of Tokuno/GreaterArtifacts.cs

Large diffs are not rendered by default.

1,453 changes: 521 additions & 932 deletions Projects/UOContent/Engines/Treasures of Tokuno/LesserArtifacts.cs

Large diffs are not rendered by default.

73 changes: 51 additions & 22 deletions Projects/UOContent/Engines/Treasures of Tokuno/TreasuresOfTokuno.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using ModernUO.Serialization;
using Server.Gumps;
using Server.Items;
using Server.Json;
using Server.Misc;
using Server.Mobiles;
using Server.Multis;
Expand All @@ -20,8 +23,15 @@ public enum TreasuresOfTokunoEra
ToTThree
}

public class ToTConfig
{
public TreasuresOfTokunoEra DropEra { get; set; }
public TreasuresOfTokunoEra RewardEra { get; set; }
}

public static class TreasuresOfTokuno
{
public const string ToTConfigurationPath = "Configuration/tot.json";
public const int ItemsPerReward = 10;

private static readonly Type[][] m_LesserArtifacts =
Expand Down Expand Up @@ -86,9 +96,45 @@ public static class TreasuresOfTokuno
typeof(BaseFormTalisman), typeof(BaseWand), typeof(JesterHatofChuckles)
};

public static TreasuresOfTokunoEra DropEra { get; set; } = TreasuresOfTokunoEra.None;
public static void Configure()
{
var pathToTFile = Path.Combine(Core.BaseDirectory, ToTConfigurationPath);
_totConfig = File.Exists(pathToTFile)
? JsonConfig.Deserialize<ToTConfig>(pathToTFile)
: new ToTConfig
{
DropEra = TreasuresOfTokunoEra.None,
RewardEra = TreasuresOfTokunoEra.ToTOne,
};
}

private static ToTConfig _totConfig;

public static TreasuresOfTokunoEra DropEra
{
get => _totConfig.DropEra;
set
{
_totConfig.DropEra = value;
SaveConfiguration();
}
}

public static TreasuresOfTokunoEra RewardEra
{
get => _totConfig.RewardEra;
set
{
_totConfig.RewardEra = value;
SaveConfiguration();
}
}

public static TreasuresOfTokunoEra RewardEra { get; set; } = TreasuresOfTokunoEra.ToTOne;
private static void SaveConfiguration()
{
var pathToTFile = Path.Combine(Core.BaseDirectory, ToTConfigurationPath);
JsonConfig.Serialize(pathToTFile, _totConfig);
}

public static Type[] LesserArtifacts => m_LesserArtifacts[(int)RewardEra - 1];

Expand Down Expand Up @@ -203,7 +249,8 @@ public static void HandleKill(Mobile victim, Mobile killer)

namespace Server.Mobiles
{
public class IharaSoko : BaseVendor
[SerializationGenerator(0, false)]
public partial class IharaSoko : BaseVendor
{
protected List<SBInfo> m_SBInfos = new();

Expand All @@ -215,10 +262,6 @@ public IharaSoko() : base("the Imperial Minister of Trade")
Hue = 0x8403;
}

public IharaSoko(Serial serial) : base(serial)
{
}

public override bool IsActiveVendor => false;
public override bool IsInvulnerable => true;
public override bool DisallowAllMoves => true;
Expand All @@ -243,20 +286,6 @@ public override void InitOutfit()
AddItem(item);
}

public override void Serialize(IGenericWriter writer)
{
base.Serialize(writer);

writer.Write(0);
}

public override void Deserialize(IGenericReader reader)
{
base.Deserialize(reader);

var version = reader.ReadInt();
}

public override bool CanBeDamaged() => false;

public override void OnMovement(Mobile m, Point3D oldLocation)
Expand Down Expand Up @@ -302,7 +331,7 @@ public override void OnMovement(Mobile m, Point3D oldLocation)
}
}

var leaveRange = 7;
const int leaveRange = 7;

if (!InRange(m, leaveRange) && InRange(oldLocation, leaveRange))
{
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System;

namespace Server.Misc;

[ManualDirtyChecking]
[TypeAlias("Server.Misc.TreasuresOfTokunoPersistance")]
[Obsolete("Deprecated in favor of a configuration file. Only used for legacy deserialization")]
public class TreasuresOfTokunoPersistence : Item
{
public TreasuresOfTokunoPersistence() : base(1) => Movable = false;

public TreasuresOfTokunoPersistence(Serial serial) : base(serial)
{
}

public override void Serialize(IGenericWriter writer)
{
base.Serialize(writer);
}

public override void Deserialize(IGenericReader reader)
{
base.Deserialize(reader);

var version = reader.ReadInt();

TreasuresOfTokuno.RewardEra = (TreasuresOfTokunoEra)reader.ReadEncodedInt();
TreasuresOfTokuno.DropEra = (TreasuresOfTokunoEra)reader.ReadEncodedInt();

Timer.DelayCall(Delete);
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions Projects/UOContent/Migrations/Server.Items.AncientUrn.v0.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Projects/UOContent/Migrations/Server.Items.DemonForks.v0.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Projects/UOContent/Migrations/Server.Items.Exiler.v0.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Projects/UOContent/Migrations/Server.Items.HanzosBow.v0.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions Projects/UOContent/Migrations/Server.Items.HonorableSwords.v0.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 7d05e3b

Please sign in to comment.