namespace Aeshnidae.AwakenedRewards;
///
/// The three server-only integer properties this mod reads and writes. None is in
/// ACE's PropertyInt enum, so none is ever sent to the client or shown in an
/// appraisal; they ride in the biota - saved, backed up and restored with the item
/// or character - which is exactly what a "done once" stamp needs.
///
/// 9040 belongs to Aeshnidae.Awakens and is only read here. 9041 is
/// InstancesNoDat's attribute-only creature marker. 9042 and 9043 are this mod's.
///
public static class Stamps
{
/// PropertyInt 9040 on a character: how many times it has awakened (Aeshnidae.Awakens).
public const PropertyInt Awakenings = (PropertyInt)9040;
///
/// PropertyInt 9042 on an attuned item: the awakening count it was scaled by when
/// it first became somebody's. Present-and-zero is a stamp too - the item was
/// looked at and left retail, and must not be scaled by a later owner's count.
///
public const PropertyInt QuestAwakeningTier = (PropertyInt)9042;
/// PropertyInt 9043 on a loot item: the tier of the copy it was rolled in.
public const PropertyInt LootAwakeningTier = (PropertyInt)9043;
public static int AwakeningsOf(Player? player) => player?.GetProperty(Awakenings) ?? 0;
/// " (Awakened N)" on the end of the name, once - a name that already carries it is left alone.
public static void StampName(WorldObject item, int n)
{
if (!Mod.Settings.StampNames || n <= 0)
return;
var name = item.Name ?? "";
var suffix = $" (Awakened {n})";
if (name.EndsWith(suffix, StringComparison.Ordinal) || name.Contains(" (Awakened ", StringComparison.Ordinal))
return;
item.Name = name + suffix;
}
}