Commit a1e0de30 authored by Toussaint Etienne's avatar Toussaint Etienne

TermTestUnitaire

parent 4a24d57a
......@@ -6,6 +6,7 @@ package core.abilities;
public enum AbilityKey {
NULL_ABILITY,
TEST_ATTACK_ABILITY,
TEST_ATTACK_ABILITY_FRIENDLY,
TEST_LP_FIREBOLT,
TEST_FIREBOLT,
MENTALI_ATTACK,
......
......@@ -40,6 +40,15 @@ public class AbilityRoster {
);
abilityFactory.registerAbilityGenerator(AbilityKey.TEST_ATTACK_ABILITY, abilityGenerator);
abilityGenerator =
() -> new Ability(
100,
AbilityIconKeys.SWORD_RED_1,
Action.ATTACK,
new ArrayList<>(Arrays.asList(new EffectDescriptor(EffectKey.TEST_ATTACK_FRIENDLY, new int[]{1})))
);
abilityFactory.registerAbilityGenerator(AbilityKey.TEST_ATTACK_ABILITY_FRIENDLY, abilityGenerator);
abilityGenerator =
......
......@@ -55,6 +55,28 @@ public class EffectBuilder implements Serializable{
};
}
/**
* Build a simple effect, that reduce the HP of the target Being (if not same faction) by max(0,howMany). Note that it cannot heal.
* @param howMany the number of HP that the target Being should lose.
* @return An instance of Effect doing what is described above.
*/
Effect reduceHP_friendly(int howMany) {
return new Effect() {
private static final long serialVersionUID = 1L;
@Override
public void effect(List<Integer> targetCharacterIDList, GameContent gameContent, int casterCharacterID) throws InterruptedException {
for (Integer targetID : targetCharacterIDList) {
try {
if(gameContent.getGameState().getCharacter(targetID).getFaction() != gameContent.getGameState().getCharacter(casterCharacterID).getFaction())
gameContent.getGameState().getCharacter(targetID).takeDamage(Math.max(howMany, 0));
} catch (EntityNotFoundExeption entityNotFoundExeption) {
}
}
}
};
}
/**
* Build an effect, which create a new entity, which move and inficlit dommage to every characters it cross.
* @param degat amount of dammage
......
......@@ -30,6 +30,15 @@ public final class EffectGeneratorRoster {
};
effectFactory.registerEffectGenerator(EffectKey.TEST_ATTACK_EFFECT, effectGenerator);
effectGenerator =
(casterCharacterID, parameters) -> {
int amountOfDamage = parameters.getNthParameter(0);
return eb.affectZone((character -> character.getHitbox()),
eb.filter( CommonCharacterIDListFilter.allExceptOne(casterCharacterID),
eb.reduceHP_friendly(amountOfDamage)));
};
effectFactory.registerEffectGenerator(EffectKey.TEST_ATTACK_FRIENDLY, effectGenerator);
effectGenerator =
......
......@@ -9,6 +9,7 @@ package core.abilities.effects;
*/
public enum EffectKey {
TEST_ATTACK_EFFECT(1),
TEST_ATTACK_FRIENDLY(1),
TEST_LP_FIREBOLT(2),
TEST_FIREBOLT(2),
TEST_SUICIDE(1),
......
package graphics.display_test;
/**
* Created by etouss on 06/01/2016.
*/
import artificial_intelligence.AIControler;
import artificial_intelligence.AIEntities.AgressiveEntity;
import artificial_intelligence.AIEntities.EnumBehaviourType;
import gameloop.DummyLocalGameLoop;
import gameloop.GameStarter;
import graphics.graphical_abstraction.GraphicsMasterAbstraction;
import graphics.ingame_input_listener.Input;
import graphics.termSkeleton.GraphicsMasterTerm;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Created by Etienne Toussaint on 06/01/16.
* This is the unit test class for the GamePanelTerm class.
*/
public class GamePanelTermTest {
@Test
public void test_move() {
GraphicsMasterTerm.build();
GraphicsMasterAbstraction gm = GraphicsMasterAbstraction.getInstance();
gm.launchGUI();
GameStarter.startGameSinglePlayer();
gm.changeGUIStateTo(GraphicsMasterAbstraction.GUIStates.GAME_PANEL);
int x = DummyLocalGameLoop.getInstance().getFollowedRelayer().getCharacter().getX();
int y = DummyLocalGameLoop.getInstance().getFollowedRelayer().getCharacter().getY();
gm.keyPressedHandler(Input.LEFT_ARROW);
gm.keyPressedHandler(Input.UP_ARROW);
/*Wait for the event to be process*/
try {
Thread.currentThread().sleep(100);
} catch (InterruptedException e) {
//e.printStackTrace();
}
assertEquals(x,DummyLocalGameLoop.getInstance().getFollowedRelayer().getCharacter().getX()+DummyLocalGameLoop.getInstance().getFollowedRelayer().getCharacter().getSpeed());
assertEquals(x,DummyLocalGameLoop.getInstance().getFollowedRelayer().getCharacter().getY()+DummyLocalGameLoop.getInstance().getFollowedRelayer().getCharacter().getSpeed());
}
}
package graphics.display_test;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
/**
* TestSuite for the terminal package.
* Will launch automatically all the JUnits tests.
*/
@RunWith(Suite.class)
@Suite.SuiteClasses({
GamePanelTermTest.class
})
public class TermTests {}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment