src/main/java/ru/alphatech/icfpc/game/Batch.java
author indvdum
Sun, 19 Jun 2011 18:16:08 +0400
changeset 96 8c40512777a1
parent 80 fcdce54b2f25
permissions -rw-r--r--
+ parsing opponent batch
akhmetovlz@33
     1
package ru.alphatech.icfpc.game;
akhmetovlz@33
     2
akhmetovlz@33
     3
import ru.alphatech.icfpc.cards.ICard;
akhmetovlz@33
     4
akhmetovlz@33
     5
public class Batch {
akhmetovlz@33
     6
	
akhmetovlz@33
     7
	public enum OperationType {
akhmetovlz@33
     8
		CARD_TO_SLOT,
akhmetovlz@33
     9
		SLOT_TO_CARD
akhmetovlz@33
    10
	}
akhmetovlz@33
    11
	
akhmetovlz@33
    12
	OperationType operationType;
akhmetovlz@33
    13
	
akhmetovlz@33
    14
	public ICard card = null;
akhmetovlz@33
    15
	public Slot  slot = null;
akhmetovlz@33
    16
	
akhmetovlz@33
    17
	public Batch(OperationType type, ICard card, Slot slot){
indvdum@96
    18
		if(type == null || card == null || slot == null)
indvdum@96
    19
			throw new ICFPCException("Illegal constructor using!");
akhmetovlz@33
    20
		this.operationType = type;
akhmetovlz@33
    21
		this.card = card;
akhmetovlz@33
    22
		this.slot = slot;
akhmetovlz@33
    23
	}
indvdum@80
    24
indvdum@80
    25
	@Override
indvdum@80
    26
	public String toString() {
indvdum@80
    27
		if(operationType == null || card == null || slot == null)
indvdum@80
    28
			throw new ICFPCException();
indvdum@80
    29
		StringBuilder ret = new StringBuilder();
indvdum@80
    30
		switch(operationType){
indvdum@80
    31
		case CARD_TO_SLOT:
indvdum@80
    32
			ret.append("1\n");
indvdum@80
    33
			ret.append(card.getName() + "\n");
indvdum@80
    34
			ret.append(slot.getId() + "\n");
indvdum@80
    35
			break;
indvdum@80
    36
		case SLOT_TO_CARD:
indvdum@80
    37
			ret.append("2\n");
indvdum@80
    38
			ret.append(slot.getId() + "\n");
indvdum@80
    39
			ret.append(card.getName() + "\n");
indvdum@80
    40
			break;
indvdum@80
    41
		}
indvdum@80
    42
		return ret.toString();
indvdum@80
    43
	}
akhmetovlz@33
    44
	
akhmetovlz@33
    45
}