Skip to content

EVE SDE Schema

Documentation for third-party developers

fighterAbilitiesByType.jsonl

Schema

  • _key (required): integer
    Range: 2948 .. 83594
  • abilitySlot0 (required): object

    • abilityID (required): integer
      Range: 2 .. 45
  • abilitySlot1 (required): object

    • abilityID (required): integer
      Range: 4 .. 13
    • cooldownSeconds (required): integer
      Range: 60 .. 90
  • abilitySlot2: object

    • abilityID (required): integer
      Range: 7 .. 38
    • charges: object
      • chargeCount (required): integer
        Range: 2 .. 20
      • rearmTimeSeconds (required): integer
        Range: 4 .. 20

Code snippets

// <auto-generated />
//
// To parse this JSON data, add NuGet 'System.Text.Json' then do:
//
//    using QuickType;
//
//    var fighterAbilitiesByType = FighterAbilitiesByType.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 FighterAbilitiesByType
    {
        [JsonPropertyName("_key")]
        public long Key { get; set; }

        [JsonPropertyName("abilitySlot0")]
        public AbilitySlot0 AbilitySlot0 { get; set; }

        [JsonPropertyName("abilitySlot1")]
        public AbilitySlot1 AbilitySlot1 { get; set; }

        [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
        [JsonPropertyName("abilitySlot2")]
        public AbilitySlot2? AbilitySlot2 { get; set; }
    }

    public partial class AbilitySlot0
    {
        [JsonPropertyName("abilityID")]
        public long AbilityId { get; set; }
    }

    public partial class AbilitySlot1
    {
        [JsonPropertyName("abilityID")]
        public long AbilityId { get; set; }

        [JsonPropertyName("cooldownSeconds")]
        public long CooldownSeconds { get; set; }
    }

    public partial class AbilitySlot2
    {
        [JsonPropertyName("abilityID")]
        public long AbilityId { get; set; }

        [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
        [JsonPropertyName("charges")]
        public Charges? Charges { get; set; }
    }

    public partial class Charges
    {
        [JsonPropertyName("chargeCount")]
        public long ChargeCount { get; set; }

        [JsonPropertyName("rearmTimeSeconds")]
        public long RearmTimeSeconds { get; set; }
    }

    public partial class FighterAbilitiesByType
    {
        public static FighterAbilitiesByType FromJson(string json) => JsonSerializer.Deserialize<FighterAbilitiesByType>(json, QuickType.Converter.Settings);
    }

    public static class Serialize
    {
        public static string ToJson(this FighterAbilitiesByType 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
            },
        };
    }

    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:
//
//    fighterAbilitiesByType, err := UnmarshalFighterAbilitiesByType(bytes)
//    bytes, err = fighterAbilitiesByType.Marshal()

package model

import "encoding/json"

func UnmarshalFighterAbilitiesByType(data []byte) (FighterAbilitiesByType, error) {
    var r FighterAbilitiesByType
    err := json.Unmarshal(data, &r)
    return r, err
}

func (r *FighterAbilitiesByType) Marshal() ([]byte, error) {
    return json.Marshal(r)
}

type FighterAbilitiesByType struct {
    Key          int64         `json:"_key"`
    AbilitySlot0 AbilitySlot0  `json:"abilitySlot0"`
    AbilitySlot1 AbilitySlot1  `json:"abilitySlot1"`
    AbilitySlot2 *AbilitySlot2 `json:"abilitySlot2,omitempty"`
}

type AbilitySlot0 struct {
    AbilityID int64 `json:"abilityID"`
}

type AbilitySlot1 struct {
    AbilityID       int64 `json:"abilityID"`
    CooldownSeconds int64 `json:"cooldownSeconds"`
}

type AbilitySlot2 struct {
    AbilityID int64    `json:"abilityID"`
    Charges   *Charges `json:"charges,omitempty"`
}

type Charges struct {
    ChargeCount      int64 `json:"chargeCount"`
    RearmTimeSeconds int64 `json:"rearmTimeSeconds"`
}
{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"_key":{"type":"integer","minimum":2948,"maximum":83594},"abilitySlot0":{"type":"object","properties":{"abilityID":{"type":"integer","minimum":2,"maximum":45}},"required":["abilityID"]},"abilitySlot1":{"type":"object","properties":{"abilityID":{"type":"integer","minimum":4,"maximum":13},"cooldownSeconds":{"type":"integer","minimum":60,"maximum":90}},"required":["abilityID","cooldownSeconds"]},"abilitySlot2":{"type":"object","properties":{"abilityID":{"type":"integer","minimum":7,"maximum":38},"charges":{"type":"object","properties":{"chargeCount":{"type":"integer","minimum":2,"maximum":20},"rearmTimeSeconds":{"type":"integer","minimum":4,"maximum":20}},"required":["chargeCount","rearmTimeSeconds"]}},"required":["abilityID"]}},"required":["_key","abilitySlot0","abilitySlot1"]}
// To parse the JSON, install kotlin's serialization plugin and do:
//
// val json                   = Json { allowStructuredMapKeys = true }
// val fighterAbilitiesByType = json.parse(FighterAbilitiesByType.serializer(), jsonString)

