708 lines
21 KiB
C#
708 lines
21 KiB
C#
using SCHALE.Common.FlatData;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Text.Json.Serialization;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace SCHALE.Common.Database
|
|
{
|
|
public class AccountDB
|
|
{
|
|
[JsonIgnore]
|
|
public virtual ICollection<ItemDB> Items { get; }
|
|
|
|
[JsonIgnore]
|
|
public virtual ICollection<CharacterDB> Characters { get; }
|
|
|
|
[JsonIgnore]
|
|
public virtual ICollection<MissionProgressDB> MissionProgresses { get; }
|
|
|
|
[JsonIgnore]
|
|
public virtual ICollection<EchelonDB> Echelons { get; }
|
|
|
|
[JsonIgnore]
|
|
public virtual ICollection<EquipmentDB> Equipment { get; }
|
|
|
|
[JsonIgnore]
|
|
public virtual ICollection<WeaponDB> Weapons { get; }
|
|
|
|
[JsonIgnore]
|
|
public virtual ICollection<GearDB> Gears { get; }
|
|
|
|
[JsonIgnore]
|
|
public virtual ICollection<MemoryLobbyDB> MemoryLobbies { get; }
|
|
|
|
[JsonIgnore]
|
|
public virtual ICollection<ScenarioHistoryDB> Scenarios { get; }
|
|
|
|
[JsonIgnore]
|
|
public virtual ICollection<CafeDB> Cafes { get; }
|
|
|
|
[JsonIgnore]
|
|
public virtual ICollection<FurnitureDB> Furnitures { get; }
|
|
|
|
[JsonIgnore]
|
|
public virtual ICollection<ScenarioGroupHistoryDB> ScenarioGroups { get; }
|
|
|
|
[JsonIgnore]
|
|
public virtual ICollection<AccountCurrencyDB> Currencies { get; }
|
|
|
|
[JsonIgnore]
|
|
public virtual ICollection<MultiFloorRaidDB> MultiFloorRaids { get; }
|
|
|
|
[JsonIgnore]
|
|
public virtual ICollection<WeekDungeonStageHistoryDB> WeekDungeonStageHistories { get; }
|
|
|
|
[JsonIgnore]
|
|
public virtual ICollection<SchoolDungeonStageHistoryDB> SchoolDungeonStageHistories { get; }
|
|
|
|
[JsonIgnore]
|
|
public virtual ICollection<CampaignStageHistoryDB> CampaignStageHistories { get; }
|
|
|
|
[JsonIgnore]
|
|
public virtual ICollection<MailDB> Mails { get; }
|
|
|
|
[JsonIgnore]
|
|
public virtual RaidInfo RaidInfo { get; set; }
|
|
|
|
public AccountDB()
|
|
{
|
|
Items = new List<ItemDB>();
|
|
Characters = new List<CharacterDB>();
|
|
MissionProgresses = new List<MissionProgressDB>();
|
|
Echelons = new List<EchelonDB>();
|
|
Equipment = new List<EquipmentDB>();
|
|
Weapons = new List<WeaponDB>();
|
|
Gears = new List<GearDB>();
|
|
MemoryLobbies = new List<MemoryLobbyDB>();
|
|
Scenarios = new List<ScenarioHistoryDB>();
|
|
Cafes = new List<CafeDB>();
|
|
Furnitures = new List<FurnitureDB>();
|
|
ScenarioGroups = new List<ScenarioGroupHistoryDB>();
|
|
Currencies = new List<AccountCurrencyDB>();
|
|
MultiFloorRaids = new List<MultiFloorRaidDB>();
|
|
WeekDungeonStageHistories = new List<WeekDungeonStageHistoryDB>();
|
|
SchoolDungeonStageHistories = new List<SchoolDungeonStageHistoryDB>();
|
|
CampaignStageHistories = new List<CampaignStageHistoryDB>();
|
|
Mails = new List<MailDB>();
|
|
}
|
|
|
|
public AccountDB(long publisherAccountId) : this()
|
|
{
|
|
PublisherAccountId = publisherAccountId;
|
|
State = AccountState.Normal;
|
|
Level = 1;
|
|
LastConnectTime = DateTime.Now;
|
|
CreateDate = DateTime.Now;
|
|
RaidInfo = new()
|
|
{
|
|
SeasonId = 1, // default
|
|
BestRankingPoint = 0,
|
|
TotalRankingPoint = 0,
|
|
};
|
|
}
|
|
|
|
[Key]
|
|
public long ServerId { get; set; }
|
|
|
|
public string? Nickname { get; set; }
|
|
public string? CallName { get; set; }
|
|
public string? DevId { get; set; }
|
|
public AccountState State { get; set; }
|
|
public int Level { get; set; }
|
|
public long Exp { get; set; }
|
|
public string? Comment { get; set; }
|
|
public int? LobbyMode { get; set; }
|
|
public long RepresentCharacterServerId { get; set; }
|
|
public long MemoryLobbyUniqueId { get; set; }
|
|
public DateTime LastConnectTime { get; set; }
|
|
public DateTime BirthDay { get; set; }
|
|
public DateTime CallNameUpdateTime { get; set; }
|
|
public long PublisherAccountId { get; set; }
|
|
public Nullable<int> RetentionDays { get; set; }
|
|
public Nullable<int> VIPLevel { get; set; }
|
|
public DateTime CreateDate { get; set; }
|
|
public Nullable<int> UnReadMailCount { get; set; }
|
|
public Nullable<DateTime> LinkRewardDate { get; set; }
|
|
}
|
|
|
|
public class FurnitureDB : ConsumableItemBaseDB
|
|
{
|
|
public override ParcelType Type { get => ParcelType.Furniture; }
|
|
|
|
[NotMapped]
|
|
[JsonIgnore]
|
|
public override IEnumerable<ParcelInfo> ParcelInfos { get; }
|
|
|
|
[JsonIgnore]
|
|
public override bool CanConsume { get => false; }
|
|
|
|
public FurnitureLocation Location { get; set; }
|
|
public long CafeDBId { get; set; }
|
|
public float PositionX { get; set; }
|
|
public float PositionY { get; set; }
|
|
public float Rotation { get; set; }
|
|
public long ItemDeploySequence { get; set; }
|
|
}
|
|
|
|
public class MissionProgressDB : IEquatable<MissionProgressDB>, IMemoryPackable<MissionProgressDB>, IMemoryPackFormatterRegister
|
|
{
|
|
[Key]
|
|
[JsonIgnore]
|
|
public long ServerId { get; set; }
|
|
|
|
[JsonIgnore]
|
|
public virtual AccountDB Account { get; set; }
|
|
|
|
[JsonIgnore]
|
|
public long AccountServerId { get; set; }
|
|
public long MissionUniqueId { get; set; }
|
|
public bool Complete { get; set; }
|
|
public DateTime StartTime { get; set; }
|
|
public Dictionary<long, long> ProgressParameters { get; set; } = [];
|
|
|
|
public bool Equals(MissionProgressDB other)
|
|
{
|
|
return default;
|
|
}
|
|
}
|
|
|
|
public abstract class ConsumableItemBaseDB : ParcelBase
|
|
{
|
|
[JsonIgnore]
|
|
public virtual AccountDB Account { get; set; }
|
|
|
|
[JsonIgnore]
|
|
public abstract bool CanConsume { get; }
|
|
|
|
[JsonIgnore]
|
|
public ParcelKeyPair Key { get; }
|
|
|
|
[JsonIgnore]
|
|
public long AccountServerId { get; set; }
|
|
|
|
[Key]
|
|
public long ServerId { get; set; }
|
|
|
|
public long UniqueId { get; set; }
|
|
public long StackCount { get; set; }
|
|
}
|
|
|
|
public class ItemDB : ConsumableItemBaseDB
|
|
{
|
|
[NotMapped]
|
|
public override ParcelType Type => ParcelType.Item;
|
|
|
|
[NotMapped]
|
|
[JsonIgnore]
|
|
public override IEnumerable<ParcelInfo> ParcelInfos { get; }
|
|
|
|
[NotMapped]
|
|
[JsonIgnore]
|
|
public override bool CanConsume => true;
|
|
}
|
|
|
|
public class CharacterDB : ParcelBase
|
|
{
|
|
[NotMapped]
|
|
public override ParcelType Type { get => ParcelType.Character; }
|
|
|
|
[JsonIgnore]
|
|
public virtual AccountDB Account { get; set; }
|
|
|
|
[JsonIgnore]
|
|
public long AccountServerId { get; set; }
|
|
|
|
[JsonIgnore]
|
|
[NotMapped]
|
|
public override IEnumerable<ParcelInfo> ParcelInfos { get; }
|
|
|
|
[Key]
|
|
public long ServerId { get; set; }
|
|
public long UniqueId { get; set; }
|
|
public int StarGrade { get; set; }
|
|
public int Level { get; set; }
|
|
public long Exp { get; set; }
|
|
public int FavorRank { get; set; }
|
|
public long FavorExp { get; set; }
|
|
public int PublicSkillLevel { get; set; }
|
|
public int ExSkillLevel { get; set; }
|
|
public int PassiveSkillLevel { get; set; }
|
|
public int ExtraPassiveSkillLevel { get; set; }
|
|
public int LeaderSkillLevel { get; set; }
|
|
public bool IsFavorite { get; set; }
|
|
public List<long> EquipmentServerIds { get; set; } = [];
|
|
public Dictionary<int, int> PotentialStats { get; set; } = [];
|
|
|
|
[JsonIgnore]
|
|
public Dictionary<int, long> EquipmentSlotAndDBIds { get; } = [];
|
|
}
|
|
|
|
public class EquipmentDB : ConsumableItemBaseDB
|
|
{
|
|
[NotMapped]
|
|
public override ParcelType Type { get => ParcelType.Equipment; }
|
|
|
|
[NotMapped]
|
|
[JsonIgnore]
|
|
public override IEnumerable<ParcelInfo> ParcelInfos { get; }
|
|
|
|
[JsonIgnore]
|
|
public override bool CanConsume { get => false; }
|
|
|
|
|
|
public int Level { get; set; }
|
|
public long Exp { get; set; }
|
|
public int Tier { get; set; }
|
|
public long BoundCharacterServerId { get; set; }
|
|
}
|
|
|
|
public class WeaponDB : ParcelBase
|
|
{
|
|
[NotMapped]
|
|
public override ParcelType Type { get => ParcelType.CharacterWeapon; }
|
|
|
|
[NotMapped]
|
|
[JsonIgnore]
|
|
public override IEnumerable<ParcelInfo> ParcelInfos { get; }
|
|
|
|
[JsonIgnore]
|
|
public virtual AccountDB Account { get; set; }
|
|
|
|
[JsonIgnore]
|
|
public long AccountServerId { get; set; }
|
|
|
|
[Key]
|
|
public long ServerId { get; set; }
|
|
|
|
public long UniqueId { get; set; }
|
|
public int Level { get; set; }
|
|
public long Exp { get; set; }
|
|
public int StarGrade { get; set; }
|
|
public long BoundCharacterServerId { get; set; }
|
|
}
|
|
|
|
public class GearDB : ParcelBase
|
|
{
|
|
[NotMapped]
|
|
public override ParcelType Type { get => ParcelType.CharacterGear; }
|
|
|
|
[NotMapped]
|
|
[JsonIgnore]
|
|
public override IEnumerable<ParcelInfo> ParcelInfos { get; }
|
|
|
|
[JsonIgnore]
|
|
public virtual AccountDB Account { get; set; }
|
|
|
|
[JsonIgnore]
|
|
public long AccountServerId { get; set; }
|
|
|
|
[Key]
|
|
public long ServerId { get; set; }
|
|
|
|
public long UniqueId { get; set; }
|
|
public int Level { get; set; }
|
|
public long Exp { get; set; }
|
|
public int Tier { get; set; }
|
|
public long SlotIndex { get; set; }
|
|
public long BoundCharacterServerId { get; set; }
|
|
|
|
[JsonIgnore]
|
|
public EquipmentDB ToEquipmentDB { get; }
|
|
}
|
|
|
|
public class MemoryLobbyDB : ParcelBase
|
|
{
|
|
public override ParcelType Type { get => ParcelType.MemoryLobby; }
|
|
|
|
[NotMapped]
|
|
[JsonIgnore]
|
|
public override IEnumerable<ParcelInfo> ParcelInfos { get; }
|
|
|
|
[JsonIgnore]
|
|
public virtual AccountDB Account { get; set; }
|
|
|
|
[JsonIgnore]
|
|
public long AccountServerId { get; set; }
|
|
|
|
[Key]
|
|
public long ServerId { get; set; }
|
|
|
|
public long MemoryLobbyUniqueId { get; set; }
|
|
}
|
|
|
|
public class ScenarioHistoryDB
|
|
{
|
|
[JsonIgnore]
|
|
public virtual AccountDB Account { get; set; }
|
|
|
|
[JsonIgnore]
|
|
public long AccountServerId { get; set; }
|
|
|
|
[Key]
|
|
public long ServerId { get; set; }
|
|
|
|
|
|
public long ScenarioUniqueId { get; set; }
|
|
public DateTime ClearDateTime { get; set; }
|
|
}
|
|
|
|
public class ScenarioGroupHistoryDB
|
|
{
|
|
[JsonIgnore]
|
|
public virtual AccountDB Account { get; set; }
|
|
|
|
[JsonIgnore]
|
|
public long AccountServerId { get; set; }
|
|
|
|
[Key]
|
|
public long ServerId { get; set; }
|
|
|
|
public long ScenarioGroupUqniueId { get; set; }
|
|
public long ScenarioType { get; set; }
|
|
public Nullable<long> EventContentId { get; set; }
|
|
public DateTime ClearDateTime { get; set; }
|
|
public bool IsReturn { get; set; }
|
|
}
|
|
|
|
public class EchelonDB
|
|
{
|
|
[Key]
|
|
[JsonIgnore]
|
|
public long ServerId { get; set; }
|
|
|
|
[JsonIgnore]
|
|
public virtual AccountDB Account { get; set; }
|
|
|
|
[JsonIgnore]
|
|
public long AccountServerId { get; set; }
|
|
|
|
public EchelonType EchelonType { get; set; }
|
|
public long EchelonNumber { get; set; }
|
|
public EchelonExtensionType ExtensionType { get; set; }
|
|
public long LeaderServerId { get; set; }
|
|
|
|
[JsonIgnore]
|
|
public int MainSlotCount { get; }
|
|
|
|
[JsonIgnore]
|
|
public int SupportSlotCount { get; }
|
|
public List<long> MainSlotServerIds { get; set; } = [];
|
|
public List<long> SupportSlotServerIds { get; set; } = [];
|
|
public long TSSInteractionServerId { get; set; }
|
|
public EchelonStatusFlag UsingFlag { get; set; }
|
|
|
|
[JsonIgnore]
|
|
public bool IsUsing { get; }
|
|
|
|
[JsonIgnore]
|
|
public List<long> AllCharacterServerIds { get; } = [];
|
|
|
|
[JsonIgnore]
|
|
public List<long> AllCharacterWithoutTSSServerIds { get; } = [];
|
|
|
|
[JsonIgnore]
|
|
public List<long> AllCharacterWithEmptyServerIds { get; } = [];
|
|
|
|
[JsonIgnore]
|
|
public List<long> BattleCharacterServerIds { get; } = [];
|
|
public List<long> SkillCardMulliganCharacterIds { get; set; } = [];
|
|
public int[] CombatStyleIndex { get; set; } = [];
|
|
}
|
|
|
|
public class CampaignSubStageSaveDB : ContentSaveDB
|
|
{
|
|
public override ContentType ContentType { get => ContentType.CampaignSubStage; }
|
|
}
|
|
|
|
public class CampaignTutorialStageSaveDB : ContentSaveDB
|
|
{
|
|
public override ContentType ContentType { get => ContentType.CampaignTutorialStage; }
|
|
}
|
|
|
|
public class CafeDB
|
|
{
|
|
[JsonIgnore]
|
|
public virtual AccountDB Account { get; set; }
|
|
|
|
[JsonIgnore]
|
|
public long AccountServerId { get; set; }
|
|
|
|
[Key]
|
|
public long CafeDBId { get; set; }
|
|
public long CafeId { get; set; }
|
|
public long AccountId { get; set; }
|
|
public int CafeRank { get; set; }
|
|
public DateTime LastUpdate { get; set; }
|
|
public Nullable<DateTime> LastSummonDate { get; set; }
|
|
|
|
[NotMapped]
|
|
public bool IsNew { get; set; }
|
|
|
|
public Dictionary<long, CafeCharacterDB> CafeVisitCharacterDBs { get; set; }
|
|
|
|
[NotMapped]
|
|
public List<FurnitureDB> FurnitureDBs { get => Account.Furnitures.Where(x => x.CafeDBId == CafeDBId).ToList(); }
|
|
|
|
public DateTime ProductionAppliedTime { get; set; }
|
|
[NotMapped]
|
|
public CafeProductionDB ProductionDB
|
|
{
|
|
get => new()
|
|
{
|
|
CafeDBId = 1,
|
|
AppliedDate = DateTime.UtcNow,
|
|
ProductionParcelInfos = [
|
|
new(){ Key = new ParcelKeyPair { Type = ParcelType.Currency, Id = 1 } }, // id 1
|
|
new() { Key = new ParcelKeyPair { Type = ParcelType.Currency, Id = 5 } }
|
|
],
|
|
};
|
|
}
|
|
|
|
[JsonIgnore]
|
|
public Dictionary<CurrencyTypes, long> CurrencyDict_Obsolete { get; set; } = new Dictionary<CurrencyTypes, long>();
|
|
|
|
[JsonIgnore]
|
|
public Dictionary<CurrencyTypes, DateTime> UpdateTimeDict_Obsolete { get; set; } = new Dictionary<CurrencyTypes, DateTime>();
|
|
}
|
|
|
|
public class RaidInfo // custom class for all raid stuff needed
|
|
{
|
|
public long SeasonId { get; set; }
|
|
|
|
public long CurrentRaidUniqueId { get; set; }
|
|
|
|
public Difficulty CurrentDifficulty { get; set; }
|
|
|
|
public long BestRankingPoint { get; set; }
|
|
|
|
public long TotalRankingPoint { get; set; }
|
|
}
|
|
|
|
public class AcademyDB
|
|
{
|
|
public long AccountId { get; set; }
|
|
|
|
public DateTime LastUpdate { get; set; }
|
|
public Dictionary<long, List<VisitingCharacterDB>> ZoneVisitCharacterDBs { get; set; }
|
|
public Dictionary<long, List<long>> ZoneScheduleGroupRecords { get; set; }
|
|
}
|
|
|
|
public class CampaignStageHistoryDB
|
|
{
|
|
[JsonIgnore]
|
|
public virtual AccountDB Account { get; set; }
|
|
|
|
[JsonIgnore]
|
|
public long AccountServerId { get; set; }
|
|
|
|
[Key]
|
|
public long ServerId { get; set; }
|
|
|
|
public long StoryUniqueId { get; set; }
|
|
public long ChapterUniqueId { get; set; }
|
|
public long StageUniqueId { get; set; }
|
|
public long TacticClearCountWithRankSRecord { get; set; }
|
|
public long ClearTurnRecord { get; set; }
|
|
|
|
[JsonIgnore]
|
|
public long BestStarRecord { get; }
|
|
public bool Star1Flag { get; set; }
|
|
public bool Star2Flag { get; set; }
|
|
public bool Star3Flag { get; set; }
|
|
public DateTime LastPlay { get; set; }
|
|
public long TodayPlayCount { get; set; }
|
|
public long TodayPurchasePlayCountHardStage { get; set; }
|
|
public Nullable<DateTime> FirstClearRewardReceive { get; set; }
|
|
public Nullable<DateTime> StarRewardReceive { get; set; }
|
|
|
|
[JsonIgnore]
|
|
public bool IsClearedEver { get; }
|
|
public long TodayPlayCountForUI { get; }
|
|
}
|
|
|
|
public class MailDB
|
|
{
|
|
[JsonIgnore]
|
|
public virtual AccountDB Account { get; set; }
|
|
|
|
[Key]
|
|
public long ServerId { get; set; }
|
|
|
|
[JsonIgnore]
|
|
public long AccountServerId { get; set; }
|
|
|
|
public MailType Type { get; set; }
|
|
public long UniqueId { get; set; }
|
|
public string Sender { get; set; }
|
|
public string Comment { get; set; }
|
|
public DateTime SendDate { get; set; }
|
|
public Nullable<DateTime> ReceiptDate { get; set; }
|
|
public Nullable<DateTime> ExpireDate { get; set; }
|
|
|
|
[NotMapped] // TODO: implement storing these two with ef core, this is very nessary since these parcel infos are the items given in the mail, must be stored
|
|
public List<ParcelInfo> ParcelInfos { get; set; } // remove [NotMapped] if implemented storing
|
|
|
|
[NotMapped]
|
|
public List<ParcelInfo> RemainParcelInfos { get; set; }
|
|
}
|
|
|
|
public class CampaignChapterClearRewardHistoryDB
|
|
{
|
|
public long AccountServerId { get; set; }
|
|
|
|
public long ChapterUniqueId { get; set; }
|
|
public StageDifficulty RewardType { get; set; }
|
|
public DateTime ReceiveDate { get; set; }
|
|
}
|
|
|
|
public class AccountCurrencyDB
|
|
{
|
|
[JsonIgnore]
|
|
public virtual AccountDB Account { get; set; }
|
|
|
|
[JsonIgnore]
|
|
public long AccountServerId { get; set; }
|
|
|
|
[Key]
|
|
public long ServerId { get; set; }
|
|
|
|
public long AccountLevel { get; set; }
|
|
public long AcademyLocationRankSum { get; set; }
|
|
public Dictionary<CurrencyTypes, long> CurrencyDict { get; set; }
|
|
public Dictionary<CurrencyTypes, DateTime> UpdateTimeDict { get; set; }
|
|
}
|
|
|
|
public class MultiFloorRaidDB
|
|
{
|
|
[JsonIgnore]
|
|
public virtual AccountDB Account { get; set; }
|
|
|
|
[JsonIgnore]
|
|
public long AccountServerId { get; set; }
|
|
|
|
[Key]
|
|
public long ServerId { get; set; }
|
|
|
|
public long SeasonId { get; set; }
|
|
public int ClearedDifficulty { get; set; }
|
|
public DateTime LastClearDate { get; set; }
|
|
public int RewardDifficulty { get; set; }
|
|
public DateTime LastRewardDate { get; set; }
|
|
public int ClearBattleFrame { get; set; }
|
|
|
|
[JsonIgnore]
|
|
public bool AllCleared { get; } = false;
|
|
|
|
[JsonIgnore]
|
|
public bool HasReceivableRewards { get; } = false;
|
|
|
|
[JsonIgnore]
|
|
public List<ParcelInfo> TotalReceivableRewards { get; } = new List<ParcelInfo>();
|
|
|
|
[JsonIgnore]
|
|
public List<ParcelInfo> TotalReceivedRewards { get; } = new List<ParcelInfo>();
|
|
}
|
|
|
|
public class WeekDungeonStageHistoryDB
|
|
{
|
|
[JsonIgnore]
|
|
public virtual AccountDB Account { get; set; }
|
|
|
|
[Key]
|
|
public long ServerId { get; set; }
|
|
[JsonIgnore]
|
|
public long AccountServerId { get; set; }
|
|
|
|
public long StageUniqueId { get; set; }
|
|
public Dictionary<StarGoalType, long> StarGoalRecord { get; set; }
|
|
|
|
[JsonIgnore]
|
|
public bool IsCleardEver { get; }
|
|
}
|
|
|
|
public class SchoolDungeonStageHistoryDB
|
|
{
|
|
[JsonIgnore]
|
|
public virtual AccountDB Account { get; set; }
|
|
|
|
[JsonIgnore]
|
|
public long AccountServerId { get; set; }
|
|
|
|
[Key]
|
|
public long ServerId { get; set; }
|
|
|
|
public long StageUniqueId { get; set; }
|
|
|
|
[JsonIgnore]
|
|
public long BestStarRecord { get; }
|
|
public bool[] StarFlags { get; set; }
|
|
|
|
[JsonIgnore]
|
|
public bool Star1Flag { get; }
|
|
|
|
[JsonIgnore]
|
|
public bool Star2Flag { get; }
|
|
|
|
[JsonIgnore]
|
|
public bool Star3Flag { get; }
|
|
|
|
[JsonIgnore]
|
|
public bool IsClearedEver { get; }
|
|
}
|
|
|
|
[Serializable]
|
|
public struct BasisPoint : IEquatable<BasisPoint>, IComparable<BasisPoint>
|
|
{
|
|
private static readonly long Multiplier;
|
|
private static readonly double OneOver10_4 = 1.0 / 10000.0;
|
|
public static readonly BasisPoint Zero;
|
|
public static readonly BasisPoint One;
|
|
public static readonly BasisPoint Epsilon;
|
|
public static readonly double DoubleEpsilon;
|
|
|
|
[JsonIgnore]
|
|
public long RawValue { get; }
|
|
|
|
private long rawValue;
|
|
public BasisPoint(long rawValue)
|
|
{
|
|
this.rawValue = rawValue;
|
|
}
|
|
public bool Equals(BasisPoint other)
|
|
{
|
|
return this.rawValue == other.rawValue;
|
|
}
|
|
|
|
public int CompareTo(BasisPoint other)
|
|
{
|
|
return rawValue.CompareTo(other.rawValue);
|
|
}
|
|
|
|
public static long operator *(long value, BasisPoint other)
|
|
{
|
|
return MultiplyLong(value, other);
|
|
}
|
|
|
|
public static long MultiplyLong(long value, BasisPoint other)
|
|
{
|
|
double result = OneOver10_4 * ((double)other.rawValue * value);
|
|
|
|
if (double.IsInfinity(result))
|
|
return long.MaxValue;
|
|
|
|
return (long)result;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|