Skip to content

Commit

Permalink
Merge pull request #26 from Mikihero/dev
Browse files Browse the repository at this point in the history
Effect fixes
  • Loading branch information
Mikihero authored Oct 14, 2023
2 parents 04ab72c + ce7830e commit 866a6ee
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
1 change: 1 addition & 0 deletions BetterCoinflips/Configs/Translations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public class Translations : ITranslation
[Description("This message will be broadcast to both players.")]
public string InventorySwapMessage { get; set; } = "Your inventory was swapped with a random player.";
public string RandomTeleportMessage { get; set; } = "You were randomly teleported.";
public string RandomTeleportWarheadDetonatedMessage { get; set; } = "Warhead is detonated so you only got a candy.";
public string HandcuffMessage { get; set; } = "You were arrested for uhh commiting war crimes... or something.";
}
}
9 changes: 6 additions & 3 deletions BetterCoinflips/EventHandlers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public void OnCoinFlip(FlippingCoinEventArgs ev)
bool helper = false;
//check if player is on cooldown
bool flag = _cooldownDict.ContainsKey(ev.Player.RawUserId)
&& (DateTime.UtcNow - _cooldownDict[ev.Player.RawUserId]).TotalSeconds < Plugin.Instance.Config.CoinCooldown;
&& (DateTime.UtcNow - _cooldownDict[ev.Player.RawUserId]).TotalSeconds < Cfg.CoinCooldown;
if (flag)
{
ev.IsAllowed = false;
Expand Down Expand Up @@ -201,6 +201,7 @@ public void OnSpawningItem(SpawningItemEventArgs ev)
{
if (Cfg.DefaultCoinsAmount != 0 && ev.Pickup.Type == ItemType.Coin)
{
Log.Debug($"Removed a coin, coins left to remove {Cfg.DefaultCoinsAmount}");
ev.IsAllowed = false;
Cfg.DefaultCoinsAmount--;
}
Expand All @@ -209,14 +210,16 @@ public void OnSpawningItem(SpawningItemEventArgs ev)
//removing locker spawning coins and replacing the chosen item in SCP pedestals
public void OnFillingLocker(FillingLockerEventArgs ev)
{
if (ev.Pickup.Type == ItemType.Coin && Plugin.Instance.Config.DefaultCoinsAmount != 0)
if (ev.Pickup.Type == ItemType.Coin && Cfg.DefaultCoinsAmount != 0)
{
Log.Debug($"Removed a locker coin, coins left to remove {Cfg.DefaultCoinsAmount}");
ev.IsAllowed = false;
Plugin.Instance.Config.DefaultCoinsAmount--;
Cfg.DefaultCoinsAmount--;
}
else if (ev.Pickup.Type == Cfg.ItemToReplace.ElementAt(0).Key
&& Cfg.ItemToReplace.ElementAt(0).Value != 0)
{
Log.Debug($"Placed a coin, coins left to place: {Cfg.ItemToReplace.ElementAt(0).Value}. Replaced item: {ev.Pickup.Type}");
ev.IsAllowed = false;
Pickup.CreateAndSpawn(ItemType.Coin, ev.Pickup.Position, new Quaternion());
Cfg.ItemToReplace[Cfg.ItemToReplace.ElementAt(0).Key]--;
Expand Down
14 changes: 12 additions & 2 deletions BetterCoinflips/Types/CoinEffect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -450,8 +450,18 @@ public CoinFlipEffect(Action<Player> execute, string message)
//22
new CoinFlipEffect(player =>
{
player.RandomTeleport<Room>();
}, Translations.RandomTeleportMessage),
if (Warhead.IsDetonated)
{
Scp330 candy = (Scp330)Item.Create(ItemType.SCP330);
candy.AddCandy(InventorySystem.Items.Usables.Scp330.CandyKindID.Red);
candy.CreatePickup(player.Position);
}
else
{
player.RandomTeleport<Room>();
}

}, Warhead.IsDetonated ? Translations.RandomTeleportWarheadDetonatedMessage : Translations.RandomTeleportMessage),

//23
new CoinFlipEffect(player =>
Expand Down

0 comments on commit 866a6ee

Please sign in to comment.