beyond-all-reason / teiserver

Middleware server for online gaming
https://www.beyondallreason.info/
MIT License
57 stars 53 forks source link

Add command to initiate a vote for boss-restricted $-commands. #365

Closed DeviousNull closed 3 months ago

DeviousNull commented 3 months ago

Note: This PR should be considered a proof-of-concept/work-in-progress, and is submitted to request feedback/review. This is the first non-trivial Teiserver change that I've written, and I am not experienced with Elixir; so I'm not confident that I'm following the idiomatic patterns for the language.

Currently, a boss is often democratically elected in order to make a relatively-minor settings change, rather than for lobby management reasons. However, this is not-uncommonly subject to abuse; a player may lie (or just not tell the whole truth) to be voted as boss, and then they may take actions other than what the rest of the lobby expects.

This PR seeks to provide an alternative way for a democratic lobby to change certain settings, without electing a boss. It does so by making the following changes:

The general flow of these commands is as follows:

  1. A player runs a $cv command to change a setting. For example: $cv minratinglevel 1
  2. Over the next 30 seconds, players may say "$y" or "$n" to place their votes
  3. After 30 seconds, if the number of $y votes is higher than the number of $n votes, then the command executes as if the Coordinator had run it.

Some restrictions have been created for the above commands:

The following commands are currently whitelisted for voting:

The patch was tested in my local dev environment, but I plan to do additional polishing/testing. I am submitting this PR now for early feedback, particularly regarding any preferred ways to implement this feature, so that less work is wasted if a change in approach is needed.

DeviousNull commented 3 months ago

Example screenshot of what the voting process looks like: 2024-07-19 16_30_30

DeviousNull commented 3 months ago

Currently planned additions:

jauggy commented 3 months ago

If you want to make these commands voteable similar to the other SPADS commands, have a look at Yaribz response to my question: https://discord.com/channels/549281623154229250/564591092360675328/1261943858514624605 He linked some tutorials. Might be useful. But it would require writing some python.

DeviousNull commented 3 months ago

That's an excellent reference, thank you. I'll look into a SPADS-plugin-based implementation; I expect it will provide a more user-friendly system.

L-e-x-o-n commented 3 months ago

As @jauggy said, doing it like SPADS commands allows better UI. I think @Beherith is already working on it and got some commands done.

DeviousNull commented 3 months ago

I've just created a PR for a SPADS-based implementation, and yes it is much prettier than this PR was: https://github.com/beyond-all-reason/spads_config_bar/pull/134

I'll go ahead and close this one now. Thanks, all!