Skip to content

Commit

Permalink
better formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
DigiDuncan committed Dec 8, 2023
1 parent 4f88010 commit 3f19ed1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 19 deletions.
6 changes: 3 additions & 3 deletions sizebot/cogs/quake.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ async def earthquake(self, ctx, quake_type: typing.Optional[QuakeType] = "step",
else:
raise UserMessedUpException(f"{quake_type} is not a valid quake type.")
mag = joules_to_mag(joules)
e_type = mag_to_name(mag).title().replace('X', 'x')
e_type = mag_to_name(mag)
rad = mag_to_radius(mag)
print_mag = max(mag, Decimal(0.0))
if rad < EARTH_RAD:
Expand Down Expand Up @@ -104,7 +104,7 @@ async def quakewalk(self, ctx, dist: SV, user: typing.Union[discord.Member, Fake
return_string = (
f"{userdata.nickname} is {userdata.height:,.3mu} tall, and weighs {userdata.weight:,.3mu}.\n"
f"Walking {dist:,.1mu}, they would take **{steps:,} steps**, each causing a **Magnitude {small_mag} earthquake.** ({small_type})\n"
f"That's equivalent to **one Magnitude {big_mag} earthquake**. ({big_type})\n"
f"That's equivalent to **one Magnitude {big_mag} earthquake**. ({big_type})"
)

await ctx.send(return_string)
Expand Down Expand Up @@ -132,7 +132,7 @@ async def quaketype(self, ctx, s: str):
return_string = (
f"{userdata.nickname} is {userdata.height:,.3mu} tall, and weighs {userdata.weight:,.3mu}.\n"
f"Typing {steps} characters, {userdata.nickname} caused **{steps:,} Magnitude {small_mag} earthquakes.** ({small_type})\n"
f"That's equivalent to **one Magnitude {big_mag} earthquake**. ({big_type})\n"
f"That's equivalent to **one Magnitude {big_mag} earthquake**. ({big_type})"
)

await ctx.send(return_string)
Expand Down
33 changes: 17 additions & 16 deletions sizebot/lib/quake.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,41 +25,42 @@ def mag_to_radius(mag: float) -> SV:

def mag_to_name(mag: float) -> str:
if mag < 1: # 0 - 1
return "no"
r = "no quake"
elif mag < 3: # 1 - 3
return "unnoticeable"
r = "unnoticeable"
elif mag < 4: # 3 - 4
return "minor"
r = "minor"
elif mag < 5: # 4 - 5
return "light"
r = "light"
elif mag < 6: # 5 - 6
return "moderate"
r = "moderate"
elif mag < 7: # 6 - 7
return "strong"
r = "strong"
elif mag < 8: # 7 - 8
return "major"
r = "major"
elif mag < 9: # 8 - 9
return "great"
r = "great"
elif mag < 10: # 9 - 10
return "extreme"
r = "extreme"
elif mag < 13: # 10 - 13 [at this point I'm making s*** up]
return "unprecedented"
r = "unprecedented"
elif mag < 21: # 13 - 21 [I did do research tho, I didn't just pull this out of my butt]
return "apocalyptic"
r = "apocalyptic"
elif mag < 22: # 21 - 23
return "earth-cracking"
r = "earth-cracking"
elif mag < 25: # 23 - 25
d = 10 ** (mag - 22)
return f"earth-crumbling x{d:,.0f}"
r = f"earth-crumbling x{d:,.0f}"
elif mag < 32: # 25 - 32
d = 10 ** (mag - 25)
return f"sun-shattering x{d:,.0f}"
r = f"sun-shattering x{d:,.0f}"
elif mag < 63: # 32 - 63
d = 10 ** (mag - 32)
return f"galaxy-collapsing x{d:,.0f}"
r = f"galaxy-collapsing x{d:,.0f}"
else: # 63+
d = 10 ** (mag - 63)
return f"universe-ending x{d:,.0f}"
r = f"universe-ending x{d:,.0f}"
return r.title().replace('X', 'x')

def scale_to_joules(user: User, g: float, factor: float) -> Decimal:
return (Decimal(user.weight / 1000) / 2) * (Decimal(g) * Decimal(user.scale)) * Decimal(factor)
Expand Down

0 comments on commit 3f19ed1

Please sign in to comment.