public void distributeStuff(int numPlayers) { Utility.Trace("Maze - distributeStuff"); // distribute keys (one for each door) Sequence seq = new Sequence(2, this.getNumRooms()); // seq.shuffle(); int num_doors = this.getNumRooms() / 10; int num_chests = this.getNumRooms() / 20; int num_keys = num_doors /*+ num_chests*/ + 2; if (GameEngine.instance.fDungeon.fCompleted) { num_keys = 0; } int no; for (int i = 0; i < num_keys; i++) { no = seq.remove(); Room room = this.getRoom(no); Utility.Assert(room.fKeys == 0, "Maze.initialize - room.getKeys() == 0"); room.fKeys = 1; } // distribute coins int num_coins = this.getNumRooms() / 7 + 1 /*numPlayers*/; for (int i = 0; i < num_coins /*8 * numPlayers*/; i++) { // no = fHermit.getRoomNumber(); // while (no == fHermit.getRoomNumber()) no = GameEngine.rand.range(2, this.getNumRooms()); Room room = this.getRoom(no); // pile coins as high as possible if (room.fCoins == 0) { // no = fHermit.getRoomNumber(); // while (no == fHermit.getRoomNumber()) no = GameEngine.rand.range(2, this.getNumRooms()); room = this.getRoom(no); } room.fCoins = room.fCoins + GameEngine.rand.range(0, GameEngine.instance.fDungeon.fNumber / 2); } // distribute carpets // int num_carpets = this.getNumRooms() / 15 + 1; int num_carpets = GameEngine.instance.fNumPlayers + this.getNumRooms() / 40; for (int i = 0; i < num_carpets; i++) { Room room = null; no = GameEngine.rand.range(2, this.getNumRooms()); room = this.getRoom(no); room.fCarpets = room.fCarpets + 1; } // distribute arrows int num_arrows = this.getNumRooms() / 10 + 1 /*numPlayers*/ + 1; for (int i = 0; i < num_arrows /* 2 * numPlayers + 2 */; i++) { no = GameEngine.rand.range(2, this.getNumRooms()); Room room = this.getRoom(no); room.fArrows = room.fArrows + GameEngine.rand.range(1, (GameEngine.instance.fDungeon.fNumber / 2) + 1); } // distribute axes { no = GameEngine.rand.range(2, this.getNumRooms()); Room room = this.getRoom(no); room.fAxes = room.fAxes + 1; } // // distribute staffs // for (int i = 0; i < GameEngine.instance.fDungeon.fNumber; i++) // { // if (GameEngine.rand.range(1, 10) == 1) // { // no = GameEngine.rand.range(2, this.getNumRooms()); // Room room = this.getRoom(no); // room.fAxes = room.fAxes + 1; // } // } // distribute springs of water int num_springs = this.getNumRooms() / 10; for (int i = 0; i < num_springs /* 5 */; i++) { Room room = null; do { no = GameEngine.rand.range(2, this.getNumRooms()); room = this.getRoom(no); } while (room.fWater > 0); Utility.Assert(room.fWater == -1, "Maze.initialize - !room.hasWater()"); room.fWater = numPlayers * GameEngine.rand.range(10, 50); } // create chests for (int iChest = 0; iChest < num_chests; iChest++) { Room target = null; int maxCount = 0; for (int i = 0; i < 100; ++i) { Room room = null; while (room == null || room.hasChest() || room.hasDoor()) { no = GameEngine.rand.range(1, fNumRooms); room = this.getRoom(no); } int count = room.countItems() + room.fCoins; if (count > maxCount) { target = room; maxCount = count; } } Utility.Assert(target != null, "Maze.initialize - target != null"); target.createChest(); if (GameEngine.rand.range(1, 2) == 1) { target.fChest.fPoisoned = true; } } if (debug) { Room entry = this.getRoom(1); entry.fCoins = 5; entry.fKeys = 1; entry.fCarpets = 1; entry.fAxes = 1; entry.fWater = 100; // entry.createChest(); } }