Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Groupe 16
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Paul Ripault
Groupe 16
Commits
2278fd89
Commit
2278fd89
authored
4 years ago
by
CARION Baptiste
Browse files
Options
Downloads
Patches
Plain Diff
Correction main et chevalier
parent
5b2c5ee3
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/Main.java
+15
-8
15 additions, 8 deletions
src/main/Main.java
src/units/Chevalier.java
+41
-1
41 additions, 1 deletion
src/units/Chevalier.java
with
56 additions
and
9 deletions
src/main/Main.java
+
15
−
8
View file @
2278fd89
...
...
@@ -2,10 +2,12 @@ package main;
import
java.util.Scanner
;
import
units.Chevalier
;
import
units.Paysant
;
public
class
Main
{
private
static
Joueur
winner
=
new
Joueur
(
"Winner"
);
private
static
Joueur
joueur1
=
new
Joueur
(
"joueur1"
);
private
static
Joueur
joueur2
=
new
Joueur
(
"joueur2"
);
private
int
actionPoint
;
static
Main
m
=
new
Main
();
...
...
@@ -20,12 +22,15 @@ public class Main {
Plateau
plateau
=
new
Plateau
();
int
x
=
11
;
int
y
=
10
;
int
x
=
5
;
int
y
=
5
;
plateau
.
getCase
(
x
,
y
).
setUnite
(
new
Paysant
(
x
,
y
,
plateau
,
winner
));
winner
.
getArmee
().
get
(
0
).
getPlateau
().
getRegion
(
0
,
0
).
changeToCamp
();
plateau
.
getCase
(
x
,
y
).
setUnite
(
new
Paysant
(
x
,
y
,
plateau
,
joueur1
));
plateau
.
getCase
(
x
+
2
,
y
+
2
).
setUnite
(
new
Paysant
(
x
+
2
,
y
+
2
,
plateau
,
joueur1
));
plateau
.
getCase
(
x
+
20
,
y
+
20
).
setUnite
(
new
Chevalier
(
x
+
20
,
y
+
20
,
plateau
,
joueur2
));
joueur1
.
getArmee
().
get
(
0
).
getPlateau
().
getRegion
(
0
,
0
).
changeToCamp
();
joueur2
.
getArmee
().
get
(
0
).
getPlateau
().
getRegion
(
0
,
0
).
changeToCamp
();
a
.
affichage
(
plateau
);
/*while(y<30) {
winner.getArmee().get(0).move(deplacement());*/
...
...
@@ -47,7 +52,7 @@ public class Main {
}
if
(
continuer
!=
3
)
{
continuer
=
2
;
m
.
game
(
new
Joueur
[]{
winner
,
null
},
plateau
);
m
.
game
(
new
Joueur
[]{
joueur1
,
joueur2
},
plateau
);
}
}
}
...
...
@@ -74,6 +79,7 @@ public class Main {
}
public
void
Tour
(
Joueur
currentPlayer
,
int
actionPoint
,
Plateau
plateau
)
{
System
.
out
.
println
(
"Debut du tour de : "
+
currentPlayer
.
getNomJoueur
());
for
(
int
i
=
0
;
i
<
actionPoint
;
i
++)
{
Interface
.
tourDeJeu
(
plateau
,
currentPlayer
);
}
...
...
@@ -84,6 +90,7 @@ public class Main {
}
public
void
setActionPoint
(
Joueur
currentPlayer
)
{
System
.
out
.
println
(
""
+
currentPlayer
.
getArmee
().
size
()
+
(
currentPlayer
.
getRoyaume
().
size
()
*
3
));
this
.
actionPoint
=
currentPlayer
.
getArmee
().
size
()
+
(
currentPlayer
.
getRoyaume
().
size
()
*
3
);
}
...
...
@@ -93,10 +100,10 @@ public class Main {
public
void
setWinner
(
Joueur
winner
)
{
this
.
winner
=
winner
;
this
.
joueur1
=
winner
;
}
public
Joueur
getWinner
()
{
return
this
.
winner
;
return
this
.
joueur1
;
}
}
This diff is collapsed.
Click to expand it.
src/units/Chevalier.java
+
41
−
1
View file @
2278fd89
package
units
;
import
java.util.Scanner
;
import
main.Joueur
;
import
main.Plateau
;
...
...
@@ -9,6 +11,7 @@ public class Chevalier extends Unite {
public
static
final
int
DAMAGE
=
5
;
public
static
final
char
SYMBOL
=
'C'
;
public
static
final
int
VISION
=
2
;
public
static
final
int
PATOGIVE
=
2
;
public
Chevalier
(
int
x
,
int
y
,
Plateau
plateau
,
Joueur
joueur
)
{
super
(
x
,
y
,
plateau
,
SYMBOL
,
ARMOR
,
DAMAGE
,
joueur
,
VISION
);
...
...
@@ -22,10 +25,47 @@ public class Chevalier extends Unite {
@Override
public
boolean
action
()
{
// TODO Auto-generated method stub
//TODO: le paysant doit regarder si il peut attaquer ou donne un PA pour le prochain tour
Scanner
sc
=
new
Scanner
(
System
.
in
);
StringBuilder
builder
=
new
StringBuilder
();
builder
.
append
(
"Voici les action disponnible pour le Paysant "
)
.
append
(
this
.
getId
()).
append
(
":\n"
);
/*
if (this.getUnitCase().haveUnitNear) {
builder.append("1. Combattre\n")
.append("2. Donner un Point d'Action\n");
}else{
builder.append("2. Donner un Point d'Action\n")
}
*/
System
.
out
.
println
(
builder
.
toString
());
int
res
=
sc
.
nextInt
();
if
(
res
==
1
)
{
combattre
();
}
else
if
(
res
==
2
){
actionGivePA
();
sc
.
close
();
return
true
;
}
else
{
//TODO:utiliser un système de vérification d'entrée globale
System
.
out
.
println
(
"ERROR"
);
}
sc
.
close
();
return
false
;
}
public
void
combattre
()
{
//TODO: il faut d'abord regarder si une unité est présente autour
}
public
void
actionGivePA
()
{
this
.
getJoueur
().
addPa
(
PATOGIVE
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment