Commit 826cac06 authored by Myriam Begel's avatar Myriam Begel
parents 1844f5d6 0bfba283
# Fichier contenant l'ensemble des species du jeu.
# Nombre de species total
5
6
#Ronflex - Character
C
......@@ -26,7 +26,7 @@ RONFLEX
TEST_ATTACK_ABILITY
TEST_FIREBOLT
NULL_ABILITY
TEST_SUICIDE
TEST_LP_FIREBOLT
#hitbox
R
15
......@@ -75,7 +75,7 @@ CHATROSE
TEST_ATTACK_ABILITY
TEST_FIREBOLT
NULL_ABILITY
TEST_SUICIDE
TEST_LP_FIREBOLT
#hitbox
R
10
......@@ -213,24 +213,41 @@ R
#entityDisplayerType
DIAGLA
#triggers
0
1
USSELESS
DEFAULT_TRIGGER
USSELESS
1
TRIGGER_DEGAT
#abilityList
1
TEST_SUICIDE
#hitbox
#--------------------------------------------------------------------
#FireboltLP- Entity
E
#name
FireBoltLP
#tilePropertyVector
2
SOLID
LIQUID
#collisionBox
R
15
15
#damageTypeVector
#visilibity
R
200
200
#entityDisplayerType
DIAGLA
#triggers
1
FIRE
#baseHP
USSELESS
DEFAULT_TRIGGER
USSELESS
1
#baseDef
0
#baseMental
0
#baseAtk
0
#baseIntel
0
TRIGGER_DEGAT_LP
#abilityList
1
TEST_SUICIDE
......@@ -6,6 +6,7 @@ package core.abilities;
public enum AbilityKey {
NULL_ABILITY,
TEST_ATTACK_ABILITY,
TEST_LP_FIREBOLT,
TEST_FIREBOLT,
TEST_SUICIDE;
}
......@@ -48,13 +48,21 @@ public class AbilityRoster {
new ArrayList<>(Arrays.asList(new EffectDescriptor(EffectKey.TEST_FIREBOLT, new int[]{5,10})))
);
abilityFactory.registerAbilityGenerator(AbilityKey.TEST_FIREBOLT, abilityGenerator);
abilityGenerator =
() -> new Ability(
2000,
AbilityIconKeys.FIRE_BOLT_1,
Action.ATTACK,
new ArrayList<>(Arrays.asList(new EffectDescriptor(EffectKey.TEST_LP_FIREBOLT, new int[]{5,10})))
);
abilityFactory.registerAbilityGenerator(AbilityKey.TEST_LP_FIREBOLT, abilityGenerator);
abilityGenerator =
() -> new Ability(
2000,
AbilityIconKeys.SHIELD_1,
Action.ATTACK,
new ArrayList<>(Arrays.asList(new EffectDescriptor(EffectKey.TEST_SUICIDE, new int[]{5})))
new ArrayList<>(Arrays.asList(new EffectDescriptor(EffectKey.TEST_SUICIDE, new int[]{})))
);
abilityFactory.registerAbilityGenerator(AbilityKey.TEST_SUICIDE, abilityGenerator);
}
......
package core.abilities.effects;
import core.gamestate.*;
import java.io.Serializable;
import java.util.List;
import java.util.function.UnaryOperator;
import java.util.stream.Collectors;
......@@ -16,7 +19,13 @@ public class CommonCharacterIDListFilter {
* @param characterIDToIgnore
* @return A CharacterIDListFilter that only remove elements equal to characterIDToIgnore
*/
static UnaryOperator<List<Integer>> allExceptOne(int characterIDToIgnore) {
return charaIDList -> {charaIDList.removeIf(x->(x==characterIDToIgnore));return charaIDList;};
}
static UnaryOperator<List<Integer>> allExceptTwo(int characterIDToIgnore, int characterIDToIgnore2) {
return charaIDList -> {charaIDList.removeIf(x->(x==characterIDToIgnore ||x== characterIDToIgnore2 ));return charaIDList;};
}
}
package core.abilities.effects;
import core.event.AbilityEvent;
import core.event.Event;
import core.gamestate.*;
import core.gamestate.Character;
import core.relayer.Relayer;
......@@ -70,7 +71,9 @@ public class EffectBuilder implements Serializable{
Entity entity = SpeciesArray.create(charac.getX(), charac.getY(), 0, "FireBolt", "FireBolt");
entity.setOrientation(charac.getOrientation());
entity.setSpeed(speed);
entity.setOwned_character(casterCharacterID);
gameContent.getGameState().addEntity(entity);
gameContent.addTriggerToCheck(entity);
RelayerEntity relayer = new RelayerEntity(entity.getID(),entity,gameContent);
entity.setRelayer(relayer);
relayer.move(DummyLocalGameLoop.getInstance().getFollowedRelayer().getDirection());
......@@ -84,7 +87,39 @@ public class EffectBuilder implements Serializable{
};
}
Effect suicide(int howMany) {
Effect spawnLPFireBolt(int degat,int speed) {
return new Effect() {
private static final long serialVersionUID = 1L;
@Override
public void effect(List<Integer> targetCharacterIDList, GameContent gameContent, int casterCharacterID) {
Character charac = null;
try {
charac = gameContent.getGameState().getCharacter(casterCharacterID);
} catch (EntityNotFoundExeption entityNotFoundExeption) {
entityNotFoundExeption.printStackTrace();
return ;
}
Entity entity = SpeciesArray.create(charac.getX(), charac.getY(), 0, "FireBoltLP", "FireBoltLP");
entity.setOrientation(charac.getOrientation());
entity.setSpeed(speed);
entity.setOwned_character(casterCharacterID);
gameContent.getGameState().addEntity(entity);
gameContent.addTriggerToCheck(entity);
RelayerEntity relayer = new RelayerEntity(entity.getID(),entity,gameContent);
entity.setRelayer(relayer);
relayer.move(DummyLocalGameLoop.getInstance().getFollowedRelayer().getDirection());
relayer.start();
//Direction direction = gameContent.getGameState().getCharacter(casterCharacterID).getDirection();
//Entity n_entity = new Entity()
}
};
}
Effect trigger_degat() {
return new Effect() {
private static final long serialVersionUID = 1L;
......@@ -92,23 +127,57 @@ public class EffectBuilder implements Serializable{
public void effect(List<Integer> targetCharacterIDList, GameContent gameContent, int casterCharacterID) {
for (Integer targetID : targetCharacterIDList) {
try {
gameContent.getGameState().getCharacter(targetID).takeDamage(Math.max(howMany, 0));
if(gameContent.getGameState().getEntity(casterCharacterID).getOwned_character() != targetID) {
gameContent.getGameState().getCharacter(targetID).takeDamage(Math.max(1, 0));
//hit =true;
}
} catch (EntityNotFoundExeption entityNotFoundExeption) {
entityNotFoundExeption.printStackTrace();
continue;
}
}
}
};
}
Effect trigger_degat_lp() {
return new Effect() {
private static final long serialVersionUID = 1L;
@Override
public void effect(List<Integer> targetCharacterIDList, GameContent gameContent, int casterCharacterID) {
boolean hit = false;
for (Integer targetID : targetCharacterIDList) {
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();
}
}
if(hit){
Event event = new AbilityEvent(casterCharacterID, 0);
DummyLocalGameLoop.getInstance().getNetworkConnection().sendEvent(event);
}
}
};
}
Effect suicide(){
return new Effect(){
private static final long serialVersionUID = 1L;
public void effect(List<Integer> targetCharacterIDList, GameContent gameContent, int casterCharacterID) {
try {
if(gameContent.getGameState().getEntity(casterCharacterID).getRelayer() != null){
gameContent.getGameState().getEntity(casterCharacterID).getRelayer().kill();
}
gameContent.removeTriggerToCheck(gameContent.getGameState().getEntity(casterCharacterID));
gameContent.getGameState().removeEntity(gameContent.getGameState().getEntity(casterCharacterID));
} catch (EntityNotFoundExeption entityNotFoundExeption) {
entityNotFoundExeption.printStackTrace();
return;
}
//gameContent.getGameState().getCharacter(casterCharacterID).takeDamage(Math.max(gameContent.getGameState().getCharacter(casterCharacterID).getMaxHP(), 0));
}
}
};
}
......
......@@ -28,6 +28,14 @@ public final class EffectGeneratorRoster {
};
effectFactory.registerEffectGenerator(EffectKey.TEST_ATTACK_EFFECT, effectGenerator);
effectGenerator =
(casterCharacterID, parameters) -> {
return eb.suicide();
};
effectFactory.registerEffectGenerator(EffectKey.TEST_SUICIDE, effectGenerator);
effectGenerator =
(casterCharacterID, parameters) -> {
int amountOfDamage = parameters.getNthParameter(0);
......@@ -39,9 +47,37 @@ public final class EffectGeneratorRoster {
effectGenerator =
(casterCharacterID, parameters) -> {
int amountOfDamage = parameters.getNthParameter(0);
return eb.suicide(amountOfDamage);
int speed = parameters.getNthParameter(1);
return eb.spawnLPFireBolt(amountOfDamage, speed);
};
effectFactory.registerEffectGenerator(EffectKey.TEST_SUICIDE, effectGenerator);
effectFactory.registerEffectGenerator(EffectKey.TEST_LP_FIREBOLT, 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()));
};
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()));
};
effectFactory.registerEffectGenerator(EffectKey.TRIGGER_DEGAT_LP, effectGenerator);
}
}
......@@ -10,7 +10,10 @@ package core.abilities.effects;
public enum EffectKey {
TEST_ATTACK_EFFECT(1),
TEST_FIREBOLT(2),
TEST_SUICIDE(1);
TEST_LP_FIREBOLT(2),
TRIGGER_DEGAT(0),
TRIGGER_DEGAT_LP(0),
TEST_SUICIDE(0);
private EffectKey(int parameterNb) {
this.parameterNb = parameterNb;
......
......@@ -35,7 +35,7 @@ public class MoveEvent implements ClientEvent,ServerEvent {
target.setCenter(p);
target.addAction(Action.WALK);
}
else if(target.getSpeciesName().equals("FireBolt")){
else if(target.getSpeciesName().equals("FireBolt") || target.getSpeciesName().equals("FireBoltLP")){
Event event = new AbilityEvent(targetID, 0);
DummyLocalGameLoop.getInstance().getNetworkConnection().sendEvent(event);
}
......
......@@ -15,7 +15,7 @@ public class TriggerEvent implements ClientEvent {
*
*/
private static final long serialVersionUID = 1L;
private Trigger trigger;
transient private Trigger trigger;
private int casterID;
public TriggerEvent(Trigger trigger, int casterID) {
......
......@@ -70,7 +70,8 @@ public class Being extends Entity {
public Being(String name,String speciesName,int posX,int posY,int ID,int owner,Zone collisionBox,TilePropertyVector tpv,Zone visibility,EntityDisplayerType type,List<TriggerDescriptor> triggers,
int HP,int def,int mental,DamageTypeVector dtv,Zone hitbox,ArrayList<Ability> abilityList) {
super(name,speciesName,posX, posY, ID,owner, collisionBox, tpv, visibility, type,triggers,abilityList);
this.HP=this.maxHP=HP;
this.HP= HP;
this.maxHP=HP;
this.def=def;
this.mental=mental;
this.dtv=Objects.requireNonNull(dtv).clone();
......
......@@ -52,6 +52,8 @@ public class Entity implements Serializable{
private int speed=5;
private ActionVector actionVector=new ActionVector();
private ArrayList<Trigger> triggers=new ArrayList<>();
private int owned_character = -1;
//TODO Add a use for floors ?
//private int floor = 0;
......@@ -216,7 +218,7 @@ public class Entity implements Serializable{
* Returns the entity's Relayer's ID.
* @return the entity's Relayer's ID.
*/
int getOwner() {
public int getOwner() {
return owner;
}
......@@ -224,7 +226,7 @@ public class Entity implements Serializable{
* Changes the entity's Relayer's ID.
* @param owner the entity's new Relayer's ID.
*/
void setOwner(int owner){
public void setOwner(int owner){
this.owner=owner;
}
......@@ -370,6 +372,13 @@ public class Entity implements Serializable{
public void setRelayer(RelayerEntity relayer){
this.relayer = relayer;
}
public int getOwned_character() {
return owned_character;
}
public void setOwned_character(int owned_character) {
this.owned_character = owned_character;
}
}
\ No newline at end of file
......@@ -78,7 +78,7 @@ public class EntitySpecies{
switch (tile){
case WALL : return false;
case TORCH : return false;
case WATER : return name == "Ponyta";
case WATER : return name.equals("Ponyta");
default : return true;
}
}
......
package core.gamestate;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.function.Supplier;
......
......@@ -32,6 +32,7 @@ public class TileSpriteLinker
spriteMap.put(TileType.STAIRS , new GroundTileSprite(SpriteLoader.getSpriteFromPath("/assets/dungeon_set_1/stairs/stairs2.bmp").getSpriteImage()));
spriteMap.put(TileType.WATER , new GroundTileSprite(SpriteLoader.getSpriteFromPath("/assets/Lava.png").getSpriteImage()));
spriteMap.put(TileType.TORCH , new GroundTileSprite(SpriteLoader.getSpriteFromPath("/assets/Torch.png").getSpriteImage()));
spriteMap.put(TileType.CHEST , new GroundTileSprite(SpriteLoader.getSpriteFromPath("/assets/chest.png").getSpriteImage()));
}
public Displayable[][] getSpriteOfTile(TileType type, TileSprite.TileAbstractType[][] mask)
......
......@@ -55,6 +55,16 @@ public class FollowerBehaviour {
actions[n] = action;
}
public void SwitchInstructions(int i, int j) {
ArrayList<String> tar = targets.get(i);
String act = actions[i];
targets.set(i,targets.get(j));
actions[i]=actions[j];
targets.set(j,tar);
actions[j]=actions[i];
}
/** Output the list of Character satysfying all the properties in target
* @param A list of Character in which you want to keep only the one satisfying the propertie in target
* @param Target : a list of words, representing a target in an instruction in the IGP Panel
......
......@@ -6,6 +6,8 @@ import core.gamestate.Entity;
import core.gamestate.GameContent;
import core.relayer.Relayer;
import core.zone.Direction;
import core.gamestate.Character;
import java.util.*;
......@@ -19,5 +21,26 @@ public class IGPEntity extends AbstractEntity {
@Override
public void act() {
FollowerBehaviour fb = behold.GetFollowerBehaviour();
List <Character> chlist = gameState.getAllCharacters();
/* TODO : ne garder que les personnages visibles ? */
Character victim = fb.FindTarget(chlist);
String action = fb.getAction();
switch (action) {
case "attaquer":
System.out.println("Je vais attaquer !");
/* TODO : attaquer victim */
break;
case "proteger":
System.out.println("Je vais te protéger !");
/* TODO : proteger victim */
break;
case "soigner" :
System.out.println("Je vais te soigner !");
/*TODO : Soigner victim */
break;
default:
System.out.println("Je ne fais rien !");
}
}
}
......@@ -172,16 +172,21 @@ public class IGPpanel extends graphics.guiSkeleton.guiPanel.GUIPanel{
/**
* ActionListener to parse an instruction.
* Should be modified soon.
* Should be modified soon. Now change the color of the textfield in green if the
* instruction is correct, and in red otherwise.
* TODO We should find some more harmonious colors and add them to GUIColorAndFonts.
*/
private ActionListener parselistener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
Script parser = new Script(stringToStream(((JTextField)e.getSource()).getText()));
JTextField btf = (JTextField) e.getSource();
Script parser = new Script(stringToStream(btf.getText()));
if (parser.checkInput()) {
System.out.println("L'instruction est correcte");
// System.out.println("L'instruction est correcte");
btf.setBackground(Color.green);
} else {
System.out.println("Erreur dans l'instruction");
//System.out.println("Erreur dans l'instruction");
btf.setBackground(Color.red);
}
}
};
......
......@@ -14,6 +14,8 @@ public class Script implements ScriptConstants {
return true;
} catch(ParseException e) {
return false;
} catch(TokenMgrError e) {
return false;
}
}
......@@ -41,27 +43,34 @@ public class Script implements ScriptConstants {
t = jj_consume_token(CTR);
/* Traitements divers TODO */
ss += " tout " + t.image;
jj_consume_token(SPACE);
s = Option();
/* Traitements divers TODO. Pour l'instant, on construit
* une simple phrase. <EOF> sera à remplacer par le caractère
* de fin de chaîne (?) */
ss += " " + s;
label_1:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case SPACE:
break;
default:
jj_la1[0] = jj_gen;
break label_1;
}
jj_consume_token(SPACE);
t = jj_consume_token(LOGIC);
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case SPACE:
jj_consume_token(SPACE);
s = Option();
/* Traitements divers TODO. Pour l'instant, on construit
* une simple phrase. */
ss += " " + s;
label_1:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case SPACE:
;
break;
default:
jj_la1[0] = jj_gen;
break label_1;
}
jj_consume_token(SPACE);
t = jj_consume_token(LOGIC);
jj_consume_token(SPACE);
s = Option();
ss += " " + t.image.toLowerCase() + " (" + s;
count = count + 1;
}
break;
default:
jj_la1[1] = jj_gen;
;
}
jj_consume_token(0);
for (int i=0; i < count; i++) {
......@@ -80,28 +89,33 @@ public class Script implements ScriptConstants {
t = jj_consume_token(CLASS);
/* Traitements divers TODO */
s = "de la classe " + t.image;
return s;
{if (true) return s;}
break;
case NOMME:
jj_consume_token(NOMME);
jj_consume_token(SPACE);
t = jj_consume_token(NAME);
/* Traitements divers TODO */
s = "nomm\u00e9 " + t.image;
return s;
{if (true) return s;}
break;
case AVEC:
jj_consume_token(AVEC);
jj_consume_token(SPACE);
t = jj_consume_token(STAT);
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case STAT:
t = jj_consume_token(STAT);
/* Traitements divers TODO */
s = "avec la stat " + t.image;
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case SPACE:
jj_consume_token(SPACE);
break;
default:
jj_la1[1] = jj_gen;
}
t = jj_consume_token(CMP);
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case SPACE:
jj_consume_token(SPACE);
break;
default:
jj_la1[2] = jj_gen;
;
}
t = jj_consume_token(CMP);
/* Traitements divers TODO */
switch (t.image) {
case "=":
......@@ -116,19 +130,79 @@ public class Script implements ScriptConstants {
s += "\u2265";
break;
default:
throw new ParseException("Invalid comparator: " + t.image);
{if (true) throw new ParseException("Invalid comparator: " + t.image);}
}
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case SPACE:
jj_consume_token(SPACE);
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case SPACE:
jj_consume_token(SPACE);
break;
default: