Beispiel #1
0
def cancel(quest, func):
    from data.getgui import gui
    gui.hook.onQuestCancel.fire(quest)
    gd = functions.get_gamedata()
    gd["quests"]["active"].remove(quest["id"])
    functions.save_gamedata(gd)
    func()
Beispiel #2
0
def register(data, override=False):
    from data.getgui import gui
    quests = get_quests()
    id = random.random() * 1000000
    id = hashlib.md5(str(id).encode('utf-8')).hexdigest()
    data["id"] = id
    if not "title" in data:
        data["title"] = "Quest"
    if not "description" in data:
        data["description"] = ""
    if not "sdescription" in data:
        data["sdescription"] = data["title"] + "\n" + data["description"]
    if not "tools" in data:
        data["tools"] = {}
    if not "rewards" in data:
        data["rewards"] = {}
    if not "requirements" in data:
        data["requirements"] = {}
    quests[id] = data
    gd = functions.get_gamedata()
    save = True
    if "quests" in gd:
        if "bind" in gd["quests"]:
            if gui.last_event[0] + "+" + gui.last_event[1] + "+" + data[
                    "title"] in gd["quests"]["bind"] and not override:
                save = False
    if save:
        gd["quests"] = quests
        if not "bind" in gd["quests"]:
            gd["quests"]["bind"] = {}
            gd["quests"]["active"] = []
        gd["quests"]["bind"][gui.last_event[0] + "+" + gui.last_event[1] +
                             "+" + data["title"]] = id
        functions.save_gamedata(gd)
        gui.hook.onQuestRegister.fire(data)
Beispiel #3
0
def garageerror(gui, veh):
    gui.clear_screen()
    back = gui.hintergrund()
    back.pack()
    gd = functions.get_gamedata()

    Label(back,
          text="Die Garage von " + gd["place"] + "ist voll.",
          bg="Gold2",
          fg="red",
          font=gui_content.ch_fontsize("32")).grid(row=1,
                                                   column=1,
                                                   columnspan=2,
                                                   sticky=NSEW)
    Button(back,
           text="Fahrzeug " + veh["name"] + " zerstören.",
           command=partial(hub, gui),
           font=gui_content.ch_fontsize("16"),
           bg="green").grid(row=2, column=1, sticky=NSEW)
    Button(back,
           text="Zu einem anderen Ort fahren.",
           command=partial(enterveh, gui, veh),
           font=gui_content.ch_fontsize("16"),
           bg="green").grid(row=2, column=2, sticky=NSEW)

    back.grid_rowconfigure(0, weight=1)
    back.grid_rowconfigure(3, weight=1)
    back.grid_columnconfigure(0, weight=1)
    back.grid_columnconfigure(3, weight=1)
Beispiel #4
0
	def useitem(self, item):
		hintergrund = self.hintergrund;

		Text = Canvas(hintergrund, bg="Gold2", highlightthickness=0, width=functions.pro_size(28,0), height=functions.pro_size(28,1));
		Text.place(x=functions.pro_size(36,0), y=functions.pro_size(36,1));
		Text2 = Canvas(hintergrund, bg="Gold2", highlightthickness=0, width=functions.pro_size(20,0), height=functions.pro_size(20,1));
		Text2.place(x=functions.pro_size(40,0), y=functions.pro_size(40,1));

		Button(Text2, text="Zurück", command=self.inventory).grid(row=0,column=1,padx=5,pady=5);
		x = 1;
		y = 1;
		if not hasattr(self.gui, "itemevents"):
			setattr(self.gui, "itemevents", {});
		if not item in self.gui.itemevents:
			self.gui.itemevents[item]={};
		for button, event in self.gui.itemevents[item].items():
			notbutton=False;
			if "place" in event:
				if not event["place"] == functions.get_gamedata()["place"]:
					notbutton=True;
			if not notbutton:
				Button(Text2, text=button, command=partial(self.useitem2, item, event[1], event[0])).grid(row=y,column=x,padx=5,pady=5);
			x+=1;
			if x == 6:
				x = 1;
				y += 1;
Beispiel #5
0
def acceptquest(func, quest):
    from data.getgui import gui
    gui.hook.onQuestAccept.fire(quest)
    event_functions.add_items(quest["tools"])
    gd = functions.get_gamedata()
    gd["quests"]["active"].append(quest["id"])
    functions.save_gamedata(gd)
    func()
