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
     1 package ru.alphatech.icfpc.game;
     2 
     3 import ru.alphatech.icfpc.cards.ICard;
     4 
     5 public class Batch {
     6 	
     7 	public enum OperationType {
     8 		CARD_TO_SLOT,
     9 		SLOT_TO_CARD
    10 	}
    11 	
    12 	OperationType operationType;
    13 	
    14 	public ICard card = null;
    15 	public Slot  slot = null;
    16 	
    17 	public Batch(OperationType type, ICard card, Slot slot){
    18 		if(type == null || card == null || slot == null)
    19 			throw new ICFPCException("Illegal constructor using!");
    20 		this.operationType = type;
    21 		this.card = card;
    22 		this.slot = slot;
    23 	}
    24 
    25 	@Override
    26 	public String toString() {
    27 		if(operationType == null || card == null || slot == null)
    28 			throw new ICFPCException();
    29 		StringBuilder ret = new StringBuilder();
    30 		switch(operationType){
    31 		case CARD_TO_SLOT:
    32 			ret.append("1\n");
    33 			ret.append(card.getName() + "\n");
    34 			ret.append(slot.getId() + "\n");
    35 			break;
    36 		case SLOT_TO_CARD:
    37 			ret.append("2\n");
    38 			ret.append(slot.getId() + "\n");
    39 			ret.append(card.getName() + "\n");
    40 			break;
    41 		}
    42 		return ret.toString();
    43 	}
    44 	
    45 }