package model

import kotlinx.serialization.*
import kotlinx.serialization.json.*
import kotlinx.serialization.descriptors.*
import kotlinx.serialization.encoding.*

@Serializable
data class FighterAbilitiesByType (
    @SerialName("_key")
    val key: Long,

    val abilitySlot0: AbilitySlot0,
    val abilitySlot1: AbilitySlot1,
    val abilitySlot2: AbilitySlot2? = null
)

@Serializable
data class AbilitySlot0 (
    @SerialName("abilityID")
    val abilityId: Long
)

@Serializable
data class AbilitySlot1 (
    @SerialName("abilityID")
    val abilityId: Long,

    val cooldownSeconds: Long
)

@Serializable
data class AbilitySlot2 (
    @SerialName("abilityID")
    val abilityId: Long,

    val charges: Charges? = null
)

@Serializable
data class Charges (
    val chargeCount: Long,
    val rearmTimeSeconds: Long
)
<?php

// This is an autogenerated file:FighterAbilitiesByType

class FighterAbilitiesByType {
    private int $key; // json:_key Required
    private AbilitySlot0 $abilitySlot0; // json:abilitySlot0 Required
    private AbilitySlot1 $abilitySlot1; // json:abilitySlot1 Required
    private ?AbilitySlot2 $abilitySlot2; // json:abilitySlot2 Optional

    /**
     * @param int $key
     * @param AbilitySlot0 $abilitySlot0
     * @param AbilitySlot1 $abilitySlot1
     * @param AbilitySlot2|null $abilitySlot2
     */
    public function __construct(int $key, AbilitySlot0 $abilitySlot0, AbilitySlot1 $abilitySlot1, ?AbilitySlot2 $abilitySlot2) {
        $this->key = $key;
        $this->abilitySlot0 = $abilitySlot0;
        $this->abilitySlot1 = $abilitySlot1;
        $this->abilitySlot2 = $abilitySlot2;
    }

