planetResources.jsonl
Schema
_key
(required): integer
Range: 40013180 .. 40328345cycle_minutes
: integer
Range: 60 .. 60harvest_silo_max
: integer
Range: 45260 .. 1620600maturation_cycle_minutes
: integer
Range: 4320 .. 4320maturation_percent
: integer
Range: 16 .. 16mature_silo_max
: integer
Range: 90520 .. 3241200power
: integer
Range: 100 .. 1020reagent_harvest_amount
: integer
Range: 31 .. 1110reagent_type_id
: integer
Range: 81143 .. 81144workforce
: integer
Range: 1000 .. 10200
Code snippets
// <auto-generated />
//
// To parse this JSON data, add NuGet 'Newtonsoft.Json' then do:
//
// using QuickType;
//
// var planetResource = PlanetResource.FromJson(jsonString);
namespace QuickType
{
using System;
using System.Collections.Generic;
using System.Globalization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
public partial class PlanetResource
{
[JsonProperty("_key")]
public long Key { get; set; }
[JsonProperty("cycle_minutes", NullValueHandling = NullValueHandling.Ignore)]
public long? CycleMinutes { get; set; }
[JsonProperty("harvest_silo_max", NullValueHandling = NullValueHandling.Ignore)]
public long? HarvestSiloMax { get; set; }
[JsonProperty("maturation_cycle_minutes", NullValueHandling = NullValueHandling.Ignore)]
public long? MaturationCycleMinutes { get; set; }
[JsonProperty("maturation_percent", NullValueHandling = NullValueHandling.Ignore)]
public long? MaturationPercent { get; set; }
[JsonProperty("mature_silo_max", NullValueHandling = NullValueHandling.Ignore)]
public long? MatureSiloMax { get; set; }
[JsonProperty("power", NullValueHandling = NullValueHandling.Ignore)]
public long? Power { get; set; }
[JsonProperty("reagent_harvest_amount", NullValueHandling = NullValueHandling.Ignore)]
public long? ReagentHarvestAmount { get; set; }
[JsonProperty("reagent_type_id", NullValueHandling = NullValueHandling.Ignore)]
public long? ReagentTypeId { get; set; }
[JsonProperty("workforce", NullValueHandling = NullValueHandling.Ignore)]
public long? Workforce { get; set; }
}
public partial class PlanetResource
{
public static PlanetResource FromJson(string json) => JsonConvert.DeserializeObject<PlanetResource>(json, QuickType.Converter.Settings);
}
public static class Serialize
{
public static string ToJson(this PlanetResource 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 }
},
};
}
}
// 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:
//
// planetResource, err := UnmarshalPlanetResource(bytes)
// bytes, err = planetResource.Marshal()
package model
import "encoding/json"
func UnmarshalPlanetResource(data []byte) (PlanetResource, error) {
var r PlanetResource
err := json.Unmarshal(data, &r)
return r, err
}
func (r *PlanetResource) Marshal() ([]byte, error) {
return json.Marshal(r)
}
type PlanetResource struct {
Key int64 `json:"_key"`
CycleMinutes *int64 `json:"cycle_minutes,omitempty"`
HarvestSiloMax *int64 `json:"harvest_silo_max,omitempty"`
MaturationCycleMinutes *int64 `json:"maturation_cycle_minutes,omitempty"`
MaturationPercent *int64 `json:"maturation_percent,omitempty"`
MatureSiloMax *int64 `json:"mature_silo_max,omitempty"`
Power *int64 `json:"power,omitempty"`
ReagentHarvestAmount *int64 `json:"reagent_harvest_amount,omitempty"`
ReagentTypeID *int64 `json:"reagent_type_id,omitempty"`
Workforce *int64 `json:"workforce,omitempty"`
}
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"_key": {
"type": "integer",
"minimum": 40013180,
"maximum": 40328345
},
"cycle_minutes": {
"type": "integer",
"minimum": 60,
"maximum": 60
},
"harvest_silo_max": {
"type": "integer",
"minimum": 45260,
"maximum": 1620600
},
"maturation_cycle_minutes": {
"type": "integer",
"minimum": 4320,
"maximum": 4320
},
"maturation_percent": {
"type": "integer",
"minimum": 16,
"maximum": 16
},
"mature_silo_max": {
"type": "integer",
"minimum": 90520,
"maximum": 3241200
},
"power": {
"type": "integer",
"minimum": 100,
"maximum": 1020
},
"reagent_harvest_amount": {
"type": "integer",
"minimum": 31,
"maximum": 1110
},
"reagent_type_id": {
"type": "integer",
"minimum": 81143,
"maximum": 81144
},
"workforce": {
"type": "integer",
"minimum": 1000,
"maximum": 10200
}
},
"required": [
"_key"
]
}
// To parse the JSON, install kotlin's serialization plugin and do:
//
// val json = Json { allowStructuredMapKeys = true }
// val planetResource = json.parse(PlanetResource.serializer(), jsonString)
package model
import kotlinx.serialization.*
import kotlinx.serialization.json.*
import kotlinx.serialization.descriptors.*
import kotlinx.serialization.encoding.*
@Serializable
data class PlanetResource (
@SerialName("_key")
val key: Long,
@SerialName("cycle_minutes")
val cycleMinutes: Long? = null,
@SerialName("harvest_silo_max")
val harvestSiloMax: Long? = null,
@SerialName("maturation_cycle_minutes")
val maturationCycleMinutes: Long? = null,
@SerialName("maturation_percent")
val maturationPercent: Long? = null,
@SerialName("mature_silo_max")
val matureSiloMax: Long? = null,
val power: Long? = null,
@SerialName("reagent_harvest_amount")
val reagentHarvestAmount: Long? = null,
@SerialName("reagent_type_id")
val reagentTypeId: Long? = null,
val workforce: Long? = null
)
<?php
// This is a autogenerated file:PlanetResource
class PlanetResource {
private int $key; // json:_key Required
private ?int $cycleMinutes; // json:cycle_minutes Optional
private ?int $harvestSiloMax; // json:harvest_silo_max Optional
private ?int $maturationCycleMinutes; // json:maturation_cycle_minutes Optional
private ?int $maturationPercent; // json:maturation_percent Optional
private ?int $matureSiloMax; // json:mature_silo_max Optional
private ?int $power; // json:power Optional
private ?int $reagentHarvestAmount; // json:reagent_harvest_amount Optional
private ?int $reagentTypeId; // json:reagent_type_id Optional
private ?int $workforce; // json:workforce Optional
/**
* @param int $key
* @param int|null $cycleMinutes
* @param int|null $harvestSiloMax
* @param int|null $maturationCycleMinutes
* @param int|null $maturationPercent
* @param int|null $matureSiloMax
* @param int|null $power
* @param int|null $reagentHarvestAmount
* @param int|null $reagentTypeId
* @param int|null $workforce
*/
public function __construct(int $key, ?int $cycleMinutes, ?int $harvestSiloMax, ?int $maturationCycleMinutes, ?int $maturationPercent, ?int $matureSiloMax, ?int $power, ?int $reagentHarvestAmount, ?int $reagentTypeId, ?int $workforce) {
$this->key = $key;
$this->cycleMinutes = $cycleMinutes;
$this->harvestSiloMax = $harvestSiloMax;
$this->maturationCycleMinutes = $maturationCycleMinutes;
$this->maturationPercent = $maturationPercent;
$this->matureSiloMax = $matureSiloMax;
$this->power = $power;
$this->reagentHarvestAmount = $reagentHarvestAmount;
$this->reagentTypeId = $reagentTypeId;
$this->workforce = $workforce;
}
/**
* @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 (PlanetResource::validateKey($this->key)) {
return $this->key; /*int*/
}
throw new Exception('never get to this PlanetResource::key');
}
/**
* @param int
* @return bool
* @throws Exception
*/
public static function validateKey(int $value): bool {
if (!is_integer($value)) {
throw new Exception("Attribute Error:PlanetResource::key");
}
return true;
}
/**
* @throws Exception
* @return int
*/
public function getKey(): int {
if (PlanetResource::validateKey($this->key)) {
return $this->key;
}
throw new Exception('never get to getKey PlanetResource::key');
}
/**
* @return int
*/
public static function sampleKey(): int {
return 31; /*31:key*/
}
/**
* @param ?int $value
* @throws Exception
* @return ?int
*/
public static function fromCycleMinutes(?int $value): ?int {
if (!is_null($value)) {
return $value; /*int*/
} else {
return null;
}
}
/**
* @throws Exception
* @return ?int
*/
public function toCycleMinutes(): ?int {
if (PlanetResource::validateCycleMinutes($this->cycleMinutes)) {
if (!is_null($this->cycleMinutes)) {
return $this->cycleMinutes; /*int*/
} else {
return null;
}
}
throw new Exception('never get to this PlanetResource::cycleMinutes');
}
/**
* @param int|null
* @return bool
* @throws Exception
*/
public static function validateCycleMinutes(?int $value): bool {
if (!is_null($value)) {
if (!is_integer($value)) {
throw new Exception("Attribute Error:PlanetResource::cycleMinutes");
}
}
return true;
}
/**
* @throws Exception
* @return ?int
*/
public function getCycleMinutes(): ?int {
if (PlanetResource::validateCycleMinutes($this->cycleMinutes)) {
return $this->cycleMinutes;
}
throw new Exception('never get to getCycleMinutes PlanetResource::cycleMinutes');
}
/**
* @return ?int
*/
public static function sampleCycleMinutes(): ?int {
return 32; /*32:cycleMinutes*/
}
/**
* @param ?int $value
* @throws Exception
* @return ?int
*/
public static function fromHarvestSiloMax(?int $value): ?int {
if (!is_null($value)) {
return $value; /*int*/
} else {
return null;
}
}
/**
* @throws Exception
* @return ?int
*/
public function toHarvestSiloMax(): ?int {
if (PlanetResource::validateHarvestSiloMax($this->harvestSiloMax)) {
if (!is_null($this->harvestSiloMax)) {
return $this->harvestSiloMax; /*int*/
} else {
return null;
}
}
throw new Exception('never get to this PlanetResource::harvestSiloMax');
}
/**
* @param int|null
* @return bool
* @throws Exception
*/
public static function validateHarvestSiloMax(?int $value): bool {
if (!is_null($value)) {
if (!is_integer($value)) {
throw new Exception("Attribute Error:PlanetResource::harvestSiloMax");
}
}
return true;
}
/**
* @throws Exception
* @return ?int
*/
public function getHarvestSiloMax(): ?int {
if (PlanetResource::validateHarvestSiloMax($this->harvestSiloMax)) {
return $this->harvestSiloMax;
}
throw new Exception('never get to getHarvestSiloMax PlanetResource::harvestSiloMax');
}
/**
* @return ?int
*/
public static function sampleHarvestSiloMax(): ?int {
return 33; /*33:harvestSiloMax*/
}
/**
* @param ?int $value
* @throws Exception
* @return ?int
*/
public static function fromMaturationCycleMinutes(?int $value): ?int {
if (!is_null($value)) {
return $value; /*int*/
} else {
return null;
}
}
/**
* @throws Exception
* @return ?int
*/
public function toMaturationCycleMinutes(): ?int {
if (PlanetResource::validateMaturationCycleMinutes($this->maturationCycleMinutes)) {
if (!is_null($this->maturationCycleMinutes)) {
return $this->maturationCycleMinutes; /*int*/
} else {
return null;
}
}
throw new Exception('never get to this PlanetResource::maturationCycleMinutes');
}
/**
* @param int|null
* @return bool
* @throws Exception
*/
public static function validateMaturationCycleMinutes(?int $value): bool {
if (!is_null($value)) {
if (!is_integer($value)) {
throw new Exception("Attribute Error:PlanetResource::maturationCycleMinutes");
}
}
return true;
}
/**
* @throws Exception
* @return ?int
*/
public function getMaturationCycleMinutes(): ?int {
if (PlanetResource::validateMaturationCycleMinutes($this->maturationCycleMinutes)) {
return $this->maturationCycleMinutes;
}
throw new Exception('never get to getMaturationCycleMinutes PlanetResource::maturationCycleMinutes');
}
/**
* @return ?int
*/
public static function sampleMaturationCycleMinutes(): ?int {
return 34; /*34:maturationCycleMinutes*/
}
/**
* @param ?int $value
* @throws Exception
* @return ?int
*/
public static function fromMaturationPercent(?int $value): ?int {
if (!is_null($value)) {
return $value; /*int*/
} else {
return null;
}
}
/**
* @throws Exception
* @return ?int
*/
public function toMaturationPercent(): ?int {
if (PlanetResource::validateMaturationPercent($this->maturationPercent)) {
if (!is_null($this->maturationPercent)) {
return $this->maturationPercent; /*int*/
} else {
return null;
}
}
throw new Exception('never get to this PlanetResource::maturationPercent');
}
/**
* @param int|null
* @return bool
* @throws Exception
*/
public static function validateMaturationPercent(?int $value): bool {
if (!is_null($value)) {
if (!is_integer($value)) {
throw new Exception("Attribute Error:PlanetResource::maturationPercent");
}
}
return true;
}
/**
* @throws Exception
* @return ?int
*/
public function getMaturationPercent(): ?int {
if (PlanetResource::validateMaturationPercent($this->maturationPercent)) {
return $this->maturationPercent;
}
throw new Exception('never get to getMaturationPercent PlanetResource::maturationPercent');
}
/**
* @return ?int
*/
public static function sampleMaturationPercent(): ?int {
return 35; /*35:maturationPercent*/
}
/**
* @param ?int $value
* @throws Exception
* @return ?int
*/
public static function fromMatureSiloMax(?int $value): ?int {
if (!is_null($value)) {
return $value; /*int*/
} else {
return null;
}
}
/**
* @throws Exception
* @return ?int
*/
public function toMatureSiloMax(): ?int {
if (PlanetResource::validateMatureSiloMax($this->matureSiloMax)) {
if (!is_null($this->matureSiloMax)) {
return $this->matureSiloMax; /*int*/
} else {
return null;
}
}
throw new Exception('never get to this PlanetResource::matureSiloMax');
}
/**
* @param int|null
* @return bool
* @throws Exception
*/
public static function validateMatureSiloMax(?int $value): bool {
if (!is_null($value)) {
if (!is_integer($value)) {
throw new Exception("Attribute Error:PlanetResource::matureSiloMax");
}
}
return true;
}
/**
* @throws Exception
* @return ?int
*/
public function getMatureSiloMax(): ?int {
if (PlanetResource::validateMatureSiloMax($this->matureSiloMax)) {
return $this->matureSiloMax;
}
throw new Exception('never get to getMatureSiloMax PlanetResource::matureSiloMax');
}
/**
* @return ?int
*/
public static function sampleMatureSiloMax(): ?int {
return 36; /*36:matureSiloMax*/
}
/**
* @param ?int $value
* @throws Exception
* @return ?int
*/
public static function fromPower(?int $value): ?int {
if (!is_null($value)) {
return $value; /*int*/
} else {
return null;
}
}
/**
* @throws Exception
* @return ?int
*/
public function toPower(): ?int {
if (PlanetResource::validatePower($this->power)) {
if (!is_null($this->power)) {
return $this->power; /*int*/
} else {
return null;
}
}
throw new Exception('never get to this PlanetResource::power');
}
/**
* @param int|null
* @return bool
* @throws Exception
*/
public static function validatePower(?int $value): bool {
if (!is_null($value)) {
if (!is_integer($value)) {
throw new Exception("Attribute Error:PlanetResource::power");
}
}
return true;
}
/**
* @throws Exception
* @return ?int
*/
public function getPower(): ?int {
if (PlanetResource::validatePower($this->power)) {
return $this->power;
}
throw new Exception('never get to getPower PlanetResource::power');
}
/**
* @return ?int
*/
public static function samplePower(): ?int {
return 37; /*37:power*/
}
/**
* @param ?int $value
* @throws Exception
* @return ?int
*/
public static function fromReagentHarvestAmount(?int $value): ?int {
if (!is_null($value)) {
return $value; /*int*/
} else {
return null;
}
}
/**
* @throws Exception
* @return ?int
*/
public function toReagentHarvestAmount(): ?int {
if (PlanetResource::validateReagentHarvestAmount($this->reagentHarvestAmount)) {
if (!is_null($this->reagentHarvestAmount)) {
return $this->reagentHarvestAmount; /*int*/
} else {
return null;
}
}
throw new Exception('never get to this PlanetResource::reagentHarvestAmount');
}
/**
* @param int|null
* @return bool
* @throws Exception
*/
public static function validateReagentHarvestAmount(?int $value): bool {
if (!is_null($value)) {
if (!is_integer($value)) {
throw new Exception("Attribute Error:PlanetResource::reagentHarvestAmount");
}
}
return true;
}
/**
* @throws Exception
* @return ?int
*/
public function getReagentHarvestAmount(): ?int {
if (PlanetResource::validateReagentHarvestAmount($this->reagentHarvestAmount)) {
return $this->reagentHarvestAmount;
}
throw new Exception('never get to getReagentHarvestAmount PlanetResource::reagentHarvestAmount');
}
/**
* @return ?int
*/
public static function sampleReagentHarvestAmount(): ?int {
return 38; /*38:reagentHarvestAmount*/
}
/**
* @param ?int $value
* @throws Exception
* @return ?int
*/
public static function fromReagentTypeId(?int $value): ?int {
if (!is_null($value)) {
return $value; /*int*/
} else {
return null;
}
}
/**
* @throws Exception
* @return ?int
*/
public function toReagentTypeId(): ?int {
if (PlanetResource::validateReagentTypeId($this->reagentTypeId)) {
if (!is_null($this->reagentTypeId)) {
return $this->reagentTypeId; /*int*/
} else {
return null;
}
}
throw new Exception('never get to this PlanetResource::reagentTypeId');
}
/**
* @param int|null
* @return bool
* @throws Exception
*/
public static function validateReagentTypeId(?int $value): bool {
if (!is_null($value)) {
if (!is_integer($value)) {
throw new Exception("Attribute Error:PlanetResource::reagentTypeId");
}
}
return true;
}
/**
* @throws Exception
* @return ?int
*/
public function getReagentTypeId(): ?int {
if (PlanetResource::validateReagentTypeId($this->reagentTypeId)) {
return $this->reagentTypeId;
}
throw new Exception('never get to getReagentTypeId PlanetResource::reagentTypeId');
}
/**
* @return ?int
*/
public static function sampleReagentTypeId(): ?int {
return 39; /*39:reagentTypeId*/
}
/**
* @param ?int $value
* @throws Exception
* @return ?int
*/
public static function fromWorkforce(?int $value): ?int {
if (!is_null($value)) {
return $value; /*int*/
} else {
return null;
}
}
/**
* @throws Exception
* @return ?int
*/
public function toWorkforce(): ?int {
if (PlanetResource::validateWorkforce($this->workforce)) {
if (!is_null($this->workforce)) {
return $this->workforce; /*int*/
} else {
return null;
}
}
throw new Exception('never get to this PlanetResource::workforce');
}
/**
* @param int|null
* @return bool
* @throws Exception
*/
public static function validateWorkforce(?int $value): bool {
if (!is_null($value)) {
if (!is_integer($value)) {
throw new Exception("Attribute Error:PlanetResource::workforce");
}
}
return true;
}
/**
* @throws Exception
* @return ?int
*/
public function getWorkforce(): ?int {
if (PlanetResource::validateWorkforce($this->workforce)) {
return $this->workforce;
}
throw new Exception('never get to getWorkforce PlanetResource::workforce');
}
/**
* @return ?int
*/
public static function sampleWorkforce(): ?int {
return 40; /*40:workforce*/
}
/**
* @throws Exception
* @return bool
*/
public function validate(): bool {
return PlanetResource::validateKey($this->key)
|| PlanetResource::validateCycleMinutes($this->cycleMinutes)
|| PlanetResource::validateHarvestSiloMax($this->harvestSiloMax)
|| PlanetResource::validateMaturationCycleMinutes($this->maturationCycleMinutes)
|| PlanetResource::validateMaturationPercent($this->maturationPercent)
|| PlanetResource::validateMatureSiloMax($this->matureSiloMax)
|| PlanetResource::validatePower($this->power)
|| PlanetResource::validateReagentHarvestAmount($this->reagentHarvestAmount)
|| PlanetResource::validateReagentTypeId($this->reagentTypeId)
|| PlanetResource::validateWorkforce($this->workforce);
}
/**
* @return stdClass
* @throws Exception
*/
public function to(): stdClass {
$out = new stdClass();
$out->{'_key'} = $this->toKey();
$out->{'cycle_minutes'} = $this->toCycleMinutes();
$out->{'harvest_silo_max'} = $this->toHarvestSiloMax();
$out->{'maturation_cycle_minutes'} = $this->toMaturationCycleMinutes();
$out->{'maturation_percent'} = $this->toMaturationPercent();
$out->{'mature_silo_max'} = $this->toMatureSiloMax();
$out->{'power'} = $this->toPower();
$out->{'reagent_harvest_amount'} = $this->toReagentHarvestAmount();
$out->{'reagent_type_id'} = $this->toReagentTypeId();
$out->{'workforce'} = $this->toWorkforce();
return $out;
}
/**
* @param stdClass $obj
* @return PlanetResource
* @throws Exception
*/
public static function from(stdClass $obj): PlanetResource {
return new PlanetResource(
PlanetResource::fromKey($obj->{'_key'})
,PlanetResource::fromCycleMinutes($obj->{'cycle_minutes'})
,PlanetResource::fromHarvestSiloMax($obj->{'harvest_silo_max'})
,PlanetResource::fromMaturationCycleMinutes($obj->{'maturation_cycle_minutes'})
,PlanetResource::fromMaturationPercent($obj->{'maturation_percent'})
,PlanetResource::fromMatureSiloMax($obj->{'mature_silo_max'})
,PlanetResource::fromPower($obj->{'power'})
,PlanetResource::fromReagentHarvestAmount($obj->{'reagent_harvest_amount'})
,PlanetResource::fromReagentTypeId($obj->{'reagent_type_id'})
,PlanetResource::fromWorkforce($obj->{'workforce'})
);
}
/**
* @return PlanetResource
*/
public static function sample(): PlanetResource {
return new PlanetResource(
PlanetResource::sampleKey()
,PlanetResource::sampleCycleMinutes()
,PlanetResource::sampleHarvestSiloMax()
,PlanetResource::sampleMaturationCycleMinutes()
,PlanetResource::sampleMaturationPercent()
,PlanetResource::sampleMatureSiloMax()
,PlanetResource::samplePower()
,PlanetResource::sampleReagentHarvestAmount()
,PlanetResource::sampleReagentTypeId()
,PlanetResource::sampleWorkforce()
);
}
}
from typing import Optional, Any, TypeVar, Type, cast
T = TypeVar("T")
def from_int(x: Any) -> int:
assert isinstance(x, int) and not isinstance(x, bool)
return x
def from_none(x: Any) -> Any:
assert x is None
return x
def from_union(fs, x):
for f in fs:
try:
return f(x)
except:
pass
assert False
def to_class(c: Type[T], x: Any) -> dict:
assert isinstance(x, c)
return cast(Any, x).to_dict()
class PlanetResource:
key: int
cycle_minutes: Optional[int]
harvest_silo_max: Optional[int]
maturation_cycle_minutes: Optional[int]
maturation_percent: Optional[int]
mature_silo_max: Optional[int]
power: Optional[int]
reagent_harvest_amount: Optional[int]
reagent_type_id: Optional[int]
workforce: Optional[int]
def __init__(self, key: int, cycle_minutes: Optional[int], harvest_silo_max: Optional[int], maturation_cycle_minutes: Optional[int], maturation_percent: Optional[int], mature_silo_max: Optional[int], power: Optional[int], reagent_harvest_amount: Optional[int], reagent_type_id: Optional[int], workforce: Optional[int]) -> None:
self.key = key
self.cycle_minutes = cycle_minutes
self.harvest_silo_max = harvest_silo_max
self.maturation_cycle_minutes = maturation_cycle_minutes
self.maturation_percent = maturation_percent
self.mature_silo_max = mature_silo_max
self.power = power
self.reagent_harvest_amount = reagent_harvest_amount
self.reagent_type_id = reagent_type_id
self.workforce = workforce
@staticmethod
def from_dict(obj: Any) -> 'PlanetResource':
assert isinstance(obj, dict)
key = from_int(obj.get("_key"))
cycle_minutes = from_union([from_int, from_none], obj.get("cycle_minutes"))
harvest_silo_max = from_union([from_int, from_none], obj.get("harvest_silo_max"))
maturation_cycle_minutes = from_union([from_int, from_none], obj.get("maturation_cycle_minutes"))
maturation_percent = from_union([from_int, from_none], obj.get("maturation_percent"))
mature_silo_max = from_union([from_int, from_none], obj.get("mature_silo_max"))
power = from_union([from_int, from_none], obj.get("power"))
reagent_harvest_amount = from_union([from_int, from_none], obj.get("reagent_harvest_amount"))
reagent_type_id = from_union([from_int, from_none], obj.get("reagent_type_id"))
workforce = from_union([from_int, from_none], obj.get("workforce"))
return PlanetResource(key, cycle_minutes, harvest_silo_max, maturation_cycle_minutes, maturation_percent, mature_silo_max, power, reagent_harvest_amount, reagent_type_id, workforce)
def to_dict(self) -> dict:
result: dict = {}
result["_key"] = from_int(self.key)
if self.cycle_minutes is not None:
result["cycle_minutes"] = from_union([from_int, from_none], self.cycle_minutes)
if self.harvest_silo_max is not None:
result["harvest_silo_max"] = from_union([from_int, from_none], self.harvest_silo_max)
if self.maturation_cycle_minutes is not None:
result["maturation_cycle_minutes"] = from_union([from_int, from_none], self.maturation_cycle_minutes)
if self.maturation_percent is not None:
result["maturation_percent"] = from_union([from_int, from_none], self.maturation_percent)
if self.mature_silo_max is not None:
result["mature_silo_max"] = from_union([from_int, from_none], self.mature_silo_max)
if self.power is not None:
result["power"] = from_union([from_int, from_none], self.power)
if self.reagent_harvest_amount is not None:
result["reagent_harvest_amount"] = from_union([from_int, from_none], self.reagent_harvest_amount)
if self.reagent_type_id is not None:
result["reagent_type_id"] = from_union([from_int, from_none], self.reagent_type_id)
if self.workforce is not None:
result["workforce"] = from_union([from_int, from_none], self.workforce)
return result
def planet_resource_from_dict(s: Any) -> PlanetResource:
return PlanetResource.from_dict(s)
def planet_resource_to_dict(x: PlanetResource) -> Any:
return to_class(PlanetResource, x)
// To parse this data:
//
// import { Convert, PlanetResource } from "./file";
//
// const planetResource = Convert.toPlanetResource(json);
//
// These functions will throw an error if the JSON doesn't
// match the expected interface, even if the JSON is valid.
export interface PlanetResource {
_key: number;
cycle_minutes?: number;
harvest_silo_max?: number;
maturation_cycle_minutes?: number;
maturation_percent?: number;
mature_silo_max?: number;
power?: number;
reagent_harvest_amount?: number;
reagent_type_id?: number;
workforce?: number;
[property: string]: any;
}
// Converts JSON strings to/from your types
// and asserts the results of JSON.parse at runtime
export class Convert {
public static toPlanetResource(json: string): PlanetResource {
return cast(JSON.parse(json), r("PlanetResource"));
}
public static planetResourceToJson(value: PlanetResource): string {
return JSON.stringify(uncast(value, r("PlanetResource")), 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 = {
"PlanetResource": o([
{ json: "_key", js: "_key", typ: 0 },
{ json: "cycle_minutes", js: "cycle_minutes", typ: u(undefined, 0) },
{ json: "harvest_silo_max", js: "harvest_silo_max", typ: u(undefined, 0) },
{ json: "maturation_cycle_minutes", js: "maturation_cycle_minutes", typ: u(undefined, 0) },
{ json: "maturation_percent", js: "maturation_percent", typ: u(undefined, 0) },
{ json: "mature_silo_max", js: "mature_silo_max", typ: u(undefined, 0) },
{ json: "power", js: "power", typ: u(undefined, 0) },
{ json: "reagent_harvest_amount", js: "reagent_harvest_amount", typ: u(undefined, 0) },
{ json: "reagent_type_id", js: "reagent_type_id", typ: u(undefined, 0) },
{ json: "workforce", js: "workforce", typ: u(undefined, 0) },
], "any"),
};