turtle@12: package ru.alphatech.icfpc.game; 0-range@4: indvdum@99: import ru.alphatech.icfpc.cards.I; akhmetovlz@110: import ru.alphatech.icfpc.cards.ICard; akhmetovlz@110: import ru.alphatech.icfpc.cards.Zero; indvdum@99: akhmetovlz@17: 0-range@4: turtle@11: public class Player 0-range@4: { indvdum@122: private int playerNumber = -1; indvdum@122: turtle@28: private Slot[] slots = new Slot[256]; indvdum@99: private Player myOpponent = null; indvdum@99: turtle@28: public Player() turtle@28: { indvdum@106: for(int i = 0; i <= 255; i++) turtle@28: { indvdum@80: slots[i] = new Slot(i); turtle@28: } turtle@28: } turtle@28: indvdum@122: public int getPlayerNumber() { indvdum@122: return playerNumber; indvdum@122: } indvdum@122: indvdum@122: public void setPlayerNumber(int playerNumber) { indvdum@122: this.playerNumber = playerNumber; indvdum@122: } indvdum@122: indvdum@99: public Player getMyOpponent() { indvdum@99: return myOpponent; indvdum@99: } indvdum@99: indvdum@99: public void setMyOpponent(Player myOpponent) { indvdum@99: this.myOpponent = myOpponent; indvdum@99: } indvdum@99: turtle@11: public Slot getSlot(int i) turtle@11: { turtle@28: return slots[i]; turtle@11: } akhmetovlz@17: akhmetovlz@19: public PlayerStatistic getStatistic(){ indvdum@122: throw new RuntimeException("Not implemented yet."); akhmetovlz@19: } akhmetovlz@30: indvdum@90: public void applyBatch(Batch batch){ indvdum@106: Run.setAutoMode(false); indvdum@106: Run.resetCallCount(); indvdum@106: try{ indvdum@106: switch(batch.operationType){ indvdum@106: case CARD_TO_SLOT: akhmetovlz@110: IValue value = getSlot(batch.slot.getId()).getValue(); akhmetovlz@110: akhmetovlz@110: if(value instanceof Zero) akhmetovlz@110: { akhmetovlz@110: value = new Value(0); akhmetovlz@110: } akhmetovlz@110: akhmetovlz@110: if(batch.card instanceof Zero) akhmetovlz@110: { akhmetovlz@110: batch.card = (ICard) new Value(0); akhmetovlz@110: } akhmetovlz@110: turtle@127: getSlot(batch.slot.getId()).putValue(batch.card.returnValue(value, this, myOpponent)); indvdum@106: break; indvdum@106: case SLOT_TO_CARD: turtle@140: IValue valueC = batch.card; turtle@140: turtle@140: if(valueC instanceof Zero) turtle@140: { turtle@140: valueC = new Value(0); turtle@140: } turtle@140: turtle@140: getSlot(batch.slot.getId()).putValue(getSlot(batch.slot.getId()).getValue().returnValue(valueC, this, myOpponent)); indvdum@106: break; indvdum@106: } indvdum@106: } catch (ICFPCException exception){ indvdum@106: getSlot(batch.slot.getId()).putValue(new I()); indvdum@106: } indvdum@106: Run.setAutoMode(true); indvdum@106: Run.resetCallCount(); indvdum@106: for(Slot slot: myOpponent.slots){ indvdum@106: if(slot.isZombie()){ indvdum@106: slot.getValue().returnValue(new I(), myOpponent, myOpponent.getMyOpponent()); indvdum@106: } indvdum@99: } indvdum@90: } akhmetovlz@30: 0-range@4: }