BibliothecaDAO / realms-contracts

Realms Monorepo for Ethereum contracts and Starknet contracts.
https://bibliothecadao.xyz/
MIT License
87 stars 33 forks source link

feat Allow approved modules to forbid travel #301

Closed aymericdelab closed 1 year ago

aymericdelab commented 1 year ago

Allow approved modules to restrain an item from travelling

Issue

I am currently working on the Bastion module, which needs to track the number of armies that are defending a bastion (a location on the map). Armies can travel in and out of the bastion using "travel" but they have to actively call a "defend" entrypoint to become a defender. This allows the Bastion Module to track the number of defenders of a bastion for example. Once an army becomes a defender, they should not be able to travel out of the bastion without removing themselves from the defense first. At the moment, the travel function allows any item to travel without constraint except when it is a defending army of a realm.

Solution

What I propose is a general solution that adds a new storage_var in the Travel module called "cannot_travel", which tracks if items are forbidden to travel. By default all the items can travel, and approved modules can call a function to forbid travel or allow travel. A check is then made everytime we travel that the item is allowed to travel.

Changes

✅ Since all items default to cannot_travel = false by default, adding this feature would not have any breaking changes