Skip to content

Commit

Permalink
add more quake types
Browse files Browse the repository at this point in the history
  • Loading branch information
DigiDuncan committed Dec 2, 2023
1 parent 5be33ed commit c485154
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
8 changes: 7 additions & 1 deletion sizebot/cogs/quake.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from sizebot.lib.constants import colors
from sizebot.lib.fakeplayer import FakePlayer
from sizebot.lib.quake import joules_to_mag, jump_joules, mag_to_name, mag_to_radius, step_joules, stomp_joules
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.units import SV
from sizebot.lib.userdb import load_or_fake
from sizebot.lib.errors import UserMessedUpException
Expand Down Expand Up @@ -37,6 +37,12 @@ async def earthquake(self, ctx, quake_type: typing.Optional[QuakeType] = "step",
elif quake_type == "jump":
verb = "jumping"
joules = jump_joules(userdata)
elif quake_type == "poke":
verb = "poking"
joules = poke_joules(userdata)
elif quake_type == "breath":
verb = "breathing"
joules = breath_joules(userdata)
else:
raise UserMessedUpException(f"{quake_type} is not a valid quake type.")
mag = joules_to_mag(joules)
Expand Down
9 changes: 9 additions & 0 deletions sizebot/lib/quake.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
STOMP_FACTOR = 0.5
JUMP_FACTOR = 1

BREATH_JOULES = 0.25
POKE_JOULES = 8

def joules_to_mag(joules: float) -> Decimal:
# This might not be super accurate.
return Decimal(2/3) * Decimal(math.log10(joules)) - Decimal(3.2)
Expand Down Expand Up @@ -63,3 +66,9 @@ def stomp_joules(user: User) -> int:

def jump_joules(user: User) -> int:
return scale_to_joules(user, G, JUMP_FACTOR)

def breath_joules(user: User) -> int:
return int(BREATH_JOULES * (user.scale ** 4))

def poke_joules(user: User) -> int:
return int(POKE_JOULES * (user.scale ** 4))

0 comments on commit c485154

Please sign in to comment.