Introduction
Introduction Statistics Contact Development Disclaimer Help
Add random attacks and quest feature. - annna - Annna the nice friendly bot.
git clone git://bitreich.org/annna/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws6…
Log
Files
Refs
Tags
README
---
commit 85900f48857793f3c924c587812e7e79971b3a03
parent e79d692b645c0a7f09625e1a33d2ce1c7cc13a28
Author: Annna Robert-Houdin <[email protected]>
Date: Tue, 29 Aug 2023 20:39:18 +0200
Add random attacks and quest feature.
Diffstat:
M modules/idlerpg/idlerpg-channel-se… | 124 ++++++++++++++++++++-------…
A modules/idlerpg/quests.txt | 7 +++++++
2 files changed, 87 insertions(+), 44 deletions(-)
---
diff --git a/modules/idlerpg/idlerpg-channel-service.py b/modules/idlerpg/idler…
@@ -106,16 +106,13 @@ def main(args):
return 1
penalties = readin_dictfile("%s/penalties.txt" % (basepath))
- print(penalties)
classes = readin_dictfile("%s/classes.txt" % (basepath))
- print(classes)
hardware = readin_dictfile("%s/hardware.txt" % (basepath))
- print(hardware)
shields = readin_dictfile("%s/shields.txt" % (basepath))
- print(shields)
weapons = readin_dictfile("%s/weapons.txt" % (basepath))
- print(weapons)
+ quests = readin_dictfile("%s/quests.txt" % (basepath))
+ print(quests)
hackers = readin_dictfile("%s/hackers.txt" % (basepath))
for hacker in hackers.keys():
@@ -123,7 +120,6 @@ def main(args):
hackers[hacker][5] = int(hackers[hacker][5])
print(hackers)
admins = readin_dictfile("%s/admins.txt" % (basepath))
- print(admins)
def random_hacker():
hacker = []
@@ -141,6 +137,55 @@ def main(args):
hacker.append(0)
return hacker
+ def go_on_quest(hackers, questhackers):
+ quest = random.choice(list(quests.keys()))
+ success = random.randint(1, 16)
+ damage = (success - 5) * 100
+ if damage >= 0:
+ say(chaninpath, quest \
+ % (", ".join(questhackers), "succeeded", damage))
+ else:
+ say(chaninpath, quest \
+ % (", ".join(questhackers), "failed", damage))
+ for hacker in questhackers:
+ hackers[hacker][0] += damage
+
+ def attack(hackers, attacker, defender):
+ attackweapon = hackers[attacker][4]
+ defendweapon = hackers[defender][4]
+ attackshield = hackers[attacker][3]
+ defendshield = hackers[defender][3]
+
+ attackweapon_roll = random.randint(1,12)
+ defendshield_roll = random.randint(1,12)
+ damage = (attackweapon_roll - defendshield_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." \
+ % (attacker, defender, attackweapon, damage, defender, \
+ hackers[defender][0])
+ hackers[defender][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." \
+ % (defender, attacker, defendshield, damage, attacker, \
+ hackers[attacker][0])
+ hackers[attacker][0] -= damage
+ else:
+ attackinfo = "%s attacked %s with a %s" \
+ ", but %s defended so well with %s, " \
+ " that no damaged occured." \
+ % (attacker, defender, attackweapon, defender, \
+ defendshield)
+ say(chaninpath, attackinfo)
+
def hacker_info(hackers, hacker):
hackerinfo = "The hacker %s of the class %s " % (hacker, hackers[hack…
hackerinfo += "is using his %s hardware " % (hackers[hacker][2])
@@ -184,6 +229,14 @@ def main(args):
elif newlevel < hackers[hacker][5]:
say(chaninpath, "%s levelled down to level %s." % (hacker,…
hackers[hacker][5] = newlevel
+
+ if random.randint(1, 65535) > 63000 and len(hackers) > 1:
+ (attacker, defender) = random.choices(list(hackers.keys()), k=…
+ attack(hackers, attacker, defender)
+ elif random.randint(1, 65535) < 2000 and len(hackers) > 1:
+ questhackers = random.choices(list(hackers.keys()), k=random.i…
+ go_on_quest(hackers, questhackers)
+
writeout_dictfile("%s/hackers.txt" % (basepath), hackers)
continue
@@ -195,7 +248,6 @@ def main(args):
for line in lines:
if line == None or line == "":
continue
- print("line = '%s'" % (line))
penalty = None
try:
@@ -207,48 +259,32 @@ def main(args):
hacker = user.split("<", 1)[1].split(">", 1)[0]
is_admin = False
if hacker in admins.keys():
- print("is admin")
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)
- 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)
+ if cmd == "!info" and is_admin and len(cmdargs) > 0:
+ if cmdargs[0] in hackers:
+ hacker_info(hackers, cmdargs[0])
+ else:
+ hacker_info(hackers, hacker)
+ elif cmd == "!attack" and len(cmdargs) > 0:
+ if cmdargs[0] in hackers:
+ attack(hackers, hacker, cmdargs[0])
+ else:
+ (attacker, defender) = random.choices(list(hackers…
+ attack(hackers, attacker, defender)
+ elif cmd == "!quest" and len(cmdargs) > 0:
+ if cmdargs[0] in hackers:
+ argsinhackers = [hacker]
+ for cmdarg in cmdargs:
+ if cmdarg in hackers:
+ argsinhackers.append(cmdarg)
+ go_on_quest(hackers, argsinhackers)
+ else:
+ questhackers = random.choices(list(hackers.keys())…
+ go_on_quest(hackers, questhackers)
elif user == "-!-":
(hacker, text) = remain.split(" ", 1)
diff --git a/modules/idlerpg/quests.txt b/modules/idlerpg/quests.txt
@@ -0,0 +1,7 @@
+%s went on a kroketen eating contest. They %s. Their idle time changed by %d.
+The hacker group %s hacked the Gibson. They %s. Their idle time changed by %d.
+The hacker group %s hacked the Pentagon. They %s. Their idle time changed by %…
+%s tried to install systemd. They %s. Their idle time changed by %d.
+Today the hacker group %s went on a journey to learn ed(1), they %s. Their idl…
+A huge entry of patches was received by the %s hacker group. They %s. Their id…
+%s did an emerge -uDN @world on gentoo. They %s. Their idle time changed by %d.
You are viewing proxied material from bitreich.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.