You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 11, 2024. It is now read-only.
Copy file name to clipboardExpand all lines: tapir_module.py
+46-37
Original file line number
Diff line number
Diff line change
@@ -13,10 +13,15 @@ def __init__(self):
13
13
14
14
self.images=len(self.tapirs) #sets the length to the length of the list
15
15
16
-
self.current_game="say \"!?\" for help"#the current game messsage
16
+
self.current_game="say \"!?\" for help"#the current game message
17
17
18
-
self.georgie=100#health of georgie
19
-
self.pennywise=100#health of pennywise
18
+
self.pairs= [
19
+
['georgie', 'pennywise']
20
+
]
21
+
22
+
self.pair_health= [
23
+
[100, 100]
24
+
]
20
25
21
26
self.commands= { #command dictioinary
22
27
'!?' : 'Hello! I am a bot made by <@149281074437029890> . \n say `!tapir` to get a random tapir image! \n say `!carrack` for a Carrack picture. \n say `!azwe` for @Azwethinkweiz\'s beautiful mocap animation. \n say `!ben` to get Ben\'s beautiful dancing. \n say `!2.4` to get an update on the new 2.4 update. \n say `!scam` to know the truth of Star Citizen. \n say `!attack <pennywise or georgie>` to play the attacking minigame. say `!attack help` for more information. \n say `!source` for my Github!',
@@ -46,14 +51,14 @@ async def print_message(self, message, raw_message): #prints the name of author
46
51
47
52
asyncdefprivate_message_recieved(self, raw_message, client): #when tapir-bot recieves a private message
48
53
"""sends me a private message of the channel ID and the author name and content"""
taper=self.tapirs[random.randrange(self.images)] #generates the tapir
65
70
awaitclient.send_message(message.channel, taper) #sends the tapir
71
+
72
+
asyncdefdefine(self, pair, raw_message, client):
73
+
"""will define a new pair for attack"""
74
+
ifpairnotinself.pairsandpair[::-1] notinself.pairs: #if it's not defined
75
+
self.pairs.append(pair) #puts the pair in
76
+
self.pair_health.append([100, 100]) #appends the health to the health list
77
+
awaitclient.send_message(raw_message.channel, '{} vs. {} is ready!'.format(pair[0], pair[1])) #confirms they are added
78
+
else: #if it's already defined
79
+
awaitclient.send_message(raw_message.channel, '{} vs. {} is already defined.'.format(pair[0], pair[1])) #says they are already defined
66
80
67
-
asyncdefattack(self, character, message, client):
68
-
"""does the pennywise vs. georgie attack minigame, for now at least"""
69
-
ifcharacter=="pennywise": #if you play ass pennywise
70
-
ifself.pennywise>0: #and he isn't dead
71
-
damage=random.randrange(10, 21) #you get a damage value
72
-
self.georgie-=damage#and damage the other charcter with it
73
-
ifself.georgie<=0: #if georgie gets dead
74
-
awaitclient.send_message(message.channel, "Georgie is dead!") #he is rekt
75
-
else: #if georgie is still alive after being beat down
76
-
awaitclient.send_message(message.channel, "Pennywise did {} points of damage to Georgie, he only has {} left!".format(damage, self.georgie)) #you get told
77
-
else: #if pennywise was dead
78
-
awaitclient.send_message(message.channel, "Pennywise is dead dummy!") #your dumb, reset
79
-
elifcharacter=="georgie": #if you want to play as georgie
80
-
ifself.georgie>0: #and he's not dead
81
-
damage=random.randrange(10, 21) #he gets a damage value
82
-
self.pennywise-=damage#applies it to pennywise
83
-
ifself.pennywise<=0: #if he gets rekt
84
-
awaitclient.send_message(message.channel, "Pennywise is dead!") #then he is dead, and you are told
85
-
else: #if he is still alive
86
-
awaitclient.send_message(message.channel, "Georgie did {} points of damage to Pennywise, he only has {} left!".format(damage, self.pennywise)) #you are told his health
87
-
else: #if georgie is dead
88
-
awaitclient.send_message(message.channel, "Georgie is dead dummy!") #ur dumb reset
89
-
elifcharacter=="reset": #resets the game
90
-
self.georgie=100#health back to 100
91
-
self.pennywise=100
92
-
awaitclient.send_message(message.channel, "Healths have been reset") #notified that it is reset
93
-
elifcharacter=="health": #if you want to know the health of the characters
94
-
awaitclient.send_message(message.channel, "Pennywise has: {} \n Georgie has {}".format(self.pennywise, self.georgie)) #it tells you the health!
95
-
elifcharacter=="help":
96
-
awaitclient.send_message(message.channel, "This is the Pennywise vs. Georgie game. It can be used to settle conflicts if needed. \n say `!attack pennywise` to play as pennywise, and say `!attack georgie` to play as georgie. \n say `!attack health` to get an update on the character's health. \n say `attack reset` to reset everything")
97
-
else:
98
-
awaitclient.send_message(message.channel, "That isn't a recognized attacking character, say `!attack help` for help")
81
+
asyncdefreset(self, raw_message, client):
82
+
"""resets all of the healths to 100"""
83
+
forpairinrange(len(self.pair_health)): #for the pair in the health list
84
+
forcharacterinrange(len(self.pair_health[pair])): #for every character in the pair
85
+
self.pair_health[pair][character] =100#their health is 100
ifpairinself.pairsorpair[::-1] inself.pairs: #if they are in the list
91
+
attacker=pair[0] #makes sure to define which is the attacker
92
+
defender=pair[1] #and the defender
93
+
ifpairnotinself.pairs: #if the base isn't in, it reverse the two
94
+
pair=pair[::-1]
95
+
pair_index=self.pairs.index(pair) #finds the index of the pair in the pairs list
96
+
attacker_index=self.pairs[pair_index].index(attacker) #finds the index of the attacker
97
+
defender_index=self.pairs[pair_index].index(defender) #and the defender
98
+
ifself.pair_health[pair_index][attacker_index] >0: #if the attacker is still alive
99
+
damage=random.randrange(10, 21) #he damages the defender
100
+
self.pair_health[pair_index][defender_index] -=damage#applies the damage
101
+
ifself.pair_health[pair_index][defender_index] >0: #if the defender is still alive
102
+
awaitclient.send_message(raw_message.channel, '{} did {} damage to {}, who has {} health left'.format(attacker, damage, defender, self.pair_health[pair_index][defender_index])) #says how much health is left of defender and such
103
+
else: #if the defender has 0 or less health after being damaged
104
+
awaitclient.send_message(raw_message.channel, '{} is dead!'.format(defender)) #if the defender dies it says so
105
+
else: #if the attacker is dead
106
+
awaitclient.send_message(raw_message.channel, '{} is dead, they can\'t attack!'.format(attacker)) #says so
0 commit comments