Browse Source

12/30/2022

BradDev
Joe DiPrima 3 years ago
parent
commit
2a4cfb67bb
  1. 128
      qmutants.py

128
qmutants.py

@ -58,8 +58,8 @@ if choice == 1:
player_add("robin-hood","gupass",1,"Nuclear-Decay","invisibility",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("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("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)
player_add("mutant-warrior-1","gupass",4,"Nuclear-Decay","dispell",True,True,True,False,True,False)
player_add("mutant-warrior-2","gupass",4,"Nuclear-Decay","dispell",True,True,True,False,True,False)
if choice == 2: if choice == 2:
player_add("Mtron","gupass",4,"Nuclear-Decay","dispell",True,True,True,True,True,False) player_add("Mtron","gupass",4,"Nuclear-Decay","dispell",True,True,True,True,True,False)
@ -79,6 +79,8 @@ farm_stock_list = ["Nuclear-Decay","Eazy-Armor","Hell-Blade"]
friend_list = ["Epilectrik","ImBait","Mtron","Im","IonJunkies-Merc","Robin-Hood","Doctor","Assassin","Mercenary","Mutant-warrior-1","Mutant-warrior-2"] friend_list = ["Epilectrik","ImBait","Mtron","Im","IonJunkies-Merc","Robin-Hood","Doctor","Assassin","Mercenary","Mutant-warrior-1","Mutant-warrior-2"]
#cure_path = ["done","tra 2000","north","north","north","north","cure me","!return","done"]
help_list = ["$ - Key listener on/off", help_list = ["$ - Key listener on/off",
"8 - North", "8 - North",
"2 - South", "2 - South",
@ -110,6 +112,8 @@ class mutant(QWidget):
mqtt_str = pyqtSignal(str) mqtt_str = pyqtSignal(str)
mqtt_str_quiet = pyqtSignal(str,str) mqtt_str_quiet = pyqtSignal(str,str)
tab_color = pyqtSignal(int,str) tab_color = pyqtSignal(int,str)
broadcast = pyqtSignal(list)
def __init__(self,player,idx): def __init__(self,player,idx):
QWidget.__init__(self) QWidget.__init__(self)
self.player=player self.player=player
@ -153,6 +157,8 @@ class mutant(QWidget):
self.watchdog = 0 self.watchdog = 0
self.cmd_watchdog = 0 self.cmd_watchdog = 0
self.prompt = False self.prompt = False
self.poisoned = False
self.current_path = ""
#value tracking #value tracking
self.riblets = 0 self.riblets = 0
@ -162,6 +168,7 @@ class mutant(QWidget):
self.clss = "Thief" self.clss = "Thief"
self.level = 0 self.level = 0
self.riblet_thresh = 200000 self.riblet_thresh = 200000
self.ion_thresh = 2000000
self.farm_year=2000 self.farm_year=2000
self.year_limit=2500 self.year_limit=2500
self.no_action_cnt = 0 self.no_action_cnt = 0
@ -169,6 +176,7 @@ class mutant(QWidget):
self.status = "" self.status = ""
self.area = "" self.area = ""
self.console_lines = 0 self.console_lines = 0
self.min_riblets = 6000000
#account #account
self.user = player.usr self.user = player.usr
@ -255,6 +263,19 @@ class mutant(QWidget):
#self.set_color() #self.set_color()
def request_received(self,request):
print("global request received")
print(request)
req_type = request[0]
req_year = request[1]
req_player = request[2]
if self.char_sel == 2:
if req_type == 'poison':
cure_path = ['done','tra '+req_year,'cast '+req_player,'!return','done']
self.current_path = cure_path
self.path_step = 1
def send_cmd(self,cmd_str): def send_cmd(self,cmd_str):
if self.prompt: if self.prompt:
self.command_str.emit(cmd_str) self.command_str.emit(cmd_str)
@ -440,6 +461,7 @@ class mutant(QWidget):
def p_btn(self): def p_btn(self):
self.send_cmd("stat\r\n") self.send_cmd("stat\r\n")
self.current_path = self.bank_list[self.selected_path][:]
self.path_step = 1 self.path_step = 1
def l_btn(self): def l_btn(self):
@ -467,6 +489,7 @@ class mutant(QWidget):
# end of file is reached # end of file is reached
if not in_str: if not in_str:
break break
self.current_path = self.bank_list[0][:]
#Button send text #Button send text
def send_str(self): def send_str(self):
@ -587,13 +610,13 @@ class mutant(QWidget):
for item_l in self.local_items: for item_l in self.local_items:
for item in farm_sell_list: for item in farm_sell_list:
if item_l == item and self.sell_list.count(item) < MAX_SELL_ITEMS: if item_l == item and self.sell_list.count(item) < MAX_SELL_ITEMS:
print("Farm sell count:"+item)
print(self.sell_list.count(item))
print(self.sell_list)
#print("Farm sell count:"+item)
#print(self.sell_list.count(item))
#print(self.sell_list)
self.send_cmd("get "+item+"\r\n") self.send_cmd("get "+item+"\r\n")
self.local_items.remove(item_l) self.local_items.remove(item_l)
self.sell_list.append(item_l) self.sell_list.append(item_l)
print(self.sell_list)
#print(self.sell_list)
self.no_action_cnt = 0 self.no_action_cnt = 0
#Farms valuable stuff #Farms valuable stuff
@ -608,7 +631,7 @@ class mutant(QWidget):
#Sell items #Sell items
def sell_items(self): def sell_items(self):
print(self.sell_list)
#print(self.sell_list)
while len(self.sell_list) > 0: while len(self.sell_list) > 0:
item_l=self.sell_list[0] item_l=self.sell_list[0]
self.sell_list.pop(0) self.sell_list.pop(0)
@ -618,15 +641,15 @@ class mutant(QWidget):
#Stock #Stock
def stock_items(self): def stock_items(self):
print(self.stock_list)
#print(self.stock_list)
for item_s in farm_stock_list: for item_s in farm_stock_list:
for item in self.stock_list: for item in self.stock_list:
if item == item_s: if item == item_s:
cnt = self.stock_list.count(item) cnt = self.stock_list.count(item)
print("item count: "+str(cnt))
#print("item count: "+str(cnt))
if item == self.weapon: if item == self.weapon:
cnt = cnt - 1 cnt = cnt - 1
print("sub weapon count: "+str(cnt))
#print("sub weapon count: "+str(cnt))
for x in range(cnt): for x in range(cnt):
self.send_cmd("stock "+item+"\r\n") self.send_cmd("stock "+item+"\r\n")
self.stock_list.remove(item) self.stock_list.remove(item)
@ -741,7 +764,8 @@ class mutant(QWidget):
#process path #process path
def path_process(self): def path_process(self):
path_str = self.bank_list[self.selected_path][self.path_step]
#path_str = self.bank_list[self.selected_path][self.path_step]
path_str = self.current_path[self.path_step]
if path_str != "done": if path_str != "done":
if path_str[0] == "!": if path_str[0] == "!":
self.script_function(path_str.strip("!").upper()) self.script_function(path_str.strip("!").upper())
@ -755,13 +779,16 @@ class mutant(QWidget):
#handle functions in path script #handle functions in path script
def script_function(self,function): def script_function(self,function):
if function == "DEPOSIT": if function == "DEPOSIT":
self.send_cmd("deposit "+str(self.riblets)+"\r\n")
dep_ribs = self.riblets - self.min_riblets
if dep_ribs < 0:
dep_ribs = 0
self.send_cmd("deposit "+str(dep_ribs)+"\r\n")
self.mqtt_str_quiet.emit(self.user," deposited "+str(self.riblets)+" riblets" ) self.mqtt_str_quiet.emit(self.user," deposited "+str(self.riblets)+" riblets" )
self.riblets = 0
if self.ions > 2000000:
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
self.riblets = self.min_riblets
if self.ions > self.ion_thresh:
self.send_cmd("secure "+str(self.ions-self.ion_thresh)+"\r\n")
self.mqtt_str_quiet.emit(self.user," secured "+str(self.ions-self.ion_thresh)+" ions" )
self.ions = self.ion_thresh
if function == "STOCK" and self.auto_farm: if function == "STOCK" and self.auto_farm:
self.stock_items() self.stock_items()
@ -776,6 +803,11 @@ class mutant(QWidget):
if new_path == len(self.bank_list): if new_path == len(self.bank_list):
new_path = 0 new_path = 0
self.path_input.setText(str(new_path)) self.path_input.setText(str(new_path))
self.tab_color.emit(self.idx,'green')
if function == "POISON":
request = ['poison',str(self.farm_year),self.user]
self.broadcast.emit(request)
#process stats #process stats
def parse_stat(self, result): def parse_stat(self, result):
@ -791,9 +823,9 @@ class mutant(QWidget):
if result.find(">") != -1: if result.find(">") != -1:
#Retally items, convert extras #Retally items, convert extras
if not self.stat_parsed and self.status != "": if not self.stat_parsed and self.status != "":
print("status_length",str(len(self.status)))
print(self.sell_list)
print("deleted list")
#print("status_length",str(len(self.status)))
#print(self.sell_list)
#print("deleted list")
self.sell_list = [] self.sell_list = []
self.stock_list = [] self.stock_list = []
self.watchdog = 0 self.watchdog = 0
@ -804,7 +836,7 @@ class mutant(QWidget):
self.sell_list.append(item_l) self.sell_list.append(item_l)
else: else:
self.send_cmd("con "+item_l+"\r\n") self.send_cmd("con "+item_l+"\r\n")
print(self.sell_list)
#print(self.sell_list)
for item_l in farm_stock_list: for item_l in farm_stock_list:
x = self.status.count(item_l) x = self.status.count(item_l)
for i in range(x): for i in range(x):
@ -902,8 +934,14 @@ class mutant(QWidget):
pass pass
year_str = year_str[:end_index] year_str = year_str[:end_index]
#print("Year:" + year_str) #print("Year:" + year_str)
#If meandering try to stay in sync with farming year, otherwise not
try: try:
self.farm_year = int(year_str)
current_year = int(year_str)
if not self.wander:
self.farm_year = current_year
else:
if current_year != self.farm_year:
self.send_cmd("tra "+str(self.farm_year)+"\r\n")
except: except:
pass pass
self.status = "" self.status = ""
@ -989,6 +1027,16 @@ class mutant(QWidget):
self.tab_color.emit(self.idx,'red') self.tab_color.emit(self.idx,'red')
#Sync checkbox with state
def change_hunt_state(self,state):
self.hunt = state
self.hu_check.setChecked(self.hunt)
#Sync checkbox with state
def change_meander_state(self,state):
self.wander = state
self.me_check.setChecked(self.wander)
#Player starting condition #Player starting condition
def player_init(self): def player_init(self):
self.in_combat=False self.in_combat=False
@ -1123,8 +1171,9 @@ class mutant(QWidget):
self.index_area(result) self.index_area(result)
#deposit riblets #deposit riblets
if self.riblets > self.riblet_thresh and self.path_step == 0 and self.wander and not self.in_combat:
if self.riblets > (self.min_riblets + self.riblet_thresh) and self.path_step == 0 and self.wander and not self.in_combat:
self.send_cmd("stat\r\n") self.send_cmd("stat\r\n")
self.current_path = self.bank_list[self.selected_path][:]
self.path_step = 1 self.path_step = 1
#process wander #process wander
@ -1185,6 +1234,14 @@ class mutant(QWidget):
if len(self.sell_list) > 0: if len(self.sell_list) > 0:
self.sell_items() self.sell_items()
#cure poison
#if result.find("You're in a maintenance shop.") != -1:
# if self.poisoned:
# self.send_cmd("cure me\r\n")
# self.poisoned = False
# self.change_hunt_state(True)
# self.tab_color.emit(self.idx,'green')
#Parse character status #Parse character status
if result.find("stat") != -1: if result.find("stat") != -1:
self.stat_parsed = False self.stat_parsed = False
@ -1197,6 +1254,24 @@ class mutant(QWidget):
if result.find("You suffer") != -1 or result.find("You are poisoned!") != -1: if result.find("You suffer") != -1 or result.find("You are poisoned!") != -1:
self.heal = True self.heal = True
#Detect poisoning
if result.find("You are poisoned!") != -1:
#self.change_meander_state(False)
#self.change_hunt_state(False)
#self.poisoned = True
self.tab_color.emit(self.idx,'Yellow')
self.send_cmd("heal\r\n")
self.send_cmd("heal\r\n")
self.change_meander_state(False)
cure_path = ['done','tra '+str(self.farm_year),'!poison','done']
self.current_path = cure_path
self.path_step = 1
#Poison cured
if result.find("has just cured your poison!") != -1:
self.tab_color.emit(self.idx,'Green')
self.change_meander_state(True)
#Monster list related #Monster list related
if (result.find("yells: Gimmie") != -1 or if (result.find("yells: Gimmie") != -1 or
result.find("just arrived from") != -1 or result.find("just arrived from") != -1 or
@ -1556,6 +1631,8 @@ class telnet_thread(QObject):
class MainWindow(QMainWindow): class MainWindow(QMainWindow):
keyPressed = pyqtSignal(int) keyPressed = pyqtSignal(int)
bcast = pyqtSignal(list)
def __init__(self): def __init__(self):
super(MainWindow, self).__init__() super(MainWindow, self).__init__()
widget = QWidget(self) widget = QWidget(self)
@ -1584,6 +1661,8 @@ class MainWindow(QMainWindow):
self.mutant_list[-1].mqtt_str.connect(self.send_mqtt) self.mutant_list[-1].mqtt_str.connect(self.send_mqtt)
self.mutant_list[-1].mqtt_str_quiet.connect(self.send_mqtt_quiet) self.mutant_list[-1].mqtt_str_quiet.connect(self.send_mqtt_quiet)
self.mutant_list[-1].tab_color.connect(self.color_tab) self.mutant_list[-1].tab_color.connect(self.color_tab)
self.mutant_list[-1].broadcast.connect(self.broadcast)
self.bcast.connect(self.mutant_list[-1].request_received)
tab = QWidget() tab = QWidget()
tab.setLayout(mutbox) tab.setLayout(mutbox)
self.tabs.addTab(tab,player.usr) self.tabs.addTab(tab,player.usr)
@ -1607,6 +1686,9 @@ class MainWindow(QMainWindow):
self.formGroupBox.addRow(self.text_button,self.text_input) self.formGroupBox.addRow(self.text_button,self.text_input)
self.layout.addLayout(self.formGroupBox) self.layout.addLayout(self.formGroupBox)
def broadcast(self,request):
self.bcast.emit(request)
def color_tab(self,idx,color): def color_tab(self,idx,color):
self.tabs.tabBar().setTabTextColor(idx, QColor(color)) self.tabs.tabBar().setTabTextColor(idx, QColor(color))

Loading…
Cancel
Save