Opened 8 years ago

Closed 8 years ago

Last modified 7 years ago

#3702 closed defect (fixed)

[PATCH] Lock-teams doesn't lock diplomacy

Reported by: elexis Owned by: elexis
Priority: Should Have Milestone: Alpha 20
Component: UI & Simulation Keywords: patch
Cc: Patch:

Description (last modified by elexis)

The lock-teams setting is currently quite useless. It forces you to be allied with your team members, but still allows changing the diplomacy of enemies to ally (i.e. backstabbing as you cooperate with the enemy).

Currently there is no way to change the teams anyway (you can only change diplomacy, i.e. ally/neutral/enemy, but you will always stay in the same team).

The lock-teams setting must be changed so that it actually enforces diplomacy-lockdown. ---

Also sending tributes to the enemy should be forbidden if locked-diplomacy is enabled, as there is no legitimate use in that situation I can think of. Sending tributes to the enemy is either a mistake or backstabbing/trolling.

Sending resources to the enemy should be allowed for diplomacy-free games though, as you might deal a peace-treaty against resources.

Attachments (4)

menu.js.patch (2.7 KB ) - added by Matthew Guttag 8 years ago.
lockedTeams.patch (4.7 KB ) - added by Matthew Guttag 8 years ago.
New patch removes for each loops from menu.js and completes the partialy implemented logic for team locking in Player.js
lockedTeams2.patch (4.6 KB ) - added by Matthew Guttag 8 years ago.
Corrected the patch to work with ceasefire
lockedTeams3.patch (15.1 KB ) - added by elexis 8 years ago.

Download all attachments as: .zip

Change History (17)

comment:1 by elexis, 8 years ago

Description: modified (diff)

comment:2 by elexis, 8 years ago

Keywords: simple added
Priority: Must HaveShould Have

comment:3 by Matthew Guttag, 8 years ago

Keywords: review patch added
Milestone: Alpha 20Alpha 21
Summary: Lock-teams doesn't lock diplomacy[PATCH] Lock-teams doesn't lock diplomacy

comment:4 by Matthew Guttag, 8 years ago

My patch stops users from changing diplomacy or tribute to players on other teams but at the same time continues to allow diplomacy with non-aligned players and when teams are not locked.

by Matthew Guttag, 8 years ago

Attachment: menu.js.patch added

comment:5 by Stan, 8 years ago

Keywords: review removed
Milestone: Alpha 21Alpha 20

For each is deprecated use for(in) or for(of) instead. In general let should be used unless you have a good reason for using var

Thanks for your work so far

comment:6 by elexis, 8 years ago

Also the checks should not only be client-side but also in the simulation. To accomplish that, checks need to be added in "diplomacy" and "attack-request" in g_Commands in Commands.js. This makes sure people can't change their gamecode to ignore your patch (since the player can't change the simulation code of the other players).

With regards to for-each use:

for (let column of ["TributeFood", "TributeWood", "TributeStone", "TributeMetal", "Ally", "Neutral", "Enemy"])
}}
Last edited 8 years ago by elexis (previous) (diff)

by Matthew Guttag, 8 years ago

Attachment: lockedTeams.patch added

New patch removes for each loops from menu.js and completes the partialy implemented logic for team locking in Player.js

comment:7 by elexis, 8 years ago

Keywords: review added; simple removed

comment:8 by historic_bruno, 8 years ago

It's not introduced by your patch, but please don't use let a, use a more descriptive variable name like in elexis's example :)

by Matthew Guttag, 8 years ago

Attachment: lockedTeams2.patch added

Corrected the patch to work with ceasefire

by elexis, 8 years ago

Attachment: lockedTeams3.patch added

comment:9 by elexis, 8 years ago

In 17818:

Diplomacy manager cleanup.
Move the diplomatic stance button initialization to a custom function.
Always hide the button if locked-teams is enabled, refs #3702.
Inline setDiplomacy.

comment:10 by elexis, 8 years ago

The GUI part has been committed.

Now a decision is needed on whether the simple changes and simplifications of the simulation in the patch above are acceptable, or whether we want to change the header of many functions in many files without a real use case just to move 2 early returns from Commands.js to Player.js and replace them with a boolean parameter.

If we decide for the latter, then we need to change 5 functions (SetTeams, SetAllies, SetNeutral, SetDiplomacy, SetDiplomacyIndex, possible others) in the Player component and most calls to it (trigger scripts like survival-of-the-fittest and other components like the Ceasefire manager and the Player initialization helper), since sometimes you want to force diplomacy changes from the simulation, sometimes you want to early return if ceasefire is active, sometimes an early return if teams are locked (other times both or neither). Rewrote that idea several times and still find it a bit pointless (maybe I need to give it another try).

The patch above allows all simulation components by default to change diplomacy, unless it was user-sent data from Commands.js.

comment:11 by elexis, 8 years ago

Owner: set to elexis
Resolution: fixed
Status: newclosed

In 17896:

Lock diplomacy for all players if the locked-teams setting is enabled, fixes #3702.
GUI fix in r17818, simulation fix here.

Remove quadruplicated code!
Check in Commands.js as this one handles user input.
Don't check in Player.js as the function should be versatile enough to change diplomacy from all components, even if teams are locked or ceasefire active.

comment:12 by elexis, 8 years ago

Keywords: review removed

comment:13 by elexis, 7 years ago

See IRC discussion with mimo on 2016-02-16 on the prohibition of sending enemies resources when teams are locked.

Note: See TracTickets for help on using tickets.