Skip to content

Commit

Permalink
Fixed that crash on level 5. The simplest things, sometimes.
Browse files Browse the repository at this point in the history
Signed-off-by: Ken Hoover <[email protected]>
  • Loading branch information
Ken Hoover committed Apr 18, 2014
1 parent d63f7b6 commit f4c3c35
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
12 changes: 11 additions & 1 deletion rop-game/src/com/kandl/ropgame/managers/GroupManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
public class GroupManager extends Actor {
private static int dayMax = 0;
private static int dayTotal = 0;
private static int seated = 0;
private static final int SEATS = 5;
private static int max = 0;
private static int current = 0;
private float spawnGap = 15;
Expand All @@ -16,6 +18,7 @@ public class GroupManager extends Actor {
public void createGroup() {
if (dayTotal++ >= dayMax) {--dayTotal; return;}
current++;
seated++;
spawnGap = 0;
Person p1 = new Person(Math.random() >= 0.5, true);
Person p2 = null;
Expand All @@ -27,14 +30,21 @@ public void createGroup() {
public void act(float delta) {
spawnGap += delta;
despawnGap += delta;
if (spawnGap >= (RopGame.DEBUG ? 0 : 20) && despawnGap >= 5 && current < max) createGroup();
if (spawnGap >= (RopGame.DEBUG ? 0 : 20) &&
despawnGap >= 5 &&
current < max &&
seated < SEATS) createGroup();
}

public static void despawn() {
current--;
despawnGap = 0;
}

public static void freeSeat() {
seated--;
}

public static void setMax(int n) {
max = n;
}
Expand Down
1 change: 1 addition & 0 deletions rop-game/src/com/kandl/ropgame/managers/TableManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public static int assignTable(Group g) {

public static void freeTable(int i) {
tables.set(i, null);
GroupManager.freeSeat();
if (GroupManager.getDayMax() == GroupManager.getDayTotal()) {
for (int n = 0; n < 5; ++n) {
if (tables.get(n) != null) return;
Expand Down

0 comments on commit f4c3c35

Please sign in to comment.