Browse Source

12/28/2022

BradDev
Joe DiPrima 3 years ago
parent
commit
445e4fc136
  1. 200
      qmutants.py

200
qmutants.py

@ -51,12 +51,12 @@ def player_add(usr,pwd,char_sel,weapon,spell,ac,ai,me,af,hu,ba):
player_list.append(plyr)
if choice == 1:
player_add("epilectrik","gupass",4,"Nuclear-Decay","dispell",True,True,True,True,True,False)
player_add("im bait","gupass",4,"Nuclear-Decay","dispell",True,True,True,True,True,False)
player_add("doctor","gupass",2,"Nuclear-Decay","cure poison",True,True,True,True,True,False)
player_add("robin-hood","gupass",1,"Nuclear-Decay","invisibility",True,True,True,True,True,False)
player_add("assassin","gupass",4,"Nuclear-Decay","dispell",True,True,True,True,True,False)
player_add("mercenary","gupass",4,"Nuclear-Decay","dispell",True,True,True,True,True,False)
player_add("epilectrik","gupass",4,"Nuclear-Decay","dispell",True,True,True,False,True,False)
player_add("im bait","gupass",4,"Nuclear-Decay","dispell",True,True,True,False,True,False)
player_add("doctor","gupass",2,"Nuclear-Decay","cure poison",True,True,True,False,True,False)
player_add("robin-hood","gupass",1,"Nuclear-Decay","invisibility",True,True,True,False,True,False)
player_add("assassin","gupass",4,"Nuclear-Decay","dispell",True,True,True,False,True,False)
player_add("mercenary","gupass",4,"Nuclear-Decay","dispell",True,True,True,False,True,False)
player_add("mutant-warrior-1","gupass",4,"Nuclear-Decay","dispell",True,True,False,False,False,False)
player_add("mutant-warrior-2","gupass",4,"Nuclear-Decay","dispell",True,True,False,False,False,False)
@ -123,6 +123,7 @@ class mutant(QWidget):
self.sell_list = []
self.stock_list = []
self.bank_list = []
self.cmd_buffer = []
#modes
self.heal = False
@ -149,6 +150,8 @@ class mutant(QWidget):
self.weapon = "Nuclear-Decay"
self.spell = player.spell
self.watchdog = 0
self.cmd_watchdog = 0
self.prompt = False
#value tracking
self.riblets = 0
@ -205,7 +208,11 @@ class mutant(QWidget):
self.watchdog_timer.setInterval(30000)
self.watchdog_timer.timeout.connect(self.watchdog_t)
self.watchdog_timer.start()
#cmd watchdog
self.watchdog_cmd_timer = QTimer()
self.watchdog_cmd_timer.setInterval(100)
self.watchdog_cmd_timer.timeout.connect(self.watchdog_cmd)
self.watchdog_cmd_timer.start()
#layout stuff
self.layout = QVBoxLayout()
@ -247,6 +254,17 @@ class mutant(QWidget):
#self.set_color()
def send_cmd(self,cmd_str):
if self.prompt:
self.command_str.emit(cmd_str)
else:
self.cmd_buffer.append(cmd_str)
def transmit_bfr(self):
while len(self.cmd_buffer)>0:
self.command_str.emit(self.cmd_buffer[0])
self.cmd_buffer.pop(0)
def set_color(self):
self.setAttribute(Qt.WA_StyledBackground, True)
self.setStyleSheet('background-color: red;')
@ -402,16 +420,16 @@ class mutant(QWidget):
#buttons
def n_btn(self):
self.command_str.emit("north\r\n")
self.send_cmd("north\r\n")
def s_btn(self):
self.command_str.emit("south\r\n")
self.send_cmd("south\r\n")
def e_btn(self):
self.command_str.emit("east\r\n")
self.send_cmd("east\r\n")
def w_btn(self):
self.command_str.emit("west\r\n")
self.send_cmd("west\r\n")
def h_btn(self):
self.heal = True
@ -423,10 +441,10 @@ class mutant(QWidget):
self.path_step=1
def l_btn(self):
self.command_str.emit("look\r\n")
self.send_cmd("look\r\n")
def st_btn(self):
self.command_str.emit("stat\r\n")
self.send_cmd("stat\r\n")
#load bank file
def load_bank_paths(self):
@ -450,7 +468,7 @@ class mutant(QWidget):
#Button send text
def send_str(self):
self.command_str.emit(self.text_input.text()+"\r\n")
self.send_cmd(self.text_input.text()+"\r\n")
#auto combat checked
def ac_checked(self):
@ -485,13 +503,13 @@ class mutant(QWidget):
#heal timer
def heal_trig(self):
if self.heal and self.logged_in and self.in_play:
self.command_str.emit("heal\r\n")
self.send_cmd("heal\r\n")
#self.mqtt_str_quiet.emit(self.user," is healing." )
#wield timer
def wield_trig(self):
if self.in_combat and self.logged_in and self.in_play:
self.command_str.emit("wie "+self.weapon+"\r\n")
self.send_cmd("wie "+self.weapon+"\r\n")
#wander timer
def wander_trig(self):
@ -504,7 +522,7 @@ class mutant(QWidget):
#increment no action counter
self.no_action_cnt = self.no_action_cnt + 1
if len(self.direction_list) == 0:
self.command_str.emit("look\r\n")
self.send_cmd("look\r\n")
#pick randomly
if len(self.direction_list) > 0:
@ -527,15 +545,15 @@ class mutant(QWidget):
except:
pass
self.command_str.emit(dir_choice+"\r\n")
self.send_cmd(dir_choice+"\r\n")
self.direction_list = []
self.previous_dir = opposite_dir[dir_choice]
#stat timer
def stat_trig(self):
if self.logged_in and self.in_play and not self.in_combat and self.path_step == 0:
self.command_str.emit("stat\r\n")
self.command_str.emit("look\r\n")
self.send_cmd("stat\r\n")
self.send_cmd("look\r\n")
#path timer
def path_trig(self):
@ -554,8 +572,8 @@ class mutant(QWidget):
for item_l in self.local_items:
for item in convert_list:
if item_l == item:
self.command_str.emit("get "+item+"\r\n")
self.command_str.emit("con "+item+"\r\n")
self.send_cmd("get "+item+"\r\n")
self.send_cmd("con "+item+"\r\n")
self.mqtt_str_quiet.emit(self.user," converted " + item )
try:
self.local_items.remove(item_l)
@ -567,7 +585,7 @@ class mutant(QWidget):
for item_l in self.local_items:
for item in farm_sell_list:
if item_l == item:
self.command_str.emit("get "+item+"\r\n")
self.send_cmd("get "+item+"\r\n")
self.local_items.remove(item_l)
self.sell_list.append(item_l)
self.no_action_cnt = 0
@ -577,7 +595,7 @@ class mutant(QWidget):
for item_l in self.local_items:
for item in farm_stock_list:
if item_l == item:
self.command_str.emit("get "+item+"\r\n")
self.send_cmd("get "+item+"\r\n")
self.local_items.remove(item_l)
self.stock_list.append(item_l)
self.no_action_cnt = 0
@ -588,22 +606,27 @@ class mutant(QWidget):
while len(self.sell_list) > 0:
item_l=self.sell_list[0]
self.sell_list.pop(0)
self.command_str.emit("sell "+item_l+"\r\n")
self.send_cmd("sell "+item_l+"\r\n")
time.sleep(.05)
#Stock
def stock_items(self):
print(self.stock_list)
while len(self.stock_list) > 0:
item_l=self.stock_list[0]
self.stock_list.pop(0)
self.command_str.emit("stock "+item_l+"\r\n")
time.sleep(.05)
for item_s in farm_stock_list:
for item in self.stock_list:
if item == item_s:
cnt = self.stock_list.count(item)
if item == self.weapon:
cnt = cnt - 1
for x in range(cnt):
self.send_cmd("stock "+item+"\r\n")
self.stock_list.remove(item)
time.sleep(.05)
#Drop monster baits
def drop_baits(self):
while self.stock_list.count("Monster-Bait") > 1:
self.command_str.emit("drop monster-bait\r\n")
self.send_cmd("drop monster-bait\r\n")
self.stock_list.remove("Monster-Bait")
#Remove friends from monster list
@ -636,7 +659,7 @@ class mutant(QWidget):
#initiate combat
def combat_start(self):
try:
self.command_str.emit("combat " + self.local_monsters[0]+"\r\n")
self.send_cmd("combat " + self.local_monsters[0]+"\r\n")
self.mqtt_str_quiet.emit(self.user," is attacking " + self.local_monsters[0] )
except:
pass
@ -678,8 +701,8 @@ class mutant(QWidget):
self.hits = self.hits + 1
if self.hits == 2:
self.command_str.emit("heal\r\n")
self.command_str.emit("heal\r\n")
self.send_cmd("heal\r\n")
self.send_cmd("heal\r\n")
self.hits = 0
if result.find("have slain") != -1 or result.find("has just left") != -1 or result.find("isn't around here!") != -1 or result.find("You're not ready") != -1:
@ -688,7 +711,7 @@ class mutant(QWidget):
except:
pass
if len(self.local_monsters) > 0:
self.command_str.emit("combat " + self.local_monsters[0]+"\r\n")
self.send_cmd("combat " + self.local_monsters[0]+"\r\n")
else:
#print("Area cleared")
self.in_combat = False
@ -700,12 +723,12 @@ class mutant(QWidget):
self.farm_year = self.farm_year + 100
if self.farm_year > self.year_limit:
self.farm_year = 2000
self.command_str.emit("tra "+str(self.farm_year)+"\r\n")
self.send_cmd("tra "+str(self.farm_year)+"\r\n")
self.drop_baits()
if self.bait and not self.stock_list.count("Monster-Bait"):
self.command_str.emit("get Monster-Bait\r\n")
self.send_cmd("get Monster-Bait\r\n")
self.stock_list.append("Monster-Bait")
self.command_str.emit("look\r\n")
self.send_cmd("look\r\n")
#process path
def path_process(self):
@ -714,7 +737,7 @@ class mutant(QWidget):
if path_str[0] == "!":
self.script_function(path_str.strip("!").upper())
else:
self.command_str.emit(path_str+"\r\n")
self.send_cmd(path_str+"\r\n")
self.path_step = self.path_step + 1
self.no_action_cnt = 0
else:
@ -723,15 +746,15 @@ class mutant(QWidget):
#handle functions in path script
def script_function(self,function):
if function == "DEPOSIT":
self.command_str.emit("deposit "+str(self.riblets)+"\r\n")
self.send_cmd("deposit "+str(self.riblets)+"\r\n")
self.mqtt_str_quiet.emit(self.user," deposited "+str(self.riblets)+" riblets" )
self.riblets = 0
if self.ions > 2000000:
self.command_str.emit("secure "+str(self.ions-2000000)+"\r\n")
self.send_cmd("secure "+str(self.ions-2000000)+"\r\n")
self.mqtt_str_quiet.emit(self.user," secured "+str(self.ions-2000000)+" ions" )
self.ions = 2000000
if function == "STOCK":
if function == "STOCK" and self.auto_farm:
self.stock_items()
if function == "SELL":
@ -739,7 +762,7 @@ class mutant(QWidget):
if function == "RETURN":
self.path_step = -1
self.command_str.emit("tra "+str(self.farm_year)+"\r\n")
self.send_cmd("tra "+str(self.farm_year)+"\r\n")
new_path = self.selected_path + 1
if new_path == len(self.bank_list):
new_path = 0
@ -762,7 +785,7 @@ class mutant(QWidget):
if i < 3:
self.sell_list.append(item_l)
else:
self.command_str.emit("con "+item_l+"\r\n")
self.send_cmd("con "+item_l+"\r\n")
for item_l in farm_stock_list:
x = self.status.count(item_l)
@ -770,7 +793,7 @@ class mutant(QWidget):
if i < 3:
self.stock_list.append(item_l)
else:
self.command_str.emit("con "+item_l+"\r\n")
self.send_cmd("con "+item_l+"\r\n")
#HP
if self.status.find("Hit Points :") != -1:
start_index = self.status.index('Hit Points : ') + 15
@ -1000,6 +1023,14 @@ class mutant(QWidget):
self.watchdog = 0
else:
self.watchdog = self.watchdog + 1
def watchdog_cmd(self):
if self.cmd_watchdog > 2:
if len(self.cmd_buffer)>0:
self.transmit_bfr()
self.cmd_watchdog = 0
else:
self.cmd_watchdog = self.cmd_watchdog + 1
#Main game loop
def mutants(self,result):
@ -1021,7 +1052,15 @@ class mutant(QWidget):
self.selected_path = int(self.path_input.text())
except:
pass
#Detect prompt
if result.find(">") != -1:
self.transmit_bfr()
self.cmd_watchdog = 0
self.prompt = True
else:
self.prompt = False
#Nothing has happened in a while, time jump
if self.no_action_cnt > self.na_thresh:
self.time_travel()
@ -1032,9 +1071,9 @@ class mutant(QWidget):
if result.find("Prepare to walk a thousand years!") != -1:
self.in_play = True
#self.player_init()
self.command_str.emit("blurb\r\n")
self.command_str.emit("deaf\r\n")
self.command_str.emit("memorize "+self.spell+"\r\n")
self.send_cmd("blurb\r\n")
self.send_cmd("deaf\r\n")
self.send_cmd("memorize "+self.spell+"\r\n")
self.tab_color.emit(self.idx,'green')
print("Character in play..")
@ -1061,13 +1100,13 @@ class mutant(QWidget):
#too many baits
if self.stock_list.count("Monster-Bait") > 3:
self.command_str.emit("drop Monster-Bait\r\n")
self.send_cmd("drop Monster-Bait\r\n")
self.stock_list.remove("Monster-Bait")
#print(self.stock_list)
#too many nuclear decays
if self.stock_list.count("Nuclear-Decay") > 3:
self.command_str.emit("con nuclear-decay\r\n")
self.send_cmd("con nuclear-decay\r\n")
self.stock_list.remove("Nuclear-Decay")
#print(self.stock_list)
@ -1080,11 +1119,7 @@ class mutant(QWidget):
#deposit riblets
if self.riblets > self.riblet_thresh and self.path_step == 0 and self.wander:
self.path_step = 1
#auto farm if sold items
if len(self.sell_list) == 0 and self.wander:
self.auto_farm = True
#process wander
if self.wander and not self.in_combat and self.path_step == 0:
self.wander_process(result)
@ -1099,30 +1134,26 @@ class mutant(QWidget):
#ion starvation
if result.find("You're starving for IONS!") != -1:
self.command_str.emit("con gold-chunck\r\n")
self.send_cmd("con gold-chunck\r\n")
self.auto_combat = True
self.heal = True
#too heavy
if self.wander and result.find("The weight of all your items forces you to the ground.") != -1:
self.wander = False
self.command_str.emit("X\r\n")
self.send_cmd("X\r\n")
#dropped your weapon!
if self.auto_farm and result.find("The Nuclear-Decay fell out of your sack!") != -1:
self.time_steps = 0
self.command_str.emit("con gold-chunck\r\n")
self.command_str.emit("get nuclear-decay\r\n")
#I can't remember why I did this
if self.auto_farm and result.find("You're not carrying a gold-chunck.") != -1:
self.auto_farm = False
self.send_cmd("con gold-chunck\r\n")
self.send_cmd("get nuclear-decay\r\n")
#Dropped the bait, pick it back up
if result.find("The Monster-Bait fell out of your sack!") != -1:
self.time_steps = 0
self.command_str.emit("con gold-chunck\r\n")
self.command_str.emit("get monster-bait\r\n")
self.send_cmd("con gold-chunck\r\n")
self.send_cmd("get monster-bait\r\n")
#Detect bait mode, add or remove from stock list
if self.bait:
@ -1136,14 +1167,15 @@ class mutant(QWidget):
#Exit game if..
if self.in_combat and result.find("You're not carrying a "+self.weapon.lower()) != -1:
self.command_str.emit("kick\r\n")
self.send_cmd("kick\r\n")
#self.exit_game()
#Lighten
if self.wander and (result.find("It's too dark to see anything!") != -1 and self.path_step == 0):
if self.char_sel == 4:
self.command_str.emit("cast\r\n")
else time_travel()
self.send_cmd("cast\r\n")
else:
self.time_travel()
#GTFO
#if result.find("You're blocked!") != -1 or len(self.local_monsters) > 4:
@ -1278,22 +1310,22 @@ class mutant(QWidget):
if key==ord("8"):
self.local_monsters = []
self.local_items = []
self.command_str.emit("north\r\n")
self.send_cmd("north\r\n")
if key==ord("2"):
self.local_monsters = []
self.local_items = []
self.command_str.emit("south\r\n")
self.send_cmd("south\r\n")
if key==ord("4"):
self.local_monsters = []
self.local_items = []
self.command_str.emit("west\r\n")
self.send_cmd("west\r\n")
if key==ord("6"):
self.local_monsters = []
self.local_items = []
self.command_str.emit("east\r\n")
self.send_cmd("east\r\n")
#functions
if key==ord("a"):
@ -1339,7 +1371,7 @@ class mutant(QWidget):
#look around
if key==ord("5"):
self.command_str.emit("look ")
self.send_cmd("look ")
#meander status
if key==ord("m"):
@ -1349,20 +1381,20 @@ class mutant(QWidget):
else:
self.wander = True
print("Meander on")
self.command_str.emit("look\r\n")
self.send_cmd("look\r\n")
#heal
if key==ord("h"):
self.command_str.emit("heal\r\n")
self.send_cmd("heal\r\n")
self.heal = True
#look around
if key==ord("l"):
self.command_str.emit("look\r\n")
self.send_cmd("look\r\n")
#stats
if key==ord("v"):
self.command_str.emit("stat\r\n")
self.send_cmd("stat\r\n")
#sell items
if key==ord("s"):
@ -1374,18 +1406,18 @@ class mutant(QWidget):
st = input("Choose path input: ")
self.selected_path = int(st)
self.path_step = 1
self.command_str.emit("Starting path..\r\n")
self.send_cmd("Starting path..\r\n")
self.flush_input()
if key==ord("K") and not self.in_combat:
print("working?")
st = input("Keyboard input: ")
self.command_str.emit(st+"\r\n")
self.send_cmd(st+"\r\n")
self.flush_input()
#wield weapon
if key==ord("w"):
self.command_str.emit("wie "+self.weapon+"\r\n")
self.send_cmd("wie "+self.weapon+"\r\n")
#drop item
if key==ord("d"):
@ -1393,7 +1425,7 @@ class mutant(QWidget):
#toss = keyboard.read_key()
st = input("drop item: ")
drop_item = "drop " + st
self.command_str.emit(drop_item+"\r\n")
self.send_cmd(drop_item+"\r\n")
#time travel
if key==ord("t") and not self.in_combat:
@ -1402,7 +1434,7 @@ class mutant(QWidget):
#toss = keyboard.read_key()
st = input("year: ")
year = "travel " + st
self.command_str.emit(year+"\r\n")
self.send_cmd(year+"\r\n")
if key==ord("x"):
pass

Loading…
Cancel
Save