Esempio n. 1
0
    def draw_boardareaarea(self):
        uc.werase(self.win_board)

        uc.box(self.win_boardarea, 0, 0)

        uc.wmove(self.win_boardarea, 1, 2)
        if self.on_menu:
            s = self.player.board.__str__()
        else:
            s = self.player.board.show_new_ship(self.new_ship_x,
                                                self.new_ship_y,
                                                self.menu[self.menu_hi].id,
                                                self.menu[self.menu_hi].length,
                                                self.new_ship_hor)

        for chr in s:
            if chr == '~':
                uc.wattron(self.win_board, uc.COLOR_PAIR(11))
                uc.waddstr(self.win_board, chr)
                uc.wattroff(self.win_board, uc.COLOR_PAIR(11))
            elif chr == 'O':
                uc.wattron(self.win_board, uc.COLOR_PAIR(12))
                uc.waddstr(self.win_board, chr)
                uc.wattroff(self.win_board, uc.COLOR_PAIR(12))
            elif chr == '#':
                uc.wattron(self.win_board, uc.COLOR_PAIR(13))
                uc.waddstr(self.win_board, chr)
                uc.wattroff(self.win_board, uc.COLOR_PAIR(13))
            else:
                uc.wattron(self.win_board, uc.COLOR_PAIR(12))
                uc.waddstr(self.win_board, chr)
                uc.wattroff(self.win_board, uc.COLOR_PAIR(12))

        uc.wrefresh(self.win_boardarea)
        uc.update_panels()
Esempio n. 2
0
	def draw_board(self):
		uc.wclear(self.win_board1)
		uc.wclear(self.win_baord2)

		uc.box(self.win_boardarea, 0, 0)

		uc.wmove(self.win_boardarea, 1, 2)

		s1 = self.player.board.__str__()
		s2 = self.player_enemy.board.__str__()

		for chr in s1:
			if chr == '~':
				uc.wattron(self.win_board, uc.COLOR_PAIR(11))
				uc.waddstr(self.win_board, chr)
				uc.wattroff(self.win_board, uc.COLOR_PAIR(11))
			elif chr == 'O':
				uc.wattron(self.win_board, uc.COLOR_PAIR(12))
				uc.waddstr(self.win_board, chr)
				uc.wattroff(self.win_board, uc.COLOR_PAIR(12))
			elif chr == '#':
				uc.wattron(self.win_board, uc.COLOR_PAIR(13))
				uc.waddstr(self.win_board, chr)
				uc.wattroff(self.win_board, uc.COLOR_PAIR(13))
			else:
				uc.wattron(self.win_board, uc.COLOR_PAIR(12))
				uc.waddstr(self.win_board, chr)
				uc.wattroff(self.win_board, uc.COLOR_PAIR(12))

		uc.wrefresh(self.win_boardarea)
		uc.update_panels()
Esempio n. 3
0
def win_show(win, label, label_color):
    starty, startx = uni.getbegyx(win)
    height, width = uni.getmaxyx(win)
    uni.box(win, 0, 0)
    uni.mvwaddch(win, 2, 0, uni.ACS_LTEE)
    uni.mvwhline(win, 2, 1, uni.ACS_HLINE, width - 2)
    uni.mvwaddch(win, 2, width - 1, uni.ACS_RTEE)
    print_in_middle(win, 1, 0, width, label, uni.COLOR_PAIR(label_color))
