Tíquete #42681

Lua: basic city edit API

: 2021-07-31 00:50 Última Atualização: 2022-04-09 07:12

Relator:
Dono:
(Nenhum)
Estado:
Aberto
Componente:
Marcos:
Prioridade:
5 - Medium
Gravidade:
5 - Medium
Resolução:
Nenhum
Arquivo:
Nenhum

Details

Sub-task of #42501. Provide the following missing methods for cities:

  • bool :rename(string name) -- sets city name if it's allowed by size and symbols
  • int :add_size(int amount, Player nationality = NULL, string reason = NULL) -- changes size and returns the resulting size that is clipped by 0 (destroys city) and MAX_CITY_SIZE. nationality is in effect only for growing (at least). if reason is not nil, calls the signal "city_size_change" with this reason.
  • bool :remove_building(Building_Type building || int building_id || string building_rule_name) -- removed wonders are marked as destroyed. Note: edithand.c does not dispatch info about removed wonders, maybe both should?
  • bool :build_building(Building_Type building || int building_id || string building_rule_name) -- if an existing wonder (great or small) is built, it is removed from its previous location. Info is sent around.
  • int :give_food(int amount) -- adds an amount of food and returns resulting food stock that is clipped from 0 to current granary size
  • int :give_shields(int amount, string stype = NULL) -- adds amount of shields, returns current shield stock that is limited with 0 from below. stype may be NULL (change only basic shields, any future change in production target within city turn resets this value - current edithand.c effect, is it good?), "before_change" (also change this counter), "disband", "caravan" (changes corresponding accumulators like a unit was disbanded or a caravan helped a wonder this turn) or "last_turn" (like a surplus was bigger at this amount).

In common Lua interface, we should better control the stocks of the city for the aforementioned functions, add city properties:

  • int .food_stock
  • int .shield_stock
  • int .before_change_shields
  • int .caravan_shields
  • int .disbanded_shields
  • int .last_turn_shields
  • lua_Object .production -- Building_Type or Unit_Type
  • lua_Object .changed_from -- Building_Type or Unit_Type
  • maybe also int :change_penalty(lua_Object to_what = 0) --argument defaults to current production

Ticket History (3/3 Histories)

2021-07-31 00:50 Updated by: ihnatus
  • New Ticket "Lua: basic city edit API" created
2021-07-31 00:51 Updated by: ihnatus
2022-04-09 07:12 Updated by: cazfi
Comentário

There's #44230 about changing city size.

Attachment File List

No attachments

Editar

You are not logged in. I you are not logged in, your comment will be treated as an anonymous post. » Login