Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
groupe-6
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
2024-projet-agile-de-rentree
groupe-6
Commits
ac934cef
Commit
ac934cef
authored
11 months ago
by
Gabriel Mille
Browse files
Options
Downloads
Patches
Plain Diff
correction input / main
parent
c13b6c91
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/java/bitFight/Input.java
+9
-2
9 additions, 2 deletions
src/main/java/bitFight/Input.java
src/main/java/bitFight/Main.java
+31
-27
31 additions, 27 deletions
src/main/java/bitFight/Main.java
with
40 additions
and
29 deletions
src/main/java/bitFight/Input.java
+
9
−
2
View file @
ac934cef
...
@@ -27,10 +27,17 @@ public class Input {
...
@@ -27,10 +27,17 @@ public class Input {
}
}
public
void
newInput
(
String
input
)
{
public
void
newInput
()
{
BufferedReader
in
=
new
BufferedReader
(
new
InputStreamReader
(
System
.
in
));
do
{
do
{
try
{
try
{
setInput
(
input
);
try
{
setInput
(
in
.
readLine
());
}
catch
(
IOException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
}
catch
(
InvalidInputException
e
)
{
}
catch
(
InvalidInputException
e
)
{
try
{
try
{
Display
.
newPrintln
(
e
.
getMessage
());
Display
.
newPrintln
(
e
.
getMessage
());
...
...
This diff is collapsed.
Click to expand it.
src/main/java/bitFight/Main.java
+
31
−
27
View file @
ac934cef
...
@@ -63,9 +63,11 @@ class Main {
...
@@ -63,9 +63,11 @@ class Main {
Input
input
=
new
Input
();
Input
input
=
new
Input
();
input
.
newInput
(
in
.
readLine
()
);
input
.
newInput
();
Display
.
goToDialogBox
();
Display
.
goToDialogBox
();
if
(
input
.
getInput
().
equals
(
"a"
))
{
while
(!
input
.
getInput
().
equals
(
"q"
)
&&
!
enemy
.
isDead
()
&&
!
player
.
isDead
())
{
while
(!
input
.
getInput
().
equals
(
"q"
)
&&
!
enemy
.
isDead
()
&&
!
player
.
isDead
())
{
//A garder au début de la boucle, mesure le temps que le joueur à pris d'écrire
//A garder au début de la boucle, mesure le temps que le joueur à pris d'écrire
...
@@ -76,7 +78,7 @@ class Main {
...
@@ -76,7 +78,7 @@ class Main {
level
.
ennemyShowing
();
level
.
ennemyShowing
();
level
.
possibleActions
();
level
.
possibleActions
();
input
.
newInput
(
in
.
readLine
()
);
input
.
newInput
();
// Boucle tant que le joueur n'a pas taper de nom d'une attaque valide ou tape trop tard ou tape q
// Boucle tant que le joueur n'a pas taper de nom d'une attaque valide ou tape trop tard ou tape q
while
((!
actionNames
.
contains
(
input
.
getInput
())
||
!
Attack
.
attackInTime
(
timeBeforeAttack
,
attackTime
))
&&
!
input
.
getInput
().
equals
(
"q"
))
{
while
((!
actionNames
.
contains
(
input
.
getInput
())
||
!
Attack
.
attackInTime
(
timeBeforeAttack
,
attackTime
))
&&
!
input
.
getInput
().
equals
(
"q"
))
{
...
@@ -86,13 +88,13 @@ class Main {
...
@@ -86,13 +88,13 @@ class Main {
Attack
randomEnemyAttack
=
Attack
.
values
()[(
int
)
rand
.
nextDouble
()*
Attack
.
values
().
length
];
Attack
randomEnemyAttack
=
Attack
.
values
()[(
int
)
rand
.
nextDouble
()*
Attack
.
values
().
length
];
level
.
ennemyFaster
(
randomEnemyAttack
);
level
.
ennemyFaster
(
randomEnemyAttack
);
timeBeforeAttack
=
LocalDateTime
.
now
();
timeBeforeAttack
=
LocalDateTime
.
now
();
input
.
newInput
(
in
.
readLine
()
);
input
.
newInput
();
}
}
if
(!
actionNames
.
contains
(
input
.
getInput
())){
if
(!
actionNames
.
contains
(
input
.
getInput
())){
Display
.
clearDialogBox
();
Display
.
clearDialogBox
();
level
.
invalidActionChoice
();
level
.
invalidActionChoice
();
input
.
newInput
(
in
.
readLine
()
);
input
.
newInput
();
System
.
out
.
println
(
actionNames
.
toString
());
System
.
out
.
println
(
actionNames
.
toString
());
System
.
out
.
println
(
input
.
getInput
());
System
.
out
.
println
(
input
.
getInput
());
}
}
...
@@ -128,7 +130,9 @@ class Main {
...
@@ -128,7 +130,9 @@ class Main {
}
}
}
in
.
close
();
in
.
close
();
Save
.
saveObject
(
"res/gamedata"
,
gamedata
);
Save
.
saveObject
(
"res/gamedata"
,
gamedata
);
}
}
}
}
\ No newline at end of file
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