diff --git a/qmutants.py b/qmutants.py index 36ac637..1af2bb3 100644 --- a/qmutants.py +++ b/qmutants.py @@ -34,8 +34,8 @@ class player(): self.end_year = 2500 self.no_action = 50 -choice = int(sys.argv[1]) -print("choice:"+sys.argv[1]) +login_f = sys.argv[1] +print("login file: "+sys.argv[1]) def player_add(usr,pwd,char_sel,weapon,spell,ac,ai,me,af,hu,ba,start_year,end_year,no_action): plyr = player() @@ -57,23 +57,42 @@ def player_add(usr,pwd,char_sel,weapon,spell,ac,ai,me,af,hu,ba,start_year,end_ye plyr.no_action = no_action player_list.append(plyr) + +#load player +def load_player_file(login): + file = "./"+login + with open(file, 'r') as login_file: + while True: + in_str = login_file.readline().strip() + if in_str != "": + f_player=in_str.split(",") + plyr = player() + plyr.usr = f_player[0] + plyr.pwrd = f_player[1] + plyr.char_sel = int(f_player[2]) + plyr.weapon = f_player[3] + plyr.spell = f_player[4] + + plyr.auto_combat = f_player[5] == 'True' + plyr.auto_ion = f_player[6] == 'True' + plyr.meander = f_player[7] == 'True' + plyr.auto_farm = f_player[8] == 'True' + plyr.hunt = f_player[9] == 'True' + plyr.bait = f_player[10] == 'True' -if choice == 1: - player_add("epilectrik","gupass",4,"Nuclear-Decay","dispell",True,True,True,False,True,False,2500,3800,50) - player_add("im bait","gupass",4,"Nuclear-Decay","dispell",True,True,True,False,True,False,2500,3800,50) - player_add("doctor","gupass",2,"Nuclear-Decay","cure poison",True,True,True,False,True,False,2000,2500,50) - player_add("robin-hood","gupass",1,"Nuclear-Decay","invisibility",True,True,True,False,True,False,2000,2500,50) - player_add("assassin","gupass",4,"Nuclear-Decay","dispell",True,True,True,False,True,False,2000,2500,50) - player_add("mercenary","gupass",4,"Nuclear-Decay","dispell",True,True,True,False,True,False,2000,2500,50) - player_add("mutant-warrior-1","gupass",4,"Nuclear-Decay","dispell",True,True,True,False,True,False,2000,2500,50) - player_add("mutant-warrior-2","gupass",4,"Nuclear-Decay","dispell",True,True,True,False,True,False,2000,2500,50) - -if choice == 2: - player_add("Mtron","gupass",4,"Nuclear-Decay","dispell",True,True,True,True,True,False,2000,2500,50) - player_add("IonJunkies-Merc","gupass",4,"Nuclear-Decay","dispell",True,True,True,True,True,False,2000,2500,50) - player_add("Ionjunkies-priest-1","gupass",2,"Nuclear-Decay","cure poison",True,True,True,False,True,False,2000,2500,50) - player_add("Ionjunkies-thief-1","gupass",1,"Nuclear-Decay","invisibility",True,True,True,False,True,False,2000,2500,50) + plyr.start_year = int(f_player[11]) + plyr.end_year = int(f_player[12]) + plyr.no_action = int(f_player[13]) + + player_list.append(plyr) + + # end of file is reached + if not in_str: + break + +load_player_file(login_f) + #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", @@ -86,7 +105,7 @@ farm_sell_list = ["Gold-Chunck","Nuclear-Rock","Nuclear-Waste"] 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","CarlRam"] #cure_path = ["done","tra 2000","north","north","north","north","cure me","!return","done"] @@ -812,28 +831,35 @@ class mutant(QWidget): #handle functions in path script def script_function(self,function): - if function == "DEPOSIT": + if function == "DEPOSIT": + #Calculate riblets to deposit dep_ribs = self.riblets - self.min_riblets if dep_ribs < 0: dep_ribs = 0 + #Deposit self.send_cmd("deposit "+str(dep_ribs)+"\r\n") self.mqtt_str_quiet.emit(self.user," deposited "+str(self.riblets)+" riblets" ) self.riblets = self.min_riblets + #Secure ions if high 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 + #Unsecure ions if low if self.ions < self.ion_thresh: self.send_cmd("unsecure "+str(self.ion_thresh-self.ions)+"\r\n") self.mqtt_str_quiet.emit(self.user," unsecured "+str(self.ion_thresh-self.ions)+" ions" ) self.ions = self.ion_thresh - + + #Stock items if function == "STOCK" and self.auto_farm: self.stock_items() - + + #Sell items if function == "SELL": self.sell_items() + #Return to starting year if function == "RETURN": self.path_step = -1 self.send_cmd("tra "+str(self.present_year)+"\r\n") @@ -842,7 +868,8 @@ class mutant(QWidget): new_path = 0 self.path_input.setText(str(new_path)) self.tab_color.emit(self.idx,'green') - + + #Request poison cure if function == "POISON": request = ['poison',str(self.present_year),self.user] self.broadcast.emit(request)