anacreonlib package#
Module contents#
- class anacreonlib.Anacreon(auth_info: AnacreonApiRequest, game_info: ScenarioInfo, client: AnacreonAsyncClient | None = None)#
Bases:
objectConstruct an Anacreon instance directly
Consider using one of the helper class methods like
log_in()instead- Parameters:
auth_info (AnacreonApiRequest) – A stub API request containing a valid auth token
game_info (ScenarioInfo) – Info about the game, such as all the traits that
client (Optional[AnacreonAsyncClient], optional) – The low-level API client to use in order to make HTTP requests. Defaults to None.
- async abort_attack(battlefield_id: int) None#
Abort an attack in progress
- Parameters:
battlefield_id (int) – The world ID of the planet that you are attacking
- async attack(battlefield_id: int, objective: BattleObjective, enemy_sovereign_ids: List[int]) None#
Attack a world
- Parameters:
battlefield_id (int) – The ID of the world that you intend to attack
objective (BattleObjective) – Whether you want to invade, reinforce a siege, or destroy all space defenses
enemy_sovereign_ids (List[int]) – A list of the sovereign ids that you wish to engage in battle with
- async buy_item(source_obj_id: int, item_id: int, item_count: int) None#
Buy an item from the Mesophons.
As a prerequisite to calling this method, you must have a fleet stationed at the world where you wish to buy ships from.
- calculate_forces(object_or_resources: World | Fleet | Dict[int, int] | List[int]) MilitaryForceInfo#
Calculate the ground forces + space forces of a particular world/fleet
- calculate_remaining_cargo_space(fleet: Fleet | int) float#
Calculate the remaining cargo space on a fleet
- Parameters:
fleet (Union[Fleet, int]) – Either the
Fleetobject, or the fleet ID- Raises:
LookupError – Raised if the fleet could not be found
- Returns:
The remaining cargo space left in the fleet. Can be negative if uneven attrition has left more cargo in the fleet than it has space for.
- Return type:
- call_get_objects_periodically() Task[None]#
Spawns an
Taskthat callsAnacreon.get_objects()every watch.- Returns:
The task that was spawned.
- Return type:
asyncio.Task[None]
- client: AnacreonAsyncClient#
the low level API client that is used to make HTTP requests to the Anacreon API
- async deploy_fleet(source_obj_id: int, resources: Dict[int, int] | List[int]) Fleet | None#
Deploy a fleet
- async destroy_improvement(world_obj_id: int, improvement_id: int) None#
Destroy a structure/improvement on a world
- async disband_fleet(fleet_obj_id: int, dest_obj_id: int) None#
Delete a fleet by forcing it to become a part of another object that it is stationed next to.
You can use this method to gift fleets to enemy sovereigns.
- async classmethod from_auth_token(game_id: str, auth_token: str, *, client: AnacreonAsyncClient | None = None) Anacreon#
Authenticate with the Anacreon API using an auth token
You can get an auth token by looking at your cookies for anacreon.kronosaur.com in your browser’s dev console.
- game_info: ScenarioInfo#
The scenario info for the game
- generate_production_info(world: World | int) Dict[int, ProductionInfo]#
Calculate production info for a world
- Parameters:
world (Union[World, int]) – Either the
Worldobject, or the world ID.- Raises:
LookupError – Raised if world is a world ID that cannot be found
- Returns:
A mapping from resource ID to
ProductionInfoobjects describing how much of that resource was imported/exported- Return type:
Dict[int, ProductionInfo]
- async get_objects() Anacreon#
Refreshes game state from the Anacreon API to update world state, fleet state, and so on.
- Returns:
this object
- Return type:
- async get_tactical(battlefield_id: str) List[Dict[str, Any]]#
Get battlefield information of a planet, such as battle groups and squadron locations
- get_valid_improvement_list(world: World) List[ScenarioInfoElement]#
Returns a list of scenario elements which represent improvements that can be built on a given world.
- Parameters:
world (World) – The world in question
- Returns:
A list of improvements that can be built.
- Return type:
List[ScenarioInfoElement]
- history: Dict[int, HistoryElement]#
A list of all history popups that would appear over your worlds in the game UI
- async classmethod log_in(game_id: str, username: str, password: str) Anacreon#
Authenticate with the Anacreon API using a Multiverse username and password
Example
>>> import asyncio >>> async def main(): ... client = await Anacreon.log_in("8JNJ7FNZ", "username", "password") ... # do stuff with client ... >>> asyncio.run(main())
- Parameters:
game_id (str) – The game ID of the game you intend to manipulate. You can find the game ID by looking at the URL when you are playing Anacreon in your browser. e.g if the URL was
anacreon.kronosaur.com/trantor.hexm?gameID=8JNJ7FNZ, the game ID would be8JNJ7FNZ.username (str) – The username to your Multiverse account
password (str) – The password to your Multiverse account
- Returns:
An instance of the API client wrapper, which can be used to programmatically perform actions within the game
- Return type:
- scenario_info_objects: Dict[int, ScenarioInfoElement]#
A mapping from trait/resource ID to
ScenarioInfoElement
- async sell_fleet(fleet_id: int, buyer_obj_id: int, resources: Dict[int, int] | List[int]) None#
Sell a fleet (or fleet cargo) to the Mesophons
As a prerequisite to calling this method, the fleet in question must already be stationed at a mesophon world.
- Parameters:
fleet_id (int) – The ID of the fleet to sell from
buyer_obj_id (int) – The ID of the Mesophon world you are selling to
resources (IdValueMapping) – The resources from the fleet which you are selling to the mesophons. You may choose to sell a portion of your resources, as opposed to all of the fleet’s cargo or all of the ships.
- async set_history_read(history_id: int) bool#
Delet a history popup that show up over a planet
You can see a list of all the history popups by looking at
Anacreon.history.- Parameters:
history_id (int) – The history ID of the popup as per
HistoryElement.id.- Returns:
Trueif the popup was successfully closed.- Return type:
- async set_industry_alloc(world_id: int, industry_id: int, pct_labor_allocated: SupportsFloat) None#
On a world, set the percent labor allocation to a structure
For example, this method can be used to set the labor allocation to defense structures to 0%.
- async set_product_alloc(world_id: int, industry_id: int, pct_labor_allocated_by_resource: Dict[int, int] | List[int]) None#
Within a single industry, set the percent labor allocation to a single product of the industry.
For example, this method can be used to set the labor allocation on a jumpship yards planet to spend 100% of the labor available to the yards structure on building Reliant-class jumptransports.
- async set_trade_route(importer_id: int, exporter_id: int, alloc_type: str = TradeRouteTypes.DEFAULT, alloc_value: str | float | None = None, res_type_id: int | None = None) None#
Create/update a trade route between 2 planets
- Parameters:
importer_id (int) – The ID of the world that is importing resources
exporter_id (int) – The ID of the world that is exporting resources
alloc_type (TradeRouteTypes, optional) – How to decide how the trade route should be set. Defaults to
TradeRouteTypes.DEFAULT, which emulates the behavior of setting up a 1 way trade route between 2 unconnected planets in the game UI.alloc_value (Optional[Union[str, float]], optional) – The percent of demand on the importing world to import from (between 0 and 999). Defaults to None.
res_type_id (Optional[int], optional) – The ID of the resource to import.
- async stop_trade_route(planet_id_a: int, planet_id_b: int) None#
Stop all trade between 2 planets
If you need to stop trade on only one resource, you may do the set the percent of demand to import to 0 using
Anacreon.set_trade_route()withalloc_typeasTradeRouteTypes.CONSUMPTION.
- async tactical_order(battlefield_id: int, order: TacticalOrderType | str, squadron_id: int, orbit: float | None = None, target_id: int | None = None) bool#
Send an order to a tactial squadron on a world
- Parameters:
battlefield_id (int) – The ID of the world
order (Union[TacticalOrderType, str]) – The order you are giving
squadron_id (int) – The ID of the squadron to give the order to
orbit (Optional[float]) – If
orderisTacticalOrderType.ORBIT, this should be the new orbit altitudetarget_id (Optional[int]) – If
orderisTacticalOrderType.TARGET, this should be the id of the tactical squadron to target
- Returns:
Trueif the order was successfully processed- Return type:
- async transfer_fleet(fleet_obj_id: int, dest_obj_id: int, resources: Dict[int, int] | List[int]) None#
Transfer ships in a fleet to another fleet/world
- async wait_for_any_update() None#
This coroutine waits until any method that updates game state, such as
Anacreon.designate_world()orAnacreon.attack(), is called.One use case for this function is when you are just starting a script, and you spawn an
Taskto periodically fetch updates. Your main coroutine would have to block until the task fetches the first update.
- async wait_for_get_objects() None#
This coroutine waits until
Anacreon.get_objects()is called by someone else.One use case for this function is when you have 2 long-lived async
Tasks running. One is calingAnacreon.get_objects()every minute, while the other is managing a fleet. The task managing the fleet could to use this method to wait for updates to the state
- class anacreonlib.AnacreonObject(*, object_class: str)#
Bases:
DeserializableDataclassCreate a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function _snake_case_to_lower_camel>, 'ignored_types': (<class 'functools.cached_property'>, <class 'set'>)}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'object_class': FieldInfo(annotation=str, required=True, alias='class', alias_priority=2)}#
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- class anacreonlib.AnacreonObjectWithId(*, object_class: str, id: int)#
Bases:
AnacreonObjectNot all anacreon objects have an ID, most notably, UpdateObject
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function _snake_case_to_lower_camel>, 'ignored_types': (<class 'functools.cached_property'>, <class 'set'>)}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'id': FieldInfo(annotation=int, required=True, alias='id', alias_priority=1), 'object_class': FieldInfo(annotation=str, required=True, alias='class', alias_priority=2)}#
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- class anacreonlib.AuthenticationResponse(*, authToken: str, rights: List[str], scopedCredentials: int, username: str)#
Bases:
DeserializableDataclassCreate a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function _snake_case_to_lower_camel>, 'ignored_types': (<class 'functools.cached_property'>, <class 'set'>)}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'auth_token': FieldInfo(annotation=str, required=True, alias='authToken', alias_priority=1), 'rights': FieldInfo(annotation=List[str], required=True, alias='rights', alias_priority=1), 'scoped_credentials': FieldInfo(annotation=int, required=True, alias='scopedCredentials', alias_priority=1, metadata=[PlainSerializer(func=<function _convert_int_to_aeon_ipinteger>, return_type=PydanticUndefined, when_used='json-unless-none'), BeforeValidator(func=<function _convert_aeon_ipinteger_to_int>)]), 'username': FieldInfo(annotation=str, required=True, alias='username', alias_priority=1)}#
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- class anacreonlib.BattlePlanDetails(*, enemySovereignIDs: List[int] | None = None, objective: BattleObjective, sovereignID: int, status: str)#
Bases:
DeserializableDataclassCreate a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function _snake_case_to_lower_camel>, 'ignored_types': (<class 'functools.cached_property'>, <class 'set'>)}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'enemy_sovereign_ids': FieldInfo(annotation=Union[List[int], NoneType], required=False, alias='enemySovereignIDs', alias_priority=2), 'objective': FieldInfo(annotation=BattleObjective, required=True, alias='objective', alias_priority=1), 'sovereign_id': FieldInfo(annotation=int, required=True, alias='sovereignID', alias_priority=1), 'status': FieldInfo(annotation=str, required=True, alias='status', alias_priority=1)}#
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- objective: BattleObjective#
- class anacreonlib.BattlePlanObject(*, object_class: Literal['battlePlan'], id: int, battlePlan: BattlePlanDetails)#
Bases:
AnacreonObjectWithIdCreate a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- battle_plan: BattlePlanDetails#
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function _snake_case_to_lower_camel>, 'ignored_types': (<class 'functools.cached_property'>, <class 'set'>)}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'battle_plan': FieldInfo(annotation=BattlePlanDetails, required=True, alias='battlePlan', alias_priority=1), 'id': FieldInfo(annotation=int, required=True, alias='id', alias_priority=1), 'object_class': FieldInfo(annotation=Literal['battlePlan'], required=True, alias='class', alias_priority=2)}#
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- class anacreonlib.DestroyedSpaceObject(*, object_class: Literal['destroyedSpaceObject'], id: int)#
Bases:
AnacreonObjectWithIdCreate a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function _snake_case_to_lower_camel>, 'ignored_types': (<class 'functools.cached_property'>, <class 'set'>)}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'id': FieldInfo(annotation=int, required=True, alias='id', alias_priority=1), 'object_class': FieldInfo(annotation=Literal['destroyedSpaceObject'], required=True, alias='class', alias_priority=2)}#
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- class anacreonlib.ExplorationGrid(*, radius: float, exploredOutline: List[List[float]])#
Bases:
DeserializableDataclassCreate a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function _snake_case_to_lower_camel>, 'ignored_types': (<class 'functools.cached_property'>, <class 'set'>)}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'explored_outline': FieldInfo(annotation=List[List[float]], required=True, alias='exploredOutline', alias_priority=1), 'radius': FieldInfo(annotation=float, required=True, alias='radius', alias_priority=1)}#
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- class anacreonlib.Fleet(*, object_class: Literal['fleet'], id: int, ftlType: str, name: str, sovereignID: int, resources: List[int], news: List[News] | None = None, anchorObjID: int | None = None, battlePlan: BattlePlanDetails | None = None, pos: Tuple[float, float], dest: Tuple[float, float] | None = None, destID: int | None = None, eta: int | None = None, region: NebulaType = NebulaType.CLEAR_SPACE)#
Bases:
AnacreonObjectWithIdCreate a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- anchor_obj_id: int | None#
Noneif this fleet is not currently stationed at a world. Otherwise, this is the ID of the world where this fleet is stationed.
- battle_plan: BattlePlanDetails | None#
- eta: int | None#
If not
None, corresponds to theUpdateObject.updateon which this fleet will arrive at its destination.
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function _snake_case_to_lower_camel>, 'ignored_types': (<class 'functools.cached_property'>, <class 'set'>)}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'anchor_obj_id': FieldInfo(annotation=Union[int, NoneType], required=False, alias='anchorObjID', alias_priority=1), 'battle_plan': FieldInfo(annotation=Union[BattlePlanDetails, NoneType], required=False, alias='battlePlan', alias_priority=1), 'dest_id': FieldInfo(annotation=Union[int, NoneType], required=False, alias='destID', alias_priority=1), 'destination': FieldInfo(annotation=Union[Tuple[float, float], NoneType], required=False, alias='dest', alias_priority=2), 'eta': FieldInfo(annotation=Union[int, NoneType], required=False, alias='eta', alias_priority=1), 'ftl_type': FieldInfo(annotation=str, required=True, alias='ftlType', alias_priority=1), 'id': FieldInfo(annotation=int, required=True, alias='id', alias_priority=1), 'name': FieldInfo(annotation=str, required=True, alias='name', alias_priority=1), 'news': FieldInfo(annotation=Union[List[News], NoneType], required=False, alias='news', alias_priority=1), 'object_class': FieldInfo(annotation=Literal['fleet'], required=True, alias='class', alias_priority=2), 'pos': FieldInfo(annotation=Tuple[float, float], required=True, alias='pos', alias_priority=1), 'region': FieldInfo(annotation=NebulaType, required=False, default=<NebulaType.CLEAR_SPACE: 1>, alias='region', alias_priority=1), 'resources': FieldInfo(annotation=List[int], required=True, alias='resources', alias_priority=1), 'sovereign_id': FieldInfo(annotation=int, required=True, alias='sovereignID', alias_priority=1)}#
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- region: NebulaType#
- class anacreonlib.History(*, object_class: Literal['history'], history: List[HistoryElement])#
Bases:
AnacreonObjectCreate a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- history: List[HistoryElement]#
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function _snake_case_to_lower_camel>, 'ignored_types': (<class 'functools.cached_property'>, <class 'set'>)}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'history': FieldInfo(annotation=List[HistoryElement], required=True, alias='history', alias_priority=1), 'object_class': FieldInfo(annotation=Literal['history'], required=True, alias='class', alias_priority=2)}#
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- class anacreonlib.HistoryElement(*, id: int, objID: int, subject: int, text: str)#
Bases:
DeserializableDataclassCreate a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- id: int#
ID of this history element, which can be passed to the setHistoryRead endpoint to clear this message
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function _snake_case_to_lower_camel>, 'ignored_types': (<class 'functools.cached_property'>, <class 'set'>)}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'id': FieldInfo(annotation=int, required=True, alias='id', alias_priority=1), 'obj_id': FieldInfo(annotation=int, required=True, alias='objID', alias_priority=1), 'subject': FieldInfo(annotation=int, required=True, alias='subject', alias_priority=1), 'text': FieldInfo(annotation=str, required=True, alias='text', alias_priority=1)}#
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- class anacreonlib.MesophonTrait(*, buyPrices: List[int | float], sellPrices: List[int | float], traitID: int)#
Bases:
DeserializableDataclassTrait applied to the Mesophon sovereign (NPE trading empire that players can buy ships from)
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- buy_prices: List[int | float]#
A list which alternates between resource ID and the number of aes this empire is willing to pay per unit (they are the buyer)
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function _snake_case_to_lower_camel>, 'ignored_types': (<class 'functools.cached_property'>, <class 'set'>)}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'buy_prices': FieldInfo(annotation=List[Union[int, float]], required=True, alias='buyPrices', alias_priority=1), 'sell_prices': FieldInfo(annotation=List[Union[int, float]], required=True, alias='sellPrices', alias_priority=1), 'trait_id': FieldInfo(annotation=int, required=True, alias='traitID', alias_priority=1)}#
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- class anacreonlib.MilitaryForceInfo(space_forces: float, ground_forces: float, missile_forces: float, maneuvering_unit_forces: float)#
Bases:
objectThis is a
dataclasses.dataclass()- ground_forces: float#
The amount of ground forces on a world/in a fleet, as would be shown in the game UI
- maneuvering_unit_forces: float#
The amount of space forces that come from units that are ships (as opposed to fixed point units or satellite units)
- class anacreonlib.NebulaType(value)#
-
Enum of types of space regions a world can be in
(technically, a world cannot be in a RIFT_ZONE) (these values are a guess)
- CLEAR_SPACE = 1#
- DARK_NEBULA = 3#
- LIGHT_NEBULA = 2#
- RIFT_ZONE = 4#
- class anacreonlib.News(*, subject: int, text: str)#
Bases:
DeserializableDataclassCreate a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function _snake_case_to_lower_camel>, 'ignored_types': (<class 'functools.cached_property'>, <class 'set'>)}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'subject': FieldInfo(annotation=int, required=True, alias='subject', alias_priority=1), 'text': FieldInfo(annotation=str, required=True, alias='text', alias_priority=1)}#
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- class anacreonlib.OwnSovereign(*, object_class: Literal['sovereign'], id: int, imperialMight: int, name: str, relationship: SovereignRelationship | None = None, doctrine: int | None = None, traits: List[MesophonTrait] | None = None, capitalID: int, stats: SovereignStats, foundedOn: int | None = None, territory: List[Tuple[float, float, float] | Tuple[float, float, float, float, float]] | None = None, adminRange: List[Tuple[float, float, float] | Tuple[float, float, float, float, float]], explorationGrid: ExplorationGrid, funds: List[int | float], secessionChance: float)#
Bases:
ReigningSovereignRepresents the sovereign belonging to the user who is currently logged in
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- exploration_grid: ExplorationGrid#
- funds: List[int | float]#
Alternating list between resource ID and resource quantity As long as is only one currency (aes), this list will only have 2 elements max
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function _snake_case_to_lower_camel>, 'ignored_types': (<class 'functools.cached_property'>, <class 'set'>)}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'admin_range': FieldInfo(annotation=List[Union[Tuple[float, float, float], Tuple[float, float, float, float, float]]], required=True, alias='adminRange', alias_priority=1), 'capital_id': FieldInfo(annotation=int, required=True, alias='capitalID', alias_priority=1), 'doctrine': FieldInfo(annotation=Union[int, NoneType], required=False, alias='doctrine', alias_priority=1), 'exploration_grid': FieldInfo(annotation=ExplorationGrid, required=True, alias='explorationGrid', alias_priority=1), 'founded_on': FieldInfo(annotation=Union[int, NoneType], required=False, alias='foundedOn', alias_priority=1), 'funds': FieldInfo(annotation=List[Union[int, float]], required=True, alias='funds', alias_priority=1), 'id': FieldInfo(annotation=int, required=True, alias='id', alias_priority=1), 'imperial_might': FieldInfo(annotation=int, required=True, alias='imperialMight', alias_priority=1), 'name': FieldInfo(annotation=str, required=True, alias='name', alias_priority=1), 'object_class': FieldInfo(annotation=Literal['sovereign'], required=True, alias='class', alias_priority=2), 'relationship': FieldInfo(annotation=Union[SovereignRelationship, NoneType], required=False, alias='relationship', alias_priority=1), 'secession_chance': FieldInfo(annotation=float, required=True, alias='secessionChance', alias_priority=1), 'stats': FieldInfo(annotation=SovereignStats, required=True, alias='stats', alias_priority=1), 'territory': FieldInfo(annotation=Union[List[Union[Tuple[float, float, float], Tuple[float, float, float, float, float]]], NoneType], required=False, alias='territory', alias_priority=1), 'traits': FieldInfo(annotation=Union[List[MesophonTrait], NoneType], required=False, alias='traits', alias_priority=1)}#
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- stats: SovereignStats#
- class anacreonlib.OwnedWorld(*, object_class: Literal['world'], id: int, culture: int, designation: int, efficiency: float, name: str, nearObjIDs: List[int] | None = None, orbit: List[float], population: int, pos: Tuple[float, float], resources: List[int] | None = None, sovereignID: int, techLevel: Literal[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], traits: List[int | Trait | Rebellion], worldClass: int, tradeRoutes: List[TradeRoute] | None = None, revIndex: RevIndex, battlePlan: BattlePlanDetails | None = None, targetTechLevel: Literal[1, 2, 3, 4, 5, 6, 7, 8, 9, 10] | None = None, targetPopulation: int | None = None, region: NebulaType = NebulaType.CLEAR_SPACE, baseConsumption: List[int | None], news: List[News] | None = None, tradeRouteMax: int | None = None)#
Bases:
WorldThis is a world we know belongs to the current user because you are guaranteed to see certain fields
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function _snake_case_to_lower_camel>, 'ignored_types': (<class 'functools.cached_property'>, <class 'set'>)}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'base_consumption': FieldInfo(annotation=List[Union[int, NoneType]], required=True, alias='baseConsumption', alias_priority=1), 'battle_plan': FieldInfo(annotation=Union[BattlePlanDetails, NoneType], required=False, alias='battlePlan', alias_priority=1), 'culture': FieldInfo(annotation=int, required=True, alias='culture', alias_priority=1), 'designation': FieldInfo(annotation=int, required=True, alias='designation', alias_priority=1), 'efficiency': FieldInfo(annotation=float, required=True, alias='efficiency', alias_priority=1, metadata=[Ge(ge=0), Le(le=100)]), 'id': FieldInfo(annotation=int, required=True, alias='id', alias_priority=1), 'name': FieldInfo(annotation=str, required=True, alias='name', alias_priority=1), 'near_obj_ids': FieldInfo(annotation=Union[List[int], NoneType], required=False, alias='nearObjIDs', alias_priority=2), 'news': FieldInfo(annotation=Union[List[News], NoneType], required=False, alias='news', alias_priority=1), 'object_class': FieldInfo(annotation=Literal['world'], required=True, alias='class', alias_priority=2), 'orbit': FieldInfo(annotation=List[float], required=True, alias='orbit', alias_priority=1), 'population': FieldInfo(annotation=int, required=True, alias='population', alias_priority=1), 'pos': FieldInfo(annotation=Tuple[float, float], required=True, alias='pos', alias_priority=1), 'region': FieldInfo(annotation=NebulaType, required=False, default=<NebulaType.CLEAR_SPACE: 1>, alias='region', alias_priority=1), 'resources': FieldInfo(annotation=Union[List[Annotated[int, PlainSerializer, BeforeValidator]], NoneType], required=False, alias='resources', alias_priority=1), 'rev_index': FieldInfo(annotation=RevIndex, required=True, alias='revIndex', alias_priority=1), 'sovereign_id': FieldInfo(annotation=int, required=True, alias='sovereignID', alias_priority=1), 'target_population': FieldInfo(annotation=Union[int, NoneType], required=False, alias='targetPopulation', alias_priority=1), 'target_tech_level': FieldInfo(annotation=Union[Literal[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], NoneType], required=False, alias='targetTechLevel', alias_priority=1), 'tech_level': FieldInfo(annotation=Literal[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], required=True, alias='techLevel', alias_priority=1), 'trade_route_max': FieldInfo(annotation=Union[int, NoneType], required=False, alias='tradeRouteMax', alias_priority=1), 'trade_routes': FieldInfo(annotation=Union[List[TradeRoute], NoneType], required=False, alias='tradeRoutes', alias_priority=1), 'traits': FieldInfo(annotation=List[Union[int, Trait, Rebellion]], required=True, alias='traits', alias_priority=1), 'world_class': FieldInfo(annotation=int, required=True, alias='worldClass', alias_priority=1)}#
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- class anacreonlib.ProductionInfo(available: float = 0, consumed: float = 0, exported: float = 0, imported: float = 0, produced: float = 0, consumed_optimal: float = 0, exported_optimal: float = 0, imported_optimal: float = 0, produced_optimal: float = 0)#
Bases:
objectThis is a
dataclasses.dataclass()- consumed_optimal: float = 0#
Amount of resource that would have been consumed last watch if there were no resource shortages
- exported_optimal: float = 0#
Amount of resource that would have been exported last watch if there were no resource shortages
- class anacreonlib.Rebellion(*, popularSupport: float, rebelForces: float, rebellionStart: int, traitID: int)#
Bases:
DeserializableDataclassCreate a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function _snake_case_to_lower_camel>, 'ignored_types': (<class 'functools.cached_property'>, <class 'set'>)}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'popular_support': FieldInfo(annotation=float, required=True, alias='popularSupport', alias_priority=1), 'rebel_forces': FieldInfo(annotation=float, required=True, alias='rebelForces', alias_priority=1), 'rebellion_start': FieldInfo(annotation=int, required=True, alias='rebellionStart', alias_priority=1), 'trait_id': FieldInfo(annotation=int, required=True, alias='traitID', alias_priority=1)}#
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- class anacreonlib.RegionObject(*, object_class: Literal['region'], id: int, shape: List[RegionShape], type: int)#
Bases:
AnacreonObjectWithIdTypically used to encode the location of nebulas, rift zones, and clear space
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function _snake_case_to_lower_camel>, 'ignored_types': (<class 'functools.cached_property'>, <class 'set'>)}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'id': FieldInfo(annotation=int, required=True, alias='id', alias_priority=1), 'object_class': FieldInfo(annotation=Literal['region'], required=True, alias='class', alias_priority=2), 'shape': FieldInfo(annotation=List[RegionShape], required=True, alias='shape', alias_priority=1), 'type': FieldInfo(annotation=int, required=True, alias='type', alias_priority=1)}#
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- shape: List[RegionShape]#
- class anacreonlib.RegionShape(*, holes: List[List[float]] | None = None, outline: List[float])#
Bases:
DeserializableDataclassCreate a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function _snake_case_to_lower_camel>, 'ignored_types': (<class 'functools.cached_property'>, <class 'set'>)}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'holes': FieldInfo(annotation=Union[List[List[float]], NoneType], required=False, alias='holes', alias_priority=1), 'outline': FieldInfo(annotation=List[float], required=True, alias='outline', alias_priority=1)}#
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- class anacreonlib.ReigningSovereign(*, object_class: Literal['sovereign'], id: int, imperialMight: int, name: str, relationship: SovereignRelationship | None = None, doctrine: int | None = None, traits: List[MesophonTrait] | None = None, capitalID: int, stats: SovereignStats, foundedOn: int | None = None, territory: List[Tuple[float, float, float] | Tuple[float, float, float, float, float]] | None = None)#
Bases:
SovereignSome Sovereigns are abdicated. This class is only for sovereigns currently playing the game.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function _snake_case_to_lower_camel>, 'ignored_types': (<class 'functools.cached_property'>, <class 'set'>)}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'capital_id': FieldInfo(annotation=int, required=True, alias='capitalID', alias_priority=1), 'doctrine': FieldInfo(annotation=Union[int, NoneType], required=False, alias='doctrine', alias_priority=1), 'founded_on': FieldInfo(annotation=Union[int, NoneType], required=False, alias='foundedOn', alias_priority=1), 'id': FieldInfo(annotation=int, required=True, alias='id', alias_priority=1), 'imperial_might': FieldInfo(annotation=int, required=True, alias='imperialMight', alias_priority=1), 'name': FieldInfo(annotation=str, required=True, alias='name', alias_priority=1), 'object_class': FieldInfo(annotation=Literal['sovereign'], required=True, alias='class', alias_priority=2), 'relationship': FieldInfo(annotation=Union[SovereignRelationship, NoneType], required=False, alias='relationship', alias_priority=1), 'stats': FieldInfo(annotation=SovereignStats, required=True, alias='stats', alias_priority=1), 'territory': FieldInfo(annotation=Union[List[Union[Tuple[float, float, float], Tuple[float, float, float, float, float]]], NoneType], required=False, alias='territory', alias_priority=1), 'traits': FieldInfo(annotation=Union[List[MesophonTrait], NoneType], required=False, alias='traits', alias_priority=1)}#
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- stats: SovereignStats#
- class anacreonlib.Relationship(*, object_class: Literal['relationship'], id: int, relationship: SovereignRelationship)#
Bases:
AnacreonObjectWithIdPartial update for sovereigns
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function _snake_case_to_lower_camel>, 'ignored_types': (<class 'functools.cached_property'>, <class 'set'>)}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'id': FieldInfo(annotation=int, required=True, alias='id', alias_priority=1), 'object_class': FieldInfo(annotation=Literal['relationship'], required=True, alias='class', alias_priority=2), 'relationship': FieldInfo(annotation=SovereignRelationship, required=True, alias='relationship', alias_priority=1)}#
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- relationship: SovereignRelationship#
- class anacreonlib.RevIndex(value)#
-
Enum of social orders a world can have
- AGGRIEVED = 'aggrieved'#
- CIVIL_WAR = 'civil war'#
- CONTENT = 'content'#
- DISSATISFIED = 'dissatisfied'#
- HAPPY = 'happy'#
- REBELLING = 'rebelling'#
- RIOTING = 'rioting'#
- class anacreonlib.Selection(*, object_class: Literal['selection'], id: int)#
Bases:
AnacreonObjectWithIdThe API returns this object if it wants the UI to select something as a result of the API request
For example, when you deploy a fleet, the API returns one of these objects in order to signal that the new fleet should be selected.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function _snake_case_to_lower_camel>, 'ignored_types': (<class 'functools.cached_property'>, <class 'set'>)}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'id': FieldInfo(annotation=int, required=True, alias='id', alias_priority=1), 'object_class': FieldInfo(annotation=Literal['selection'], required=True, alias='class', alias_priority=2)}#
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- class anacreonlib.Siege(*, object_class: Literal['siege'], id: int, anchorObjID: int, attackForces: float, defenseForces: float, name: str, news: List[News] | None = None, pos: Tuple[float, float], resources: List[float] | None = None, sovereignID: int, status: SiegeStatus | None = None, timeleft: int | None = None)#
Bases:
AnacreonObjectWithIdCreate a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function _snake_case_to_lower_camel>, 'ignored_types': (<class 'functools.cached_property'>, <class 'set'>)}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'anchor_obj_id': FieldInfo(annotation=int, required=True, alias='anchorObjID', alias_priority=1), 'attack_forces': FieldInfo(annotation=float, required=True, alias='attackForces', alias_priority=1), 'defense_forces': FieldInfo(annotation=float, required=True, alias='defenseForces', alias_priority=1), 'id': FieldInfo(annotation=int, required=True, alias='id', alias_priority=1), 'name': FieldInfo(annotation=str, required=True, alias='name', alias_priority=1), 'news': FieldInfo(annotation=Union[List[News], NoneType], required=False, alias='news', alias_priority=1), 'object_class': FieldInfo(annotation=Literal['siege'], required=True, alias='class', alias_priority=2), 'pos': FieldInfo(annotation=Tuple[float, float], required=True, alias='pos', alias_priority=1), 'resources': FieldInfo(annotation=Union[List[float], NoneType], required=False, alias='resources', alias_priority=1), 'sovereign_id': FieldInfo(annotation=int, required=True, alias='sovereignID', alias_priority=1), 'status': FieldInfo(annotation=Union[SiegeStatus, NoneType], required=False, alias='status', alias_priority=1), 'timeLeft': FieldInfo(annotation=Union[int, NoneType], required=False, alias='timeleft', alias_priority=1)}#
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- status: SiegeStatus | None#
- class anacreonlib.Sovereign(*, object_class: Literal['sovereign'], id: int, imperialMight: int, name: str, relationship: SovereignRelationship | None = None, doctrine: int | None = None, traits: List[MesophonTrait] | None = None)#
Bases:
AnacreonObjectWithIdAny sovereign that has ever played in the current game
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function _snake_case_to_lower_camel>, 'ignored_types': (<class 'functools.cached_property'>, <class 'set'>)}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'doctrine': FieldInfo(annotation=Union[int, NoneType], required=False, alias='doctrine', alias_priority=1), 'id': FieldInfo(annotation=int, required=True, alias='id', alias_priority=1), 'imperial_might': FieldInfo(annotation=int, required=True, alias='imperialMight', alias_priority=1), 'name': FieldInfo(annotation=str, required=True, alias='name', alias_priority=1), 'object_class': FieldInfo(annotation=Literal['sovereign'], required=True, alias='class', alias_priority=2), 'relationship': FieldInfo(annotation=Union[SovereignRelationship, NoneType], required=False, alias='relationship', alias_priority=1), 'traits': FieldInfo(annotation=Union[List[MesophonTrait], NoneType], required=False, alias='traits', alias_priority=1)}#
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- relationship: SovereignRelationship | None#
- traits: List[MesophonTrait] | None#
- class anacreonlib.SovereignActions(*, attacksInitiated: int, offensivesInitiated: int, worldsConquered: int)#
Bases:
DeserializableDataclassCreate a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function _snake_case_to_lower_camel>, 'ignored_types': (<class 'functools.cached_property'>, <class 'set'>)}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'attacks_initiated': FieldInfo(annotation=int, required=True, alias='attacksInitiated', alias_priority=1), 'offensives_initiated': FieldInfo(annotation=int, required=True, alias='offensivesInitiated', alias_priority=1), 'worlds_conquered': FieldInfo(annotation=int, required=True, alias='worldsConquered', alias_priority=1)}#
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- class anacreonlib.SovereignRelationship(*, firstContact: int, ourActions: SovereignActions, theirActions: SovereignActions)#
Bases:
DeserializableDataclassCreate a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function _snake_case_to_lower_camel>, 'ignored_types': (<class 'functools.cached_property'>, <class 'set'>)}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'first_contact': FieldInfo(annotation=int, required=True, alias='firstContact', alias_priority=1), 'our_actions': FieldInfo(annotation=SovereignActions, required=True, alias='ourActions', alias_priority=1), 'their_actions': FieldInfo(annotation=SovereignActions, required=True, alias='theirActions', alias_priority=1)}#
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- our_actions: SovereignActions#
- their_actions: SovereignActions#
- class anacreonlib.SovereignStats(*, fleets: int, population: int, resources: List[int] | None = None, techLevel: Literal[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], worlds: int)#
Bases:
DeserializableDataclassCreate a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function _snake_case_to_lower_camel>, 'ignored_types': (<class 'functools.cached_property'>, <class 'set'>)}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'fleets': FieldInfo(annotation=int, required=True, alias='fleets', alias_priority=1, metadata=[PlainSerializer(func=<function _convert_int_to_aeon_ipinteger>, return_type=PydanticUndefined, when_used='json-unless-none'), BeforeValidator(func=<function _convert_aeon_ipinteger_to_int>)]), 'population': FieldInfo(annotation=int, required=True, alias='population', alias_priority=1), 'resources': FieldInfo(annotation=Union[List[Annotated[int, PlainSerializer, BeforeValidator]], NoneType], required=False, alias='resources', alias_priority=1), 'tech_level': FieldInfo(annotation=Literal[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], required=True, alias='techLevel', alias_priority=1), 'worlds': FieldInfo(annotation=int, required=True, alias='worlds', alias_priority=1)}#
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- class anacreonlib.TradeRoute(*, imports: List[float | None] | None = None, exports: List[float | None] | None = None, importTech: Tuple[int, int] | Tuple[int, int, Any] | None = None, exportTech: Tuple[int, int] | Tuple[int, int, Any] | None = None, partnerObjID: int, reciprocal: bool | None = None)#
Bases:
DeserializableDataclass- Variables:
import_tech – tuple of the desired tech level to acheive, and how many levels uplifted the planet actually is
reciprocal – if true, the data for this trade route is attached to the partner object.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- import_tech: Tuple[int, int] | Tuple[int, int, Any] | None#
Third tuple element is usually not present. If present, it indicates why the world cannot be uplifted to the desired tech level.
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function _snake_case_to_lower_camel>, 'ignored_types': (<class 'functools.cached_property'>, <class 'set'>)}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'export_tech': FieldInfo(annotation=Union[Tuple[int, int], Tuple[int, int, Any], NoneType], required=False, alias='exportTech', alias_priority=1), 'exports': FieldInfo(annotation=Union[List[Union[float, NoneType]], NoneType], required=False, alias='exports', alias_priority=1), 'import_tech': FieldInfo(annotation=Union[Tuple[int, int], Tuple[int, int, Any], NoneType], required=False, alias='importTech', alias_priority=1), 'imports': FieldInfo(annotation=Union[List[Union[float, NoneType]], NoneType], required=False, alias='imports', alias_priority=1), 'partner_obj_id': FieldInfo(annotation=int, required=True, alias='partnerObjID', alias_priority=1), 'reciprocal': FieldInfo(annotation=Union[bool, NoneType], required=False, alias='return', alias_priority=2)}#
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- class anacreonlib.Trait(*, allocation: float, buildData: List[float | None | List[Any]], isPrimary: bool | None = None, productionData: List[float | None] | None = None, isFixed: bool | None = None, targetAllocation: float, traitID: int, buildComplete: int | None = None, workUnits: float)#
Bases:
DeserializableDataclassCreate a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- is_primary: bool | None#
True`if this structure is the primary industry on the world (i.e it belongs to the designation)
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function _snake_case_to_lower_camel>, 'ignored_types': (<class 'functools.cached_property'>, <class 'set'>)}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'allocation': FieldInfo(annotation=float, required=True, alias='allocation', alias_priority=1), 'build_complete': FieldInfo(annotation=Union[int, NoneType], required=False, alias='buildComplete', alias_priority=1), 'build_data': FieldInfo(annotation=List[Union[float, NoneType, List[Any]]], required=True, alias='buildData', alias_priority=1), 'is_fixed': FieldInfo(annotation=Union[bool, NoneType], required=False, alias='isFixed', alias_priority=1), 'is_primary': FieldInfo(annotation=Union[bool, NoneType], required=False, alias='isPrimary', alias_priority=1), 'production_data': FieldInfo(annotation=Union[List[Union[float, NoneType]], NoneType], required=False, alias='productionData', alias_priority=1), 'target_allocation': FieldInfo(annotation=float, required=True, alias='targetAllocation', alias_priority=1), 'trait_id': FieldInfo(annotation=int, required=True, alias='traitID', alias_priority=1), 'work_units': FieldInfo(annotation=float, required=True, alias='workUnits', alias_priority=1)}#
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- class anacreonlib.UpdateObject(*, object_class: Literal['update'], nextUpdateTime: int, sequence: int, update: float, year0: int)#
Bases:
AnacreonObjectCreate a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function _snake_case_to_lower_camel>, 'ignored_types': (<class 'functools.cached_property'>, <class 'set'>)}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'next_update_time': FieldInfo(annotation=int, required=True, alias='nextUpdateTime', alias_priority=1), 'object_class': FieldInfo(annotation=Literal['update'], required=True, alias='class', alias_priority=2), 'sequence': FieldInfo(annotation=int, required=True, alias='sequence', alias_priority=1, metadata=[PlainSerializer(func=<function _convert_int_to_aeon_ipinteger>, return_type=PydanticUndefined, when_used='json-unless-none'), BeforeValidator(func=<function _convert_aeon_ipinteger_to_int>)]), 'update': FieldInfo(annotation=float, required=True, alias='update', alias_priority=1), 'year0': FieldInfo(annotation=int, required=True, alias='year0', alias_priority=1)}#
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- class anacreonlib.World(*, object_class: Literal['world'], id: int, culture: int, designation: int, efficiency: float, name: str, nearObjIDs: List[int] | None = None, orbit: List[float], population: int, pos: Tuple[float, float], resources: List[int] | None = None, sovereignID: int, techLevel: Literal[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], traits: List[int | Trait | Rebellion], worldClass: int, tradeRoutes: List[TradeRoute] | None = None, revIndex: RevIndex | None = None, battlePlan: BattlePlanDetails | None = None, targetTechLevel: Literal[1, 2, 3, 4, 5, 6, 7, 8, 9, 10] | None = None, targetPopulation: int | None = None, region: NebulaType = NebulaType.CLEAR_SPACE)#
Bases:
AnacreonObjectWithIdCreate a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- battle_plan: BattlePlanDetails | None#
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function _snake_case_to_lower_camel>, 'ignored_types': (<class 'functools.cached_property'>, <class 'set'>)}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'battle_plan': FieldInfo(annotation=Union[BattlePlanDetails, NoneType], required=False, alias='battlePlan', alias_priority=1), 'culture': FieldInfo(annotation=int, required=True, alias='culture', alias_priority=1), 'designation': FieldInfo(annotation=int, required=True, alias='designation', alias_priority=1), 'efficiency': FieldInfo(annotation=float, required=True, alias='efficiency', alias_priority=1, metadata=[Ge(ge=0), Le(le=100)]), 'id': FieldInfo(annotation=int, required=True, alias='id', alias_priority=1), 'name': FieldInfo(annotation=str, required=True, alias='name', alias_priority=1), 'near_obj_ids': FieldInfo(annotation=Union[List[int], NoneType], required=False, alias='nearObjIDs', alias_priority=2), 'object_class': FieldInfo(annotation=Literal['world'], required=True, alias='class', alias_priority=2), 'orbit': FieldInfo(annotation=List[float], required=True, alias='orbit', alias_priority=1), 'population': FieldInfo(annotation=int, required=True, alias='population', alias_priority=1), 'pos': FieldInfo(annotation=Tuple[float, float], required=True, alias='pos', alias_priority=1), 'region': FieldInfo(annotation=NebulaType, required=False, default=<NebulaType.CLEAR_SPACE: 1>, alias='region', alias_priority=1), 'resources': FieldInfo(annotation=Union[List[Annotated[int, PlainSerializer, BeforeValidator]], NoneType], required=False, alias='resources', alias_priority=1), 'rev_index': FieldInfo(annotation=Union[RevIndex, NoneType], required=False, alias='revIndex', alias_priority=1), 'sovereign_id': FieldInfo(annotation=int, required=True, alias='sovereignID', alias_priority=1), 'target_population': FieldInfo(annotation=Union[int, NoneType], required=False, alias='targetPopulation', alias_priority=1), 'target_tech_level': FieldInfo(annotation=Union[Literal[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], NoneType], required=False, alias='targetTechLevel', alias_priority=1), 'tech_level': FieldInfo(annotation=Literal[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], required=True, alias='techLevel', alias_priority=1), 'trade_routes': FieldInfo(annotation=Union[List[TradeRoute], NoneType], required=False, alias='tradeRoutes', alias_priority=1), 'traits': FieldInfo(annotation=List[Union[int, Trait, Rebellion]], required=True, alias='traits', alias_priority=1), 'world_class': FieldInfo(annotation=int, required=True, alias='worldClass', alias_priority=1)}#
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- region: NebulaType#
- property resource_dict: Dict[int, float]#
A dict mapping from resource ID to resource qty on the world
- resources: List[int] | None#
This is a list alternating between resource ID and quantity stockpiled on the world
- property squashed_trait_dict: Dict[int, int | Trait]#
Return a dict mapping from trait ID to either trait ID or trait object
- target_population: int | None#
If the population is going to change, the value of this field is what the planet is heading towards
Unit is millions of people
- target_tech_level: Literal[1, 2, 3, 4, 5, 6, 7, 8, 9, 10] | None#
If the world is going to change tech levels soon, the value of this field is the target tech level
- property trade_route_partners: Dict[int, TradeRoute] | None#
Returns a set of all of the trade route partners of this world
- trade_routes: List[TradeRoute] | None#
Submodules#
anacreonlib.exceptions module#
anacreonlib.utils module#
Utility function to help with decode information from the Anacreon API
Where possible, function signatures have been ordered with partial application
(see functools.partial()) in mind.
- anacreonlib.utils.dist(pointA: Tuple[float, float], pointB: Tuple[float, float]) float#
Retuns the distance between 2 points
Example
>>> pointA = (0, 0) >>> pointB = (3, 4) >>> utils.dist(pointA, pointB) 5.0
- Parameters:
pointA (Location) – An
(x, y)coordinate pairpointB (Location) – An
(x, y)coordinate pair
- Returns:
The distance between the two points
- Return type:
- anacreonlib.utils.does_trait_depend_on_trait(scninfo: List[ScenarioInfoElement], trait_a: int, trait_b: int) bool#
Check if a
trait_bhas anothertrait_aanywhere in the chain of requirements.For example, a sealed arcology (trait ID 218) is an upgrade to a domed city (trait id 88). So, the call
utils.does_trait_depend_on_trait(scninfo, 218, 88)would returnTruebecause trait ID 218 needs trait ID 88 to be built first.Note that there can be multiple upgrade paths to a more advanced trait/improvement. For example, the the sealed arcology ruins (ID 219) are also a predecessor to the sealed arcology (ID 218).
- Parameters:
scninfo (List[ScenarioInfoElement]) – The scenario info
trait_a (int) – The ID of the ‘more advanced’ trait
trait_b (int) – The ID of the ‘less advanced’ trait
- Returns:
Whether
trait_aneedstrait_bto be built first.- Return type:
- anacreonlib.utils.flat_list_to_n_tuples(n: int, lst: List[T]) List[Tuple[T, ...]]#
Converts a list
[1,2,3,4,5,6,...]into a list of tuples[(1,2,3), (4,5,6), ...]where the length of each tuple is specified by the parameternExample
One use case of this function is to handle import data
>>> imports = [130, 100, 5700, None, 260, 100, 6400, 500] >>> for res_id, pct, optimal, actual in flat_list_to_n_tuples(4, imports): ... print(f"Imported {actual or optimal} units of resource id {res_id} (optimal: {optimal})") ... Imported 5700 units of resource id 130 (optimal: 5700) Imported 500 units of resource id 260 (optimal: 6400)
- Parameters:
n (int) – The length of each tuple in the returned list
lst (List[T]) – A flat list of all of the items
- Returns:
A list of tuples, where each item in the original list appears exactly once.
- Return type:
List[Tuple[T, …]]
- anacreonlib.utils.flat_list_to_tuples(lst: Sequence[T]) List[Tuple[T, T]]#
Turn a flat list of alternating key-value pairs into a list of tuples
Example
A common use case of this function is to iterate over a
resourceslist>>> resources = [130, 500, 159, 15000] >>> for res_id, res_qty in utils.flat_list_to_tuples(resources): ... print(f"We have {res_qty} of resource id {res_id}") ... We have 500 of resource id 130 We have 15000 of resource id 159
- Parameters:
lst (Sequence[T]) – A flat sequence of alternating key-value pairs
- Returns:
A list of key-value tuples
- Return type:
List[Tuple[T, T]]
- anacreonlib.utils.get_world_primary_industry_products(world: World) List[int] | None#
Get the list of resource IDs that a planet produces with its primary industry
- anacreonlib.utils.trait_inherits_from_trait(scninfo: List[ScenarioInfoElement], child_trait: Trait | int, parent_trait: Trait | int) bool#
Check if a trait inherits from another trait
Traits can extend other traits. For example, the trait for having abundant chronimium deposits, ID
50, inherits from the trait for having any chronimium deposits, ID56. A world that has trait ID50also has trait ID56. However, this is only implied by the inheritance hierarchy of traits – the world object as returned by the API does would only give the “most specific” trait. In this case, it would only explicitly say the world has trait ID50. This function can be used to figure out that the world also has trait ID56as a result.- Parameters:
scninfo (List[ScenarioInfoElement]) – The scenario info
child_trait (Union[Trait, int]) – The ‘more advanced/specific’ trait (e.g the trait id for abundant chronimium deposits)
parent_trait (Union[Trait, int]) – The ‘less advanced/specific’ trait (e.g the trait id for chronimium deposits)
- Raises:
LookupError – Raised if the child trait ID could not be found in the
scenario info –
- Returns:
Trueif the child trait supplants the parent trait, like how asealed arcology supplants a domed city.
Falseotherwise.
- Return type:
- anacreonlib.utils.trait_under_construction(squashed_trait_dict: Dict[int, int | Trait], trait_id: int) bool#
Check whether a world is still building a trait
- Parameters:
squashed_trait_dict (Dict[int, Union[int, Trait]]) – A dict mapping from trait ID to either the trait ID or trait object. This can be obtained from
anacreonlib.types.response_datatypes.World.squashed_trait_dict()trait_id (int) – The ID of the trait to check for
- Returns:
Trueif the world has the trait, and it is still building.Falseif the world has fully built the trait, or if it does not have the trait at all.- Return type:
- anacreonlib.utils.world_has_fully_built_trait(scninfo: List[ScenarioInfoElement], world: World, target_trait_id: int) bool#
Check that a world has fully built a trait to completion.
This function is aware of the trait inheritance hierarchy. So, for example, we would consider a planet that has a sealed arcology (trait ID
218) to have ‘fully built’ a domed city (trait ID88), because a sealed arcology upgrades a domed city.- Parameters:
scninfo (List[ScenarioInfoElement]) – The scenario info for the game
world (World) – The world to check for
target_trait_id (int) – The trait ID to check for
- Returns:
Trueif the world has the specified trait, or a successor to the specified trait.Falseotherwise.- Return type:
- anacreonlib.utils.world_has_trait(scninfo: List[ScenarioInfoElement], world: World, target_trait_id: int, include_world_characteristics: bool = True) bool#
Checks whether a world has a given trait, or a child trait extends the given trait
- Parameters:
scninfo (List[ScenarioInfoElement]) – The scenario info for the game.
world (World) – The world to check
target_trait_id (int) – The trait to check the presence of
include_world_characteristics (bool, optional) – Whether or not we should take intrinsic world characteristics (e.g world type, designation) into account. Defaults to True.
- Returns:
Whether or not the planet has the given trait.
- Return type:
anacreonlib.anacreon_async_client module#
- class anacreonlib.anacreon_async_client.AnacreonAsyncClient(*, base_url: str = 'https://anacreon.kronosaur.com/api/')#
Bases:
ConsumerA coroutine-based asynchronous API client to interact with anacreon
- abort_attack = <uplink.commands.RequestDefinitionBuilder object>#
- attack = <uplink.commands.RequestDefinitionBuilder object>#
- authenticate_user = <uplink.commands.RequestDefinitionBuilder object>#
- build_improvement = <uplink.commands.RequestDefinitionBuilder object>#
- buy_item = <uplink.commands.RequestDefinitionBuilder object>#
- deploy_fleet = <uplink.commands.RequestDefinitionBuilder object>#
- designate_world = <uplink.commands.RequestDefinitionBuilder object>#
- destroy_improvement = <uplink.commands.RequestDefinitionBuilder object>#
- disband_fleet = <uplink.commands.RequestDefinitionBuilder object>#
- get_game_info = <uplink.commands.RequestDefinitionBuilder object>#
- get_game_list = <uplink.commands.RequestDefinitionBuilder object>#
- get_objects = <uplink.commands.RequestDefinitionBuilder object>#
- get_tactical = <uplink.commands.RequestDefinitionBuilder object>#
- launch_lams = <uplink.commands.RequestDefinitionBuilder object>#
- rename_object = <uplink.commands.RequestDefinitionBuilder object>#
- sell_fleet = <uplink.commands.RequestDefinitionBuilder object>#
- send_message = <uplink.commands.RequestDefinitionBuilder object>#
- set_fleet_destination = <uplink.commands.RequestDefinitionBuilder object>#
- set_history_read = <uplink.commands.RequestDefinitionBuilder object>#
- set_industry_alloc = <uplink.commands.RequestDefinitionBuilder object>#
- set_product_alloc = <uplink.commands.RequestDefinitionBuilder object>#
- set_trade_route = <uplink.commands.RequestDefinitionBuilder object>#
- stop_trade_route = <uplink.commands.RequestDefinitionBuilder object>#
- tactical_order = <uplink.commands.RequestDefinitionBuilder object>#
- transfer_fleet = <uplink.commands.RequestDefinitionBuilder object>#
anacreonlib.anacreon module#
The Anacreon class is a wrapper around
AnacreonAsyncClient that handles
basic functionality (such as state management and merging partial updates).
- class anacreonlib.anacreon.Anacreon(auth_info: AnacreonApiRequest, game_info: ScenarioInfo, client: AnacreonAsyncClient | None = None)#
Bases:
objectConstruct an Anacreon instance directly
Consider using one of the helper class methods like
log_in()instead- Parameters:
auth_info (AnacreonApiRequest) – A stub API request containing a valid auth token
game_info (ScenarioInfo) – Info about the game, such as all the traits that
client (Optional[AnacreonAsyncClient], optional) – The low-level API client to use in order to make HTTP requests. Defaults to None.
- async abort_attack(battlefield_id: int) None#
Abort an attack in progress
- Parameters:
battlefield_id (int) – The world ID of the planet that you are attacking
- async attack(battlefield_id: int, objective: BattleObjective, enemy_sovereign_ids: List[int]) None#
Attack a world
- Parameters:
battlefield_id (int) – The ID of the world that you intend to attack
objective (BattleObjective) – Whether you want to invade, reinforce a siege, or destroy all space defenses
enemy_sovereign_ids (List[int]) – A list of the sovereign ids that you wish to engage in battle with
- async buy_item(source_obj_id: int, item_id: int, item_count: int) None#
Buy an item from the Mesophons.
As a prerequisite to calling this method, you must have a fleet stationed at the world where you wish to buy ships from.
- calculate_forces(object_or_resources: World | Fleet | Dict[int, int] | List[int]) MilitaryForceInfo#
Calculate the ground forces + space forces of a particular world/fleet
- calculate_remaining_cargo_space(fleet: Fleet | int) float#
Calculate the remaining cargo space on a fleet
- Parameters:
fleet (Union[Fleet, int]) – Either the
Fleetobject, or the fleet ID- Raises:
LookupError – Raised if the fleet could not be found
- Returns:
The remaining cargo space left in the fleet. Can be negative if uneven attrition has left more cargo in the fleet than it has space for.
- Return type:
- call_get_objects_periodically() Task[None]#
Spawns an
Taskthat callsAnacreon.get_objects()every watch.- Returns:
The task that was spawned.
- Return type:
asyncio.Task[None]
- client: AnacreonAsyncClient#
the low level API client that is used to make HTTP requests to the Anacreon API
- async deploy_fleet(source_obj_id: int, resources: Dict[int, int] | List[int]) Fleet | None#
Deploy a fleet
- async destroy_improvement(world_obj_id: int, improvement_id: int) None#
Destroy a structure/improvement on a world
- async disband_fleet(fleet_obj_id: int, dest_obj_id: int) None#
Delete a fleet by forcing it to become a part of another object that it is stationed next to.
You can use this method to gift fleets to enemy sovereigns.
- async classmethod from_auth_token(game_id: str, auth_token: str, *, client: AnacreonAsyncClient | None = None) Anacreon#
Authenticate with the Anacreon API using an auth token
You can get an auth token by looking at your cookies for anacreon.kronosaur.com in your browser’s dev console.
- game_info: ScenarioInfo#
The scenario info for the game
- generate_production_info(world: World | int) Dict[int, ProductionInfo]#
Calculate production info for a world
- Parameters:
world (Union[World, int]) – Either the
Worldobject, or the world ID.- Raises:
LookupError – Raised if world is a world ID that cannot be found
- Returns:
A mapping from resource ID to
ProductionInfoobjects describing how much of that resource was imported/exported- Return type:
Dict[int, ProductionInfo]
- async get_objects() Anacreon#
Refreshes game state from the Anacreon API to update world state, fleet state, and so on.
- Returns:
this object
- Return type:
- async get_tactical(battlefield_id: str) List[Dict[str, Any]]#
Get battlefield information of a planet, such as battle groups and squadron locations
- get_valid_improvement_list(world: World) List[ScenarioInfoElement]#
Returns a list of scenario elements which represent improvements that can be built on a given world.
- Parameters:
world (World) – The world in question
- Returns:
A list of improvements that can be built.
- Return type:
List[ScenarioInfoElement]
- history: Dict[int, HistoryElement]#
A list of all history popups that would appear over your worlds in the game UI
- async classmethod log_in(game_id: str, username: str, password: str) Anacreon#
Authenticate with the Anacreon API using a Multiverse username and password
Example
>>> import asyncio >>> async def main(): ... client = await Anacreon.log_in("8JNJ7FNZ", "username", "password") ... # do stuff with client ... >>> asyncio.run(main())
- Parameters:
game_id (str) – The game ID of the game you intend to manipulate. You can find the game ID by looking at the URL when you are playing Anacreon in your browser. e.g if the URL was
anacreon.kronosaur.com/trantor.hexm?gameID=8JNJ7FNZ, the game ID would be8JNJ7FNZ.username (str) – The username to your Multiverse account
password (str) – The password to your Multiverse account
- Returns:
An instance of the API client wrapper, which can be used to programmatically perform actions within the game
- Return type:
- scenario_info_objects: Dict[int, ScenarioInfoElement]#
A mapping from trait/resource ID to
ScenarioInfoElement
- async sell_fleet(fleet_id: int, buyer_obj_id: int, resources: Dict[int, int] | List[int]) None#
Sell a fleet (or fleet cargo) to the Mesophons
As a prerequisite to calling this method, the fleet in question must already be stationed at a mesophon world.
- Parameters:
fleet_id (int) – The ID of the fleet to sell from
buyer_obj_id (int) – The ID of the Mesophon world you are selling to
resources (IdValueMapping) – The resources from the fleet which you are selling to the mesophons. You may choose to sell a portion of your resources, as opposed to all of the fleet’s cargo or all of the ships.
- async set_history_read(history_id: int) bool#
Delet a history popup that show up over a planet
You can see a list of all the history popups by looking at
Anacreon.history.
- async set_industry_alloc(world_id: int, industry_id: int, pct_labor_allocated: SupportsFloat) None#
On a world, set the percent labor allocation to a structure
For example, this method can be used to set the labor allocation to defense structures to 0%.
- async set_product_alloc(world_id: int, industry_id: int, pct_labor_allocated_by_resource: Dict[int, int] | List[int]) None#
Within a single industry, set the percent labor allocation to a single product of the industry.
For example, this method can be used to set the labor allocation on a jumpship yards planet to spend 100% of the labor available to the yards structure on building Reliant-class jumptransports.
- async set_trade_route(importer_id: int, exporter_id: int, alloc_type: str = TradeRouteTypes.DEFAULT, alloc_value: str | float | None = None, res_type_id: int | None = None) None#
Create/update a trade route between 2 planets
- Parameters:
importer_id (int) – The ID of the world that is importing resources
exporter_id (int) – The ID of the world that is exporting resources
alloc_type (TradeRouteTypes, optional) – How to decide how the trade route should be set. Defaults to
TradeRouteTypes.DEFAULT, which emulates the behavior of setting up a 1 way trade route between 2 unconnected planets in the game UI.alloc_value (Optional[Union[str, float]], optional) – The percent of demand on the importing world to import from (between 0 and 999). Defaults to None.
res_type_id (Optional[int], optional) – The ID of the resource to import.
- async stop_trade_route(planet_id_a: int, planet_id_b: int) None#
Stop all trade between 2 planets
If you need to stop trade on only one resource, you may do the set the percent of demand to import to 0 using
Anacreon.set_trade_route()withalloc_typeasTradeRouteTypes.CONSUMPTION.
- async tactical_order(battlefield_id: int, order: TacticalOrderType | str, squadron_id: int, orbit: float | None = None, target_id: int | None = None) bool#
Send an order to a tactial squadron on a world
- Parameters:
battlefield_id (int) – The ID of the world
order (Union[TacticalOrderType, str]) – The order you are giving
squadron_id (int) – The ID of the squadron to give the order to
orbit (Optional[float]) – If
orderisTacticalOrderType.ORBIT, this should be the new orbit altitudetarget_id (Optional[int]) – If
orderisTacticalOrderType.TARGET, this should be the id of the tactical squadron to target
- Returns:
Trueif the order was successfully processed- Return type:
- async transfer_fleet(fleet_obj_id: int, dest_obj_id: int, resources: Dict[int, int] | List[int]) None#
Transfer ships in a fleet to another fleet/world
- update_obj: UpdateObject | None#
- async wait_for_any_update() None#
This coroutine waits until any method that updates game state, such as
Anacreon.designate_world()orAnacreon.attack(), is called.One use case for this function is when you are just starting a script, and you spawn an
Taskto periodically fetch updates. Your main coroutine would have to block until the task fetches the first update.
- async wait_for_get_objects() None#
This coroutine waits until
Anacreon.get_objects()is called by someone else.One use case for this function is when you have 2 long-lived async
Tasks running. One is calingAnacreon.get_objects()every minute, while the other is managing a fleet. The task managing the fleet could to use this method to wait for updates to the state
- class anacreonlib.anacreon.MilitaryForceInfo(space_forces: float, ground_forces: float, missile_forces: float, maneuvering_unit_forces: float)#
Bases:
objectThis is a
dataclasses.dataclass()- ground_forces: float#
The amount of ground forces on a world/in a fleet, as would be shown in the game UI
- maneuvering_unit_forces: float#
The amount of space forces that come from units that are ships (as opposed to fixed point units or satellite units)
- class anacreonlib.anacreon.ProductionInfo(available: float = 0, consumed: float = 0, exported: float = 0, imported: float = 0, produced: float = 0, consumed_optimal: float = 0, exported_optimal: float = 0, imported_optimal: float = 0, produced_optimal: float = 0)#
Bases:
objectThis is a
dataclasses.dataclass()- consumed_optimal: float = 0#
Amount of resource that would have been consumed last watch if there were no resource shortages
- exported_optimal: float = 0#
Amount of resource that would have been exported last watch if there were no resource shortages
Subpackages#
- anacreonlib.types package
- Module contents
- anacreonlib.types.request_datatypes module
AbortAttackAbortAttackRequestAlterImprovementAlterImprovementRequestAnacreonApiRequestAttackAttackRequestAuthenticationRequestBattlePlanBuyItemBuyItemRequestDeployFleetDeployFleetRequestDesignateWorldDesignateWorldRequestDisbandFleetDisbandFleetRequestGetTacticalGetTacticalRequestLaunchJumpMissileLaunchJumpMissileRequestRenameObjectRenameObjectRequestSellFleetSellFleetRequestSendMessageSendMessageRequestSerializableDataclassSetFleetDestinationSetFleetDestinationRequestSetHistoryReadSetHistoryReadRequestSetIndustryAllocSetIndustryAllocRequestSetProductAllocSetProductAllocRequestSetTradeRouteSetTradeRouteRequestStopTradeRouteStopTradeRouteRequestTacticalOrderTacticalOrderRequestTacticalOrderTypeTradeRouteTypesTransferFleetTransferFleetRequest
- anacreonlib.types.response_datatypes module
AnacreonObjectAnacreonObjectWithIdAuthenticationResponseBattlePlanDetailsBattlePlanObjectDestroyedSpaceObjectExplorationGridFleetHistoryHistoryElementMesophonTraitNebulaTypeNewsOwnSovereignOwnSovereign.admin_rangeOwnSovereign.capital_idOwnSovereign.doctrineOwnSovereign.exploration_gridOwnSovereign.founded_onOwnSovereign.fundsOwnSovereign.idOwnSovereign.imperial_mightOwnSovereign.model_computed_fieldsOwnSovereign.model_configOwnSovereign.model_fieldsOwnSovereign.nameOwnSovereign.object_classOwnSovereign.relationshipOwnSovereign.secession_chanceOwnSovereign.statsOwnSovereign.territoryOwnSovereign.traits
OwnedWorldOwnedWorld.base_consumptionOwnedWorld.battle_planOwnedWorld.cultureOwnedWorld.designationOwnedWorld.efficiencyOwnedWorld.idOwnedWorld.model_computed_fieldsOwnedWorld.model_configOwnedWorld.model_fieldsOwnedWorld.nameOwnedWorld.near_obj_idsOwnedWorld.newsOwnedWorld.object_classOwnedWorld.orbitOwnedWorld.populationOwnedWorld.posOwnedWorld.regionOwnedWorld.resourcesOwnedWorld.rev_indexOwnedWorld.sovereign_idOwnedWorld.target_populationOwnedWorld.target_tech_levelOwnedWorld.tech_levelOwnedWorld.trade_route_maxOwnedWorld.trade_routesOwnedWorld.traitsOwnedWorld.world_class
RebellionRegionObjectRegionShapeReigningSovereignReigningSovereign.capital_idReigningSovereign.doctrineReigningSovereign.founded_onReigningSovereign.idReigningSovereign.imperial_mightReigningSovereign.model_computed_fieldsReigningSovereign.model_configReigningSovereign.model_fieldsReigningSovereign.nameReigningSovereign.object_classReigningSovereign.relationshipReigningSovereign.statsReigningSovereign.territoryReigningSovereign.traits
RelationshipRevIndexSelectionSiegeSovereignSovereignActionsSovereignRelationshipSovereignStatsTradeRouteTraitUpdateObjectWorldWorld.battle_planWorld.cultureWorld.designationWorld.efficiencyWorld.idWorld.model_computed_fieldsWorld.model_configWorld.model_fieldsWorld.nameWorld.near_obj_idsWorld.object_classWorld.orbitWorld.populationWorld.posWorld.regionWorld.resource_dictWorld.resourcesWorld.rev_indexWorld.sovereign_idWorld.squashed_trait_dictWorld.target_populationWorld.target_tech_levelWorld.tech_levelWorld.trade_route_partnersWorld.trade_routesWorld.traitsWorld.world_class
- anacreonlib.types.scenario_info_datatypes module
CategoryCategory.BUREAU_OF_TRADECategory.COMMODITYCategory.CULTURECategory.DESIGNATIONCategory.DOCTRINECategory.FEATURECategory.FIXED_UNITCategory.GROUND_UNITCategory.IMPROVEMENTCategory.INDUSTRYCategory.LAM_UNITCategory.MANEUVERING_UNITCategory.ORBITAL_UNITCategory.REBELLIONCategory.WORLD_CLASS
RoleRole.ACADEMYRole.ACADEMY_INDUSTRYRole.ADMINISTRATIONRole.CITADELRole.CITADEL_INDUSTRYRole.COMPONENT_INDUSTRYRole.CONSUMER_GOODS_INDUSTRYRole.ENERGY_INDUSTRYRole.FOUNDATIONRole.GROUND_DEFENSE_INDUSTRYRole.IMPERIAL_CAPITALRole.LIFE_SUPPORTRole.ORBITAL_DEFENSE_INDUSTRYRole.RAW_MATERIAL_INDUSTRYRole.SECTOR_CAPITALRole.SHIPYARDRole.SHIPYARD_INDUSTRYRole.SPACEPORTRole.TECH_ADVANCERole.TRADING_HUBRole.UNIVERSITY
ScenarioInfoScenarioInfoClassScenarioInfoElementScenarioInfoElement.attack_valueScenarioInfoElement.background_colorScenarioInfoElement.background_imageScenarioInfoElement.background_image_low_detailScenarioInfoElement.background_image_tacticalScenarioInfoElement.build_exclusionsScenarioInfoElement.build_requirementsScenarioInfoElement.build_timeScenarioInfoElement.build_upgradeScenarioInfoElement.can_landScenarioInfoElement.capital_industryScenarioInfoElement.capital_typeScenarioInfoElement.cargo_spaceScenarioInfoElement.categoryScenarioInfoElement.descriptionScenarioInfoElement.designation_onlyScenarioInfoElement.exclusionsScenarioInfoElement.exportsScenarioInfoElement.ftlScenarioInfoElement.hiddenScenarioInfoElement.idScenarioInfoElement.image_labelScenarioInfoElement.image_largeScenarioInfoElement.image_mediumScenarioInfoElement.image_smallScenarioInfoElement.inherit_fromScenarioInfoElement.is_cargoScenarioInfoElement.is_jump_beaconScenarioInfoElement.map_feature_sizeScenarioInfoElement.map_sizeScenarioInfoElement.massScenarioInfoElement.max_tech_levelScenarioInfoElement.min_tech_levelScenarioInfoElement.model_computed_fieldsScenarioInfoElement.model_configScenarioInfoElement.model_fieldsScenarioInfoElement.nameScenarioInfoElement.name_descScenarioInfoElement.npe_onlyScenarioInfoElement.player_allocScenarioInfoElement.player_product_allocScenarioInfoElement.primary_industryScenarioInfoElement.requirementsScenarioInfoElement.roleScenarioInfoElement.scenario_info_classScenarioInfoElement.short_nameScenarioInfoElement.statsScenarioInfoElement.tech_level_advanceScenarioInfoElement.unid
UserInfo
- anacreonlib.types.type_hints module