def __init__(self, user_IP):
        window = tkinter.Tk()

        self.window = window
        window.attributes("-fullscreen", True)
        # Set Window
        window.title("Fate Game")
        # Set ""Class"" Variables
        self.user_IP = user_IP
        self.monitor_resolution_x = window.winfo_screenwidth()
        self.monitor_resolution_y = window.winfo_screenheight()
        UIAssetImport.Cover(self)
        # Create main Canvas
        self.canvas = tkinter.Canvas(window,
                                     width=self.monitor_resolution_x,
                                     height=self.monitor_resolution_y,
                                     bg="#333337",
                                     bd=0,
                                     highlightthickness=0,
                                     relief='ridge')
        self.canvas.pack()
        self.canvas.create_image(0, 0, image=self.wallpaper, anchor="nw")
        self.canvas.create_image(10,
                                 0,
                                 image=self.logo_image,
                                 anchor="nw",
                                 tags="logo_image")
        self.canvas.tag_bind("logo_image", "<Button-1>", self.quit_program)
        self.canvas.create_image(self.monitor_resolution_x / 2,
                                 self.monitor_resolution_y - 250,
                                 image=self.ui_click_to_start,
                                 anchor="c",
                                 tags="click_to_start")
Esempio n. 2
0
 def update_servant_list(self):
     list_pos_y = 252
     for i in range(len(self.canvas_servant_list_bg)):
         self.canvas_servant_list.delete(self.canvas_servant_list_bg[i])
         self.canvas_servant_list.delete(
             self.canvas_servant_list_text_name[i])
         self.canvas_servant_list.delete(self.canvas_servant_list_image[i])
         self.canvas_servant_list.delete(
             self.canvas_servant_list_image_ref[i])
     for servant in self.servant_list[self.servant_list_page]:
         self.canvas_servant_list_bg.append(
             self.canvas_servant_list.create_rectangle(
                 123,
                 list_pos_y - 27,
                 580,
                 list_pos_y + 27,
                 fill="#2c2303",
                 tags=(servant['Name'], "servant_list")))
         self.canvas_servant_list_text_name.append(
             self.canvas_servant_list.create_text(180,
                                                  list_pos_y,
                                                  text=servant['Name'],
                                                  fill="#cccccc",
                                                  font=("Coolvetica Rg",
                                                        25),
                                                  anchor="w",
                                                  tags=(servant['Name'],
                                                        "servant_list")))
         try:
             servant_image = UIAssetImport.get_servant_icon(servant, 50, 50)
         except FileNotFoundError:
             GlobalLibrary.error(
                 str("Servant needs icon: " + servant['Name']))
             servant_image = UIAssetImport.image_resize(
                 "Pictures/Class-Shielder-Gold.png", 50, 50)
         self.canvas_servant_list_image_ref.append(servant_image)
         self.canvas_servant_list_image.append(
             self.canvas_servant_list.create_image(150,
                                                   list_pos_y,
                                                   image=servant_image,
                                                   anchor="c",
                                                   tags=(servant['Name'],
                                                         "servant_list")))
         list_pos_y += 55
     self.canvas_servant_list.tag_bind("servant_list", "<Button-1>",
                                       self.select_servant)
 def load_map(self, map_name, player_servants):
     map_path = str("Maps/" + map_name + ".map")
     y = 0
     with open(map_path, "r") as map_file:
         for map_line in map_file.readlines():
             map_line = ast.literal_eval(map_line)
             x = 0
             for tile_value in map_line:
                 self.set_grid_pos(x, y, tile_value, False)
                 x += 1
             y += 1
     map_cfg_path = str("Maps/" + map_name + ".cfg")
     with open(map_cfg_path, "r") as map_cfg:
         state = 0
         self.tileset = []
         enemy_list = []
         for cfg_line in map_cfg.readlines():
             cfg_line = cfg_line.strip("\n")
             if cfg_line == 'Tileset:':
                 state = 0
             elif cfg_line == 'Enemies:':
                 state = 1
             elif cfg_line == "":
                 continue
             else:
                 cfg_line = ast.literal_eval(cfg_line)
                 if isinstance(cfg_line, list) and state == 0:
                     self.tileset.append(cfg_line)
                 elif isinstance(cfg_line, list) and state == 1:
                     enemy_list.append(cfg_line)
     UIAssetImport.load_tileset(self.tileset, self.grid_size, self.GUI)
     self.display_grid_graphics()
     self.spawn_player_servants(player_servants)
     for enemy in enemy_list:
         self.set_grid_pos(enemy[0], enemy[1],
                           Servants.get_enemy_servant(enemy[2], enemy[3]),
                           True)
         self.turn_tracker.TurnCounterList.append(enemy[2])
