linkWithShip.jsonl
Schema
_key(required): integer
Range: 60244 .. 92183applyPvpFlag(required): booleancanRelink(required): booleancharacterEnergyCost: number
Range: 25 .. 33dbuffPostLinkDuration(required): integer
Range: 0 .. 60-
dbuffs(required): array of object_key(required): integer
Range: 3 .. 2428_value(required): number
Range: -100 .. 1000
-
generateCynoInhibitor(required): boolean keepDbuffDurationOnLinkBreak(required): booleanlinkDuration(required): integer
Range: 240 .. 600linkEffectGraphicIDOverride(required): integer
Range: 25030 .. 25114linkableShipTypeListID(required): integer
Range: 300 .. 946maxLinkRange(required): integer
Range: 5000 .. 30000omegaOnly(required): booleansolarsystemInterferenceCost: number
Range: 500 .. 550
Code snippets
// <auto-generated />
//
// To parse this JSON data, add NuGet 'System.Text.Json' then do:
//
// using QuickType;
//
// var linkWithShip = LinkWithShip.FromJson(jsonString);
#nullable enable
#pragma warning disable CS8618
#pragma warning disable CS8601
#pragma warning disable CS8602
#pragma warning disable CS8603
namespace QuickType
{
using System;
using System.Collections.Generic;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Globalization;
public partial class LinkWithShip
{
[JsonPropertyName("_key")]
public long Key { get; set; }
[JsonPropertyName("applyPvpFlag")]
public bool ApplyPvpFlag { get; set; }
[JsonPropertyName("canRelink")]
public bool CanRelink { get; set; }
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
[JsonPropertyName("characterEnergyCost")]
[JsonConverter(typeof(PurpleMinMaxValueCheckConverter))]
public double? CharacterEnergyCost { get; set; }
[JsonPropertyName("dbuffPostLinkDuration")]
public long DbuffPostLinkDuration { get; set; }
[JsonPropertyName("dbuffs")]
public Dbuff[] Dbuffs { get; set; }
[JsonPropertyName("generateCynoInhibitor")]
public bool GenerateCynoInhibitor { get; set; }
[JsonPropertyName("keepDbuffDurationOnLinkBreak")]
public bool KeepDbuffDurationOnLinkBreak { get; set; }
[JsonPropertyName("linkableShipTypeListID")]
public long LinkableShipTypeListId { get; set; }
[JsonPropertyName("linkDuration")]
public long LinkDuration { get; set; }
[JsonPropertyName("linkEffectGraphicIDOverride")]
public long LinkEffectGraphicIdOverride { get; set; }
[JsonPropertyName("maxLinkRange")]
public long MaxLinkRange { get; set; }
[JsonPropertyName("omegaOnly")]
public bool OmegaOnly { get; set; }
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
[JsonPropertyName("solarsystemInterferenceCost")]
[JsonConverter(typeof(TentacledMinMaxValueCheckConverter))]
public double? SolarsystemInterferenceCost { get; set; }
}
public partial class Dbuff
{
[JsonPropertyName("_key")]
public long Key { get; set; }
[JsonPropertyName("_value")]
[JsonConverter(typeof(FluffyMinMaxValueCheckConverter))]
public double Value { get; set; }
}
public partial class LinkWithShip
{
public static LinkWithShip FromJson(string json) => JsonSerializer.Deserialize<LinkWithShip>(json, QuickType.Converter.Settings);
}
public static class Serialize
{
public static string ToJson(this LinkWithShip self) => JsonSerializer.Serialize(self, QuickType.Converter.Settings);
}
internal static class Converter
{
public static readonly JsonSerializerOptions Settings = new(JsonSerializerDefaults.General)
{
Converters =
{
new DateOnlyConverter(),
new TimeOnlyConverter(),
IsoDateTimeOffsetConverter.Singleton
},
};
}
internal class PurpleMinMaxValueCheckConverter : JsonConverter<double>
{
public override bool CanConvert(Type t) => t == typeof(double);
public override double Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
var value = reader.GetDouble();
if (value >= 25 && value <= 33)
{
return value;
}
throw new Exception("Cannot unmarshal type double");
}
public override void Write(Utf8JsonWriter writer, double value, JsonSerializerOptions options)
{
if (value >= 25 && value <= 33)
{
JsonSerializer.Serialize(writer, value, options);
return;
}
throw new Exception("Cannot marshal type double");
}
public static readonly PurpleMinMaxValueCheckConverter Singleton = new PurpleMinMaxValueCheckConverter();
}
internal class FluffyMinMaxValueCheckConverter : JsonConverter<double>
{
public override bool CanConvert(Type t) => t == typeof(double);
public override double Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
var value = reader.GetDouble();
if (value >= -100 && value <= 1000)
{
return value;
}
throw new Exception("Cannot unmarshal type double");
}
public override void Write(Utf8JsonWriter writer, double value, JsonSerializerOptions options)
{
if (value >= -100 && value <= 1000)
{
JsonSerializer.Serialize(writer, value, options);
return;
}
throw new Exception("Cannot marshal type double");
}
public static readonly FluffyMinMaxValueCheckConverter Singleton = new FluffyMinMaxValueCheckConverter();
}
internal class TentacledMinMaxValueCheckConverter : JsonConverter<double>
{
public override bool CanConvert(Type t) => t == typeof(double);
public override double Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
var value = reader.GetDouble();
if (value >= 500 && value <= 550)
{
return value;
}
throw new Exception("Cannot unmarshal type double");
}
public override void Write(Utf8JsonWriter writer, double value, JsonSerializerOptions options)
{
if (value >= 500 && value <= 550)
{
JsonSerializer.Serialize(writer, value, options);
return;
}
throw new Exception("Cannot marshal type double");
}
public static readonly TentacledMinMaxValueCheckConverter Singleton = new TentacledMinMaxValueCheckConverter();
}
public class DateOnlyConverter : JsonConverter<DateOnly>
{
private readonly string serializationFormat;
public DateOnlyConverter() : this(null) { }
public DateOnlyConverter(string? serializationFormat)
{
this.serializationFormat = serializationFormat ?? "yyyy-MM-dd";
}
public override DateOnly Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
var value = reader.GetString();
return DateOnly.Parse(value!);
}
public override void Write(Utf8JsonWriter writer, DateOnly value, JsonSerializerOptions options)
=> writer.WriteStringValue(value.ToString(serializationFormat));
}
public class TimeOnlyConverter : JsonConverter<TimeOnly>
{
private readonly string serializationFormat;
public TimeOnlyConverter() : this(null) { }
public TimeOnlyConverter(string? serializationFormat)
{
this.serializationFormat = serializationFormat ?? "HH:mm:ss.fff";
}
public override TimeOnly Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
var value = reader.GetString();
return TimeOnly.Parse(value!);
}
public override void Write(Utf8JsonWriter writer, TimeOnly value, JsonSerializerOptions options)
=> writer.WriteStringValue(value.ToString(serializationFormat));
}
internal class IsoDateTimeOffsetConverter : JsonConverter<DateTimeOffset>
{
public override bool CanConvert(Type t) => t == typeof(DateTimeOffset);
private const string DefaultDateTimeFormat = "yyyy'-'MM'-'dd'T'HH':'mm':'ss.FFFFFFFK";
private DateTimeStyles _dateTimeStyles = DateTimeStyles.RoundtripKind;
private string? _dateTimeFormat;
private CultureInfo? _culture;
public DateTimeStyles DateTimeStyles
{
get => _dateTimeStyles;
set => _dateTimeStyles = value;
}
public string? DateTimeFormat
{
get => _dateTimeFormat ?? string.Empty;
set => _dateTimeFormat = (string.IsNullOrEmpty(value)) ? null : value;
}
public CultureInfo Culture
{
get => _culture ?? CultureInfo.CurrentCulture;
set => _culture = value;
}
public override void Write(Utf8JsonWriter writer, DateTimeOffset value, JsonSerializerOptions options)
{
string text;
if ((_dateTimeStyles & DateTimeStyles.AdjustToUniversal) == DateTimeStyles.AdjustToUniversal
|| (_dateTimeStyles & DateTimeStyles.AssumeUniversal) == DateTimeStyles.AssumeUniversal)
{
value = value.ToUniversalTime();
}
text = value.ToString(_dateTimeFormat ?? DefaultDateTimeFormat, Culture);
writer.WriteStringValue(text);
}
public override DateTimeOffset Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
string? dateText = reader.GetString();
if (string.IsNullOrEmpty(dateText) == false)
{
if (!string.IsNullOrEmpty(_dateTimeFormat))
{
return DateTimeOffset.ParseExact(dateText, _dateTimeFormat, Culture, _dateTimeStyles);
}
else
{
return DateTimeOffset.Parse(dateText, Culture, _dateTimeStyles);
}
}
else
{
return default(DateTimeOffset);
}
}
public static readonly IsoDateTimeOffsetConverter Singleton = new IsoDateTimeOffsetConverter();
}
}
#pragma warning restore CS8618
#pragma warning restore CS8601
#pragma warning restore CS8602
#pragma warning restore CS8603
// Code generated from JSON Schema using quicktype. DO NOT EDIT.
// To parse and unparse this JSON data, add this code to your project and do:
//
// linkWithShip, err := UnmarshalLinkWithShip(bytes)
// bytes, err = linkWithShip.Marshal()
package model
import "encoding/json"
func UnmarshalLinkWithShip(data []byte) (LinkWithShip, error) {
var r LinkWithShip
err := json.Unmarshal(data, &r)
return r, err
}
func (r *LinkWithShip) Marshal() ([]byte, error) {
return json.Marshal(r)
}
type LinkWithShip struct {
Key int64 `json:"_key"`
ApplyPvpFlag bool `json:"applyPvpFlag"`
CanRelink bool `json:"canRelink"`
CharacterEnergyCost *float64 `json:"characterEnergyCost,omitempty"`
DbuffPostLinkDuration int64 `json:"dbuffPostLinkDuration"`
Dbuffs []Dbuff `json:"dbuffs"`
GenerateCynoInhibitor bool `json:"generateCynoInhibitor"`
KeepDbuffDurationOnLinkBreak bool `json:"keepDbuffDurationOnLinkBreak"`
LinkableShipTypeListID int64 `json:"linkableShipTypeListID"`
LinkDuration int64 `json:"linkDuration"`
LinkEffectGraphicIDOverride int64 `json:"linkEffectGraphicIDOverride"`
MaxLinkRange int64 `json:"maxLinkRange"`
OmegaOnly bool `json:"omegaOnly"`
SolarsystemInterferenceCost *float64 `json:"solarsystemInterferenceCost,omitempty"`
}
type Dbuff struct {
Key int64 `json:"_key"`
Value float64 `json:"_value"`
}
{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"_key":{"type":"integer","minimum":60244,"maximum":92183},"applyPvpFlag":{"type":"boolean"},"canRelink":{"type":"boolean"},"characterEnergyCost":{"type":"number","minimum":25.0,"maximum":33.0},"dbuffPostLinkDuration":{"type":"integer","minimum":0,"maximum":60},"dbuffs":{"type":"array","items":{"type":"object","properties":{"_key":{"type":"integer","minimum":3,"maximum":2428},"_value":{"type":"number","minimum":-100.0,"maximum":1000.0}},"required":["_key","_value"]},"minItems":2,"maxItems":6},"generateCynoInhibitor":{"type":"boolean"},"keepDbuffDurationOnLinkBreak":{"type":"boolean"},"linkDuration":{"type":"integer","minimum":240,"maximum":600},"linkEffectGraphicIDOverride":{"type":"integer","minimum":25030,"maximum":25114},"linkableShipTypeListID":{"type":"integer","minimum":300,"maximum":946},"maxLinkRange":{"type":"integer","minimum":5000,"maximum":30000},"omegaOnly":{"type":"boolean"},"solarsystemInterferenceCost":{"type":"number","minimum":500.0,"maximum":550.0}},"required":["_key","applyPvpFlag","canRelink","dbuffPostLinkDuration","dbuffs","generateCynoInhibitor","keepDbuffDurationOnLinkBreak","linkDuration","linkEffectGraphicIDOverride","linkableShipTypeListID","maxLinkRange","omegaOnly"]}
// To parse the JSON, install kotlin's serialization plugin and do:
//
// val json = Json { allowStructuredMapKeys = true }
// val linkWithShip = json.parse(LinkWithShip.serializer(), jsonString)
package model
import kotlinx.serialization.*
import kotlinx.serialization.json.*
import kotlinx.serialization.descriptors.*
import kotlinx.serialization.encoding.*
@Serializable
data class LinkWithShip (
@SerialName("_key")
val key: Long,
val applyPvpFlag: Boolean,
val canRelink: Boolean,
val characterEnergyCost: Double? = null,
val dbuffPostLinkDuration: Long,
val dbuffs: List<Dbuff>,
val generateCynoInhibitor: Boolean,
val keepDbuffDurationOnLinkBreak: Boolean,
@SerialName("linkableShipTypeListID")
val linkableShipTypeListId: Long,
val linkDuration: Long,
@SerialName("linkEffectGraphicIDOverride")
val linkEffectGraphicIdOverride: Long,
val maxLinkRange: Long,
val omegaOnly: Boolean,
val solarsystemInterferenceCost: Double? = null
)
@Serializable
data class Dbuff (
@SerialName("_key")
val key: Long,
@SerialName("_value")
val value: Double
)
<?php
// This is an autogenerated file:LinkWithShip
class LinkWithShip {
private int $key; // json:_key Required
private bool $applyPvpFlag; // json:applyPvpFlag Required
private bool $canRelink; // json:canRelink Required
private ?float $characterEnergyCost; // json:characterEnergyCost Optional
private int $dbuffPostLinkDuration; // json:dbuffPostLinkDuration Required
private array $dbuffs; // json:dbuffs Required
private bool $generateCynoInhibitor; // json:generateCynoInhibitor Required
private bool $keepDbuffDurationOnLinkBreak; // json:keepDbuffDurationOnLinkBreak Required
private int $linkableShipTypeListId; // json:linkableShipTypeListID Required
private int $linkDuration; // json:linkDuration Required
private int $linkEffectGraphicIdOverride; // json:linkEffectGraphicIDOverride Required
private int $maxLinkRange; // json:maxLinkRange Required
private bool $omegaOnly; // json:omegaOnly Required
private ?float $solarsystemInterferenceCost; // json:solarsystemInterferenceCost Optional
/**
* @param int $key
* @param bool $applyPvpFlag
* @param bool $canRelink
* @param float|null $characterEnergyCost
* @param int $dbuffPostLinkDuration
* @param array $dbuffs
* @param bool $generateCynoInhibitor
* @param bool $keepDbuffDurationOnLinkBreak
* @param int $linkableShipTypeListId
* @param int $linkDuration
* @param int $linkEffectGraphicIdOverride
* @param int $maxLinkRange
* @param bool $omegaOnly
* @param float|null $solarsystemInterferenceCost
*/
public function __construct(int $key, bool $applyPvpFlag, bool $canRelink, ?float $characterEnergyCost, int $dbuffPostLinkDuration, array $dbuffs, bool $generateCynoInhibitor, bool $keepDbuffDurationOnLinkBreak, int $linkableShipTypeListId, int $linkDuration, int $linkEffectGraphicIdOverride, int $maxLinkRange, bool $omegaOnly, ?float $solarsystemInterferenceCost) {
$this->key = $key;
$this->applyPvpFlag = $applyPvpFlag;
$this->canRelink = $canRelink;
$this->characterEnergyCost = $characterEnergyCost;
$this->dbuffPostLinkDuration = $dbuffPostLinkDuration;
$this->dbuffs = $dbuffs;
$this->generateCynoInhibitor = $generateCynoInhibitor;
$this->keepDbuffDurationOnLinkBreak = $keepDbuffDurationOnLinkBreak;
$this->linkableShipTypeListId = $linkableShipTypeListId;
$this->linkDuration = $linkDuration;
$this->linkEffectGraphicIdOverride = $linkEffectGraphicIdOverride;
$this->maxLinkRange = $maxLinkRange;
$this->omegaOnly = $omegaOnly;
$this->solarsystemInterferenceCost = $solarsystemInterferenceCost;
}
/**
* @param int $value
* @throws Exception
* @return int
*/
public static function fromKey(int $value): int {
return $value; /*int*/
}
/**
* @throws Exception
* @return int
*/
public function toKey(): int {
if (LinkWithShip::validateKey($this->key)) {
return $this->key; /*int*/
}
throw new Exception('never get to this LinkWithShip::key');
}
/**
* @param int
* @return bool
* @throws Exception
*/
public static function validateKey(int $value): bool {
if (!is_integer($value)) {
throw new Exception("Attribute Error:LinkWithShip::key");
}
return true;
}
/**
* @throws Exception
* @return int
*/
public function getKey(): int {
if (LinkWithShip::validateKey($this->key)) {
return $this->key;
}
throw new Exception('never get to getKey LinkWithShip::key');
}
/**
* @return int
*/
public static function sampleKey(): int {
return 31; /*31:key*/
}
/**
* @param bool $value
* @throws Exception
* @return bool
*/
public static function fromApplyPvpFlag(bool $value): bool {
return $value; /*bool*/
}
/**
* @throws Exception
* @return bool
*/
public function toApplyPvpFlag(): bool {
if (LinkWithShip::validateApplyPvpFlag($this->applyPvpFlag)) {
return $this->applyPvpFlag; /*bool*/
}
throw new Exception('never get to this LinkWithShip::applyPvpFlag');
}
/**
* @param bool
* @return bool
* @throws Exception
*/
public static function validateApplyPvpFlag(bool $value): bool {
if (!is_bool($value)) {
throw new Exception("Attribute Error:LinkWithShip::applyPvpFlag");
}
return true;
}
/**
* @throws Exception
* @return bool
*/
public function getApplyPvpFlag(): bool {
if (LinkWithShip::validateApplyPvpFlag($this->applyPvpFlag)) {
return $this->applyPvpFlag;
}
throw new Exception('never get to getApplyPvpFlag LinkWithShip::applyPvpFlag');
}
/**
* @return bool
*/
public static function sampleApplyPvpFlag(): bool {
return true; /*32:applyPvpFlag*/
}
/**
* @param bool $value
* @throws Exception
* @return bool
*/
public static function fromCanRelink(bool $value): bool {
return $value; /*bool*/
}
/**
* @throws Exception
* @return bool
*/
public function toCanRelink(): bool {
if (LinkWithShip::validateCanRelink($this->canRelink)) {
return $this->canRelink; /*bool*/
}
throw new Exception('never get to this LinkWithShip::canRelink');
}
/**
* @param bool
* @return bool
* @throws Exception
*/
public static function validateCanRelink(bool $value): bool {
if (!is_bool($value)) {
throw new Exception("Attribute Error:LinkWithShip::canRelink");
}
return true;
}
/**
* @throws Exception
* @return bool
*/
public function getCanRelink(): bool {
if (LinkWithShip::validateCanRelink($this->canRelink)) {
return $this->canRelink;
}
throw new Exception('never get to getCanRelink LinkWithShip::canRelink');
}
/**
* @return bool
*/
public static function sampleCanRelink(): bool {
return true; /*33:canRelink*/
}
/**
* @param ?float $value
* @throws Exception
* @return ?float
*/
public static function fromCharacterEnergyCost(?float $value): ?float {
if (!is_null($value)) {
return $value; /*float*/
} else {
return null;
}
}
/**
* @throws Exception
* @return ?float
*/
public function toCharacterEnergyCost(): ?float {
if (LinkWithShip::validateCharacterEnergyCost($this->characterEnergyCost)) {
if (!is_null($this->characterEnergyCost)) {
return $this->characterEnergyCost; /*float*/
} else {
return null;
}
}
throw new Exception('never get to this LinkWithShip::characterEnergyCost');
}
/**
* @param float|null
* @return bool
* @throws Exception
*/
public static function validateCharacterEnergyCost(?float $value): bool {
if (!is_null($value)) {
if (!is_float($value) && !is_int($value)) {
throw new Exception("Attribute Error:LinkWithShip::characterEnergyCost");
}
}
return true;
}
/**
* @throws Exception
* @return ?float
*/
public function getCharacterEnergyCost(): ?float {
if (LinkWithShip::validateCharacterEnergyCost($this->characterEnergyCost)) {
return $this->characterEnergyCost;
}
throw new Exception('never get to getCharacterEnergyCost LinkWithShip::characterEnergyCost');
}
/**
* @return ?float
*/
public static function sampleCharacterEnergyCost(): ?float {
return 34.034; /*34:characterEnergyCost*/
}
/**
* @param int $value
* @throws Exception
* @return int
*/
public static function fromDbuffPostLinkDuration(int $value): int {
return $value; /*int*/
}
/**
* @throws Exception
* @return int
*/
public function toDbuffPostLinkDuration(): int {
if (LinkWithShip::validateDbuffPostLinkDuration($this->dbuffPostLinkDuration)) {
return $this->dbuffPostLinkDuration; /*int*/
}
throw new Exception('never get to this LinkWithShip::dbuffPostLinkDuration');
}
/**
* @param int
* @return bool
* @throws Exception
*/
public static function validateDbuffPostLinkDuration(int $value): bool {
if (!is_integer($value)) {
throw new Exception("Attribute Error:LinkWithShip::dbuffPostLinkDuration");
}
return true;
}
/**
* @throws Exception
* @return int
*/
public function getDbuffPostLinkDuration(): int {
if (LinkWithShip::validateDbuffPostLinkDuration($this->dbuffPostLinkDuration)) {
return $this->dbuffPostLinkDuration;
}
throw new Exception('never get to getDbuffPostLinkDuration LinkWithShip::dbuffPostLinkDuration');
}
/**
* @return int
*/
public static function sampleDbuffPostLinkDuration(): int {
return 35; /*35:dbuffPostLinkDuration*/
}
/**
* @param array $value
* @throws Exception
* @return array
*/
public static function fromDbuffs(array $value): array {
return array_map(function ($value) {
return Dbuff::from($value); /*class*/
}, $value);
}
/**
* @throws Exception
* @return array
*/
public function toDbuffs(): array {
if (LinkWithShip::validateDbuffs($this->dbuffs)) {
return array_map(function ($value) {
return $value->to(); /*class*/
}, $this->dbuffs);
}
throw new Exception('never get to this LinkWithShip::dbuffs');
}
/**
* @param array
* @return bool
* @throws Exception
*/
public static function validateDbuffs(array $value): bool {
if (!is_array($value)) {
throw new Exception("Attribute Error:LinkWithShip::dbuffs");
}
array_walk($value, function($value_v) {
$value_v->validate();
});
return true;
}
/**
* @throws Exception
* @return array
*/
public function getDbuffs(): array {
if (LinkWithShip::validateDbuffs($this->dbuffs)) {
return $this->dbuffs;
}
throw new Exception('never get to getDbuffs LinkWithShip::dbuffs');
}
/**
* @return array
*/
public static function sampleDbuffs(): array {
return array(
Dbuff::sample() /*36:*/
); /* 36:dbuffs*/
}
/**
* @param bool $value
* @throws Exception
* @return bool
*/
public static function fromGenerateCynoInhibitor(bool $value): bool {
return $value; /*bool*/
}
/**
* @throws Exception
* @return bool
*/
public function toGenerateCynoInhibitor(): bool {
if (LinkWithShip::validateGenerateCynoInhibitor($this->generateCynoInhibitor)) {
return $this->generateCynoInhibitor; /*bool*/
}
throw new Exception('never get to this LinkWithShip::generateCynoInhibitor');
}
/**
* @param bool
* @return bool
* @throws Exception
*/
public static function validateGenerateCynoInhibitor(bool $value): bool {
if (!is_bool($value)) {
throw new Exception("Attribute Error:LinkWithShip::generateCynoInhibitor");
}
return true;
}
/**
* @throws Exception
* @return bool
*/
public function getGenerateCynoInhibitor(): bool {
if (LinkWithShip::validateGenerateCynoInhibitor($this->generateCynoInhibitor)) {
return $this->generateCynoInhibitor;
}
throw new Exception('never get to getGenerateCynoInhibitor LinkWithShip::generateCynoInhibitor');
}
/**
* @return bool
*/
public static function sampleGenerateCynoInhibitor(): bool {
return true; /*37:generateCynoInhibitor*/
}
/**
* @param bool $value
* @throws Exception
* @return bool
*/
public static function fromKeepDbuffDurationOnLinkBreak(bool $value): bool {
return $value; /*bool*/
}
/**
* @throws Exception
* @return bool
*/
public function toKeepDbuffDurationOnLinkBreak(): bool {
if (LinkWithShip::validateKeepDbuffDurationOnLinkBreak($this->keepDbuffDurationOnLinkBreak)) {
return $this->keepDbuffDurationOnLinkBreak; /*bool*/
}
throw new Exception('never get to this LinkWithShip::keepDbuffDurationOnLinkBreak');
}
/**
* @param bool
* @return bool
* @throws Exception
*/
public static function validateKeepDbuffDurationOnLinkBreak(bool $value): bool {
if (!is_bool($value)) {
throw new Exception("Attribute Error:LinkWithShip::keepDbuffDurationOnLinkBreak");
}
return true;
}
/**
* @throws Exception
* @return bool
*/
public function getKeepDbuffDurationOnLinkBreak(): bool {
if (LinkWithShip::validateKeepDbuffDurationOnLinkBreak($this->keepDbuffDurationOnLinkBreak)) {
return $this->keepDbuffDurationOnLinkBreak;
}
throw new Exception('never get to getKeepDbuffDurationOnLinkBreak LinkWithShip::keepDbuffDurationOnLinkBreak');
}
/**
* @return bool
*/
public static function sampleKeepDbuffDurationOnLinkBreak(): bool {
return true; /*38:keepDbuffDurationOnLinkBreak*/
}
/**
* @param int $value
* @throws Exception
* @return int
*/
public static function fromLinkableShipTypeListId(int $value): int {
return $value; /*int*/
}
/**
* @throws Exception
* @return int
*/
public function toLinkableShipTypeListId(): int {
if (LinkWithShip::validateLinkableShipTypeListId($this->linkableShipTypeListId)) {
return $this->linkableShipTypeListId; /*int*/
}
throw new Exception('never get to this LinkWithShip::linkableShipTypeListId');
}
/**
* @param int
* @return bool
* @throws Exception
*/
public static function validateLinkableShipTypeListId(int $value): bool {
if (!is_integer($value)) {
throw new Exception("Attribute Error:LinkWithShip::linkableShipTypeListId");
}
return true;
}
/**
* @throws Exception
* @return int
*/
public function getLinkableShipTypeListId(): int {
if (LinkWithShip::validateLinkableShipTypeListId($this->linkableShipTypeListId)) {
return $this->linkableShipTypeListId;
}
throw new Exception('never get to getLinkableShipTypeListId LinkWithShip::linkableShipTypeListId');
}
/**
* @return int
*/
public static function sampleLinkableShipTypeListId(): int {
return 39; /*39:linkableShipTypeListId*/
}
/**
* @param int $value
* @throws Exception
* @return int
*/
public static function fromLinkDuration(int $value): int {
return $value; /*int*/
}
/**
* @throws Exception
* @return int
*/
public function toLinkDuration(): int {
if (LinkWithShip::validateLinkDuration($this->linkDuration)) {
return $this->linkDuration; /*int*/
}
throw new Exception('never get to this LinkWithShip::linkDuration');
}
/**
* @param int
* @return bool
* @throws Exception
*/
public static function validateLinkDuration(int $value): bool {
if (!is_integer($value)) {
throw new Exception("Attribute Error:LinkWithShip::linkDuration");
}
return true;
}
/**
* @throws Exception
* @return int
*/
public function getLinkDuration(): int {
if (LinkWithShip::validateLinkDuration($this->linkDuration)) {
return $this->linkDuration;
}
throw new Exception('never get to getLinkDuration LinkWithShip::linkDuration');
}
/**
* @return int
*/
public static function sampleLinkDuration(): int {
return 40; /*40:linkDuration*/
}
/**
* @param int $value
* @throws Exception
* @return int
*/
public static function fromLinkEffectGraphicIdOverride(int $value): int {
return $value; /*int*/
}
/**
* @throws Exception
* @return int
*/
public function toLinkEffectGraphicIdOverride(): int {
if (LinkWithShip::validateLinkEffectGraphicIdOverride($this->linkEffectGraphicIdOverride)) {
return $this->linkEffectGraphicIdOverride; /*int*/
}
throw new Exception('never get to this LinkWithShip::linkEffectGraphicIdOverride');
}
/**
* @param int
* @return bool
* @throws Exception
*/
public static function validateLinkEffectGraphicIdOverride(int $value): bool {
if (!is_integer($value)) {
throw new Exception("Attribute Error:LinkWithShip::linkEffectGraphicIdOverride");
}
return true;
}
/**
* @throws Exception
* @return int
*/
public function getLinkEffectGraphicIdOverride(): int {
if (LinkWithShip::validateLinkEffectGraphicIdOverride($this->linkEffectGraphicIdOverride)) {
return $this->linkEffectGraphicIdOverride;
}
throw new Exception('never get to getLinkEffectGraphicIdOverride LinkWithShip::linkEffectGraphicIdOverride');
}
/**
* @return int
*/
public static function sampleLinkEffectGraphicIdOverride(): int {
return 41; /*41:linkEffectGraphicIdOverride*/
}
/**
* @param int $value
* @throws Exception
* @return int
*/
public static function fromMaxLinkRange(int $value): int {
return $value; /*int*/
}
/**
* @throws Exception
* @return int
*/
public function toMaxLinkRange(): int {
if (LinkWithShip::validateMaxLinkRange($this->maxLinkRange)) {
return $this->maxLinkRange; /*int*/
}
throw new Exception('never get to this LinkWithShip::maxLinkRange');
}
/**
* @param int
* @return bool
* @throws Exception
*/
public static function validateMaxLinkRange(int $value): bool {
if (!is_integer($value)) {
throw new Exception("Attribute Error:LinkWithShip::maxLinkRange");
}
return true;
}
/**
* @throws Exception
* @return int
*/
public function getMaxLinkRange(): int {
if (LinkWithShip::validateMaxLinkRange($this->maxLinkRange)) {
return $this->maxLinkRange;
}
throw new Exception('never get to getMaxLinkRange LinkWithShip::maxLinkRange');
}
/**
* @return int
*/
public static function sampleMaxLinkRange(): int {
return 42; /*42:maxLinkRange*/
}
/**
* @param bool $value
* @throws Exception
* @return bool
*/
public static function fromOmegaOnly(bool $value): bool {
return $value; /*bool*/
}
/**
* @throws Exception
* @return bool
*/
public function toOmegaOnly(): bool {
if (LinkWithShip::validateOmegaOnly($this->omegaOnly)) {
return $this->omegaOnly; /*bool*/
}
throw new Exception('never get to this LinkWithShip::omegaOnly');
}
/**
* @param bool
* @return bool
* @throws Exception
*/
public static function validateOmegaOnly(bool $value): bool {
if (!is_bool($value)) {
throw new Exception("Attribute Error:LinkWithShip::omegaOnly");
}
return true;
}
/**
* @throws Exception
* @return bool
*/
public function getOmegaOnly(): bool {
if (LinkWithShip::validateOmegaOnly($this->omegaOnly)) {
return $this->omegaOnly;
}
throw new Exception('never get to getOmegaOnly LinkWithShip::omegaOnly');
}
/**
* @return bool
*/
public static function sampleOmegaOnly(): bool {
return true; /*43:omegaOnly*/
}
/**
* @param ?float $value
* @throws Exception
* @return ?float
*/
public static function fromSolarsystemInterferenceCost(?float $value): ?float {
if (!is_null($value)) {
return $value; /*float*/
} else {
return null;
}
}
/**
* @throws Exception
* @return ?float
*/
public function toSolarsystemInterferenceCost(): ?float {
if (LinkWithShip::validateSolarsystemInterferenceCost($this->solarsystemInterferenceCost)) {
if (!is_null($this->solarsystemInterferenceCost)) {
return $this->solarsystemInterferenceCost; /*float*/
} else {
return null;
}
}
throw new Exception('never get to this LinkWithShip::solarsystemInterferenceCost');
}
/**
* @param float|null
* @return bool
* @throws Exception
*/
public static function validateSolarsystemInterferenceCost(?float $value): bool {
if (!is_null($value)) {
if (!is_float($value) && !is_int($value)) {
throw new Exception("Attribute Error:LinkWithShip::solarsystemInterferenceCost");
}
}
return true;
}
/**
* @throws Exception
* @return ?float
*/
public function getSolarsystemInterferenceCost(): ?float {
if (LinkWithShip::validateSolarsystemInterferenceCost($this->solarsystemInterferenceCost)) {
return $this->solarsystemInterferenceCost;
}
throw new Exception('never get to getSolarsystemInterferenceCost LinkWithShip::solarsystemInterferenceCost');
}
/**
* @return ?float
*/
public static function sampleSolarsystemInterferenceCost(): ?float {
return 44.044; /*44:solarsystemInterferenceCost*/
}
/**
* @throws Exception
* @return bool
*/
public function validate(): bool {
return LinkWithShip::validateKey($this->key)
|| LinkWithShip::validateApplyPvpFlag($this->applyPvpFlag)
|| LinkWithShip::validateCanRelink($this->canRelink)
|| LinkWithShip::validateCharacterEnergyCost($this->characterEnergyCost)
|| LinkWithShip::validateDbuffPostLinkDuration($this->dbuffPostLinkDuration)
|| LinkWithShip::validateDbuffs($this->dbuffs)
|| LinkWithShip::validateGenerateCynoInhibitor($this->generateCynoInhibitor)
|| LinkWithShip::validateKeepDbuffDurationOnLinkBreak($this->keepDbuffDurationOnLinkBreak)
|| LinkWithShip::validateLinkableShipTypeListId($this->linkableShipTypeListId)
|| LinkWithShip::validateLinkDuration($this->linkDuration)
|| LinkWithShip::validateLinkEffectGraphicIdOverride($this->linkEffectGraphicIdOverride)
|| LinkWithShip::validateMaxLinkRange($this->maxLinkRange)
|| LinkWithShip::validateOmegaOnly($this->omegaOnly)
|| LinkWithShip::validateSolarsystemInterferenceCost($this->solarsystemInterferenceCost);
}
/**
* @return stdClass
* @throws Exception
*/
public function to(): stdClass {
$out = new stdClass();
$out->{'_key'} = $this->toKey();
$out->{'applyPvpFlag'} = $this->toApplyPvpFlag();
$out->{'canRelink'} = $this->toCanRelink();
$out->{'characterEnergyCost'} = $this->toCharacterEnergyCost();
$out->{'dbuffPostLinkDuration'} = $this->toDbuffPostLinkDuration();
$out->{'dbuffs'} = $this->toDbuffs();
$out->{'generateCynoInhibitor'} = $this->toGenerateCynoInhibitor();
$out->{'keepDbuffDurationOnLinkBreak'} = $this->toKeepDbuffDurationOnLinkBreak();
$out->{'linkableShipTypeListID'} = $this->toLinkableShipTypeListId();
$out->{'linkDuration'} = $this->toLinkDuration();
$out->{'linkEffectGraphicIDOverride'} = $this->toLinkEffectGraphicIdOverride();
$out->{'maxLinkRange'} = $this->toMaxLinkRange();
$out->{'omegaOnly'} = $this->toOmegaOnly();
$out->{'solarsystemInterferenceCost'} = $this->toSolarsystemInterferenceCost();
return $out;
}
/**
* @param stdClass $obj
* @return LinkWithShip
* @throws Exception
*/
public static function from(stdClass $obj): LinkWithShip {
return new LinkWithShip(
LinkWithShip::fromKey($obj->{'_key'})
,LinkWithShip::fromApplyPvpFlag($obj->{'applyPvpFlag'})
,LinkWithShip::fromCanRelink($obj->{'canRelink'})
,LinkWithShip::fromCharacterEnergyCost($obj->{'characterEnergyCost'})
,LinkWithShip::fromDbuffPostLinkDuration($obj->{'dbuffPostLinkDuration'})
,LinkWithShip::fromDbuffs($obj->{'dbuffs'})
,LinkWithShip::fromGenerateCynoInhibitor($obj->{'generateCynoInhibitor'})
,LinkWithShip::fromKeepDbuffDurationOnLinkBreak($obj->{'keepDbuffDurationOnLinkBreak'})
,LinkWithShip::fromLinkableShipTypeListId($obj->{'linkableShipTypeListID'})
,LinkWithShip::fromLinkDuration($obj->{'linkDuration'})
,LinkWithShip::fromLinkEffectGraphicIdOverride($obj->{'linkEffectGraphicIDOverride'})
,LinkWithShip::fromMaxLinkRange($obj->{'maxLinkRange'})
,LinkWithShip::fromOmegaOnly($obj->{'omegaOnly'})
,LinkWithShip::fromSolarsystemInterferenceCost($obj->{'solarsystemInterferenceCost'})
);
}
/**
* @return LinkWithShip
*/
public static function sample(): LinkWithShip {
return new LinkWithShip(
LinkWithShip::sampleKey()
,LinkWithShip::sampleApplyPvpFlag()
,LinkWithShip::sampleCanRelink()
,LinkWithShip::sampleCharacterEnergyCost()
,LinkWithShip::sampleDbuffPostLinkDuration()
,LinkWithShip::sampleDbuffs()
,LinkWithShip::sampleGenerateCynoInhibitor()
,LinkWithShip::sampleKeepDbuffDurationOnLinkBreak()
,LinkWithShip::sampleLinkableShipTypeListId()
,LinkWithShip::sampleLinkDuration()
,LinkWithShip::sampleLinkEffectGraphicIdOverride()
,LinkWithShip::sampleMaxLinkRange()
,LinkWithShip::sampleOmegaOnly()
,LinkWithShip::sampleSolarsystemInterferenceCost()
);
}
}
// This is an autogenerated file:Dbuff
class Dbuff {
private int $key; // json:_key Required
private float $value; // json:_value Required
/**
* @param int $key
* @param float $value
*/
public function __construct(int $key, float $value) {
$this->key = $key;
$this->value = $value;
}
/**
* @param int $value
* @throws Exception
* @return int
*/
public static function fromKey(int $value): int {
return $value; /*int*/
}
/**
* @throws Exception
* @return int
*/
public function toKey(): int {
if (Dbuff::validateKey($this->key)) {
return $this->key; /*int*/
}
throw new Exception('never get to this Dbuff::key');
}
/**
* @param int
* @return bool
* @throws Exception
*/
public static function validateKey(int $value): bool {
if (!is_integer($value)) {
throw new Exception("Attribute Error:Dbuff::key");
}
return true;
}
/**
* @throws Exception
* @return int
*/
public function getKey(): int {
if (Dbuff::validateKey($this->key)) {
return $this->key;
}
throw new Exception('never get to getKey Dbuff::key');
}
/**
* @return int
*/
public static function sampleKey(): int {
return 31; /*31:key*/
}
/**
* @param float $value
* @throws Exception
* @return float
*/
public static function fromValue(float $value): float {
return $value; /*float*/
}
/**
* @throws Exception
* @return float
*/
public function toValue(): float {
if (Dbuff::validateValue($this->value)) {
return $this->value; /*float*/
}
throw new Exception('never get to this Dbuff::value');
}
/**
* @param float
* @return bool
* @throws Exception
*/
public static function validateValue(float $value): bool {
if (!is_float($value) && !is_int($value)) {
throw new Exception("Attribute Error:Dbuff::value");
}
return true;
}
/**
* @throws Exception
* @return float
*/
public function getValue(): float {
if (Dbuff::validateValue($this->value)) {
return $this->value;
}
throw new Exception('never get to getValue Dbuff::value');
}
/**
* @return float
*/
public static function sampleValue(): float {
return 32.032; /*32:value*/
}
/**
* @throws Exception
* @return bool
*/
public function validate(): bool {
return Dbuff::validateKey($this->key)
|| Dbuff::validateValue($this->value);
}
/**
* @return stdClass
* @throws Exception
*/
public function to(): stdClass {
$out = new stdClass();
$out->{'_key'} = $this->toKey();
$out->{'_value'} = $this->toValue();
return $out;
}
/**
* @param stdClass $obj
* @return Dbuff
* @throws Exception
*/
public static function from(stdClass $obj): Dbuff {
return new Dbuff(
Dbuff::fromKey($obj->{'_key'})
,Dbuff::fromValue($obj->{'_value'})
);
}
/**
* @return Dbuff
*/
public static function sample(): Dbuff {
return new Dbuff(
Dbuff::sampleKey()
,Dbuff::sampleValue()
);
}
}
from dataclasses import dataclass
from typing import Any, TypeVar, Callable, Type, cast
T = TypeVar("T")
def from_int(x: Any) -> int:
assert isinstance(x, int) and not isinstance(x, bool)
return x
def from_float(x: Any) -> float:
assert isinstance(x, (float, int)) and not isinstance(x, bool)
return float(x)
def to_float(x: Any) -> float:
assert isinstance(x, (int, float))
return x
def from_bool(x: Any) -> bool:
assert isinstance(x, bool)
return x
def from_list(f: Callable[[Any], T], x: Any) -> list[T]:
assert isinstance(x, list)
return [f(y) for y in x]
def from_none(x: Any) -> Any:
assert x is None
return x
def from_union(fs, x):
for f in fs:
try:
return f(x)
except:
pass
assert False
def to_class(c: Type[T], x: Any) -> dict:
assert isinstance(x, c)
return cast(Any, x).to_dict()
@dataclass
class Dbuff:
key: int
value: float
@staticmethod
def from_dict(obj: Any) -> 'Dbuff':
assert isinstance(obj, dict)
key = from_int(obj.get("_key"))
value = from_float(obj.get("_value"))
return Dbuff(key, value)
def to_dict(self) -> dict:
result: dict = {}
result["_key"] = from_int(self.key)
result["_value"] = to_float(self.value)
return result
@dataclass
class LinkWithShip:
key: int
apply_pvp_flag: bool
can_relink: bool
dbuff_post_link_duration: int
dbuffs: list[Dbuff]
generate_cyno_inhibitor: bool
keep_dbuff_duration_on_link_break: bool
linkable_ship_type_list_id: int
link_duration: int
link_effect_graphic_id_override: int
max_link_range: int
omega_only: bool
character_energy_cost: float | None = None
solarsystem_interference_cost: float | None = None
@staticmethod
def from_dict(obj: Any) -> 'LinkWithShip':
assert isinstance(obj, dict)
key = from_int(obj.get("_key"))
apply_pvp_flag = from_bool(obj.get("applyPvpFlag"))
can_relink = from_bool(obj.get("canRelink"))
dbuff_post_link_duration = from_int(obj.get("dbuffPostLinkDuration"))
dbuffs = from_list(Dbuff.from_dict, obj.get("dbuffs"))
generate_cyno_inhibitor = from_bool(obj.get("generateCynoInhibitor"))
keep_dbuff_duration_on_link_break = from_bool(obj.get("keepDbuffDurationOnLinkBreak"))
linkable_ship_type_list_id = from_int(obj.get("linkableShipTypeListID"))
link_duration = from_int(obj.get("linkDuration"))
link_effect_graphic_id_override = from_int(obj.get("linkEffectGraphicIDOverride"))
max_link_range = from_int(obj.get("maxLinkRange"))
omega_only = from_bool(obj.get("omegaOnly"))
character_energy_cost = from_union([from_float, from_none], obj.get("characterEnergyCost"))
solarsystem_interference_cost = from_union([from_float, from_none], obj.get("solarsystemInterferenceCost"))
return LinkWithShip(key, apply_pvp_flag, can_relink, dbuff_post_link_duration, dbuffs, generate_cyno_inhibitor, keep_dbuff_duration_on_link_break, linkable_ship_type_list_id, link_duration, link_effect_graphic_id_override, max_link_range, omega_only, character_energy_cost, solarsystem_interference_cost)
def to_dict(self) -> dict:
result: dict = {}
result["_key"] = from_int(self.key)
result["applyPvpFlag"] = from_bool(self.apply_pvp_flag)
result["canRelink"] = from_bool(self.can_relink)
result["dbuffPostLinkDuration"] = from_int(self.dbuff_post_link_duration)
result["dbuffs"] = from_list(lambda x: to_class(Dbuff, x), self.dbuffs)
result["generateCynoInhibitor"] = from_bool(self.generate_cyno_inhibitor)
result["keepDbuffDurationOnLinkBreak"] = from_bool(self.keep_dbuff_duration_on_link_break)
result["linkableShipTypeListID"] = from_int(self.linkable_ship_type_list_id)
result["linkDuration"] = from_int(self.link_duration)
result["linkEffectGraphicIDOverride"] = from_int(self.link_effect_graphic_id_override)
result["maxLinkRange"] = from_int(self.max_link_range)
result["omegaOnly"] = from_bool(self.omega_only)
if self.character_energy_cost is not None:
result["characterEnergyCost"] = from_union([to_float, from_none], self.character_energy_cost)
if self.solarsystem_interference_cost is not None:
result["solarsystemInterferenceCost"] = from_union([to_float, from_none], self.solarsystem_interference_cost)
return result
def link_with_ship_from_dict(s: Any) -> LinkWithShip:
return LinkWithShip.from_dict(s)
def link_with_ship_to_dict(x: LinkWithShip) -> Any:
return to_class(LinkWithShip, x)
// To parse this data:
//
// import { Convert, LinkWithShip } from "./LinkWithShip";
//
// const linkWithShip = Convert.toLinkWithShip(json);
//
// These functions will throw an error if the JSON doesn't
// match the expected interface, even if the JSON is valid.
export interface LinkWithShip {
_key: number;
applyPvpFlag: boolean;
canRelink: boolean;
characterEnergyCost?: number;
dbuffPostLinkDuration: number;
dbuffs: [Dbuff, Dbuff, ...Dbuff[]];
generateCynoInhibitor: boolean;
keepDbuffDurationOnLinkBreak: boolean;
linkableShipTypeListID: number;
linkDuration: number;
linkEffectGraphicIDOverride: number;
maxLinkRange: number;
omegaOnly: boolean;
solarsystemInterferenceCost?: number;
[property: string]: unknown;
}
export interface Dbuff {
_key: number;
_value: number;
[property: string]: unknown;
}
// Converts JSON strings to/from your types
// and asserts the results of JSON.parse at runtime
export class Convert {
public static toLinkWithShip(json: string): LinkWithShip {
return cast(JSON.parse(json), r("LinkWithShip"));
}
public static linkWithShipToJson(value: LinkWithShip): string {
return JSON.stringify(uncast(value, r("LinkWithShip")), null, 2);
}
}
function invalidValue(typ: any, val: any, key: any, parent: any = ''): never {
const prettyTyp = prettyTypeName(typ);
const parentText = parent ? ` on ${parent}` : '';
const keyText = key ? ` for key "${key}"` : '';
throw Error(`Invalid value${keyText}${parentText}. Expected ${prettyTyp} but got ${JSON.stringify(val)}`);
}
function prettyTypeName(typ: any): string {
if (Array.isArray(typ)) {
if (typ.length === 2 && typ[0] === undefined) {
return `an optional ${prettyTypeName(typ[1])}`;
} else {
return `one of [${typ.map(a => { return prettyTypeName(a); }).join(", ")}]`;
}
} else if (typeof typ === "object" && typ.literal !== undefined) {
return typ.literal;
} else {
return typeof typ;
}
}
function jsonToJSProps(typ: any): any {
if (typ.jsonToJS === undefined) {
const map: any = {};
typ.props.forEach((p: any) => map[p.json] = { key: p.js, typ: p.typ });
typ.jsonToJS = map;
}
return typ.jsonToJS;
}
function jsToJSONProps(typ: any): any {
if (typ.jsToJSON === undefined) {
const map: any = {};
typ.props.forEach((p: any) => map[p.js] = { key: p.json, typ: p.typ });
typ.jsToJSON = map;
}
return typ.jsToJSON;
}
function transform(val: any, typ: any, getProps: any, key: any = '', parent: any = ''): any {
function transformPrimitive(typ: string, val: any): any {
if (typeof typ === typeof val) return val;
return invalidValue(typ, val, key, parent);
}
function transformUnion(typs: any[], val: any): any {
// val must validate against one typ in typs
const l = typs.length;
for (let i = 0; i < l; i++) {
const typ = typs[i];
try {
return transform(val, typ, getProps);
} catch (_) {}
}
return invalidValue(typs, val, key, parent);
}
function transformEnum(cases: string[], val: any): any {
if (cases.indexOf(val) !== -1) return val;
return invalidValue(cases.map(a => { return l(a); }), val, key, parent);
}
function transformArray(typ: any, val: any): any {
// val must be an array with no invalid elements
if (!Array.isArray(val)) return invalidValue(l("array"), val, key, parent);
return val.map(el => transform(el, typ, getProps));
}
function transformDate(val: any): any {
if (val === null) {
return null;
}
const d = new Date(val);
if (isNaN(d.valueOf())) {
return invalidValue(l("Date"), val, key, parent);
}
return d;
}
function transformObject(props: { [k: string]: any }, additional: any, val: any): any {
if (val === null || typeof val !== "object" || Array.isArray(val)) {
return invalidValue(l(ref || "object"), val, key, parent);
}
const result: any = {};
Object.getOwnPropertyNames(props).forEach(key => {
const prop = props[key];
const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
result[prop.key] = transform(v, prop.typ, getProps, key, ref);
});
Object.getOwnPropertyNames(val).forEach(key => {
if (!Object.prototype.hasOwnProperty.call(props, key)) {
result[key] = transform(val[key], additional, getProps, key, ref);
}
});
return result;
}
if (typ === "any") return val;
if (typ === null) {
if (val === null) return val;
return invalidValue(typ, val, key, parent);
}
if (typ === false) return invalidValue(typ, val, key, parent);
let ref: any = undefined;
while (typeof typ === "object" && typ.ref !== undefined) {
ref = typ.ref;
typ = typeMap[typ.ref];
}
if (Array.isArray(typ)) return transformEnum(typ, val);
if (typeof typ === "object") {
return typ.hasOwnProperty("unionMembers") ? transformUnion(typ.unionMembers, val)
: typ.hasOwnProperty("arrayItems") ? transformArray(typ.arrayItems, val)
: typ.hasOwnProperty("props") ? transformObject(getProps(typ), typ.additional, val)
: invalidValue(typ, val, key, parent);
}
// Numbers can be parsed by Date but shouldn't be.
if (typ === Date && typeof val !== "number") return transformDate(val);
return transformPrimitive(typ, val);
}
function cast<T>(val: any, typ: any): T {
return transform(val, typ, jsonToJSProps);
}
function uncast<T>(val: T, typ: any): any {
return transform(val, typ, jsToJSONProps);
}
function l(typ: any) {
return { literal: typ };
}
function a(typ: any) {
return { arrayItems: typ };
}
function u(...typs: any[]) {
return { unionMembers: typs };
}
function o(props: any[], additional: any) {
return { props, additional };
}
function m(additional: any) {
return { props: [], additional };
}
function r(name: string) {
return { ref: name };
}
const typeMap: any = {
"LinkWithShip": o([
{ json: "_key", js: "_key", typ: 0 },
{ json: "applyPvpFlag", js: "applyPvpFlag", typ: true },
{ json: "canRelink", js: "canRelink", typ: true },
{ json: "characterEnergyCost", js: "characterEnergyCost", typ: u(undefined, 3.14) },
{ json: "dbuffPostLinkDuration", js: "dbuffPostLinkDuration", typ: 0 },
{ json: "dbuffs", js: "dbuffs", typ: a(r("Dbuff")) },
{ json: "generateCynoInhibitor", js: "generateCynoInhibitor", typ: true },
{ json: "keepDbuffDurationOnLinkBreak", js: "keepDbuffDurationOnLinkBreak", typ: true },
{ json: "linkableShipTypeListID", js: "linkableShipTypeListID", typ: 0 },
{ json: "linkDuration", js: "linkDuration", typ: 0 },
{ json: "linkEffectGraphicIDOverride", js: "linkEffectGraphicIDOverride", typ: 0 },
{ json: "maxLinkRange", js: "maxLinkRange", typ: 0 },
{ json: "omegaOnly", js: "omegaOnly", typ: true },
{ json: "solarsystemInterferenceCost", js: "solarsystemInterferenceCost", typ: u(undefined, 3.14) },
], "any"),
"Dbuff": o([
{ json: "_key", js: "_key", typ: 0 },
{ json: "_value", js: "_value", typ: 3.14 },
], "any"),
};