Skip to content

Commit

Permalink
add heartbeat to quake
Browse files Browse the repository at this point in the history
  • Loading branch information
DigiDuncan committed Dec 3, 2023
1 parent 5d12907 commit 76a9890
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
17 changes: 10 additions & 7 deletions sizebot/cogs/quake.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@

from sizebot.lib.constants import colors, emojis
from sizebot.lib.fakeplayer import FakePlayer
from sizebot.lib.quake import breath_joules, joules_to_mag, jump_joules, mag_to_name, mag_to_radius, poke_joules, step_joules, stomp_joules
from sizebot.lib.quake import breath_joules, heartbeat_joules, joules_to_mag, jump_joules, mag_to_name, mag_to_radius, poke_joules, step_joules, stomp_joules
from sizebot.lib.units import SV
from sizebot.lib.userdb import load_or_fake
from sizebot.lib.errors import UserMessedUpException

EARTH_RAD = Decimal(10_018_570)
UNI_RAD = Decimal(4.4E26)
QuakeType = typing.Literal["step", "stomp", "jump", "poke", "breath", "breathe"]
QuakeType = typing.Literal["step", "stomp", "jump", "poke", "breath", "breathe", "heartbeat"]

class QuakeCog(commands.Cog):
"""Quake commands."""
Expand All @@ -30,20 +30,23 @@ async def earthquake(self, ctx, quake_type: typing.Optional[QuakeType] = "step",
user = ctx.author
userdata = load_or_fake(user)
if quake_type == "step":
verb = "stepping"
verb = " stepping"
joules = step_joules(userdata)
elif quake_type == "stomp":
verb = "stomping"
verb = " stomping"
joules = stomp_joules(userdata)
elif quake_type == "jump":
verb = "jumping"
verb = " jumping"
joules = jump_joules(userdata)
elif quake_type == "poke":
verb = "poking"
verb = " poking"
joules = poke_joules(userdata)
elif quake_type == "breath" or quake_type == "breathe":
verb = "breathing"
verb = " breathing"
joules = breath_joules(userdata)
elif quake_type == "heartbeat":
verb = "'s heart beating"
joules = heartbeat_joules(userdata)
else:
raise UserMessedUpException(f"{quake_type} is not a valid quake type.")
mag = joules_to_mag(joules)
Expand Down
4 changes: 4 additions & 0 deletions sizebot/lib/quake.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

BREATH_JOULES = 0.025
POKE_JOULES = 8
HEARTBEAT_JOULES = 5.38E-9

def joules_to_mag(joules: float) -> Decimal:
# This might not be super accurate.
Expand Down Expand Up @@ -72,3 +73,6 @@ def breath_joules(user: User) -> Decimal:

def poke_joules(user: User) -> Decimal:
return Decimal(POKE_JOULES) * (user.scale ** 3)

def heartbeat_joules(user: User) -> Decimal:
return Decimal(HEARTBEAT_JOULES) * (user.scale ** 3)

0 comments on commit 76a9890

Please sign in to comment.