> For the complete documentation index, see [llms.txt](https://book.denismakhortov.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://book.denismakhortov.com/ru/server/game_data.md).

# Game Data

game\_data - это глобальная таблица со всеми данными о текущей игре. Вы можете напрямую работать с ней, чтобы менять поведение игры на сервере.

## Как узнать, что она содержит

Узнать содержимое любой таблицы можно, используя встроенную функцию `debug_log(game_data)` результат она запишет в файл log в корень сервера

## Советы по изменению

Старайтесь не изменять этот файл самостоятельно, а использовать готовые модули. Например, если вы хотите, чтобы две страны начали воевать друг с другом, то подключите в начале плагина модуль relations (отношения между странами)

```
local relations = require "core.relations"
```

А в самом коде плагина в нужный момент вызовите

```
relations.register_war(land1, land2) 
```

## Содержание game\_data

Здесь не будет перечисляться все содержание, так как оно очень большое. Только основное, что может пригодится чаще, чем другое

| поле       | краткое описание         |
| ---------- | ------------------------ |
| difficulty | уровень сложности        |
| queue      | последовательность ходов |
| step       | текущий ход              |
| lands      | страны                   |
| provinces  | провинции                |

**Данные страны**

Данные страны хранятся в `game_data.lands[land_id]`, где land\_id - ид страны (не название, а именно id)

Основное, неполное содержание этой таблицы:

| поле     | краткое описание          |
| -------- | ------------------------- |
| ideology | идеология                 |
| money    | число денег               |
| economy  | данные о доходах/расходах |
| allies   | союзники                  |
| enemies  | враги                     |

**Данные провинции**

Данные провинции хранятся в `game_data.provinces[province]`, где province - ид провинции

Содержание этой таблицы:

| поле  | краткое описание                                                                  |
| ----- | --------------------------------------------------------------------------------- |
| water | является ли водной (true/false)                                                   |
| o     | ид страны, которая ей владеет                                                     |
| p     | население                                                                         |
| a     | таблица с данными об армии в этой провинции (key - id страны, val - число армии)  |
| l\_a  | нанимаемая в данный момент армия, которая будет доступна на след ход              |
| r     | таблица с ресурсами (как заполнять, можно посмотреть в файле fill\_resources.lua) |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://book.denismakhortov.com/ru/server/game_data.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
