Add attack command - annna - Annna the nice friendly bot. HTML git clone git://bitreich.org/annna/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/annna/ DIR Log DIR Files DIR Refs DIR Tags DIR README --- DIR commit e79d692b645c0a7f09625e1a33d2ce1c7cc13a28 DIR parent 7166b93b08b30b2a0c7ab0732376abc76fe41943 HTML Author: Scarlett McAllister <git@roygbyte.com> Date: Mon, 28 Aug 2023 22:53:18 -0300 Add attack command Signed-off-by: Annna Robert-Houdin <annna@bitreich.org> Diffstat: M modules/idlerpg/idlerpg-channel-se… | 43 ++++++++++++++++++++++++++----- 1 file changed, 37 insertions(+), 6 deletions(-) --- DIR diff --git a/modules/idlerpg/idlerpg-channel-service.py b/modules/idlerpg/idlerpg-channel-service.py @@ -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. %s, your " \ + "idle time has been reduced to %s." \ + % (hacker, cmdargs[0], weapon, damage, cmdargs[0], \ + hackers[cmdargs[0]][0]) + hackers[cmdargs[0]][0] -= damage + elif damage < 0: + # Defence success + damage = abs(damage) + attackinfo = "%s defended an attack from %s " \ + "with their %s, causing %s seconds of activity. %s, " \ + "your idle time has been reduced to %s." \ + % (cmdargs[0], hacker, weapon, damage, hacker, \ + hackers[hacker][0]) + hackers[hacker][0] -= damage + else: + continue + say(chaninpath, attackinfo) elif user == "-!-": (hacker, text) = remain.split(" ", 1)