Bug 235 - Incorrect position information of initializtion
Summary: Incorrect position information of initializtion
Status: CONFIRMED
Alias: None
Product: CS3343 group25 chess game
Classification: Unclassified
Component: chess game (show other bugs)
Version: unspecified
Hardware: PC Mac OS
: --- enhancement
Assignee: HUANG Xiaofeng
URL:
Depends on:
Blocks:
 
Reported: 2017-11-30 10:09 HKT by Andy
Modified: 2017-11-30 10:09 HKT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andy 2017-11-30 10:09:05 HKT
public boolean upgrade(int role, int x, int y, int target_x, int target_y) {
		switch (role){
		case 1:
			theChessBoard.initialize(target_x, target_y, new Knight(theChessBoard.getPiece(x, y).getColor(),"1"));
			return true;
		case 2:
			theChessBoard.initialize(target_x, target_y, new Bishop(theChessBoard.getPiece(x, y).getColor(),"1"));
			return true;
		case 3:
			theChessBoard.initialize(target_x, target_y, new Rook(theChessBoard.getPiece(x, y).getColor(),"1"));
			return true;
		case 4:
			theChessBoard.initialize(target_x, target_y, new Queen(theChessBoard.getPiece(x, y).getColor(),"1"));
			return true;
		default:
			return false;
		}
	}

This step is behind the move action, so theChessBoard.getPiece(x, y) should be theChessBoard.getPiece(target_x, target_y)