chessjiang.java

来自「ajax chessajax chessajax chessajax chess」· Java 代码 · 共 40 行

JAVA
40
字号
package chs;

import java.util.List;

public class ChessJiang extends ChessItem {

	public ChessJiang(String id, int x, int y) {
		super(id, x, y);
		// TODO Auto-generated constructor stub
	}

	public ChessJiang(ChessBoard b, String id, int x, int y) {
		super(b, id, x, y);
		// TODO Auto-generated constructor stub
	}

	public boolean moveTo(int x, int y) {
		ChessItem cpj = b.findItemAt(x, y);
		List lstFind = b.findItemOnLine(this.getX(), this.getY(), x, y);
		if (cpj != null && cpj.isType('j') && this.isOnLine(x, y)
				&& lstFind.size() == 0) {
			return true;
		}
		
		if (!this.isOnStep(x, y)) {
			System.err.println("move over 1 step.");
			return false;
		}
		
		// 不在王宫里
		if (this.isInBase(x, y)) {
			System.err.println("move out of palace.");
			return false;
		}
		
		return true;
	}

};

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?