Skip to content
Snippets Groups Projects
Commit 8585e5bd authored by CARION Baptiste's avatar CARION Baptiste
Browse files

Ajout village

parent 414fc8d7
No related branches found
No related tags found
No related merge requests found
......@@ -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>
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
......@@ -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 "? ";}
}
}
......@@ -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;
......
......@@ -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();
}
}
}
......@@ -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);
......
......@@ -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);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment