Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mafia: Refactor plugin to stop misusing the playerTable #10200

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

HoeenCoder
Copy link
Member

This is going to be a large refactor with several commits, I'm PRing this in draft form to allow reviews as I complete portions of the refactor.

The overall goal is to stop directly accessing, iterating over, and modifying the playerTable from RoomGame which is causing all sorts of issues for mafia players.

Expect this to take a while to complete.

Unbeknownst to me when I wrote this plugin, playerTable is not a source of truth for who is in the game or not.
With this commit, I'm making it a policy for the mafia plugin to never directly read or mutate from the playerTable.

As an alternative, RoomGame#players is an array of players that can be accessed, and a Mafia#getPlayer(ID) method was added for ease of getting a specific player.
…nt from remaining players.

Some playerTable references were missed and removed in this commit.

RoomGame#playerCount will no longer reflect the number of un-eliminated players as players in a Mafia game can be revived and are not removed from the game until it ends or they sub out.
Instead, we will not use the Mafia#getRemainingPlayers() method to get a array of remaining players and check its length for the uneliminated player count.
@HoeenCoder HoeenCoder force-pushed the mafia-refactor branch 2 times, most recently from e61724c to a6084c9 Compare April 3, 2024 01:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant