Exemple #1
0
 def _build_inventory_display(self, position):
     gold_frame = LabelFrame(self._inventory_display,
                             text=s.language.treasure)
     Label(gold_frame, image=Gallery.get("penz-d2")).grid(row=0, column=0)
     Label(gold_frame,
           textvariable=self._current_player.gold).grid(row=0, column=1)
     gold_frame.grid(row=0, column=0, sticky=N + E + W + S, padx=5)
     crew_frame = LabelFrame(self._inventory_display, text=s.language.crew)
     Label(crew_frame, image=Gallery.get("crew")).grid(row=0, column=0)
     Label(crew_frame,
           textvariable=self._current_player.crew).grid(row=0, column=1)
     crew_frame.grid(row=0, column=1, sticky=N + E + W + S, padx=5)
     self._inventory_display.grid(row=position, column=0)
     self._inventory_display.columnconfigure(
         ALL, minsize=(self.master.width - 20) / 2)
Exemple #2
0
 def _build_heading(self, position):
     flag = Gallery.get(
         f"flag_{self._current_player.empire.adjective.lower()}")
     Label(self._heading, text=self._current_player.name).grid(row=0,
                                                               column=0)
     Label(self._heading, image=flag).grid(row=1, column=0)
     self._heading.grid(row=position, column=0, pady=5)
Exemple #3
0
 def __init__(self, master, pakli, kep, nev, ertek, fuggveny, megtekint):
     Toplevel.__init__(self)
     self.master = master
     self.pakli = pakli
     self.nev = nev
     self.ertek = ertek
     self.fuggveny = fuggveny
     self.bezar = self.destroy
     cim = self.master.card_texts[self.nev][0]
     if self.nev == 'treasure':
         szoveg = self.master.card_texts[self.nev][1] % ertek
     else:
         szoveg = self.master.card_texts[self.nev][1]
     self.title(s.language.event_card if self.pakli ==
                "event" else s.language.treasure_card)
     cimStilus = 'helvetica 14 bold'
     self.kartyalap = Frame(self, relief=GROOVE, bd=2, bg='ivory')
     Label(self.kartyalap, image=Gallery.get(kep)).pack()
     Separator(self.kartyalap, orient=HORIZONTAL).pack(fill=X)
     Label(self.kartyalap, wraplength=216, text=cim,
           font=cimStilus).pack(fill=X)
     Separator(self.kartyalap, orient=HORIZONTAL).pack(fill=X)
     self.szovegfelirat = Label(self.kartyalap, wraplength=216, text=szoveg)
     self.szovegfelirat.pack(fill=X)
     self.kartyalap.pack(pady=5, padx=5)
     if megtekint:
         pass
     else:
         exec(self.fuggveny)
         self.protocol("WM_DELETE_WINDOW", self.bezar)
     self.transient(self.master)
     self.resizable(False, False)
 def _display_wind(self):
     current_direction = str(self.wind_direction.index(0))
     image_key = 'wind_direction' + current_direction
     self.board_canvas.delete(self.wind_direction_arrow)
     self.wind_direction_arrow = self.board_canvas.create_image(int(6.5 * self.tile_size),
                                                                int(2.5 * self.tile_size),
                                                                image=Gallery.get(image_key), anchor=CENTER)
Exemple #5
0
 def hajoacs_lekepez(self):
     "A hajóácspanel."
     self.hajoframek = {}
     self.hajogombok = {}
     for hajo in self.boss.vehetoHajok:
         self.hajoframek[hajo] = Frame(self.hajoacs)
         self.hajogombok[hajo] = Button(
             self.hajoframek[hajo],
             image=Gallery.get(hajo),
             command=lambda hajo=hajo: self.ujHajo(hajo))
         self.hajogombok[hajo].pack(side=LEFT)
         if self.boss.aktivjatekos.ship in self.boss.vehetoHajok:
             if self.boss.vehetoHajok.index(
                     self.boss.aktivjatekos.ship
             ) < self.boss.vehetoHajok.index(hajo):
                 ar = self.boss.hajotipustar[
                     hajo].price - self.boss.hajotipustar[
                         self.boss.aktivjatekos.ship].price
                 Label(self.hajoframek[hajo],
                       text='%s: %i %s' %
                       (s.language.price, ar, s.language.gold)).pack(
                           side=LEFT, fill=X)
             else:
                 Label(self.hajoframek[hajo],
                       text=s.language.already_bought).pack(side=LEFT,
                                                            fill=X)
         else:
             Label(self.hajoframek[hajo],
                   text='%s: %i %s' %
                   (s.language.price, self.boss.hajotipustar[hajo].price,
                    s.language.gold)).pack(side=LEFT, fill=X)
         self.hajoframek[hajo].pack(side=TOP, pady=5, padx=5, fill=X)
     self.penzszamolo()
     self.hajoacs.pack(fill=Y, pady=5)
Exemple #6
0
 def _build_state_display(self, position):
     state_field = LabelFrame(self,
                              text=s.language.cards,
                              relief=RAISED,
                              width=self.master.width - 31)
     state_slots_per_row = int((self.master.width - 31) / 32)
     state_slot_height = 24 + (
         (int(len(self._current_player.states) / state_slots_per_row) + 1) *
         32)
     if self._current_player.states:
         for index, state in enumerate(self._current_player.states):
             if state not in self._main_window.engine.nemKartyaStatusz:
                 if state in self._main_window.engine.eventszotar.keys():
                     origin = self._main_window.engine.eventszotar
                     prefix = "event"
                 else:
                     origin = self._main_window.engine.kincsszotar
                     prefix = "treasure"
                 icon = f"{prefix}_{self._main_window.engine.eventszotar[state].kep}_i"
                 icon = icon[(icon.find('_') + 1):]
                 button = Button(
                     state_field,
                     image=Gallery.get(icon),
                     command=lambda s=state: origin[s].megjelenik(1))
                 button.grid(row=int(index / state_slots_per_row),
                             column=index % state_slots_per_row)
         state_field.config(height=state_slot_height)
         if state_field.winfo_children():
             state_field.grid(row=position, column=0)
         state_field.grid_propagate(False)
 def mark_target_tiles(self, tiles):
     self.tile_marks = []
     for column, row in tiles:
         tile_mark = self.board_canvas.create_image((column - 0.5) * self.tile_size, (row - 0.5) * self.tile_size,
                                                    image=Gallery.get("X"), anchor=CENTER)
         self.tile_marks.append(tile_mark)
         self.is_field_select_visible.set(True)
     self.is_field_select_blinking = True
     self._blinker.start()
 def render_ship_figure(self, player):
     Gallery._generate_assembled_ship_image(player.ship, player.color)
     self.ship_figure_images[player.name] = Gallery.get(f"{player.ship}_{player.color}")
     if player.name in self.figures:
         self.board_canvas.delete(self.figures[player.name])
     x, y = player.coordinates
     self.figures[player.name] = self.board_canvas.create_image((x - 0.5) * self.tile_size,
                                                                (y - 0.5) * self.tile_size,
                                                                image=self.ship_figure_images[player.name],
                                                                anchor=CENTER)
