typeBonus.jsonl
Schema
_key
(required): integer
Range: 582 .. 88001iconID
: integer
Range: 98 .. 24577-
miscBonuses
: array of objectbonus
: number
Range: -85 .. 200-
bonusText
(required): objectde
: stringen
(required): stringes
: stringfr
: stringja
: stringko
: stringru
: stringzh
: string
-
importance
(required): integer
Range: 1 .. 15 isPositive
: booleanunitID
: integer
Range: 105 .. 144
-
roleBonuses
: array of objectbonus
: number
Range: -85 .. 1400-
bonusText
(required): objectde
: stringen
(required): stringes
: stringfr
: stringja
: stringko
: stringru
: stringzh
: string
-
importance
(required): integer
Range: 1 .. 150 unitID
: integer
Range: 104 .. 139
-
types
: array of object_key
(required): integer
Range: 3184 .. 81044-
_value
(required): array of objectbonus
: number
Range: -4 .. 5000-
bonusText
(required): objectde
: stringen
(required): stringes
: stringfr
: stringja
: stringko
: stringru
: stringzh
: string
-
importance
(required): integer
Range: 1 .. 30 unitID
: integer
Range: 1 .. 139
Code snippets
// <auto-generated />
//
// To parse this JSON data, add NuGet 'Newtonsoft.Json' then do:
//
// using QuickType;
//
// var typeBonus = TypeBonus.FromJson(jsonString);
namespace QuickType
{
using System;
using System.Collections.Generic;
using System.Globalization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
public partial class TypeBonus
{
[JsonProperty("_key")]
public long Key { get; set; }
[JsonProperty("iconID", NullValueHandling = NullValueHandling.Ignore)]
public long? IconId { get; set; }
[JsonProperty("miscBonuses", NullValueHandling = NullValueHandling.Ignore)]
public MiscBonus[] MiscBonuses { get; set; }
[JsonProperty("roleBonuses", NullValueHandling = NullValueHandling.Ignore)]
public RoleBonus[] RoleBonuses { get; set; }
[JsonProperty("types", NullValueHandling = NullValueHandling.Ignore)]
public TypeElement[] Types { get; set; }
}
public partial class MiscBonus
{
[JsonProperty("bonus", NullValueHandling = NullValueHandling.Ignore)]
[JsonConverter(typeof(PurpleMinMaxValueCheckConverter))]
public double? Bonus { get; set; }
[JsonProperty("bonusText")]
public MiscBonusBonusText BonusText { get; set; }
[JsonProperty("importance")]
public long Importance { get; set; }
[JsonProperty("isPositive", NullValueHandling = NullValueHandling.Ignore)]
public bool? IsPositive { get; set; }
[JsonProperty("unitID", NullValueHandling = NullValueHandling.Ignore)]
public long? UnitId { get; set; }
}
public partial class MiscBonusBonusText
{
[JsonProperty("de", NullValueHandling = NullValueHandling.Ignore)]
[JsonConverter(typeof(PurpleMinMaxLengthCheckConverter))]
public string De { get; set; }
[JsonProperty("en")]
[JsonConverter(typeof(FluffyMinMaxLengthCheckConverter))]
public string En { get; set; }
[JsonProperty("es", NullValueHandling = NullValueHandling.Ignore)]
[JsonConverter(typeof(TentacledMinMaxLengthCheckConverter))]
public string Es { get; set; }
[JsonProperty("fr", NullValueHandling = NullValueHandling.Ignore)]
[JsonConverter(typeof(StickyMinMaxLengthCheckConverter))]
public string Fr { get; set; }
[JsonProperty("ja", NullValueHandling = NullValueHandling.Ignore)]
[JsonConverter(typeof(IndigoMinMaxLengthCheckConverter))]
public string Ja { get; set; }
[JsonProperty("ko", NullValueHandling = NullValueHandling.Ignore)]
[JsonConverter(typeof(IndecentMinMaxLengthCheckConverter))]
public string Ko { get; set; }
[JsonProperty("ru", NullValueHandling = NullValueHandling.Ignore)]
[JsonConverter(typeof(HilariousMinMaxLengthCheckConverter))]
public string Ru { get; set; }
[JsonProperty("zh", NullValueHandling = NullValueHandling.Ignore)]
[JsonConverter(typeof(AmbitiousMinMaxLengthCheckConverter))]
public string Zh { get; set; }
}
public partial class RoleBonus
{
[JsonProperty("bonus", NullValueHandling = NullValueHandling.Ignore)]
[JsonConverter(typeof(FluffyMinMaxValueCheckConverter))]
public double? Bonus { get; set; }
[JsonProperty("bonusText")]
public RoleBonusBonusText BonusText { get; set; }
[JsonProperty("importance")]
public long Importance { get; set; }
[JsonProperty("unitID", NullValueHandling = NullValueHandling.Ignore)]
public long? UnitId { get; set; }
}
public partial class RoleBonusBonusText
{
[JsonProperty("de", NullValueHandling = NullValueHandling.Ignore)]
[JsonConverter(typeof(CunningMinMaxLengthCheckConverter))]
public string De { get; set; }
[JsonProperty("en")]
[JsonConverter(typeof(MagentaMinMaxLengthCheckConverter))]
public string En { get; set; }
[JsonProperty("es", NullValueHandling = NullValueHandling.Ignore)]
[JsonConverter(typeof(FriskyMinMaxLengthCheckConverter))]
public string Es { get; set; }
[JsonProperty("fr", NullValueHandling = NullValueHandling.Ignore)]
[JsonConverter(typeof(MischievousMinMaxLengthCheckConverter))]
public string Fr { get; set; }
[JsonProperty("ja", NullValueHandling = NullValueHandling.Ignore)]
[JsonConverter(typeof(BraggadociousMinMaxLengthCheckConverter))]
public string Ja { get; set; }
[JsonProperty("ko", NullValueHandling = NullValueHandling.Ignore)]
[JsonConverter(typeof(MinMaxLengthCheckConverter1))]
public string Ko { get; set; }
[JsonProperty("ru", NullValueHandling = NullValueHandling.Ignore)]
[JsonConverter(typeof(MinMaxLengthCheckConverter2))]
public string Ru { get; set; }
[JsonProperty("zh", NullValueHandling = NullValueHandling.Ignore)]
[JsonConverter(typeof(MinMaxLengthCheckConverter3))]
public string Zh { get; set; }
}
public partial class TypeElement
{
[JsonProperty("_key")]
public long Key { get; set; }
[JsonProperty("_value")]
public Value[] Value { get; set; }
}
public partial class Value
{
[JsonProperty("bonus", NullValueHandling = NullValueHandling.Ignore)]
[JsonConverter(typeof(TentacledMinMaxValueCheckConverter))]
public double? Bonus { get; set; }
[JsonProperty("bonusText")]
public ValueBonusText BonusText { get; set; }
[JsonProperty("importance")]
public long Importance { get; set; }
[JsonProperty("unitID", NullValueHandling = NullValueHandling.Ignore)]
public long? UnitId { get; set; }
}
public partial class ValueBonusText
{
[JsonProperty("de", NullValueHandling = NullValueHandling.Ignore)]
[JsonConverter(typeof(MinMaxLengthCheckConverter4))]
public string De { get; set; }
[JsonProperty("en")]
[JsonConverter(typeof(MinMaxLengthCheckConverter5))]
public string En { get; set; }
[JsonProperty("es", NullValueHandling = NullValueHandling.Ignore)]
[JsonConverter(typeof(MinMaxLengthCheckConverter6))]
public string Es { get; set; }
[JsonProperty("fr", NullValueHandling = NullValueHandling.Ignore)]
[JsonConverter(typeof(MinMaxLengthCheckConverter7))]
public string Fr { get; set; }
[JsonProperty("ja", NullValueHandling = NullValueHandling.Ignore)]
[JsonConverter(typeof(MinMaxLengthCheckConverter8))]
public string Ja { get; set; }
[JsonProperty("ko", NullValueHandling = NullValueHandling.Ignore)]
[JsonConverter(typeof(MinMaxLengthCheckConverter9))]
public string Ko { get; set; }
[JsonProperty("ru", NullValueHandling = NullValueHandling.Ignore)]
[JsonConverter(typeof(MinMaxLengthCheckConverter10))]
public string Ru { get; set; }
[JsonProperty("zh", NullValueHandling = NullValueHandling.Ignore)]
[JsonConverter(typeof(MinMaxLengthCheckConverter11))]
public string Zh { get; set; }
}
public partial class TypeBonus
{
public static TypeBonus FromJson(string json) => JsonConvert.DeserializeObject<TypeBonus>(json, QuickType.Converter.Settings);
}
public static class Serialize
{
public static string ToJson(this TypeBonus self) => JsonConvert.SerializeObject(self, QuickType.Converter.Settings);
}
internal static class Converter
{
public static readonly JsonSerializerSettings Settings = new JsonSerializerSettings
{
MetadataPropertyHandling = MetadataPropertyHandling.Ignore,
DateParseHandling = DateParseHandling.None,
Converters =
{
new IsoDateTimeConverter { DateTimeStyles = DateTimeStyles.AssumeUniversal }
},
};
}
internal class PurpleMinMaxValueCheckConverter : JsonConverter
{
public override bool CanConvert(Type t) => t == typeof(double) || t == typeof(double?);
public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
{
if (reader.TokenType == JsonToken.Null) return null;
var value = serializer.Deserialize<double>(reader);
if (value >= -85 && value <= 200)
{
return value;
}
throw new Exception("Cannot unmarshal type double");
}
public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
{
if (untypedValue == null)
{
serializer.Serialize(writer, null);
return;
}
var value = (double)untypedValue;
if (value >= -85 && value <= 200)
{
serializer.Serialize(writer, value);
return;
}
throw new Exception("Cannot marshal type double");
}
public static readonly PurpleMinMaxValueCheckConverter Singleton = new PurpleMinMaxValueCheckConverter();
}
internal class PurpleMinMaxLengthCheckConverter : JsonConverter
{
public override bool CanConvert(Type t) => t == typeof(string);
public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
{
var value = serializer.Deserialize<string>(reader);
if (value.Length >= 23 && value.Length <= 215)
{
return value;
}
throw new Exception("Cannot unmarshal type string");
}
public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
{
var value = (string)untypedValue;
if (value.Length >= 23 && value.Length <= 215)
{
serializer.Serialize(writer, value);
return;
}
throw new Exception("Cannot marshal type string");
}
public static readonly PurpleMinMaxLengthCheckConverter Singleton = new PurpleMinMaxLengthCheckConverter();
}
internal class FluffyMinMaxLengthCheckConverter : JsonConverter
{
public override bool CanConvert(Type t) => t == typeof(string);
public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
{
var value = serializer.Deserialize<string>(reader);
if (value.Length >= 14 && value.Length <= 173)
{
return value;
}
throw new Exception("Cannot unmarshal type string");
}
public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
{
var value = (string)untypedValue;
if (value.Length >= 14 && value.Length <= 173)
{
serializer.Serialize(writer, value);
return;
}
throw new Exception("Cannot marshal type string");
}
public static readonly FluffyMinMaxLengthCheckConverter Singleton = new FluffyMinMaxLengthCheckConverter();
}
internal class TentacledMinMaxLengthCheckConverter : JsonConverter
{
public override bool CanConvert(Type t) => t == typeof(string);
public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
{
var value = serializer.Deserialize<string>(reader);
if (value.Length >= 28 && value.Length <= 220)
{
return value;
}
throw new Exception("Cannot unmarshal type string");
}
public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
{
var value = (string)untypedValue;
if (value.Length >= 28 && value.Length <= 220)
{
serializer.Serialize(writer, value);
return;
}
throw new Exception("Cannot marshal type string");
}
public static readonly TentacledMinMaxLengthCheckConverter Singleton = new TentacledMinMaxLengthCheckConverter();
}
internal class StickyMinMaxLengthCheckConverter : JsonConverter
{
public override bool CanConvert(Type t) => t == typeof(string);
public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
{
var value = serializer.Deserialize<string>(reader);
if (value.Length >= 17 && value.Length <= 223)
{
return value;
}
throw new Exception("Cannot unmarshal type string");
}
public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
{
var value = (string)untypedValue;
if (value.Length >= 17 && value.Length <= 223)
{
serializer.Serialize(writer, value);
return;
}
throw new Exception("Cannot marshal type string");
}
public static readonly StickyMinMaxLengthCheckConverter Singleton = new StickyMinMaxLengthCheckConverter();
}
internal class IndigoMinMaxLengthCheckConverter : JsonConverter
{
public override bool CanConvert(Type t) => t == typeof(string);
public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
{
var value = serializer.Deserialize<string>(reader);
if (value.Length >= 7 && value.Length <= 122)
{
return value;
}
throw new Exception("Cannot unmarshal type string");
}
public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
{
var value = (string)untypedValue;
if (value.Length >= 7 && value.Length <= 122)
{
serializer.Serialize(writer, value);
return;
}
throw new Exception("Cannot marshal type string");
}
public static readonly IndigoMinMaxLengthCheckConverter Singleton = new IndigoMinMaxLengthCheckConverter();
}
internal class IndecentMinMaxLengthCheckConverter : JsonConverter
{
public override bool CanConvert(Type t) => t == typeof(string);
public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
{
var value = serializer.Deserialize<string>(reader);
if (value.Length >= 6 && value.Length <= 97)
{
return value;
}
throw new Exception("Cannot unmarshal type string");
}
public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
{
var value = (string)untypedValue;
if (value.Length >= 6 && value.Length <= 97)
{
serializer.Serialize(writer, value);
return;
}
throw new Exception("Cannot marshal type string");
}
public static readonly IndecentMinMaxLengthCheckConverter Singleton = new IndecentMinMaxLengthCheckConverter();
}
internal class HilariousMinMaxLengthCheckConverter : JsonConverter
{
public override bool CanConvert(Type t) => t == typeof(string);
public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
{
var value = serializer.Deserialize<string>(reader);
if (value.Length >= 13 && value.Length <= 211)
{
return value;
}
throw new Exception("Cannot unmarshal type string");
}
public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
{
var value = (string)untypedValue;
if (value.Length >= 13 && value.Length <= 211)
{
serializer.Serialize(writer, value);
return;
}
throw new Exception("Cannot marshal type string");
}
public static readonly HilariousMinMaxLengthCheckConverter Singleton = new HilariousMinMaxLengthCheckConverter();
}
internal class AmbitiousMinMaxLengthCheckConverter : JsonConverter
{
public override bool CanConvert(Type t) => t == typeof(string);
public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
{
var value = serializer.Deserialize<string>(reader);
if (value.Length >= 5 && value.Length <= 93)
{
return value;
}
throw new Exception("Cannot unmarshal type string");
}
public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
{
var value = (string)untypedValue;
if (value.Length >= 5 && value.Length <= 93)
{
serializer.Serialize(writer, value);
return;
}
throw new Exception("Cannot marshal type string");
}
public static readonly AmbitiousMinMaxLengthCheckConverter Singleton = new AmbitiousMinMaxLengthCheckConverter();
}
internal class FluffyMinMaxValueCheckConverter : JsonConverter
{
public override bool CanConvert(Type t) => t == typeof(double) || t == typeof(double?);
public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
{
if (reader.TokenType == JsonToken.Null) return null;
var value = serializer.Deserialize<double>(reader);
if (value >= -85 && value <= 1400)
{
return value;
}
throw new Exception("Cannot unmarshal type double");
}
public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
{
if (untypedValue == null)
{
serializer.Serialize(writer, null);
return;
}
var value = (double)untypedValue;
if (value >= -85 && value <= 1400)
{
serializer.Serialize(writer, value);
return;
}
throw new Exception("Cannot marshal type double");
}
public static readonly FluffyMinMaxValueCheckConverter Singleton = new FluffyMinMaxValueCheckConverter();
}
internal class CunningMinMaxLengthCheckConverter : JsonConverter
{
public override bool CanConvert(Type t) => t == typeof(string);
public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
{
var value = serializer.Deserialize<string>(reader);
if (value.Length >= 9 && value.Length <= 405)
{
return value;
}
throw new Exception("Cannot unmarshal type string");
}
public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
{
var value = (string)untypedValue;
if (value.Length >= 9 && value.Length <= 405)
{
serializer.Serialize(writer, value);
return;
}
throw new Exception("Cannot marshal type string");
}
public static readonly CunningMinMaxLengthCheckConverter Singleton = new CunningMinMaxLengthCheckConverter();
}
internal class MagentaMinMaxLengthCheckConverter : JsonConverter
{
public override bool CanConvert(Type t) => t == typeof(string);
public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
{
var value = serializer.Deserialize<string>(reader);
if (value.Length >= 7 && value.Length <= 340)
{
return value;
}
throw new Exception("Cannot unmarshal type string");
}
public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
{
var value = (string)untypedValue;
if (value.Length >= 7 && value.Length <= 340)
{
serializer.Serialize(writer, value);
return;
}
throw new Exception("Cannot marshal type string");
}
public static readonly MagentaMinMaxLengthCheckConverter Singleton = new MagentaMinMaxLengthCheckConverter();
}
internal class FriskyMinMaxLengthCheckConverter : JsonConverter
{
public override bool CanConvert(Type t) => t == typeof(string);
public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
{
var value = serializer.Deserialize<string>(reader);
if (value.Length >= 6 && value.Length <= 382)
{
return value;
}
throw new Exception("Cannot unmarshal type string");
}
public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
{
var value = (string)untypedValue;
if (value.Length >= 6 && value.Length <= 382)
{
serializer.Serialize(writer, value);
return;
}
throw new Exception("Cannot marshal type string");
}
public static readonly FriskyMinMaxLengthCheckConverter Singleton = new FriskyMinMaxLengthCheckConverter();
}
internal class MischievousMinMaxLengthCheckConverter : JsonConverter
{
public override bool CanConvert(Type t) => t == typeof(string);
public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
{
var value = serializer.Deserialize<string>(reader);
if (value.Length >= 7 && value.Length <= 392)
{
return value;
}
throw new Exception("Cannot unmarshal type string");
}
public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
{
var value = (string)untypedValue;
if (value.Length >= 7 && value.Length <= 392)
{
serializer.Serialize(writer, value);
return;
}
throw new Exception("Cannot marshal type string");
}
public static readonly MischievousMinMaxLengthCheckConverter Singleton = new MischievousMinMaxLengthCheckConverter();
}
internal class BraggadociousMinMaxLengthCheckConverter : JsonConverter
{
public override bool CanConvert(Type t) => t == typeof(string);
public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
{
var value = serializer.Deserialize<string>(reader);
if (value.Length >= 6 && value.Length <= 248)
{
return value;
}
throw new Exception("Cannot unmarshal type string");
}
public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
{
var value = (string)untypedValue;
if (value.Length >= 6 && value.Length <= 248)
{
serializer.Serialize(writer, value);
return;
}
throw new Exception("Cannot marshal type string");
}
public static readonly BraggadociousMinMaxLengthCheckConverter Singleton = new BraggadociousMinMaxLengthCheckConverter();
}
internal class MinMaxLengthCheckConverter1 : JsonConverter
{
public override bool CanConvert(Type t) => t == typeof(string);
public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
{
var value = serializer.Deserialize<string>(reader);
if (value.Length >= 7 && value.Length <= 230)
{
return value;
}
throw new Exception("Cannot unmarshal type string");
}
public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
{
var value = (string)untypedValue;
if (value.Length >= 7 && value.Length <= 230)
{
serializer.Serialize(writer, value);
return;
}
throw new Exception("Cannot marshal type string");
}
public static readonly MinMaxLengthCheckConverter1 Singleton = new MinMaxLengthCheckConverter1();
}
internal class MinMaxLengthCheckConverter2 : JsonConverter
{
public override bool CanConvert(Type t) => t == typeof(string);
public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
{
var value = serializer.Deserialize<string>(reader);
if (value.Length >= 22 && value.Length <= 338)
{
return value;
}
throw new Exception("Cannot unmarshal type string");
}
public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
{
var value = (string)untypedValue;
if (value.Length >= 22 && value.Length <= 338)
{
serializer.Serialize(writer, value);
return;
}
throw new Exception("Cannot marshal type string");
}
public static readonly MinMaxLengthCheckConverter2 Singleton = new MinMaxLengthCheckConverter2();
}
internal class MinMaxLengthCheckConverter3 : JsonConverter
{
public override bool CanConvert(Type t) => t == typeof(string);
public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
{
var value = serializer.Deserialize<string>(reader);
if (value.Length >= 4 && value.Length <= 193)
{
return value;
}
throw new Exception("Cannot unmarshal type string");
}
public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
{
var value = (string)untypedValue;
if (value.Length >= 4 && value.Length <= 193)
{
serializer.Serialize(writer, value);
return;
}
throw new Exception("Cannot marshal type string");
}
public static readonly MinMaxLengthCheckConverter3 Singleton = new MinMaxLengthCheckConverter3();
}
internal class TentacledMinMaxValueCheckConverter : JsonConverter
{
public override bool CanConvert(Type t) => t == typeof(double) || t == typeof(double?);
public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
{
if (reader.TokenType == JsonToken.Null) return null;
var value = serializer.Deserialize<double>(reader);
if (value >= -4 && value <= 5000)
{
return value;
}
throw new Exception("Cannot unmarshal type double");
}
public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
{
if (untypedValue == null)
{
serializer.Serialize(writer, null);
return;
}
var value = (double)untypedValue;
if (value >= -4 && value <= 5000)
{
serializer.Serialize(writer, value);
return;
}
throw new Exception("Cannot marshal type double");
}
public static readonly TentacledMinMaxValueCheckConverter Singleton = new TentacledMinMaxValueCheckConverter();
}
internal class MinMaxLengthCheckConverter4 : JsonConverter
{
public override bool CanConvert(Type t) => t == typeof(string);
public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
{
var value = serializer.Deserialize<string>(reader);
if (value.Length >= 24 && value.Length <= 221)
{
return value;
}
throw new Exception("Cannot unmarshal type string");
}
public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
{
var value = (string)untypedValue;
if (value.Length >= 24 && value.Length <= 221)
{
serializer.Serialize(writer, value);
return;
}
throw new Exception("Cannot marshal type string");
}
public static readonly MinMaxLengthCheckConverter4 Singleton = new MinMaxLengthCheckConverter4();
}
internal class MinMaxLengthCheckConverter5 : JsonConverter
{
public override bool CanConvert(Type t) => t == typeof(string);
public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
{
var value = serializer.Deserialize<string>(reader);
if (value.Length >= 21 && value.Length <= 188)
{
return value;
}
throw new Exception("Cannot unmarshal type string");
}
public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
{
var value = (string)untypedValue;
if (value.Length >= 21 && value.Length <= 188)
{
serializer.Serialize(writer, value);
return;
}
throw new Exception("Cannot marshal type string");
}
public static readonly MinMaxLengthCheckConverter5 Singleton = new MinMaxLengthCheckConverter5();
}
internal class MinMaxLengthCheckConverter6 : JsonConverter
{
public override bool CanConvert(Type t) => t == typeof(string);
public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
{
var value = serializer.Deserialize<string>(reader);
if (value.Length >= 35 && value.Length <= 230)
{
return value;
}
throw new Exception("Cannot unmarshal type string");
}
public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
{
var value = (string)untypedValue;
if (value.Length >= 35 && value.Length <= 230)
{
serializer.Serialize(writer, value);
return;
}
throw new Exception("Cannot marshal type string");
}
public static readonly MinMaxLengthCheckConverter6 Singleton = new MinMaxLengthCheckConverter6();
}
internal class MinMaxLengthCheckConverter7 : JsonConverter
{
public override bool CanConvert(Type t) => t == typeof(string);
public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
{
var value = serializer.Deserialize<string>(reader);
if (value.Length >= 29 && value.Length <= 216)
{
return value;
}
throw new Exception("Cannot unmarshal type string");
}
public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
{
var value = (string)untypedValue;
if (value.Length >= 29 && value.Length <= 216)
{
serializer.Serialize(writer, value);
return;
}
throw new Exception("Cannot marshal type string");
}
public static readonly MinMaxLengthCheckConverter7 Singleton = new MinMaxLengthCheckConverter7();
}
internal class MinMaxLengthCheckConverter8 : JsonConverter
{
public override bool CanConvert(Type t) => t == typeof(string);
public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
{
var value = serializer.Deserialize<string>(reader);
if (value.Length >= 7 && value.Length <= 149)
{
return value;
}
throw new Exception("Cannot unmarshal type string");
}
public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
{
var value = (string)untypedValue;
if (value.Length >= 7 && value.Length <= 149)
{
serializer.Serialize(writer, value);
return;
}
throw new Exception("Cannot marshal type string");
}
public static readonly MinMaxLengthCheckConverter8 Singleton = new MinMaxLengthCheckConverter8();
}
internal class MinMaxLengthCheckConverter9 : JsonConverter
{
public override bool CanConvert(Type t) => t == typeof(string);
public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
{
var value = serializer.Deserialize<string>(reader);
if (value.Length >= 6 && value.Length <= 145)
{
return value;
}
throw new Exception("Cannot unmarshal type string");
}
public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
{
var value = (string)untypedValue;
if (value.Length >= 6 && value.Length <= 145)
{
serializer.Serialize(writer, value);
return;
}
throw new Exception("Cannot marshal type string");
}
public static readonly MinMaxLengthCheckConverter9 Singleton = new MinMaxLengthCheckConverter9();
}
internal class MinMaxLengthCheckConverter10 : JsonConverter
{
public override bool CanConvert(Type t) => t == typeof(string);
public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
{
var value = serializer.Deserialize<string>(reader);
if (value.Length >= 22 && value.Length <= 262)
{
return value;
}
throw new Exception("Cannot unmarshal type string");
}
public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
{
var value = (string)untypedValue;
if (value.Length >= 22 && value.Length <= 262)
{
serializer.Serialize(writer, value);
return;
}
throw new Exception("Cannot marshal type string");
}
public static readonly MinMaxLengthCheckConverter10 Singleton = new MinMaxLengthCheckConverter10();
}
internal class MinMaxLengthCheckConverter11 : JsonConverter
{
public override bool CanConvert(Type t) => t == typeof(string);
public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
{
var value = serializer.Deserialize<string>(reader);
if (value.Length >= 5 && value.Length <= 129)
{
return value;
}
throw new Exception("Cannot unmarshal type string");
}
public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
{
var value = (string)untypedValue;
if (value.Length >= 5 && value.Length <= 129)
{
serializer.Serialize(writer, value);
return;
}
throw new Exception("Cannot marshal type string");
}
public static readonly MinMaxLengthCheckConverter11 Singleton = new MinMaxLengthCheckConverter11();
}
}
// 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:
//
// typeBonus, err := UnmarshalTypeBonus(bytes)
// bytes, err = typeBonus.Marshal()
package model
import "encoding/json"
func UnmarshalTypeBonus(data []byte) (TypeBonus, error) {
var r TypeBonus
err := json.Unmarshal(data, &r)
return r, err
}
func (r *TypeBonus) Marshal() ([]byte, error) {
return json.Marshal(r)
}
type TypeBonus struct {
Key int64 `json:"_key"`
IconID *int64 `json:"iconID,omitempty"`
MiscBonuses []MiscBonus `json:"miscBonuses,omitempty"`
RoleBonuses []RoleBonus `json:"roleBonuses,omitempty"`
Types []Type `json:"types,omitempty"`
}
type MiscBonus struct {
Bonus *float64 `json:"bonus,omitempty"`
BonusText MiscBonusBonusText `json:"bonusText"`
Importance int64 `json:"importance"`
IsPositive *bool `json:"isPositive,omitempty"`
UnitID *int64 `json:"unitID,omitempty"`
}
type MiscBonusBonusText struct {
De *string `json:"de,omitempty"`
En string `json:"en"`
Es *string `json:"es,omitempty"`
Fr *string `json:"fr,omitempty"`
Ja *string `json:"ja,omitempty"`
Ko *string `json:"ko,omitempty"`
Ru *string `json:"ru,omitempty"`
Zh *string `json:"zh,omitempty"`
}
type RoleBonus struct {
Bonus *float64 `json:"bonus,omitempty"`
BonusText RoleBonusBonusText `json:"bonusText"`
Importance int64 `json:"importance"`
UnitID *int64 `json:"unitID,omitempty"`
}
type RoleBonusBonusText struct {
De *string `json:"de,omitempty"`
En string `json:"en"`
Es *string `json:"es,omitempty"`
Fr *string `json:"fr,omitempty"`
Ja *string `json:"ja,omitempty"`
Ko *string `json:"ko,omitempty"`
Ru *string `json:"ru,omitempty"`
Zh *string `json:"zh,omitempty"`
}
type Type struct {
Key int64 `json:"_key"`
Value []Value `json:"_value"`
}
type Value struct {
Bonus *float64 `json:"bonus,omitempty"`
BonusText ValueBonusText `json:"bonusText"`
Importance int64 `json:"importance"`
UnitID *int64 `json:"unitID,omitempty"`
}
type ValueBonusText struct {
De *string `json:"de,omitempty"`
En string `json:"en"`
Es *string `json:"es,omitempty"`
Fr *string `json:"fr,omitempty"`
Ja *string `json:"ja,omitempty"`
Ko *string `json:"ko,omitempty"`
Ru *string `json:"ru,omitempty"`
Zh *string `json:"zh,omitempty"`
}
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"_key": {
"type": "integer",
"minimum": 582,
"maximum": 88001
},
"iconID": {
"type": "integer",
"minimum": 98,
"maximum": 24577
},
"miscBonuses": {
"type": "array",
"items": {
"type": "object",
"properties": {
"bonus": {
"type": "number",
"minimum": -85.0,
"maximum": 200.0
},
"bonusText": {
"type": "object",
"properties": {
"de": {
"type": "string",
"minLength": 23,
"maxLength": 215
},
"en": {
"type": "string",
"minLength": 14,
"maxLength": 173
},
"es": {
"type": "string",
"minLength": 28,
"maxLength": 220
},
"fr": {
"type": "string",
"minLength": 17,
"maxLength": 223
},
"ja": {
"type": "string",
"minLength": 7,
"maxLength": 122
},
"ko": {
"type": "string",
"minLength": 6,
"maxLength": 97
},
"ru": {
"type": "string",
"minLength": 13,
"maxLength": 211
},
"zh": {
"type": "string",
"minLength": 5,
"maxLength": 93
}
},
"required": [
"en"
]
},
"importance": {
"type": "integer",
"minimum": 1,
"maximum": 15
},
"isPositive": {
"type": "boolean"
},
"unitID": {
"type": "integer",
"minimum": 105,
"maximum": 144
}
},
"required": [
"bonusText",
"importance"
]
},
"minItems": 1,
"maxItems": 15
},
"roleBonuses": {
"type": "array",
"items": {
"type": "object",
"properties": {
"bonus": {
"type": "number",
"minimum": -85.0,
"maximum": 1400.0
},
"bonusText": {
"type": "object",
"properties": {
"de": {
"type": "string",
"minLength": 9,
"maxLength": 405
},
"en": {
"type": "string",
"minLength": 7,
"maxLength": 340
},
"es": {
"type": "string",
"minLength": 6,
"maxLength": 382
},
"fr": {
"type": "string",
"minLength": 7,
"maxLength": 392
},
"ja": {
"type": "string",
"minLength": 6,
"maxLength": 248
},
"ko": {
"type": "string",
"minLength": 7,
"maxLength": 230
},
"ru": {
"type": "string",
"minLength": 22,
"maxLength": 338
},
"zh": {
"type": "string",
"minLength": 4,
"maxLength": 193
}
},
"required": [
"en"
]
},
"importance": {
"type": "integer",
"minimum": 1,
"maximum": 150
},
"unitID": {
"type": "integer",
"minimum": 104,
"maximum": 139
}
},
"required": [
"bonusText",
"importance"
]
},
"minItems": 1,
"maxItems": 14
},
"types": {
"type": "array",
"items": {
"type": "object",
"properties": {
"_key": {
"type": "integer",
"minimum": 3184,
"maximum": 81044
},
"_value": {
"type": "array",
"items": {
"type": "object",
"properties": {
"bonus": {
"type": "number",
"minimum": -4.0,
"maximum": 5000.0
},
"bonusText": {
"type": "object",
"properties": {
"de": {
"type": "string",
"minLength": 24,
"maxLength": 221
},
"en": {
"type": "string",
"minLength": 21,
"maxLength": 188
},
"es": {
"type": "string",
"minLength": 35,
"maxLength": 230
},
"fr": {
"type": "string",
"minLength": 29,
"maxLength": 216
},
"ja": {
"type": "string",
"minLength": 7,
"maxLength": 149
},
"ko": {
"type": "string",
"minLength": 6,
"maxLength": 145
},
"ru": {
"type": "string",
"minLength": 22,
"maxLength": 262
},
"zh": {
"type": "string",
"minLength": 5,
"maxLength": 129
}
},
"required": [
"en"
]
},
"importance": {
"type": "integer",
"minimum": 1,
"maximum": 30
},
"unitID": {
"type": "integer",
"minimum": 1,
"maximum": 139
}
},
"required": [
"bonusText",
"importance"
]
},
"minItems": 1,
"maxItems": 8
}
},
"required": [
"_key",
"_value"
]
},
"minItems": 1,
"maxItems": 5
}
},
"required": [
"_key"
]
}
// To parse the JSON, install kotlin's serialization plugin and do:
//
// val json = Json { allowStructuredMapKeys = true }
// val typeBonus = json.parse(TypeBonus.serializer(), jsonString)
package model
import kotlinx.serialization.*
import kotlinx.serialization.json.*
import kotlinx.serialization.descriptors.*
import kotlinx.serialization.encoding.*
@Serializable
data class TypeBonus (
@SerialName("_key")
val key: Long,
@SerialName("iconID")
val iconId: Long? = null,
val miscBonuses: List<MiscBonus>? = null,
val roleBonuses: List<RoleBonus>? = null,
val types: List<Type>? = null
)
@Serializable
data class MiscBonus (
val bonus: Double? = null,
val bonusText: MiscBonusBonusText,
val importance: Long,
val isPositive: Boolean? = null,
@SerialName("unitID")
val unitId: Long? = null
)
@Serializable
data class MiscBonusBonusText (
val de: String? = null,
val en: String,
val es: String? = null,
val fr: String? = null,
val ja: String? = null,
val ko: String? = null,
val ru: String? = null,
val zh: String? = null
)
@Serializable
data class RoleBonus (
val bonus: Double? = null,
val bonusText: RoleBonusBonusText,
val importance: Long,
@SerialName("unitID")
val unitId: Long? = null
)
@Serializable
data class RoleBonusBonusText (
val de: String? = null,
val en: String,
val es: String? = null,
val fr: String? = null,
val ja: String? = null,
val ko: String? = null,
val ru: String? = null,
val zh: String? = null
)
@Serializable
data class Type (
@SerialName("_key")
val key: Long,
@SerialName("_value")
val value: List<Value>
)
@Serializable
data class Value (
val bonus: Double? = null,
val bonusText: ValueBonusText,
val importance: Long,
@SerialName("unitID")
val unitId: Long? = null
)
@Serializable
data class ValueBonusText (
val de: String? = null,
val en: String,
val es: String? = null,
val fr: String? = null,
val ja: String? = null,
val ko: String? = null,
val ru: String? = null,
val zh: String? = null
)
<?php
// This is a autogenerated file:TypeBonus
class TypeBonus {
private int $key; // json:_key Required
private ?int $iconId; // json:iconID Optional
private ?array $miscBonuses; // json:miscBonuses Optional
private ?array $roleBonuses; // json:roleBonuses Optional
private ?array $types; // json:types Optional
/**
* @param int $key
* @param int|null $iconId
* @param array|null $miscBonuses
* @param array|null $roleBonuses
* @param array|null $types
*/
public function __construct(int $key, ?int $iconId, ?array $miscBonuses, ?array $roleBonuses, ?array $types) {
$this->key = $key;
$this->iconId = $iconId;
$this->miscBonuses = $miscBonuses;
$this->roleBonuses = $roleBonuses;
$this->types = $types;
}
/**
* @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 (TypeBonus::validateKey($this->key)) {
return $this->key; /*int*/
}
throw new Exception('never get to this TypeBonus::key');
}
/**
* @param int
* @return bool
* @throws Exception
*/
public static function validateKey(int $value): bool {
if (!is_integer($value)) {
throw new Exception("Attribute Error:TypeBonus::key");
}
return true;
}
/**
* @throws Exception
* @return int
*/
public function getKey(): int {
if (TypeBonus::validateKey($this->key)) {
return $this->key;
}
throw new Exception('never get to getKey TypeBonus::key');
}
/**
* @return int
*/
public static function sampleKey(): int {
return 31; /*31:key*/
}
/**
* @param ?int $value
* @throws Exception
* @return ?int
*/
public static function fromIconId(?int $value): ?int {
if (!is_null($value)) {
return $value; /*int*/
} else {
return null;
}
}
/**
* @throws Exception
* @return ?int
*/
public function toIconId(): ?int {
if (TypeBonus::validateIconId($this->iconId)) {
if (!is_null($this->iconId)) {
return $this->iconId; /*int*/
} else {
return null;
}
}
throw new Exception('never get to this TypeBonus::iconId');
}
/**
* @param int|null
* @return bool
* @throws Exception
*/
public static function validateIconId(?int $value): bool {
if (!is_null($value)) {
if (!is_integer($value)) {
throw new Exception("Attribute Error:TypeBonus::iconId");
}
}
return true;
}
/**
* @throws Exception
* @return ?int
*/
public function getIconId(): ?int {
if (TypeBonus::validateIconId($this->iconId)) {
return $this->iconId;
}
throw new Exception('never get to getIconId TypeBonus::iconId');
}
/**
* @return ?int
*/
public static function sampleIconId(): ?int {
return 32; /*32:iconId*/
}
/**
* @param ?array $value
* @throws Exception
* @return ?array
*/
public static function fromMiscBonuses(?array $value): ?array {
if (!is_null($value)) {
return array_map(function ($value) {
return MiscBonus::from($value); /*class*/
}, $value);
} else {
return null;
}
}
/**
* @throws Exception
* @return ?array
*/
public function toMiscBonuses(): ?array {
if (TypeBonus::validateMiscBonuses($this->miscBonuses)) {
if (!is_null($this->miscBonuses)) {
return array_map(function ($value) {
return $value->to(); /*class*/
}, $this->miscBonuses);
} else {
return null;
}
}
throw new Exception('never get to this TypeBonus::miscBonuses');
}
/**
* @param array|null
* @return bool
* @throws Exception
*/
public static function validateMiscBonuses(?array $value): bool {
if (!is_null($value)) {
if (!is_array($value)) {
throw new Exception("Attribute Error:TypeBonus::miscBonuses");
}
array_walk($value, function($value_v) {
$value_v->validate();
});
}
return true;
}
/**
* @throws Exception
* @return ?array
*/
public function getMiscBonuses(): ?array {
if (TypeBonus::validateMiscBonuses($this->miscBonuses)) {
return $this->miscBonuses;
}
throw new Exception('never get to getMiscBonuses TypeBonus::miscBonuses');
}
/**
* @return ?array
*/
public static function sampleMiscBonuses(): ?array {
return array(
MiscBonus::sample() /*33:*/
); /* 33:miscBonuses*/
}
/**
* @param ?array $value
* @throws Exception
* @return ?array
*/
public static function fromRoleBonuses(?array $value): ?array {
if (!is_null($value)) {
return array_map(function ($value) {
return RoleBonus::from($value); /*class*/
}, $value);
} else {
return null;
}
}
/**
* @throws Exception
* @return ?array
*/
public function toRoleBonuses(): ?array {
if (TypeBonus::validateRoleBonuses($this->roleBonuses)) {
if (!is_null($this->roleBonuses)) {
return array_map(function ($value) {
return $value->to(); /*class*/
}, $this->roleBonuses);
} else {
return null;
}
}
throw new Exception('never get to this TypeBonus::roleBonuses');
}
/**
* @param array|null
* @return bool
* @throws Exception
*/
public static function validateRoleBonuses(?array $value): bool {
if (!is_null($value)) {
if (!is_array($value)) {
throw new Exception("Attribute Error:TypeBonus::roleBonuses");
}
array_walk($value, function($value_v) {
$value_v->validate();
});
}
return true;
}
/**
* @throws Exception
* @return ?array
*/
public function getRoleBonuses(): ?array {
if (TypeBonus::validateRoleBonuses($this->roleBonuses)) {
return $this->roleBonuses;
}
throw new Exception('never get to getRoleBonuses TypeBonus::roleBonuses');
}
/**
* @return ?array
*/
public static function sampleRoleBonuses(): ?array {
return array(
RoleBonus::sample() /*34:*/
); /* 34:roleBonuses*/
}
/**
* @param ?array $value
* @throws Exception
* @return ?array
*/
public static function fromTypes(?array $value): ?array {
if (!is_null($value)) {
return array_map(function ($value) {
return Type::from($value); /*class*/
}, $value);
} else {
return null;
}
}
/**
* @throws Exception
* @return ?array
*/
public function toTypes(): ?array {
if (TypeBonus::validateTypes($this->types)) {
if (!is_null($this->types)) {
return array_map(function ($value) {
return $value->to(); /*class*/
}, $this->types);
} else {
return null;
}
}
throw new Exception('never get to this TypeBonus::types');
}
/**
* @param array|null
* @return bool
* @throws Exception
*/
public static function validateTypes(?array $value): bool {
if (!is_null($value)) {
if (!is_array($value)) {
throw new Exception("Attribute Error:TypeBonus::types");
}
array_walk($value, function($value_v) {
$value_v->validate();
});
}
return true;
}
/**
* @throws Exception
* @return ?array
*/
public function getTypes(): ?array {
if (TypeBonus::validateTypes($this->types)) {
return $this->types;
}
throw new Exception('never get to getTypes TypeBonus::types');
}
/**
* @return ?array
*/
public static function sampleTypes(): ?array {
return array(
Type::sample() /*35:*/
); /* 35:types*/
}
/**
* @throws Exception
* @return bool
*/
public function validate(): bool {
return TypeBonus::validateKey($this->key)
|| TypeBonus::validateIconId($this->iconId)
|| TypeBonus::validateMiscBonuses($this->miscBonuses)
|| TypeBonus::validateRoleBonuses($this->roleBonuses)
|| TypeBonus::validateTypes($this->types);
}
/**
* @return stdClass
* @throws Exception
*/
public function to(): stdClass {
$out = new stdClass();
$out->{'_key'} = $this->toKey();
$out->{'iconID'} = $this->toIconId();
$out->{'miscBonuses'} = $this->toMiscBonuses();
$out->{'roleBonuses'} = $this->toRoleBonuses();
$out->{'types'} = $this->toTypes();
return $out;
}
/**
* @param stdClass $obj
* @return TypeBonus
* @throws Exception
*/
public static function from(stdClass $obj): TypeBonus {
return new TypeBonus(
TypeBonus::fromKey($obj->{'_key'})
,TypeBonus::fromIconId($obj->{'iconID'})
,TypeBonus::fromMiscBonuses($obj->{'miscBonuses'})
,TypeBonus::fromRoleBonuses($obj->{'roleBonuses'})
,TypeBonus::fromTypes($obj->{'types'})
);
}
/**
* @return TypeBonus
*/
public static function sample(): TypeBonus {
return new TypeBonus(
TypeBonus::sampleKey()
,TypeBonus::sampleIconId()
,TypeBonus::sampleMiscBonuses()
,TypeBonus::sampleRoleBonuses()
,TypeBonus::sampleTypes()
);
}
}
// This is a autogenerated file:MiscBonus
class MiscBonus {
private ?float $bonus; // json:bonus Optional
private MiscBonusBonusText $bonusText; // json:bonusText Required
private int $importance; // json:importance Required
private ?bool $isPositive; // json:isPositive Optional
private ?int $unitId; // json:unitID Optional
/**
* @param float|null $bonus
* @param MiscBonusBonusText $bonusText
* @param int $importance
* @param bool|null $isPositive
* @param int|null $unitId
*/
public function __construct(?float $bonus, MiscBonusBonusText $bonusText, int $importance, ?bool $isPositive, ?int $unitId) {
$this->bonus = $bonus;
$this->bonusText = $bonusText;
$this->importance = $importance;
$this->isPositive = $isPositive;
$this->unitId = $unitId;
}
/**
* @param ?float $value
* @throws Exception
* @return ?float
*/
public static function fromBonus(?float $value): ?float {
if (!is_null($value)) {
return $value; /*float*/
} else {
return null;
}
}
/**
* @throws Exception
* @return ?float
*/
public function toBonus(): ?float {
if (MiscBonus::validateBonus($this->bonus)) {
if (!is_null($this->bonus)) {
return $this->bonus; /*float*/
} else {
return null;
}
}
throw new Exception('never get to this MiscBonus::bonus');
}
/**
* @param float|null
* @return bool
* @throws Exception
*/
public static function validateBonus(?float $value): bool {
if (!is_null($value)) {
if (!is_float($value)) {
throw new Exception("Attribute Error:MiscBonus::bonus");
}
}
return true;
}
/**
* @throws Exception
* @return ?float
*/
public function getBonus(): ?float {
if (MiscBonus::validateBonus($this->bonus)) {
return $this->bonus;
}
throw new Exception('never get to getBonus MiscBonus::bonus');
}
/**
* @return ?float
*/
public static function sampleBonus(): ?float {
return 31.031; /*31:bonus*/
}
/**
* @param stdClass $value
* @throws Exception
* @return MiscBonusBonusText
*/
public static function fromBonusText(stdClass $value): MiscBonusBonusText {
return MiscBonusBonusText::from($value); /*class*/
}
/**
* @throws Exception
* @return stdClass
*/
public function toBonusText(): stdClass {
if (MiscBonus::validateBonusText($this->bonusText)) {
return $this->bonusText->to(); /*class*/
}
throw new Exception('never get to this MiscBonus::bonusText');
}
/**
* @param MiscBonusBonusText
* @return bool
* @throws Exception
*/
public static function validateBonusText(MiscBonusBonusText $value): bool {
$value->validate();
return true;
}
/**
* @throws Exception
* @return MiscBonusBonusText
*/
public function getBonusText(): MiscBonusBonusText {
if (MiscBonus::validateBonusText($this->bonusText)) {
return $this->bonusText;
}
throw new Exception('never get to getBonusText MiscBonus::bonusText');
}
/**
* @return MiscBonusBonusText
*/
public static function sampleBonusText(): MiscBonusBonusText {
return MiscBonusBonusText::sample(); /*32:bonusText*/
}
/**
* @param int $value
* @throws Exception
* @return int
*/
public static function fromImportance(int $value): int {
return $value; /*int*/
}
/**
* @throws Exception
* @return int
*/
public function toImportance(): int {
if (MiscBonus::validateImportance($this->importance)) {
return $this->importance; /*int*/
}
throw new Exception('never get to this MiscBonus::importance');
}
/**
* @param int
* @return bool
* @throws Exception
*/
public static function validateImportance(int $value): bool {
if (!is_integer($value)) {
throw new Exception("Attribute Error:MiscBonus::importance");
}
return true;
}
/**
* @throws Exception
* @return int
*/
public function getImportance(): int {
if (MiscBonus::validateImportance($this->importance)) {
return $this->importance;
}
throw new Exception('never get to getImportance MiscBonus::importance');
}
/**
* @return int
*/
public static function sampleImportance(): int {
return 33; /*33:importance*/
}
/**
* @param ?bool $value
* @throws Exception
* @return ?bool
*/
public static function fromIsPositive(?bool $value): ?bool {
if (!is_null($value)) {
return $value; /*bool*/
} else {
return null;
}
}
/**
* @throws Exception
* @return ?bool
*/
public function toIsPositive(): ?bool {
if (MiscBonus::validateIsPositive($this->isPositive)) {
if (!is_null($this->isPositive)) {
return $this->isPositive; /*bool*/
} else {
return null;
}
}
throw new Exception('never get to this MiscBonus::isPositive');
}
/**
* @param bool|null
* @return bool
* @throws Exception
*/
public static function validateIsPositive(?bool $value): bool {
if (!is_null($value)) {
if (!is_bool($value)) {
throw new Exception("Attribute Error:MiscBonus::isPositive");
}
}
return true;
}
/**
* @throws Exception
* @return ?bool
*/
public function getIsPositive(): ?bool {
if (MiscBonus::validateIsPositive($this->isPositive)) {
return $this->isPositive;
}
throw new Exception('never get to getIsPositive MiscBonus::isPositive');
}
/**
* @return ?bool
*/
public static function sampleIsPositive(): ?bool {
return true; /*34:isPositive*/
}
/**
* @param ?int $value
* @throws Exception
* @return ?int
*/
public static function fromUnitId(?int $value): ?int {
if (!is_null($value)) {
return $value; /*int*/
} else {
return null;
}
}
/**
* @throws Exception
* @return ?int
*/
public function toUnitId(): ?int {
if (MiscBonus::validateUnitId($this->unitId)) {
if (!is_null($this->unitId)) {
return $this->unitId; /*int*/
} else {
return null;
}
}
throw new Exception('never get to this MiscBonus::unitId');
}
/**
* @param int|null
* @return bool
* @throws Exception
*/
public static function validateUnitId(?int $value): bool {
if (!is_null($value)) {
if (!is_integer($value)) {
throw new Exception("Attribute Error:MiscBonus::unitId");
}
}
return true;
}
/**
* @throws Exception
* @return ?int
*/
public function getUnitId(): ?int {
if (MiscBonus::validateUnitId($this->unitId)) {
return $this->unitId;
}
throw new Exception('never get to getUnitId MiscBonus::unitId');
}
/**
* @return ?int
*/
public static function sampleUnitId(): ?int {
return 35; /*35:unitId*/
}
/**
* @throws Exception
* @return bool
*/
public function validate(): bool {
return MiscBonus::validateBonus($this->bonus)
|| MiscBonus::validateBonusText($this->bonusText)
|| MiscBonus::validateImportance($this->importance)
|| MiscBonus::validateIsPositive($this->isPositive)
|| MiscBonus::validateUnitId($this->unitId);
}
/**
* @return stdClass
* @throws Exception
*/
public function to(): stdClass {
$out = new stdClass();
$out->{'bonus'} = $this->toBonus();
$out->{'bonusText'} = $this->toBonusText();
$out->{'importance'} = $this->toImportance();
$out->{'isPositive'} = $this->toIsPositive();
$out->{'unitID'} = $this->toUnitId();
return $out;
}
/**
* @param stdClass $obj
* @return MiscBonus
* @throws Exception
*/
public static function from(stdClass $obj): MiscBonus {
return new MiscBonus(
MiscBonus::fromBonus($obj->{'bonus'})
,MiscBonus::fromBonusText($obj->{'bonusText'})
,MiscBonus::fromImportance($obj->{'importance'})
,MiscBonus::fromIsPositive($obj->{'isPositive'})
,MiscBonus::fromUnitId($obj->{'unitID'})
);
}
/**
* @return MiscBonus
*/
public static function sample(): MiscBonus {
return new MiscBonus(
MiscBonus::sampleBonus()
,MiscBonus::sampleBonusText()
,MiscBonus::sampleImportance()
,MiscBonus::sampleIsPositive()
,MiscBonus::sampleUnitId()
);
}
}
// This is a autogenerated file:MiscBonusBonusText
class MiscBonusBonusText {
private ?string $de; // json:de Optional
private string $en; // json:en Required
private ?string $es; // json:es Optional
private ?string $fr; // json:fr Optional
private ?string $ja; // json:ja Optional
private ?string $ko; // json:ko Optional
private ?string $ru; // json:ru Optional
private ?string $zh; // json:zh Optional
/**
* @param string|null $de
* @param string $en
* @param string|null $es
* @param string|null $fr
* @param string|null $ja
* @param string|null $ko
* @param string|null $ru
* @param string|null $zh
*/
public function __construct(?string $de, string $en, ?string $es, ?string $fr, ?string $ja, ?string $ko, ?string $ru, ?string $zh) {
$this->de = $de;
$this->en = $en;
$this->es = $es;
$this->fr = $fr;
$this->ja = $ja;
$this->ko = $ko;
$this->ru = $ru;
$this->zh = $zh;
}
/**
* @param ?string $value
* @throws Exception
* @return ?string
*/
public static function fromDe(?string $value): ?string {
if (!is_null($value)) {
return $value; /*string*/
} else {
return null;
}
}
/**
* @throws Exception
* @return ?string
*/
public function toDe(): ?string {
if (MiscBonusBonusText::validateDe($this->de)) {
if (!is_null($this->de)) {
return $this->de; /*string*/
} else {
return null;
}
}
throw new Exception('never get to this MiscBonusBonusText::de');
}
/**
* @param string|null
* @return bool
* @throws Exception
*/
public static function validateDe(?string $value): bool {
if (!is_null($value)) {
if (!is_string($value)) {
throw new Exception("Attribute Error:MiscBonusBonusText::de");
}
}
return true;
}
/**
* @throws Exception
* @return ?string
*/
public function getDe(): ?string {
if (MiscBonusBonusText::validateDe($this->de)) {
return $this->de;
}
throw new Exception('never get to getDe MiscBonusBonusText::de');
}
/**
* @return ?string
*/
public static function sampleDe(): ?string {
return 'MiscBonusBonusText::de::31'; /*31:de*/
}
/**
* @param string $value
* @throws Exception
* @return string
*/
public static function fromEn(string $value): string {
return $value; /*string*/
}
/**
* @throws Exception
* @return string
*/
public function toEn(): string {
if (MiscBonusBonusText::validateEn($this->en)) {
return $this->en; /*string*/
}
throw new Exception('never get to this MiscBonusBonusText::en');
}
/**
* @param string
* @return bool
* @throws Exception
*/
public static function validateEn(string $value): bool {
if (!is_string($value)) {
throw new Exception("Attribute Error:MiscBonusBonusText::en");
}
return true;
}
/**
* @throws Exception
* @return string
*/
public function getEn(): string {
if (MiscBonusBonusText::validateEn($this->en)) {
return $this->en;
}
throw new Exception('never get to getEn MiscBonusBonusText::en');
}
/**
* @return string
*/
public static function sampleEn(): string {
return 'MiscBonusBonusText::en::32'; /*32:en*/
}
/**
* @param ?string $value
* @throws Exception
* @return ?string
*/
public static function fromEs(?string $value): ?string {
if (!is_null($value)) {
return $value; /*string*/
} else {
return null;
}
}
/**
* @throws Exception
* @return ?string
*/
public function toEs(): ?string {
if (MiscBonusBonusText::validateEs($this->es)) {
if (!is_null($this->es)) {
return $this->es; /*string*/
} else {
return null;
}
}
throw new Exception('never get to this MiscBonusBonusText::es');
}
/**
* @param string|null
* @return bool
* @throws Exception
*/
public static function validateEs(?string $value): bool {
if (!is_null($value)) {
if (!is_string($value)) {
throw new Exception("Attribute Error:MiscBonusBonusText::es");
}
}
return true;
}
/**
* @throws Exception
* @return ?string
*/
public function getEs(): ?string {
if (MiscBonusBonusText::validateEs($this->es)) {
return $this->es;
}
throw new Exception('never get to getEs MiscBonusBonusText::es');
}
/**
* @return ?string
*/
public static function sampleEs(): ?string {
return 'MiscBonusBonusText::es::33'; /*33:es*/
}
/**
* @param ?string $value
* @throws Exception
* @return ?string
*/
public static function fromFr(?string $value): ?string {
if (!is_null($value)) {
return $value; /*string*/
} else {
return null;
}
}
/**
* @throws Exception
* @return ?string
*/
public function toFr(): ?string {
if (MiscBonusBonusText::validateFr($this->fr)) {
if (!is_null($this->fr)) {
return $this->fr; /*string*/
} else {
return null;
}
}
throw new Exception('never get to this MiscBonusBonusText::fr');
}
/**
* @param string|null
* @return bool
* @throws Exception
*/
public static function validateFr(?string $value): bool {
if (!is_null($value)) {
if (!is_string($value)) {
throw new Exception("Attribute Error:MiscBonusBonusText::fr");
}
}
return true;
}
/**
* @throws Exception
* @return ?string
*/
public function getFr(): ?string {
if (MiscBonusBonusText::validateFr($this->fr)) {
return $this->fr;
}
throw new Exception('never get to getFr MiscBonusBonusText::fr');
}
/**
* @return ?string
*/
public static function sampleFr(): ?string {
return 'MiscBonusBonusText::fr::34'; /*34:fr*/
}
/**
* @param ?string $value
* @throws Exception
* @return ?string
*/
public static function fromJa(?string $value): ?string {
if (!is_null($value)) {
return $value; /*string*/
} else {
return null;
}
}
/**
* @throws Exception
* @return ?string
*/
public function toJa(): ?string {
if (MiscBonusBonusText::validateJa($this->ja)) {
if (!is_null($this->ja)) {
return $this->ja; /*string*/
} else {
return null;
}
}
throw new Exception('never get to this MiscBonusBonusText::ja');
}
/**
* @param string|null
* @return bool
* @throws Exception
*/
public static function validateJa(?string $value): bool {
if (!is_null($value)) {
if (!is_string($value)) {
throw new Exception("Attribute Error:MiscBonusBonusText::ja");
}
}
return true;
}
/**
* @throws Exception
* @return ?string
*/
public function getJa(): ?string {
if (MiscBonusBonusText::validateJa($this->ja)) {
return $this->ja;
}
throw new Exception('never get to getJa MiscBonusBonusText::ja');
}
/**
* @return ?string
*/
public static function sampleJa(): ?string {
return 'MiscBonusBonusText::ja::35'; /*35:ja*/
}
/**
* @param ?string $value
* @throws Exception
* @return ?string
*/
public static function fromKo(?string $value): ?string {
if (!is_null($value)) {
return $value; /*string*/
} else {
return null;
}
}
/**
* @throws Exception
* @return ?string
*/
public function toKo(): ?string {
if (MiscBonusBonusText::validateKo($this->ko)) {
if (!is_null($this->ko)) {
return $this->ko; /*string*/
} else {
return null;
}
}
throw new Exception('never get to this MiscBonusBonusText::ko');
}
/**
* @param string|null
* @return bool
* @throws Exception
*/
public static function validateKo(?string $value): bool {
if (!is_null($value)) {
if (!is_string($value)) {
throw new Exception("Attribute Error:MiscBonusBonusText::ko");
}
}
return true;
}
/**
* @throws Exception
* @return ?string
*/
public function getKo(): ?string {
if (MiscBonusBonusText::validateKo($this->ko)) {
return $this->ko;
}
throw new Exception('never get to getKo MiscBonusBonusText::ko');
}
/**
* @return ?string
*/
public static function sampleKo(): ?string {
return 'MiscBonusBonusText::ko::36'; /*36:ko*/
}
/**
* @param ?string $value
* @throws Exception
* @return ?string
*/
public static function fromRu(?string $value): ?string {
if (!is_null($value)) {
return $value; /*string*/
} else {
return null;
}
}
/**
* @throws Exception
* @return ?string
*/
public function toRu(): ?string {
if (MiscBonusBonusText::validateRu($this->ru)) {
if (!is_null($this->ru)) {
return $this->ru; /*string*/
} else {
return null;
}
}
throw new Exception('never get to this MiscBonusBonusText::ru');
}
/**
* @param string|null
* @return bool
* @throws Exception
*/
public static function validateRu(?string $value): bool {
if (!is_null($value)) {
if (!is_string($value)) {
throw new Exception("Attribute Error:MiscBonusBonusText::ru");
}
}
return true;
}
/**
* @throws Exception
* @return ?string
*/
public function getRu(): ?string {
if (MiscBonusBonusText::validateRu($this->ru)) {
return $this->ru;
}
throw new Exception('never get to getRu MiscBonusBonusText::ru');
}
/**
* @return ?string
*/
public static function sampleRu(): ?string {
return 'MiscBonusBonusText::ru::37'; /*37:ru*/
}
/**
* @param ?string $value
* @throws Exception
* @return ?string
*/
public static function fromZh(?string $value): ?string {
if (!is_null($value)) {
return $value; /*string*/
} else {
return null;
}
}
/**
* @throws Exception
* @return ?string
*/
public function toZh(): ?string {
if (MiscBonusBonusText::validateZh($this->zh)) {
if (!is_null($this->zh)) {
return $this->zh; /*string*/
} else {
return null;
}
}
throw new Exception('never get to this MiscBonusBonusText::zh');
}
/**
* @param string|null
* @return bool
* @throws Exception
*/
public static function validateZh(?string $value): bool {
if (!is_null($value)) {
if (!is_string($value)) {
throw new Exception("Attribute Error:MiscBonusBonusText::zh");
}
}
return true;
}
/**
* @throws Exception
* @return ?string
*/
public function getZh(): ?string {
if (MiscBonusBonusText::validateZh($this->zh)) {
return $this->zh;
}
throw new Exception('never get to getZh MiscBonusBonusText::zh');
}
/**
* @return ?string
*/
public static function sampleZh(): ?string {
return 'MiscBonusBonusText::zh::38'; /*38:zh*/
}
/**
* @throws Exception
* @return bool
*/
public function validate(): bool {
return MiscBonusBonusText::validateDe($this->de)
|| MiscBonusBonusText::validateEn($this->en)
|| MiscBonusBonusText::validateEs($this->es)
|| MiscBonusBonusText::validateFr($this->fr)
|| MiscBonusBonusText::validateJa($this->ja)
|| MiscBonusBonusText::validateKo($this->ko)
|| MiscBonusBonusText::validateRu($this->ru)
|| MiscBonusBonusText::validateZh($this->zh);
}
/**
* @return stdClass
* @throws Exception
*/
public function to(): stdClass {
$out = new stdClass();
$out->{'de'} = $this->toDe();
$out->{'en'} = $this->toEn();
$out->{'es'} = $this->toEs();
$out->{'fr'} = $this->toFr();
$out->{'ja'} = $this->toJa();
$out->{'ko'} = $this->toKo();
$out->{'ru'} = $this->toRu();
$out->{'zh'} = $this->toZh();
return $out;
}
/**
* @param stdClass $obj
* @return MiscBonusBonusText
* @throws Exception
*/
public static function from(stdClass $obj): MiscBonusBonusText {
return new MiscBonusBonusText(
MiscBonusBonusText::fromDe($obj->{'de'})
,MiscBonusBonusText::fromEn($obj->{'en'})
,MiscBonusBonusText::fromEs($obj->{'es'})
,MiscBonusBonusText::fromFr($obj->{'fr'})
,MiscBonusBonusText::fromJa($obj->{'ja'})
,MiscBonusBonusText::fromKo($obj->{'ko'})
,MiscBonusBonusText::fromRu($obj->{'ru'})
,MiscBonusBonusText::fromZh($obj->{'zh'})
);
}
/**
* @return MiscBonusBonusText
*/
public static function sample(): MiscBonusBonusText {
return new MiscBonusBonusText(
MiscBonusBonusText::sampleDe()
,MiscBonusBonusText::sampleEn()
,MiscBonusBonusText::sampleEs()
,MiscBonusBonusText::sampleFr()
,MiscBonusBonusText::sampleJa()
,MiscBonusBonusText::sampleKo()
,MiscBonusBonusText::sampleRu()
,MiscBonusBonusText::sampleZh()
);
}
}
// This is a autogenerated file:RoleBonus
class RoleBonus {
private ?float $bonus; // json:bonus Optional
private RoleBonusBonusText $bonusText; // json:bonusText Required
private int $importance; // json:importance Required
private ?int $unitId; // json:unitID Optional
/**
* @param float|null $bonus
* @param RoleBonusBonusText $bonusText
* @param int $importance
* @param int|null $unitId
*/
public function __construct(?float $bonus, RoleBonusBonusText $bonusText, int $importance, ?int $unitId) {
$this->bonus = $bonus;
$this->bonusText = $bonusText;
$this->importance = $importance;
$this->unitId = $unitId;
}
/**
* @param ?float $value
* @throws Exception
* @return ?float
*/
public static function fromBonus(?float $value): ?float {
if (!is_null($value)) {
return $value; /*float*/
} else {
return null;
}
}
/**
* @throws Exception
* @return ?float
*/
public function toBonus(): ?float {
if (RoleBonus::validateBonus($this->bonus)) {
if (!is_null($this->bonus)) {
return $this->bonus; /*float*/
} else {
return null;
}
}
throw new Exception('never get to this RoleBonus::bonus');
}
/**
* @param float|null
* @return bool
* @throws Exception
*/
public static function validateBonus(?float $value): bool {
if (!is_null($value)) {
if (!is_float($value)) {
throw new Exception("Attribute Error:RoleBonus::bonus");
}
}
return true;
}
/**
* @throws Exception
* @return ?float
*/
public function getBonus(): ?float {
if (RoleBonus::validateBonus($this->bonus)) {
return $this->bonus;
}
throw new Exception('never get to getBonus RoleBonus::bonus');
}
/**
* @return ?float
*/
public static function sampleBonus(): ?float {
return 31.031; /*31:bonus*/
}
/**
* @param stdClass $value
* @throws Exception
* @return RoleBonusBonusText
*/
public static function fromBonusText(stdClass $value): RoleBonusBonusText {
return RoleBonusBonusText::from($value); /*class*/
}
/**
* @throws Exception
* @return stdClass
*/
public function toBonusText(): stdClass {
if (RoleBonus::validateBonusText($this->bonusText)) {
return $this->bonusText->to(); /*class*/
}
throw new Exception('never get to this RoleBonus::bonusText');
}
/**
* @param RoleBonusBonusText
* @return bool
* @throws Exception
*/
public static function validateBonusText(RoleBonusBonusText $value): bool {
$value->validate();
return true;
}
/**
* @throws Exception
* @return RoleBonusBonusText
*/
public function getBonusText(): RoleBonusBonusText {
if (RoleBonus::validateBonusText($this->bonusText)) {
return $this->bonusText;
}
throw new Exception('never get to getBonusText RoleBonus::bonusText');
}
/**
* @return RoleBonusBonusText
*/
public static function sampleBonusText(): RoleBonusBonusText {
return RoleBonusBonusText::sample(); /*32:bonusText*/
}
/**
* @param int $value
* @throws Exception
* @return int
*/
public static function fromImportance(int $value): int {
return $value; /*int*/
}
/**
* @throws Exception
* @return int
*/
public function toImportance(): int {
if (RoleBonus::validateImportance($this->importance)) {
return $this->importance; /*int*/
}
throw new Exception('never get to this RoleBonus::importance');
}
/**
* @param int
* @return bool
* @throws Exception
*/
public static function validateImportance(int $value): bool {
if (!is_integer($value)) {
throw new Exception("Attribute Error:RoleBonus::importance");
}
return true;
}
/**
* @throws Exception
* @return int
*/
public function getImportance(): int {
if (RoleBonus::validateImportance($this->importance)) {
return $this->importance;
}
throw new Exception('never get to getImportance RoleBonus::importance');
}
/**
* @return int
*/
public static function sampleImportance(): int {
return 33; /*33:importance*/
}
/**
* @param ?int $value
* @throws Exception
* @return ?int
*/
public static function fromUnitId(?int $value): ?int {
if (!is_null($value)) {
return $value; /*int*/
} else {
return null;
}
}
/**
* @throws Exception
* @return ?int
*/
public function toUnitId(): ?int {
if (RoleBonus::validateUnitId($this->unitId)) {
if (!is_null($this->unitId)) {
return $this->unitId; /*int*/
} else {
return null;
}
}
throw new Exception('never get to this RoleBonus::unitId');
}
/**
* @param int|null
* @return bool
* @throws Exception
*/
public static function validateUnitId(?int $value): bool {
if (!is_null($value)) {
if (!is_integer($value)) {
throw new Exception("Attribute Error:RoleBonus::unitId");
}
}
return true;
}
/**
* @throws Exception
* @return ?int
*/
public function getUnitId(): ?int {
if (RoleBonus::validateUnitId($this->unitId)) {
return $this->unitId;
}
throw new Exception('never get to getUnitId RoleBonus::unitId');
}
/**
* @return ?int
*/
public static function sampleUnitId(): ?int {
return 34; /*34:unitId*/
}
/**
* @throws Exception
* @return bool
*/
public function validate(): bool {
return RoleBonus::validateBonus($this->bonus)
|| RoleBonus::validateBonusText($this->bonusText)
|| RoleBonus::validateImportance($this->importance)
|| RoleBonus::validateUnitId($this->unitId);
}
/**
* @return stdClass
* @throws Exception
*/
public function to(): stdClass {
$out = new stdClass();
$out->{'bonus'} = $this->toBonus();
$out->{'bonusText'} = $this->toBonusText();
$out->{'importance'} = $this->toImportance();
$out->{'unitID'} = $this->toUnitId();
return $out;
}
/**
* @param stdClass $obj
* @return RoleBonus
* @throws Exception
*/
public static function from(stdClass $obj): RoleBonus {
return new RoleBonus(
RoleBonus::fromBonus($obj->{'bonus'})
,RoleBonus::fromBonusText($obj->{'bonusText'})
,RoleBonus::fromImportance($obj->{'importance'})
,RoleBonus::fromUnitId($obj->{'unitID'})
);
}
/**
* @return RoleBonus
*/
public static function sample(): RoleBonus {
return new RoleBonus(
RoleBonus::sampleBonus()
,RoleBonus::sampleBonusText()
,RoleBonus::sampleImportance()
,RoleBonus::sampleUnitId()
);
}
}
// This is a autogenerated file:RoleBonusBonusText
class RoleBonusBonusText {
private ?string $de; // json:de Optional
private string $en; // json:en Required
private ?string $es; // json:es Optional
private ?string $fr; // json:fr Optional
private ?string $ja; // json:ja Optional
private ?string $ko; // json:ko Optional
private ?string $ru; // json:ru Optional
private ?string $zh; // json:zh Optional
/**
* @param string|null $de
* @param string $en
* @param string|null $es
* @param string|null $fr
* @param string|null $ja
* @param string|null $ko
* @param string|null $ru
* @param string|null $zh
*/
public function __construct(?string $de, string $en, ?string $es, ?string $fr, ?string $ja, ?string $ko, ?string $ru, ?string $zh) {
$this->de = $de;
$this->en = $en;
$this->es = $es;
$this->fr = $fr;
$this->ja = $ja;
$this->ko = $ko;
$this->ru = $ru;
$this->zh = $zh;
}
/**
* @param ?string $value
* @throws Exception
* @return ?string
*/
public static function fromDe(?string $value): ?string {
if (!is_null($value)) {
return $value; /*string*/
} else {
return null;
}
}
/**
* @throws Exception
* @return ?string
*/
public function toDe(): ?string {
if (RoleBonusBonusText::validateDe($this->de)) {
if (!is_null($this->de)) {
return $this->de; /*string*/
} else {
return null;
}
}
throw new Exception('never get to this RoleBonusBonusText::de');
}
/**
* @param string|null
* @return bool
* @throws Exception
*/
public static function validateDe(?string $value): bool {
if (!is_null($value)) {
if (!is_string($value)) {
throw new Exception("Attribute Error:RoleBonusBonusText::de");
}
}
return true;
}
/**
* @throws Exception
* @return ?string
*/
public function getDe(): ?string {
if (RoleBonusBonusText::validateDe($this->de)) {
return $this->de;
}
throw new Exception('never get to getDe RoleBonusBonusText::de');
}
/**
* @return ?string
*/
public static function sampleDe(): ?string {
return 'RoleBonusBonusText::de::31'; /*31:de*/
}
/**
* @param string $value
* @throws Exception
* @return string
*/
public static function fromEn(string $value): string {
return $value; /*string*/
}
/**
* @throws Exception
* @return string
*/
public function toEn(): string {
if (RoleBonusBonusText::validateEn($this->en)) {
return $this->en; /*string*/
}
throw new Exception('never get to this RoleBonusBonusText::en');
}
/**
* @param string
* @return bool
* @throws Exception
*/
public static function validateEn(string $value): bool {
if (!is_string($value)) {
throw new Exception("Attribute Error:RoleBonusBonusText::en");
}
return true;
}
/**
* @throws Exception
* @return string
*/
public function getEn(): string {
if (RoleBonusBonusText::validateEn($this->en)) {
return $this->en;
}
throw new Exception('never get to getEn RoleBonusBonusText::en');
}
/**
* @return string
*/
public static function sampleEn(): string {
return 'RoleBonusBonusText::en::32'; /*32:en*/
}
/**
* @param ?string $value
* @throws Exception
* @return ?string
*/
public static function fromEs(?string $value): ?string {
if (!is_null($value)) {
return $value; /*string*/
} else {
return null;
}
}
/**
* @throws Exception
* @return ?string
*/
public function toEs(): ?string {
if (RoleBonusBonusText::validateEs($this->es)) {
if (!is_null($this->es)) {
return $this->es; /*string*/
} else {
return null;
}
}
throw new Exception('never get to this RoleBonusBonusText::es');
}
/**
* @param string|null
* @return bool
* @throws Exception
*/
public static function validateEs(?string $value): bool {
if (!is_null($value)) {
if (!is_string($value)) {
throw new Exception("Attribute Error:RoleBonusBonusText::es");
}
}
return true;
}
/**
* @throws Exception
* @return ?string
*/
public function getEs(): ?string {
if (RoleBonusBonusText::validateEs($this->es)) {
return $this->es;
}
throw new Exception('never get to getEs RoleBonusBonusText::es');
}
/**
* @return ?string
*/
public static function sampleEs(): ?string {
return 'RoleBonusBonusText::es::33'; /*33:es*/
}
/**
* @param ?string $value
* @throws Exception
* @return ?string
*/
public static function fromFr(?string $value): ?string {
if (!is_null($value)) {
return $value; /*string*/
} else {
return null;
}
}
/**
* @throws Exception
* @return ?string
*/
public function toFr(): ?string {
if (RoleBonusBonusText::validateFr($this->fr)) {
if (!is_null($this->fr)) {
return $this->fr; /*string*/
} else {
return null;
}
}
throw new Exception('never get to this RoleBonusBonusText::fr');
}
/**
* @param string|null
* @return bool
* @throws Exception
*/
public static function validateFr(?string $value): bool {
if (!is_null($value)) {
if (!is_string($value)) {
throw new Exception("Attribute Error:RoleBonusBonusText::fr");
}
}
return true;
}
/**
* @throws Exception
* @return ?string
*/
public function getFr(): ?string {
if (RoleBonusBonusText::validateFr($this->fr)) {
return $this->fr;
}
throw new Exception('never get to getFr RoleBonusBonusText::fr');
}
/**
* @return ?string
*/
public static function sampleFr(): ?string {
return 'RoleBonusBonusText::fr::34'; /*34:fr*/
}
/**
* @param ?string $value
* @throws Exception
* @return ?string
*/
public static function fromJa(?string $value): ?string {
if (!is_null($value)) {
return $value; /*string*/
} else {
return null;
}
}
/**
* @throws Exception
* @return ?string
*/
public function toJa(): ?string {
if (RoleBonusBonusText::validateJa($this->ja)) {
if (!is_null($this->ja)) {
return $this->ja; /*string*/
} else {
return null;
}
}
throw new Exception('never get to this RoleBonusBonusText::ja');
}
/**
* @param string|null
* @return bool
* @throws Exception
*/
public static function validateJa(?string $value): bool {
if (!is_null($value)) {
if (!is_string($value)) {
throw new Exception("Attribute Error:RoleBonusBonusText::ja");
}
}
return true;
}
/**
* @throws Exception
* @return ?string
*/
public function getJa(): ?string {
if (RoleBonusBonusText::validateJa($this->ja)) {
return $this->ja;
}
throw new Exception('never get to getJa RoleBonusBonusText::ja');
}
/**
* @return ?string
*/
public static function sampleJa(): ?string {
return 'RoleBonusBonusText::ja::35'; /*35:ja*/
}
/**
* @param ?string $value
* @throws Exception
* @return ?string
*/
public static function fromKo(?string $value): ?string {
if (!is_null($value)) {
return $value; /*string*/
} else {
return null;
}
}
/**
* @throws Exception
* @return ?string
*/
public function toKo(): ?string {
if (RoleBonusBonusText::validateKo($this->ko)) {
if (!is_null($this->ko)) {
return $this->ko; /*string*/
} else {
return null;
}
}
throw new Exception('never get to this RoleBonusBonusText::ko');
}
/**
* @param string|null
* @return bool
* @throws Exception
*/
public static function validateKo(?string $value): bool {
if (!is_null($value)) {
if (!is_string($value)) {
throw new Exception("Attribute Error:RoleBonusBonusText::ko");
}
}
return true;
}
/**
* @throws Exception
* @return ?string
*/
public function getKo(): ?string {
if (RoleBonusBonusText::validateKo($this->ko)) {
return $this->ko;
}
throw new Exception('never get to getKo RoleBonusBonusText::ko');
}
/**
* @return ?string
*/
public static function sampleKo(): ?string {
return 'RoleBonusBonusText::ko::36'; /*36:ko*/
}
/**
* @param ?string $value
* @throws Exception
* @return ?string
*/
public static function fromRu(?string $value): ?string {
if (!is_null($value)) {
return $value; /*string*/
} else {
return null;
}
}
/**
* @throws Exception
* @return ?string
*/
public function toRu(): ?string {
if (RoleBonusBonusText::validateRu($this->ru)) {
if (!is_null($this->ru)) {
return $this->ru; /*string*/
} else {
return null;
}
}
throw new Exception('never get to this RoleBonusBonusText::ru');
}
/**
* @param string|null
* @return bool
* @throws Exception
*/
public static function validateRu(?string $value): bool {
if (!is_null($value)) {
if (!is_string($value)) {
throw new Exception("Attribute Error:RoleBonusBonusText::ru");
}
}
return true;
}
/**
* @throws Exception
* @return ?string
*/
public function getRu(): ?string {
if (RoleBonusBonusText::validateRu($this->ru)) {
return $this->ru;
}
throw new Exception('never get to getRu RoleBonusBonusText::ru');
}
/**
* @return ?string
*/
public static function sampleRu(): ?string {
return 'RoleBonusBonusText::ru::37'; /*37:ru*/
}
/**
* @param ?string $value
* @throws Exception
* @return ?string
*/
public static function fromZh(?string $value): ?string {
if (!is_null($value)) {
return $value; /*string*/
} else {
return null;
}
}
/**
* @throws Exception
* @return ?string
*/
public function toZh(): ?string {
if (RoleBonusBonusText::validateZh($this->zh)) {
if (!is_null($this->zh)) {
return $this->zh; /*string*/
} else {
return null;
}
}
throw new Exception('never get to this RoleBonusBonusText::zh');
}
/**
* @param string|null
* @return bool
* @throws Exception
*/
public static function validateZh(?string $value): bool {
if (!is_null($value)) {
if (!is_string($value)) {
throw new Exception("Attribute Error:RoleBonusBonusText::zh");
}
}
return true;
}
/**
* @throws Exception
* @return ?string
*/
public function getZh(): ?string {
if (RoleBonusBonusText::validateZh($this->zh)) {
return $this->zh;
}
throw new Exception('never get to getZh RoleBonusBonusText::zh');
}
/**
* @return ?string
*/
public static function sampleZh(): ?string {
return 'RoleBonusBonusText::zh::38'; /*38:zh*/
}
/**
* @throws Exception
* @return bool
*/
public function validate(): bool {
return RoleBonusBonusText::validateDe($this->de)
|| RoleBonusBonusText::validateEn($this->en)
|| RoleBonusBonusText::validateEs($this->es)
|| RoleBonusBonusText::validateFr($this->fr)
|| RoleBonusBonusText::validateJa($this->ja)
|| RoleBonusBonusText::validateKo($this->ko)
|| RoleBonusBonusText::validateRu($this->ru)
|| RoleBonusBonusText::validateZh($this->zh);
}
/**
* @return stdClass
* @throws Exception
*/
public function to(): stdClass {
$out = new stdClass();
$out->{'de'} = $this->toDe();
$out->{'en'} = $this->toEn();
$out->{'es'} = $this->toEs();
$out->{'fr'} = $this->toFr();
$out->{'ja'} = $this->toJa();
$out->{'ko'} = $this->toKo();
$out->{'ru'} = $this->toRu();
$out->{'zh'} = $this->toZh();
return $out;
}
/**
* @param stdClass $obj
* @return RoleBonusBonusText
* @throws Exception
*/
public static function from(stdClass $obj): RoleBonusBonusText {
return new RoleBonusBonusText(
RoleBonusBonusText::fromDe($obj->{'de'})
,RoleBonusBonusText::fromEn($obj->{'en'})
,RoleBonusBonusText::fromEs($obj->{'es'})
,RoleBonusBonusText::fromFr($obj->{'fr'})
,RoleBonusBonusText::fromJa($obj->{'ja'})
,RoleBonusBonusText::fromKo($obj->{'ko'})
,RoleBonusBonusText::fromRu($obj->{'ru'})
,RoleBonusBonusText::fromZh($obj->{'zh'})
);
}
/**
* @return RoleBonusBonusText
*/
public static function sample(): RoleBonusBonusText {
return new RoleBonusBonusText(
RoleBonusBonusText::sampleDe()
,RoleBonusBonusText::sampleEn()
,RoleBonusBonusText::sampleEs()
,RoleBonusBonusText::sampleFr()
,RoleBonusBonusText::sampleJa()
,RoleBonusBonusText::sampleKo()
,RoleBonusBonusText::sampleRu()
,RoleBonusBonusText::sampleZh()
);
}
}
// This is a autogenerated file:Type
class Type {
private int $key; // json:_key Required
private array $value; // json:_value Required
/**
* @param int $key
* @param array $value
*/
public function __construct(int $key, array $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 (Type::validateKey($this->key)) {
return $this->key; /*int*/
}
throw new Exception('never get to this Type::key');
}
/**
* @param int
* @return bool
* @throws Exception
*/
public static function validateKey(int $value): bool {
if (!is_integer($value)) {
throw new Exception("Attribute Error:Type::key");
}
return true;
}
/**
* @throws Exception
* @return int
*/
public function getKey(): int {
if (Type::validateKey($this->key)) {
return $this->key;
}
throw new Exception('never get to getKey Type::key');
}
/**
* @return int
*/
public static function sampleKey(): int {
return 31; /*31:key*/
}
/**
* @param array $value
* @throws Exception
* @return array
*/
public static function fromValue(array $value): array {
return array_map(function ($value) {
return Value::from($value); /*class*/
}, $value);
}
/**
* @throws Exception
* @return array
*/
public function toValue(): array {
if (Type::validateValue($this->value)) {
return array_map(function ($value) {
return $value->to(); /*class*/
}, $this->value);
}
throw new Exception('never get to this Type::value');
}
/**
* @param array
* @return bool
* @throws Exception
*/
public static function validateValue(array $value): bool {
if (!is_array($value)) {
throw new Exception("Attribute Error:Type::value");
}
array_walk($value, function($value_v) {
$value_v->validate();
});
return true;
}
/**
* @throws Exception
* @return array
*/
public function getValue(): array {
if (Type::validateValue($this->value)) {
return $this->value;
}
throw new Exception('never get to getValue Type::value');
}
/**
* @return array
*/
public static function sampleValue(): array {
return array(
Value::sample() /*32:*/
); /* 32:value*/
}
/**
* @throws Exception
* @return bool
*/
public function validate(): bool {
return Type::validateKey($this->key)
|| Type::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 Type
* @throws Exception
*/
public static function from(stdClass $obj): Type {
return new Type(
Type::fromKey($obj->{'_key'})
,Type::fromValue($obj->{'_value'})
);
}
/**
* @return Type
*/
public static function sample(): Type {
return new Type(
Type::sampleKey()
,Type::sampleValue()
);
}
}
// This is a autogenerated file:Value
class Value {
private ?float $bonus; // json:bonus Optional
private ValueBonusText $bonusText; // json:bonusText Required
private int $importance; // json:importance Required
private ?int $unitId; // json:unitID Optional
/**
* @param float|null $bonus
* @param ValueBonusText $bonusText
* @param int $importance
* @param int|null $unitId
*/
public function __construct(?float $bonus, ValueBonusText $bonusText, int $importance, ?int $unitId) {
$this->bonus = $bonus;
$this->bonusText = $bonusText;
$this->importance = $importance;
$this->unitId = $unitId;
}
/**
* @param ?float $value
* @throws Exception
* @return ?float
*/
public static function fromBonus(?float $value): ?float {
if (!is_null($value)) {
return $value; /*float*/
} else {
return null;
}
}
/**
* @throws Exception
* @return ?float
*/
public function toBonus(): ?float {
if (Value::validateBonus($this->bonus)) {
if (!is_null($this->bonus)) {
return $this->bonus; /*float*/
} else {
return null;
}
}
throw new Exception('never get to this Value::bonus');
}
/**
* @param float|null
* @return bool
* @throws Exception
*/
public static function validateBonus(?float $value): bool {
if (!is_null($value)) {
if (!is_float($value)) {
throw new Exception("Attribute Error:Value::bonus");
}
}
return true;
}
/**
* @throws Exception
* @return ?float
*/
public function getBonus(): ?float {
if (Value::validateBonus($this->bonus)) {
return $this->bonus;
}
throw new Exception('never get to getBonus Value::bonus');
}
/**
* @return ?float
*/
public static function sampleBonus(): ?float {
return 31.031; /*31:bonus*/
}
/**
* @param stdClass $value
* @throws Exception
* @return ValueBonusText
*/
public static function fromBonusText(stdClass $value): ValueBonusText {
return ValueBonusText::from($value); /*class*/
}
/**
* @throws Exception
* @return stdClass
*/
public function toBonusText(): stdClass {
if (Value::validateBonusText($this->bonusText)) {
return $this->bonusText->to(); /*class*/
}
throw new Exception('never get to this Value::bonusText');
}
/**
* @param ValueBonusText
* @return bool
* @throws Exception
*/
public static function validateBonusText(ValueBonusText $value): bool {
$value->validate();
return true;
}
/**
* @throws Exception
* @return ValueBonusText
*/
public function getBonusText(): ValueBonusText {
if (Value::validateBonusText($this->bonusText)) {
return $this->bonusText;
}
throw new Exception('never get to getBonusText Value::bonusText');
}
/**
* @return ValueBonusText
*/
public static function sampleBonusText(): ValueBonusText {
return ValueBonusText::sample(); /*32:bonusText*/
}
/**
* @param int $value
* @throws Exception
* @return int
*/
public static function fromImportance(int $value): int {
return $value; /*int*/
}
/**
* @throws Exception
* @return int
*/
public function toImportance(): int {
if (Value::validateImportance($this->importance)) {
return $this->importance; /*int*/
}
throw new Exception('never get to this Value::importance');
}
/**
* @param int
* @return bool
* @throws Exception
*/
public static function validateImportance(int $value): bool {
if (!is_integer($value)) {
throw new Exception("Attribute Error:Value::importance");
}
return true;
}
/**
* @throws Exception
* @return int
*/
public function getImportance(): int {
if (Value::validateImportance($this->importance)) {
return $this->importance;
}
throw new Exception('never get to getImportance Value::importance');
}
/**
* @return int
*/
public static function sampleImportance(): int {
return 33; /*33:importance*/
}
/**
* @param ?int $value
* @throws Exception
* @return ?int
*/
public static function fromUnitId(?int $value): ?int {
if (!is_null($value)) {
return $value; /*int*/
} else {
return null;
}
}
/**
* @throws Exception
* @return ?int
*/
public function toUnitId(): ?int {
if (Value::validateUnitId($this->unitId)) {
if (!is_null($this->unitId)) {
return $this->unitId; /*int*/
} else {
return null;
}
}
throw new Exception('never get to this Value::unitId');
}
/**
* @param int|null
* @return bool
* @throws Exception
*/
public static function validateUnitId(?int $value): bool {
if (!is_null($value)) {
if (!is_integer($value)) {
throw new Exception("Attribute Error:Value::unitId");
}
}
return true;
}
/**
* @throws Exception
* @return ?int
*/
public function getUnitId(): ?int {
if (Value::validateUnitId($this->unitId)) {
return $this->unitId;
}
throw new Exception('never get to getUnitId Value::unitId');
}
/**
* @return ?int
*/
public static function sampleUnitId(): ?int {
return 34; /*34:unitId*/
}
/**
* @throws Exception
* @return bool
*/
public function validate(): bool {
return Value::validateBonus($this->bonus)
|| Value::validateBonusText($this->bonusText)
|| Value::validateImportance($this->importance)
|| Value::validateUnitId($this->unitId);
}
/**
* @return stdClass
* @throws Exception
*/
public function to(): stdClass {
$out = new stdClass();
$out->{'bonus'} = $this->toBonus();
$out->{'bonusText'} = $this->toBonusText();
$out->{'importance'} = $this->toImportance();
$out->{'unitID'} = $this->toUnitId();
return $out;
}
/**
* @param stdClass $obj
* @return Value
* @throws Exception
*/
public static function from(stdClass $obj): Value {
return new Value(
Value::fromBonus($obj->{'bonus'})
,Value::fromBonusText($obj->{'bonusText'})
,Value::fromImportance($obj->{'importance'})
,Value::fromUnitId($obj->{'unitID'})
);
}
/**
* @return Value
*/
public static function sample(): Value {
return new Value(
Value::sampleBonus()
,Value::sampleBonusText()
,Value::sampleImportance()
,Value::sampleUnitId()
);
}
}
// This is a autogenerated file:ValueBonusText
class ValueBonusText {
private ?string $de; // json:de Optional
private string $en; // json:en Required
private ?string $es; // json:es Optional
private ?string $fr; // json:fr Optional
private ?string $ja; // json:ja Optional
private ?string $ko; // json:ko Optional
private ?string $ru; // json:ru Optional
private ?string $zh; // json:zh Optional
/**
* @param string|null $de
* @param string $en
* @param string|null $es
* @param string|null $fr
* @param string|null $ja
* @param string|null $ko
* @param string|null $ru
* @param string|null $zh
*/
public function __construct(?string $de, string $en, ?string $es, ?string $fr, ?string $ja, ?string $ko, ?string $ru, ?string $zh) {
$this->de = $de;
$this->en = $en;
$this->es = $es;
$this->fr = $fr;
$this->ja = $ja;
$this->ko = $ko;
$this->ru = $ru;
$this->zh = $zh;
}
/**
* @param ?string $value
* @throws Exception
* @return ?string
*/
public static function fromDe(?string $value): ?string {
if (!is_null($value)) {
return $value; /*string*/
} else {
return null;
}
}
/**
* @throws Exception
* @return ?string
*/
public function toDe(): ?string {
if (ValueBonusText::validateDe($this->de)) {
if (!is_null($this->de)) {
return $this->de; /*string*/
} else {
return null;
}
}
throw new Exception('never get to this ValueBonusText::de');
}
/**
* @param string|null
* @return bool
* @throws Exception
*/
public static function validateDe(?string $value): bool {
if (!is_null($value)) {
if (!is_string($value)) {
throw new Exception("Attribute Error:ValueBonusText::de");
}
}
return true;
}
/**
* @throws Exception
* @return ?string
*/
public function getDe(): ?string {
if (ValueBonusText::validateDe($this->de)) {
return $this->de;
}
throw new Exception('never get to getDe ValueBonusText::de');
}
/**
* @return ?string
*/
public static function sampleDe(): ?string {
return 'ValueBonusText::de::31'; /*31:de*/
}
/**
* @param string $value
* @throws Exception
* @return string
*/
public static function fromEn(string $value): string {
return $value; /*string*/
}
/**
* @throws Exception
* @return string
*/
public function toEn(): string {
if (ValueBonusText::validateEn($this->en)) {
return $this->en; /*string*/
}
throw new Exception('never get to this ValueBonusText::en');
}
/**
* @param string
* @return bool
* @throws Exception
*/
public static function validateEn(string $value): bool {
if (!is_string($value)) {
throw new Exception("Attribute Error:ValueBonusText::en");
}
return true;
}
/**
* @throws Exception
* @return string
*/
public function getEn(): string {
if (ValueBonusText::validateEn($this->en)) {
return $this->en;
}
throw new Exception('never get to getEn ValueBonusText::en');
}
/**
* @return string
*/
public static function sampleEn(): string {
return 'ValueBonusText::en::32'; /*32:en*/
}
/**
* @param ?string $value
* @throws Exception
* @return ?string
*/
public static function fromEs(?string $value): ?string {
if (!is_null($value)) {
return $value; /*string*/
} else {
return null;
}
}
/**
* @throws Exception
* @return ?string
*/
public function toEs(): ?string {
if (ValueBonusText::validateEs($this->es)) {
if (!is_null($this->es)) {
return $this->es; /*string*/
} else {
return null;
}
}
throw new Exception('never get to this ValueBonusText::es');
}
/**
* @param string|null
* @return bool
* @throws Exception
*/
public static function validateEs(?string $value): bool {
if (!is_null($value)) {
if (!is_string($value)) {
throw new Exception("Attribute Error:ValueBonusText::es");
}
}
return true;
}
/**
* @throws Exception
* @return ?string
*/
public function getEs(): ?string {
if (ValueBonusText::validateEs($this->es)) {
return $this->es;
}
throw new Exception('never get to getEs ValueBonusText::es');
}
/**
* @return ?string
*/
public static function sampleEs(): ?string {
return 'ValueBonusText::es::33'; /*33:es*/
}
/**
* @param ?string $value
* @throws Exception
* @return ?string
*/
public static function fromFr(?string $value): ?string {
if (!is_null($value)) {
return $value; /*string*/
} else {
return null;
}
}
/**
* @throws Exception
* @return ?string
*/
public function toFr(): ?string {
if (ValueBonusText::validateFr($this->fr)) {
if (!is_null($this->fr)) {
return $this->fr; /*string*/
} else {
return null;
}
}
throw new Exception('never get to this ValueBonusText::fr');
}
/**
* @param string|null
* @return bool
* @throws Exception
*/
public static function validateFr(?string $value): bool {
if (!is_null($value)) {
if (!is_string($value)) {
throw new Exception("Attribute Error:ValueBonusText::fr");
}
}
return true;
}
/**
* @throws Exception
* @return ?string
*/
public function getFr(): ?string {
if (ValueBonusText::validateFr($this->fr)) {
return $this->fr;
}
throw new Exception('never get to getFr ValueBonusText::fr');
}
/**
* @return ?string
*/
public static function sampleFr(): ?string {
return 'ValueBonusText::fr::34'; /*34:fr*/
}
/**
* @param ?string $value
* @throws Exception
* @return ?string
*/
public static function fromJa(?string $value): ?string {
if (!is_null($value)) {
return $value; /*string*/
} else {
return null;
}
}
/**
* @throws Exception
* @return ?string
*/
public function toJa(): ?string {
if (ValueBonusText::validateJa($this->ja)) {
if (!is_null($this->ja)) {
return $this->ja; /*string*/
} else {
return null;
}
}
throw new Exception('never get to this ValueBonusText::ja');
}
/**
* @param string|null
* @return bool
* @throws Exception
*/
public static function validateJa(?string $value): bool {
if (!is_null($value)) {
if (!is_string($value)) {
throw new Exception("Attribute Error:ValueBonusText::ja");
}
}
return true;
}
/**
* @throws Exception
* @return ?string
*/
public function getJa(): ?string {
if (ValueBonusText::validateJa($this->ja)) {
return $this->ja;
}
throw new Exception('never get to getJa ValueBonusText::ja');
}
/**
* @return ?string
*/
public static function sampleJa(): ?string {
return 'ValueBonusText::ja::35'; /*35:ja*/
}
/**
* @param ?string $value
* @throws Exception
* @return ?string
*/
public static function fromKo(?string $value): ?string {
if (!is_null($value)) {
return $value; /*string*/
} else {
return null;
}
}
/**
* @throws Exception
* @return ?string
*/
public function toKo(): ?string {
if (ValueBonusText::validateKo($this->ko)) {
if (!is_null($this->ko)) {
return $this->ko; /*string*/
} else {
return null;
}
}
throw new Exception('never get to this ValueBonusText::ko');
}
/**
* @param string|null
* @return bool
* @throws Exception
*/
public static function validateKo(?string $value): bool {
if (!is_null($value)) {
if (!is_string($value)) {
throw new Exception("Attribute Error:ValueBonusText::ko");
}
}
return true;
}
/**
* @throws Exception
* @return ?string
*/
public function getKo(): ?string {
if (ValueBonusText::validateKo($this->ko)) {
return $this->ko;
}
throw new Exception('never get to getKo ValueBonusText::ko');
}
/**
* @return ?string
*/
public static function sampleKo(): ?string {
return 'ValueBonusText::ko::36'; /*36:ko*/
}
/**
* @param ?string $value
* @throws Exception
* @return ?string
*/
public static function fromRu(?string $value): ?string {
if (!is_null($value)) {
return $value; /*string*/
} else {
return null;
}
}
/**
* @throws Exception
* @return ?string
*/
public function toRu(): ?string {
if (ValueBonusText::validateRu($this->ru)) {
if (!is_null($this->ru)) {
return $this->ru; /*string*/
} else {
return null;
}
}
throw new Exception('never get to this ValueBonusText::ru');
}
/**
* @param string|null
* @return bool
* @throws Exception
*/
public static function validateRu(?string $value): bool {
if (!is_null($value)) {
if (!is_string($value)) {
throw new Exception("Attribute Error:ValueBonusText::ru");
}
}
return true;
}
/**
* @throws Exception
* @return ?string
*/
public function getRu(): ?string {
if (ValueBonusText::validateRu($this->ru)) {
return $this->ru;
}
throw new Exception('never get to getRu ValueBonusText::ru');
}
/**
* @return ?string
*/
public static function sampleRu(): ?string {
return 'ValueBonusText::ru::37'; /*37:ru*/
}
/**
* @param ?string $value
* @throws Exception
* @return ?string
*/
public static function fromZh(?string $value): ?string {
if (!is_null($value)) {
return $value; /*string*/
} else {
return null;
}
}
/**
* @throws Exception
* @return ?string
*/
public function toZh(): ?string {
if (ValueBonusText::validateZh($this->zh)) {
if (!is_null($this->zh)) {
return $this->zh; /*string*/
} else {
return null;
}
}
throw new Exception('never get to this ValueBonusText::zh');
}
/**
* @param string|null
* @return bool
* @throws Exception
*/
public static function validateZh(?string $value): bool {
if (!is_null($value)) {
if (!is_string($value)) {
throw new Exception("Attribute Error:ValueBonusText::zh");
}
}
return true;
}
/**
* @throws Exception
* @return ?string
*/
public function getZh(): ?string {
if (ValueBonusText::validateZh($this->zh)) {
return $this->zh;
}
throw new Exception('never get to getZh ValueBonusText::zh');
}
/**
* @return ?string
*/
public static function sampleZh(): ?string {
return 'ValueBonusText::zh::38'; /*38:zh*/
}
/**
* @throws Exception
* @return bool
*/
public function validate(): bool {
return ValueBonusText::validateDe($this->de)
|| ValueBonusText::validateEn($this->en)
|| ValueBonusText::validateEs($this->es)
|| ValueBonusText::validateFr($this->fr)
|| ValueBonusText::validateJa($this->ja)
|| ValueBonusText::validateKo($this->ko)
|| ValueBonusText::validateRu($this->ru)
|| ValueBonusText::validateZh($this->zh);
}
/**
* @return stdClass
* @throws Exception
*/
public function to(): stdClass {
$out = new stdClass();
$out->{'de'} = $this->toDe();
$out->{'en'} = $this->toEn();
$out->{'es'} = $this->toEs();
$out->{'fr'} = $this->toFr();
$out->{'ja'} = $this->toJa();
$out->{'ko'} = $this->toKo();
$out->{'ru'} = $this->toRu();
$out->{'zh'} = $this->toZh();
return $out;
}
/**
* @param stdClass $obj
* @return ValueBonusText
* @throws Exception
*/
public static function from(stdClass $obj): ValueBonusText {
return new ValueBonusText(
ValueBonusText::fromDe($obj->{'de'})
,ValueBonusText::fromEn($obj->{'en'})
,ValueBonusText::fromEs($obj->{'es'})
,ValueBonusText::fromFr($obj->{'fr'})
,ValueBonusText::fromJa($obj->{'ja'})
,ValueBonusText::fromKo($obj->{'ko'})
,ValueBonusText::fromRu($obj->{'ru'})
,ValueBonusText::fromZh($obj->{'zh'})
);
}
/**
* @return ValueBonusText
*/
public static function sample(): ValueBonusText {
return new ValueBonusText(
ValueBonusText::sampleDe()
,ValueBonusText::sampleEn()
,ValueBonusText::sampleEs()
,ValueBonusText::sampleFr()
,ValueBonusText::sampleJa()
,ValueBonusText::sampleKo()
,ValueBonusText::sampleRu()
,ValueBonusText::sampleZh()
);
}
}
from typing import Optional, Any, List, TypeVar, Type, cast, Callable
T = TypeVar("T")
def from_str(x: Any) -> str:
assert isinstance(x, str)
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 from_float(x: Any) -> float:
assert isinstance(x, (float, int)) and not isinstance(x, bool)
return float(x)
def from_int(x: Any) -> int:
assert isinstance(x, int) and not isinstance(x, bool)
return x
def from_bool(x: Any) -> bool:
assert isinstance(x, bool)
return x
def to_float(x: Any) -> float:
assert isinstance(x, (int, float))
return x
def to_class(c: Type[T], x: Any) -> dict:
assert isinstance(x, c)
return cast(Any, x).to_dict()
def from_list(f: Callable[[Any], T], x: Any) -> List[T]:
assert isinstance(x, list)
return [f(y) for y in x]
class MiscBonusBonusText:
de: Optional[str]
en: str
es: Optional[str]
fr: Optional[str]
ja: Optional[str]
ko: Optional[str]
ru: Optional[str]
zh: Optional[str]
def __init__(self, de: Optional[str], en: str, es: Optional[str], fr: Optional[str], ja: Optional[str], ko: Optional[str], ru: Optional[str], zh: Optional[str]) -> None:
self.de = de
self.en = en
self.es = es
self.fr = fr
self.ja = ja
self.ko = ko
self.ru = ru
self.zh = zh
@staticmethod
def from_dict(obj: Any) -> 'MiscBonusBonusText':
assert isinstance(obj, dict)
de = from_union([from_str, from_none], obj.get("de"))
en = from_str(obj.get("en"))
es = from_union([from_str, from_none], obj.get("es"))
fr = from_union([from_str, from_none], obj.get("fr"))
ja = from_union([from_str, from_none], obj.get("ja"))
ko = from_union([from_str, from_none], obj.get("ko"))
ru = from_union([from_str, from_none], obj.get("ru"))
zh = from_union([from_str, from_none], obj.get("zh"))
return MiscBonusBonusText(de, en, es, fr, ja, ko, ru, zh)
def to_dict(self) -> dict:
result: dict = {}
if self.de is not None:
result["de"] = from_union([from_str, from_none], self.de)
result["en"] = from_str(self.en)
if self.es is not None:
result["es"] = from_union([from_str, from_none], self.es)
if self.fr is not None:
result["fr"] = from_union([from_str, from_none], self.fr)
if self.ja is not None:
result["ja"] = from_union([from_str, from_none], self.ja)
if self.ko is not None:
result["ko"] = from_union([from_str, from_none], self.ko)
if self.ru is not None:
result["ru"] = from_union([from_str, from_none], self.ru)
if self.zh is not None:
result["zh"] = from_union([from_str, from_none], self.zh)
return result
class MiscBonus:
bonus: Optional[float]
bonus_text: MiscBonusBonusText
importance: int
is_positive: Optional[bool]
unit_id: Optional[int]
def __init__(self, bonus: Optional[float], bonus_text: MiscBonusBonusText, importance: int, is_positive: Optional[bool], unit_id: Optional[int]) -> None:
self.bonus = bonus
self.bonus_text = bonus_text
self.importance = importance
self.is_positive = is_positive
self.unit_id = unit_id
@staticmethod
def from_dict(obj: Any) -> 'MiscBonus':
assert isinstance(obj, dict)
bonus = from_union([from_float, from_none], obj.get("bonus"))
bonus_text = MiscBonusBonusText.from_dict(obj.get("bonusText"))
importance = from_int(obj.get("importance"))
is_positive = from_union([from_bool, from_none], obj.get("isPositive"))
unit_id = from_union([from_int, from_none], obj.get("unitID"))
return MiscBonus(bonus, bonus_text, importance, is_positive, unit_id)
def to_dict(self) -> dict:
result: dict = {}
if self.bonus is not None:
result["bonus"] = from_union([to_float, from_none], self.bonus)
result["bonusText"] = to_class(MiscBonusBonusText, self.bonus_text)
result["importance"] = from_int(self.importance)
if self.is_positive is not None:
result["isPositive"] = from_union([from_bool, from_none], self.is_positive)
if self.unit_id is not None:
result["unitID"] = from_union([from_int, from_none], self.unit_id)
return result
class RoleBonusBonusText:
de: Optional[str]
en: str
es: Optional[str]
fr: Optional[str]
ja: Optional[str]
ko: Optional[str]
ru: Optional[str]
zh: Optional[str]
def __init__(self, de: Optional[str], en: str, es: Optional[str], fr: Optional[str], ja: Optional[str], ko: Optional[str], ru: Optional[str], zh: Optional[str]) -> None:
self.de = de
self.en = en
self.es = es
self.fr = fr
self.ja = ja
self.ko = ko
self.ru = ru
self.zh = zh
@staticmethod
def from_dict(obj: Any) -> 'RoleBonusBonusText':
assert isinstance(obj, dict)
de = from_union([from_str, from_none], obj.get("de"))
en = from_str(obj.get("en"))
es = from_union([from_str, from_none], obj.get("es"))
fr = from_union([from_str, from_none], obj.get("fr"))
ja = from_union([from_str, from_none], obj.get("ja"))
ko = from_union([from_str, from_none], obj.get("ko"))
ru = from_union([from_str, from_none], obj.get("ru"))
zh = from_union([from_str, from_none], obj.get("zh"))
return RoleBonusBonusText(de, en, es, fr, ja, ko, ru, zh)
def to_dict(self) -> dict:
result: dict = {}
if self.de is not None:
result["de"] = from_union([from_str, from_none], self.de)
result["en"] = from_str(self.en)
if self.es is not None:
result["es"] = from_union([from_str, from_none], self.es)
if self.fr is not None:
result["fr"] = from_union([from_str, from_none], self.fr)
if self.ja is not None:
result["ja"] = from_union([from_str, from_none], self.ja)
if self.ko is not None:
result["ko"] = from_union([from_str, from_none], self.ko)
if self.ru is not None:
result["ru"] = from_union([from_str, from_none], self.ru)
if self.zh is not None:
result["zh"] = from_union([from_str, from_none], self.zh)
return result
class RoleBonus:
bonus: Optional[float]
bonus_text: RoleBonusBonusText
importance: int
unit_id: Optional[int]
def __init__(self, bonus: Optional[float], bonus_text: RoleBonusBonusText, importance: int, unit_id: Optional[int]) -> None:
self.bonus = bonus
self.bonus_text = bonus_text
self.importance = importance
self.unit_id = unit_id
@staticmethod
def from_dict(obj: Any) -> 'RoleBonus':
assert isinstance(obj, dict)
bonus = from_union([from_float, from_none], obj.get("bonus"))
bonus_text = RoleBonusBonusText.from_dict(obj.get("bonusText"))
importance = from_int(obj.get("importance"))
unit_id = from_union([from_int, from_none], obj.get("unitID"))
return RoleBonus(bonus, bonus_text, importance, unit_id)
def to_dict(self) -> dict:
result: dict = {}
if self.bonus is not None:
result["bonus"] = from_union([to_float, from_none], self.bonus)
result["bonusText"] = to_class(RoleBonusBonusText, self.bonus_text)
result["importance"] = from_int(self.importance)
if self.unit_id is not None:
result["unitID"] = from_union([from_int, from_none], self.unit_id)
return result
class ValueBonusText:
de: Optional[str]
en: str
es: Optional[str]
fr: Optional[str]
ja: Optional[str]
ko: Optional[str]
ru: Optional[str]
zh: Optional[str]
def __init__(self, de: Optional[str], en: str, es: Optional[str], fr: Optional[str], ja: Optional[str], ko: Optional[str], ru: Optional[str], zh: Optional[str]) -> None:
self.de = de
self.en = en
self.es = es
self.fr = fr
self.ja = ja
self.ko = ko
self.ru = ru
self.zh = zh
@staticmethod
def from_dict(obj: Any) -> 'ValueBonusText':
assert isinstance(obj, dict)
de = from_union([from_str, from_none], obj.get("de"))
en = from_str(obj.get("en"))
es = from_union([from_str, from_none], obj.get("es"))
fr = from_union([from_str, from_none], obj.get("fr"))
ja = from_union([from_str, from_none], obj.get("ja"))
ko = from_union([from_str, from_none], obj.get("ko"))
ru = from_union([from_str, from_none], obj.get("ru"))
zh = from_union([from_str, from_none], obj.get("zh"))
return ValueBonusText(de, en, es, fr, ja, ko, ru, zh)
def to_dict(self) -> dict:
result: dict = {}
if self.de is not None:
result["de"] = from_union([from_str, from_none], self.de)
result["en"] = from_str(self.en)
if self.es is not None:
result["es"] = from_union([from_str, from_none], self.es)
if self.fr is not None:
result["fr"] = from_union([from_str, from_none], self.fr)
if self.ja is not None:
result["ja"] = from_union([from_str, from_none], self.ja)
if self.ko is not None:
result["ko"] = from_union([from_str, from_none], self.ko)
if self.ru is not None:
result["ru"] = from_union([from_str, from_none], self.ru)
if self.zh is not None:
result["zh"] = from_union([from_str, from_none], self.zh)
return result
class Value:
bonus: Optional[float]
bonus_text: ValueBonusText
importance: int
unit_id: Optional[int]
def __init__(self, bonus: Optional[float], bonus_text: ValueBonusText, importance: int, unit_id: Optional[int]) -> None:
self.bonus = bonus
self.bonus_text = bonus_text
self.importance = importance
self.unit_id = unit_id
@staticmethod
def from_dict(obj: Any) -> 'Value':
assert isinstance(obj, dict)
bonus = from_union([from_float, from_none], obj.get("bonus"))
bonus_text = ValueBonusText.from_dict(obj.get("bonusText"))
importance = from_int(obj.get("importance"))
unit_id = from_union([from_int, from_none], obj.get("unitID"))
return Value(bonus, bonus_text, importance, unit_id)
def to_dict(self) -> dict:
result: dict = {}
if self.bonus is not None:
result["bonus"] = from_union([to_float, from_none], self.bonus)
result["bonusText"] = to_class(ValueBonusText, self.bonus_text)
result["importance"] = from_int(self.importance)
if self.unit_id is not None:
result["unitID"] = from_union([from_int, from_none], self.unit_id)
return result
class TypeElement:
key: int
value: List[Value]
def __init__(self, key: int, value: List[Value]) -> None:
self.key = key
self.value = value
@staticmethod
def from_dict(obj: Any) -> 'TypeElement':
assert isinstance(obj, dict)
key = from_int(obj.get("_key"))
value = from_list(Value.from_dict, obj.get("_value"))
return TypeElement(key, value)
def to_dict(self) -> dict:
result: dict = {}
result["_key"] = from_int(self.key)
result["_value"] = from_list(lambda x: to_class(Value, x), self.value)
return result
class TypeBonus:
key: int
icon_id: Optional[int]
misc_bonuses: Optional[List[MiscBonus]]
role_bonuses: Optional[List[RoleBonus]]
types: Optional[List[TypeElement]]
def __init__(self, key: int, icon_id: Optional[int], misc_bonuses: Optional[List[MiscBonus]], role_bonuses: Optional[List[RoleBonus]], types: Optional[List[TypeElement]]) -> None:
self.key = key
self.icon_id = icon_id
self.misc_bonuses = misc_bonuses
self.role_bonuses = role_bonuses
self.types = types
@staticmethod
def from_dict(obj: Any) -> 'TypeBonus':
assert isinstance(obj, dict)
key = from_int(obj.get("_key"))
icon_id = from_union([from_int, from_none], obj.get("iconID"))
misc_bonuses = from_union([lambda x: from_list(MiscBonus.from_dict, x), from_none], obj.get("miscBonuses"))
role_bonuses = from_union([lambda x: from_list(RoleBonus.from_dict, x), from_none], obj.get("roleBonuses"))
types = from_union([lambda x: from_list(TypeElement.from_dict, x), from_none], obj.get("types"))
return TypeBonus(key, icon_id, misc_bonuses, role_bonuses, types)
def to_dict(self) -> dict:
result: dict = {}
result["_key"] = from_int(self.key)
if self.icon_id is not None:
result["iconID"] = from_union([from_int, from_none], self.icon_id)
if self.misc_bonuses is not None:
result["miscBonuses"] = from_union([lambda x: from_list(lambda x: to_class(MiscBonus, x), x), from_none], self.misc_bonuses)
if self.role_bonuses is not None:
result["roleBonuses"] = from_union([lambda x: from_list(lambda x: to_class(RoleBonus, x), x), from_none], self.role_bonuses)
if self.types is not None:
result["types"] = from_union([lambda x: from_list(lambda x: to_class(TypeElement, x), x), from_none], self.types)
return result
def type_bonus_from_dict(s: Any) -> TypeBonus:
return TypeBonus.from_dict(s)
def type_bonus_to_dict(x: TypeBonus) -> Any:
return to_class(TypeBonus, x)
// To parse this data:
//
// import { Convert, TypeBonus } from "./file";
//
// const typeBonus = Convert.toTypeBonus(json);
//
// These functions will throw an error if the JSON doesn't
// match the expected interface, even if the JSON is valid.
export interface TypeBonus {
_key: number;
iconID?: number;
miscBonuses?: MiscBonus[];
roleBonuses?: RoleBonus[];
types?: Type[];
[property: string]: any;
}
export interface MiscBonus {
bonus?: number;
bonusText: MiscBonusBonusText;
importance: number;
isPositive?: boolean;
unitID?: number;
[property: string]: any;
}
export interface MiscBonusBonusText {
de?: string;
en: string;
es?: string;
fr?: string;
ja?: string;
ko?: string;
ru?: string;
zh?: string;
[property: string]: any;
}
export interface RoleBonus {
bonus?: number;
bonusText: RoleBonusBonusText;
importance: number;
unitID?: number;
[property: string]: any;
}
export interface RoleBonusBonusText {
de?: string;
en: string;
es?: string;
fr?: string;
ja?: string;
ko?: string;
ru?: string;
zh?: string;
[property: string]: any;
}
export interface Type {
_key: number;
_value: Value[];
[property: string]: any;
}
export interface Value {
bonus?: number;
bonusText: ValueBonusText;
importance: number;
unitID?: number;
[property: string]: any;
}
export interface ValueBonusText {
de?: string;
en: string;
es?: string;
fr?: string;
ja?: string;
ko?: string;
ru?: string;
zh?: string;
[property: string]: any;
}
// Converts JSON strings to/from your types
// and asserts the results of JSON.parse at runtime
export class Convert {
public static toTypeBonus(json: string): TypeBonus {
return cast(JSON.parse(json), r("TypeBonus"));
}
public static typeBonusToJson(value: TypeBonus): string {
return JSON.stringify(uncast(value, r("TypeBonus")), 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 = {
"TypeBonus": o([
{ json: "_key", js: "_key", typ: 0 },
{ json: "iconID", js: "iconID", typ: u(undefined, 0) },
{ json: "miscBonuses", js: "miscBonuses", typ: u(undefined, a(r("MiscBonus"))) },
{ json: "roleBonuses", js: "roleBonuses", typ: u(undefined, a(r("RoleBonus"))) },
{ json: "types", js: "types", typ: u(undefined, a(r("Type"))) },
], "any"),
"MiscBonus": o([
{ json: "bonus", js: "bonus", typ: u(undefined, 3.14) },
{ json: "bonusText", js: "bonusText", typ: r("MiscBonusBonusText") },
{ json: "importance", js: "importance", typ: 0 },
{ json: "isPositive", js: "isPositive", typ: u(undefined, true) },
{ json: "unitID", js: "unitID", typ: u(undefined, 0) },
], "any"),
"MiscBonusBonusText": o([
{ json: "de", js: "de", typ: u(undefined, "") },
{ json: "en", js: "en", typ: "" },
{ json: "es", js: "es", typ: u(undefined, "") },
{ json: "fr", js: "fr", typ: u(undefined, "") },
{ json: "ja", js: "ja", typ: u(undefined, "") },
{ json: "ko", js: "ko", typ: u(undefined, "") },
{ json: "ru", js: "ru", typ: u(undefined, "") },
{ json: "zh", js: "zh", typ: u(undefined, "") },
], "any"),
"RoleBonus": o([
{ json: "bonus", js: "bonus", typ: u(undefined, 3.14) },
{ json: "bonusText", js: "bonusText", typ: r("RoleBonusBonusText") },
{ json: "importance", js: "importance", typ: 0 },
{ json: "unitID", js: "unitID", typ: u(undefined, 0) },
], "any"),
"RoleBonusBonusText": o([
{ json: "de", js: "de", typ: u(undefined, "") },
{ json: "en", js: "en", typ: "" },
{ json: "es", js: "es", typ: u(undefined, "") },
{ json: "fr", js: "fr", typ: u(undefined, "") },
{ json: "ja", js: "ja", typ: u(undefined, "") },
{ json: "ko", js: "ko", typ: u(undefined, "") },
{ json: "ru", js: "ru", typ: u(undefined, "") },
{ json: "zh", js: "zh", typ: u(undefined, "") },
], "any"),
"Type": o([
{ json: "_key", js: "_key", typ: 0 },
{ json: "_value", js: "_value", typ: a(r("Value")) },
], "any"),
"Value": o([
{ json: "bonus", js: "bonus", typ: u(undefined, 3.14) },
{ json: "bonusText", js: "bonusText", typ: r("ValueBonusText") },
{ json: "importance", js: "importance", typ: 0 },
{ json: "unitID", js: "unitID", typ: u(undefined, 0) },
], "any"),
"ValueBonusText": o([
{ json: "de", js: "de", typ: u(undefined, "") },
{ json: "en", js: "en", typ: "" },
{ json: "es", js: "es", typ: u(undefined, "") },
{ json: "fr", js: "fr", typ: u(undefined, "") },
{ json: "ja", js: "ja", typ: u(undefined, "") },
{ json: "ko", js: "ko", typ: u(undefined, "") },
{ json: "ru", js: "ru", typ: u(undefined, "") },
{ json: "zh", js: "zh", typ: u(undefined, "") },
], "any"),
};