Esempio n. 4
0
    def draw_board(self):
        uc.wclear(self.win_board)

        offset_x = 2
        offset_y = 1

        uc.box(self.win_boardarea, 0, 0)

        uc.wmove(self.win_boardarea, offset_y, offset_x)
        if self.on_menu:
            s = self.player.board.__str__()
        else:
            s = self.player.board.show_new_ship(self.new_ship_x,
                                                self.new_ship_y,
                                                self.menu[self.menu_hi].id,
                                                self.menu[self.menu_hi].length,
                                                self.new_ship_hor)

        uc.init_pair(11, uc.COLOR_BLUE, uc.COLOR_BLACK)
        uc.init_pair(12, uc.COLOR_WHITE, uc.COLOR_BLACK)
        uc.init_pair(13, uc.COLOR_RED, uc.COLOR_BLACK)

        for chr in s:
            if chr == '~':
                uc.wattron(self.win_board, uc.COLOR_PAIR(11))
                uc.waddstr(self.win_board, chr)
                uc.wattroff(self.win_board, uc.COLOR_PAIR(11))
            elif chr == 'O':
                uc.wattron(self.win_board, uc.COLOR_PAIR(12))
                uc.waddstr(self.win_board, chr)
                uc.wattroff(self.win_board, uc.COLOR_PAIR(12))
            elif chr == '#':
                uc.wattron(self.win_board, uc.COLOR_PAIR(13))
                uc.waddstr(self.win_board, chr)
                uc.wattroff(self.win_board, uc.COLOR_PAIR(13))
            else:
                uc.wattron(self.win_board, uc.COLOR_PAIR(12))
                uc.waddstr(self.win_board, chr)
                uc.wattroff(self.win_board, uc.COLOR_PAIR(12))

        uc.wbkgd(self.win_statusbar, uc.COLOR_PAIR(11))

        uc.wrefresh(self.win_boardarea)
        uc.update_panels()
Esempio n. 5
0
    def draw_statusbar(self):
        uc.wclear(self.win_statusbar)
        s = '[q] quit   '

        if self.on_menu:
            s += '[\u2191\u2193] move   '
            s += '[\u21B5] select   '
        else:
            s += '[\u2190\u2191\u2192\u2193] move   '
            s += '[r] rotate   '
            s += '[s] suggest   '
            s += '[\u21B5] commit   '

        s += f'{self.num_ships_set}/{len(self.player.ship_list)} set'

        uc.waddstr(self.win_statusbar, s)
        uc.init_pair(4, uc.COLOR_WHITE, uc.COLOR_BLUE)
        uc.wbkgd(self.win_statusbar, uc.COLOR_PAIR(4))
        uc.wrefresh(self.win_statusbar)
Esempio n. 6
0
    def close(self):
        prompt_start_x = self.max_x // 2 - 19
        prompt_start_y = self.max_y // 3

        if prompt_start_x < 1:
            prompt_start_x = 1
        if prompt_start_y < 1:
            prompt_start_y = 1

        win_prompt = uc.newwin(3, 38, prompt_start_y, prompt_start_x)
        uc.box(win_prompt, 0, 0)
        uc.mvwaddstr(win_prompt, 1, 1, 'Do you want to close the game? (y|n)')
        uc.wbkgd(win_prompt, uc.COLOR_PAIR(1))
        uc.wrefresh(win_prompt)

        answer = uc.wgetch(stdscr)
        if answer == ord('y') or answer == ord('Y'):
            uc.endwin()
            exit()
        else:
            uc.delwin(win_prompt)
Esempio n. 7
0
uni.init_pair(3, uni.COLOR_BLUE, uni.COLOR_BLACK)
uni.init_pair(4, uni.COLOR_CYAN, uni.COLOR_BLACK)

init_wins(my_wins, 3)

my_panels[0] = uni.new_panel(my_wins[0])
my_panels[1] = uni.new_panel(my_wins[1])
my_panels[2] = uni.new_panel(my_wins[2])

uni.set_panel_userptr(my_panels[0], my_panels[1])
uni.set_panel_userptr(my_panels[1], my_panels[2])
uni.set_panel_userptr(my_panels[2], my_panels[0])

uni.update_panels()

uni.attron(uni.COLOR_PAIR(4))
uni.mvaddstr(0,
             int(NCOLS / 2) - 2,
             "Use tab to browse through the windows (Q to Exit)")
uni.attroff(uni.COLOR_PAIR(4))
uni.doupdate()

top = my_panels[2]

ch = -1
while ((ch != uni.CCHAR('q')) and (ch != uni.CCHAR('Q'))):
    ch = uni.getch()
    if ch == 9:
        top = uni.panel_userptr(top)
        uni.top_panel(top)
    uni.update_panels()