Exemple #9
0
 def _build_score_field(self, position):
     self._score_field.config(text=s.language.scores)
     score_fields = {}
     target_empires = [empire.value for empire in Empires]
     target_empires.remove(self._current_player.empire)
     for index, empire in enumerate(target_empires):
         score_fields[empire.adjective] = Frame(self._score_field)
         flag = Gallery.get(f"flag_{empire.adjective.lower()}")
         Label(score_fields[empire.adjective], image=flag).grid(row=0,
                                                                column=0)
         Label(score_fields[empire.adjective], text=':').grid(row=0,
                                                              column=1)
         Label(score_fields[empire.adjective],
               textvariable=self._current_player.scores[
                   empire.adjective]).grid(row=0, column=2)
         score_fields[empire.adjective].grid(row=int((index / 2) % 2),
                                             column=index % 2,
                                             sticky=E + W)
     self._score_field.grid(row=position, column=0)
     self._score_field.columnconfigure(ALL,
                                       minsize=(self.master.width - 34) / 2)
 def _render_tiles(self):
     for location in self.locations:
         for x, y in self.locations[location]:
             self.board_canvas.create_image(int((x - 0.5) * self.tile_size), int((y - 0.5) * self.tile_size),
                                            image=Gallery.get(location), anchor=CENTER)
 def _render_battle_screen_button_images(self):
     buttons = ["gun", "rifle", "caltrop", "grenade", "grapeshot", "greek_fire", "monkey", "sirenhorn", "sirens",
                "alvarez"]
     for button in buttons:
         Gallery.get(f"icon_{button}")
 def _render_crewman(self):
     for i in range(3):
         Gallery.get(f"crewman{i}")
 def _render_flags(self):
     for empire in Empires:
         Gallery.get(f"flag_{empire.value.adjective.lower()}")
 def _render_ships(self):
     for ship_type in ['brigantine', 'frigate', 'schooner', 'galleon']:
         Gallery.get(ship_type)
 def _render_crew(self):
     Gallery.get("crew")
 def _render_money(self):
     for money_type in ['1', '8', 'd', 'd2']:
         Gallery.get(f"penz-{money_type}")
 def _render_compass(self):
     self.board_canvas.create_image(int(6.5 * self.tile_size), int(2.5 * self.tile_size),
                                    image=Gallery.get("compass"), anchor=CENTER)
     self.wind_direction_arrow = self.board_canvas.create_image(0, 0, image=None)
 def _load_tile_picker(self):
     Gallery.get("X")
 def test_get_item_existing(self):
     Gallery._pictures["foo"] = "bar"
     self.assertEqual("bar", Gallery.get("foo"))
 def _render_semi_transparent_tile_backgrounds(self):
     for (x, y) in self.tiles:
         self.board_canvas.create_image(int((x - 0.5) * self.tile_size), int((y - 0.5) * self.tile_size),
                                        image=Gallery.get("tile"), anchor=CENTER)
 def _render_background(self):
     self.board_canvas.create_image(0, 0, image=Gallery.get("map"), anchor=NW)
