Add attack command - annna - Annna the nice friendly bot. | |
git clone git://bitreich.org/annna/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws6… | |
Log | |
Files | |
Refs | |
Tags | |
README | |
--- | |
commit e79d692b645c0a7f09625e1a33d2ce1c7cc13a28 | |
parent 7166b93b08b30b2a0c7ab0732376abc76fe41943 | |
Author: Scarlett McAllister <[email protected]> | |
Date: Mon, 28 Aug 2023 22:53:18 -0300 | |
Add attack command | |
Signed-off-by: Annna Robert-Houdin <[email protected]> | |
Diffstat: | |
M modules/idlerpg/idlerpg-channel-se… | 43 ++++++++++++++++++++++++++-… | |
1 file changed, 37 insertions(+), 6 deletions(-) | |
--- | |
diff --git a/modules/idlerpg/idlerpg-channel-service.py b/modules/idlerpg/idler… | |
@@ -205,19 +205,50 @@ def main(args): | |
if user.startswith("<") and user.endswith(">"): | |
hacker = user.split("<", 1)[1].split(">", 1)[0] | |
+ is_admin = False | |
if hacker in admins.keys(): | |
print("is admin") | |
- if remain.startswith("!"): | |
- (cmd, *cmdargs) = remain.split(" ") | |
- print("cmd = %s; cmdargs = %s" % (cmd, cmdargs)) | |
- if cmd == "!info": | |
+ is_admin = True | |
+ else: | |
+ penalty = "text" | |
+ if remain.startswith("!"): | |
+ (cmd, *cmdargs) = remain.split(" ") | |
+ print("cmd = %s; cmdargs = %s" % (cmd, cmdargs)) | |
+ if cmd == "!info" and is_admin: | |
if len(cmdargs) > 0: | |
if cmdargs[0] in hackers: | |
hacker_info(hackers, cmdargs[0]) | |
else: | |
hacker_info(hackers, hacker) | |
- else: | |
- penalty = "text" | |
+ elif cmd == "!attack": | |
+ if len(cmdargs) > 0: | |
+ if cmdargs[0] in hackers: | |
+ weapon = hackers[hacker][3] | |
+ weapon_roll = random.randint(1,12) | |
+ shield = hackers[cmdargs[0]][4] | |
+ shield_roll = random.randint(1,12) | |
+ damage = (weapon_roll - shield_roll) * 100 | |
+ attackinfo = "The hacker " | |
+ if damage > 0: | |
+ # Attack success | |
+ attackinfo = "%s attacked %s with a %s… | |
+ ", causing %s seconds of activity.… | |
+ "idle time has been reduced to %s.… | |
+ % (hacker, cmdargs[0], weapon, dam… | |
+ hackers[cmdargs[0]][0]) | |
+ hackers[cmdargs[0]][0] -= damage | |
+ elif damage < 0: | |
+ # Defence success | |
+ damage = abs(damage) | |
+ attackinfo = "%s defended an attack fr… | |
+ "with their %s, causing %s seconds… | |
+ "your idle time has been reduced t… | |
+ % (cmdargs[0], hacker, weapon, dam… | |
+ hackers[hacker][0]) | |
+ hackers[hacker][0] -= damage | |
+ else: | |
+ continue | |
+ say(chaninpath, attackinfo) | |
elif user == "-!-": | |
(hacker, text) = remain.split(" ", 1) |