Skip to content

Commit

Permalink
...
Browse files Browse the repository at this point in the history
  • Loading branch information
QuentinBeauchet committed Apr 17, 2021
1 parent a772b71 commit c5e9d57
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/main/java/Model/Entitys/Monsters/Snake.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


public class Snake extends AbstractMonster{
private static class Tail extends AbstractMonster{
private class Tail extends AbstractMonster{
protected Tail(Etage m, Position pos, String nom, int pv, int path_type, int lvl) {
super(m, pos, nom, pv, 0,0,0,60000, path_type, lvl);
}
Expand All @@ -20,6 +20,15 @@ public String toString() {
return Affichage.BRIGTH_BLUE+Affichage.BOLD+"O";
}

@Override
public boolean updatePV(int pv) {
boolean Alive = super.updatePV(pv);
if(!Alive){
snakeTail.remove(this);
}
return Alive;
}

@Override
public void move(Position pos) {
if(getEtage().get(pos).getEntity()==null){
Expand All @@ -28,7 +37,7 @@ public void move(Position pos) {
}
}

private final ArrayList<Tail> snakeTail = new ArrayList<>();
protected final ArrayList<Tail> snakeTail = new ArrayList<>();
private final int size_of_tail;
protected Snake(Etage m, Position pos, String nom, int pv, int force, double vision_radius, int agro, int update_rate_ms, int path_type, int lvl, int size_of_tail) {
super(m, pos, nom, pv, force, vision_radius, agro, update_rate_ms, path_type, lvl);
Expand Down Expand Up @@ -64,8 +73,8 @@ public void move(Position pos) {
public boolean updatePV(int pv) {
boolean Alive = super.updatePV(pv);
if(!Alive){
for(Tail t : snakeTail){
t.updatePV(-Integer.MAX_VALUE);
while(snakeTail.size()>0){
snakeTail.get(0).updatePV(-Integer.MAX_VALUE);
}
}
return Alive;
Expand Down

0 comments on commit c5e9d57

Please sign in to comment.