Skip to content
Snippets Groups Projects
Commit 49e833b4 authored by Francois .D's avatar Francois .D
Browse files

merge Francois

parents 9cc9bfed c979be3b
No related branches found
No related tags found
No related merge requests found
......@@ -2,16 +2,24 @@ package main;
public class Affichage {
public static void affichage(Plateau plateau){
final char plaine = '~';
final char plaine = '.';
final char montagne = '◼';
final char inconnu = '~';
for(int i=0; i< plateau.getPlateau().length*5; i++) {
for(int j=0; j< plateau.getPlateau()[0].length*5; j++) {
if(plateau.getCase(i, j).getType()==Type.FORT) {
System.out.print("W");
System.out.print("F");
}else if(plateau.getCase(i, j).getUnite() != null) {
System.out.print(plateau.getCase(i, j).getUnite().getSymbol());
}else {
if (plateau.getCase(i, j).getType()==Type.GRASS) {
System.out.print(plaine);
}
else if (plateau.getCase(i, j).getType()==Type.MOUNTAIN) {
System.out.print(montagne);
}
}
}
System.out.println();
}
......
package main;
import units.Unite;
public class Deplacement {
public void deplacement (Unite unit ,Direction direction, Plateau plateau) {
if (direction.equals(Direction.BAS)){
}
}
}
......@@ -8,6 +8,7 @@ public class Main {
public static void main(String[] args) {
/*Region[][] regions = new Region[6][6];
for(int i = 0; i<regions.length; i++) {
for(int j = 0; j<regions[i].length; j++) {
......@@ -16,22 +17,43 @@ public class Main {
}*/
Plateau plateau = new Plateau();
plateau.getCase(12, 7).setUnite(new Paysant(plateau.getCase(12, 7), plateau, winner));
int x = 11;
int y = 0;
plateau.getCase(x, y).setUnite(new Paysant(x, y, plateau, winner));
Affichage.affichage(plateau);
<<<<<<< HEAD
Scan.scan(3);
=======
plateau.getCase(x, y).getUnite().move(Direction.HAUT);
System.out.println('\n');
Affichage.affichage(plateau);
<<<<<<< HEAD
=======
Menu();
}
public static void Menu () {
System.out.print("Bienvenu dans Game of Crown, vous êtes actuellement sur le Menu !");
>>>>>>> 6e6d8e1d075a8855972540815248afce1757f9e0
>>>>>>> c979be3b4c31bb3686f26c7d0c7a781558004709
}
private Joueur Game (Joueur[] joueurs) {
public Joueur Game (Joueur[] joueurs) {
boolean gameEnd = false;
while(gameEnd){
for (Joueur currentPlayer : joueurs) {
setActionPoint(currentPlayer);
Tour(currentPlayer, actionPoint);
}
}
return getWinner();
}
public void Tour (Joueur currentPlayer, int actionPoint) {
}
public void setActionPoint (int actionPoint) {
this.actionPoint = actionPoint;
}
......
package main;
import java.util.Random;
public class Region {
public Case[][] region = new Case[5][5];
private Joueur proprietaire = null;
public Region() {
Random random = new Random();
for (int i = 0; i < region.length; i++) {
for (int j = 0; j < region[0].length; j++) {
if (random.nextInt(8) == 1) {
region[i][j] = new Case(Type.MOUNTAIN);
}
else {
region[i][j] = new Case(Type.GRASS);
}
}
int rd1 = (int)Math.random()*6;
int rd2 = (int)Math.random()*6;
}
int rd1 = (int)random.nextInt(5);
int rd2 = (int)random.nextInt(5);
region[rd1][rd2].setEvent(Event.FORT);
region[rd1][rd2].setType(Type.FORT);
}
......
package main;
public enum Type {
UNITE,GRASS,FORT;
UNITE,GRASS, MOUNTAIN, VILLAGE, FORT;
}
package units;
import main.Case;
import main.Joueur;
import main.Plateau;
public class Archer extends Unite{
public static final int ARMOR = 5;
public static final int DAMAGE = 5;
public static final char SYMBOL = 'A';
public Archer(Case caseUnit, Plateau plateau, Joueur joueur) {
super(caseUnit, plateau, SYMBOL, ARMOR, DAMAGE, joueur);
}
@Override
public String toString() {
return "Archer " + this.getId();
}
@Override
public boolean action() {
// TODO Auto-generated method stub
return false;
}
}
package units;
import main.Case;
import main.Joueur;
import main.Plateau;
public class Chevalier extends Unite {
public static final int ARMOR = 10;
public static final int DAMAGE = 5;
public static final char SYMBOL = 'C';
public Chevalier(Case caseUnit, Plateau plateau, Joueur joueur) {
super(caseUnit, plateau, SYMBOL, ARMOR, DAMAGE, joueur);
}
@Override
public String toString() {
return "Chevalier " + this.getId();
}
@Override
public boolean action() {
// TODO Auto-generated method stub
return false;
}
}
package units;
import main.Case;
import main.Joueur;
import main.Plateau;
public class Eclaireur extends Unite {
public static final int ARMOR = 1;
public static final int DAMAGE = 0;
public static final char SYMBOL = 'E';
public Eclaireur(Case caseUnit, Plateau plateau, Joueur joueur) {
super(caseUnit, plateau, SYMBOL, ARMOR, DAMAGE, joueur);
}
@Override
public String toString() {
return "Eclaireur " + this.getId();
}
@Override
public boolean action() {
// TODO Auto-generated method stub
return false;
}
}
......@@ -13,8 +13,8 @@ public class Paysant extends Unite{
public static final char SYMBOL = 'p';
public static final int PATOGIVE = 1;
public Paysant(Case caseUnit, Plateau plateau, Joueur joueur) {
super(caseUnit, plateau, SYMBOL, ARMOR, DAMAGE, joueur);
public Paysant(int x, int y, Plateau plateau, Joueur joueur) {
super(x, y, plateau, SYMBOL, ARMOR, DAMAGE, joueur);
}
......@@ -49,7 +49,7 @@ public class Paysant extends Unite{
sc.close();
return true;
}else {
//TODO:utiliser un systme de vrification d'entre globale
//TODO:utiliser un systme de vrification d'entre globale
System.out.println("ERROR");
}
......@@ -59,7 +59,7 @@ public class Paysant extends Unite{
}
public void combattre() {
//TODO: il faut d'abord regarder si une unit est prsente autour
//TODO: il faut d'abord regarder si une unit est prsente autour
}
public void actionGivePA() {
......
......@@ -20,15 +20,15 @@ public abstract class Unite {
private Joueur joueur;
private Items item;
public Unite(Case caseUnit, Plateau plateau, char symbol, int armor, int damage, Joueur joueur) {
public Unite(int x, int y, Plateau plateau, char symbol, int armor, int damage, Joueur joueur) {
this.id = generalId;
generalId++;
this.plateau = plateau;
this.symbol = symbol;
this.armor = armor;
this.damage = damage;
this.x = 14;
this.y = 28;
this.x = x;
this.y = y;
this.joueur = joueur;
this.item = null;
}
......@@ -110,7 +110,7 @@ public abstract class Unite {
}
public boolean updatePosition(int x,int y) {
if(this.plateau.getCase(x, y)!=null) {
if(x>=0 && x<plateau.getPlateau().length*plateau.getRegion(0, 0).region.length && y>=0 && y<plateau.getPlateau().length*plateau.getRegion(0, 0).region.length ) {
this.plateau.getCase(x, y).setUnite(this);
this.plateau.getCase(x, y).setType(Type.UNITE);
if(this.plateau.getCase(x, y).isDecouverte()==false) {
......@@ -118,34 +118,39 @@ public abstract class Unite {
}
if(this.plateau.getCase(x, y).getEvent() == Event.FORT) {
this.plateau.getRegion(x, y).setProprietaire(joueur);
this.joueur.getRoyaume().add(this.plateau.getRegion(x, y));
//this.joueur.getRoyaume().add(this.plateau.getRegion(x, y));
}
return true;
}
return false;
}
//à voir le type
public void move(Direction d) {
public boolean move(Direction d) {
if(d == Direction.BAS) {
if (updatePosition(x,y+1)) {
if (updatePosition(x+1,y)) {
this.plateau.getCase(x, y).setUnite(null);
return true;
}
}
else if(d == Direction.DROITE) {
if (updatePosition(x+1,y)) {
if (updatePosition(x,y+1)) {
this.plateau.getCase(x, y).setUnite(null);
return true;
}
}
else if(d == Direction.GAUCHE) {
if (updatePosition(x-1,y)) {
if (updatePosition(x,y-1)) {
this.plateau.getCase(x, y).setUnite(null);
return true;
}
}
else if(d == Direction.HAUT) {
if (updatePosition(x, y-1)) {
if (updatePosition(x-1, y)) {
this.plateau.getCase(x, y).setUnite(null);
return true;
}
}
return false;
}
public abstract String toString();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment