package th; /* Region class * Regions are generators of special areas. They usually return a node with a * chunk of map attached to it, and are typically invoked by constructors of * special nodes. */ class Region { // Create the region. The constructor should concern itself only // with changing the intial node and locating the branch; let the // generator do the generating proper. // This will replace the inital description: public static String description = "This room has regional flair."; public static String name = "Regional Branch"; public static int NORTH = 0, SOUTH = 1, EAST = 3, WEST = 2; public static Class[] regions_to_make = { //Utl.gclass("ZeiusRegion"), Utl.gclass("WonkaRegion"), Utl.gclass("SpanningRegion"), Utl.gclass("SpanningRegion"), Utl.gclass("ConferenceRegion"), Utl.gclass("ScifiRegion"), Utl.gclass("HoboRegion") }; public Region (Node start, int region) { int initdr = Utl.rn(3); int stop = 0; while (stop < 4) { initdr = (initdr + 1)%4; if (initdr == 0 && start.north != null) { stop++; continue; } if (initdr == 1 && start.south != null) { stop++; continue; } if (initdr == 2 && start.west != null) { stop++; continue; } if (initdr == 3 && start.east != null) { stop++; continue; } generate(start, region, initdr); break; } } // Override this method! public void generate (Node origin, int region, int direction) { Node tmp = (Node)Utl.newInstance(Utl.rn(Node.non_unique_special_nodes)); tmp.region = region; Map.makelink(tmp, origin, direction); } }