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