    /**
     * @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 (FighterAbilitiesByType::validateKey($this->key))  {
            return $this->key; /*int*/
        }
        throw new Exception('never get to this FighterAbilitiesByType::key');
    }

    /**
     * @param int
     * @return bool
     * @throws Exception
     */
    public static function validateKey(int $value): bool {
        if (!is_integer($value)) {
            throw new Exception("Attribute Error:FighterAbilitiesByType::key");
        }
        return true;
    }

    /**
     * @throws Exception
     * @return int
     */
    public function getKey(): int {
        if (FighterAbilitiesByType::validateKey($this->key))  {
            return $this->key;
        }
        throw new Exception('never get to getKey FighterAbilitiesByType::key');
    }

    /**
     * @return int
     */
    public static function sampleKey(): int {
        return 31; /*31:key*/
    }

    /**
     * @param stdClass $value
     * @throws Exception
     * @return AbilitySlot0
     */
    public static function fromAbilitySlot0(stdClass $value): AbilitySlot0 {
        return AbilitySlot0::from($value); /*class*/
    }

    /**
     * @throws Exception
     * @return stdClass
     */
    public function toAbilitySlot0(): stdClass {
        if (FighterAbilitiesByType::validateAbilitySlot0($this->abilitySlot0))  {
            return $this->abilitySlot0->to(); /*class*/
        }
        throw new Exception('never get to this FighterAbilitiesByType::abilitySlot0');
    }

    /**
     * @param AbilitySlot0
     * @return bool
     * @throws Exception
     */
    public static function validateAbilitySlot0(AbilitySlot0 $value): bool {
        $value->validate();
        return true;
    }

    /**
     * @throws Exception
     * @return AbilitySlot0
     */
    public function getAbilitySlot0(): AbilitySlot0 {
        if (FighterAbilitiesByType::validateAbilitySlot0($this->abilitySlot0))  {
            return $this->abilitySlot0;
        }
        throw new Exception('never get to getAbilitySlot0 FighterAbilitiesByType::abilitySlot0');
    }

    /**
     * @return AbilitySlot0
     */
    public static function sampleAbilitySlot0(): AbilitySlot0 {
        return AbilitySlot0::sample(); /*32:abilitySlot0*/
    }

    /**
     * @param stdClass $value
     * @throws Exception
     * @return AbilitySlot1
     */
    public static function fromAbilitySlot1(stdClass $value): AbilitySlot1 {
        return AbilitySlot1::from($value); /*class*/
    }

    /**
     * @throws Exception
     * @return stdClass
     */
    public function toAbilitySlot1(): stdClass {
        if (FighterAbilitiesByType::validateAbilitySlot1($this->abilitySlot1))  {
            return $this->abilitySlot1->to(); /*class*/
        }
        throw new Exception('never get to this FighterAbilitiesByType::abilitySlot1');
    }

    /**
     * @param AbilitySlot1
     * @return bool
     * @throws Exception
     */
    public static function validateAbilitySlot1(AbilitySlot1 $value): bool {
        $value->validate();
        return true;
    }

    /**
     * @throws Exception
     * @return AbilitySlot1
     */
    public function getAbilitySlot1(): AbilitySlot1 {
        if (FighterAbilitiesByType::validateAbilitySlot1($this->abilitySlot1))  {
            return $this->abilitySlot1;
        }
        throw new Exception('never get to getAbilitySlot1 FighterAbilitiesByType::abilitySlot1');
    }

    /**
     * @return AbilitySlot1
     */
    public static function sampleAbilitySlot1(): AbilitySlot1 {
        return AbilitySlot1::sample(); /*33:abilitySlot1*/
    }

    /**
     * @param ?stdClass $value
     * @throws Exception
     * @return ?AbilitySlot2
     */
    public static function fromAbilitySlot2(?stdClass $value): ?AbilitySlot2 {
        if (!is_null($value)) {
            return AbilitySlot2::from($value); /*class*/
        } else {
            return  null;
        }
    }

    /**
     * @throws Exception
     * @return ?stdClass
     */
    public function toAbilitySlot2(): ?stdClass {
        if (FighterAbilitiesByType::validateAbilitySlot2($this->abilitySlot2))  {
            if (!is_null($this->abilitySlot2)) {
                return $this->abilitySlot2->to(); /*class*/
            } else {
                return  null;
            }
        }
        throw new Exception('never get to this FighterAbilitiesByType::abilitySlot2');
    }

    /**
     * @param AbilitySlot2|null
     * @return bool
     * @throws Exception
     */
    public static function validateAbilitySlot2(?AbilitySlot2 $value): bool {
        if (!is_null($value)) {
            $value->validate();
        }
        return true;
    }

    /**
     * @throws Exception
     * @return ?AbilitySlot2
     */
    public function getAbilitySlot2(): ?AbilitySlot2 {
        if (FighterAbilitiesByType::validateAbilitySlot2($this->abilitySlot2))  {
            return $this->abilitySlot2;
        }
        throw new Exception('never get to getAbilitySlot2 FighterAbilitiesByType::abilitySlot2');
    }

    /**
     * @return ?AbilitySlot2
     */
    public static function sampleAbilitySlot2(): ?AbilitySlot2 {
        return AbilitySlot2::sample(); /*34:abilitySlot2*/
    }

    /**
     * @throws Exception
     * @return bool
     */
    public function validate(): bool {
        return FighterAbilitiesByType::validateKey($this->key)
        || FighterAbilitiesByType::validateAbilitySlot0($this->abilitySlot0)
        || FighterAbilitiesByType::validateAbilitySlot1($this->abilitySlot1)
        || FighterAbilitiesByType::validateAbilitySlot2($this->abilitySlot2);
    }

    /**
     * @return stdClass
     * @throws Exception
     */
    public function to(): stdClass  {
        $out = new stdClass();
        $out->{'_key'} = $this->toKey();
        $out->{'abilitySlot0'} = $this->toAbilitySlot0();
        $out->{'abilitySlot1'} = $this->toAbilitySlot1();
        $out->{'abilitySlot2'} = $this->toAbilitySlot2();
        return $out;
    }

    /**
     * @param stdClass $obj
     * @return FighterAbilitiesByType
     * @throws Exception
     */
    public static function from(stdClass $obj): FighterAbilitiesByType {
        return new FighterAbilitiesByType(
         FighterAbilitiesByType::fromKey($obj->{'_key'})
        ,FighterAbilitiesByType::fromAbilitySlot0($obj->{'abilitySlot0'})
        ,FighterAbilitiesByType::fromAbilitySlot1($obj->{'abilitySlot1'})
        ,FighterAbilitiesByType::fromAbilitySlot2($obj->{'abilitySlot2'})
        );
    }

    /**
     * @return FighterAbilitiesByType
     */
    public static function sample(): FighterAbilitiesByType {
        return new FighterAbilitiesByType(
         FighterAbilitiesByType::sampleKey()
        ,FighterAbilitiesByType::sampleAbilitySlot0()
        ,FighterAbilitiesByType::sampleAbilitySlot1()
        ,FighterAbilitiesByType::sampleAbilitySlot2()
        );
    }
}

// This is an autogenerated file:AbilitySlot0

class AbilitySlot0 {
    private int $abilityId; // json:abilityID Required

    /**
     * @param int $abilityId
     */
    public function __construct(int $abilityId) {
        $this->abilityId = $abilityId;
    }

    /**
     * @param int $value
     * @throws Exception
     * @return int
     */
    public static function fromAbilityId(int $value): int {
        return $value; /*int*/
    }

    /**
     * @throws Exception
     * @return int
     */
    public function toAbilityId(): int {
        if (AbilitySlot0::validateAbilityId($this->abilityId))  {
            return $this->abilityId; /*int*/
        }
        throw new Exception('never get to this AbilitySlot0::abilityId');
    }

    /**
     * @param int
     * @return bool
     * @throws Exception
     */
    public static function validateAbilityId(int $value): bool {
        if (!is_integer($value)) {
            throw new Exception("Attribute Error:AbilitySlot0::abilityId");
        }
        return true;
    }

    /**
     * @throws Exception
     * @return int
     */
    public function getAbilityId(): int {
        if (AbilitySlot0::validateAbilityId($this->abilityId))  {
            return $this->abilityId;
        }
        throw new Exception('never get to getAbilityId AbilitySlot0::abilityId');
    }

    /**
     * @return int
     */
    public static function sampleAbilityId(): int {
        return 31; /*31:abilityId*/
    }

    /**
     * @throws Exception
     * @return bool
     */
    public function validate(): bool {
        return AbilitySlot0::validateAbilityId($this->abilityId);
    }

    /**
     * @return stdClass
     * @throws Exception
     */
    public function to(): stdClass  {
        $out = new stdClass();
        $out->{'abilityID'} = $this->toAbilityId();
        return $out;
    }

    /**
     * @param stdClass $obj
     * @return AbilitySlot0
     * @throws Exception
     */
    public static function from(stdClass $obj): AbilitySlot0 {
        return new AbilitySlot0(
         AbilitySlot0::fromAbilityId($obj->{'abilityID'})
        );
    }

    /**
     * @return AbilitySlot0
     */
    public static function sample(): AbilitySlot0 {
        return new AbilitySlot0(
         AbilitySlot0::sampleAbilityId()
        );
    }
}

// This is an autogenerated file:AbilitySlot1

class AbilitySlot1 {
    private int $abilityId; // json:abilityID Required
    private int $cooldownSeconds; // json:cooldownSeconds Required

    /**
     * @param int $abilityId
     * @param int $cooldownSeconds
     */
    public function __construct(int $abilityId, int $cooldownSeconds) {
        $this->abilityId = $abilityId;
        $this->cooldownSeconds = $cooldownSeconds;
    }

    /**
     * @param int $value
     * @throws Exception
     * @return int
     */
    public static function fromAbilityId(int $value): int {
        return $value; /*int*/
    }

    /**
     * @throws Exception
     * @return int
     */
    public function toAbilityId(): int {
        if (AbilitySlot1::validateAbilityId($this->abilityId))  {
            return $this->abilityId; /*int*/
        }
        throw new Exception('never get to this AbilitySlot1::abilityId');
    }

