package space.animefu.starfallhaven;
import org.junit.Test;
import static org.junit.Assert.*;

public class GameWorldTest {
 @Test public void generationIsDeterministicAndHasThreeColonists(){
  GameWorld a=new GameWorld(84621),b=new GameWorld(84621); assertEquals(3,a.colonists.size());
  for(int x=0;x<GameWorld.WIDTH;x++)for(int y=0;y<GameWorld.HEIGHT;y++)assertEquals(a.tiles[x][y],b.tiles[x][y]);
 }
 @Test public void wallConsumesResources(){GameWorld w=new GameWorld(1);w.setTool(GameWorld.Tool.WALL);int wood=w.wood,stone=w.stone;w.command(19,13);assertTrue(w.walls[19][13]);assertEquals(wood-4,w.wood);assertEquals(stone-2,w.stone);}
 @Test public void nightSpawnsRaid(){GameWorld w=new GameWorld(2);w.timeOfDay=.679f;for(int i=0;i<20;i++)w.update(.1f);assertTrue(w.isNight());assertTrue(w.enemies.size()>=3);}
 @Test public void beaconDefenseCanWin(){GameWorld w=new GameWorld(3);w.wood=30;w.stone=20;w.crystal=12;w.setTool(GameWorld.Tool.BEACON);w.command(19,13);assertTrue(w.beaconCharge>0);for(int i=0;i<260;i++){w.enemies.clear();w.update(.1f);}assertEquals(GameWorld.Result.WON,w.result);}
 @Test public void starvationDamagesColonist(){GameWorld w=new GameWorld(4);GameWorld.Colonist c=w.colonists.get(0);w.food=0;c.hunger=0;c.energy=0;float hp=c.health;w.update(.1f);assertTrue(c.health<hp);}
}
