📄 remove_figure.m
字号:
function remove_figure( from )
% remove_figure removes(beats) a figure from the field and deletes the instance
%
% Inputs:
% * from ... position in matrix notation (i.e. [2 3])
% * global board ... chess board information
% * global game ... information about the game status
%
% Outputs:
% * global game ... possible change in game status (i.e. King is beaten)
% * global board ... remove a certain figure from the board (if there was any)
%
% Example
% Assume there is a night on [3 4]. The |remove_figure( [3 4] )| gets rid
% of it.
%
% See also: Chess
%
%TODO: update of figure instances
%
%% Signature
% Author: W.Garn
% E-Mail: wgarn@yahoo.com
% Date: 2006/03/23 12:00:00
%
% Copyright 2006 W.Garn
%
global board;
global game;
fig = board.figures(from(1),from(2));
board.last2field = fig;
if fig ~=' '
color = getColor(from);
[name, handle_chess_figure] = getFigureName(fig);
if ~isempty(handle_chess_figure)
handle_chess_figure('remove',from);
else
disp(['I do not knwo how to remove a ' name ' yet :(']);
end
if upper(fig)== 'K' % king is removed!
game.status = 0; % game over
end
% general removement
board.figures(from(1),from(2)) = ' ';
if color %white
board.white(from(1),from(2)) = 0;
else
board.black(from(1),from(2)) = 0;
end
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -