diff --git a/.classpath b/.classpath index e0e6526e3ded89337a532dec843a201cb3b592bc..4697753aa55735bd8df62ca3b9580f4b96c48707 100644 --- a/.classpath +++ b/.classpath @@ -3,6 +3,11 @@ <classpathentry kind="src" path="src"/> <classpathentry kind="src" path="test"/> <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"> + <attributes> + <attribute name="module" value="true"/> + </attributes> + </classpathentry> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="output" path="bin"/> </classpath> diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index 272e3b91d2da5619281ba19d380758998935673d..c7f863b738c131ca608effecafdaa9a807dc585f 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -1,12 +1,12 @@ eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.compliance=1.7 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.release=disabled -org.eclipse.jdt.core.compiler.source=1.5 +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/src/main/Case.java b/src/main/Case.java index 8e206ff03f6034051ec185e6ac2f4a72440a13f2..d56ea12524de05117ffb7057014779833da67ddc 100644 --- a/src/main/Case.java +++ b/src/main/Case.java @@ -15,7 +15,8 @@ public class Case { private Unite unite; private int x; private int y; - private boolean aEteVu; + private boolean pille; + private int tempsDepuisPillage; public Case(Type type) { this.type = type; @@ -24,6 +25,26 @@ public class Case { this.events = new ArrayList<Evenements>(); this.x = 0; this.y = 0; + this.pille = false; + this.tempsDepuisPillage = 0; + } + public void setPillage() { + this.pille = true; + this.tempsDepuisPillage = 5; + } + public boolean getPille () { + return this.pille; + } + public void setPille (boolean pille) { + this.pille = pille; + } + public void decreaseTimePillage () { + if (this.tempsDepuisPillage == 0) { + setPille(false); + } + else { + this.tempsDepuisPillage--; + } } public void setX(int x) { this.x = x; @@ -90,6 +111,9 @@ public class Case { else if (this.type == Type.FORT) { return "♜ "; } + else if (this.type == Type.VILLAGE) { + return "V "; + } else { return "? ";} } } diff --git a/src/main/Region.java b/src/main/Region.java index 6eb76d39e4b0f656df2d9df2bcb69e55af9dba58..5fbffd444a1d88b48318e923ada633f45f2fd408 100644 --- a/src/main/Region.java +++ b/src/main/Region.java @@ -3,6 +3,7 @@ package main; import java.util.Random; import events.FortEvent; +import events.VillageEvent; public class Region { public Case[][] region = new Case[5][5]; @@ -31,6 +32,13 @@ public class Region { int rd2 = (int)random.nextInt(5); region[rd1][rd2].addEvents(new FortEvent()); region[rd1][rd2].setType(Type.FORT); + int k = (int)random.nextInt(2); + for (int l = 0; l < k; l++) { + rd1 = (int)random.nextInt(5); + rd2 = (int)random.nextInt(5); + region[rd1][rd2].addEvents(new VillageEvent()); + region[rd1][rd2].setType(Type.VILLAGE); + } } public void setX(int x) { this.x = x; diff --git a/src/main/Scan.java b/src/main/Scan.java index e11ff9d6c984a70bc32afca610c2423e443878d5..49c9b2d35d6557bbb55f354f51879663666d5d4b 100644 --- a/src/main/Scan.java +++ b/src/main/Scan.java @@ -19,5 +19,28 @@ public class Scan { sc.close(); return res; } + + public static String readString() { + String res = ""; + Scanner scanner = new Scanner(System.in); + res = scanner.nextLine(); + scanner.close(); + return res; + } + + public static String readString(String message) { + String res = ""; + Scanner scanner = new Scanner(System.in); + System.out.println(message); + res = scanner.nextLine(); + scanner.close(); + return res; + } + + public static void clearScreen() { + for( int i = 0 ; i < 100; i++) { + System.out.println(); + } + } } diff --git a/src/units/Paysant.java b/src/units/Paysant.java index f361b7e5fb16d3d4d09396d93d3af5b09304e6eb..82b305201a6e0099c31baa193785d15fe2b6dff3 100644 --- a/src/units/Paysant.java +++ b/src/units/Paysant.java @@ -11,7 +11,7 @@ public class Paysant extends Unite{ public static final int DAMAGE = 1; public static final char SYMBOL = 'p'; public static final int PATOGIVE = 1; - public static final int VISION = 4; + public static final int VISION = 1; public Paysant(int x, int y, Plateau plateau, Joueur joueur) { super(x, y, plateau, SYMBOL, ARMOR, DAMAGE, joueur, VISION); diff --git a/src/units/Unite.java b/src/units/Unite.java index 98b0f2ec74aa271c48c9d2c751e1c880f17fe65d..223a0b58b54ce8f0292731982214d2f8603e4abf 100644 --- a/src/units/Unite.java +++ b/src/units/Unite.java @@ -182,6 +182,7 @@ public abstract class Unite { this.plateau.getCase(x, y).setType(Type.GRASS); this.x=rd1; this.y=rd2; + updateDecouverte(this.plateau.getCase(rd1, rd2), this.vision); } public void updateDecouverte (Case emplacement, int vision) { if (vision > -1) { @@ -199,7 +200,7 @@ public abstract class Unite { } if (emplacement.getY() < 29) { this.plateau.getCase(emplacement.getX(), emplacement.getY() +1).setDecouverte(true); - if (this.plateau.getCase(emplacement.getX()+1, emplacement.getY()+1).getType() != Type.MOUNTAIN) { + if (this.plateau.getCase(emplacement.getX(), emplacement.getY()+1).getType() != Type.MOUNTAIN) { updateDecouverte(this.plateau.getCase(emplacement.getX(), emplacement.getY() +1), vision-1); } }