Beispiel #6
0
def event(gui, events):
    gd = functions.get_gamedata()
    event = random.SystemRandom().choice(events)
    keyword = "random"
    try:
        exec("print(\"" + gd["place"] + "\")")
    except:
        gd["place"] = ""
        keyword = "travel"
    gui.game(event[1], event[0], ["place-" + keyword, gd["place"]])
Beispiel #7
0
def get(quest, func):
    from data.getgui import gui
    gui.hook.onQuestFinish.fire(quest)
    gd = functions.get_gamedata()
    gd["quests"]["active"].remove(quest["id"])
    functions.save_gamedata(gd)
    event_functions.add_items(quest["rewards"])
    for item, amount in quest["requirements"].items():
        event_functions.remove_items(item, amount)
    func()
Beispiel #8
0
def enterplace(gui, name, takeveh=False, endjourney=False, force=False):
    gui.hook.onPlaceEnter.fire(name)
    gd = functions.get_gamedata()
    place = get_place(name)
    check = True
    try:
        exec("print(\"" + str(gd["travel"]) + "\")")
    except KeyError:
        check = False
    stop = False
    if check:
        if gd["travel"]["destination"] == name and not endjourney and not force:
            stop = True
    if not stop:
        gd["place"] = name
        gd["place_hub_timer"] = 0
        if endjourney:
            veh = gd["travel"]["vehicle"]
            del gd["travel"]
        elif takeveh:
            veh = gd["travel"]["vehicle"]
        garageworks = True
        try:
            if veh["name"] == "selfdestruct":
                takeveh = False
        except UnboundLocalError:
            print("")
        if takeveh:
            garageworks = False
            if len(gd["places"][name]["garage"]
                   ["storage"]) >= gd["places"][name]["garage"]["size"]:
                functions.save_gamedata(gd)
                garageerror(gui, veh)
            else:
                gd["places"][name]["garage"]["storage"].append(veh)
                garageworks = True
        if garageworks:
            if place["system"]["first"] and place["options"]["events"][
                    "enterf"][0] != "None":
                gd["places"][name]["system"]["first"] = False
                functions.save_gamedata(gd)
                gui.game(place["options"]["events"]["enterf"][1],
                         place["options"]["events"]["enterf"][0],
                         ["place-enterf", name])
            else:
                functions.save_gamedata(gd)
                if place["options"]["events"]["entern"][0] != "None":
                    gui.game(place["options"]["events"]["entern"][1],
                             place["options"]["events"]["entern"][0],
                             ["place-entern", name])
                else:
                    hub(gui, False, True)
    else:
        gui.new_text()
Beispiel #9
0
def exit(event, id, func, gui):
    cons = get_cons()
    con = cons[id]
    if con["removeonexit"]:
        del cons[id]
        gd = functions.get_gamedata()
        gd["containers"] = cons
        functions.save_gamedata(gd)
    if not event == "none":
        exec("event." + func + "()")
    else:
        place_functions.hub(gui, False, True)
Beispiel #10
0
def travel(gui, place, vehicle, key=-1):
    gd = functions.get_gamedata()
    vehicle["key"] = key
    gd["travel"] = {
        "steps": vehicle["steps"],
        "destination": place,
        "vehicle": vehicle
    }
    if not key == -1:
        del gd["places"][gd["place"]]["garage"]["storage"][key]
    functions.save_gamedata(gd)
    leave(gui)
Beispiel #11
0
def leave(gui):
    gd = functions.get_gamedata()
    gui.hook.onPlaceLeave.fire(gd["place"])
    try:
        place = get_place(gd["place"])
        del gd["place"]
        functions.save_gamedata(gd)
        if place["options"]["events"]["exit"][0] != "None":
            gui.game(place["options"]["events"]["exit"][1],
                     place["options"]["events"]["exit"][0],
                     ["place-exit", name])
        else:
            gui.new_text()
    except:
        gui.new_text()
Beispiel #12
0
def register(data, override=False):
    from data.getgui import gui
    factions = get_factions()
    if not "value" in data:
        data["value"] = 0
    if not "value2" in data:
        data["value2"] = 0
    cancel = False
    if data["name"] in factions:
        if not override:
            cancel = True
    if not cancel:
        factions[data["name"]] = data
        gd = functions.get_gamedata()
        gd["factions"] = factions
        functions.save_gamedata(gd)
        gui.hook.onFactionRegister.fire(data)
