Skip to content

Commit

Permalink
Random legend displays legend info, resolves #19
Browse files Browse the repository at this point in the history
  • Loading branch information
LevBernstein committed Nov 16, 2021
1 parent 6c7ef55 commit 5467e2f
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 22 deletions.
4 changes: 2 additions & 2 deletions Bot.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
""" Beardless Bot """
__version__ = "Full Release 1.6.8"
__version__ = "Full Release 1.6.9"

import asyncio
from random import choice, randint
Expand Down Expand Up @@ -362,7 +362,7 @@ async def cmdRohan(ctx, *args):

@bot.command(name="random")
async def cmdRandomBrawl(ctx, ranType="None", *args):
await ctx.send(embed=brawl.randomBrawl(ranType.lower()))
await ctx.send(embed=brawl.randomBrawl(ranType.lower(), brawlKey))


@bot.command(name="fact")
Expand Down
2 changes: 1 addition & 1 deletion README.MD
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Beardless Bot

### Full Release 1.6.8
### Full Release 1.6.9

A Discord bot supporting gambling (coin flips and blackjack),
a currency system, fun facts, and more.
Expand Down
15 changes: 8 additions & 7 deletions bb_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,13 +486,6 @@ def test_blackjack_startingHand():
)


def test_randomBrawl():
assert brawl.randomBrawl("legend").title == "Random Legend"
assert brawl.randomBrawl("weapon").title == "Random Weapon"
assert brawl.randomBrawl("invalidrandom").title == "Brawlhalla Randomizer"
assert brawl.randomBrawl("invalidrandom").title == "Brawlhalla Randomizer"


def test_info():
text = TestMessage("!info searchterm")
namedUser = TestUser("searchterm", roles=(TestRole(), TestRole()))
Expand Down Expand Up @@ -598,6 +591,14 @@ def test_animal():
# Tests for commands that require a Brawlhalla API key:


def test_randomBrawl():
assert brawl.randomBrawl("weapon").title == "Random Weapon"
assert brawl.randomBrawl("legend").title == "Random Legend"
assert len(brawl.randomBrawl("legend", brawlKey).fields) == 2
assert brawl.randomBrawl("invalidrandom").title == "Brawlhalla Randomizer"
assert brawl.randomBrawl("invalidrandom").title == "Brawlhalla Randomizer"


def test_fetchBrawlID():
assert brawl.fetchBrawlID(196354892208537600) == 7032472
assert not brawl.fetchBrawlID(654133911558946837)
Expand Down
13 changes: 7 additions & 6 deletions brawl.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def plural(t):
).format(target, h, plural(h), m, plural(m), s, plural(s))


def randomBrawl(ranType: str) -> discord.Embed:
def randomBrawl(ranType: str, key: str = None) -> discord.Embed:
if ranType in ("legend", "weapon"):
if ranType == "legend":
choices = tuple(
Expand All @@ -75,15 +75,16 @@ def randomBrawl(ranType: str) -> discord.Embed:
"Blasters",
"Axe"
)
if ranType == "legend" and key:
return legendInfo(key, choice(choices).lower())
return bbEmbed(
"Random " + ranType.title(),
f"Your {ranType} is {choice(choices)}."
)
else:
return bbEmbed(
"Brawlhalla Randomizer",
"Please do !random legend or !random weapon."
)
return bbEmbed(
"Brawlhalla Randomizer",
"Please do !random legend or !random weapon."
)


def claimProfile(discordID: int, brawlID: str):
Expand Down
2 changes: 1 addition & 1 deletion bucks.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ def reset(target: discord.User) -> discord.Embed:

def leaderboard(target: discord.User = None) -> discord.Embed:
# Runtime = 2 * |money.csv| + runtime of sorted(money.csv) + 10
# = O(n) + O(nlogn) + 10 = O(nlogn)
# = 2 * O(n) + O(nlogn) + 10 = O(nlogn)
diction = {}
emb = bbEmbed("BeardlessBucks Leaderboard")
with open("resources/money.csv") as csvfile:
Expand Down
2 changes: 1 addition & 1 deletion misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def truncTime(member):
return str(member.created_at)[:-7]


# Wrapper for discord.Embed init() that defaults to
# Wrapper for discord.Embed.init() that defaults to
# commonly-used values and is easier to call
def bbEmbed(
name: str = "", value: str = "", col: int = 0xFFF994
Expand Down
8 changes: 4 additions & 4 deletions resources/money.csv
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
714149971397705740,1200,corvet corvet beach#0024
295072759992680469,871,YNeos#4444
511679866261864448,200,Shewrpy = senpai#6134
696729737720234094,52099,sunbored#8073
696729737720234094,86099,sunbored#8073
687535372800229378,200,liarcake#3987
653729591306879016,0,Phizzuk#6688
375673292083822604,200,ebolawarrior30#2530
Expand Down Expand Up @@ -267,7 +267,7 @@
716374389016232058,231,dezz-senpai#5913
743710061867696180,505,TyoZa#1111
533733667814768663,500,Naz#7322
549589780455882754,600,winter husko#1685
549589780455882754,0,christmas doge in a suit#1685
554360414658625558,180,liam#6315
796389754245480458,2,roadhog main go brr#4415
404502217350053897,300,kennydoge39#5178
Expand Down Expand Up @@ -334,7 +334,7 @@
735436444134277140,400,AyoBlaze#2395
462092912390438922,300,NinjaTim60#7263
661164105994076171,69,Billie Eyelash#3685
196354892208537600,400,Captain No-Beard#7511
196354892208537600,410,Captain No-Beard#7511
689174104925929597,300,Sharker#5377
699783670768205884,300,Kaanav#3110
441012860588654633,240,Aura#0230
Expand All @@ -348,7 +348,7 @@
831580718358200344,413,Evilychee#6693
737945994679025675,300,SpaceGod#3861
709698228987363339,200,Sir Theodore lll#2817
753094428813557861,310,DKeane120#2084
753094428813557861,320,DKeane120#2084
569218129532682250,2,fryfry#1949
489787046051971073,0,Hl_Pavgiss#4509
808315985680924702,503,crabpatty ツ#1800
Expand Down

0 comments on commit 5467e2f

Please sign in to comment.