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
b56aebbe
Commit
b56aebbe
authored
10 months ago
by
Camille Okubo
Browse files
Options
Downloads
Patches
Plain Diff
AttackTest, microfix Attack & Character
parent
1f064988
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/java/bitFight/Attack.java
+0
-5
0 additions, 5 deletions
src/main/java/bitFight/Attack.java
src/main/java/bitFight/Character.java
+8
-0
8 additions, 0 deletions
src/main/java/bitFight/Character.java
src/test/java/bitFight/AttackTest.java
+4
-3
4 additions, 3 deletions
src/test/java/bitFight/AttackTest.java
with
12 additions
and
8 deletions
src/main/java/bitFight/Attack.java
+
0
−
5
View file @
b56aebbe
...
@@ -14,7 +14,6 @@ public enum Attack implements Action {
...
@@ -14,7 +14,6 @@ public enum Attack implements Action {
private
String
name
;
private
String
name
;
private
ActionHeight
height
;
private
ActionHeight
height
;
private
int
energyCost
;
private
int
energyCost
;
public
static
ArrayList
<
String
>
attacksNames
=
new
ArrayList
<
String
>();
Attack
(
int
damage
,
String
name
,
ActionHeight
height
,
int
energyCost
)
{
Attack
(
int
damage
,
String
name
,
ActionHeight
height
,
int
energyCost
)
{
this
.
damage
=
damage
;
this
.
damage
=
damage
;
...
@@ -44,8 +43,4 @@ public enum Attack implements Action {
...
@@ -44,8 +43,4 @@ public enum Attack implements Action {
public
static
boolean
attackInTime
(
LocalDateTime
timeBeforeAttack
,
int
attackTime
)
{
public
static
boolean
attackInTime
(
LocalDateTime
timeBeforeAttack
,
int
attackTime
)
{
return
(
Duration
.
between
(
timeBeforeAttack
,
LocalDateTime
.
now
()).
toSeconds
()
>
attackTime
);
return
(
Duration
.
between
(
timeBeforeAttack
,
LocalDateTime
.
now
()).
toSeconds
()
>
attackTime
);
}
}
public
static
String
getIndexOfInput
(
String
input
)
{
return
Attack
.
attacksNames
.
get
(
attacksNames
.
indexOf
(
input
)).
toUpperCase
();
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/main/java/bitFight/Character.java
+
8
−
0
View file @
b56aebbe
...
@@ -73,6 +73,14 @@ public class Character implements Serializable {
...
@@ -73,6 +73,14 @@ public class Character implements Serializable {
attackMultiplier
=
attackMultiplier
*
1.2
;
attackMultiplier
=
attackMultiplier
*
1.2
;
}
}
public
double
getMaxEnergy
()
{
return
maxEnergy
;
}
public
double
getCurrentEnergy
()
{
return
currentEnergy
;
}
public
void
damage
(
double
damage
){
public
void
damage
(
double
damage
){
this
.
currentHealth
-=
damage
;
this
.
currentHealth
-=
damage
;
if
(
this
.
currentHealth
<
0
)
this
.
currentHealth
=
0
;
if
(
this
.
currentHealth
<
0
)
this
.
currentHealth
=
0
;
...
...
This diff is collapsed.
Click to expand it.
src/test/java/bitFight/AttackTest.java
+
4
−
3
View file @
b56aebbe
...
@@ -7,7 +7,7 @@ import org.junit.jupiter.api.Test;
...
@@ -7,7 +7,7 @@ import org.junit.jupiter.api.Test;
public
class
AttackTest
{
public
class
AttackTest
{
Player
player
=
new
Player
(
"joueur1"
);
Player
player
=
new
Player
(
"joueur1"
);
Enemy
ennemy
=
new
Enemy
(
"ennemy"
,
3
);
Enemy
ennemy
=
new
Enemy
(
"ennemy"
,
1
);
@Test
@Test
void
testGetDamage
()
{
void
testGetDamage
()
{
...
@@ -19,10 +19,11 @@ public class AttackTest {
...
@@ -19,10 +19,11 @@ public class AttackTest {
ennemy
.
setCurrentHealth
(
100.0
);
ennemy
.
setCurrentHealth
(
100.0
);
assertEquals
(
"Joueur : "
+
(
int
)
player
.
getCurrentHealth
(),
"Joueur : 100"
);
assertEquals
(
"Joueur : "
+
(
int
)
player
.
getCurrentHealth
(),
"Joueur : 100"
);
assertEquals
(
"Ennemi : "
+
(
int
)
ennemy
.
getCurrentHealth
(),
"Ennemi : 100"
);
assertEquals
(
"Ennemi : "
+
(
int
)
ennemy
.
getCurrentHealth
(),
"Ennemi : 100"
);
String
attack
=
Attack
.
getIndexOfInput
(
"kick"
);
ennemy
.
damage
(
Attack
.
PUNCH
.
getDamage
()
);
ennemy
.
damage
(
Attack
.
valueOf
(
attack
).
getDamage
());
player
.
exhaust
(
Attack
.
PUNCH
.
getEnergyCost
());
assertEquals
(
"Joueur : "
+
(
int
)
player
.
getCurrentHealth
(),
"Joueur : 100"
);
assertEquals
(
"Joueur : "
+
(
int
)
player
.
getCurrentHealth
(),
"Joueur : 100"
);
assertEquals
(
"Ennemi : "
+
(
int
)
ennemy
.
getCurrentHealth
(),
"Ennemi : 90"
);
assertEquals
(
"Ennemi : "
+
(
int
)
ennemy
.
getCurrentHealth
(),
"Ennemi : 90"
);
assertEquals
(
"Energie joueur : "
+
(
int
)
player
.
getCurrentEnergy
(),
"Energie joueur : 90"
);
}
}
}
}
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