-
-
Notifications
You must be signed in to change notification settings - Fork 355
WIP: Allow toggling loving impostor #301
base: master
Are you sure you want to change the base?
Conversation
source/Patches/Roles/Lover.cs
Outdated
@@ -71,22 +71,22 @@ public static void Gen(List<PlayerControl> crewmates, List<PlayerControl> impost | |||
{ | |||
//System.Console.WriteLine("LOVER2"); | |||
if (crewmates.Count <= 0) return; | |||
if (crewmates.Count <= 1 && impostors.Count < 1) return; | |||
if (crewmates.Count <= 1 && (impostors.Count < 1 || !CustomGameOptions.AllowLovingImpostor)) return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (crewmates.Count <= 1 && (impostors.Count < 1 || !CustomGameOptions.AllowLovingImpostor)) return; | |
if (crewmates.Count <= 1 && (!CustomGameOptions.AllowLovingImpostor || impostors.Count < 1)) return; |
if you want to test this, build the project (either using (it would previously be automatically moved to an |
source/Patches/Roles/Lover.cs
Outdated
@@ -71,22 +71,22 @@ public static void Gen(List<PlayerControl> crewmates, List<PlayerControl> impost | |||
{ | |||
//System.Console.WriteLine("LOVER2"); | |||
if (crewmates.Count <= 0) return; | |||
if (crewmates.Count <= 1 && impostors.Count < 1) return; | |||
if (crewmates.Count <= 1 && (impostors.Count < 1 || !CustomGameOptions.AllowLovingImpostor)) return; | |||
|
|||
//System.Console.WriteLine("LOVER3"); | |||
var b = Random.RandomRangeInt(0, 3); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
slightly out of scope i know, but could b
be changed to just be the lovingImpostor
boolean?
seems it was originally just meant to be 1
or 0
indicating if a loving impostor should be generated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to, but it urns out at 1am after like 5 hours of Among Us, my brain couldn't figure out how. I've attempted to rewrite this whole section to not reassign stuff to the same variable.
I haven't touched C# in a while; I've been doing Java for the past 7 years. I also prefer a more verbose, more risk averse coding style. So I avoided If you'd prefer another coding style, or if this isn't idiomatic C#, feel free to ask for changes. |
@@ -9,24 +9,31 @@ namespace TownOfUs.Roles | |||
{ | |||
public class Lover : Role | |||
{ | |||
public Lover(PlayerControl player, int num, bool loverImpostor) : base(player) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The convention where num == 2
for impostor seemed really brittle to me. So I changed it to always specify.
} | ||
|
||
public Lover OtherLover { get; set; } | ||
public bool LoveCoupleWins { get; set; } | ||
public int Num { get; set; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I couldn't find where this was used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for the sake of consistency, should probably use var, and remove the docstring comments, but other than that LGTM
source/Patches/Roles/Lover.cs
Outdated
@@ -67,26 +74,29 @@ protected override string NameText(PlayerVoteArea player = null) | |||
return Player.name + "\n" + "Lover"; | |||
} | |||
|
|||
private static readonly int LOVING_IMPOSTOR_CHANCE = 25; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private static readonly int LOVING_IMPOSTOR_CHANCE = 25; | |
private const int LOVING_IMPOSTOR_CHANCE = 25; |
source/Patches/Roles/Lover.cs
Outdated
writer.Write(b); | ||
var lover1 = new Lover(player1, 1, b == 0); | ||
var lover2 = new Lover(player2, 2, b == 0); | ||
writer.Write(lovingImpostor ? 0 : 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
theres a writer.WriteBoolean
method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think it would also be nice to have an option to change the chance of a loving impostor (possibly replacing the toggle?)
@@ -284,6 +285,8 @@ public static void GenerateAll() | |||
Lovers = | |||
new CustomHeaderOption(num++, "<color=#FF66CCFF>Lovers</color>"); | |||
BothLoversDie = new CustomToggleOption(num++, "Both Lovers Die"); | |||
LovingImpostorOn = new CustomNumberOption(num++, "Allow Loving Impostor",25f, 0f, 100f, 10f, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LovingImpostorOn = new CustomNumberOption(num++, "Allow Loving Impostor",25f, 0f, 100f, 10f, | |
LovingImpostorOn = new CustomNumberOption(num++, "Loving Impostor Chance", 25f, 0f, 100f, 10f, |
var lovingImpostorEnabled = Random.RandomRangeInt(1, 101) <= CustomGameOptions.LovingImpostorOn; | ||
|
||
var canMakeCrewCrewLovers = crewmates.Count >= 2; | ||
var canMakeCrewImpostorLovers = crewmates.Count >= 1 && impostors.Count >= 2 && lovingImpostorEnabled; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var canMakeCrewImpostorLovers = crewmates.Count >= 1 && impostors.Count >= 2 && lovingImpostorEnabled; | |
var canMakeCrewImpostorLovers = crewmates.Count >= 1 && impostors.Count >= 1 && lovingImpostorEnabled; |
there would only need to be one impostor free
@@ -338,12 +338,12 @@ public static void Postfix([HarmonyArgument(0)] byte callId, [HarmonyArgument(1) | |||
case CustomRPC.SetCouple: | |||
var id = reader.ReadByte(); | |||
var id2 = reader.ReadByte(); | |||
var b1 = reader.ReadByte(); | |||
bool lovingImpostor = reader.ReadByte() == 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bool lovingImpostor = reader.ReadByte() == 0; | |
var lovingImpostor = reader.ReadByte() == 0; |
|
||
### Game Options | ||
| Name | Description | Type | Default | | ||
|----------|:-------------:|:------:|:------:| | ||
| Lovers | The percentage probability of the Lovers appearing | Percentage | 0% | | ||
| Both Lovers Die | Whether the other Lover automatically dies if the other does | Toggle | True | | ||
| Allow Loving Impostor | Whether one of the Lovers can be an Impostor | Percentage | 25% | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Allow Loving Impostor | Whether one of the Lovers can be an Impostor | Percentage | 25% | | |
| Loving Impostor Chance | The percentage probability of a Loving Impostor appearing | Percentage | 25% | |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This is just a first draft. I'm not able to test it yet nor have I figured out how to add unit tests. If someone can point me toward contributing guidelines, I'm happy to flesh this out more fully.