Beispiel #13
0
	def hub_menu(self):
		gd = functions.get_gamedata();
		self.clear_screen1();
		menu = Canvas(self.hintergrund, bg="gold2", highlightthickness=0);
		menu.place(x=functions.pro_size(5,0), y=functions.pro_size(5,1));
		Button(menu, text="Inventar", command=self.inventory, width=functions.pro_size(1,0), font=gui_content.ch_fontsize(16)).grid(row=1);
		check=True;
		try:
			exec("print(\""+str(gd["travel"])+"\")");
		except:
			check=False;
		if check:
			Label(menu, text="Aktuelle Reise: \nZiel: "+gd["travel"]["destination"]+"\nAnkunft in: "+str(gd["travel"]["steps"]), bg="Gold2", font=gui_content.ch_fontsize(16)).grid(row=1,column=1,sticky=W);
		else:
			Label(menu, text="Aktuelle Reise: \nKeine", bg="Gold2", font=gui_content.ch_fontsize(16)).grid(row=1,column=1,sticky=W);
			Button(menu, text="Ort ansteuern", command=self.travel, font=gui_content.ch_fontsize(16)).grid(row=2,column=1,sticky=W);
		Button(menu, text="Fraktions-Übersicht", command=self.factions, font=gui_content.ch_fontsize(16)).grid(row=1,column=2,sticky=W);
		
		Button(self.hintergrund, text="Weiter gehen", command=self.hintergrund.quit, font=gui_content.ch_fontsize("16")).place(x=functions.pro_size(50,0), y=functions.pro_size(85,1), anchor=CENTER);
Beispiel #14
0
def move(event, id, func, direction, item, amount, gui):
    conf = get_cons()[id]
    con = conf["inv"]
    inv = functions.get_inventory()
    if direction == 1:
        gui.hook.onContainerMoveToCon.fire(id, conf, inv, item, amount, event,
                                           func)
    if direction == -1:
        gui.hook.onContainerMoveToInv.fire(id, conf, inv, item, amount, event,
                                           func)
    mistake = False
    if direction == 1:
        if not event_functions.check_item(item) >= amount:
            mistake = True
    else:
        if not con[item] >= amount:
            mistake = True
    if not mistake:
        try:
            exec("print(\"" + str(con[item]) + "\")")
        except KeyError:
            con[item] = 0
        try:
            exec("print(\"" + str(inv[item]) + "\")")
        except KeyError:
            inv[item] = 0
        if direction == 1:
            famount = 0
            for item, amo in con.items():
                famount += amo
            if (conf["size"] - famount - amount) < 0:
                amount += (conf["size"] - famount - amount)
        #	print("Checked. famount:"+str(famount));
        con[item] += amount * direction
        inv[item] += amount * direction * -1
        gd = functions.get_gamedata()
        gd["inventory"] = inv
        gd["containers"][id]["inv"] = con
        functions.save_gamedata(gd)
        if direction == 1:
            inve(event, id, func, gui)
        else:
            open(event, id, func, gui)
Beispiel #15
0
def svalue(name, value, mode=False):
    if mode:
        valuestring = "value2"
    else:
        valuestring = "value"
    value2 = value
    value *= 1.5
    facs = get_factions()
    fac = facs[name]
    divide = fac[valuestring]
    if divide == 0:
        divide = 1
    value = value * (divide / 2)
    divide = divide / 8
    value = value / divide
    fac[valuestring] += value
    gd = functions.get_gamedata()
    facs[name] = fac
    gd["factions"] = facs
    from data.getgui import gui
    gui.hook.onFactionValue.fire(fac, value2, value, mode)
    functions.save_gamedata(gd)
Beispiel #16
0
def savetogps(gui, place, remkey=-1):
    gd = functions.get_gamedata()
    try:
        gpsmax = gd["gpsmax"]
    except:
        gpsmax = 3
        gd["gpsmax"] = 3
    gps = get_gps()
    if len(get_gps()) < gpsmax:
        gps.append(gd["place"])
        gd["gps"] = gps
        functions.save_gamedata(gd)
        print("success")
    else:
        if not remkey == -1:
            print("replaced")
            gps[remkey] = gd["place"]
            gd["gps"] = gps
            functions.save_gamedata(gd)
        else:
            print("full")
            enterveh(gui, place, True, -2)
    hub(gui)
Beispiel #17
0
def overview(gui, self):
    self.clear_screen1()
    back = self.hintergrund
    gd = functions.get_gamedata()
    fac = get_factions()
    Text = Canvas(back, bg="Gold2", highlightthickness=0)
    Text.place(x=functions.pro_size(10, 0), y=functions.pro_size(10, 1))
    Label(Text,
          text="Fraktions-Übersicht",
          font=gui_content.ch_fontsize(32),
          bg="Gold2").grid(row=0, sticky=W)
    Label(Text,
          text="Verhältnis",
          font=gui_content.ch_fontsize(32),
          bg="Gold2").grid(row=0, column=2, columnspan=4, sticky=W)
    Label(Text, text="Stärke", font=gui_content.ch_fontsize(32),
          bg="Gold2").grid(row=0, column=6, columnspan=4, sticky=W)
    Button(Text,
           text="Zurück",
           command=self.hub_menu,
           font=gui_content.ch_fontsize(26),
           bg="Gold2").grid(row=1, sticky=W)
    Label(Text,
          text="Fraktions",
          font=gui_content.ch_fontsize(32),
          bg="Gold2",
          fg="Gold2").grid(row=0, column=1, sticky=W)
    Label(Text,
          text="Fraktions",
          font=gui_content.ch_fontsize(32),
          bg="Gold2",
          fg="Gold2").grid(row=0, column=5, sticky=W)
    keywords = {
        -100: ["Tötung auf Sicht", "red4", "white"],
        -90: ["Extrem Aggressiv", "red2", "white"],
        -66: ["Extrem Misstrauisch", "firebrick2", "black"],
        -33: ["Misstrauisch", "IndianRed1", "black"],
        -3: ["Neutral", "beige", "black"],
        3: ["Akzeptiert", "PaleGreen1", "black"],
        33: ["Vertraut", "green2", "black"],
        66: ["Extrem Vertraut", "green4", "white"],
        90: ["Blind Vertraut", "dark green", "white"]
    }
    keywords2 = {
        -100: ["Kaum Existent", "red4", "white"],
        -90: ["Extrem geschwächt", "red2", "white"],
        -66: ["Sehr geschwächt", "firebrick2", "black"],
        -33: ["Geschwächt", "IndianRed1", "black"],
        -3: ["Neutral", "beige", "black"],
        3: ["Relevant", "PaleGreen1", "black"],
        33: ["Sehr stark", "green2", "black"],
        66: ["Dominant", "green4", "white"],
        90: ["Regierend", "dark green", "white"]
    }
    row = 1
    for name, data in fac.items():
        row += 1
        Label(Text,
              text=name + ":",
              font=gui_content.ch_fontsize(24),
              bg="Gold2",
              fg="black").grid(row=row, column=0, sticky=W)
        Label(Text,
              text=str(data["value"]) + "%",
              font=gui_content.ch_fontsize(24),
              bg="Gold2",
              fg="black").grid(row=row, column=1, sticky=E)
        for value, keyw in keywords.items():
            if data["value"] >= value:
                keyword = keyw
        for value, keyw in keywords2.items():
            if data["value2"] >= value:
                keyword2 = keyw
        Label(Text,
              text="[",
              font=gui_content.ch_fontsize(24),
              bg="Gold2",
              fg="black").grid(row=row, column=2, sticky=W)
        Label(Text,
              text=keyword[0],
              font=gui_content.ch_fontsize(24),
              bg=keyword[1],
              fg=keyword[2]).grid(row=row, column=3, sticky=W)
        Label(Text,
              text="]",
              font=gui_content.ch_fontsize(24),
              bg="Gold2",
              fg="black").grid(row=row, column=4, sticky=W)
        Label(Text,
              text=str(data["value2"]) + "%",
              font=gui_content.ch_fontsize(24),
              bg="Gold2",
              fg="black").grid(row=row, column=5, sticky=E)
        Label(Text,
              text="[",
              font=gui_content.ch_fontsize(24),
              bg="Gold2",
              fg="black").grid(row=row, column=6, sticky=W)
        Label(Text,
              text=keyword2[0],
              font=gui_content.ch_fontsize(24),
              bg=keyword2[1],
              fg=keyword2[2]).grid(row=row, column=7, sticky=W)
        Label(Text,
              text="]",
              font=gui_content.ch_fontsize(24),
              bg="Gold2",
              fg="black").grid(row=row, column=8, sticky=W)
Beispiel #18
0
def get_factions():
    try:
        return functions.get_gamedata()["factions"]
    except:
        return {}
Beispiel #19
0
def get_cons():
    try:
        return functions.get_gamedata()["containers"]
    except:
        return {}
Beispiel #20
0
def get_quests():
    try:
        return functions.get_gamedata()["quests"]
    except:
        return {}
Beispiel #21
0
    def new_text(self, used_text="X"):
        self.hook.onEventEnd.fire(*self.last_event)
        check = True
        gd = functions.get_gamedata()
        #	print(gd);
        try:
            exec("print(\"" + gd["place"] + "\")")
        except:
            check = False
        check2 = True
        gd = functions.get_gamedata()
        #	print(gd);
        try:
            exec("print(\"" + str(gd["travel"]) + "\")")
        except:
            check2 = False
        if check:
            place_functions.hub(self)
        else:
            if not hasattr(self, "alreadyruns"):
                self.alreadyruns = True
            alreadyruns = False
            if self.alreadyruns:
                alreadyruns = True
                try:
                    self.hub_time += 1
                    if self.hub_time == 3:
                        self.hub_time = 0
                        self.game("hub", "system")
                except AttributeError:
                    setattr(self, "hub_time", 0)
                    pass
                self.alreadyruns = False
        #	print("HUB: "+str(self.hub_time))
            try:
                if check2 and not gd["travel"]["vehicle"]["events"] == "all":
                    place_functions.hub(self, True)
                elif check2:
                    if alreadyruns:
                        gd["travel"]["steps"] -= 1
                        functions.save_gamedata(gd)
                        if gd["travel"]["steps"] <= 0:
                            place_functions.hub(self, True)
            except KeyError:
                print("")
            else:
                alreadyused = functions.json_file_decode(
                    "user\\used_texts.json")[self.activemod]
                if used_text != "X":
                    boo_i = False
                    for i in alreadyused:
                        if alreadyused[i] == used_text:
                            boo_i = True
                    if boo_i:
                        game_folder1 = str(inspect.stack()[1][1])
                        game_folder1 = game_folder1.split("\\")
                        game_folder1 = game_folder1[len(game_folder1) - 2]
                        req = len(alreadyused[game_folder1])
                        alreadyused[game_folder1][req] = used_text + ".py"
                        functions.json_file_encode("user\\used_texts.json",
                                                   alreadyused)

                folders = [f.path for f in os.scandir("events") if f.is_dir()]
                folder = [x[7:] for x in folders]
                random1 = {}
                file_count = 0
                for f in folder:
                    if f != "__init__":
                        if f != "__pycache__":
                            for file in os.scandir("events\\" + f):
                                file = str(file)[11:-2]
                                file_module = file[:-3]

                                if file_module != "__init__":
                                    if file != "__pycache__":
                                        if f != "system":
                                            random1[str(file_count)] = {
                                                "folder": f,
                                                "file": file_module
                                            }
                                            file_count += 1
                print(random1)
                hg = random.random() * len(random1)
                self.game(random1[str(int(hg))]["file"],
                          random1[str(int(hg))]["folder"])
Beispiel #22
0
def get_places():
    try:
        return functions.get_gamedata()["places"]
    except:
        return {}
