package com.cardshifter.api.incoming;

import java.util.Arrays;

import com.cardshifter.api.ArrayUtil;
import com.cardshifter.api.abstr.CardMessage;

public class UseAbilityMessage extends CardMessage {

	private final int id;
	private final String action;
	private final int gameId;
	private final int[] targets;

	public UseAbilityMessage() {
		this(0, 0, "", new int[0]);
	}

	public UseAbilityMessage(int gameId, int id, String action, int[] targets) {
		super("use");
		this.id = id;
		this.action = action;
		this.gameId = gameId;
		this.targets = ArrayUtil.copyOf(targets);
	}
	
	public UseAbilityMessage(int gameid, int entity, String action, int target) {
		this(gameid, entity, action, new int[]{ target });
	}

	public String getAction() {
		return action;
	}
	
	public int getId() {
		return id;
	}
	
	public int getGameId() {
		return gameId;
	}
	
	public int[] getTargets() {
		return ArrayUtil.copyOf(targets);
	}

	@Override
	public String toString() {
		return "UseAbilityMessage [id=" + id + ", action=" + action
				+ ", gameId=" + gameId + ", targets=" + Arrays.toString(targets) + "]";
	}

}

@@ -143,16 +143,262 @@
 ssage;%0A%0A
+/**%0A * Message for a game entity to use a certain ability.%0A * %3Cp%3E%0A * Game entities (e.g., cards, players) may have one or more ability actions that they can perform.%0A * Certain abilities can have multiple targets, hence the use of an array. %0A */%0A
 public c
@@ -553,16 +553,50 @@
 argets;%0A
+%09%0A%09/** Constructor. (no params) */
 %0A%09public
@@ -657,213 +657,768 @@
 %7D%0A%0A%09
-public UseAbilityMessage(int gameId, int id, String action, int%5B%5D targets) %7B%0A%09%09super(%22use%22);%0A%09%09this.id = id;%0A%09%09this.action = action;%0A%09%09this.gameId = gameId;%0A%09%09this.targets = ArrayUtil.copyOf(targets);%0A%09%7D%0A%09
+/**%0A%09 * Constructor. (multiple targets)%0A%09 * %3Cp%3E%0A%09 * Used for multiple target actions.%0A%09 * %0A%09 * @param gameId  This current game%0A%09 * @param entity  This game entity performing an action%0A%09 * @param action  This action%0A%09 * @param targets  The set of multiple targets affected by this action%0A%09 */%0A%09public UseAbilityMessage(int gameId, int id, String action, int%5B%5D targets) %7B%0A%09%09super(%22use%22);%0A%09%09this.id = id;%0A%09%09this.action = action;%0A%09%09this.gameId = gameId;%0A%09%09this.targets = ArrayUtil.copyOf(targets);%0A%09%7D%0A%09/**%0A%09 * Constructor. %0A%09 * %3Cp%3E%0A%09 * Used for single target actions.%0A%09 * %0A%09 * @param gameId  This current game%0A%09 * @param entity  This game entity performing an action%0A%09 * @param action  This action%0A%09 * @param target  The single target affected by this action%0A%09 */
 %0A%09pu
@@ -1549,16 +1549,46 @@
  %7D);%0A%09%7D%0A
+%09%0A%09/** @return  This action */
 %0A%09public
@@ -1626,24 +1626,77 @@
 action;%0A%09%7D%0A%09
+/** @return  This game entity performing an action */
 %0A%09public int
@@ -1719,24 +1719,57 @@
 urn id;%0A%09%7D%0A%09
+/** @return  This current game */
 %0A%09public int
@@ -1804,16 +1804,51 @@
 Id;%0A%09%7D%0A%09
+/** @return  This set of targets */
 %0A%09public
@@ -1908,16 +1908,68 @@
 ts);%0A%09%7D%0A
+%09/** @return  This request as converted to String */
 %0A%09@Overr
@@ -2029,16 +2029,25 @@
 essage %5B
+%22%0A%09%09%09%09+ %22
 id=%22 + i
@@ -2048,16 +2048,21 @@
 =%22 + id 
+%0A%09%09%09%09
 + %22, act
@@ -2103,16 +2103,21 @@
  gameId 
+%0A%09%09%09%09
 + %22, tar
@@ -2150,16 +2150,20 @@
 argets) 
+%0A%09%09%09
 + %22%5D%22;%0A%09

Update UseAbilityMessage.java