You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1355 lines
47 KiB
1355 lines
47 KiB
from PyQt5.QtGui import *
|
|
from PyQt5.QtWidgets import *
|
|
from PyQt5.QtCore import *
|
|
|
|
import os
|
|
import getpass
|
|
import telnetlib
|
|
import re
|
|
import time
|
|
import keyboard
|
|
import random
|
|
import sys
|
|
import paho.mqtt.client as mqtt
|
|
|
|
HOST = "telnet.goldenunicorn.net"
|
|
|
|
#usr_1 = "epilectrik"
|
|
#pwrd_1 = "gupass"
|
|
|
|
#usr_2 = "im bait"
|
|
#pwrd_2 = "gupass"
|
|
|
|
usr_1 = "Mtron"
|
|
pwrd_1 = "gupass"
|
|
|
|
usr_2 = "IonJunkies-Merc"
|
|
pwrd_2 = "gupass"
|
|
|
|
|
|
#this is a thing that i wrote
|
|
#static lists
|
|
convert_list = ["Ion-Pack","Ion-Decay","Cheese","Nuclear-thong","Skull","Bottle-Cap","Cigarette-Butt","Knife","Gas-Grenade","Leather-Vest","Buckler","Bola","Bug-Plate",
|
|
"Light-Spear","Silver-Potion","Bastard-Sword","Invisible-Knife","Great-Club","Spear","Blizzard-Staff","Devil_Key","Grey-Dagger","Bone","Axe","BlackJack",
|
|
"Golden-Key","Crystal-Key","Trident","Ice-Knife","Iron-Sickle","Gold-Spear","Fang-Dagger","Hound-Fang","Pink-Potion","Small-Dagger","Mage-Stick","Purple-Potion",
|
|
"Tree-Branch","Poker","Bronze Knife","Small-Club","Wonderous-Sword","Spell-Potion","Long-Sword","Ion-Gauntlet","Sling-Sword","Small-Spear","Iron-Mace","Iron-Boots",
|
|
"Tree-Stump","Saphire","Flame-Sword","Rock-Club","Lava-Dagger","Bloody-Arm","Golden-Needle","Ion-Booster","Devil-Key","Chain-Mail","Weak-Cloth","Splint-Mail","Rags",
|
|
"Bug-Skin","Troll-Sword","Axe","Plate-Mail","Common-Hide","Kelp-Mail"]
|
|
|
|
farm_sell_list = ["Gold-Chunck","Nuclear-Rock","Nuclear-Waste"]
|
|
|
|
farm_stock_list = ["Nuclear-Decay","Troll-Skin","Invisible-Cloth","Green-Vial","Hell-Blade"]
|
|
|
|
friend_list = ["Epilectrik","ImBait","Mtron","Im","IonJunkies-Merc"]
|
|
|
|
help_list = ["$ - Key listener on/off",
|
|
"8 - North",
|
|
"2 - South",
|
|
"6 - East",
|
|
"4 - West",
|
|
"5 - Look direction",
|
|
"c - Combat",
|
|
"w - Wield weapon",
|
|
"a - Auto combat on/off",
|
|
"f - Auto farm on/off",
|
|
"i - Auto Ion on/off",
|
|
"t - time travel",
|
|
"d - drop item",
|
|
"k - keyboard input",
|
|
"v - status",
|
|
"m - meander"
|
|
]
|
|
|
|
opposite_dir = {
|
|
"north":"south",
|
|
"south":"north",
|
|
"east":"west",
|
|
"west":"east",
|
|
}
|
|
|
|
#Heater popup window
|
|
class mutant(QWidget):
|
|
command_str = pyqtSignal(str)
|
|
mqtt_str = pyqtSignal(str)
|
|
|
|
def __init__(self,user,password):
|
|
QWidget.__init__(self)
|
|
#file related
|
|
self.path=user
|
|
|
|
#dynamic lists
|
|
self.local_items = []
|
|
self.local_monsters = []
|
|
self.direction_list = []
|
|
self.sell_list = []
|
|
self.stock_list = []
|
|
self.bank_list = []
|
|
|
|
#modes
|
|
self.heal = False
|
|
self.wander = False
|
|
self.bait = False
|
|
self.auto_combat = True
|
|
self.auto_ion = False
|
|
self.auto_farm = False
|
|
self.key_detect = False
|
|
|
|
#states
|
|
self.time_steps = 0
|
|
self.in_combat = False
|
|
self.hits = 0
|
|
self.lock_key="["
|
|
self.area_indexed = True
|
|
self.stat_parsed = True
|
|
self.previous_dir = ""
|
|
self.selected_path = 0
|
|
self.path_step = 0
|
|
self.location = [0,0]
|
|
|
|
#value tracking
|
|
self.riblets = 0
|
|
self.riblet_thresh = 200000
|
|
self.farm_year=2000
|
|
self.year_limit=2500
|
|
self.no_action_cnt = 0
|
|
self.na_thresh = 50
|
|
self.status = ""
|
|
self.area = ""
|
|
|
|
#account
|
|
self.user = user
|
|
self.password = password
|
|
self.logged_in = False
|
|
|
|
#timers
|
|
|
|
#healing
|
|
self.heal_timer = QTimer()
|
|
self.heal_timer.setInterval(1000)
|
|
self.heal_timer.timeout.connect(self.heal_trig)
|
|
self.heal_timer.start()
|
|
#wielding
|
|
self.wield_timer = QTimer()
|
|
self.wield_timer.setInterval(200)
|
|
self.wield_timer.timeout.connect(self.wield_trig)
|
|
self.wield_timer.start()
|
|
#wander
|
|
self.wander_timer = QTimer()
|
|
self.wander_timer.setInterval(500)
|
|
self.wander_timer.timeout.connect(self.wander_trig)
|
|
self.wander_timer.start()
|
|
#stat
|
|
self.stat_timer = QTimer()
|
|
self.stat_timer.setInterval(30000)
|
|
self.stat_timer.timeout.connect(self.stat_trig)
|
|
self.stat_timer.start()
|
|
#path
|
|
self.path_timer = QTimer()
|
|
self.path_timer.setInterval(100)
|
|
self.path_timer.timeout.connect(self.path_trig)
|
|
self.path_timer.start()
|
|
|
|
#layout stuff
|
|
self.layout = QVBoxLayout()
|
|
|
|
# Add console
|
|
self.console = QTextEdit()
|
|
self.console.setTextColor(QColor(255, 255, 255))
|
|
self.console.setStyleSheet("QTextEdit { color: white; background-color: rgb(0, 0, 0); font-size: 18px; }")
|
|
self.console.clear()
|
|
self.console.append("test")
|
|
self.layout.addWidget(self.console)
|
|
|
|
#Add buttons
|
|
self.button_group()
|
|
|
|
# Add text input
|
|
self.formGroupBox = QFormLayout()
|
|
self.text_input = QLineEdit()
|
|
self.text_button = QPushButton("Send")
|
|
self.text_button.clicked.connect(self.send_str)
|
|
self.formGroupBox.addRow(self.text_button,self.text_input)
|
|
self.layout.addLayout(self.formGroupBox)
|
|
|
|
#mode group
|
|
self.createModeGroup()
|
|
self.layout.addLayout(self.mode_layout)
|
|
|
|
#settings group
|
|
self.createSettingsGroup()
|
|
self.layout.addLayout(self.settingsGroupBox)
|
|
|
|
self.setLayout(self.layout)
|
|
self.load_bank_paths()
|
|
self.init_telnet()
|
|
|
|
def init_telnet(self):
|
|
|
|
#init telnet thread
|
|
self.tn_obj = telnet_thread()
|
|
self.tn_thread = QThread()
|
|
self.tn_obj.moveToThread(self.tn_thread)
|
|
|
|
#Connect signals
|
|
self.tn_thread.started.connect(self.tn_obj.telnet_listen)
|
|
self.tn_obj.received.connect(self.execute_loop)
|
|
self.command_str.connect(self.tn_obj.tn_write)
|
|
self.tn_obj.disconnected.connect(self.reconnect)
|
|
#start thread
|
|
self.tn_thread.start()
|
|
|
|
def reconnect(self):
|
|
self.logged_in = False
|
|
print("obj restarting")
|
|
#create buttons
|
|
def button_group(self):
|
|
hbox1 = QHBoxLayout()
|
|
b_grid = QGridLayout()
|
|
button_w = 50
|
|
north_button = QPushButton("North")
|
|
south_button = QPushButton("South")
|
|
east_button = QPushButton("East")
|
|
west_button = QPushButton("West")
|
|
heal_button = QPushButton("Heal")
|
|
combat_button = QPushButton("Combat")
|
|
path_button = QPushButton("Path")
|
|
look_button = QPushButton("Look")
|
|
stat_button = QPushButton("Stat")
|
|
|
|
b_grid.addWidget(north_button,0,1)
|
|
b_grid.addWidget(south_button,2,1)
|
|
b_grid.addWidget(east_button,1,2)
|
|
b_grid.addWidget(west_button,1,0)
|
|
b_grid.addWidget(heal_button,0,0)
|
|
b_grid.addWidget(combat_button,0,2)
|
|
b_grid.addWidget(path_button,2,0)
|
|
b_grid.addWidget(look_button,1,1)
|
|
b_grid.addWidget(stat_button,2,2)
|
|
|
|
hbox1.addItem(QSpacerItem(150, 0, QSizePolicy.Minimum))
|
|
hbox1.addLayout(b_grid)
|
|
hbox1.addItem(QSpacerItem(150, 0, QSizePolicy.Minimum))
|
|
|
|
north_button.clicked.connect(self.n_btn)
|
|
south_button.clicked.connect(self.s_btn)
|
|
east_button.clicked.connect(self.e_btn)
|
|
west_button.clicked.connect(self.w_btn)
|
|
heal_button.clicked.connect(self.h_btn)
|
|
combat_button.clicked.connect(self.c_btn)
|
|
path_button.clicked.connect(self.p_btn)
|
|
look_button.clicked.connect(self.l_btn)
|
|
stat_button.clicked.connect(self.st_btn)
|
|
|
|
self.layout.addLayout(hbox1)
|
|
|
|
#Creates the form groupbox
|
|
def createModeGroup(self):
|
|
self.mode_layout = QVBoxLayout()
|
|
hbox1 = QHBoxLayout()
|
|
hbox2 = QHBoxLayout()
|
|
self.ac_check = QCheckBox("Auto Combat")
|
|
self.ac_check.setChecked(True)
|
|
self.af_check = QCheckBox("Auto Farm")
|
|
self.ai_check = QCheckBox("Auto Ion")
|
|
self.me_check = QCheckBox("Meander")
|
|
self.ba_check = QCheckBox("Bait")
|
|
|
|
self.ac_check.stateChanged.connect(self.ac_checked)
|
|
self.af_check.stateChanged.connect(self.af_checked)
|
|
self.ai_check.stateChanged.connect(self.ai_checked)
|
|
self.me_check.stateChanged.connect(self.me_checked)
|
|
self.ba_check.stateChanged.connect(self.ba_checked)
|
|
|
|
hbox1.addWidget(self.ac_check)
|
|
hbox1.addWidget(self.af_check)
|
|
hbox1.addWidget(self.ba_check)
|
|
hbox2.addWidget(self.ai_check)
|
|
hbox2.addWidget(self.me_check)
|
|
hbox2.addWidget(self.ba_check)
|
|
|
|
self.mode_layout.addLayout(hbox1)
|
|
self.mode_layout.addLayout(hbox2)
|
|
|
|
def createSettingsGroup(self):
|
|
self.settingsGroupBox = QFormLayout()
|
|
self.fy_input = QLineEdit("2000")
|
|
self.na_input = QLineEdit("50")
|
|
self.yl_input = QLineEdit("2300")
|
|
self.path_input = QLineEdit("0")
|
|
|
|
self.settingsGroupBox.addRow(QLabel("Farm Year:"),self.fy_input)
|
|
self.settingsGroupBox.addRow(QLabel("No Action:"),self.na_input)
|
|
self.settingsGroupBox.addRow(QLabel("Year Limit:"),self.yl_input)
|
|
self.settingsGroupBox.addRow(QLabel("Path:"),self.path_input)
|
|
|
|
#buttons
|
|
def n_btn(self):
|
|
self.command_str.emit("north\r\n")
|
|
|
|
def s_btn(self):
|
|
self.command_str.emit("south\r\n")
|
|
|
|
def e_btn(self):
|
|
self.command_str.emit("east\r\n")
|
|
|
|
def w_btn(self):
|
|
self.command_str.emit("west\r\n")
|
|
|
|
def h_btn(self):
|
|
self.heal = True
|
|
|
|
def c_btn(self):
|
|
self.combat_start()
|
|
|
|
def p_btn(self):
|
|
self.path_step=1
|
|
|
|
def l_btn(self):
|
|
self.command_str.emit("look\r\n")
|
|
|
|
def st_btn(self):
|
|
self.command_str.emit("stat\r\n")
|
|
|
|
#load bank file
|
|
def load_bank_paths(self):
|
|
file = "./"+self.path+"/banks.txt"
|
|
if (os.path.exists(self.path) == False):
|
|
os.makedirs(self.path)
|
|
f = open(file, "x")
|
|
print("creating "+file)
|
|
else:
|
|
print("File Exists")
|
|
with open(file, 'r') as script:
|
|
while True:
|
|
in_str = script.readline().strip()
|
|
if in_str != "":
|
|
self.bank_list.append(in_str.split(","))
|
|
# end of file is reached
|
|
if not in_str:
|
|
break
|
|
|
|
#Button send text
|
|
def send_str(self):
|
|
self.command_str.emit(self.text_input.text()+"\r\n")
|
|
|
|
#auto combat checked
|
|
def ac_checked(self):
|
|
self.auto_combat = self.ac_check.isChecked()
|
|
print("Auto Combat: "+str(self.auto_combat))
|
|
|
|
#auto farm checked
|
|
def af_checked(self):
|
|
self.auto_farm = self.af_check.isChecked()
|
|
print("Auto farm: "+str(self.auto_farm))
|
|
|
|
#auto ion checked
|
|
def ai_checked(self):
|
|
self.auto_ion = self.ai_check.isChecked()
|
|
print("Auto ion: "+str(self.auto_ion))
|
|
|
|
#meander checked
|
|
def me_checked(self):
|
|
self.wander = self.me_check.isChecked()
|
|
print("Wander: "+str(self.wander))
|
|
|
|
#meander checked
|
|
def ba_checked(self):
|
|
self.bait = self.ba_check.isChecked()
|
|
print("Bait: "+str(self.bait))
|
|
|
|
#heal timer
|
|
def heal_trig(self):
|
|
if self.heal:
|
|
self.command_str.emit("heal\r\n")
|
|
|
|
#wield timer
|
|
def wield_trig(self):
|
|
if self.in_combat:
|
|
self.command_str.emit("wie nuclear-decay\r\n")
|
|
|
|
#wander timer
|
|
def wander_trig(self):
|
|
if self.wander and not self.in_combat and self.path_step == 0:
|
|
self.area_indexed = False
|
|
self.local_monsters = []
|
|
self.local_items = []
|
|
print("wander triggered")
|
|
print("no action: " + str(self.no_action_cnt))
|
|
#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")
|
|
|
|
#pick randomly
|
|
if len(self.direction_list) > 0:
|
|
if len(self.direction_list) > 1:
|
|
try:
|
|
self.direction_list.remove(self.previous_dir)
|
|
except:
|
|
pass
|
|
#print(self.direction_list)
|
|
dir_choice = random.choice(self.direction_list)
|
|
try:
|
|
if dir_choice == "north":
|
|
self.location[1] = self.location[1] + 1
|
|
if dir_choice == "south":
|
|
self.location[1] = self.location[1] - 1
|
|
if dir_choice == "east":
|
|
self.location[0] = self.location[0] + 1
|
|
if dir_choice == "west":
|
|
self.location[0] = self.location[0] - 1
|
|
except:
|
|
pass
|
|
|
|
self.command_str.emit(dir_choice+"\r\n")
|
|
self.direction_list = []
|
|
self.previous_dir = opposite_dir[dir_choice]
|
|
|
|
#stat timer
|
|
def stat_trig(self):
|
|
if not self.in_combat and self.path_step ==0:
|
|
self.command_str.emit("stat\r\n")
|
|
self.command_str.emit("look\r\n")
|
|
|
|
#path timer
|
|
def path_trig(self):
|
|
if not self.in_combat:
|
|
self.path_process()
|
|
|
|
#search a list
|
|
def search(self, list, platform):
|
|
for i in range(len(list)):
|
|
if list[i] == platform:
|
|
return True
|
|
return False
|
|
|
|
#Reup Ions
|
|
def convert_items(self):
|
|
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")
|
|
try:
|
|
self.local_items.remove(item_l)
|
|
except:
|
|
pass
|
|
|
|
#Farms valuable stuff
|
|
def farm_sell_items(self):
|
|
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.local_items.remove(item_l)
|
|
self.sell_list.append(item_l)
|
|
self.no_action_cnt = 0
|
|
|
|
#Farms valuable stuff
|
|
def farm_stock_items(self):
|
|
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.local_items.remove(item_l)
|
|
self.stock_list.append(item_l)
|
|
self.no_action_cnt = 0
|
|
|
|
#Sell items
|
|
def sell_items(self):
|
|
print(self.sell_list)
|
|
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")
|
|
time.sleep(.25)
|
|
|
|
#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(.25)
|
|
|
|
#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.stock_list.remove("Monster-Bait")
|
|
|
|
#Remove friends from monster list
|
|
def remove_friends(self):
|
|
for friend in friend_list:
|
|
try:
|
|
self.local_monsters.remove(friend)
|
|
except:
|
|
pass
|
|
|
|
#Flushes keyboard
|
|
def flush_input(self):
|
|
try:
|
|
import msvcrt
|
|
while msvcrt.kbhit():
|
|
msvcrt.getch()
|
|
except ImportError:
|
|
import sys, termios
|
|
termios.tcflush(sys.stdin, termios.TCIOFLUSH)
|
|
|
|
#Decode incoming information
|
|
def decode_line(self,line):
|
|
result = ""
|
|
if line.decode('cp1252') != "":
|
|
ansi_escape = re.compile(r'\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])')
|
|
result = ansi_escape.sub('', line.decode('cp1252').strip('\n'))
|
|
self.console.append(result)
|
|
return result
|
|
|
|
#initiate combat
|
|
def combat_start(self):
|
|
try:
|
|
self.command_str.emit("combat " + self.local_monsters[0]+"\r\n")
|
|
except:
|
|
pass
|
|
self.in_combat = True
|
|
self.heal = True
|
|
self.wield_trig()
|
|
self.path_step = 0
|
|
self.no_action_cnt = 0
|
|
|
|
#process wander
|
|
def wander_process(self, result):
|
|
#area clear
|
|
if result.find("north - area continues.") != -1 or result.find("north - open gate.") != -1:
|
|
self.direction_list.append("north")
|
|
if result.find("south - area continues.") != -1 or result.find("south - open gate.") != -1:
|
|
self.direction_list.append("south")
|
|
if result.find("east - area continues.") != -1 or result.find("east - open gate.") != -1:
|
|
self.direction_list.append("east")
|
|
if result.find("west - area continues.") != -1 or result.find("west - open gate.") != -1:
|
|
self.direction_list.append("west")
|
|
|
|
#are there monsters
|
|
if result.find("You see shadows to the") != -1:
|
|
try:
|
|
if result.find("north") != -1:
|
|
self.direction_list.remove("north")
|
|
if result.find("south") != -1:
|
|
self.direction_list.remove("south")
|
|
if result.find("east") != -1:
|
|
self.direction_list.remove("east")
|
|
if result.find("west") != -1:
|
|
self.direction_list.remove("west")
|
|
except:
|
|
pass
|
|
|
|
#process combat per loop
|
|
def combat_process(self, result):
|
|
if result.find("You suffer") != -1:
|
|
self.hits = self.hits + 1
|
|
if self.hits == 2:
|
|
self.command_str.emit("heal\r\n")
|
|
self.command_str.emit("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:
|
|
try:
|
|
self.local_monsters.pop(0)
|
|
except:
|
|
pass
|
|
if len(self.local_monsters) > 0:
|
|
self.command_str.emit("combat " + self.local_monsters[0]+"\r\n")
|
|
else:
|
|
#print("Area cleared")
|
|
self.in_combat = False
|
|
|
|
#time travel
|
|
def time_travel(self):
|
|
self.local_items = []
|
|
self.location = [0,0]
|
|
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.drop_baits()
|
|
if self.bait and not self.stock_list.count("Monster-Bait"):
|
|
self.command_str.emit("get Monster-Bait\r\n")
|
|
self.stock_list.append("Monster-Bait")
|
|
self.command_str.emit("look\r\n")
|
|
|
|
#process path
|
|
def path_process(self):
|
|
path_str = self.bank_list[self.selected_path][self.path_step]
|
|
if path_str != "done":
|
|
if path_str[0] == "!":
|
|
self.script_function(path_str.strip("!").upper())
|
|
else:
|
|
self.command_str.emit(path_str+"\r\n")
|
|
self.path_step = self.path_step + 1
|
|
self.no_action_cnt = 0
|
|
else:
|
|
self.path_step = 0
|
|
|
|
#handle functions in path script
|
|
def script_function(self,function):
|
|
if function == "DEPOSIT":
|
|
self.command_str.emit("deposit "+str(self.riblets)+"\r\n")
|
|
self.riblets = 0
|
|
if function == "STOCK":
|
|
self.stock_items()
|
|
|
|
if function == "SELL":
|
|
self.sell_items()
|
|
|
|
if function == "RETURN":
|
|
self.path_step = -1
|
|
self.command_str.emit("tra "+str(self.farm_year)+"\r\n")
|
|
new_path = self.selected_path + 1
|
|
if new_path == len(self.bank_list):
|
|
new_path = 0
|
|
self.path_input.setText(str(new_path))
|
|
|
|
|
|
#process stats
|
|
def parse_stat(self, result):
|
|
if self.stat_parsed == False:
|
|
self.sell_list = []
|
|
self.stock_list = []
|
|
self.status += result
|
|
if result.find(">") != -1:
|
|
self.stat_parsed = True
|
|
|
|
if self.stat_parsed and self.status != "":
|
|
for item_l in farm_sell_list:
|
|
x = self.status.count(item_l)
|
|
for i in range(x):
|
|
self.sell_list.append(item_l)
|
|
|
|
for item_l in farm_stock_list:
|
|
x = self.status.count(item_l)
|
|
for i in range(x):
|
|
self.stock_list.append(item_l)
|
|
|
|
#scrape riblets
|
|
if self.status.find("Riblets :") != -1:
|
|
start_index = self.status.index('Riblets : ') + 16
|
|
riblets_str = self.status[start_index:]
|
|
try:
|
|
end_index = riblets_str.index('Ions')
|
|
except:
|
|
pass
|
|
|
|
riblets_str = riblets_str[:end_index]
|
|
#print("Riblets:" + riblets_str)
|
|
try:
|
|
self.riblets = int(riblets_str)
|
|
except:
|
|
pass
|
|
|
|
#scrape year
|
|
if self.status.find("Year A.D. :") != -1:
|
|
start_index = self.status.index('Year A.D. : ') + 17
|
|
year_str = self.status[start_index:]
|
|
try:
|
|
end_index = 4
|
|
except:
|
|
pass
|
|
year_str = year_str[:end_index]
|
|
#print("Year:" + year_str)
|
|
self.farm_year = int(year_str)
|
|
|
|
|
|
self.status = ""
|
|
#print("sell list")
|
|
#print(self.sell_list)
|
|
#print("stock list")
|
|
#print(self.stock_list)
|
|
|
|
#index area
|
|
def index_area(self,result):
|
|
if self.area_indexed == False:
|
|
self.area += result
|
|
if result.find(">") != -1:
|
|
self.area_indexed = True
|
|
|
|
if self.area_indexed and self.area != "":
|
|
if self.area.find("On the ground lies:") != -1:
|
|
start_index = self.area.index('On the ground lies:')
|
|
item_str = self.area[start_index:]
|
|
try:
|
|
end_index = item_str.index('***')
|
|
except:
|
|
try:
|
|
end_index = item_str.index('>')
|
|
except:
|
|
pass
|
|
item_str = item_str[:end_index]
|
|
item_str = item_str.replace("On the ground lies:","")
|
|
item_str = item_str.replace("0","")
|
|
item_str = item_str.replace("1","")
|
|
item_str = item_str.replace("2","")
|
|
item_str = item_str.replace("3","")
|
|
item_str = item_str.replace("4","")
|
|
item_str = item_str.replace("5","")
|
|
item_str = item_str.replace("6","")
|
|
item_str = item_str.replace("7","")
|
|
item_str = item_str.replace("8","")
|
|
item_str = item_str.replace("9","")
|
|
item_str = item_str.replace("(","")
|
|
item_str = item_str.replace(")","")
|
|
item_str = item_str.replace("A ","")
|
|
item_str = item_str.replace("An ","")
|
|
item_str = item_str.replace(" ","")
|
|
item_str = item_str.replace(".","")
|
|
item_str = item_str.replace("\r\n","")
|
|
item_str = item_str.replace("***","")
|
|
self.local_items = list(item_str.split(","))
|
|
#print(self.local_items)
|
|
|
|
if self.area.find("is here") != -1 or self.area.find("are here") != -1:
|
|
try:
|
|
end_index = self.area.index('here')
|
|
monster_str = self.area[:end_index]
|
|
start_index = monster_str.rindex('***')
|
|
monster_str = monster_str[start_index:]
|
|
monster_str = monster_str.replace("\r\n","")
|
|
monster_str = monster_str.replace(" and ","")
|
|
monster_str = monster_str.replace(" are ","")
|
|
monster_str = monster_str.replace(" is ","")
|
|
monster_str = monster_str.replace(" ","")
|
|
monster_str = monster_str.replace(".","")
|
|
monster_str = monster_str.replace("***","")
|
|
self.local_monsters = list(monster_str.split(","))
|
|
self.remove_friends()
|
|
#print(self.local_monsters)
|
|
except:
|
|
pass
|
|
|
|
self.area = ""
|
|
|
|
#Main game loop
|
|
def mutants(self,result):
|
|
#update farm year text box
|
|
try:
|
|
self.fy_input.setText(str(self.farm_year))
|
|
self.na_thresh = int(self.na_input.text())
|
|
self.year_limit = int(self.yl_input.text())
|
|
self.selected_path = int(self.path_input.text())
|
|
except:
|
|
pass
|
|
|
|
#Nothing has happened in a while, time jump
|
|
if self.no_action_cnt > self.na_thresh:
|
|
self.time_travel()
|
|
self.no_action_cnt = 0
|
|
#New area, take a look
|
|
|
|
#New area, set index, get location
|
|
if result.find("Compass:") != -1:
|
|
res_filter = result.replace("Compass:","")
|
|
res_filter = res_filter.replace("Compass:","")
|
|
res_filter = res_filter.replace("N","")
|
|
res_filter = res_filter.replace("E","")
|
|
res_filter = res_filter.replace(":",",")
|
|
res_filter = res_filter.replace("(","")
|
|
res_filter = res_filter.replace(")","")
|
|
res_filter = res_filter.replace(" ","")
|
|
try:
|
|
self.location = list(map(int, res_filter.split(",")))
|
|
except:
|
|
print('location failed')
|
|
#print(self.location)
|
|
self.area_indexed = False
|
|
|
|
#drop baits
|
|
if self.location == [0,0]:
|
|
self.drop_baits()
|
|
|
|
#too many baits
|
|
if self.stock_list.count("Monster-Bait") > 3:
|
|
self.command_str.emit("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.stock_list.remove("Nuclear-Decay")
|
|
#print(self.stock_list)
|
|
|
|
#parse status
|
|
self.parse_stat(result)
|
|
|
|
#index area
|
|
self.index_area(result)
|
|
|
|
#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)
|
|
|
|
#process combat
|
|
if self.in_combat:
|
|
self.combat_process(result)
|
|
|
|
#scrapers
|
|
if result.find("(N)onstop, (Q)uit, or (C)ontinue?") != -1:
|
|
self.command_str.emit("C\r\n")
|
|
|
|
#ion starvation
|
|
if result.find("You're starving for IONS!") != -1:
|
|
self.command_str.emit("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")
|
|
|
|
#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
|
|
|
|
#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")
|
|
|
|
#Detect bait mode, add or remove from stock list
|
|
if self.bait:
|
|
if not farm_stock_list.count("Monster-Bait"):
|
|
farm_stock_list.append("Monster-Bait")
|
|
else:
|
|
try:
|
|
farm_stock_list.remove("Monster-Bait")
|
|
except:
|
|
pass
|
|
|
|
#Exit game if..
|
|
if self.in_combat and result.find("You're not carrying a nuclear-decay.") != -1:
|
|
self.command_str.emit("x\r\n")
|
|
|
|
#GTFO
|
|
if self.wander and (((result.find("It's too dark to see anything!") != -1 and self.path_step == 0) or
|
|
result.find("You're blocked!") != -1) or
|
|
len(self.local_monsters) > 4):
|
|
|
|
self.heal = True
|
|
local_monsters = []
|
|
|
|
self.command_str.emit("tra "+str(self.farm_year)+"\r\n")
|
|
self.in_combat = False
|
|
|
|
#Sell the loot
|
|
if result.find("City Trading Centre") != -1 and self.path_step == 0:
|
|
if len(self.sell_list) > 0:
|
|
self.sell_items()
|
|
|
|
#Parse character status
|
|
if result.find("stat") != -1:
|
|
self.stat_parsed = False
|
|
|
|
#Trigger stop healing
|
|
if result.find("Nothing happens!") != -1 or result.find("You don't have enough ions to heal!") != -1:
|
|
self.heal = False
|
|
|
|
#Turn on healing
|
|
if result.find("You suffer") != -1 or result.find("You are poisoned!") != -1:
|
|
self.heal = True
|
|
|
|
#Monster list related
|
|
if (result.find("yells: Gimmie") != -1 or
|
|
result.find("just arrived from") != -1 or
|
|
result.find("has hit") != -1 or
|
|
result.find("body is glowing") != -1 or
|
|
result.find("Get away from me") != -1 or
|
|
result.find("just appeared through a time portal!") != -1):
|
|
m = result.index(' ')
|
|
monster = result[:m]
|
|
if not self.search(self.local_monsters, monster):
|
|
self.local_monsters.append(monster)
|
|
self.remove_friends()
|
|
#print(self.local_monsters)
|
|
if len(self.local_monsters) > 0 and self.auto_combat and not self.in_combat:
|
|
self.combat_start()
|
|
|
|
#Monster took off, remove from list
|
|
if result.find("has just left") != -1:
|
|
end_index = result.index(' has')
|
|
mon_str = result[:end_index]
|
|
mon_str = mon_str.replace(" ","")
|
|
try:
|
|
self.local_monsters.remove(mon_str)
|
|
except:
|
|
pass
|
|
#print(mon_str)
|
|
#print(self.local_monsters)
|
|
|
|
#Monster died, remove from list
|
|
if result.find("is crumbling to dust") != -1:
|
|
end_index = result.index(' is')
|
|
mon_str = result[:end_index]
|
|
mon_str = mon_str.replace(" ","")
|
|
try:
|
|
self.local_monsters.remove(mon_str)
|
|
except:
|
|
pass
|
|
#print(mon_str)
|
|
#print(self.local_monsters)
|
|
|
|
#Someone picked something up, remove from item list
|
|
if result.find("picked up the") != -1:
|
|
start_index = result.index('the') + 4
|
|
item_str = result[start_index:]
|
|
end_index = item_str.index('.')
|
|
item_str = item_str[:end_index]
|
|
item_str = item_str.replace(" ","")
|
|
try:
|
|
self.local_items.remove(item_str)
|
|
except:
|
|
pass
|
|
#print(item_str)
|
|
#print(self.local_items)
|
|
|
|
#Dead person dropping stuff, add to local list
|
|
if result.find("is falling from") != -1:
|
|
try:
|
|
start_index = result.index('A')
|
|
item_str = result[start_index:]
|
|
end_index = item_str.index('is')
|
|
item_str = item_str[:end_index]
|
|
item_str = item_str.replace(" ","")
|
|
item_str = item_str.replace("is","")
|
|
item_str = item_str.replace("An","")
|
|
item_str = item_str.replace("A","")
|
|
self.local_items.append(item_str)
|
|
except:
|
|
print("Monster item drop error")
|
|
print(result)
|
|
#print(self.local_items)
|
|
|
|
#You died, do some stuff
|
|
if result.find("Select (Bury, 1-5, ?)") != -1:
|
|
self.mqtt_str.emit(self.user+" has died")
|
|
print("MQTT signal emitted")
|
|
self.in_combat=False
|
|
self.heal = False
|
|
self.wander = False
|
|
self.auto_farm = False
|
|
self.auto_combat = False
|
|
self.ac_check.setChecked(False)
|
|
self.af_check.setChecked(False)
|
|
self.ai_check.setChecked(False)
|
|
self.me_check.setChecked(False)
|
|
|
|
#farm items
|
|
if len(self.local_items) > 0 and not self.in_combat and not self.path_step:
|
|
farm_zero = True
|
|
if self.location == [0,0]:
|
|
farm_zero = False
|
|
if not self.wander:
|
|
farm_zero = True
|
|
|
|
if self.auto_farm and farm_zero:
|
|
self.farm_sell_items()
|
|
self.farm_stock_items()
|
|
if self.auto_ion:
|
|
self.convert_items()
|
|
#print("convert")
|
|
|
|
def process_keys(self, key):
|
|
|
|
#keyboard related - this part sucks
|
|
if key==ord(self.lock_key):
|
|
if self.key_detect:
|
|
self.key_detect = False
|
|
print("Key detect off")
|
|
else:
|
|
self.key_detect = True
|
|
print("Key detect on")
|
|
|
|
if self.key_detect:
|
|
if key==ord("?"):
|
|
for help in help_list:
|
|
print(help)
|
|
|
|
#directions
|
|
if key==ord("8"):
|
|
self.local_monsters = []
|
|
self.local_items = []
|
|
self.command_str.emit("north\r\n")
|
|
|
|
if key==ord("2"):
|
|
self.local_monsters = []
|
|
self.local_items = []
|
|
self.command_str.emit("south\r\n")
|
|
|
|
if key==ord("4"):
|
|
self.local_monsters = []
|
|
self.local_items = []
|
|
self.command_str.emit("west\r\n")
|
|
|
|
if key==ord("6"):
|
|
self.local_monsters = []
|
|
self.local_items = []
|
|
self.command_str.emit("east\r\n")
|
|
|
|
#functions
|
|
if key==ord("a"):
|
|
if self.auto_combat:
|
|
self.auto_combat = False
|
|
print("Auto combat off")
|
|
else:
|
|
self.auto_combat = True
|
|
print("Auto combat on")
|
|
#Auto Ion
|
|
if key==ord("i"):
|
|
if self.auto_ion:
|
|
self.auto_ion = False
|
|
print("Auto ion off")
|
|
else:
|
|
self.auto_ion = True
|
|
print("Auto ion on")
|
|
#Auto farm
|
|
if key==ord("f"):
|
|
if self.auto_farm:
|
|
self.auto_farm = False
|
|
print("Auto farm off")
|
|
else:
|
|
self.auto_farm = True
|
|
print("Auto farm on")
|
|
|
|
#Year limit
|
|
if key==ord("y"):
|
|
self.flush_input()
|
|
st = input("Year limit: ")
|
|
self.year_limit = int(st)
|
|
|
|
#No action threshhold
|
|
if key==ord("n"):
|
|
self.flush_input()
|
|
st = input("No action: ")
|
|
self.na_thresh = int(st)
|
|
|
|
#Start combat
|
|
if key==ord("c"):
|
|
if len(self.local_monsters) > 0:
|
|
combat_start()
|
|
|
|
#look around
|
|
if key==ord("5"):
|
|
self.command_str.emit("look ")
|
|
|
|
#meander status
|
|
if key==ord("m"):
|
|
if self.wander:
|
|
self.wander = False
|
|
print("Meander off")
|
|
else:
|
|
self.wander = True
|
|
print("Meander on")
|
|
self.command_str.emit("look\r\n")
|
|
|
|
#heal
|
|
if key==ord("h"):
|
|
self.command_str.emit("heal\r\n")
|
|
self.heal = True
|
|
|
|
#look around
|
|
if key==ord("l"):
|
|
self.command_str.emit("look\r\n")
|
|
|
|
#stats
|
|
if key==ord("v"):
|
|
self.command_str.emit("stat\r\n")
|
|
|
|
#sell items
|
|
if key==ord("s"):
|
|
self.sell_items()
|
|
|
|
#store path select
|
|
if key==ord("p") and not self.in_combat:
|
|
self.flush_input()
|
|
st = input("Choose path input: ")
|
|
self.selected_path = int(st)
|
|
self.path_step = 1
|
|
self.command_str.emit("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.flush_input()
|
|
|
|
#wield weapon
|
|
if key==ord("w"):
|
|
self.command_str.emit("wie nuclear-decay\r\n")
|
|
|
|
#drop item
|
|
if key==ord("d"):
|
|
self.flush_input()
|
|
#toss = keyboard.read_key()
|
|
st = input("drop item: ")
|
|
drop_item = "drop " + st
|
|
self.command_str.emit(drop_item+"\r\n")
|
|
|
|
#time travel
|
|
if key==ord("t") and not self.in_combat:
|
|
monster_list = []
|
|
self.flush_input()
|
|
#toss = keyboard.read_key()
|
|
st = input("year: ")
|
|
year = "travel " + st
|
|
self.command_str.emit(year+"\r\n")
|
|
|
|
if key==ord("x"):
|
|
pass
|
|
|
|
#login routine
|
|
def login_listener(self, result):
|
|
|
|
if result == "Otherwise type \"new\": ":
|
|
self.command_str.emit(self.user+"\r\n")
|
|
|
|
if result == "Enter your password: ":
|
|
self.command_str.emit(self.password+"\r\n")
|
|
|
|
if result == "(N)onstop, (Q)uit, or (C)ontinue?":
|
|
self.command_str.emit("Q\r\n")
|
|
|
|
if result == "Make your selection (G,T,F,M,S,? for help, or X to exit): ":
|
|
self.command_str.emit("G\r\n")
|
|
self.mqtt_str.emit(self.user+" is online")
|
|
|
|
if result == "help, or X to exit): ":
|
|
self.command_str.emit("C\r\n")
|
|
|
|
if result == "Select (P,I,H,S,W,X,?): ":
|
|
self.command_str.emit("P\r\n")
|
|
|
|
if result == "Select (Bury, 1-5, ?) ":
|
|
self.command_str.emit("4\r\n")
|
|
#self.mutants()
|
|
self.logged_in = True
|
|
|
|
#main game loop
|
|
def execute_loop(self, result):
|
|
self.console.append(result)
|
|
self.console.moveCursor(QTextCursor.End)
|
|
|
|
if self.logged_in == False:
|
|
self.login_listener(result)
|
|
else:
|
|
self.mutants(result)
|
|
|
|
|
|
class telnet_thread(QObject):
|
|
received = pyqtSignal(str)
|
|
disconnected = pyqtSignal()
|
|
|
|
#Init
|
|
def __init__(self):
|
|
QWidget.__init__(self)
|
|
#telnet lib
|
|
self.tn = telnetlib.Telnet()
|
|
self.open_telnet()
|
|
|
|
#Open connection
|
|
def open_telnet(self):
|
|
try:
|
|
self.tn.open(HOST,23)
|
|
print("telnet connected..")
|
|
except:
|
|
print("Connection attempt failed..")
|
|
|
|
#Decode incoming information
|
|
def decode_line(self,line):
|
|
result = ""
|
|
if line.decode('cp1252') != "":
|
|
ansi_escape = re.compile(r'\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])')
|
|
result = ansi_escape.sub('', line.decode('cp1252').strip('\n'))
|
|
return result
|
|
|
|
#Write to telnet object
|
|
def tn_write(self,send_str):
|
|
try:
|
|
self.tn.write(send_str.encode('ascii'))
|
|
except:
|
|
pass
|
|
|
|
#Listen perpetually
|
|
def telnet_listen(self):
|
|
print("listening..")
|
|
while True:
|
|
#data decode
|
|
QApplication.processEvents()
|
|
result = ""
|
|
line = None
|
|
try:
|
|
line = self.tn.read_until(b"\n",0) # Read one line
|
|
result = self.decode_line(line).strip("\r").strip("\n").strip("\b")
|
|
if result != "":
|
|
self.received.emit(result)
|
|
except:
|
|
try:
|
|
print("Reconnectiong...")
|
|
self.tn.close()
|
|
self.disconnected.emit()
|
|
self.open_telnet()
|
|
except:
|
|
print("Reconnect failed!")
|
|
|
|
class MainWindow(QMainWindow):
|
|
keyPressed = pyqtSignal(int)
|
|
def __init__(self):
|
|
super(MainWindow, self).__init__()
|
|
widget = QWidget(self)
|
|
self.layout = QVBoxLayout(widget)
|
|
self.setCentralWidget(widget)
|
|
self.setup_mqtt()
|
|
mutbox = QHBoxLayout()
|
|
|
|
self.m1 = mutant(usr_1,pwrd_2)
|
|
self.m2 = mutant(usr_2,pwrd_2)
|
|
mutbox.addWidget(self.m1)
|
|
mutbox.addWidget(self.m2)
|
|
self.m1.mqtt_str.connect(self.send_mqtt)
|
|
self.m2.mqtt_str.connect(self.send_mqtt)
|
|
self.layout.addLayout(mutbox)
|
|
self.button_group()
|
|
self.createModeGroup()
|
|
self.show()
|
|
|
|
#Connect signals
|
|
#self.keyPressed.connect(self.m.process_keys)
|
|
|
|
# Add text input
|
|
self.formGroupBox = QFormLayout()
|
|
self.text_input = QLineEdit()
|
|
self.text_button = QPushButton("Send")
|
|
self.text_button.clicked.connect(self.send_str)
|
|
self.formGroupBox.addRow(self.text_button,self.text_input)
|
|
self.layout.addLayout(self.formGroupBox)
|
|
|
|
self.send_mqtt("Welcome To mutants..")
|
|
|
|
#Events like mouse movement and keyboard action that happen on the main form
|
|
def eventFilter(self, source, event):
|
|
#print(source)
|
|
if str(source).find("QWindow") != -1:
|
|
if event.type() == QEvent.KeyPress:
|
|
self.keyPressed.emit(event.key())
|
|
|
|
return QMainWindow.eventFilter(self, source, event)
|
|
|
|
#create buttons
|
|
def button_group(self):
|
|
hbox1 = QHBoxLayout()
|
|
hbox2 = QHBoxLayout()
|
|
b_grid = QGridLayout()
|
|
|
|
north_button = QPushButton("North")
|
|
south_button = QPushButton("South")
|
|
east_button = QPushButton("East")
|
|
west_button = QPushButton("West")
|
|
heal_button = QPushButton("Heal")
|
|
combat_button = QPushButton("Combat")
|
|
|
|
hbox2.addWidget(heal_button)
|
|
hbox2.addWidget(combat_button)
|
|
|
|
b_grid.addWidget(north_button,0,1)
|
|
b_grid.addWidget(south_button,2,1)
|
|
b_grid.addWidget(east_button,1,2)
|
|
b_grid.addWidget(west_button,1,0)
|
|
b_grid.addLayout(hbox2,1,1)
|
|
#b_grid.addWidget(heal_button,2,2)
|
|
#b_grid.addWidget(combat_button,2,0)
|
|
|
|
hbox1.addItem(QSpacerItem(350, 0, QSizePolicy.Minimum))
|
|
hbox1.addLayout(b_grid)
|
|
hbox1.addItem(QSpacerItem(350, 0, QSizePolicy.Minimum))
|
|
|
|
north_button.clicked.connect(self.n_btn)
|
|
south_button.clicked.connect(self.s_btn)
|
|
east_button.clicked.connect(self.e_btn)
|
|
west_button.clicked.connect(self.w_btn)
|
|
heal_button.clicked.connect(self.h_btn)
|
|
combat_button.clicked.connect(self.c_btn)
|
|
|
|
self.layout.addLayout(hbox1)
|
|
|
|
#buttons
|
|
def n_btn(self):
|
|
self.m1.command_str.emit("north\r\n")
|
|
self.m2.command_str.emit("north\r\n")
|
|
def s_btn(self):
|
|
self.m1.command_str.emit("south\r\n")
|
|
self.m2.command_str.emit("south\r\n")
|
|
def e_btn(self):
|
|
self.m1.command_str.emit("east\r\n")
|
|
self.m2.command_str.emit("east\r\n")
|
|
def w_btn(self):
|
|
self.m1.command_str.emit("west\r\n")
|
|
self.m2.command_str.emit("west\r\n")
|
|
def h_btn(self):
|
|
self.m1.heal = True
|
|
self.m2.heal = True
|
|
def c_btn(self):
|
|
self.m1.combat_start()
|
|
self.m2.combat_start()
|
|
|
|
#Button send text
|
|
def send_str(self):
|
|
self.m1.command_str.emit(self.text_input.text()+"\r\n")
|
|
self.m2.command_str.emit(self.text_input.text()+"\r\n")
|
|
|
|
#Creates the form groupbox
|
|
def createModeGroup(self):
|
|
self.mode_layout = QVBoxLayout()
|
|
hbox1 = QHBoxLayout()
|
|
hbox2 = QHBoxLayout()
|
|
self.mq_check = QCheckBox("MQTT")
|
|
self.mq_check.setChecked(True)
|
|
|
|
hbox1.addWidget(self.mq_check)
|
|
|
|
self.layout.addLayout(hbox1)
|
|
|
|
def setup_mqtt(self):
|
|
broker_address="192.168.86.27"
|
|
print("creating new instance")
|
|
self.client = mqtt.Client("P1") #create new instance
|
|
self.client.username_pw_set("homeassistant", "oes5gohng9gau1Quei2ohpixashi4Thidoon1shohGai2mae0ru2zaph2vooshai")
|
|
self.client.connect(broker_address)
|
|
|
|
#Send mqtt
|
|
def send_mqtt(self,out_str):
|
|
self.setup_mqtt()
|
|
if self.mq_check.isChecked():
|
|
self.client.publish("mutants", out_str)
|
|
|
|
if __name__ == "__main__":
|
|
App = QApplication(sys.argv)
|
|
QApplication.setQuitOnLastWindowClosed(True)
|
|
Root = MainWindow()
|
|
Root.show()
|
|
App.installEventFilter(Root)
|
|
sys.exit(App.exec())
|