Project:Lynching

Redesign notes for chk_decision:

Statuses
Anything that adjusts the number, type, or weight of votes should be a status and is defined before chk_decision is ever called
 * influence is handled via the influence status
 * impatience and pacifism are handled via the votes status
 * narcolepsy, gunner, sick, and priest consecrating are handled via the absent status

The purpose of this is to remove dependencies between event listeners, so that we can eliminate priorities on all lynch-related events. By having statuses defined, our logic can fully determine who would normally be lynched and then fire an event to let listeners modify that. This lets execution flow through the lynch code once rather than having recursion whenever something needs to do something fancy

Code Flow
The lynch code goes through the following steps in order whenever chk_decision is called (note that statuses are already defined at beginning of day and not reflected here). All event names are subject to change to something more sensible, unless they reference cats 😺.
 * 1) Fire the lynch_behavior event, which lets listeners change how many people should be voted today, whether or not ties cause all tied players to be voted, and whether or not a vote should be forced this execution. Preventing default on the event has no effect.
 * 2) Given our lynch behavior, run through the voting logic to determine who should be lynched by performing the following steps in order.
 * 3) If there is a majority vote on someone, select that person as the vote target and exit.
 * 4) If 50% or more of the village has chosen to abstain and abstaining is enabled, select that the village abstains and exit.
 * 5) If a vote is not being forced and nothing was selected in the above 2 steps, exit.
 * 6) If there is a plurality of votes on a single person, select that person as the vote target and exit.
 * 7) If the plurality of votes is a tie, check tie behavior. If we vote all tied players on ties, select all tied players as the vote targets. Otherwise, select that the village abstains and exit, regardless of whether or not abstaining is currently enabled. As a special case, if every currently-alive player is tied and we vote all tied players on ties (i.e. we're about to kill everyone), select that the village abstains and exit, regardless of whether or not abstaining is currently enabled.
 * 8) If nothing was selected in the previous step, exit without performing a lynch or ending day.
 * 9) If the village has selected to abstain, fire the chk_decision_abstain event, mark that an abstention happened, handle the abstention, and end day. Preventing default on the event has no effect.
 * 10) If the village has selected to lynch people, let N be the number of people selected to be lynched and add it to a tracking variable of how many people were lynched today. Fire the chk_decision_lynch event once for each person. Preventing default on the event causes that person to not be lynched; this does not change the value of N. Display lynch messages and call add_dying for each player lynched.
 * 11) Run kill_players to kill all lynched players simultaneously.
 * 12) If the number of people lynched today is greater than or equal to the number of lynches set in the lynch_behavior event from step 1, end day.

lynch_behavior
Parameters:
 * evt
 * Event object


 * var
 * Game state object

Event Data Dict:
 * num_lynches (int)
 * Number of lynches that should happen today (default 1)


 * kill_ties (bool)
 * Whether or not all tied players are killed on a forced lynch (default False)


 * force (bool)
 * Whether or not a lynch should be forced (default True if chk_decision was called with timeout=True, and False otherwise)

Preventing default has no effect for this event.

chk_decision_lynch
Parameters:
 * evt
 * Event object


 * var
 * Game state object


 * target
 * User being lynched


 * votelist
 * List of the users voting target; order is the order in which !vote commands were issued for the user, earliest first

Event Data Dict: None

Preventing default causes nobody to be lynched this time.

chk_decision_abstain
Parameters:
 * evt
 * Event object


 * var
 * Game state object


 * votelist
 * List of the users voting to abstain; order is the order in which !abstain commands were issued, earliest first. This only lists people who abstained explicitly, it does not list those who never voted.

Event Data Dict: None

Preventing default has no effect for this event.