Commit 29923d5f authored by Louis Cohen's avatar Louis Cohen
Browse files

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

parents c5430a12 0edca016
......@@ -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
......
......@@ -26,11 +26,10 @@ public class IGPEntity extends AbstractEntity {
FollowerBehaviour fb = behold.GetFollowerBehaviour();
List <Character> chlist=null;
try{
gameState.getAllCharacters();
chlist = gameState.getAllCharacters();
}catch(InterruptedException e){
return;
return;
}
/* TODO : ne garder que les personnages visibles ? */
Character victim = fb.FindTarget(chlist);
String action = fb.getAction();
switch (action) {
......@@ -78,18 +77,18 @@ public class IGPEntity extends AbstractEntity {
/*TODO : Soigner victim */
break;
default:
Entity owner =null;
try {
owner = gameState.getEntity(relayer.getCharacter().getOwner());
Entity owner =null;
try {
owner = gameState.getEntity(relayer.getCharacter().getOwner());
}catch(Exception e){
return;
}
int dX3 = owner.getX();
int dY3 = owner.getY();
int sX3 = relayer.getCharacter().getX();
int sY3 = relayer.getCharacter().getY();
Direction dir3 = AI.alpha_star(map,sX3, sY3, dX3, dY3,map.getWidth(),map.getHeight());
this.relayer.move(dir3);
return;
}
int dX3 = owner.getX();
int dY3 = owner.getY();
int sX3 = relayer.getCharacter().getX();
int sY3 = relayer.getCharacter().getY();
Direction dir3 = AI.alpha_star(map,sX3, sY3, dX3, dY3,map.getWidth(),map.getHeight());
this.relayer.move(dir3);
}
}
}
......@@ -48,16 +48,16 @@ public class IGPpanel extends graphics.guiSkeleton.guiPanel.GUIPanel{
@Override
public void actionPerformed(ActionEvent e) {
Script parser = new Script(stringToStream(prflabel[j].getText()));
if (parser.checkInput().get(0) != "NULL") {
ArrayList<String> target = parser.checkInput();
if (target.get(0) != "NULL") {
prflabel[j].setBackground(Color.green);
ArrayList<String> target = new ArrayList<String>();
fob.setNthInstruction(target,"attaque",j);
String act = target.get(0);
target.remove(0);
fob.setNthInstruction(target,act,j);
}
else {
prflabel[j].setBackground(Color.red);
ArrayList<String> emptytarget = new ArrayList<String>();
emptytarget.add("NULL");
fob.setNthInstruction(emptytarget,"nothing",j);
fob.setNthInstruction(target,"nothing",j);
}
}
};
......@@ -206,6 +206,7 @@ public class IGPpanel extends graphics.guiSkeleton.guiPanel.GUIPanel{
public void actionPerformed(ActionEvent actionEvent) {
BehaviourHolder.getInstance().SetFollowerBehaviour(fob);
getGraphicsMaster().changeGUIStateTo(GraphicsMaster.GUIStates.MAIN_MENU);
BehaviourHolder.getInstance().GetFollowerBehaviour().PrintElements();
}
};
......
/* Generated By:JavaCC: Do not edit this line. ParseException.java Version 5.0 */
/* JavaCCOptions:KEEP_LINE_COL=null */
/* Generated By:JavaCC: Do not edit this line. ParseException.java Version 6.1 */
/* JavaCCOptions:KEEP_LINE_COLUMN=true */
package ingame_programming;
/**
......@@ -20,6 +20,11 @@ public class ParseException extends Exception {
*/
private static final long serialVersionUID = 1L;
/**
* The end of line string for this machine.
*/
protected static String EOL = System.getProperty("line.separator", "\n");
/**
* This constructor is used by the method "generateParseException"
* in the generated parser. Calling this constructor generates
......@@ -88,7 +93,7 @@ public class ParseException extends Exception {
private static String initialise(Token currentToken,
int[][] expectedTokenSequences,
String[] tokenImage) {
String eol = System.getProperty("line.separator", "\n");
StringBuffer expected = new StringBuffer();
int maxSize = 0;
for (int i = 0; i < expectedTokenSequences.length; i++) {
......@@ -101,7 +106,7 @@ public class ParseException extends Exception {
if (expectedTokenSequences[i][expectedTokenSequences[i].length - 1] != 0) {
expected.append("...");
}
expected.append(eol).append(" ");
expected.append(EOL).append(" ");
}
String retval = "Encountered \"";
Token tok = currentToken.next;
......@@ -118,20 +123,23 @@ public class ParseException extends Exception {
tok = tok.next;
}
retval += "\" at line " + currentToken.next.beginLine + ", column " + currentToken.next.beginColumn;
retval += "." + eol;
if (expectedTokenSequences.length == 1) {
retval += "Was expecting:" + eol + " ";
retval += "." + EOL;
if (expectedTokenSequences.length == 0) {
// Nothing to add here
} else {
retval += "Was expecting one of:" + eol + " ";
if (expectedTokenSequences.length == 1) {
retval += "Was expecting:" + EOL + " ";
} else {
retval += "Was expecting one of:" + EOL + " ";
}
retval += expected.toString();
}
retval += expected.toString();
return retval;
}
/**
* The end of line string for this machine.
*/
protected String eol = System.getProperty("line.separator", "\n");
/**
* Used to convert raw characters to their escaped version
......@@ -144,8 +152,6 @@ public class ParseException extends Exception {
for (int i = 0; i < str.length(); i++) {
switch (str.charAt(i))
{
case 0 :
continue;
case '\b':
retval.append("\\b");
continue;
......@@ -184,4 +190,4 @@ public class ParseException extends Exception {
}
}
/* JavaCC - OriginalChecksum=fdeccd9ec608922b5d520e3c9365cc57 (do not edit this line) */
/* JavaCC - OriginalChecksum=a98a94272526032735fc5fe6318e2fe9 (do not edit this line) */
/* Script.java */
/* Generated By:JavaCC: Do not edit this line. Script.java */
package ingame_programming;
......@@ -23,12 +24,11 @@ public class Script implements ScriptConstants {
return msg;
}
final public ArrayList<String> Instruction() throws ParseException {
ArrayList<String> target = new ArrayList<String>();
final public ArrayList<String> Instruction() throws ParseException {ArrayList<String> target = new ArrayList<String>();
ArrayList<String> tmp = new ArrayList<String>();
Token t;
t = jj_consume_token(VB);
switch (t.image.substring(0, 3)) {
switch (t.image.substring(0, 3)) {
case "att":
target.add("attaquer");
break;
......@@ -43,7 +43,7 @@ public class Script implements ScriptConstants {
}
jj_consume_token(SPACE);
t = jj_consume_token(CTR);
target.add("CTR");
target.add("CTR");
switch (t.image.substring(0,3)) {
case "all":
target.add("allie");
......@@ -51,24 +51,25 @@ public class Script implements ScriptConstants {
default:
target.add(t.image);
}
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case SPACE:
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
case SPACE:{
jj_consume_token(SPACE);
tmp = Option();
label_1:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case SPACE:
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
case SPACE:{
;
break;
}
default:
jj_la1[0] = jj_gen;
break label_1;
}
jj_consume_token(SPACE);
t = jj_consume_token(LOGIC);
tmp.add(0, "(");
tmp.add(0, "(");
tmp.add(0, t.image.toUpperCase());
tmp.add(")");
target.addAll(tmp);
......@@ -76,124 +77,137 @@ public class Script implements ScriptConstants {
tmp = Option();
}
break;
}
default:
jj_la1[1] = jj_gen;
;
}
jj_consume_token(0);
target.addAll(tmp);
{if (true) return target;}
target.addAll(tmp);
{if ("" != null) return target;}
throw new Error("Missing return statement in function");
}
/** Détail des options. */
final public ArrayList<String> Option() throws ParseException {
ArrayList<String> tmp1 = new ArrayList<String>();
final public ArrayList<String> Option() throws ParseException {ArrayList<String> tmp1 = new ArrayList<String>();
ArrayList<String> tmp2 = new ArrayList<String>();
Token t;
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case CLASS:
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
case CLASS:{
t = jj_consume_token(CLASS);
tmp1.add("CLASS");
tmp1.add("CLASS");
tmp1.add(t.image);
{if (true) return tmp1;}
{if ("" != null) return tmp1;}
break;
case NOMME:
}
case NOMME:{
jj_consume_token(NOMME);
jj_consume_token(SPACE);
t = jj_consume_token(NAME);
tmp1.add("NOMME");
tmp1.add("NOMME");
tmp1.add(t.image);
{if (true) return tmp1;}
{if ("" != null) return tmp1;}
break;
case AVEC:
}
case AVEC:{
jj_consume_token(AVEC);
jj_consume_token(SPACE);
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case STAT:
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
case STAT:{
t = jj_consume_token(STAT);
tmp1.add("AVEC");
tmp1.add("AVEC");
tmp1.add(t.image);
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case SPACE:
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
case SPACE:{
jj_consume_token(SPACE);
break;
}
default:
jj_la1[2] = jj_gen;
;
}
t = jj_consume_token(CMP);
tmp1.add(t.image);
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case SPACE:
tmp1.add(t.image);
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
case SPACE:{
jj_consume_token(SPACE);
break;
}
default:
jj_la1[3] = jj_gen;
;
}
t = jj_consume_token(VAL);
tmp1.add(t.image);
tmp1.add(t.image);
break;
case HP:
}
case HP:{
jj_consume_token(HP);
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case SPACE:
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
case SPACE:{
jj_consume_token(SPACE);
break;
}
default:
jj_la1[4] = jj_gen;
;
}
t = jj_consume_token(CMP);
tmp1.add("AVEC");
tmp1.add("AVEC");
tmp1.add("PV");
tmp1.add(t.image);
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case SPACE:
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
case SPACE:{
jj_consume_token(SPACE);
break;
}
default:
jj_la1[5] = jj_gen;
;
}
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case VAL:
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
case VAL:{
t = jj_consume_token(VAL);
tmp1.add(t.image);
tmp1.add(t.image);
break;
case VALPRCT:
}
case VALPRCT:{
t = jj_consume_token(VALPRCT);
tmp1.add("%");
tmp1.add("%");
tmp1.add(t.image.substring(0, t.image.length()-1));
break;
}
default:
jj_la1[6] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
break;
}
default:
jj_la1[7] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
{if (true) return tmp1;}
{if ("" != null) return tmp1;}
break;
case POSSEDANT:
}
case POSSEDANT:{
jj_consume_token(POSSEDANT);
jj_consume_token(SPACE);
t = jj_consume_token(ITEM);
tmp1.add("POSSEDANT");
tmp1.add("POSSEDANT");
tmp1.add(t.image.toLowerCase().replaceAll("\u00e9|\u00e8|\u00ea","e"));
{if (true) return tmp1;}
{if ("" != null) return tmp1;}
break;
case 20:
}
case 20:{
jj_consume_token(20);
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case SPACE:
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
case SPACE:{
jj_consume_token(SPACE);
break;
}
default:
jj_la1[8] = jj_gen;
;
......@@ -203,28 +217,31 @@ public class Script implements ScriptConstants {
t = jj_consume_token(LOGIC);
jj_consume_token(SPACE);
tmp2 = Option();
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case SPACE:
switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {
case SPACE:{
jj_consume_token(SPACE);
break;
}
default:
jj_la1[9] = jj_gen;
;
}
jj_consume_token(21);
tmp1.add(0, "(");
tmp1.add(0, "(");
tmp1.add(0, t.image.toUpperCase());
tmp1.add(")");
tmp1.addAll(tmp2);
{if (true) return tmp1;}
{if ("" != null) return tmp1;}
break;
case NO:
}
case NO:{
jj_consume_token(NO);
jj_consume_token(SPACE);
tmp1 = Option();
tmp1.add(0, "NO");
{if (true) return tmp1;}
tmp1.add(0, "NO");
{if ("" != null) return tmp1;}
break;
}
default:
jj_la1[10] = jj_gen;
jj_consume_token(-1);
......@@ -291,7 +308,15 @@ public class Script implements ScriptConstants {
/** Reinitialise. */
public void ReInit(java.io.Reader stream) {
jj_input_stream.ReInit(stream, 1, 1);
if (jj_input_stream == null) {
jj_input_stream = new SimpleCharStream(stream, 1, 1);
} else {
jj_input_stream.ReInit(stream, 1, 1);
}
if (token_source == null) {
token_source = new ScriptTokenManager(jj_input_stream);
}
token_source.ReInit(jj_input_stream);
token = new Token();
jj_ntk = -1;
......@@ -351,7 +376,7 @@ public class Script implements ScriptConstants {
return t;
}
private int jj_ntk() {
private int jj_ntk_f() {
if ((jj_nt=token.next) == null)
return (jj_ntk = (token.next=token_source.getNextToken()).kind);
else
......
/* Generated By:JavaCC: Do not edit this line. ScriptConstants.java */
package ingame_programming;
/**
* Token literal values and constants.
* Generated by org.javacc.parser.OtherFilesGen#start()
*/
public interface ScriptConstants {
/** End of File. */
int EOF = 0;
/** RegularExpression Id. */
int VB = 4;
/** RegularExpression Id. */
int CTR = 5;
/** RegularExpression Id. */
int CLASS = 6;
/** RegularExpression Id. */
int STAT = 7;
/** RegularExpression Id. */
int HP = 8;
/** RegularExpression Id. */
int CMP = 9;
/** RegularExpression Id. */
int AVEC = 10;
/** RegularExpression Id. */
int POSSEDANT = 11;
/** RegularExpression Id. */
int NOMME = 12;
/** RegularExpression Id. */
int LOGIC = 13;
/** RegularExpression Id. */
int NO = 14;
/** RegularExpression Id. */
int VAL = 15;
/** RegularExpression Id. */
int VALPRCT = 16;
/** RegularExpression Id. */
int ITEM = 17;
/** RegularExpression Id. */
int NAME = 18;
/** RegularExpression Id. */
int SPACE = 19;
/** Lexical state. */
int DEFAULT = 0;
/** Literal token values. */
String[] tokenImage = {
"<EOF>",
"\"\\n\"",
"\"\\r\"",
"\"\\t\"",
"<VB>",
"<CTR>",
"<CLASS>",
"<STAT>",
"\"PV\"",
"<CMP>",
"\"avec\"",
"<POSSEDANT>",
"<NOMME>",
"<LOGIC>",
"<NO>",
"<VAL>",
"<VALPRCT>",
"<ITEM>",
"<NAME>",
"<SPACE>",
"\"(\"",
"\")\"",
};
}
/* ScriptTokenManager.java */
/* Generated By:JavaCC: Do not edit this line. ScriptTokenManager.java */
package ingame_programming;
import java.util.ArrayList;
/** Token Manager. */
public class ScriptTokenManager implements ScriptConstants
{
@SuppressWarnings("unused")public class ScriptTokenManager implements ScriptConstants {
/** Debug output. */
public java.io.PrintStream debugStream = System.out;
/** Set debug output. */
public void setDebugStream(java.io.PrintStream ds) { debugStream = ds; }
private final int jjStopStringLiteralDfa_0(int pos, long active0)
{
private final int jjStopStringLiteralDfa_0(int pos, long active0){
switch (pos)
{
case 0:
......@@ -42,8 +41,7 @@ private final int jjStopStringLiteralDfa_0(int pos, long active0)
return -1;
}
}
private final int jjStartNfa_0(int pos, long active0)
{
private final int jjStartNfa_0(int pos, long active0){
return jjMoveNfa_0(jjStopStringLiteralDfa_0(pos, active0), pos + 1);
}
private int jjStopAtPos(int pos, int kind)
......@@ -52,8 +50,7 @@ private int jjStopAtPos(int pos, int kind)
jjmatchedPos = pos;
return pos + 1;
}
private int jjMoveStringLiteralDfa0_0()
{
private int jjMoveStringLiteralDfa0_0(){
switch(curChar)
{
case 40:
......@@ -68,8 +65,7 @@ private int jjMoveStringLiteralDfa0_0()
return jjMoveNfa_0(6, 0);
}
}
private int jjMoveStringLiteralDfa1_0(long active0)
{
private int jjMoveStringLiteralDfa1_0(long active0){
try { curChar = input_stream.readChar(); }
catch(java.io.IOException e) {
jjStopStringLiteralDfa_0(0, active0);
......@@ -88,8 +84,7 @@ private int jjMoveStringLiteralDfa1_0(long active0)
}
return jjStartNfa_0(0, active0);
}
private int jjMoveStringLiteralDfa2_0(long old0, long active0)
{
private int jjMoveStringLiteralDfa2_0(long old0, long active0){
if (((active0 &= old0)) == 0L)
return jjStartNfa_0(0, old0);
try { curChar = input_stream.readChar(); }
......@@ -106,8 +101,7 @@ private int jjMoveStringLiteralDfa2_0(long old0, long active0)
}
return jjStartNfa_0(1, active0);
}