    /**
     * @param int
     * @return bool
     * @throws Exception
     */
    public static function validateAbilityId(int $value): bool {
        if (!is_integer($value)) {
            throw new Exception("Attribute Error:AbilitySlot1::abilityId");
        }
        return true;
    }

    /**
     * @throws Exception
     * @return int
     */
    public function getAbilityId(): int {
        if (AbilitySlot1::validateAbilityId($this->abilityId))  {
            return $this->abilityId;
        }
        throw new Exception('never get to getAbilityId AbilitySlot1::abilityId');
    }

    /**
     * @return int
     */
    public static function sampleAbilityId(): int {
        return 31; /*31:abilityId*/
    }

    /**
     * @param int $value
     * @throws Exception
     * @return int
     */
    public static function fromCooldownSeconds(int $value): int {
        return $value; /*int*/
    }

    /**
     * @throws Exception
     * @return int
     */
    public function toCooldownSeconds(): int {
        if (AbilitySlot1::validateCooldownSeconds($this->cooldownSeconds))  {
            return $this->cooldownSeconds; /*int*/
        }
        throw new Exception('never get to this AbilitySlot1::cooldownSeconds');
    }

    /**
     * @param int
     * @return bool
     * @throws Exception
     */
    public static function validateCooldownSeconds(int $value): bool {
        if (!is_integer($value)) {
            throw new Exception("Attribute Error:AbilitySlot1::cooldownSeconds");
        }
        return true;
    }

    /**
     * @throws Exception
     * @return int
     */
    public function getCooldownSeconds(): int {
        if (AbilitySlot1::validateCooldownSeconds($this->cooldownSeconds))  {
            return $this->cooldownSeconds;
        }
        throw new Exception('never get to getCooldownSeconds AbilitySlot1::cooldownSeconds');
    }

    /**
     * @return int
     */
    public static function sampleCooldownSeconds(): int {
        return 32; /*32:cooldownSeconds*/
    }

    /**
     * @throws Exception
     * @return bool
     */
    public function validate(): bool {
        return AbilitySlot1::validateAbilityId($this->abilityId)
        || AbilitySlot1::validateCooldownSeconds($this->cooldownSeconds);
    }

    /**
     * @return stdClass
     * @throws Exception
     */
    public function to(): stdClass  {
        $out = new stdClass();
        $out->{'abilityID'} = $this->toAbilityId();
        $out->{'cooldownSeconds'} = $this->toCooldownSeconds();
        return $out;
    }

    /**
     * @param stdClass $obj
     * @return AbilitySlot1
     * @throws Exception
     */
    public static function from(stdClass $obj): AbilitySlot1 {
        return new AbilitySlot1(
         AbilitySlot1::fromAbilityId($obj->{'abilityID'})
        ,AbilitySlot1::fromCooldownSeconds($obj->{'cooldownSeconds'})
        );
    }

    /**
     * @return AbilitySlot1
     */
    public static function sample(): AbilitySlot1 {
        return new AbilitySlot1(
         AbilitySlot1::sampleAbilityId()
        ,AbilitySlot1::sampleCooldownSeconds()
        );
    }
}

// This is an autogenerated file:AbilitySlot2

class AbilitySlot2 {
    private int $abilityId; // json:abilityID Required
    private ?Charges $charges; // json:charges Optional

    /**
     * @param int $abilityId
     * @param Charges|null $charges
     */
    public function __construct(int $abilityId, ?Charges $charges) {
        $this->abilityId = $abilityId;
        $this->charges = $charges;
    }

    /**
     * @param int $value
     * @throws Exception
     * @return int
     */
    public static function fromAbilityId(int $value): int {
        return $value; /*int*/
    }

    /**
     * @throws Exception
     * @return int
     */
    public function toAbilityId(): int {
        if (AbilitySlot2::validateAbilityId($this->abilityId))  {
            return $this->abilityId; /*int*/
        }
        throw new Exception('never get to this AbilitySlot2::abilityId');
    }

    /**
     * @param int
     * @return bool
     * @throws Exception
     */
    public static function validateAbilityId(int $value): bool {
        if (!is_integer($value)) {
            throw new Exception("Attribute Error:AbilitySlot2::abilityId");
        }
        return true;
    }

    /**
     * @throws Exception
     * @return int
     */
    public function getAbilityId(): int {
        if (AbilitySlot2::validateAbilityId($this->abilityId))  {
            return $this->abilityId;
        }
        throw new Exception('never get to getAbilityId AbilitySlot2::abilityId');
    }

    /**
     * @return int
     */
    public static function sampleAbilityId(): int {
        return 31; /*31:abilityId*/
    }

    /**
     * @param ?stdClass $value
     * @throws Exception
     * @return ?Charges
     */
    public static function fromCharges(?stdClass $value): ?Charges {
        if (!is_null($value)) {
            return Charges::from($value); /*class*/
        } else {
            return  null;
        }
    }

    /**
     * @throws Exception
     * @return ?stdClass
     */
    public function toCharges(): ?stdClass {
        if (AbilitySlot2::validateCharges($this->charges))  {
            if (!is_null($this->charges)) {
                return $this->charges->to(); /*class*/
            } else {
                return  null;
            }
        }
        throw new Exception('never get to this AbilitySlot2::charges');
    }

    /**
     * @param Charges|null
     * @return bool
     * @throws Exception
     */
    public static function validateCharges(?Charges $value): bool {
        if (!is_null($value)) {
            $value->validate();
        }
        return true;
    }

    /**
     * @throws Exception
     * @return ?Charges
     */
    public function getCharges(): ?Charges {
        if (AbilitySlot2::validateCharges($this->charges))  {
            return $this->charges;
        }
        throw new Exception('never get to getCharges AbilitySlot2::charges');
    }

    /**
     * @return ?Charges
     */
    public static function sampleCharges(): ?Charges {
        return Charges::sample(); /*32:charges*/
    }

    /**
     * @throws Exception
     * @return bool
     */
    public function validate(): bool {
        return AbilitySlot2::validateAbilityId($this->abilityId)
        || AbilitySlot2::validateCharges($this->charges);
    }

    /**
     * @return stdClass
     * @throws Exception
     */
    public function to(): stdClass  {
        $out = new stdClass();
        $out->{'abilityID'} = $this->toAbilityId();
        $out->{'charges'} = $this->toCharges();
        return $out;
    }

    /**
     * @param stdClass $obj
     * @return AbilitySlot2
     * @throws Exception
     */
    public static function from(stdClass $obj): AbilitySlot2 {
        return new AbilitySlot2(
         AbilitySlot2::fromAbilityId($obj->{'abilityID'})
        ,AbilitySlot2::fromCharges($obj->{'charges'})
        );
    }

    /**
     * @return AbilitySlot2
     */
    public static function sample(): AbilitySlot2 {
        return new AbilitySlot2(
         AbilitySlot2::sampleAbilityId()
        ,AbilitySlot2::sampleCharges()
        );
    }
}

// This is an autogenerated file:Charges

class Charges {
    private int $chargeCount; // json:chargeCount Required
    private int $rearmTimeSeconds; // json:rearmTimeSeconds Required

    /**
     * @param int $chargeCount
     * @param int $rearmTimeSeconds
     */
    public function __construct(int $chargeCount, int $rearmTimeSeconds) {
        $this->chargeCount = $chargeCount;
        $this->rearmTimeSeconds = $rearmTimeSeconds;
    }

    /**
     * @param int $value
     * @throws Exception
     * @return int
     */
    public static function fromChargeCount(int $value): int {
        return $value; /*int*/
    }

    /**
     * @throws Exception
     * @return int
     */
    public function toChargeCount(): int {
        if (Charges::validateChargeCount($this->chargeCount))  {
            return $this->chargeCount; /*int*/
        }
        throw new Exception('never get to this Charges::chargeCount');
    }

    /**
     * @param int
     * @return bool
     * @throws Exception
     */
    public static function validateChargeCount(int $value): bool {
        if (!is_integer($value)) {
            throw new Exception("Attribute Error:Charges::chargeCount");
        }
        return true;
    }

    /**
     * @throws Exception
     * @return int
     */
    public function getChargeCount(): int {
        if (Charges::validateChargeCount($this->chargeCount))  {
            return $this->chargeCount;
        }
        throw new Exception('never get to getChargeCount Charges::chargeCount');
    }

    /**
     * @return int
     */
    public static function sampleChargeCount(): int {
        return 31; /*31:chargeCount*/
    }

    /**
     * @param int $value
     * @throws Exception
     * @return int
     */
    public static function fromRearmTimeSeconds(int $value): int {
        return $value; /*int*/
    }

