class Ware: def __init__(self, Name, BasePrice, Modifier, Occident, Orient, Corsair, Venetian): self.Name = Name self.BasePrice = BasePrice self.Modifier = Modifier self.Occident = Occident self.Orient = Orient self.Corsair = Corsair self.Venetian = Venetian def __repr__(self): return self.Name def Update_TE(self): self.Modifier = self.Modifier * 50 if self.Occident != 0: self.Occident = round(self.Occident + self.Modifier, 2) else: pass if self.Orient != 0: self.Orient = round(self.Orient + self.Modifier, 2) else: pass if self.Corsair != 0: self.Corsair = round(self.Corsair + self.Modifier, 2) else: pass if self.Venetian != 0: self.Venetian = round(self.Venetian + self.Modifier, 2) else: pass class NPC: def __init__(self, Name, Gold_Amount_Sell, Base_Trade_Amount, Min_Trade_Amount, Trade_Slot_Count, Output): self.Name = Name self.Gold_Amount_Sell = Gold_Amount_Sell self.Base_Trade_Amount = Base_Trade_Amount self.Min_Trade_Amount = Min_Trade_Amount self.Trade_Slot_Count = Trade_Slot_Count self.Output = Output def __repr__(self): return "{" + self.Name + ", " + str(self.Gold_Amount_Sell) + ", " + str(self.Base_Trade_Amount) + ", " + str( self.Min_Trade_Amount) + ", " + str(self.Trade_Slot_Count) + self.Output + "}" # Ware("Name", BasePrice, Modifier, Occident, Orient, Corsair, Venetian) list_of_Wares = [ Ware("Duftwasser", 225, 0, 0, 100, 0, 120), Ware("Kerzenhalter", 194, 0, 100, 0, 0, 120), Ware("Kanonen", 169, 0, 0, 50, 100, 100), Ware("Proviant", 168, 0, 50, 50, 100, 100), Ware("Perlenketten", 165, 0, 0, 100, 0, 120), Ware("Kaffee", 162, 0, 0, 100, 0, 120), Ware("Wein", 120, 0, 100, 0, 50, 120), Ware("Kriegsmaschinen", 119, 0, 0, 0, 100, 100), Ware("Brokatgewänder", 108, 0, 100, 0, 0, 120), Ware("Teppiche", 107, 0, 0, 100, 0, 100), Ware("Brillen", 90, 0, 100, 0, 0, 100), Ware("Kerzen", 87, 0, 50, 0, 0, 100), Ware("Messing", 84, 0, 50, 0, 50, 100), Ware("Marzipan", 78, 0, 0, 100, 0, 120), Ware("Pelzmäntel", 77, 0, 100, 0, 0, 120), Ware("Rosenöl", 75, 0, 0, 50, 0, 120), Ware("Glas", 68, 0, 100, 50, 50, 120), Ware("Waffen", 52, 0, 0, 0, 100, 100), Ware("Fleisch", 50, 0, 100, 0, 50, 100), Ware("Kaffeebohen", 50, 0, 0, 50, 0, 100), Ware("Bücher", 50, 0, 100, 0, 0, 120), Ware("Perlen", 48, 0, 0, 50, 50, 120), Ware("Leinenkutten", 46, 0, 100, 0, 0, 100), Ware("Mosaik", 46, 0, 0, 100, 50, 100), Ware("Trauben", 45, 0, 50, 0, 0, 100), Ware("Lederwämser", 41, 0, 100, 0, 0, 120), Ware("Golderz", 40, 0, 50, 0, 50, 100), Ware("Gold", 40, 0, 50, 0, 50, 120), Ware("Bier", 39, 0, 100, 0, 100, 100), Ware("Fässer", 38, 0, 50, 0, 50, 100), Ware("Kupfererz", 36, 0, 50, 0, 50, 100), Ware("Werkzeug", 36, 0, 100, 100, 50, 120), Ware("Eisen", 33, 0, 50, 50, 50, 100), Ware("Bienenwachs", 27, 0, 50, 0, 0, 100), Ware("Brot", 26, 0, 100, 0, 0, 100), Ware("Zucker", 26, 0, 0, 50, 0, 100), Ware("Hanf", 24, 0, 50, 0, 0, 100), Ware("Papier", 24, 0, 50, 0, 0, 100), Ware("Tierhäute", 24, 0, 50, 0, 0, 100), Ware("Seide", 21, 0, 0, 50, 0, 100), Ware("Pottasche", 20, 0, 50, 50, 0, 100), Ware("Pelze", 19, 0, 50, 0, 50, 100), Ware("Indigo", 19, 0, 0, 50, 0, 100), Ware("Ton", 18, 0, 0, 50, 50, 100), Ware("Quartz", 18, 0, 0, 50, 0, 100), Ware("Gewürze", 18, 0, 0, 100, 50, 120), Ware("Milch", 16, 0, 0, 100, 0, 120), Ware("Mehl", 16, 0, 50, 0, 0, 100), Ware("Zuckerrohr", 13, 0, 0, 50, 0, 100), Ware("Most", 12, 0, 100, 0, 50, 100), Ware("Eisenerz", 12, 0, 50, 50, 50, 100), Ware("Mandeln", 9, 0, 0, 50, 0, 100), Ware("Fisch", 9, 0, 100, 0, 50, 100), Ware("Salz", 9, 0, 50, 50, 50, 100), Ware("Rinder", 9, 0, 50, 0, 0, 120), Ware("Kohle", 9, 0, 50, 50, 50, 100), Ware("Sole", 6, 0, 50, 50, 50, 100), Ware("Kräuter", 6, 0, 50, 0, 0, 100), Ware("Datteln", 4, 0, 0, 100, 50, 0), Ware("Weizen", 3, 0, 50, 0, 0, 100), Ware("Holz", 4, 0, 100, 50, 0, 120), Ware("Stein", 8, 0, 100, 50, 100, 100), Ware("Seile", 39, 0, 100, 50, 100, 100), Ware("empty", 0, 0, 0, 0, 0, 0) ] # NPC("Name", Gold_Amount_Sell, Base_Trade_Amount, Min_Trade_Amount, Trade_Slot_Count) list_of_NPC = [NPC("Occident", 1400, 30, 8, 8, []), NPC("Orient", 1400, 30, 5, 8, []), NPC("Corsair", 1400, 30, 5, 6, []), NPC("Venetian", 1050, 35, 6, 8, []) ] Input_List = [0, 1, 2, 3, 4, 5, 6, 7] # Jede Zahl wird durch einen eingegebenen Warennamen ersetzt Input_Price_List = [0, 0, 0, 0, 0, 0, 0, 0] # Jede Zahl wird durch einen eingegebenen Warenpreis ersetzt k = 0 while k in Input_List: I = input("Input a Ware name: ") # Diese Eingabe soll in der Input_List vermerkt werden if I == "": # Wird keine Eingabe mehr getätigt wird die Input_List mit leeren Waren aufgefüllt while k in Input_List: Input_List[k] = next(filter(lambda Ware: Ware.Name == "empty", list_of_Wares)) k += 1 if k == 8: k = "finished" else: Typo = 0 for Ware in list_of_Wares: # Existiert die Eingabe in list_of_Wares, ist die Eingabe korrekt if Ware.Name == I: Typo += 1 else: Typo = Typo # Existiert die Eingabe nicht, gilt Typo = 0, die Eingabe muss wiederholt werden. if Typo < 1: k = k print("There must be a Typo! Please try again.") else: Input_List[k] = next(filter(lambda Ware: (Ware.Name == str(I)), list_of_Wares)) # Hier wird die Zahl in der Input_List durch das Objekt samt Attributen ersetzt L = 7 L_list = [7] while L in L_list: try: P = int(input( "Input Ware Price: ")) # hier wird der Preis der Ware aingestellt. L in L_List lässt den Vorgang bei Fehleingabe wiederholen. if P >= int(Input_List[k].BasePrice) and P <= 4 * Input_List[k].BasePrice: # der Preis muss natürlich Anno-kompatibel sein Input_Price_List[k] = P Input_List[k].Modifier = round(2 / 3 * int(Input_Price_List[k]) / Input_List[k].BasePrice - 5 / 3, 3) k += 1 # Der Preis wird direkt im Modifier festgehalten, die Input_Price_list ist also nurnoch für den Menschen notwendig. L += 1 if k == 8: k = "finished" # Falls was schief läuft wird k ein String und kann in Input_List nicht mehr vorkommen. else: print("Price must be between " + str(Input_List[k].BasePrice) + " and " + str(int(Input_List[k].BasePrice * 4)) + "! Please input again.") L = 7 # Fehlermeldung falls der Preis nicht im Intervall except ValueError: L = 7 # Fehlermeldung falls der Preis einen Buchstaben enthält print("Input must be a Number, please try again.") for Ware in Input_List: # Der Modifier wird direkt in den restlichen TEs verrechnet Ware.Update_TE() Input_List_Occ__ = Input_List Input_List_Ori__ = Input_List Input_List_Cor__ = Input_List Input_List_Ven__ = Input_List for NPC in list_of_NPC: if NPC.Name == "Occident": Input_List_Occ_ = sorted(Input_List_Occ__, key=lambda Ware: Ware.BasePrice, reverse=True) # sortierung nach Preis Input_List_Occ = sorted(Input_List_Occ_, key=lambda Ware: Ware.Occident, reverse=True) # sortierung nach der Occident TE, bei gleicher TE for Ware in Input_List_Occ: # bleibt die Reihenfolge wie sie vorher war - also nach Preis WareTE = Ware.Occident / 100 # kurzes Setup für die Berechnung j = NPC.Min_Trade_Amount tuple = [Ware, j] # das Tupel wird an .Output angehängt und so der Verkauf im Objekt des NPCs festgehalten if WareTE > 0: NPC.Output.append(tuple) NPC.Gold_Amount_Sell = NPC.Gold_Amount_Sell - NPC.Min_Trade_Amount * Ware.BasePrice else: tuple = (list_of_Wares[63], 0) NPC.Output.append(tuple) for Ware in Input_List_Occ: i = NPC.Min_Trade_Amount tuple = [Ware, i] WareTE = Ware.Occident / 100 Trade_Amount = float((NPC.Base_Trade_Amount + NPC.Min_Trade_Amount) * WareTE) if WareTE > 0: while NPC.Gold_Amount_Sell > 0 and i < Trade_Amount: NPC.Gold_Amount_Sell = NPC.Gold_Amount_Sell - Ware.BasePrice i += 1 index = Input_List_Occ.index(Ware) NPC.Output[index][1] = i else: pass elif NPC.Name == "Orient": Input_List_Ori_ = sorted(Input_List_Ori__, key=lambda Ware: Ware.BasePrice, reverse=True) Input_List_Ori = sorted(Input_List_Ori_, key=lambda Ware: Ware.Orient, reverse=True) for Ware in Input_List_Ori: WareTE = Ware.Orient / 100 j = NPC.Min_Trade_Amount tuple = [Ware, j] if WareTE > 0: NPC.Output.append(tuple) NPC.Gold_Amount_Sell = NPC.Gold_Amount_Sell - NPC.Min_Trade_Amount * Ware.BasePrice else: tuple = (list_of_Wares[63], 0) NPC.Output.append(tuple) for Ware in Input_List_Ori: i = NPC.Min_Trade_Amount tuple = [Ware, i] WareTE = Ware.Orient / 100 Trade_Amount = float((NPC.Base_Trade_Amount + NPC.Min_Trade_Amount) * WareTE) if WareTE > 0: while NPC.Gold_Amount_Sell > 0 and i < Trade_Amount: NPC.Gold_Amount_Sell = NPC.Gold_Amount_Sell - Ware.BasePrice i += 1 index = Input_List_Ori.index(Ware) NPC.Output[index][1] = i else: pass elif NPC.Name == "Corsair": Input_List_Cor_ = sorted(Input_List_Cor__, key=lambda Ware: Ware.BasePrice, reverse=True) Input_List_Cor = sorted(Input_List_Cor_, key=lambda Ware: Ware.Corsair, reverse=True) for Ware in Input_List_Cor: WareTE = Ware.Corsair / 100 j = NPC.Min_Trade_Amount tuple = [Ware, j] if WareTE > 0: NPC.Output.append(tuple) NPC.Gold_Amount_Sell = NPC.Gold_Amount_Sell - NPC.Min_Trade_Amount * Ware.BasePrice else: tuple = (list_of_Wares[63], 0) NPC.Output.append(tuple) for Ware in Input_List_Cor: i = NPC.Min_Trade_Amount tuple = [Ware, i] WareTE = Ware.Corsair / 100 Trade_Amount = float((NPC.Base_Trade_Amount + NPC.Min_Trade_Amount) * WareTE) if WareTE > 0: while NPC.Gold_Amount_Sell > 0 and i < Trade_Amount: NPC.Gold_Amount_Sell = NPC.Gold_Amount_Sell - Ware.BasePrice i += 1 index = Input_List_Cor.index(Ware) NPC.Output[index][1] = i elif NPC.Name == "Venetian": Input_List_Ven_ = sorted(Input_List_Ven__, key=lambda Ware: Ware.BasePrice, reverse=True) Input_List_Ven = sorted(Input_List_Ven_, key=lambda Ware: Ware.Venetian, reverse=True) for Ware in Input_List_Ven: WareTE = Ware.Venetian / 100 j = NPC.Min_Trade_Amount tuple = [Ware, j] if WareTE > 0: NPC.Output.append(tuple) NPC.Gold_Amount_Sell = NPC.Gold_Amount_Sell - NPC.Min_Trade_Amount * Ware.BasePrice else: tuple = (list_of_Wares[63], 0) NPC.Output.append(tuple) for Ware in Input_List_Ven: i = NPC.Min_Trade_Amount tuple = [Ware, i] WareTE = Ware.Venetian / 100 Trade_Amount = float((NPC.Base_Trade_Amount + NPC.Min_Trade_Amount) * WareTE) if WareTE > 0: while NPC.Gold_Amount_Sell > 0 and i < Trade_Amount and i < 54: NPC.Gold_Amount_Sell = NPC.Gold_Amount_Sell - Ware.BasePrice i += 1 index = Input_List_Ven.index(Ware) NPC.Output[index][1] = i else: pass else: pass print(str(NPC.Name) + ": " + str(NPC.Output)) input("Press enter to close")