⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 movement.java

📁 java 开发的围棋打谱程序 可供大家做参考
💻 JAVA
字号:
package org.nebula.goapplet;


import java.util.*;

/**
 * Movement
 * 
 * Description:
 * 
 * @author harry
 * 
 */
public class Movement {

	private String comment; // if no comment, comment = null

	private Vector tips;

	protected int col, row; // invalid position (-1, -1)

	protected int player; // invalid player(UNKNOWN);

	private Vector captives;

	private Vector forcePut;

	private Vector erases;

	private Vector variations;

	private int curIndex;

	public Variation owner;

	public Movement() {
		this(-1, -1, GoPlayer.UNKNOWN);
	}

	public Movement(int col, int row, int player) {
		this.col = col;
		this.row = row;
		this.player = player;
		captives = new Vector();

		comment = "";
		tips = new Vector();
		forcePut = new Vector();
		erases = new Vector();

		variations = new Vector();
		owner = null;
	}

	public boolean isOpened() {
		return true;
	}

	public void addVariation(Variation v) {
		variations.addElement(v);
		v.owner = this;
	}

	public Variation getVariation(int index) {
		return (Variation) variations.elementAt(index);
	}

	public int getVarCount() {
		return variations.size();
	}

	public Variation reset() {
		curIndex = 0;
		return (Variation) variations.elementAt(curIndex);
	}

	public Variation next() {
		if (curIndex == variations.size() - 1)
			return null;
		curIndex++;
		return (Variation) variations.elementAt(curIndex);
	}

	public Variation previous() {
		if (curIndex == 0)
			return null;
		curIndex--;
		return (Variation) variations.elementAt(curIndex);
	}

	public boolean hasNext() {
		if (curIndex == variations.size() - 1)
			return false;
		return true;
	}

	public boolean hasPrevious() {
		if (curIndex == 0)
			return false;
		return true;
	}

	public Variation getCurrentVariation() {
		return (Variation) variations.elementAt(curIndex);
	}

	public void addCaptive(int c, int r, int n, int cl) {
		captives.addElement(new Captive(c, r, n, cl));
	}

	public int captiveCount() {
		return captives.size();
	}

	public Captive captiveAt(int index) {
		Captive p = (Captive) captives.elementAt(index);
		return p;
	}

	public String getComment() {
		return comment;
	}

	public void setComment(String cmt) {
		if (cmt == null)
			comment = "";
		else
			comment = cmt;
	}

	public void addForce(int x, int y, int player) {
		forcePut.addElement(new HandTip(x, y, player));
	}

	public int getForceCount() {
		return forcePut.size();
	}

	public HandTip forceAt(int index) {
		HandTip p = (HandTip) forcePut.elementAt(index);
		return p;
	}

	public void addErase(int x, int y, int player) {
		erases.addElement(new HandTip(x, y, player));
	}

	public int getEraseCount() {
		return erases.size();
	}

	public HandTip eraseAt(int index) {
		HandTip p = (HandTip) erases.elementAt(index);
		return p;
	}

	public void addTip(int x, int y, int tip) {
		tips.addElement(new HandTip(x, y, tip));
	}

	public int getTipCount() {
		return tips.size();
	}

	public HandTip tipAt(int index) {
		HandTip p = (HandTip) tips.elementAt(index);
		return p;
	}

	public final class HandTip {
		public int col, row;

		public int tip;

		public HandTip(int _col, int _row, int _tip) {
			col = _col;
			row = _row;
			tip = _tip;
		}
	}

	public class Captive {
		public int col; // invalid position (-1, -1);

		public int row;

		public int number; // if number, number = NONE

		public int color;

		public Captive(int c, int r, int n, int cl) {
			col = c;
			row = r;
			number = n;
			color = cl;
		}
	}

	public String toSimpleString() {
		if (player == GoPlayer.BLACK) {
			return "B[" + (char) ('a' + col) + (char) ('a' + row) + "]";
		} else if (player == GoPlayer.WHITE) {
			return "W[" + (char) ('a' + col) + (char) ('a' + row) + "]";
		}
		return null;
	}
}

⌨️ 快捷键说明

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