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
f389659f
Commit
f389659f
authored
4 years ago
by
Maxime Wallart
Browse files
Options
Downloads
Patches
Plain Diff
update move
parent
a35b27cd
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/main/Main.java
+6
-2
6 additions, 2 deletions
src/main/Main.java
src/units/Paysant.java
+4
-4
4 additions, 4 deletions
src/units/Paysant.java
src/units/Unite.java
+15
-10
15 additions, 10 deletions
src/units/Unite.java
with
25 additions
and
16 deletions
src/main/Main.java
+
6
−
2
View file @
f389659f
...
@@ -16,9 +16,13 @@ public class Main {
...
@@ -16,9 +16,13 @@ public class Main {
}*/
}*/
Plateau
plateau
=
new
Plateau
();
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
);
plateau
.
getCase
(
x
,
y
).
getUnite
().
move
(
Direction
.
HAUT
);
System
.
out
.
println
(
'\n'
);
Affichage
.
affichage
(
plateau
);
Affichage
.
affichage
(
plateau
);
}
}
private
Joueur
Game
(
Joueur
[]
joueurs
)
{
private
Joueur
Game
(
Joueur
[]
joueurs
)
{
...
...
This diff is collapsed.
Click to expand it.
src/units/Paysant.java
+
4
−
4
View file @
f389659f
...
@@ -13,8 +13,8 @@ public class Paysant extends Unite{
...
@@ -13,8 +13,8 @@ public class Paysant extends Unite{
public
static
final
char
SYMBOL
=
'p'
;
public
static
final
char
SYMBOL
=
'p'
;
public
static
final
int
PATOGIVE
=
1
;
public
static
final
int
PATOGIVE
=
1
;
public
Paysant
(
Case
caseUnit
,
Plateau
plateau
,
Joueur
joueur
)
{
public
Paysant
(
int
x
,
int
y
,
Plateau
plateau
,
Joueur
joueur
)
{
super
(
caseUnit
,
plateau
,
SYMBOL
,
ARMOR
,
DAMAGE
,
joueur
);
super
(
x
,
y
,
plateau
,
SYMBOL
,
ARMOR
,
DAMAGE
,
joueur
);
}
}
...
@@ -49,7 +49,7 @@ public class Paysant extends Unite{
...
@@ -49,7 +49,7 @@ public class Paysant extends Unite{
sc
.
close
();
sc
.
close
();
return
true
;
return
true
;
}
else
{
}
else
{
//TODO:utiliser un systme de vrification d'entre globale
//TODO:utiliser un syst
�
me de v
�
rification d'entr
�
e globale
System
.
out
.
println
(
"ERROR"
);
System
.
out
.
println
(
"ERROR"
);
}
}
...
@@ -59,7 +59,7 @@ public class Paysant extends Unite{
...
@@ -59,7 +59,7 @@ public class Paysant extends Unite{
}
}
public
void
combattre
()
{
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 pr
�
sente autour
}
}
public
void
actionGivePA
()
{
public
void
actionGivePA
()
{
...
...
This diff is collapsed.
Click to expand it.
src/units/Unite.java
+
15
−
10
View file @
f389659f
...
@@ -20,15 +20,15 @@ public abstract class Unite {
...
@@ -20,15 +20,15 @@ public abstract class Unite {
private
Joueur
joueur
;
private
Joueur
joueur
;
private
Items
item
;
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
;
this
.
id
=
generalId
;
generalId
++;
generalId
++;
this
.
plateau
=
plateau
;
this
.
plateau
=
plateau
;
this
.
symbol
=
symbol
;
this
.
symbol
=
symbol
;
this
.
armor
=
armor
;
this
.
armor
=
armor
;
this
.
damage
=
damage
;
this
.
damage
=
damage
;
this
.
x
=
14
;
this
.
x
=
x
;
this
.
y
=
28
;
this
.
y
=
y
;
this
.
joueur
=
joueur
;
this
.
joueur
=
joueur
;
this
.
item
=
null
;
this
.
item
=
null
;
}
}
...
@@ -110,7 +110,7 @@ public abstract class Unite {
...
@@ -110,7 +110,7 @@ public abstract class Unite {
}
}
public
boolean
updatePosition
(
int
x
,
int
y
)
{
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
).
setUnite
(
this
);
this
.
plateau
.
getCase
(
x
,
y
).
setType
(
Type
.
UNITE
);
this
.
plateau
.
getCase
(
x
,
y
).
setType
(
Type
.
UNITE
);
if
(
this
.
plateau
.
getCase
(
x
,
y
).
isDecouverte
()==
false
)
{
if
(
this
.
plateau
.
getCase
(
x
,
y
).
isDecouverte
()==
false
)
{
...
@@ -118,34 +118,39 @@ public abstract class Unite {
...
@@ -118,34 +118,39 @@ public abstract class Unite {
}
}
if
(
this
.
plateau
.
getCase
(
x
,
y
).
getEvent
()
==
Event
.
FORT
)
{
if
(
this
.
plateau
.
getCase
(
x
,
y
).
getEvent
()
==
Event
.
FORT
)
{
this
.
plateau
.
getRegion
(
x
,
y
).
setProprietaire
(
joueur
);
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
true
;
}
}
return
false
;
return
false
;
}
}
//à voir le type
//à voir le type
public
void
move
(
Direction
d
)
{
public
boolean
move
(
Direction
d
)
{
if
(
d
==
Direction
.
BAS
)
{
if
(
d
==
Direction
.
BAS
)
{
if
(
updatePosition
(
x
,
y
+
1
))
{
if
(
updatePosition
(
x
+
1
,
y
))
{
this
.
plateau
.
getCase
(
x
,
y
).
setUnite
(
null
);
this
.
plateau
.
getCase
(
x
,
y
).
setUnite
(
null
);
return
true
;
}
}
}
}
else
if
(
d
==
Direction
.
DROITE
)
{
else
if
(
d
==
Direction
.
DROITE
)
{
if
(
updatePosition
(
x
+
1
,
y
))
{
if
(
updatePosition
(
x
,
y
+
1
))
{
this
.
plateau
.
getCase
(
x
,
y
).
setUnite
(
null
);
this
.
plateau
.
getCase
(
x
,
y
).
setUnite
(
null
);
return
true
;
}
}
}
}
else
if
(
d
==
Direction
.
GAUCHE
)
{
else
if
(
d
==
Direction
.
GAUCHE
)
{
if
(
updatePosition
(
x
-
1
,
y
))
{
if
(
updatePosition
(
x
,
y
-
1
))
{
this
.
plateau
.
getCase
(
x
,
y
).
setUnite
(
null
);
this
.
plateau
.
getCase
(
x
,
y
).
setUnite
(
null
);
return
true
;
}
}
}
}
else
if
(
d
==
Direction
.
HAUT
)
{
else
if
(
d
==
Direction
.
HAUT
)
{
if
(
updatePosition
(
x
,
y
-
1
))
{
if
(
updatePosition
(
x
-
1
,
y
))
{
this
.
plateau
.
getCase
(
x
,
y
).
setUnite
(
null
);
this
.
plateau
.
getCase
(
x
,
y
).
setUnite
(
null
);
return
true
;
}
}
}
}
return
false
;
}
}
public
abstract
String
toString
();
public
abstract
String
toString
();
...
...
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