Beispiel #23
0
def questmenu(title,
              decline=False,
              accept=False,
              finish=False,
              cancelfunc=False,
              confunc=False):
    from data.getgui import gui
    if not decline:
        decline = gui.new_text
    if not accept:
        accept = gui.new_text
    if not finish:
        finish = gui.new_text
    if not cancelfunc:
        cancelfunc = gui.new_text
    if not confunc:
        confunc = gui.new_text
    gd = functions.get_gamedata()
    id = gd["quests"]["bind"][gui.last_event[0] + "+" + gui.last_event[1] +
                              "+" + title]
    quest = get_quests()[id]
    reached = False
    active = False
    if id in gd["quests"]["active"]:
        reached = True
        for item, amount in quest["requirements"].items():
            if event_functions.check_item(item) < amount:
                reached = False
        active = True
    gui.clear_screen()
    back = gui.hintergrund()
    back.pack()
    Text = Canvas(back,
                  bg="Gold2",
                  highlightthickness=0,
                  width=functions.pro_size(80, 0))
    Text.place(x=functions.pro_size(10, 0), y=functions.pro_size(10, 1))
    Label(Text, text="Quest:", font=gui_content.ch_fontsize(12),
          bg="Gold2").grid(row=0, columnspan=3, sticky=W)
    Label(Text,
          text=quest["title"],
          font=gui_content.ch_fontsize(32),
          bg="Gold2").grid(row=1, columnspan=3, sticky=W)
    Label(Text,
          text=quest["description"],
          font=gui_content.ch_fontsize(16),
          bg="Gold2").grid(row=2, columnspan=3, sticky=W)
    Label(Text,
          text="a",
          font=gui_content.ch_fontsize(16),
          bg="Gold2",
          fg="Gold2").grid(row=3, columnspan=3, sticky=W)
    Label(Text,
          text="a",
          font=gui_content.ch_fontsize(16),
          bg="Gold2",
          fg="Gold2").grid(row=4, columnspan=3, sticky=W)
    Label(Text,
          text="Zu beschaffende Items:",
          font=gui_content.ch_fontsize(16),
          bg="Gold2").grid(row=50, sticky=W)
    i = 49
    for item, amount in quest["requirements"].items():
        i += 1
        Label(Text,
              text=item + " x " + str(amount),
              font=gui_content.ch_fontsize(16),
              bg="Gold2").grid(row=i, column=2, sticky=W)
    i += 1
    Label(Text,
          text="Erhaltene Items zum Erfüllen der Quest:",
          font=gui_content.ch_fontsize(16),
          bg="Gold2").grid(row=i, columnspan=2, sticky=W)
    i -= 1
    for item, amount in quest["tools"].items():
        i += 1
        Label(Text,
              text=item + " x " + str(amount),
              font=gui_content.ch_fontsize(16),
              bg="Gold2").grid(row=i, column=2, sticky=W)
    i += 1
    Label(Text,
          text="Belohnungen:",
          font=gui_content.ch_fontsize(16),
          bg="Gold2").grid(row=i, sticky=W)
    i -= 1
    for item, amount in quest["rewards"].items():
        i += 1
        Label(Text,
              text=item + " x " + str(amount),
              font=gui_content.ch_fontsize(16),
              bg="Gold2").grid(row=i, column=2, sticky=W)
    i += 1
    Label(Text,
          text="a",
          font=gui_content.ch_fontsize(16),
          bg="Gold2",
          fg="Gold2").grid(row=i, columnspan=3, sticky=W)
    Label(Text,
          text="a",
          font=gui_content.ch_fontsize(16),
          bg="Gold2",
          fg="Gold2").grid(row=(i + 1), columnspan=3, sticky=W)
    Label(Text,
          text="a",
          font=gui_content.ch_fontsize(16),
          bg="Gold2",
          fg="Gold2").grid(row=(i + 2), columnspan=3, sticky=W)
    Label(Text,
          text="a",
          font=gui_content.ch_fontsize(16),
          bg="Gold2",
          fg="Gold2").grid(row=(i + 3), columnspan=3, sticky=W)
    Label(Text,
          text="a",
          font=gui_content.ch_fontsize(16),
          bg="Gold2",
          fg="Gold2").grid(row=(i + 4), columnspan=3, sticky=W)
    Label(Text,
          text="a",
          font=gui_content.ch_fontsize(16),
          bg="Gold2",
          fg="Gold2").grid(row=(i + 5), columnspan=3, sticky=W)
    i += 6
    nobutton = True
    if not active:
        if not gd["quests"]["active"]:
            Button(Text,
                   text="Annehmen",
                   command=partial(acceptquest, accept, quest),
                   bg="green",
                   font=gui_content.ch_fontsize("16"),
                   width=functions.pro_size(1, 0)).grid(row=i,
                                                        column=0,
                                                        padx=5,
                                                        pady=5)
            Button(Text,
                   text="Ablehnen",
                   command=partial(declinequest, decline, quest),
                   bg="red",
                   font=gui_content.ch_fontsize("16"),
                   width=functions.pro_size(1, 0)).grid(row=i,
                                                        padx=5,
                                                        pady=5,
                                                        column=1)
            nobutton = False
        else:
            Button(Text,
                   text="Beende zuerst deine aktuelle Quest!",
                   state=DISABLED,
                   bg="red",
                   font=gui_content.ch_fontsize("16"),
                   width=functions.pro_size(1, 0)).grid(row=i,
                                                        padx=5,
                                                        pady=5,
                                                        column=0)
    elif reached:
        Button(Text,
               text="Erreicht!",
               state=DISABLED,
               bg="green",
               font=gui_content.ch_fontsize("16"),
               width=functions.pro_size(1, 0)).grid(row=i,
                                                    padx=5,
                                                    pady=5,
                                                    column=0)
        Button(Text,
               text="Belohnung abholen",
               command=partial(get, quest, finish),
               bg="green",
               font=gui_content.ch_fontsize("16"),
               width=functions.pro_size(1, 0)).grid(row=i,
                                                    padx=5,
                                                    pady=5,
                                                    column=1)
    else:
        Button(Text,
               text="Aktiv",
               state=DISABLED,
               bg="blue",
               font=gui_content.ch_fontsize("16"),
               width=functions.pro_size(1, 0)).grid(row=i,
                                                    padx=5,
                                                    pady=5,
                                                    column=0)
        Button(Text,
               text="Abbrechen",
               command=partial(cancel, quest, cancelfunc),
               bg="red",
               font=gui_content.ch_fontsize("16"),
               width=functions.pro_size(1, 0)).grid(row=i,
                                                    padx=5,
                                                    pady=5,
                                                    column=1)
    if nobutton:
        Button(Text,
               text="Weiter",
               command=confunc,
               bg="white",
               font=gui_content.ch_fontsize("16"),
               width=functions.pro_size(1, 0)).grid(row=i,
                                                    padx=5,
                                                    pady=5,
                                                    column=10)