Esempio n. 4
0
 def update_team_list(self):
     self.team_list_image_ref_array = []
     player_servant_list = [
         self.player_stats.servant_ref_1, self.player_stats.servant_ref_2,
         self.player_stats.servant_ref_3
     ]
     for i in range(len(player_servant_list)):
         self.team_list_image_ref_array.append(
             UIAssetImport.get_servant_icon(player_servant_list[i], 70, 70))
         self.canvas_team_list.itemconfigure(
             self.canvas_team_list_icons[i],
             image=self.team_list_image_ref_array[i])
         self.canvas_team_list.itemconfigure(
             self.canvas_team_list_text_name[i],
             text=player_servant_list[i]['Name'])
         self.canvas_team_list.itemconfigure(
             self.canvas_team_list_text_atk[i],
             text=str("ATK: " + str(player_servant_list[i]['ATK'])))
         self.canvas_team_list.itemconfigure(
             self.canvas_team_list_text_hp[i],
             text=str("HP: " + str(player_servant_list[i]['HP'])))
         self.canvas_team_list.itemconfigure(
             self.canvas_team_list_text_lvl[i],
             text=player_servant_list[i]['Level'])
         try:
             if player_servant_list[i]['Class'] == "Saber":
                 servant_class = self.ui_class_saber
             elif player_servant_list[i]['Class'] == "Archer":
                 servant_class = self.ui_class_archer
             elif player_servant_list[i]['Class'] == "Lancer":
                 servant_class = self.ui_class_lancer
             elif player_servant_list[i]['Class'] == "Caster":
                 servant_class = self.ui_class_caster
             elif player_servant_list[i]['Class'] == "Rider":
                 servant_class = self.ui_class_rider
             elif player_servant_list[i]['Class'] == "Assassin":
                 servant_class = self.ui_class_assassin
             elif player_servant_list[i]['Class'] == "Ruler":
                 servant_class = self.ui_class_ruler
             elif player_servant_list[i]['Class'] == "Shielder":
                 servant_class = self.ui_class_shielder
             elif player_servant_list[i]['Class'] == "Berserker":
                 servant_class = self.ui_class_berserker
         except KeyError:
             print("REMEMBER TO ADD CLASSES TO SERVANTS")
         self.canvas_team_list.itemconfigure(self.canvas_team_list_class[i],
                                             image=servant_class)
Esempio n. 5
0
    def __init__(self, window, user_IP):
        self.init_finished = False
        self.user_IP = user_IP
        self.window = window
        self.image_array = []
        self.image_ref_array = []
        self.canvases = []
        self.canvas_team_list_icons = []
        self.canvas_team_list_text_name = []
        self.canvas_team_list_text_atk = []
        self.canvas_team_list_text_hp = []
        self.canvas_team_list_text_lvl = []
        self.canvas_team_list_class = []
        self.canvas_servant_list_bg = []
        self.canvas_servant_list_text_name = []
        self.canvas_servant_list_image = []
        self.canvas_servant_list_image_ref = []
        self.servant_list_page_max = 0
        self.servant_list_page = 0
        self.servant_list = []
        self.servant_data = object
        self.canvas_servant_list_selected_bg = None
        self.selected_servant = ""
        self.monitor_resolution_x = self.window.winfo_screenwidth()
        self.monitor_resolution_y = self.window.winfo_screenheight()
        if not hasattr(self, 'canvas'):
            UIAssetImport.Menu(self)

        self.servant_database = Mongo.ServantDatabase()
        self.servant_database.sync_files()
        self.update_databases()

        # Create main Canvas
        self.window.configure(bg='#333337')

        self.create_canvas_quit()
        self.create_canvas_servant_list()
        self.create_canvas_servant_bio()
        self.create_canvas_team_list()
        self.create_canvas_battle()
        self.init_finished = True
