Commit 4e58807a authored by Thomas Dupriez's avatar Thomas Dupriez

Merge remote-tracking branch 'origin/master'

parents 875c049f 96920cfc
......@@ -265,7 +265,7 @@ public class EffectBuilder implements Serializable{
@Override
public void effect(List<Integer> targetCharacterIDList, GameContent gameContent, int casterCharacterID){
throw new SecurityException();
throw new RuntimeException("Unreachable trap trigger");
}
};
}
......
......@@ -133,7 +133,7 @@ public class GameContent implements Serializable{
sem.release();
}
public boolean checkStrairs(Map newMap,NetworkConnection networkConnection) throws InterruptedException {
public boolean checkStairs(Map newMap,NetworkConnection networkConnection) throws InterruptedException {
for(Character player:players){
if(player.isOnStairs(map)){
recreate(map,true);
......
......@@ -125,7 +125,7 @@ public class ServerLoop extends Thread {
networkConnection.sendEvent(toBeSentToClientsEvent);
}
gameContent.applyTrigger(networkConnection);
if(gameContent.checkStrairs(nextMap,networkConnection))
if(gameContent.checkStairs(nextMap,networkConnection))
nextMap=MapGeneration.mapGeneration(MapSize.SMALL);
}
......
......@@ -15,7 +15,7 @@ import java.awt.event.ActionEvent;
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 {
......
......@@ -238,7 +238,7 @@ public class FollowerBehaviour {
case "NOMME" :
List<Character> l7 = new ArrayList<Character>();
for (Character ch : list) {
if (target.get(1) == ch.getName()) {
if (target.get(1).equals(ch.getName())) {
l7.add(ch);
}
}
......
......@@ -15,26 +15,26 @@ import java.util.*;
public class IGPEntity extends AbstractEntity {
BehaviourHolder behold = BehaviourHolder.getInstance();
public IGPEntity(GameContent gameContent, Relayer relayer) {
super(gameContent,relayer);
}
@Override
public void act() {
FollowerBehaviour fb = behold.GetFollowerBehaviour();
// Looking at the FollowerBehaviour generated by the IGPpanel
FollowerBehaviour fb = BehaviourHolder.getInstance().GetFollowerBehaviour();
List <Character> chlist=null;
try{
chlist = gameState.getAllCharacters();
}catch(InterruptedException e){
return;
}
// Using the FollowerBehaviour to find the "victim" of our action and find the action
Character victim = fb.FindTarget(chlist);
String action = fb.getAction();
switch (action) {
case "attaquer":
/* TODO : attaquer victim */
// Goto the victim and try to attack it
int dX = victim.getX();
int dY = victim.getY();
int sX = relayer.getCharacter().getX();
......@@ -48,7 +48,7 @@ public class IGPEntity extends AbstractEntity {
this.relayer.tryToCastAbility(0);
break;
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 dY2 = victim.getY();
int sX2 = relayer.getCharacter().getX();
......@@ -84,8 +84,9 @@ public class IGPEntity extends AbstractEntity {
}
break;
case "soigner" :
/*TODO : Soigner victim */
// This case is not implemented in the game, so "soigner" willl be considered as nothing by the IA
default:
// In the default case, so the aciton "nothing", the Follower will just follow his owner
Entity owner =null;
try {
owner = gameState.getEntity(relayer.getCharacter().getOwner());
......
......@@ -11,12 +11,12 @@ import java.io.InputStream;
import java.io.ByteArrayInputStream;
import java.util.*;
/** First iteration of the panel for ingame programming
/** Panel for ingame programming
* @author Alexis Ghyselen & William Babonnaud
*/
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 */
private int nbf = 8 ;
......@@ -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 */
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 JTextField[] prflabel = new JTextField[nbf];
private JLabel[] hintlabel = new JLabel[nbf];
......@@ -36,9 +36,9 @@ public class IGPpanel extends graphics.guiSkeleton.guiPanel.GUIPanel{
/**
* 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.
* 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];
......@@ -91,21 +91,6 @@ public class IGPpanel extends graphics.guiSkeleton.guiPanel.GUIPanel{
buttonPanel.setBackground(GUIColorsAndFonts.backGround1);
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 */
for (int i =0; i < nbf ; i++) {
/** The button that will allow the user to switch rules */
......@@ -155,23 +140,6 @@ public class IGPpanel extends graphics.guiSkeleton.guiPanel.GUIPanel{
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;
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 */
......
......@@ -26,13 +26,16 @@ import core.abilities.AbilityKey;
public class TestIGP {
public static void main(String argv[]) throws ParseException {
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"));
try {
parser.Instruction();
} catch(ParseException e) {
System.out.println("ParseException error");
} catch(TokenMgrError e) {
System.out.println("TokenMgrError error");
FollowerBehaviour fb = new FollowerBehaviour(4);
Script parser = new Script(stringToStream("attaque ennemi (avec PV < 50% et (avec DEF < 50 ou non avec MEN < 50)) ou avec DEF = 50"));
ArrayList<String> targett = parser.checkInput();
if (targett.get(0) != "NULL") {
String act = targett.get(0);
targett.remove(0);
fb.setNthInstruction(targett,act,3);
}
else {
fb.setNthInstruction(targett,"nothing",3);
}
Zone zone = EmptyZone.getEmptyZone();
TilePropertyVector tpv = new TilePropertyVector();
......@@ -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);
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);
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);
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);
ch5.takeDamage(10);
ArrayList<Character> chlist = new ArrayList<Character>();
......@@ -56,42 +61,37 @@ public class TestIGP {
chlist.add(ch3);
chlist.add(ch4);
chlist.add(ch5);
FollowerBehaviour fb = new FollowerBehaviour(3);
ArrayList<String> target3 = new ArrayList<String>();
target3.add("NULL");
fb.setNthInstruction(target3,"nothing",0);
ArrayList<String> target2 = new ArrayList<String>();
target2.add("CTR");
target2.add("allie");
target2.add("NO");
target2.add("AVEC");
target2.add("MEN");
target2.add("=");
target2.add("20");
fb.setNthInstruction(target2,"proteger",1);
ArrayList<String> target = new ArrayList<String>();
target.add("CTR");
target.add("ennemi");
target.add("OU");
target.add("(");
target.add("ET");
target.add("(");
target.add("AVEC");
target.add("DEF");
target.add(">=");
target.add("40");
target.add(")");
target.add("NO");
target.add("NOMME");
target.add("nom3");
target.add(")");
target.add("AVEC");
target.add("PV");
target.add("=");
target.add("%");
target.add("100");
target.add("EOF");
fb.setNthInstruction(target,"attaquer",2);
Script parser2 = new Script(stringToStream("Bonjour"));
ArrayList<String> target3 = parser2.checkInput();
if (target3.get(0) != "NULL") {
String act = target3.get(0);
target3.remove(0);
fb.setNthInstruction(target3,act,0);
}
else {
fb.setNthInstruction(target3,"nothing",0);
}
Script parser3 = new Script(stringToStream("proteger allie non avec MEN = 20"));
ArrayList<String> target2 = parser3.checkInput();
if (target2.get(0) != "NULL") {
String act = target2.get(0);
target2.remove(0);
fb.setNthInstruction(target2,act,1);
}
else {
fb.setNthInstruction(target2,"nothing",1);
}
Script parser4 = new Script(stringToStream("soigner ennemi (avec DEF >= 40 et non nommé nom3 ) ou avec PV = 100%"));
ArrayList<String> target = parser4.checkInput();
if (target.get(0) != "NULL") {
String act = target.get(0);
target.remove(0);
fb.setNthInstruction(target,act,2);
}
else {
fb.setNthInstruction(target,"nothing",2);
}
fb.PrintElements();
BehaviourHolder bh = BehaviourHolder.getInstance();
bh.SetFollowerBehaviour(fb);
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