Beispiel #24
0
def garage(gui):
    gui.clear_screen()
    hintergrund = gui.hintergrund()
    hintergrund.pack()

    Label(hintergrund,
          text="Garage von " + functions.get_gamedata()["place"],
          font=gui_content.ch_fontsize("16"),
          bg="green").place(y=functions.pro_size(1, 1),
                            x=functions.pro_size(50, 0),
                            anchor=N)
    Button(hintergrund,
           text="Zurück",
           command=partial(hub, gui, False, True),
           font=gui_content.ch_fontsize("16"),
           bg="green").place(y=functions.pro_size(5, 1),
                             x=functions.pro_size(50, 0),
                             anchor=N)

    inventar1 = Canvas(hintergrund,
                       width=functions.pro_size(90, 0),
                       height=functions.pro_size(80, 1))
    inventar1.place(anchor=N,
                    x=functions.pro_size(50, 0),
                    y=functions.pro_size(10, 1))
    inventar = functions.VerticalScrolledFrame(inventar1)
    inventar.place(width=functions.pro_size(90, 0),
                   height=functions.pro_size(80, 1))

    inventar_content = get_place(
        functions.get_gamedata()["place"])["garage"]["storage"]
    if len(inventar_content) == 0:
        Label(inventar.interior,
              text="Leer",
              font=gui_content.ch_fontsize("32")).place(
                  x=functions.pro_size(50, 0),
                  y=functions.pro_size(50, 1),
                  anchor=CENTER)
    else:

        xrow = 0
        for value in inventar_content:
            xrow += 1
            newcanvas = {}
            newcanvas[xrow] = Canvas(inventar.interior,
                                     bg="green",
                                     width=functions.pro_size(90, 0),
                                     height=functions.pro_size(9, 1))
            newcanvas[xrow].grid(row=xrow)
            Label(newcanvas[xrow],
                  text=value["name"],
                  font=gui_content.ch_fontsize("40"),
                  bg="green",
                  fg="white").place(x=functions.pro_size(1, 0),
                                    y=functions.pro_size(4.5, 1),
                                    anchor=W)
            Button(newcanvas[xrow],
                   text="Benutzen",
                   command=partial(enterveh, gui, value, True, (xrow - 1)),
                   fg="white",
                   bg="green").place(y=functions.pro_size(9, 1),
                                     x=functions.pro_size(88, 0),
                                     anchor=SE)
Beispiel #25
0
def hub(gui, travel=False, returned=False):
    gui.alreadyruns = True
    gui.clear_screen()
    back = gui.hintergrund()
    back.pack()
    gd = functions.get_gamedata()
    if travel:
        print(gd["travel"]["steps"])
        if gd["travel"]["steps"] <= 0:
            print("Destination Reached.")
            enterplace(gui, gd["travel"]["destination"], True, True)
        else:
            gd["travel"]["steps"] -= 1
            functions.save_gamedata(gd)
            print("Travel")
            event(gui, gd["travel"]["vehicle"]["events"])
    else:
        try:
            place = get_place(gd["place"])
        except KeyError:
            gui.game("hub", "system")
        try:
            exec("print(\"" + str(gd["place_hub_timer"]) + "\")")
        except:
            #	print(sys.exc_info());
            gd["place_hub_timer"] = 0
        print(gd["place_hub_timer"])
        if not returned:
            if not gd["place_hub_timer"] == 0:
                if not gd["place_hub_timer"] >= (place["options"]["hubtimer"] +
                                                 1):
                    gd["place_hub_timer"] += 1
                    functions.save_gamedata(gd)
                    print("Random")
                    event(gui, place["options"]["events"]["random"])
                else:
                    print(
                        str(place["options"]["hubtimer"] + 1) + "/" +
                        str(gd["place_hub_timer"]))
                    gd["place_hub_timer"] = 0
                    functions.save_gamedata(gd)
            gd["place_hub_timer"] += 1
        functions.save_gamedata(gd)
        Text = Canvas(back, bg="Gold2", highlightthickness=0)
        Text.place(x=functions.pro_size(10, 0), y=functions.pro_size(10, 1))
        Label(Text,
              text="Willkommen " + place["word"] + " " + gd["place"],
              font=gui_content.ch_fontsize(32),
              bg="Gold2").grid(row=1, columnspan=3, sticky=W)
        Button(Text,
               text="Garage",
               command=partial(garage, gui),
               font=gui_content.ch_fontsize("16"),
               width=functions.pro_size(1, 0)).grid(row=2, padx=5, pady=5)
        if not place["storage"]["disable"]:
            Button(Text,
                   text="Lager",
                   command=partial(storage, gui),
                   font=gui_content.ch_fontsize("16"),
                   width=functions.pro_size(1, 0)).grid(row=2,
                                                        column=1,
                                                        padx=5,
                                                        pady=5)
        else:
            Button(Text,
                   text="Lager",
                   state=DISABLED,
                   command=partial(storage, gui),
                   font=gui_content.ch_fontsize("16"),
                   width=functions.pro_size(1, 0)).grid(row=2,
                                                        column=1,
                                                        padx=5,
                                                        pady=5)
        if not gd["place"] in get_gps():
            Button(Text,
                   text="Ort Speichern",
                   command=partial(savetogps, gui, place),
                   font=gui_content.ch_fontsize("16"),
                   width=functions.pro_size(1, 0)).grid(row=2,
                                                        column=2,
                                                        padx=5,
                                                        pady=5)
        else:
            Button(Text,
                   text="Ort Gespeichert.",
                   command=partial(print, ""),
                   font=gui_content.ch_fontsize("16"),
                   width=functions.pro_size(1, 0),
                   bg="green").grid(row=2, column=2, padx=5, pady=5)
        if len(place["options"]["events"]["clickable"]) > 0:
            Label(Text,
                  text="Aktionen:",
                  font=gui_content.ch_fontsize(20),
                  bg="Gold2").grid(row=3, sticky=W, columnspan=3)
            key = 0
            for value in place["options"]["events"]["clickable"]:
                row = math.floor(key / 6) + 4
                column = (key % 6)
                if key < 61:
                    Button(Text,
                           text=value[2],
                           command=partial(clickable, gui, value),
                           font=gui_content.ch_fontsize("16"),
                           width=functions.pro_size(1, 0),
                           height=functions.pro_size(.05,
                                                     1)).grid(row=row,
                                                              column=column,
                                                              padx=5,
                                                              pady=5)
                elif key == 61:
                    Label(Text,
                          text="Maximum von 60 Aktionen überschritten.",
                          font=gui_content.ch_fontsize(20),
                          bg="Gold2",
                          fg="red").grid(row=14, sticky=W, columnspan=6)
                key += 1
        Label(Text,
              text=place["description"],
              font=gui_content.ch_fontsize(20),
              bg="Gold2").grid(row=15, sticky=W, columnspan=3)
        Button(Text,
               text=gd["place"] + " verlassen",
               command=partial(leave, gui),
               bg="red",
               font=gui_content.ch_fontsize("16"),
               width=functions.pro_size(1, 0)).grid(row=16, padx=5, pady=5)
        if len(place["options"]["events"]["random"]) > 0:
            Button(Text,
                   text="Weitergehen",
                   command=partial(event, gui,
                                   place["options"]["events"]["random"]),
                   bg="green",
                   font=gui_content.ch_fontsize("16"),
                   width=functions.pro_size(1, 0)).grid(row=16,
                                                        column=1,
                                                        padx=5,
                                                        pady=5)
        else:
            Button(Text,
                   text="Weitergehen",
                   state=DISABLED,
                   command=partial(event, gui),
                   bg="green",
                   font=gui_content.ch_fontsize("16"),
                   width=functions.pro_size(1, 0)).grid(row=16,
                                                        column=1,
                                                        padx=5,
                                                        pady=5)
Beispiel #26
0
def storage(gui):
    container.openxx(
        get_place(functions.get_gamedata()["place"])["system"]["container"],
        gui)
Beispiel #27
0
def clickable(gui, event):
    gd = functions.get_gamedata()
    gui.game(event[1], event[0], ["clickable", gd["place"]])
Beispiel #28
0
def get_gps():
    try:
        return functions.get_gamedata()["gps"]
    except:
        return []