    /**
     * @throws Exception
     * @return int
     */
    public function toRearmTimeSeconds(): int {
        if (Charges::validateRearmTimeSeconds($this->rearmTimeSeconds))  {
            return $this->rearmTimeSeconds; /*int*/
        }
        throw new Exception('never get to this Charges::rearmTimeSeconds');
    }

    /**
     * @param int
     * @return bool
     * @throws Exception
     */
    public static function validateRearmTimeSeconds(int $value): bool {
        if (!is_integer($value)) {
            throw new Exception("Attribute Error:Charges::rearmTimeSeconds");
        }
        return true;
    }

    /**
     * @throws Exception
     * @return int
     */
    public function getRearmTimeSeconds(): int {
        if (Charges::validateRearmTimeSeconds($this->rearmTimeSeconds))  {
            return $this->rearmTimeSeconds;
        }
        throw new Exception('never get to getRearmTimeSeconds Charges::rearmTimeSeconds');
    }

    /**
     * @return int
     */
    public static function sampleRearmTimeSeconds(): int {
        return 32; /*32:rearmTimeSeconds*/
    }

    /**
     * @throws Exception
     * @return bool
     */
    public function validate(): bool {
        return Charges::validateChargeCount($this->chargeCount)
        || Charges::validateRearmTimeSeconds($this->rearmTimeSeconds);
    }

    /**
     * @return stdClass
     * @throws Exception
     */
    public function to(): stdClass  {
        $out = new stdClass();
        $out->{'chargeCount'} = $this->toChargeCount();
        $out->{'rearmTimeSeconds'} = $this->toRearmTimeSeconds();
        return $out;
    }

    /**
     * @param stdClass $obj
     * @return Charges
     * @throws Exception
     */
    public static function from(stdClass $obj): Charges {
        return new Charges(
         Charges::fromChargeCount($obj->{'chargeCount'})
        ,Charges::fromRearmTimeSeconds($obj->{'rearmTimeSeconds'})
        );
    }

    /**
     * @return Charges
     */
    public static function sample(): Charges {
        return new Charges(
         Charges::sampleChargeCount()
        ,Charges::sampleRearmTimeSeconds()
        );
    }
}
from dataclasses import dataclass
from typing import Any, TypeVar, Type, cast


T = TypeVar("T")


def from_int(x: Any) -> int:
    assert isinstance(x, int) and not isinstance(x, bool)
    return 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 AbilitySlot0:
    ability_id: int

    @staticmethod
    def from_dict(obj: Any) -> 'AbilitySlot0':
        assert isinstance(obj, dict)
        ability_id = from_int(obj.get("abilityID"))
        return AbilitySlot0(ability_id)

    def to_dict(self) -> dict:
        result: dict = {}
        result["abilityID"] = from_int(self.ability_id)
        return result


@dataclass
class AbilitySlot1:
    ability_id: int
    cooldown_seconds: int

    @staticmethod
    def from_dict(obj: Any) -> 'AbilitySlot1':
        assert isinstance(obj, dict)
        ability_id = from_int(obj.get("abilityID"))
        cooldown_seconds = from_int(obj.get("cooldownSeconds"))
        return AbilitySlot1(ability_id, cooldown_seconds)

    def to_dict(self) -> dict:
        result: dict = {}
        result["abilityID"] = from_int(self.ability_id)
        result["cooldownSeconds"] = from_int(self.cooldown_seconds)
        return result


@dataclass
class Charges:
    charge_count: int
    rearm_time_seconds: int

    @staticmethod
    def from_dict(obj: Any) -> 'Charges':
        assert isinstance(obj, dict)
        charge_count = from_int(obj.get("chargeCount"))
        rearm_time_seconds = from_int(obj.get("rearmTimeSeconds"))
        return Charges(charge_count, rearm_time_seconds)

    def to_dict(self) -> dict:
        result: dict = {}
        result["chargeCount"] = from_int(self.charge_count)
        result["rearmTimeSeconds"] = from_int(self.rearm_time_seconds)
        return result


@dataclass
class AbilitySlot2:
    ability_id: int
    charges: Charges | None = None

    @staticmethod
    def from_dict(obj: Any) -> 'AbilitySlot2':
        assert isinstance(obj, dict)
        ability_id = from_int(obj.get("abilityID"))
        charges = from_union([Charges.from_dict, from_none], obj.get("charges"))
        return AbilitySlot2(ability_id, charges)

    def to_dict(self) -> dict:
        result: dict = {}
        result["abilityID"] = from_int(self.ability_id)
        if self.charges is not None:
            result["charges"] = from_union([lambda x: to_class(Charges, x), from_none], self.charges)
        return result


