Commit 907c834a authored by Toussaint Etienne's avatar Toussaint Etienne

Documentation_term_abs

parent 8c3451a5
......@@ -23,6 +23,13 @@ public class CommonCharacterIDListFilter {
static UnaryOperator<List<Integer>> allExceptOne(int characterIDToIgnore) {
return charaIDList -> {charaIDList.removeIf(x->(x==characterIDToIgnore));return charaIDList;};
}
/**
*
* @param characterIDToIgnore
* @param characterIDToIgnore2
* @returnA CharacterIDListFilter that both remove elements equal to characterIDToIgnore and characterIDToIgnore2
*/
static UnaryOperator<List<Integer>> allExceptTwo(int characterIDToIgnore, int characterIDToIgnore2) {
return charaIDList -> {charaIDList.removeIf(x->(x==characterIDToIgnore ||x== characterIDToIgnore2 ));return charaIDList;};
}
......
......@@ -49,14 +49,18 @@ public class EffectBuilder implements Serializable{
try {
gameContent.getGameState().getCharacter(targetID).takeDamage(Math.max(howMany, 0));
} catch (EntityNotFoundExeption entityNotFoundExeption) {
//entityNotFoundExeption.printStackTrace();
}
}
}
};
}
/**
* Build an effect, which create a new entity, which move and inficlit dommage to every characters it cross.
* @param degat amount of dammage
* @param speed speed the entity move.
* @return An instance of Effect doing what is described above.
*/
Effect spawnFireBolt(int degat,int speed) {
return new Effect() {
private static final long serialVersionUID = 1L;
......@@ -67,7 +71,6 @@ public class EffectBuilder implements Serializable{
try {
charac = gameContent.getGameState().getCharacter(casterCharacterID);
} catch (EntityNotFoundExeption entityNotFoundExeption) {
//entityNotFoundExeption.printStackTrace();
return ;
}
Entity entity = SpeciesArray.create(charac.getX(), charac.getY(), 0, "FireBolt", "FireBolt");
......@@ -85,15 +88,16 @@ public class EffectBuilder implements Serializable{
relayer.move(charac.getDirection());
}
relayer.start();
//Direction direction = gameContent.getGameState().getCharacter(casterCharacterID).getDirection();
//Entity n_entity = new Entity()
}
};
}
/**
* Build an effect, which create a new entity, which move and inficlit dommage to every characters it cross.
* @param degat amount of dammage
* @param speed speed the entity move.
* @return An instance of Effect doing what is described above.
*/
Effect spawnFrostBolt(int degat,int speed) {
return new Effect() {
private static final long serialVersionUID = 1L;
......@@ -104,7 +108,6 @@ public class EffectBuilder implements Serializable{
try {
charac = gameContent.getGameState().getCharacter(casterCharacterID);
} catch (EntityNotFoundExeption entityNotFoundExeption) {
//entityNotFoundExeption.printStackTrace();
return ;
}
Entity entity = SpeciesArray.create(charac.getX(), charac.getY(), 0, "FrostBolt", "FrostBolt");
......@@ -122,15 +125,16 @@ public class EffectBuilder implements Serializable{
relayer.move(charac.getDirection());
}
relayer.start();
//Direction direction = gameContent.getGameState().getCharacter(casterCharacterID).getDirection();
//Entity n_entity = new Entity()
}
};
}
/**
* Build an effect, which create a new entity, which move and inficlit dammage to the first character it meets.
* @param degat amount of dammage
* @param speed speed the entity move.
* @return An instance of Effect doing what is described above.
*/
Effect spawnLPFireBolt(int degat,int speed) {
return new Effect() {
private static final long serialVersionUID = 1L;
......@@ -141,7 +145,6 @@ public class EffectBuilder implements Serializable{
try {
charac = gameContent.getGameState().getCharacter(casterCharacterID);
} catch (EntityNotFoundExeption entityNotFoundExeption) {
//entityNotFoundExeption.printStackTrace();
return ;
}
Entity entity = SpeciesArray.create(charac.getX(), charac.getY(), 0, "FireBoltLP", "FireBoltLP");
......@@ -159,15 +162,14 @@ public class EffectBuilder implements Serializable{
relayer.move(charac.getDirection());
}
relayer.start();
//Direction direction = gameContent.getGameState().getCharacter(casterCharacterID).getDirection();
//Entity n_entity = new Entity()
}
};
}
/**
* A trigger inflicting damage to any character in the area.
* @return An instance of Effect doing what is described above.
*/
Effect trigger_degat() {
return new Effect() {
private static final long serialVersionUID = 1L;
......@@ -178,16 +180,18 @@ public class EffectBuilder implements Serializable{
try {
if(gameContent.getGameState().getEntity(casterCharacterID).getOwned_character() != targetID) {
gameContent.getGameState().getCharacter(targetID).takeDamage(Math.max(1, 0));
//hit =true;
}
} catch (EntityNotFoundExeption entityNotFoundExeption) {
//entityNotFoundExeption.printStackTrace();
}
}
}
};
}
/**
* A trigger inflicting damage to any character in the area. if it happens then send a destroy event to the entity responsable.
* @return An instance of Effect doing what is described above.
*/
Effect trigger_degat_lp() {
return new Effect() {
private static final long serialVersionUID = 1L;
......@@ -202,7 +206,6 @@ public class EffectBuilder implements Serializable{
hit =true;
}
} catch (EntityNotFoundExeption entityNotFoundExeption) {
//entityNotFoundExeption.printStackTrace();
}
}
if(hit){
......@@ -213,6 +216,10 @@ public class EffectBuilder implements Serializable{
};
}
/**
* An effect killing the entity properly.
* @return An instance of Effect doing what is described above.
*/
Effect suicide(){
return new Effect(){
private static final long serialVersionUID = 1L;
......@@ -224,7 +231,6 @@ public class EffectBuilder implements Serializable{
gameContent.removeTriggerToCheck(gameContent.getGameState().getEntity(casterCharacterID));
gameContent.getGameState().removeEntity(gameContent.getGameState().getEntity(casterCharacterID));
} catch (EntityNotFoundExeption entityNotFoundExeption) {
//entityNotFoundExeption.printStackTrace();
}
}
......
......@@ -43,10 +43,6 @@ public final class EffectGeneratorRoster {
effectFactory.registerEffectGenerator(EffectKey.MENTALI_ATTACK_DAMAGE, effectGenerator);
effectGenerator =
(casterCharacterID, parameters) -> {
return eb.suicide();
......@@ -79,12 +75,6 @@ public final class EffectGeneratorRoster {
effectGenerator =
(casterCharacterID, parameters) -> {
//int amountOfDamage = parameters.getNthParameter(0);
/*Effect[] arr = {eb.affectZone((character -> character.getHitbox()),
eb.filter( CommonCharacterIDListFilter.allExceptOne(casterCharacterID),
eb.reduceHP(5)))
,eb.suicide()};*/
//return eb.sequence(arr);
return eb.affectZone((character -> character.getHitbox()),
eb.filter( CommonCharacterIDListFilter.allExceptOne(casterCharacterID),
eb.trigger_degat()));
......@@ -92,12 +82,6 @@ public final class EffectGeneratorRoster {
effectFactory.registerEffectGenerator(EffectKey.TRIGGER_DEGAT, effectGenerator);
effectGenerator =
(casterCharacterID, parameters) -> {
//int amountOfDamage = parameters.getNthParameter(0);
/*Effect[] arr = {eb.affectZone((character -> character.getHitbox()),
eb.filter( CommonCharacterIDListFilter.allExceptOne(casterCharacterID),
eb.reduceHP(5)))
,eb.suicide()};*/
//return eb.sequence(arr);
return eb.affectZone((character -> character.getHitbox()),
eb.filter( CommonCharacterIDListFilter.allExceptOne(casterCharacterID),
eb.trigger_degat_lp()));
......
......@@ -56,7 +56,6 @@ public class AbilityEvent implements ClientEvent,ServerEvent {
}
return true;
} catch (EntityNotFoundExeption entityNotFoundExeption) {
//entityNotFoundExeption.printStackTrace();
return false;
}
}
......
......@@ -41,7 +41,6 @@ public class MoveEvent implements ClientEvent,ServerEvent {
}
return true;
} catch (EntityNotFoundExeption entityNotFoundExeption) {
//entityNotFoundExeption.printStackTrace();
return true;
}
}
......
......@@ -88,11 +88,11 @@ public class Entity implements Serializable{
private ArrayList<Trigger> triggers=new ArrayList<>();
//TODO the one who added all of this, document it.
/**
* ????
* The id of the possible entity's owner (character)
*/
private int owned_character = -1;
/**
* ????
* A possible pointer to the relayer of this entity.
*/
transient private RelayerEntity relayer;
......@@ -470,19 +470,34 @@ public class Entity implements Serializable{
return abilityList;
}
//TODO the one who added this, document it.
/**
* Getters
* @return
*/
public RelayerEntity getRelayer(){
return relayer;
}
/**
* Setters
* @param relayer
*/
public void setRelayer(RelayerEntity relayer){
this.relayer = relayer;
}
/**
* Getters
* @return
*/
public int getOwned_character() {
return owned_character;
}
/**
* Setters
* @param owned_character
*/
public void setOwned_character(int owned_character) {
this.owned_character = owned_character;
}
......
package core.gamestate;
/**
* This class represents the exception being sent whenever we try to get an entity throw gamestate which is not in:
* -Entity might be dead now
* -You are looking in a too specific subset, (ie : character).
* Created by etouss on 04/01/2016.
*/
public class EntityNotFoundExeption extends Exception {
......
......@@ -12,21 +12,19 @@ import gameloop.ServerLoop;
import java.util.Objects;
/**
* A simplier version of the powerfull Relayer made in order to match the entity instead of character
* -It allow entity to move, smoothly at each refresh og the gamestate.
*/
public class RelayerEntity extends Thread{
private final int ID;
private Entity character;
private GameContent gameContent;
private int characterClass = 0;
private boolean end=false;
private Direction direction=Direction.NONE;
private boolean hasTriedToCastAbility = false;
private int currentAbility=0;
//private AbilityEvent event;
public RelayerEntity(int ID, Entity entity, GameContent gameContent){
//this.event = ability;
this.ID=ID;
this.character=Objects.requireNonNull(entity);
this.gameContent = gameContent;
......@@ -80,7 +78,6 @@ public class RelayerEntity extends Thread{
}
public void kill() {
//DummyLocalGameLoop.getInstance().getNetworkConnection().sendEvent(event);
end=true;
}
}
......@@ -2,6 +2,7 @@ package graphics.graphical_utility;
/**
* Created by etouss on 20/12/2015.
* A tricky class to be able to implements easily trigger effect on menu element in the terminal_interface.
*/
public interface Voidy {
public void apply();
......
......@@ -15,31 +15,11 @@ public class TermFrame implements FrameAbstraction {
private ArrayList<PanelTerminal> panels = new ArrayList<>();
public TermFrame() {
setInFullScreen();
// setResizable(false);
//setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//RepaintTimer.getInstance().setMainFrameToRepaint(this);
}
/**
* Set this Frame into fullscreen
*/
public void setInFullScreen() {
/*Get maximum terminal size ?? */
// Getting the size of the user's computer screen and setting winWidth and winHeight accordingly
//GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
//Rectangle fullScreenDimension = ge.getMaximumWindowBounds();
//setSize((int)fullScreenDimension.getWidth(), (int)fullScreenDimension.getHeight());
}
@Override
public void init(FrameKeyListenerAbstraction keyListenerAbstraction) {
//this.setFocusable(true); //For the keyListener to work
//this.addKeyListener((KeyListener)keyListenerAbstraction);
//this.revalidate();
//this.setVisible(true);
}
@Override
......@@ -50,8 +30,6 @@ public class TermFrame implements FrameAbstraction {
@Override
public void add(PanelAbstraction panel){
panels.add((PanelTerminal)panel);
//super.add((JPanel) panel);
//this.revalidate();
this.repaint();
}
......
......@@ -146,8 +146,6 @@ public class GamePanelTerminal extends PanelTerminal implements GamePanelAbstrac
}
/*To display*/
//System.out.println("X: "+(processedEntity.getX() - x_core_min_to_display) / ratio_screen_core+"\n");
//System.out.println("Y: "+(processedEntity.getY()-y_core_min_to_display)/ratio_screen_core+"\n");
myPanel[(processedEntity.getX() - x_core_min_to_display) / ratio_screen_core].setCharAt((processedEntity.getY() - y_core_min_to_display) / ratio_screen_core, processedEntity.getEntityDisplayer().getTermSprite());
if(processedEntity instanceof Being) {
entityListSorted.add((Being)processedEntity);
......
......@@ -38,9 +38,6 @@ public abstract class PanelTerminal implements PanelAbstraction{
myPanel[i] = new StringBuilder(s);
}
//The following 2 lines are commented because KeyListener does not seem to work in a JPanel
//associatedKeyHandler = new KeyListenerForGUIPanel(this);
//setFocusable(true);
}
@Override
......@@ -52,34 +49,4 @@ public abstract class PanelTerminal implements PanelAbstraction{
}
}
/**
* This method is called by the gui before displaying the panel
*/
//abstract void initialise();
/**
* This method is called by the gui after this panel is no more displayed
*/
//abstract void finalise();
/**
* Define here what should happen if a key is pressed while this panel has the focus
* @param e
*/
//abstract void keyPressedHandler(KeyEvent e);
//Example of a body one could give to the keyPressedHandler method when implementing a guiPanel
//if(e.getKeyCode() == 27) { // 27 -> Escape
// System.out.println("Escape has been pressed");
//}
/**
* Define here what should happen if a key is released while this panel has the focus
* @param e
*/
//abstract void keyReleasedHandler(KeyEvent e);
/**
* Define here what should happen if a key is typed while this panel has the focus
* @param e
*/
//abstract void keyTypedHandler(KeyEvent e);
}
\ 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