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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
2024-projet-agile-de-rentree
groupe-6
Commits
c2b1330e
Commit
c2b1330e
authored
8 months ago
by
Gabriel Mille
Browse files
Options
Downloads
Patches
Plain Diff
correction input
parent
4190a0d7
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/bitFight/Input.java
+5
-10
5 additions, 10 deletions
src/main/java/bitFight/Input.java
src/main/java/bitFight/Main.java
+7
-18
7 additions, 18 deletions
src/main/java/bitFight/Main.java
with
12 additions
and
28 deletions
src/main/java/bitFight/Input.java
+
5
−
10
View file @
c2b1330e
...
@@ -5,10 +5,13 @@ import java.io.BufferedReader;
...
@@ -5,10 +5,13 @@ import java.io.BufferedReader;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
import
java.io.InputStreamReader
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Scanner
;
public
class
Input
{
public
class
Input
{
private
String
input
=
""
;
private
String
input
=
""
;
private
ArrayList
<
String
>
inputRange
;
private
ArrayList
<
String
>
inputRange
;
private
static
BufferedReader
in
=
new
BufferedReader
(
new
InputStreamReader
(
System
.
in
));
public
String
getInput
()
{
public
String
getInput
()
{
return
input
;
return
input
;
...
@@ -27,23 +30,15 @@ public class Input {
...
@@ -27,23 +30,15 @@ public class Input {
}
}
public
void
newInput
()
throws
IOException
{
public
void
newInput
(
Scanner
in
)
throws
IOException
{
do
{
do
{
BufferedReader
in
=
new
BufferedReader
(
new
InputStreamReader
(
System
.
in
));
try
{
try
{
try
{
setInput
(
in
.
nextLine
());
setInput
(
in
.
readLine
());
}
catch
(
IOException
e
)
{
// TODO Auto-generated catch block
System
.
err
.
println
(
e
.
getMessage
()
+
": Contact support"
);
}
}
catch
(
InvalidInputException
e
)
{
}
catch
(
InvalidInputException
e
)
{
Display
.
newPrintln
(
e
.
getMessage
());
Display
.
newPrintln
(
e
.
getMessage
());
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
System
.
err
.
println
(
e
.
getMessage
()+
": Contact support"
);
System
.
err
.
println
(
e
.
getMessage
()+
": Contact support"
);
}
finally
{
// in.close();
}
}
}
}
while
(!
validInput
());
while
(!
validInput
());
...
...
This diff is collapsed.
Click to expand it.
src/main/java/bitFight/Main.java
+
7
−
18
View file @
c2b1330e
...
@@ -7,6 +7,7 @@ import java.io.InputStreamReader;
...
@@ -7,6 +7,7 @@ import java.io.InputStreamReader;
import
java.time.LocalDateTime
;
import
java.time.LocalDateTime
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Random
;
import
java.util.Random
;
import
java.util.Scanner
;
class
Main
{
class
Main
{
...
@@ -27,15 +28,7 @@ class Main {
...
@@ -27,15 +28,7 @@ class Main {
level
=
gamedata
.
getLevelReached
();
level
=
gamedata
.
getLevelReached
();
}
}
try
{
menu
.
display
();
menu
.
display
();
}
catch
(
IOException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
catch
(
InterruptedException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
menu
.
validate
();
menu
.
validate
();
Display
.
clearScreen
();
Display
.
clearScreen
();
...
@@ -62,7 +55,7 @@ class Main {
...
@@ -62,7 +55,7 @@ class Main {
ArrayList
<
String
>
actionNames
=
new
ArrayList
<>();
ArrayList
<
String
>
actionNames
=
new
ArrayList
<>();
for
(
Action
a
:
actionList
)
actionNames
.
add
(
a
.
getName
());
for
(
Action
a
:
actionList
)
actionNames
.
add
(
a
.
getName
());
BufferedReader
in
=
new
BufferedReader
(
new
InputStreamRead
er
(
System
.
in
)
)
;
Scanner
in
=
new
Scann
er
(
System
.
in
);
Random
rand
=
new
Random
();
Random
rand
=
new
Random
();
...
@@ -70,7 +63,7 @@ class Main {
...
@@ -70,7 +63,7 @@ class Main {
level
.
ennemyShowing
();
level
.
ennemyShowing
();
Input
input
=
new
Input
();
Input
input
=
new
Input
();
input
.
newInput
();
input
.
newInput
(
in
);
Display
.
goToDialogBox
();
Display
.
goToDialogBox
();
...
@@ -82,9 +75,8 @@ class Main {
...
@@ -82,9 +75,8 @@ class Main {
LocalDateTime
timeBeforeAttack
=
LocalDateTime
.
now
();
LocalDateTime
timeBeforeAttack
=
LocalDateTime
.
now
();
int
attackTime
=
5
-
(
int
)(
5
*
rand
.
nextDouble
());
int
attackTime
=
5
-
(
int
)(
5
*
rand
.
nextDouble
());
if
(
input
.
getInput
().
equals
(
"a"
))
{
level
.
possibleActions
();
level
.
possibleActions
();
input
.
newInput
();
input
.
newInput
(
in
);
// 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"
))
{
...
@@ -96,13 +88,13 @@ class Main {
...
@@ -96,13 +88,13 @@ class Main {
level
.
ennemyFaster
(
randomEnemyAttack
);
level
.
ennemyFaster
(
randomEnemyAttack
);
Display
.
displayNewHealthBar
();
Display
.
displayNewHealthBar
();
timeBeforeAttack
=
LocalDateTime
.
now
();
timeBeforeAttack
=
LocalDateTime
.
now
();
input
.
newInput
();
input
.
newInput
(
in
);
}
}
if
(!
actionNames
.
contains
(
input
.
getInput
())){
if
(!
actionNames
.
contains
(
input
.
getInput
())){
Display
.
clearDialogBox
();
Display
.
clearDialogBox
();
level
.
invalidActionChoice
();
level
.
invalidActionChoice
();
input
.
newInput
();
input
.
newInput
(
in
);
}
}
}
}
...
@@ -129,8 +121,6 @@ class Main {
...
@@ -129,8 +121,6 @@ class Main {
//Display.clearDialogBox();
//Display.clearDialogBox();
input
.
newInput
();
if
(
enemy
.
isDead
()){
if
(
enemy
.
isDead
()){
level
.
ennemyDying
();
level
.
ennemyDying
();
player
.
revive
();
player
.
revive
();
...
@@ -155,6 +145,5 @@ class Main {
...
@@ -155,6 +145,5 @@ 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