Exemple #22
0
 def letrehoz(self):
     self.ablak = Toplevel()
     if self.nev == 'portroyal':
         self.ablak.title((s.language.port + ' - Port Royal'))
     else:
         self.ablak.title((s.language.port, '-', self.nev.capitalize()))
     self.ablak.transient(self.master)
     self.ablak.grab_set()
     self.ujMatrozok(
     )  # A játékos belépésekor a kocka által mutatott számot hozzáadjuk a helyi matrózok létszámához.
     self.tevekenysegek = Frame(
         self.ablak)  # Főkeret: tartalma panelek és gombok
     self.tevekenysegek.pack(side=TOP, ipadx=5)
     # A kép panel
     self.kep = Label(self.tevekenysegek, image=Gallery.get(self.nev))
     self.kep.pack(side=LEFT, pady=5, padx=5, fill=Y)
     # A fogadó panel
     self.fogado = LabelFrame(self.tevekenysegek, text=s.language.tavern)
     line1 = Frame(self.fogado)  # a bérelhető létszám
     Label(line1, text=(s.language.sailors_to_hire + ':')).pack(side=LEFT)
     self.matrozokszama_kiirva = Label(
         line1, textvariable=self.matrozokszama).pack(side=RIGHT)
     line1.pack(side=TOP, fill=X)
     line2 = Frame(self.fogado)  # legénység / hajó max. kapacitás
     Label(line2, text=(s.language.crew + ':')).pack(side=LEFT)
     Label(line2,
           textvariable=self.boss.aktivjatekos.crew_limit).pack(side=RIGHT)
     Label(line2, text='/').pack(side=RIGHT)
     Label(line2, textvariable=self.boss.aktivjatekos.crew).pack(side=RIGHT)
     line2.pack(side=TOP, fill=X)
     Separator(self.fogado, orient=HORIZONTAL).pack(side=TOP,
                                                    fill=X,
                                                    pady=5,
                                                    padx=5)
     line3 = Frame(self.fogado)  # a skála címe
     szoveg = s.language.crew_new
     szoveg = szoveg + ' ' * (33 - len(szoveg))
     Label(line3, text=szoveg).pack(side=LEFT)
     line3.pack(side=TOP, fill=X)
     self.line4 = Frame(self.fogado)  # a skála
     self.berskala = Scale(self.line4)
     self.line4.pack(side=TOP, fill=X)
     self.line5 = Frame(
         self.fogado)  # a skálán beállított értéket érvényesítő gomb
     self.skalaCimke = Label(self.line5)
     self.felberel = Button(self.line5,
                            text=s.language.crew_hire,
                            command=self.matrozFelberelese)
     self.felberel.pack(side=RIGHT, padx=5, pady=5)
     self.line5.pack(side=TOP, fill=X)
     self.fogado.pack(side=LEFT, pady=5, padx=5, fill=Y)
     # A hajóács panel
     self.hajoacs = LabelFrame(self.tevekenysegek,
                               text=s.language.shipwright)
     self.hajoacs_lekepez()
     self.hajoacs.pack(side=LEFT, fill=Y, pady=5)
     # A kormányzó panel
     pontok = 0
     kormanyzo_mondja = StringVar()
     for pontforras in self.boss.aktivjatekos.scores.keys():
         pontok += self.boss.aktivjatekos.scores[pontforras].get()
     self.kormanyzo = LabelFrame(self.tevekenysegek,
                                 text=s.language.governor)
     if self.empire == 'pirate':
         elsullyesztettHelyiHajok = 0  # A kalózok nem birodalom, nem büntetnek az elsüllyedt kalózhajókért
     else:
         elsullyesztettHelyiHajok = self.boss.aktivjatekos.scores[
             self.empire.adjective].get()
     if elsullyesztettHelyiHajok > 0:
         kormanyzo_mondja.set(s.language.governor_punish %
                              elsullyesztettHelyiHajok)
         self.boss.aktivjatekos.update_turns_to_miss(
             elsullyesztettHelyiHajok)
         self.boss.aktivjatekos.scores[self.empire.adjective].set(0)
     else:
         maxJutalom = self.jutalomszamolo() * 8
         kormanyzo_mondja.set(s.language.governor_reward % maxJutalom)
         self.boss.aktivjatekos.update_gold(maxJutalom)
         self.penzszamolo()
         for birodalom in self.boss.aktivjatekos.scores.keys():
             self.boss.aktivjatekos.scores[birodalom].set(0)
     Label(self.kormanyzo, wraplength=125,
           textvariable=kormanyzo_mondja).pack(side=LEFT)
     if self.empire != 'pirate' and pontok > 0:
         self.kormanyzo.pack(side=LEFT, pady=5, padx=5, fill=Y)
     # Gombok
     Button(self.ablak, text=s.language.done,
            command=self.ablak.destroy).pack(side=BOTTOM, pady=5)
     self.ablak.update_idletasks()
     w, h = self.ablak.winfo_width(), self.ablak.winfo_height()
     bx, by = self.master.get_window_position()
     bh, bw = self.master.height, self.master.width
     self.ablak.geometry('+' + str(int(bx + (bw + (bh / 3) - w) / 2)) +
                         '+' + str(int(by + (bh - h) / 2)))
     self.master.wait_window(self.ablak)
 def test_get_item_nonexisting(self, _load_picture):
     self.assertEqual("bar", Gallery.get("foo"))
     _load_picture.assert_called_once_with("foo")