m3talstorm / foe-bot

:robot: A simple bot to automate the main functions of Forge of Empires (FoE)
MIT License
45 stars 15 forks source link

Feature request: Train troops #11

Closed LordMike closed 5 years ago

LordMike commented 6 years ago

I've tried training troops and watching the API. This is what I got:

Note, I believe the data is [buildingId, slotId] where slotId is 0-indexed from the left.

[{
        "requestId": 11,
        "__class__": "ServerRequest",
        "requestMethod": "startProduction",
        "requestData": [35, 0],
        "requestClass": "CityProductionService",
        "voClassName": "ServerRequest"
    }
]

Response:

[{
        "responseData": true,
        "requestClass": "MessageService",
        "requestMethod": "newMessage",
        "requestId": 11,
        "__class__": "ServerResponse"
    }, {
        .. snip ..
        "requestClass": "TimeService",
        "requestMethod": "updateTime",
        "requestId": 11,
        "__class__": "ServerResponse"
    }, {
        .. snip ..
        "requestClass": "ResourceService",
        "requestMethod": "getPlayerResources",
        "requestId": 11,
        "__class__": "ServerResponse"
    }, {
        .. snip ..
        "requestClass": "ResourceService",
        "requestMethod": "getPlayerAutoRefills",
        "requestId": 11,
        "__class__": "ServerResponse"
    }, {
        "responseData": {
            "updatedEntities": [{
                    "id": 35,
                    "player_id": 7393223,
                    "cityentity_id": "M_BronzeAge_JavelinerBarracks",
                    "type": "military",
                    "x": 20,
                    "y": 16,
                    "connected": 1,
                    "state": {
                        "current_product": {
                            "unit_type_id": "javeliner",
                            "unit_class": "light_melee",
                            "amount": 1,
                            "becomes_stale": false,
                            "train_costs": {
                                "money": 25,
                                "supplies": 25,
                                "goods": [],
                                "__class__": "CityResource"
                            },
                            "time_to_heal": 30,
                            "time_to_train": 20,
                            "requirements": {
                                "resources": {
                                    "money": 25,
                                    "supplies": 25,
                                    "goods": [],
                                    "__class__": "CityResource"
                                },
                                "__class__": "CityEntityRequirements"
                            },
                            "name": "Spearfighter",
                            "production_time": 20,
                            "asset_name": "imperialknight",
                            "production_option": 1,
                            "__class__": "CityEntityMilitaryProduct"
                        },
                        "boosted": false,
                        "is_motivated": false,
                        "next_state_transition_in": 20,
                        "__class__": "ProducingState"
                    },
                    "__class__": "CityMapEntity"
                }
            ],
            "militaryProducts": [],
            "__class__": "CityProductionResult"
        },
        "requestClass": "CityProductionService",
        "requestMethod": "startProduction",
        "requestId": 11,
        "__class__": "ServerResponse"
    }
]
LordMike commented 6 years ago

I'm unsure how to detect if it's possible to build units. I can see that StartupService comes back with all data, including all buildings (part of map data), where the state of my barracks is e.g. Idle.

Can't really locate the count of troops or similar.

diogofacin commented 6 years ago

Count of troops shows upon the response of ArmyUnitDataService . getArmyInfo It's equivalent to open the Army screen or Campaign map