For this issue, I will only add the following features:
Military access (and trespassing)
Toggle to engage in battles
Presets ("Allied", "Neutral" and "At war")
Diplomatic actions
Actions requiring consent from the other country
A certain number of turns having to pass before you can use a diplomatic action
List of things to do:
Add the rules
[x] Default preset (Presets disabled; Allied; Neutral; At War)
[x] All countries start with a random relationship preset (bool, false by default)
[x] Relationship default: grant military access (bool, false by default)
[x] Can manually grant military access (bool, false by default)
[x] Can manually revoke military access (bool, false by default)
[x] Can ask for military access (bool, false by default)
[x] Automatically grant military access to whoever grants military access to you (bool, false by default)
[x] Automatically revoke military access when fighting (bool, true by default)
[x] Option when army loses military access (Ignore; Delete; Teleport to valid location)
[x] Relationship default: is trespassing (bool, true by default)
[x] Can manually turn on (bool, false by default)
[x] Can manually turn off (bool, false by default)
[x] Can ask to stop trespassing (bool, false by default)
[x] Automatically fight trespassers (bool, true by default)
[x] Relationship default: is fighting (bool, true by default)
[x] Can manually turn on (bool, false by default)
[x] Can manually turn off (bool, false by default)
[x] Can ask to stop fighting (bool, false by default)
[x] Automatically fight back (bool, true by default)
Create code architecture
[x] Create class DiplomacyRelationships, add it to Country
[x] Create class DiplomacyRelationship
[x] Create class DiplomacyPreset, add it to DiplomacyRelationship
[x] The preset data overrides the relationship's data
[x] Create class DiplomacyAction, add lists of it to DiplomacyPreset and DiplomacyRelationship
[x] The game has built-in diplomatic actions
[x] There's a function that performs an action
[x] Create an Action subclass for performing diplomatic actions
Implement the "available after turns" feature for diplomatic actions
[x] Remember the turn on which each action became available in some data structure
[x] Set the turn on which the action became available, when it does
[x] Correctly tell if an action can be performed
[x] Prevent an action from being performed if it can't be performed
Implement the "needs consent" feature for diplomatic actions
[x] A country now has a GameNotifications, a list of GameNotification
[x] There's a function to add a new notification to a country, passing a GameNotification object
[x] GameNotification has information such as the country who created the notification, and the turn on which is was created
[x] GameNotification has a list of outcomes contained inside
[x] An outcome is represented by a callable function and a name (e.g. "Accept", does stuff)
[x] You can select one of the notification's outcomes with something like notification.select_outcome()
[x] Selecting an outcome applies its associated function
[x] Selecting an outcome removes the notification from the list (hint: use a signal)
[x] An invalid outcome index does nothing and dismisses the notification; furthermore, an invalid positive outcome index pushes an error
[x] Alternatively, you can dismiss/ignore a notification using something like notification.dismiss()
[x] Dismissing removes the notification from the list
[x] Notifications are automatically dismissed after three turns
[x] Diplomatic actions that require consent do not apply their outcome immediately
[x] These actions now create a new notification for the recipient country
[x] The notification has two outcomes: "Accept", which applies the action's outcome, and "Decline", which dismisses the notification
[x] The notification is added to the recipient country's notifications
[x] There's a new Action subclass for selecting an outcome for a notification
[x] The action stores the notification's index (int) and the outcome's index (int)
[x] An action with an invalid notification index has no effect
[x] It's possible to obtain a specific notification by passing an index; an invalid index returns a new empty notification
[x] A country cannot handle another country's notifications
[x] For each action, and for each country, you can only send one request per turn
[x] Notifications are immediately dismissed when they are no longer valid (e.g. you offer alliance but then you declare war)
Enforce military access and trespassing
[x] You can only move an army into another country's land if you have military access or if you're trespassing
[x] The visuals reflect this
[x] An army only takes control over a province if it's trespassing
Enforce options for what happens when an army loses military access
[x] Ignore: do nothing about it
[x] Delete: remove the army entirely
[x] Teleport to valid location: teleport the army to the nearest province it has access to, and make it unable to move again for this turn
[x] When there is more than one "nearest" province, prioritize the army's home territory
[x] Armies get merged after they teleport
[x] Consider this edge case. Country A has military access to country B, and puts an army in a province controlled by country B. Meanwhile, country C is at war with country B, but they are neutral towards country A. Country C moves into and takes control over the province. Country A's army is now located in country C, which it doesn't have military access to. In this edge case, military access loss behavior should trigger specifically for this army. More generally, the behavior should trigger whenever a province's owner country changes.
Enforce the battle engagement toggle
[x] Battles only occur when either country has "engage in combat" toggled on
Add country UI
[x] The colored rectangle in the top bar can be clicked on to open the country UI for the playing country
[x] It has different tints when hovering and when holding click
[x] This rectangle now also appears in the UI that appears when selecting a province
[x] It only appears there when the province has an owner country
[x] The playing country's relationship preset with the province owner is also shown, if applicable
[x] That rectangle is colored after the country in question; it opens the country UI for that country
[x] The UI shows information about the country: its name, money, and so on
[x] The UI contains a relationship UI for the relationship between that country and the playing country
[x] The relationship UI is not present if the country is the playing country
[x] The UI shows a list of all the other countries
[x] If relationship presets are enabled, next to each other country, it shows the country's preset with the other country
[x] Relationship presets have a color and the shown preset is colored after the preset (e.g. "Allied" will be green)
[x] Each country on the list can be clicked on to open a relationship UI
Add relationship UI
[x] The UI shows both country 1's relationship with country 2 and vice versa
[x] The UI shows the relationship preset, if they are enabled
[x] The UI shows all the data about the relationship
[x] The UI shows all the available diplomatic actions (when you're one of the two countries)
[x] It's clearly shown if you have to wait some number of turns before being able to perform a specific action
[x] It's clearly shown if you can't perform an action because you've already performed it this turn
[x] Clicking on a diplomatic action performs it, when applicable
[x] When a diplomatic action is performed, all the UIs update accordingly
Add UI for game notifications
[x] There's a UI that notifies the player when consent is asked for a diplomatic action
[x] There can be many such notifications at a time on screen: they are small and neatly arranged
[x] The notification UI is colored after the country that made the request
[x] Left clicking on a notification opens a new popup
[x] The popup allows you to either give consent, in which case the action is applied, or ignore the request
[x] Right clicking on a notification automatically ignores the request and removes the notification
Save and load
[x] Save country relationships
[x] Load country relationships
[x] Save a country's game notifications
[x] Load a country's game notifications
Networking
[x] Use the new Action subclasses
[x] Only users playing as the playing country see diplomatic action buttons
[x] Only users playing as the playing country can perform diplomatic actions
[x] Only users playing as the playing country see its notifications
[x] Only users playing as the playing country can handle its notifications
Alliance, peace, war, etc.
For this issue, I will only add the following features:
List of things to do:
Add the rules
Create code architecture
Implement the "available after turns" feature for diplomatic actions
Implement the "needs consent" feature for diplomatic actions
Enforce military access and trespassing
Enforce options for what happens when an army loses military access
Enforce the battle engagement toggle
Add country UI
Add relationship UI
Add UI for game notifications
Save and load
Networking