src/main/java/ru/alphatech/icfpc/cards/Copy.java
author akhmetovlz
Sun, 19 Jun 2011 19:13:42 +0400
changeset 101 4bb458c3548e
parent 74 b277f6c31f5f
child 102 cc814352ab43
permissions -rw-r--r--
(no commit message)
     1 package ru.alphatech.icfpc.cards;
     2 
     3 import ru.alphatech.icfpc.game.ICFPCException;
     4 import ru.alphatech.icfpc.game.IValue;
     5 import ru.alphatech.icfpc.game.Player;
     6 import ru.alphatech.icfpc.game.Value;
     7 
     8 public class Copy implements ICard
     9 {
    10 	@Override
    11 	public String getName() {
    12 		return "copy";
    13 	}
    14 	
    15 	@Override
    16 	public IValue returnValue(IValue iobj, Player proponent, Player opponent)
    17 	{
    18 		if (iobj instanceof Value)
    19 		{
    20 			int i = ((Value)iobj).getValue();
    21 
    22 			if (i >= 0 && i <= 255)
    23 			{
    24 				return opponent.getSlot(i).getValue();
    25 			}
    26 			else
    27 			{
    28 				throw new ICFPCException();
    29 			}
    30 		}
    31 		else
    32 		{
    33 			throw new ICFPCException();
    34 		}
    35 
    36 	}
    37 }