Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- note
- description: "Summary description for {PIECE}."
- author: ""
- date: "$Date$"
- revision: "$Revision$"
- class
- PIECE
- create
- make
- feature
- color: BOOLEAN
- position_x: INTEGER
- position_y: INTEGER
- type:STRING
- first_move: BOOLEAN
- make(t:STRING; clr:BOOLEAN; x,y:INTEGER)
- do
- type:= t
- color:= clr
- position_x:= x
- position_y:= y
- first_move:= true
- end
- feature
- set_newPos(x,y: INTEGER)
- do
- position_x:= x
- position_y:= y
- end
- can_move(x,y: INTEGER):BOOLEAN
- do
- if (type ~ "pawn") then
- if ((color = true and (y - position_y) = 1) or (color = false and (y - position_y) = -1)) then
- RESULT:= true;
- else
- RESULT:= false;
- end
- elseif (type ~ "bishop") then
- if ((y - position_y).abs = (x - position_x).abs) then
- RESULT:= true;
- else
- RESULT:= false;
- end
- elseif (type ~ "knight") then
- if (((y - position_y).abs = 2 and (x - position_x).abs = 1) or ((y - position_y).abs = 1 and (x - position_x).abs = 2)) then
- RESULT:= true;
- else
- RESULT:= false;
- end
- elseif (type ~ "rook") then
- if (((y - position_y).abs /= 0 and (x - position_x).abs = 0) or ((y - position_y).abs = 0 and (x - position_x).abs /= 0)) then
- RESULT:= true;
- else
- RESULT:= false;
- end
- elseif (type ~ "queen") then
- if (((y - position_y).abs /= 0 and (x - position_x).abs = 0) or ((y - position_y).abs = 0 and (x - position_x).abs /= 0)
- or (y - position_y).abs = (x - position_x).abs)
- then
- RESULT:= true;
- else
- RESULT:= false;
- end
- elseif (type ~ "king") then
- if (((x-position_x).abs = 1 and (y-position_y).abs = 0)
- or ((y-position_y).abs = 1 and (x-position_x).abs = 0)
- or ((x-position_x).abs = 1 and (y-position_y).abs = 1))
- then
- RESULT:= true;
- else
- RESULT:= false;
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement