Android Open Source - abalone-android Move






From Project

Back to project page abalone-android.

License

The source code is released under:

GNU General Public License

If you think the Android project abalone-android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/**
* Copyright (c) 2010-2011 Yaroslav Geryatovich, Alexander Yakushev
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*//*w  ww .  j  a  v a2s.c o m*/
package com.bytopia.abalone.mechanics;

/**
 * Class that represents a process of moving - the group which is moved, new
 * position of this group and so on.
 * 
 * @author Bytopia
 */
public class Move {

  /**
   * Source group that is moved.
   */
  private Group source;

  /**
   * New position of the moved group.
   */
  private Group destination;

  /**
   * Direction in which the group was moved.
   */
  private byte direction;

  /**
   * Side that performs a move.
   */
  private byte side;

  /**
   * Constructs a move of the given group in a given destination made by
   * player of a given side.
   * 
   * @param group
   *            group that is moved
   * @param d
   *            direction in which it is moved
   * @param side
   *            side that moves the group
   */
  public Move(Group group, byte d, byte side) {
    source = group;
    destination = group.shift(d);
    direction = d;
    this.side = side;
  }

  /**
   * Returns the group that is moved.
   * 
   * @return group being moved
   */
  public Group getSource() {
    return source;
  }

  /**
   * Returns the new position of the moved group.
   * 
   * @return group after the movement.
   */
  public Group getDestination() {
    return destination;
  }

  /**
   * Returns the direction in which group is moved.
   * 
   * @return direction of movement
   */
  public byte getDirection() {
    return direction;
  }

  /**
   * Returns the side that moves the group.
   * 
   * @return player side
   */
  public byte getSide() {
    return side;
  }

  /**
   * Tests if the move performed is a pushing move.
   * 
   * @return true if the move is pushing, false if the move is leaping
   */
  public boolean isPushing() {
    return source.isLineDirected(direction);
  }

  /**
   * Returns the peak of the moved group.
   * 
   * @return peak cell of the move
   */
  public Cell getPeak() {
    return source.getPeak(direction);
  }

  /**
   * Returns the tail of the moved group.
   * 
   * @return tail cell of the move
   */
  public Cell getTail() {
    return source.getPeak(Direction.opposite[direction]);
  }

  /**
   * Returns a string representing the movement in a form of
   * "source direction", e.g. "A1-C3 SouthEast"
   */
  @Override
  public String toString() {
    return source.toString() + " " + direction;
  }
  
}




Java Source Code List

com.bytopia.abalone.BoardRenderer.java
com.bytopia.abalone.BoardView.java
com.bytopia.abalone.GameActivity.java
com.bytopia.abalone.GameOptionsActivity.java
com.bytopia.abalone.LoseBallsView.java
com.bytopia.abalone.MainMenuActivity.java
com.bytopia.abalone.Options.java
com.bytopia.abalone.Scenario.java
com.bytopia.abalone.SelectLayoutActivity.java
com.bytopia.abalone.SplashAcitvity.java
com.bytopia.abalone.TutorialActivity.java
com.bytopia.abalone.TutorialBoardView.java
com.bytopia.abalone.mechanics.AiAnn.java
com.bytopia.abalone.mechanics.AiBeatrice.java
com.bytopia.abalone.mechanics.AiCharlotte.java
com.bytopia.abalone.mechanics.AiDeborah.java
com.bytopia.abalone.mechanics.ArtificialIntilligence.java
com.bytopia.abalone.mechanics.BelgianLayout.java
com.bytopia.abalone.mechanics.Board.java
com.bytopia.abalone.mechanics.Cell.java
com.bytopia.abalone.mechanics.ClassicLayout.java
com.bytopia.abalone.mechanics.ConsoleWatcher.java
com.bytopia.abalone.mechanics.Debug.java
com.bytopia.abalone.mechanics.Direction.java
com.bytopia.abalone.mechanics.EmptyLayout.java
com.bytopia.abalone.mechanics.Game.java
com.bytopia.abalone.mechanics.GermanLayout.java
com.bytopia.abalone.mechanics.Group.java
com.bytopia.abalone.mechanics.Layout.java
com.bytopia.abalone.mechanics.MoveType.java
com.bytopia.abalone.mechanics.Move.java
com.bytopia.abalone.mechanics.Player.java
com.bytopia.abalone.mechanics.Side.java
com.bytopia.abalone.mechanics.TestLayout.java
com.bytopia.abalone.mechanics.Watcher.java