Commit 436a8c76 authored by Mathieu Hilaire's avatar Mathieu Hilaire

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

parents ee2dbc00 4e58807a
Simple assembler of sprites
to run :
java -jar PokemonSpriteAssembler
\ No newline at end of file
...@@ -261,6 +261,17 @@ public abstract class AbstractEntity extends Thread { ...@@ -261,6 +261,17 @@ public abstract class AbstractEntity extends Thread {
} }
} }
public void waiting_move(){
Direction dir = this.relayer.getCharacter().getDirection();
double r = random();
if(r<0.8){
for(int i=0; i<1;i++) {
this.relayer.move(dir);
}
}
else{this.random_move();}
}
public void act() { public void act() {
} }
......
...@@ -39,7 +39,7 @@ public class BossEntity extends AbstractEntity { ...@@ -39,7 +39,7 @@ public class BossEntity extends AbstractEntity {
Entity victim = this.gameState.getAllEntities().get(victim_i); Entity victim = this.gameState.getAllEntities().get(victim_i);
/* d_min minimum distance to not run away /* d_min minimum distance to not run away
* dmax maximum distance to not get closer*/ * dmax maximum distance to not get closer*/
double d_min = 32*3; // tiles of length 32 : so 3 and 7 tiles double d_min = 32*5; // tiles of length 32 : so 5 and 14 tiles
double d_max = 32*14; double d_max = 32*14;
double d = Distance_to_victim(victim); double d = Distance_to_victim(victim);
if(d<d_min){ if(d<d_min){
...@@ -56,14 +56,7 @@ public class BossEntity extends AbstractEntity { ...@@ -56,14 +56,7 @@ public class BossEntity extends AbstractEntity {
} }
else{ else{
Direction dir = this.relayer.getCharacter().getDirection(); this.waiting_move();
double r = random();
if(r<0.8){
for(int i=0; i<1;i++) {
this.relayer.move(Direction.NONE);
}
}
else{this.random_move();}
} }
......
...@@ -52,17 +52,8 @@ public class StraightEntity extends AbstractEntity { ...@@ -52,17 +52,8 @@ public class StraightEntity extends AbstractEntity {
} }
} }
else{ else{
Direction d = this.relayer.getCharacter().getDirection(); this.waiting_move();
double r = random();
if(r<0.8){
for(int i=0; i<1;i++) {
this.relayer.move(d);
}
}
else{this.random_move();}
} }
// attack // attack
} }
} }
...@@ -168,8 +168,9 @@ DIAGLA ...@@ -168,8 +168,9 @@ DIAGLA
#triggers #triggers
0 0
#abilityList #abilityList
1 2
TEST_ATTACK_ABILITY TEST_ATTACK_ABILITY
TEST_FIREBOLT
#hitbox #hitbox
R R
10 10
......
...@@ -265,7 +265,7 @@ public class EffectBuilder implements Serializable{ ...@@ -265,7 +265,7 @@ public class EffectBuilder implements Serializable{
@Override @Override
public void effect(List<Integer> targetCharacterIDList, GameContent gameContent, int casterCharacterID){ public void effect(List<Integer> targetCharacterIDList, GameContent gameContent, int casterCharacterID){
throw new SecurityException(); throw new RuntimeException("Unreachable trap trigger");
} }
}; };
} }
......
...@@ -43,7 +43,13 @@ public class GameContent implements Serializable{ ...@@ -43,7 +43,13 @@ public class GameContent implements Serializable{
for(Entity e:map.getEntities()){ for(Entity e:map.getEntities()){
gameState.addEntity(e); gameState.addEntity(e);
Relayer dmr = Relayers.addNewRelayer(e); Relayer dmr = Relayers.addNewRelayer(e);
AIControler.add(this,dmr, EnumBehaviourType.Boss); String name = dmr.getCharacter().getSpeciesName();
if(name.equals("Ronflex")){
AIControler.add(this,dmr, EnumBehaviourType.Boss);
}
else{
AIControler.add(this,dmr, EnumBehaviourType.Straight);
}
} }
} }
int posX=(map.getPositionPlayerStart().getI())*Point.TileScale; int posX=(map.getPositionPlayerStart().getI())*Point.TileScale;
...@@ -127,7 +133,7 @@ public class GameContent implements Serializable{ ...@@ -127,7 +133,7 @@ public class GameContent implements Serializable{
sem.release(); sem.release();
} }
public boolean checkStrairs(Map newMap,NetworkConnection networkConnection) throws InterruptedException { public boolean checkStairs(Map newMap,NetworkConnection networkConnection) throws InterruptedException {
for(Character player:players){ for(Character player:players){
if(player.isOnStairs(map)){ if(player.isOnStairs(map)){
recreate(map,true); recreate(map,true);
......
...@@ -125,7 +125,7 @@ public class ServerLoop extends Thread { ...@@ -125,7 +125,7 @@ public class ServerLoop extends Thread {
networkConnection.sendEvent(toBeSentToClientsEvent); networkConnection.sendEvent(toBeSentToClientsEvent);
} }
gameContent.applyTrigger(networkConnection); gameContent.applyTrigger(networkConnection);
if(gameContent.checkStrairs(nextMap,networkConnection)) if(gameContent.checkStairs(nextMap,networkConnection))
nextMap=MapGeneration.mapGeneration(MapSize.SMALL); nextMap=MapGeneration.mapGeneration(MapSize.SMALL);
} }
......
...@@ -28,8 +28,9 @@ public class AvatarDisplayer ...@@ -28,8 +28,9 @@ public class AvatarDisplayer
private int barreSizeH = 10; private int barreSizeH = 10;
private Color lifeColorActive = new Color(255,0,0, 255); private Color lifeColorActive = new Color(255,0,0, 255);
private Color lifeColorPassive = new Color(255,0,0, 80); private Color lifeColorPassive = new Color(255,0,0, 80);
private Color expColorActive = new Color(125, 46, 116, 255); private Color goldColor = new Color(255, 209, 61,255);
private Color expColorPassive = new Color(125, 46, 116, 80); // private Color expColorActive = new Color(125, 46, 116, 255);
// private Color expColorPassive = new Color(125, 46, 116, 80);
private String pathCharacter = "/assets/character/"; private String pathCharacter = "/assets/character/";
private String imgTypeCharacter = ".gif"; private String imgTypeCharacter = ".gif";
private String pathBuff = "/assets/"; private String pathBuff = "/assets/";
...@@ -60,11 +61,16 @@ public class AvatarDisplayer ...@@ -60,11 +61,16 @@ public class AvatarDisplayer
g.setColor(lifeColorActive); g.setColor(lifeColorActive);
g.fillRect(pictureSize + 10,10,Math.round(barreSizeW * (float)character.getHP() / character.getMaxHP()),barreSizeH); g.fillRect(pictureSize + 10,10,Math.round(barreSizeW * (float)character.getHP() / character.getMaxHP()),barreSizeH);
/** Exp **/ /** Gold **/
g.setColor(expColorPassive); g.setColor(goldColor);
g.fillRect(pictureSize + 10,25, barreSizeW,barreSizeH); g.setFont(new Font("Arial", Font.PLAIN, 20));
g.setColor(expColorActive); g.drawString("" + character.getGold(), 100,50);
g.fillRect(pictureSize + 10,25,Math.round(barreSizeW * (float)character.getExp() / character.getMaxExp()),barreSizeH);
// /** Exp **/
// g.setColor(expColorPassive);
// g.fillRect(pictureSize + 10,25, barreSizeW,barreSizeH);
// g.setColor(expColorActive);
// g.fillRect(pictureSize + 10,25,Math.round(barreSizeW * (float)character.getExp() / character.getMaxExp()),barreSizeH);
/** Buffs **/ /** Buffs **/
for (int i = 0; i < buffList.size(); i++) for (int i = 0; i < buffList.size(); i++)
......
...@@ -15,7 +15,7 @@ import java.awt.event.ActionEvent; ...@@ -15,7 +15,7 @@ import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
/** /**
* Created by dupriez on 01/01/16. * Created by tlopez on 06/01/16.
*/ */
public class GameWinPanel extends MenuPanel implements GameOverPanelAbstraction { public class GameWinPanel extends MenuPanel implements GameOverPanelAbstraction {
......
...@@ -238,7 +238,7 @@ public class FollowerBehaviour { ...@@ -238,7 +238,7 @@ public class FollowerBehaviour {
case "NOMME" : case "NOMME" :
List<Character> l7 = new ArrayList<Character>(); List<Character> l7 = new ArrayList<Character>();
for (Character ch : list) { for (Character ch : list) {
if (target.get(1) == ch.getName()) { if (target.get(1).equals(ch.getName())) {
l7.add(ch); l7.add(ch);
} }
} }
......
...@@ -15,26 +15,26 @@ import java.util.*; ...@@ -15,26 +15,26 @@ import java.util.*;
public class IGPEntity extends AbstractEntity { public class IGPEntity extends AbstractEntity {
BehaviourHolder behold = BehaviourHolder.getInstance();
public IGPEntity(GameContent gameContent, Relayer relayer) { public IGPEntity(GameContent gameContent, Relayer relayer) {
super(gameContent,relayer); super(gameContent,relayer);
} }
@Override @Override
public void act() { public void act() {
FollowerBehaviour fb = behold.GetFollowerBehaviour(); // Looking at the FollowerBehaviour generated by the IGPpanel
FollowerBehaviour fb = BehaviourHolder.getInstance().GetFollowerBehaviour();
List <Character> chlist=null; List <Character> chlist=null;
try{ try{
chlist = gameState.getAllCharacters(); chlist = gameState.getAllCharacters();
}catch(InterruptedException e){ }catch(InterruptedException e){
return; return;
} }
// Using the FollowerBehaviour to find the "victim" of our action and find the action
Character victim = fb.FindTarget(chlist); Character victim = fb.FindTarget(chlist);
String action = fb.getAction(); String action = fb.getAction();
switch (action) { switch (action) {
case "attaquer": case "attaquer":
/* TODO : attaquer victim */ // Goto the victim and try to attack it
int dX = victim.getX(); int dX = victim.getX();
int dY = victim.getY(); int dY = victim.getY();
int sX = relayer.getCharacter().getX(); int sX = relayer.getCharacter().getX();
...@@ -48,7 +48,7 @@ public class IGPEntity extends AbstractEntity { ...@@ -48,7 +48,7 @@ public class IGPEntity extends AbstractEntity {
this.relayer.tryToCastAbility(0); this.relayer.tryToCastAbility(0);
break; break;
case "proteger": case "proteger":
/* TODO : proteger victim */ /* Find the nearest ennemy from the character we have to protect and try to attack him */
int dX2 = victim.getX(); int dX2 = victim.getX();
int dY2 = victim.getY(); int dY2 = victim.getY();
int sX2 = relayer.getCharacter().getX(); int sX2 = relayer.getCharacter().getX();
...@@ -84,8 +84,9 @@ public class IGPEntity extends AbstractEntity { ...@@ -84,8 +84,9 @@ public class IGPEntity extends AbstractEntity {
} }
break; break;
case "soigner" : case "soigner" :
/*TODO : Soigner victim */ // This case is not implemented in the game, so "soigner" willl be considered as nothing by the IA
default: default:
// In the default case, so the aciton "nothing", the Follower will just follow his owner
Entity owner =null; Entity owner =null;
try { try {
owner = gameState.getEntity(relayer.getCharacter().getOwner()); owner = gameState.getEntity(relayer.getCharacter().getOwner());
......
...@@ -11,12 +11,12 @@ import java.io.InputStream; ...@@ -11,12 +11,12 @@ import java.io.InputStream;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.util.*; import java.util.*;
/** First iteration of the panel for ingame programming /** Panel for ingame programming
* @author Alexis Ghyselen & William Babonnaud * @author Alexis Ghyselen & William Babonnaud
*/ */
public class IGPpanel extends graphics.guiSkeleton.guiPanel.GUIPanel{ public class IGPpanel extends graphics.guiSkeleton.guiPanel.GUIPanel{
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** nbf is the number of rules we want in our panel, here we decide that we will work with 8 possible rules */ /** nbf is the number of rules we want in our panel, here we decide that we will work with 8 possible rules */
private int nbf = 8 ; private int nbf = 8 ;
...@@ -26,7 +26,7 @@ public class IGPpanel extends graphics.guiSkeleton.guiPanel.GUIPanel{ ...@@ -26,7 +26,7 @@ public class IGPpanel extends graphics.guiSkeleton.guiPanel.GUIPanel{
/** fob is the FollowerBheaviour created by the IGPpanel, it's is linked to the BehaviourHolder when you press back */ /** fob is the FollowerBheaviour created by the IGPpanel, it's is linked to the BehaviourHolder when you press back */
private FollowerBehaviour fob = new FollowerBehaviour(nbf); private FollowerBehaviour fob = new FollowerBehaviour(nbf);
/** This is the elements of our panel, for each rule, we got a switch button, a textfield to write the rule and an hint label that is useless for now */ /** This is the elements of our panel, for each rule, we got a switch button, a textfield to write the rule and an hint label give example of sentences */
private JButton[] bswitch = new JButton[nbf]; private JButton[] bswitch = new JButton[nbf];
private JTextField[] prflabel = new JTextField[nbf]; private JTextField[] prflabel = new JTextField[nbf];
private JLabel[] hintlabel = new JLabel[nbf]; private JLabel[] hintlabel = new JLabel[nbf];
...@@ -36,9 +36,9 @@ public class IGPpanel extends graphics.guiSkeleton.guiPanel.GUIPanel{ ...@@ -36,9 +36,9 @@ public class IGPpanel extends graphics.guiSkeleton.guiPanel.GUIPanel{
/** /**
* ActionListener to parse an instruction. * ActionListener to parse an instruction.
* Should be modified soon. Now change the color of the textfield in green if the * Change the color of the textfield in green if the
* instruction is correct, and in red otherwise. * instruction is correct, and in red otherwise.
* TODO We should find some more harmonious colors and add them to GUIColorAndFonts. * And add the new instruction to the FollowerBehaviour fob
*/ */
parselistener = new ActionListener[nbf]; parselistener = new ActionListener[nbf];
...@@ -91,21 +91,6 @@ public class IGPpanel extends graphics.guiSkeleton.guiPanel.GUIPanel{ ...@@ -91,21 +91,6 @@ public class IGPpanel extends graphics.guiSkeleton.guiPanel.GUIPanel{
buttonPanel.setBackground(GUIColorsAndFonts.backGround1); buttonPanel.setBackground(GUIColorsAndFonts.backGround1);
GridBagConstraints c2; GridBagConstraints c2;
/* Create empty boxes to arrange horizontally the elements
for (int i=0; i < nbf; i++) {
c2 = new GridBagConstraints();
/* c2.gridx=0;c2.gridy=(i+1);c2.gridwidth=1;c2.gridheight=1;c2.weightx=1;c2.weighty=1;
buttonPanel.add(Box.createHorizontalGlue(), c2); */
/* c2.gridx=2;c2.gridy=(i+1);c2.weightx=1;
buttonPanel.add(Box.createHorizontalGlue(), c2); */
/*c2.gridx=4;c2.gridy=(i+1);c2.weightx=1;
buttonPanel.add(Box.createHorizontalGlue(), c2); */
/* c2.gridx=6;c2.gridy=(i+1);c2.weightx=1;
buttonPanel.add(Box.createHorizontalGlue(), c2);
c2.gridx=7;c2.gridy=(i+1);c2.weightx=1;
buttonPanel.add(Box.createHorizontalGlue(), c2);
} */
/** Creation of the elements of the IGP_Panel */ /** Creation of the elements of the IGP_Panel */
for (int i =0; i < nbf ; i++) { for (int i =0; i < nbf ; i++) {
/** The button that will allow the user to switch rules */ /** The button that will allow the user to switch rules */
...@@ -155,23 +140,6 @@ public class IGPpanel extends graphics.guiSkeleton.guiPanel.GUIPanel{ ...@@ -155,23 +140,6 @@ public class IGPpanel extends graphics.guiSkeleton.guiPanel.GUIPanel{
c = new GridBagConstraints(); c = new GridBagConstraints();
c.gridx=0; c.gridy=1; c.gridwidth=1; c.gridheight=1;c.weightx=1;c.weighty=10;c.fill=GridBagConstraints.BOTH; c.gridx=0; c.gridy=1; c.gridwidth=1; c.gridheight=1;c.weightx=1;c.weighty=10;c.fill=GridBagConstraints.BOTH;
add(buttonPanel, c); add(buttonPanel, c);
/*
ENS label panel
JPanel ensLabelPanel = new JPanel();
ensLabelPanel.setLayout(new BorderLayout());
ensLabelPanel.setOpaque(true);
ensLabelPanel.setBackground(GUIColorsAndFonts.backGround1);
JLabel ensLabel = new JLabel();
ensLabel.setFont(GUIColorsAndFonts.smallFont1);
ensLabel.setText("V1.0 - ENS team");
ensLabel.setForeground(GUIColorsAndFonts.fontColor1);
ensLabelPanel.add(ensLabel, BorderLayout.LINE_START);
c = new GridBagConstraints();
c.gridx=0; c.gridy=2; c.gridwidth=1; c.gridheight=1;c.weightx=0;c.weighty=0;c.fill=GridBagConstraints.BOTH;
add(ensLabelPanel, c); */
} }
/** ActionListener that will allow to switch rules */ /** ActionListener that will allow to switch rules */
......
...@@ -26,13 +26,16 @@ import core.abilities.AbilityKey; ...@@ -26,13 +26,16 @@ import core.abilities.AbilityKey;
public class TestIGP { public class TestIGP {
public static void main(String argv[]) throws ParseException { public static void main(String argv[]) throws ParseException {
System.out.println("Bonjour"); System.out.println("Bonjour");
Script parser = new Script(stringToStream("attaque ennemi (avec PV < 50% et (avec DEF < 50 ou non possedant potion)) ou avec DEF = 50")); FollowerBehaviour fb = new FollowerBehaviour(4);
try { Script parser = new Script(stringToStream("attaque ennemi (avec PV < 50% et (avec DEF < 50 ou non avec MEN < 50)) ou avec DEF = 50"));
parser.Instruction(); ArrayList<String> targett = parser.checkInput();
} catch(ParseException e) { if (targett.get(0) != "NULL") {
System.out.println("ParseException error"); String act = targett.get(0);
} catch(TokenMgrError e) { targett.remove(0);
System.out.println("TokenMgrError error"); fb.setNthInstruction(targett,act,3);
}
else {
fb.setNthInstruction(targett,"nothing",3);
} }
Zone zone = EmptyZone.getEmptyZone(); Zone zone = EmptyZone.getEmptyZone();
TilePropertyVector tpv = new TilePropertyVector(); TilePropertyVector tpv = new TilePropertyVector();
...@@ -47,7 +50,9 @@ public class TestIGP { ...@@ -47,7 +50,9 @@ public class TestIGP {
Character ch2 = new Character("nom2","spnom1",10,10,10,1,zone,tpv,zone,edt,list,30,30,30,dtv,zone,30,30,abl); Character ch2 = new Character("nom2","spnom1",10,10,10,1,zone,tpv,zone,edt,list,30,30,30,dtv,zone,30,30,abl);
ch2.takeDamage(20); ch2.takeDamage(20);
Character ch3 = new Character("nom3","spnom1",10,10,10,1,zone,tpv,zone,edt,list,40,40,40,dtv,zone,40,40,abl); Character ch3 = new Character("nom3","spnom1",10,10,10,1,zone,tpv,zone,edt,list,40,40,40,dtv,zone,40,40,abl);
ch3.takeDamage(20);
Character ch4 = new Character("nom4","spnom1",10,10,10,1,zone,tpv,zone,edt,list,50,30,50,dtv,zone,50,50,abl); Character ch4 = new Character("nom4","spnom1",10,10,10,1,zone,tpv,zone,edt,list,50,30,50,dtv,zone,50,50,abl);
ch4.takeDamage(20);
Character ch5 = new Character("nom5","spnom1",10,10,10,1,zone,tpv,zone,edt,list,60,30,60,dtv,zone,60,60,abl); Character ch5 = new Character("nom5","spnom1",10,10,10,1,zone,tpv,zone,edt,list,60,30,60,dtv,zone,60,60,abl);
ch5.takeDamage(10); ch5.takeDamage(10);
ArrayList<Character> chlist = new ArrayList<Character>(); ArrayList<Character> chlist = new ArrayList<Character>();
...@@ -56,42 +61,37 @@ public class TestIGP { ...@@ -56,42 +61,37 @@ public class TestIGP {
chlist.add(ch3); chlist.add(ch3);
chlist.add(ch4); chlist.add(ch4);
chlist.add(ch5); chlist.add(ch5);
FollowerBehaviour fb = new FollowerBehaviour(3); Script parser2 = new Script(stringToStream("Bonjour"));
ArrayList<String> target3 = new ArrayList<String>(); ArrayList<String> target3 = parser2.checkInput();
target3.add("NULL"); if (target3.get(0) != "NULL") {
fb.setNthInstruction(target3,"nothing",0); String act = target3.get(0);
ArrayList<String> target2 = new ArrayList<String>(); target3.remove(0);
target2.add("CTR"); fb.setNthInstruction(target3,act,0);
target2.add("allie"); }
target2.add("NO"); else {
target2.add("AVEC"); fb.setNthInstruction(target3,"nothing",0);
target2.add("MEN"); }
target2.add("="); Script parser3 = new Script(stringToStream("proteger allie non avec MEN = 20"));
target2.add("20"); ArrayList<String> target2 = parser3.checkInput();
fb.setNthInstruction(target2,"proteger",1); if (target2.get(0) != "NULL") {
ArrayList<String> target = new ArrayList<String>(); String act = target2.get(0);
target.add("CTR"); target2.remove(0);
target.add("ennemi"); fb.setNthInstruction(target2,act,1);
target.add("OU"); }
target.add("("); else {
target.add("ET"); fb.setNthInstruction(target2,"nothing",1);
target.add("("); }
target.add("AVEC"); Script parser4 = new Script(stringToStream("soigner ennemi (avec DEF >= 40 et non nommé nom3 ) ou avec PV = 100%"));
target.add("DEF"); ArrayList<String> target = parser4.checkInput();
target.add(">="); if (target.get(0) != "NULL") {
target.add("40"); String act = target.get(0);
target.add(")"); target.remove(0);
target.add("NO"); fb.setNthInstruction(target,act,2);
target.add("NOMME"); }
target.add("nom3"); else {
target.add(")"); fb.setNthInstruction(target,"nothing",2);
target.add("AVEC"); }
target.add("PV"); fb.PrintElements();
target.add("=");
target.add("%");
target.add("100");
target.add("EOF");
fb.setNthInstruction(target,"attaquer",2);
BehaviourHolder bh = BehaviourHolder.getInstance(); BehaviourHolder bh = BehaviourHolder.getInstance();
bh.SetFollowerBehaviour(fb); bh.SetFollowerBehaviour(fb);
Character ch = bh.GetFollowerBehaviour().FindTarget(chlist); Character ch = bh.GetFollowerBehaviour().FindTarget(chlist);
......
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