@dataclass
class FighterAbilitiesByType:
    key: int
    ability_slot0: AbilitySlot0
    ability_slot1: AbilitySlot1
    ability_slot2: AbilitySlot2 | None = None

    @staticmethod
    def from_dict(obj: Any) -> 'FighterAbilitiesByType':
        assert isinstance(obj, dict)
        key = from_int(obj.get("_key"))
        ability_slot0 = AbilitySlot0.from_dict(obj.get("abilitySlot0"))
        ability_slot1 = AbilitySlot1.from_dict(obj.get("abilitySlot1"))
        ability_slot2 = from_union([AbilitySlot2.from_dict, from_none], obj.get("abilitySlot2"))
        return FighterAbilitiesByType(key, ability_slot0, ability_slot1, ability_slot2)

    def to_dict(self) -> dict:
        result: dict = {}
        result["_key"] = from_int(self.key)
        result["abilitySlot0"] = to_class(AbilitySlot0, self.ability_slot0)
        result["abilitySlot1"] = to_class(AbilitySlot1, self.ability_slot1)
        if self.ability_slot2 is not None:
            result["abilitySlot2"] = from_union([lambda x: to_class(AbilitySlot2, x), from_none], self.ability_slot2)
        return result


def fighter_abilities_by_type_from_dict(s: Any) -> FighterAbilitiesByType:
    return FighterAbilitiesByType.from_dict(s)


def fighter_abilities_by_type_to_dict(x: FighterAbilitiesByType) -> Any:
    return to_class(FighterAbilitiesByType, x)
// To parse this data:
//
//   import { Convert, FighterAbilitiesByType } from "./FighterAbilitiesByType";
//
//   const fighterAbilitiesByType = Convert.toFighterAbilitiesByType(json);
//
// These functions will throw an error if the JSON doesn't
// match the expected interface, even if the JSON is valid.

export interface FighterAbilitiesByType {
    _key:          number;
    abilitySlot0:  AbilitySlot0;
    abilitySlot1:  AbilitySlot1;
    abilitySlot2?: AbilitySlot2;
    [property: string]: unknown;
}

export interface AbilitySlot0 {
    abilityID: number;
    [property: string]: unknown;
}

export interface AbilitySlot1 {
    abilityID:       number;
    cooldownSeconds: number;
    [property: string]: unknown;
}

export interface AbilitySlot2 {
    abilityID: number;
    charges?:  Charges;
    [property: string]: unknown;
}

export interface Charges {
    chargeCount:      number;
    rearmTimeSeconds: 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 toFighterAbilitiesByType(json: string): FighterAbilitiesByType {
        return cast(JSON.parse(json), r("FighterAbilitiesByType"));
    }

    public static fighterAbilitiesByTypeToJson(value: FighterAbilitiesByType): string {
        return JSON.stringify(uncast(value, r("FighterAbilitiesByType")), 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 = {
    "FighterAbilitiesByType": o([
        { json: "_key", js: "_key", typ: 0 },
        { json: "abilitySlot0", js: "abilitySlot0", typ: r("AbilitySlot0") },
        { json: "abilitySlot1", js: "abilitySlot1", typ: r("AbilitySlot1") },
        { json: "abilitySlot2", js: "abilitySlot2", typ: u(undefined, r("AbilitySlot2")) },
    ], "any"),
    "AbilitySlot0": o([
        { json: "abilityID", js: "abilityID", typ: 0 },
    ], "any"),
    "AbilitySlot1": o([
        { json: "abilityID", js: "abilityID", typ: 0 },
        { json: "cooldownSeconds", js: "cooldownSeconds", typ: 0 },
    ], "any"),
    "AbilitySlot2": o([
        { json: "abilityID", js: "abilityID", typ: 0 },
        { json: "charges", js: "charges", typ: u(undefined, r("Charges")) },
    ], "any"),
    "Charges": o([
        { json: "chargeCount", js: "chargeCount", typ: 0 },
        { json: "rearmTimeSeconds", js: "rearmTimeSeconds", typ: 0 },
    ], "any"),
};