Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
sofialottii committed Feb 18, 2024
1 parent eefd15d commit 209da0b
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/main/java/pvzclone/model/impl/GameImpl.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package pvzclone.model.impl;

import java.util.Set;
import java.util.stream.Collectors;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import pvzclone.model.api.Bullet;
Expand Down Expand Up @@ -174,17 +175,20 @@ public void update(final long elapsed) {
*/
private void createWave() {
final int totZombies = this.world.getLevel().getZombieCount();
final int totzombieWave = this.world.getLevel().getZombieCountInWave();
final int totZombieWave = this.world.getLevel().getZombieCountInWave();

if (this.gameState.getZombiesGenerated() >= totZombies - totzombieWave
if (this.gameState.getZombiesGenerated() >= totZombies - totZombieWave
&& this.wavePassed < this.world.getLevel().getZombieWaveCount()) {
this.canSingleZombieGenerate = false;
this.wavePassed = this.wavePassed + 1;
final Set<Entities> newWave = this.zombiesFactory.createEntities(totzombieWave);
for (final Entities singleZombieInWave : newWave) {
this.zombies.add((Zombie) singleZombieInWave);
this.gameState.incZombiesGenerated();
}
this.wavePassed++;

final Set<Zombie> newWave = zombiesFactory.createEntities(totZombieWave)
.stream()
.map(entity -> (Zombie) entity)
.collect(Collectors.toSet());

this.zombies.addAll(newWave);
this.gameState.incZombiesGenerated();
}
}

Expand Down

0 comments on commit 209da0b

Please sign in to comment.