diff --git a/qmutants.py b/qmutants.py index 6a93f81..4a94855 100644 --- a/qmutants.py +++ b/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("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) + 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: 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"] +#cure_path = ["done","tra 2000","north","north","north","north","cure me","!return","done"] + help_list = ["$ - Key listener on/off", "8 - North", "2 - South", @@ -109,7 +111,9 @@ class mutant(QWidget): command_str = pyqtSignal(str) mqtt_str = pyqtSignal(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): QWidget.__init__(self) self.player=player @@ -153,6 +157,8 @@ class mutant(QWidget): self.watchdog = 0 self.cmd_watchdog = 0 self.prompt = False + self.poisoned = False + self.current_path = "" #value tracking self.riblets = 0 @@ -162,6 +168,7 @@ class mutant(QWidget): self.clss = "Thief" self.level = 0 self.riblet_thresh = 200000 + self.ion_thresh = 2000000 self.farm_year=2000 self.year_limit=2500 self.no_action_cnt = 0 @@ -169,6 +176,7 @@ class mutant(QWidget): self.status = "" self.area = "" self.console_lines = 0 + self.min_riblets = 6000000 #account self.user = player.usr @@ -255,6 +263,19 @@ class mutant(QWidget): #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): if self.prompt: self.command_str.emit(cmd_str) @@ -440,6 +461,7 @@ class mutant(QWidget): def p_btn(self): self.send_cmd("stat\r\n") + self.current_path = self.bank_list[self.selected_path][:] self.path_step = 1 def l_btn(self): @@ -467,7 +489,8 @@ class mutant(QWidget): # end of file is reached if not in_str: break - + self.current_path = self.bank_list[0][:] + #Button send text def send_str(self): self.send_cmd(self.text_input.text()+"\r\n") @@ -587,13 +610,13 @@ class mutant(QWidget): for item_l in self.local_items: for item in farm_sell_list: 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.local_items.remove(item_l) self.sell_list.append(item_l) - print(self.sell_list) + #print(self.sell_list) self.no_action_cnt = 0 #Farms valuable stuff @@ -608,7 +631,7 @@ class mutant(QWidget): #Sell items def sell_items(self): - print(self.sell_list) + #print(self.sell_list) while len(self.sell_list) > 0: item_l=self.sell_list[0] self.sell_list.pop(0) @@ -618,15 +641,15 @@ class mutant(QWidget): #Stock def stock_items(self): - print(self.stock_list) + #print(self.stock_list) for item_s in farm_stock_list: for item in self.stock_list: if item == item_s: cnt = self.stock_list.count(item) - print("item count: "+str(cnt)) + #print("item count: "+str(cnt)) if item == self.weapon: cnt = cnt - 1 - print("sub weapon count: "+str(cnt)) + #print("sub weapon count: "+str(cnt)) for x in range(cnt): self.send_cmd("stock "+item+"\r\n") self.stock_list.remove(item) @@ -741,7 +764,8 @@ class mutant(QWidget): #process path 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[0] == "!": self.script_function(path_str.strip("!").upper()) @@ -754,14 +778,17 @@ class mutant(QWidget): #handle functions in path script def script_function(self,function): - if function == "DEPOSIT": - self.send_cmd("deposit "+str(self.riblets)+"\r\n") + if function == "DEPOSIT": + 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.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: self.stock_items() @@ -776,7 +803,12 @@ class mutant(QWidget): if new_path == len(self.bank_list): new_path = 0 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 def parse_stat(self, result): if self.stat_parsed == False: @@ -791,9 +823,9 @@ class mutant(QWidget): if result.find(">") != -1: #Retally items, convert extras 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.stock_list = [] self.watchdog = 0 @@ -804,7 +836,7 @@ class mutant(QWidget): self.sell_list.append(item_l) else: self.send_cmd("con "+item_l+"\r\n") - print(self.sell_list) + #print(self.sell_list) for item_l in farm_stock_list: x = self.status.count(item_l) for i in range(x): @@ -902,8 +934,14 @@ class mutant(QWidget): pass year_str = year_str[:end_index] #print("Year:" + year_str) + #If meandering try to stay in sync with farming year, otherwise not 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: pass self.status = "" @@ -989,6 +1027,16 @@ class mutant(QWidget): 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 def player_init(self): self.in_combat=False @@ -1123,8 +1171,9 @@ class mutant(QWidget): self.index_area(result) #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.current_path = self.bank_list[self.selected_path][:] self.path_step = 1 #process wander @@ -1184,7 +1233,15 @@ class mutant(QWidget): if (result.find("City Trading Centre") != -1 or result.find("Satan Inc. Trade Centre") != -1) and self.path_step == 0 and not self.in_combat: if len(self.sell_list) > 0: 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 if result.find("stat") != -1: self.stat_parsed = False @@ -1196,6 +1253,24 @@ class mutant(QWidget): #Turn on healing if result.find("You suffer") != -1 or result.find("You are poisoned!") != -1: 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 if (result.find("yells: Gimmie") != -1 or @@ -1556,6 +1631,8 @@ class telnet_thread(QObject): class MainWindow(QMainWindow): keyPressed = pyqtSignal(int) + bcast = pyqtSignal(list) + def __init__(self): super(MainWindow, self).__init__() 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_quiet.connect(self.send_mqtt_quiet) 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.setLayout(mutbox) self.tabs.addTab(tab,player.usr) @@ -1606,6 +1685,9 @@ class MainWindow(QMainWindow): self.text_button.clicked.connect(self.send_str) self.formGroupBox.addRow(self.text_button,self.text_input) self.layout.addLayout(self.formGroupBox) + + def broadcast(self,request): + self.bcast.emit(request) def color_tab(self,idx,color): self.tabs.tabBar().setTabTextColor(idx, QColor(color))