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
a new storage_var "cannot_travel"
2 new external functions "allow_travel" and "forbid_travel"
1 new internal function "assert_can_travel"
refactoring of "travel" to include "assert_can_travel"
✅ Since all items default to cannot_travel = false by default, adding this feature would not have any breaking changes
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