Esempio n. 6
0
    def show_servant_bio(self):
        for servant in self.servant_list[self.servant_list_page]:
            if servant['Name'] == self.selected_servant:
                self.servant_data = servant
        base_servant_data = Servants.get_servant(self.servant_data['Name'])
        self.canvas_servant_bio.create_image(415,
                                             500,
                                             image=self.ui_servant_bio,
                                             anchor="c",
                                             tags="servant_bio")
        self.canvas_servant_bio.create_text(220,
                                            280,
                                            text=self.servant_data['Name'],
                                            fill="#cccccc",
                                            font=("Coolvetica Rg", 30),
                                            anchor="w",
                                            tags="servant_bio")
        try:
            self.selected_servant_image = UIAssetImport.get_servant_icon(
                self.servant_data, 125, 125)
        except FileNotFoundError:
            GlobalLibrary.error("REMEMBER TO ADD ICON PATHS TO SERVANTS!!!")
            self.selected_servant_image = UIAssetImport.image_resize(
                "Pictures/Class-Shielder-Gold.png", 125, 125)
        self.canvas_servant_bio.create_image(107,
                                             315,
                                             image=self.selected_servant_image,
                                             anchor="c",
                                             tags="servant_bio")
        self.canvas_servant_bio.create_text(
            220,
            320,
            text=str("HP: " + str(self.servant_data['HP']) + " (" +
                     str(base_servant_data['HP']) + ")"),
            fill="#888888",
            font=("Coolvetica Rg", 15),
            anchor="w",
            tags="servant_bio")
        self.canvas_servant_bio.create_text(
            400,
            320,
            text=str("HP: " + str(self.servant_data['ATK']) + " (" +
                     str(base_servant_data['ATK']) + ")"),
            fill="#888888",
            font=("Coolvetica Rg", 15),
            anchor="w",
            tags="servant_bio")
        self.canvas_servant_bio.create_text(
            580,
            320,
            text=str("Move: " + str(self.servant_data['Move'])),
            fill="#888888",
            font=("Coolvetica Rg", 15),
            anchor="w",
            tags="servant_bio")
        self.canvas_servant_bio.create_rectangle(215,
                                                 340,
                                                 780,
                                                 370,
                                                 fill="#2c2303",
                                                 tags="servant_bio")

        self.canvas_servant_bio.create_rectangle(220,
                                                 345,
                                                 (self.servant_data['Level'] *
                                                  ((775 - 215) / 100)) + 215,
                                                 365,
                                                 fill="#433607",
                                                 tags="servant_bio")
        self.canvas_servant_bio.create_text(
            ((self.servant_data['Level'] * ((775 - 215) / 100)) / 2) + 215,
            355,
            text=str(self.servant_data['Level']),
            fill="#888888",
            font=("Coolvetica Rg", 12),
            anchor="c",
            tags="servant_bio")
        try:
            if self.servant_data['Class'] == "Saber":
                servant_class = self.ui_class_saber
            elif self.servant_data['Class'] == "Archer":
                servant_class = self.ui_class_archer
            elif self.servant_data['Class'] == "Lancer":
                servant_class = self.ui_class_lancer
            elif self.servant_data['Class'] == "Caster":
                servant_class = self.ui_class_caster
            elif self.servant_data['Class'] == "Rider":
                servant_class = self.ui_class_rider
            elif self.servant_data['Class'] == "Assassin":
                servant_class = self.ui_class_assassin
            elif self.servant_data['Class'] == "Ruler":
                servant_class = self.ui_class_ruler
            elif self.servant_data['Class'] == "Shielder":
                servant_class = self.ui_class_shielder
            elif self.servant_data['Class'] == "Berserker":
                servant_class = self.ui_class_berserker
            self.canvas_servant_bio.create_image(740,
                                                 290,
                                                 image=servant_class,
                                                 anchor="c",
                                                 tags="servant_bio")
        except KeyError:
            GlobalLibrary.error("REMEMBER TO ADD CLASSES TO SERVANTS")
        except UnboundLocalError:
            GlobalLibrary.error("REMEMBER TO ADD CLASSES TO SERVANTS")

        try:
            self.canvas_servant_bio.create_text(55,
                                                425,
                                                text=str(
                                                    self.servant_data['Desc']),
                                                fill="#888888",
                                                font=("Coolvetica Rg", 15),
                                                anchor="nw",
                                                justify="left",
                                                width=725,
                                                tags="servant_bio")
        except KeyError:
            GlobalLibrary.error("REMEMBER TO ADD DESCRIPTIONS TO SERVANTS")
        self.canvas_team_list.create_image(
            100, (int(self.canvas_team_list.cget("height")) / 2) - 160,
            image=self.ui_servant_list_button,
            anchor="c",
            tags=("servant_bio", "team_slot1"))
        self.canvas_team_list.create_image(
            100, (int(self.canvas_team_list.cget("height")) / 2) - 160,
            image=self.ui_right_arrow,
            anchor="c",
            tags=("servant_bio", "team_slot1"))
        self.canvas_team_list.create_image(
            100, (int(self.canvas_team_list.cget("height")) / 2) - 30,
            image=self.ui_servant_list_button,
            anchor="c",
            tags=("servant_bio", "team_slot2"))
        self.canvas_team_list.create_image(
            100, (int(self.canvas_team_list.cget("height")) / 2) - 30,
            image=self.ui_right_arrow,
            anchor="c",
            tags=("servant_bio", "team_slot2"))
        self.canvas_team_list.create_image(
            100, (int(self.canvas_team_list.cget("height")) / 2) + 100,
            image=self.ui_servant_list_button,
            anchor="c",
            tags=("servant_bio", "team_slot3"))
        self.canvas_team_list.create_image(
            100, (int(self.canvas_team_list.cget("height")) / 2) + 100,
            image=self.ui_right_arrow,
            anchor="c",
            tags=("servant_bio", "team_slot3"))
        self.canvas_team_list.tag_bind("team_slot1", "<Button-1>",
                                       self.set_player_servant)
        self.canvas_team_list.tag_bind("team_slot2", "<Button-1>",
                                       self.set_player_servant)
        self.canvas_team_list.tag_bind("team_slot3", "<Button-1>",
                                       self.set_player_servant)
    def __init__(self, window, user_IP, grid_amount, grid_size, turn_tracker,
                 player_stats):
        GlobalLibrary.initalise(Main.__name__)
        self.window = window
        # Set ""Global"" Variables
        self.user_IP = user_IP
        self.grid_amount = grid_amount  # Number of Boxes
        self.grid_size = grid_size  # Box Size
        self.grid_manager = None
        self.grid_clicked_x = int
        self.grid_clicked_y = int
        self.turn_tracker = turn_tracker
        self.player_stats = player_stats
        self.servant_has_moved = False
        self.image_array = []
        self.image_ref_array = []
        self.selection_array = []
        self.monitor_resolution_x = window.winfo_screenwidth()
        self.monitor_resolution_y = window.winfo_screenheight()
        self.grid_origin_x = self.monitor_resolution_x / 2 + (
            -int(self.grid_amount / 2) * self.grid_size)
        self.grid_origin_y = self.monitor_resolution_y / 2 + (
            -int(self.grid_amount / 2) * self.grid_size)
        self.selected_servant = object
        if not hasattr(self, 'canvas'):
            UIAssetImport.Battle(self, grid_size)
        # Create main Canvas
        self.canvas = tkinter.Canvas(window,
                                     width=self.monitor_resolution_x,
                                     height=self.monitor_resolution_y,
                                     bg="#333337",
                                     bd=0,
                                     highlightthickness=0,
                                     relief='ridge')
        self.canvas.pack()
        self.canvas.create_image(10,
                                 0,
                                 image=self.logo_image,
                                 anchor="nw",
                                 tags="logo_image")
        self.canvas.tag_bind("logo_image", "<Button-1>", self.open_main_menu)

        # Set Mouse Binds
        self.canvas.bind("<Button-1>", self.click)

        self.turn_counter_bg = self.canvas.create_image(
            self.monitor_resolution_x,
            self.monitor_resolution_y,
            image=self.ui_turn_order_bg,
            anchor="se")
        self.turn_counter_text = (self.canvas.create_text(
            self.monitor_resolution_x - 65,
            self.monitor_resolution_y - 88,
            text="DEBUG",
            fill="#ffffff",
            font=("Coolvetica Rg", 20),
            anchor="c",
            justify="center"))
        self.turn_counter_image = []
        self.turn_counter_image.append(
            self.canvas.create_image(self.monitor_resolution_x - 275,
                                     self.monitor_resolution_y - 30,
                                     image=self.logo_image,
                                     anchor="c"))
        self.turn_counter_image.append(
            self.canvas.create_image(self.monitor_resolution_x - 175,
                                     self.monitor_resolution_y - 30,
                                     image=self.logo_image,
                                     anchor="c"))
        self.turn_counter_image.append(
            self.canvas.create_image(self.monitor_resolution_x - 75,
                                     self.monitor_resolution_y - 30,
                                     image=self.logo_image,
                                     anchor="c"))