Exemple #1
0
 def spawn_validation(self, color, name, x, y):
     if color not in ('white', 'black'):
         screen.addstr(13, 2, 'Invalid color')
         return False
     elif x * y < 0 or x > 7 or y > 7:
         screen.addstr(13, 2, 'Out of range')
         return False
     else:
         return True
Exemple #2
0
 def draw_indexes(self):
     for i in range(8):
         screen.addstr(1, 3 + (i * 2),
                       chr(97 + i))  # 97 -> 'a' in ASCII code
         screen.addstr(10, 3 + (i * 2), chr(97 + i))
         screen.addstr(2 + i, 1, str(8 - i))
         screen.addstr(2 + i, 19, str(8 - i))
Exemple #3
0
 def display(self):
     self.draw_indexes()
     moves = []
     if Cursor.sel:
         a, b = Cursor.selected()
         moves = self.highlight_movable_fields(self.board[b][a])
     for y in reversed(range(8)):
         for x in range(8):
             Minion = self.board[y][x]
             color = self.color_as_number(Minion)
             if (x, y) == Cursor.pointed():
                 screen.addstr(2 + y, 3 + (x * 2), Minion.symbol,
                               curses.color_pair(color) | curses.A_BOLD)
             elif (x, y) == Cursor.selected():
                 screen.addstr(2 + y, 3 + (x * 2), Minion.symbol,
                               curses.color_pair(4) | curses.A_BOLD)
             elif (x, y) in (moves):
                 screen.addstr(2 + y, 3 + (x * 2), Minion.symbol,
                               curses.color_pair(9))
             else:
                 screen.addstr(2 + y, 3 + (x * 2), Minion.symbol,
                               curses.color_pair(color))
Exemple #4
0
 def display(self):
     screen.addstr(self.shift_y - 1, self.shift_x + 2, '{0} mode'.format(self.mode))
     for i, string in enumerate(self.log):
         screen.addstr(self.shift_y + i, self.shift_x, string)
Exemple #5
0
 def draw_log_border(self):
     for y in range(self.height):
         for x in range(self.width):
             screen.addstr(self.shift_y + y, self.shift_x + x, '*')
Exemple #6
0
 def show_cursor_info(self):
     selected = Chess.board[self.index_y][self.index_x]
     screen.addstr(1, 62, 'console coords: ')
     screen.addstr(2, 62, '({0}, {1})'.format(self.x + self.shift_x, self.y + self.shift_y))
     screen.addstr(3, 62, 'board indexes: ')
     screen.addstr(4, 62, '({0}, {1})'.format(self.index_x, self.index_y))
     screen.addstr(5, 62, 'chess notation: ')
     screen.addstr(6, 62, '({0}, {1})'.format(chr(97 + self.index_x), 8 - self.index_y))
     screen.addstr(7, 62, selected.info())
Exemple #7
0
 def show_selected_minion_moves(self):
     moves = Chess.board[self.index_y][self.index_x].valid_moves
     for i, key in enumerate(moves.keys()):
         screen.addstr(12, 3, 'Valid moves: ')
         screen.addstr(13 + i, 5, key)
         screen.addstr(13 + i, 8, str(moves[key]))