1.1 --- a/src/main/java/ru/alphatech/icfpc/cards/Succ.java Sun Jun 19 12:15:24 2011 +0400
1.2 +++ b/src/main/java/ru/alphatech/icfpc/cards/Succ.java Sun Jun 19 12:53:34 2011 +0400
1.3 @@ -1,5 +1,6 @@
1.4 package ru.alphatech.icfpc.cards;
1.5
1.6 +import ru.alphatech.icfpc.game.ICFPCException;
1.7 import ru.alphatech.icfpc.game.IValue;
1.8 import ru.alphatech.icfpc.game.Player;
1.9 import ru.alphatech.icfpc.game.Value;
1.10 @@ -17,7 +18,9 @@
1.11 }
1.12 return new Value(((Value)value).getValue() + 1);
1.13 }
1.14 -
1.15 - return new Value(-100);
1.16 + else
1.17 + {
1.18 + throw new ICFPCException();
1.19 + }
1.20 }
1.21 }
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/src/main/java/ru/alphatech/icfpc/game/ICFPCException.java Sun Jun 19 12:53:34 2011 +0400
2.3 @@ -0,0 +1,7 @@
2.4 +package ru.alphatech.icfpc.game;
2.5 +
2.6 +@SuppressWarnings("serial")
2.7 +public class ICFPCException extends RuntimeException
2.8 +{
2.9 +
2.10 +}
3.1 --- a/src/main/java/ru/alphatech/icfpc/game/Player.java Sun Jun 19 12:15:24 2011 +0400
3.2 +++ b/src/main/java/ru/alphatech/icfpc/game/Player.java Sun Jun 19 12:53:34 2011 +0400
3.3 @@ -1,7 +1,5 @@
3.4 package ru.alphatech.icfpc.game;
3.5
3.6 -import ru.alphatech.icfpc.cards.I;
3.7 -
3.8 import ru.alphatech.icfpc.cards.ICard;
3.9
3.10
3.11 @@ -14,8 +12,7 @@
3.12 {
3.13 for(int i = 0; i < 255; i++)
3.14 {
3.15 - slots[i].setVitality(10000);
3.16 - slots[i].putValue(new I());
3.17 + slots[i] = new Slot();
3.18 }
3.19 registers[0] = 0;
3.20 registers[1] = 1;
4.1 --- a/src/main/java/ru/alphatech/icfpc/game/Slot.java Sun Jun 19 12:15:24 2011 +0400
4.2 +++ b/src/main/java/ru/alphatech/icfpc/game/Slot.java Sun Jun 19 12:53:34 2011 +0400
4.3 @@ -1,12 +1,14 @@
4.4 package ru.alphatech.icfpc.game;
4.5
4.6 +import ru.alphatech.icfpc.cards.I;
4.7 +
4.8
4.9 public class Slot
4.10 {
4.11 private int _vitality = 10000;
4.12
4.13 - private IValue _value = null;
4.14 -
4.15 + private IValue _value = new I();
4.16 +
4.17 public void setVitality(int vitality)
4.18 {
4.19 _vitality = vitality;
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
5.2 +++ b/src/test/java/ru/alphatech/icfpc/cards/tests/TestI.java Sun Jun 19 12:53:34 2011 +0400
5.3 @@ -0,0 +1,21 @@
5.4 +package ru.alphatech.icfpc.cards.tests;
5.5 +
5.6 +import org.junit.Test;
5.7 +
5.8 +import ru.alphatech.icfpc.cards.I;
5.9 +import ru.alphatech.icfpc.game.IValue;
5.10 +import ru.alphatech.icfpc.game.Player;
5.11 +import ru.alphatech.icfpc.game.Value;
5.12 +import junit.framework.Assert;
5.13 +
5.14 +public class TestI extends Assert
5.15 +{
5.16 + @Test
5.17 + public void testValue()
5.18 + {
5.19 + Player opponent = new Player();
5.20 + Player proponent = new Player();
5.21 + IValue x = new Value(10);
5.22 + assertEquals(x, new I().returnValue(x, proponent, opponent));
5.23 + }
5.24 +}
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
6.2 +++ b/src/test/java/ru/alphatech/icfpc/cards/tests/TestSucc.java Sun Jun 19 12:53:34 2011 +0400
6.3 @@ -0,0 +1,36 @@
6.4 +package ru.alphatech.icfpc.cards.tests;
6.5 +
6.6 +import junit.framework.TestCase;
6.7 +
6.8 +import org.junit.Test;
6.9 +
6.10 +import ru.alphatech.icfpc.cards.I;
6.11 +import ru.alphatech.icfpc.cards.Succ;
6.12 +import ru.alphatech.icfpc.game.ICFPCException;
6.13 +import ru.alphatech.icfpc.game.IValue;
6.14 +import ru.alphatech.icfpc.game.Player;
6.15 +import ru.alphatech.icfpc.game.Value;
6.16 +
6.17 +public class TestSucc extends TestCase
6.18 +{
6.19 + @Test
6.20 + public void testValue()
6.21 + {
6.22 + Player opponent = new Player();
6.23 + Player proponent = new Player();
6.24 + IValue x = new Value(10);
6.25 + IValue i = new I();
6.26 + assertEquals(65535, ((Value)new Succ().returnValue(new Value(65535), proponent, opponent)).getValue());
6.27 + assertEquals(65535, ((Value)new Succ().returnValue(new Value(65536), proponent, opponent)).getValue());
6.28 + assertEquals(11, ((Value)new Succ().returnValue(new Value(10), proponent, opponent)).getValue());
6.29 + try
6.30 + {
6.31 + new Succ().returnValue(i, proponent, opponent);
6.32 + assertFalse(true);
6.33 + }
6.34 + catch (ICFPCException e)
6.35 + {
6.36 + assertTrue(true);
6.37 + }
6.38 + }
6.39 +}
7.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
7.2 +++ b/src/test/java/ru/alphatech/icfpc/cards/tests/TestZero.java Sun Jun 19 12:53:34 2011 +0400
7.3 @@ -0,0 +1,22 @@
7.4 +package ru.alphatech.icfpc.cards.tests;
7.5 +
7.6 +import org.junit.Test;
7.7 +
7.8 +import ru.alphatech.icfpc.cards.Zero;
7.9 +import ru.alphatech.icfpc.game.IValue;
7.10 +import ru.alphatech.icfpc.game.Player;
7.11 +import ru.alphatech.icfpc.game.Value;
7.12 +
7.13 +import junit.framework.Assert;
7.14 +
7.15 +public class TestZero extends Assert
7.16 +{
7.17 + @Test
7.18 + public void testValue()
7.19 + {
7.20 + Player opponent = new Player();
7.21 + Player proponent = new Player();
7.22 + IValue zero = new Zero().returnValue(null, proponent, opponent);
7.23 + assertEquals(((Value)zero).getValue(), 0);
7.24 + }
7.25 +}