src/main/java/ru/alphatech/icfpc/game/Player.java
author indvdum
Sun, 19 Jun 2011 19:44:06 +0400
changeset 106 643b85a8a16b
parent 99 60187fe9405d
child 110 d6c063577f0d
permissions -rw-r--r--
* analyzing
     1 package ru.alphatech.icfpc.game;
     2 
     3 import ru.alphatech.icfpc.cards.I;
     4 
     5 
     6 
     7 public class Player
     8 {
     9 	private Slot[] slots = new Slot[256];
    10 	private Player myOpponent = null;
    11 
    12 	public Player()
    13     {
    14 		for(int i = 0; i <= 255; i++)
    15 		{
    16 			slots[i] = new Slot(i);
    17 		}
    18     }
    19 	
    20 	public Player getMyOpponent() {
    21 		return myOpponent;
    22 	}
    23 	
    24 	public void setMyOpponent(Player myOpponent) {
    25 		this.myOpponent = myOpponent;
    26 	}
    27 	
    28 	public Slot getSlot(int i)
    29 	{
    30 		return slots[i];
    31 	}
    32 	
    33 	public PlayerStatistic getStatistic(){
    34 		throw new RuntimeException("Not impilemented yet.");
    35 	}
    36 	
    37 	public void applyBatch(Batch batch){
    38 		Run.setAutoMode(false);
    39 		Run.resetCallCount();
    40 		try{
    41 			switch(batch.operationType){
    42 			case CARD_TO_SLOT:
    43 				batch.card.returnValue(getSlot(batch.slot.getId()).getValue(), this, myOpponent);
    44 				break;
    45 			case SLOT_TO_CARD:
    46 				getSlot(batch.slot.getId()).getValue().returnValue(batch.card, this, myOpponent);
    47 				break;
    48 			}
    49 		} catch (ICFPCException exception){
    50 			getSlot(batch.slot.getId()).putValue(new I());
    51 		}
    52 		Run.setAutoMode(true);
    53 		Run.resetCallCount();
    54 		for(Slot slot: myOpponent.slots){
    55 			if(slot.isZombie()){
    56 				slot.getValue().returnValue(new I(), myOpponent, myOpponent.getMyOpponent());
    57 			}
    58 		}
    59 	}
    60 	
    61 }