src/main/java/ru/alphatech/icfpc/cards/Dbl.java
author Azamat S. Kalimoulline <turtle@bazon.ru>
Sun, 19 Jun 2011 19:13:07 +0400
changeset 102 cc814352ab43
parent 74 b277f6c31f5f
permissions -rw-r--r--
Call Count.
     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 Dbl extends AbstractCard
     9 {
    10 	@Override
    11 	public String getName() {
    12 		return "dbl";
    13 	}
    14 	
    15 	@Override
    16 	public IValue returnValue(IValue nobj, Player proponent, Player opponent)
    17 	{
    18 		incAndTest();
    19 		
    20 		if(nobj instanceof Value)
    21 		{
    22 			int n = ((Value)nobj).getValue();
    23 			
    24 			if(n >= 32767)
    25 			{
    26 				return new Value(65535);
    27 			}
    28 			else
    29 			{
    30 				return new Value(n * 2);
    31 			}
    32 		}
    33 		else
    34 		{
    35 			throw new ICFPCException();
    36 		}
    37 	}
    38 }