Commit e2b7f323 authored by Theodore Lopez's avatar Theodore Lopez

add comments and suppress unnecessary code (trap)

parent 412bcdd3
# Fichier contenant l'ensemble des species du jeu.
# Nombre de species total
9
8
#Ronflex - Character
C
......@@ -223,34 +223,6 @@ TRIGGER_DEGAT
#abilityList
1
TEST_SUICIDE
#--------------------------------------------------------------------
#Trap - Entity
E
#name
Trap
#tilePropertyVector
2
SOLID
LIQUID
#collisionBox
R
15
15
#visilibity
R
200
200
#entityDisplayerType
DIAGLA
#triggers
1
#trigger function
DEFAULT_TRIGGER
#effect descriptor
1
TRAP_TRIGGER
#abilityList
0
#--------------------------------------------------
#FireboltLP- Entity
E
......
......@@ -259,16 +259,6 @@ public class EffectBuilder implements Serializable{
};
}
Effect trap_trigger() {
return new Effect() {
private static final long serialVersionUID = 1L;
@Override
public void effect(List<Integer> targetCharacterIDList, GameContent gameContent, int casterCharacterID){
throw new RuntimeException("Unreachable trap trigger");
}
};
}
/**
* A trigger increasing the amount of gold of the characters in the area. if it happens then send a destroy event
......@@ -298,7 +288,7 @@ public class EffectBuilder implements Serializable{
}
};
}
/** Methods to be applied on an Effect to transform it into another one **/
/**
......
......@@ -76,12 +76,6 @@ public final class EffectGeneratorRoster {
};
effectFactory.registerEffectGenerator(EffectKey.TEST_LP_FIREBOLT, effectGenerator);
effectGenerator =
(casterCharacterID, parameters) -> {
return eb.trap_trigger();
};
effectFactory.registerEffectGenerator(EffectKey.TRAP_TRIGGER, effectGenerator);
effectGenerator =
(casterCharacterID, parameters) -> {
return eb.affectZone((character -> character.getHitbox()),
......
......@@ -5,7 +5,7 @@ import java.io.IOException;
import core.zone.Zone;
/**
* This clss is used to construct being from a "skeleton".
* This clss is used to construct being from a "skeleton" found in the species.txt file.
* @author Guerquin Arnaud
*
*/
......@@ -58,6 +58,9 @@ public class BeingSpecies extends EntitySpecies{
SpeciesArray.lineError++;
}
/*
* Create a new Being using the parameters and the information stored in the species.
* */
@Override
public Being create(int posX, int posY, int id, int owner, String name) {
return new Being(name,this.name,posX, posY, id,owner, collisionBox, tpv, visibility, entityDisplayerType,triggers,
......
......@@ -2,11 +2,20 @@ package core.gamestate;
import java.io.BufferedReader;
import java.io.IOException;
/**
* This class is used to construct character from a "skeleton" found in the species.txt file.
* @author Guerquin Arnaud
*
*/
public class CharacterSpecies extends BeingSpecies{
final int baseAtk;
final int baseIntel;
/**
* Construct a characterSpecies using the data in the given BufferReader
* @param br the BufferReader where data is read
* @throws IOException if can't read from the BufferReader.
*/
CharacterSpecies(BufferedReader br) throws IOException {
super(br);
br.readLine();
......@@ -19,6 +28,9 @@ public class CharacterSpecies extends BeingSpecies{
SpeciesArray.lineError++;
}
/**
* Create a new character using the parameters and the information stored in the species.
*/
@Override
public Character create(int posX, int posY, int id, int owner, String name) {
......
......@@ -29,7 +29,7 @@ public class EntitySpecies{
/**
* Construct a new Entity species with the information in the file.
* Construct a new Entity species with the information in the species.txt file.
* @param br the file where data is read
* @throws IOException if the file can't be read
*/
......
......@@ -35,10 +35,14 @@ public class GameContent implements Serializable{
private Semaphore sem = new Semaphore(1);
public GameContent(Map map,int playersNumber) throws InterruptedException {
/*
* Generate a new gamecontent,
* creating the relayers associated to the entities already on the map
* adding player and IA at start position
*/
this.map=Objects.requireNonNull(map);
this.gameState=new GameState();
players=new ArrayList<>();
AIControler.killAll();
if(map.getEntities()!=null) {
for(Entity e:map.getEntities()){
gameState.addEntity(e);
......@@ -78,8 +82,6 @@ public class GameContent implements Serializable{
return gameState;
}
/** Setter section **/
public void setMap(Map map) {
this.map = Objects.requireNonNull(map);
}
......@@ -116,7 +118,11 @@ public class GameContent implements Serializable{
return players;
}
public void applyTrigger(NetworkConnection networkConnection) throws InterruptedException {
/*
* Check if the entity has been triggered
* */
public void checkTrigger(NetworkConnection networkConnection) throws InterruptedException {
sem.acquire();
for(Entity e:triggerEntities){
e.checkTrigger(this,networkConnection);
......@@ -124,6 +130,9 @@ public class GameContent implements Serializable{
sem.release();
}
/*
* add the entity to the triggerEntities that must be checked for collision with other entities at every frame
* */
public void addTriggerToCheck(Entity e) throws InterruptedException
{
sem.acquire();
......@@ -131,13 +140,16 @@ public class GameContent implements Serializable{
sem.release();
}
public void removeTriggerToCheck(Entity e) throws InterruptedException
{
sem.acquire();
triggerEntities.remove(e);
sem.release();
}
/*
* Check if a player is on the stairs,
* */
public boolean checkStairs(Map newMap,NetworkConnection networkConnection) throws InterruptedException {
for(Character player:players){
......@@ -149,6 +161,11 @@ public class GameContent implements Serializable{
}
return false;
}
/*
* Not working, create a new floor,
* the issue is that after the new floor is created, there is problem for telling it to the GamePanel
* */
public void recreate(Map map,boolean server) throws InterruptedException {
this.map=Objects.requireNonNull(map);
......
......@@ -117,6 +117,11 @@ public class ServerLoop extends Thread {
}
/*
* Execute all the Event of the queue that are associated with the current frame
* (Effectively, it executes all the Event of the queue)
* */
void executeFrame(GameContent gameContent) throws InterruptedException {
while (!(queue.isEmpty()) && queue.peek().getTime() == cframe) {
//System.out.println("Coucou, local execution");
......@@ -124,9 +129,10 @@ public class ServerLoop extends Thread {
Event toBeSentToClientsEvent = event.apply(gameContent);
networkConnection.sendEvent(toBeSentToClientsEvent);
}
gameContent.applyTrigger(networkConnection);
/*Once per frame, check the stairs and check the trigger*/
gameContent.checkTrigger(networkConnection);
if(gameContent.checkStairs(nextMap,networkConnection))
nextMap=MapGeneration.mapGeneration(MapSize.SMALL);
nextMap=MapGeneration.mapGeneration(MapSize.MEDIUM);
}
......
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