Commit 144e4dfa authored by hilaire1's avatar hilaire1
Browse files

Merge branch 'master' of gitlab.crans.org:genie_logiciel_2015/the_dungeon_project

parents 08824359 9f359aaa
......@@ -17,6 +17,12 @@ build
org.scala-ide.sdt.core/META-INF/MANIFEST.MF
org.scala-ide.sdt.update-site/site.xml
# Fichiers générés par JavaCC
src/ingame_programming/ParseException.java
src/ingame_programming/Token*
src/ingame_programming/Script*.java
src/ingame_programming/SimpleCharStream.java
### Intellij ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio
......
Ce dossier contient les scripts pour une intégration continue à la main.
=== INSTALLATION ===
* mettre en place un cron qui pull le projet à interval régulier.
* mettre en place le serveur http a contacter (server.py)
* Copier post-merge dans .git/hooks.
* Modifier mailci.py pour utiliser un serveur smpt correct.
......@@ -7,6 +7,8 @@ PACKAGEDIRS = ${shell find . -iname '*.java' | sed 's/\.\/\|[^/]*.java//g' | sor
#TESTCLASS = ${shell find . -name *Test.java | sed 's/.\/src\/\|.java//g' | sed 's/\//./g'}
PARSER = ${shell find . -name *.jj | sed "s/\.\///"}
# Java compiler
JAVAC = javac
JVM = 1.8
......@@ -47,9 +49,9 @@ IMAGEFILES = $(wildcard $(SRC)$(IMG)*.png $(SRC)$(IMG)*.gif $(SRC)$(IMG)*.txt)
# The first target is the one that is executed when you invoke
# "make".
.PHONY: all clean cleandoc hack
.PHONY: all clean cleandoc hack genpars
all : hack $(addprefix $(BIN), $(CLASS_FILES))
all : hack genpars $(addprefix $(BIN), $(CLASS_FILES))
@cp -r $(addprefix $(SRC)$(IMG), $(IMAGEDIRS)) $(IMAGEFILES) $(BIN)$(IMG)
@cp -r $(LIB) $(BIN)
......@@ -66,6 +68,10 @@ hack :
buildplay: all
cd bin/; java -cp $(LIB)*:. graphics.guiSkeleton.Igniter_Main
# Generate parser
genpars: $(PARSER)
@cd `dirname $<` ;find . -name *.jj | while read i; do java -cp lib/javacc-6.1.2.jar javacc $$i; done
clean :
rm -rf $(BIN)
......
#/bin/sh
git config --bool hooks.allownonascii "false"
exit 0
......@@ -43,6 +43,10 @@ public class AIControler {
break;
case Follower:
ai = new IGPEntity(gameContent,dmr);
break;
case Straight:
ai = new StraightEntity(gameContent,dmr);
break;
default:
LOGGER.severe("Trying to instanciate unrecognized type of AI.");
break;
......
......@@ -76,7 +76,7 @@ public abstract class AbstractEntity extends Thread {
*/
public int Choose_victim(){
float dmin =0 ;
float dmax = 10000000;
float dmax = 100000;
int victim = -1;
List<Entity> entityList=gameState.getAllEntities();
for (int i=0;i<entityList.size();i++) {
......@@ -106,8 +106,8 @@ public abstract class AbstractEntity extends Thread {
*/
public void move_to_entity(Entity victim) {
// X is UP-DOWN
int px = this.relayer.getCharacter().getX();
int py = this.relayer.getCharacter().getY();
int px = this.relayer.getCharacter().getX();
int py = this.relayer.getCharacter().getY();
int Delta_x = this.relayer.getCharacter().getX()-victim.getX();
// Y is LEFT-RIGHT
int Delta_y = this.relayer.getCharacter().getY()-victim.getY();
......@@ -118,11 +118,11 @@ public abstract class AbstractEntity extends Thread {
double r = random() % 2;
if(r==0){
this.relayer.move(Direction.LEFT);
System.out.print("pas mal");
System.out.println("pas mal");
}
else{
this.relayer.move(Direction.RIGHT);
System.out.print("pas mal");
System.out.println("pas mal");
}
}
}
......@@ -132,11 +132,11 @@ public abstract class AbstractEntity extends Thread {
double r = random() % 2;
if(r==0){
this.relayer.move(Direction.LEFT);
System.out.print("pas mal");
System.out.println("pas mal");
}
else{
this.relayer.move(Direction.RIGHT);
System.out.print("pas mal");
System.out.println("pas mal");
}
}
}
......@@ -196,6 +196,23 @@ public abstract class AbstractEntity extends Thread {
}
public void random_move(){
double r = random();
if(r<0.25){
this.relayer.move(Direction.RIGHT);
}
else {
if (r < 0.5) {
this.relayer.move(Direction.UP);
} else {
if (r < 0.75) {
this.relayer.move(Direction.DOWN);
} else {
this.relayer.move(Direction.LEFT);
}
}
}
}
/**
* This is the function sequentially called by run.
* The behaviour of the AI is implemented here.
......
......@@ -5,10 +5,13 @@ import core.gamestate.Entity;
import core.gamestate.GameContent;
import core.relayer.Relayer;
import core.zone.Direction;
import core.zone.ZoneUnion;
import logging.Logging;
import java.util.List;
import static java.lang.Math.random;
/**
* Created by Yann RAMUSAT on 30/12/15.
*/
......@@ -33,12 +36,12 @@ public class BasicEntity extends AbstractEntity {
public void act() {
// basic targeting and pathfinding
int victim_i = this.Choose_victim();
/*if (victim_i!=-1) {
this.move_to_victim(gameState.getAllEntities().get(this.Choose_victim()));
}*/
// A*
// A*
List<Entity> entityList=gameState.getAllEntities();
int dX = entityList.get(this.Choose_victim()).getX();
int dY = entityList.get(this.Choose_victim()).getY();
......@@ -46,8 +49,12 @@ public class BasicEntity extends AbstractEntity {
int sY = relayer.getCharacter().getY();
Direction dir = AI.alpha_star(map,sX, sY, dX, dY,map.getWidth(),map.getHeight());
//Logging.getInstance().getLogger().info(dir.toString());
this.relayer.move(dir);
if (relayer.getCharacter().getCollisionBox().intersect(entityList.get(victim_i).getCollisionBox())) {
this.relayer.move(Direction.NONE);
}
else {
this.relayer.move(dir);
}
// attack
this.relayer.tryToCastAbility(0);
}
......
......@@ -7,5 +7,6 @@ public enum EnumBehaviourType {
Agressive,
Basic,
Defender,
Follower;
Follower,
Straight;
}
package artificial_intelligence.AIEntities;
import artificial_intelligence.AlphaStar.AI;
import core.gamestate.Entity;
import core.gamestate.GameContent;
import core.relayer.Relayer;
import core.zone.Direction;
import logging.Logging;
import java.util.List;
import static java.lang.Math.random;
/**
* Created by Yann RAMUSAT on 30/12/15.
*/
public class StraightEntity extends AbstractEntity {
/**
* Instanciate a basic AI given as context a GameContent and a Relayer to contact.
*
* This use the classes used by the network.
*
* @param gameContent the actual content of the game. Map + Entities.
* @param relayer the relayer to contact.
*/
public StraightEntity(GameContent gameContent, Relayer relayer) {
super(gameContent, relayer);
}
/**
* This is the function sequentially called by run.
* The behaviour of the basic AI is implemented here.
*/
@Override
public void act() {
// basic targeting and pathfinding
int victim_i = this.Choose_victim();
if (victim_i!=-1) {
double r = random();
if(r<0.9){
//this.move_to_victim(gameState.getAllEntities().get(this.Choose_victim()));
if (relayer.getCharacter().getCollisionBox().intersect(gameState.getAllEntities().get(this.Choose_victim()).getCollisionBox())) {
this.relayer.move(Direction.NONE);
}
else {
this.move_to_victim(gameState.getAllEntities().get(this.Choose_victim()));
}
}
else{
this.random_move();
}
}
else{
Direction d = this.relayer.getCharacter().getDirection();
double r = random();
if(r<0.8){
for(int i=0; i<1;i++) {
this.relayer.move(d);
}
}
else{this.random_move();}
}
// attack
this.relayer.tryToCastAbility(0);
}
}
src/assets/diagla.png

3.26 KB | W: | H:

src/assets/diagla.png

3.88 KB | W: | H:

src/assets/diagla.png
src/assets/diagla.png
src/assets/diagla.png
src/assets/diagla.png
  • 2-up
  • Swipe
  • Onion skin
src/assets/firebolt.png

2.65 KB | W: | H:

src/assets/firebolt.png

2.65 KB | W: | H:

src/assets/firebolt.png
src/assets/firebolt.png
src/assets/firebolt.png
src/assets/firebolt.png
  • 2-up
  • Swipe
  • Onion skin
number of patterns : 4
number of monsters : 3
Ronflex
Ponyta
Diagla
id : 1
nom : fullMonster1
1
0
0
id : 2
nom : fullMonster2
0
1
0
id : 3
nom : fullMonster3
0
0
1
id : 4
nom : equilibria
1
1
1
\ No newline at end of file
......@@ -90,7 +90,7 @@ WATER
LIGHT
DARK
#baseHP
10
200
#baseDef
1
#baseMental
......
......@@ -33,10 +33,10 @@ public class AbilityRoster {
abilityGenerator =
() -> new Ability(
1200,
100,
AbilityIconKeys.SWORD_RED_1,
Action.ATTACK,
new ArrayList<>(Arrays.asList(new EffectDescriptor(EffectKey.TEST_ATTACK_EFFECT, new int[]{2})))
new ArrayList<>(Arrays.asList(new EffectDescriptor(EffectKey.TEST_ATTACK_EFFECT, new int[]{1})))
);
abilityFactory.registerAbilityGenerator(AbilityKey.TEST_ATTACK_ABILITY, abilityGenerator);
......
......@@ -23,6 +23,7 @@ public abstract class Effect implements Serializable{
* @param targetCharacterIDList a List of the IDs of the Characters to apply this effect on
* @param gameContent the gameContent in which the target characters lives
* @param casterCharacterID the ID of the Character that casted the Ability containing this Effect
* @throws InterruptedException
*/
abstract public void effect(List<Integer> targetCharacterIDList, GameContent gameContent, int casterCharacterID);
abstract public void effect(List<Integer> targetCharacterIDList, GameContent gameContent, int casterCharacterID) throws InterruptedException;
}
......@@ -44,7 +44,7 @@ public class EffectBuilder implements Serializable{
private static final long serialVersionUID = 1L;
@Override
public void effect(List<Integer> targetCharacterIDList, GameContent gameContent, int casterCharacterID) {
public void effect(List<Integer> targetCharacterIDList, GameContent gameContent, int casterCharacterID) throws InterruptedException {
for (Integer targetID : targetCharacterIDList) {
try {
gameContent.getGameState().getCharacter(targetID).takeDamage(Math.max(howMany, 0));
......@@ -62,7 +62,7 @@ public class EffectBuilder implements Serializable{
private static final long serialVersionUID = 1L;
@Override
public void effect(List<Integer> targetCharacterIDList, GameContent gameContent, int casterCharacterID) {
public void effect(List<Integer> targetCharacterIDList, GameContent gameContent, int casterCharacterID) throws InterruptedException {
Character charac = null;
try {
charac = gameContent.getGameState().getCharacter(casterCharacterID);
......@@ -99,7 +99,7 @@ public class EffectBuilder implements Serializable{
private static final long serialVersionUID = 1L;
@Override
public void effect(List<Integer> targetCharacterIDList, GameContent gameContent, int casterCharacterID) {
public void effect(List<Integer> targetCharacterIDList, GameContent gameContent, int casterCharacterID) throws InterruptedException {
Character charac = null;
try {
charac = gameContent.getGameState().getCharacter(casterCharacterID);
......@@ -136,7 +136,7 @@ public class EffectBuilder implements Serializable{
private static final long serialVersionUID = 1L;
@Override
public void effect(List<Integer> targetCharacterIDList, GameContent gameContent, int casterCharacterID) {
public void effect(List<Integer> targetCharacterIDList, GameContent gameContent, int casterCharacterID) throws InterruptedException {
Character charac = null;
try {
charac = gameContent.getGameState().getCharacter(casterCharacterID);
......@@ -173,7 +173,7 @@ public class EffectBuilder implements Serializable{
private static final long serialVersionUID = 1L;
@Override
public void effect(List<Integer> targetCharacterIDList, GameContent gameContent, int casterCharacterID) {
public void effect(List<Integer> targetCharacterIDList, GameContent gameContent, int casterCharacterID) throws InterruptedException {
for (Integer targetID : targetCharacterIDList) {
try {
if(gameContent.getGameState().getEntity(casterCharacterID).getOwned_character() != targetID) {
......@@ -193,7 +193,7 @@ public class EffectBuilder implements Serializable{
private static final long serialVersionUID = 1L;
@Override
public void effect(List<Integer> targetCharacterIDList, GameContent gameContent, int casterCharacterID) {
public void effect(List<Integer> targetCharacterIDList, GameContent gameContent, int casterCharacterID) throws InterruptedException {
boolean hit = false;
for (Integer targetID : targetCharacterIDList) {
try {
......@@ -216,7 +216,7 @@ public class EffectBuilder implements Serializable{
Effect suicide(){
return new Effect(){
private static final long serialVersionUID = 1L;
public void effect(List<Integer> targetCharacterIDList, GameContent gameContent, int casterCharacterID) {
public void effect(List<Integer> targetCharacterIDList, GameContent gameContent, int casterCharacterID) throws InterruptedException {
try {
if(gameContent.getGameState().getEntity(casterCharacterID).getRelayer() != null){
gameContent.getGameState().getEntity(casterCharacterID).getRelayer().kill();
......@@ -270,7 +270,7 @@ public class EffectBuilder implements Serializable{
private Random randomGenerator = new Random();
@Override
public void effect(List<Integer> targetCharacterIDList, GameContent gameContent, int casterCharacterID) {
public void effect(List<Integer> targetCharacterIDList, GameContent gameContent, int casterCharacterID) throws InterruptedException {
List<Integer> idsOfCharactersWhoPassedTheTest = new ArrayList<>();
for (Integer targetID : targetCharacterIDList) {
if (randomGenerator.nextInt(outOf) < chances) {
......@@ -323,7 +323,7 @@ public class EffectBuilder implements Serializable{
private static final long serialVersionUID = 1L;
@Override
public void effect(List<Integer> targetCharacterIDList, GameContent gameContent, int casterCharacterID) {
public void effect(List<Integer> targetCharacterIDList, GameContent gameContent, int casterCharacterID) throws InterruptedException {
List<Integer> newTargetCharacterIDList = new ArrayList<>();
//TODO: The following could be written in a more functional way
for (Integer targetID : targetCharacterIDList) {
......@@ -359,7 +359,7 @@ public class EffectBuilder implements Serializable{
private static final long serialVersionUID = 1L;
@Override
public void effect(List<Integer> targetCharacterIDList, GameContent gameContent, int casterCharacterID) {
public void effect(List<Integer> targetCharacterIDList, GameContent gameContent, int casterCharacterID) throws InterruptedException {
baseEffect.effect(charaListFilter.apply(targetCharacterIDList), gameContent, casterCharacterID);
}
};
......@@ -380,7 +380,7 @@ public class EffectBuilder implements Serializable{
private static final long serialVersionUID = 1L;
@Override
public void effect(List<Integer> targetCharacterIDList, GameContent gameContent, int casterCharacterID) {
public void effect(List<Integer> targetCharacterIDList, GameContent gameContent, int casterCharacterID) throws InterruptedException {
for (Effect baseEffect : baseEffectsArray) {
baseEffect.effect(targetCharacterIDList, gameContent, casterCharacterID);
}
......
......@@ -30,16 +30,16 @@ public class AbilityEvent implements ClientEvent,ServerEvent {
this.potentialCasterCharacterID = potentialCasterCharacterID;
this.abilityNb = abilityNb;
}
@Override
public boolean execute(GameContent gameContent) {
public boolean execute(GameContent gameContent) throws InterruptedException {
Entity potentialCaster = null;
try {
potentialCaster = gameContent.getGameState().getEntity(potentialCasterCharacterID);
Ability abilityPotentiallyCasted = potentialCaster.getAbilityList().get(abilityNb);
List<EffectDescriptor> effectDescriptorList = abilityPotentiallyCasted.cast();
if (effectDescriptorList != null) {
//Ability successfully cast
//TODO: Remove later in the game the Action we add in the following line
......
......@@ -9,9 +9,9 @@ public class AddedTriggerEvent implements ClientEvent{
private static final long serialVersionUID = 1L;
int targetID;
Trigger trigger;
@Override
public boolean execute(GameContent gameContent) {
public boolean execute(GameContent gameContent) throws InterruptedException {
Entity e= null;
try {
e = gameContent.getGameState().getEntity(targetID);
......
package core.event;
import core.gamestate.GameContent;
import network.innershell.NetworkObject;
/**
* This interface is used to define the message transmitted between the Relayer,
* the GameState and the GameLoop.
* @author Guerquin Arnaud
*
*/
public interface Event extends NetworkObject{
static final long serialVersionUID = 1L;
public static final int infinity = -1;
boolean execute(GameContent gameContent);
Event resolve(GameContent gameContent);
/**
* Applies the event on the given gameContent.
* @param gameContent the gameContent on which the event will be applied.
* @return If modification to the gameState occured, it returns an Event whose apply method will perform the same modification
*/
default public Event apply(GameContent gameContent){
if(execute(gameContent))
return resolve(gameContent);
return FailedEvent.failed;
}
}
package core.event;
import core.gamestate.GameContent;
import network.innershell.NetworkObject;
/**
* This interface is used to define the message transmitted between the Relayer,
* the GameState and the GameLoop.
* @author Guerquin Arnaud
*
*/
public interface Event extends NetworkObject{
static final long serialVersionUID = 1L;
public static final int infinity = -1;
boolean execute(GameContent gameContent) throws InterruptedException;
Event resolve(GameContent gameContent);
/**
* Applies the event on the given gameContent.
* @param gameContent the gameContent on which the event will be applied.
* @return If modification to the gameState occured, it returns an Event whose apply method will perform the same modification
* @throws InterruptedException
*/
default public Event apply(GameContent gameContent) throws InterruptedException{
if(execute(gameContent))
return resolve(gameContent);
return FailedEvent.failed;
}
}
Supports Markdown
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