Skip to content

Commit

Permalink
Making the Crwal static template system generic
Browse files Browse the repository at this point in the history
  • Loading branch information
tukkek committed Feb 14, 2018
1 parent 231e7a0 commit d279dcb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
6 changes: 3 additions & 3 deletions javelin/controller/generator/dungeon/DungeonGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ void generatepool(int sizehint) {
}
}
if (RPG.chancein(2)) {
Collections.shuffle(StaticTemplate.CRAWL);
Collections.shuffle(StaticTemplate.STATIC);
int target = pool.size() / templates.size();
pool.addAll(StaticTemplate.CRAWL.subList(0,
Math.min(target, StaticTemplate.CRAWL.size())));
pool.addAll(StaticTemplate.STATIC.subList(0,
Math.min(target, StaticTemplate.STATIC.size())));
}
Collections.shuffle(pool);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)

}

public static final ArrayList<Template> CRAWL = new ArrayList<Template>();
public static final ArrayList<Template> STATIC = new ArrayList<Template>();
static final HashMap<Character, Character> TRANSLATE = new HashMap<Character, Character>();

static {
Expand All @@ -47,7 +47,7 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)

ArrayList<File> files = new ArrayList<File>(300);
try {
Files.walkFileTree(Paths.get("maps/templates/crawl"),
Files.walkFileTree(Paths.get("maps/templates/"),
new TemplateReader(files));
} catch (IOException e) {
throw new RuntimeException(e);
Expand All @@ -57,7 +57,7 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
t.generate();
if (validate(t)) {
t.create();
CRAWL.add(t);
STATIC.add(t);
} else {
System.err.println("Failed to load static template: " + t.name);
}
Expand Down Expand Up @@ -133,9 +133,6 @@ static boolean validate(StaticTemplate t) {
return false;
}
}
// if (t.name.equals("maps/templates/crawl/traps/grate4.template")) {
// System.out.println("debug");
// }
if (t.count(WALL) == size) {
return false;
}
Expand Down

0 comments on commit d279dcb

Please sign in to comment.