|
|
@ -17,44 +17,44 @@ import main.Dice;
|
|
|
|
public class Room {
|
|
|
|
public class Room {
|
|
|
|
public int number;
|
|
|
|
public int number;
|
|
|
|
public Exit[] exits;
|
|
|
|
public Exit[] exits;
|
|
|
|
public Dungeon.Type isNatural;
|
|
|
|
public Dungeon.Type type;
|
|
|
|
public boolean isRoom, hasMonster, hasTrap, hasMagic, hasSpecial, hasTreasure = false;
|
|
|
|
public boolean isRoom, hasMonster, hasTrap, hasMagic, hasSpecial, hasTreasure = false;
|
|
|
|
public Enemy monster;
|
|
|
|
public Enemy monster;
|
|
|
|
public Treasure treasure;
|
|
|
|
public Treasure treasure;
|
|
|
|
public Trap trap;
|
|
|
|
public Trap trap;
|
|
|
|
public String type, magicPhenomenon, specialPhenomenon = null;
|
|
|
|
public String desc, magicPhenomenon, specialPhenomenon = null;
|
|
|
|
|
|
|
|
|
|
|
|
public Room(Exit predecessor, int numberOfExits, boolean room, String type, Counter c){
|
|
|
|
public Room(Exit predecessor, int numberOfExits, boolean room, String desc, Counter c){
|
|
|
|
exits = new Exit[numberOfExits];
|
|
|
|
exits = new Exit[numberOfExits];
|
|
|
|
exits[0] = predecessor;
|
|
|
|
exits[0] = predecessor;
|
|
|
|
this.isRoom = room;
|
|
|
|
this.isRoom = room;
|
|
|
|
this.type = type;
|
|
|
|
this.desc = desc;
|
|
|
|
number = 0;
|
|
|
|
number = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public List<Room> generate(Counter c, Dungeon.Type isNatural){
|
|
|
|
public List<Room> generate(Counter c, Dungeon.Type type){
|
|
|
|
number = c.Next();
|
|
|
|
number = c.Next();
|
|
|
|
List<Room> list = new LinkedList();
|
|
|
|
List<Room> list = new LinkedList();
|
|
|
|
for(int i = 0; i < exits.length; i++){
|
|
|
|
for(int i = 0; i < exits.length; i++){
|
|
|
|
if(exits[i] == null){
|
|
|
|
if(exits[i] == null){
|
|
|
|
Exit predecessor = new Exit(this);
|
|
|
|
Exit predecessor = new Exit(this);
|
|
|
|
Room newRoom = RandomRoom(false, predecessor, c, isNatural);
|
|
|
|
Room newRoom = RandomRoom(false, predecessor, c, type);
|
|
|
|
exits[i] = new Exit(newRoom, predecessor.type);
|
|
|
|
exits[i] = new Exit(newRoom, predecessor.type);
|
|
|
|
list.add(newRoom);
|
|
|
|
list.add(newRoom);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SetContents(isNatural);
|
|
|
|
SetContents(type);
|
|
|
|
return list;
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void SetContents(Dungeon.Type isNatural){
|
|
|
|
private void SetContents(Dungeon.Type type){
|
|
|
|
if(isRoom){
|
|
|
|
if(isRoom){
|
|
|
|
switch(Dice.Roll(6, 2)){
|
|
|
|
switch(Dice.Roll(6, 2)){
|
|
|
|
case 2:
|
|
|
|
case 2:
|
|
|
|
case 3: return;
|
|
|
|
case 3: return;
|
|
|
|
case 4:
|
|
|
|
case 4:
|
|
|
|
hasMonster = true;
|
|
|
|
hasMonster = true;
|
|
|
|
monster = new Enemy(isNatural);
|
|
|
|
monster = new Enemy(type);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
case 5:
|
|
|
|
case 5:
|
|
|
|
hasTrap = true;
|
|
|
|
hasTrap = true;
|
|
|
@ -74,19 +74,19 @@ public class Room {
|
|
|
|
case 9:
|
|
|
|
case 9:
|
|
|
|
hasMonster = true;
|
|
|
|
hasMonster = true;
|
|
|
|
hasTrap = true;
|
|
|
|
hasTrap = true;
|
|
|
|
monster = new Enemy(isNatural);
|
|
|
|
monster = new Enemy(type);
|
|
|
|
trap = new Trap();
|
|
|
|
trap = new Trap();
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
case 10:
|
|
|
|
case 10:
|
|
|
|
hasMonster = true;
|
|
|
|
hasMonster = true;
|
|
|
|
hasTreasure = true;
|
|
|
|
hasTreasure = true;
|
|
|
|
monster = new Enemy(isNatural);
|
|
|
|
monster = new Enemy(type);
|
|
|
|
treasure = new Treasure();
|
|
|
|
treasure = new Treasure();
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
case 11:
|
|
|
|
case 11:
|
|
|
|
hasMonster = true;
|
|
|
|
hasMonster = true;
|
|
|
|
hasMagic = true;
|
|
|
|
hasMagic = true;
|
|
|
|
monster = new Enemy(isNatural);
|
|
|
|
monster = new Enemy(type);
|
|
|
|
// TODO: generate magic here
|
|
|
|
// TODO: generate magic here
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
case 12:
|
|
|
|
case 12:
|
|
|
@ -103,7 +103,7 @@ public class Room {
|
|
|
|
case 3: return;
|
|
|
|
case 3: return;
|
|
|
|
case 4:
|
|
|
|
case 4:
|
|
|
|
hasMonster = true;
|
|
|
|
hasMonster = true;
|
|
|
|
monster = new Enemy(isNatural);
|
|
|
|
monster = new Enemy(type);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
case 5:
|
|
|
|
case 5:
|
|
|
|
hasTrap = true;
|
|
|
|
hasTrap = true;
|
|
|
@ -115,14 +115,14 @@ public class Room {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.isNatural = isNatural;
|
|
|
|
this.type = type;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public String toString(){
|
|
|
|
public String toString(){
|
|
|
|
if(!isRoom){
|
|
|
|
if(!isRoom){
|
|
|
|
return "Gang " + number;
|
|
|
|
return "Gang " + number;
|
|
|
|
} else if(isNatural == Dungeon.Type.NATURAL){
|
|
|
|
} else if(Dungeon.Natural(type)){
|
|
|
|
return "Höhle " + number;
|
|
|
|
return "Höhle " + number;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
return "Raum " + number;
|
|
|
|
return "Raum " + number;
|
|
|
@ -136,7 +136,7 @@ public class Room {
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
out += "Gang ";
|
|
|
|
out += "Gang ";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
out += "Nummer " + number + ": " + type + "\n" +
|
|
|
|
out += "Nummer " + number + ": " + desc + "\n" +
|
|
|
|
"Ausgänge:\n";
|
|
|
|
"Ausgänge:\n";
|
|
|
|
for(Exit x : exits){
|
|
|
|
for(Exit x : exits){
|
|
|
|
out += x.toLongString();
|
|
|
|
out += x.toLongString();
|
|
|
@ -168,61 +168,61 @@ public class Room {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static Room RoomBigExits(Exit predecessor, Counter c, Dungeon.Type isNatural){
|
|
|
|
public static Room RoomBigExits(Exit predecessor, Counter c, Dungeon.Type type){
|
|
|
|
int rand = Dice.Roll(3, 1);
|
|
|
|
int rand = Dice.Roll(3, 1);
|
|
|
|
if(isNatural == Dungeon.Type.NATURAL){
|
|
|
|
if(Dungeon.Natural(type)){
|
|
|
|
return new Room(predecessor, rand + 1, true, "große Höhle mit " + rand + " Ausgängen", c);
|
|
|
|
return new Room(predecessor, rand + 1, true, "große Höhle mit " + rand + " Ausgängen", c);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
return new Room(predecessor, rand + 1, true, "großer Raum mit " + rand + " Ausgängen", c);
|
|
|
|
return new Room(predecessor, rand + 1, true, "großer Raum mit " + rand + " Ausgängen", c);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static Room RoomSmallExits(Exit predecessor, Counter c, Dungeon.Type isNatural){
|
|
|
|
public static Room RoomSmallExits(Exit predecessor, Counter c, Dungeon.Type type){
|
|
|
|
int rand = Dice.Roll(3, 1);
|
|
|
|
int rand = Dice.Roll(3, 1);
|
|
|
|
if(isNatural == Dungeon.Type.NATURAL){
|
|
|
|
if(Dungeon.Natural(type)){
|
|
|
|
return new Room(predecessor, rand + 1, true, "kleine Höhle mit " + rand + " Ausgängen", c);
|
|
|
|
return new Room(predecessor, rand + 1, true, "kleine Höhle mit " + rand + " Ausgängen", c);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
return new Room(predecessor, rand + 1, true, "kleiner Raum mit " + rand + " Ausgängen", c);
|
|
|
|
return new Room(predecessor, rand + 1, true, "kleiner Raum mit " + rand + " Ausgängen", c);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static Room RoomBigNoExits(Exit predecessor, Counter c, Dungeon.Type isNatural){
|
|
|
|
public static Room RoomBigNoExits(Exit predecessor, Counter c, Dungeon.Type type){
|
|
|
|
if(isNatural == Dungeon.Type.NATURAL){
|
|
|
|
if(Dungeon.Natural(type)){
|
|
|
|
return new Room(predecessor, 1, true, "große Höhle ohne Ausgang", c);
|
|
|
|
return new Room(predecessor, 1, true, "große Höhle ohne Ausgang", c);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
return new Room(predecessor, 1, true, "großer Raum ohne Ausgang", c);
|
|
|
|
return new Room(predecessor, 1, true, "großer Raum ohne Ausgang", c);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static Room RoomBigExitsStair(Exit predecessor, Counter c, Dungeon.Type isNatural){
|
|
|
|
public static Room RoomBigExitsStair(Exit predecessor, Counter c, Dungeon.Type type){
|
|
|
|
int rand = Dice.Roll(2, 1);
|
|
|
|
int rand = Dice.Roll(2, 1);
|
|
|
|
if(isNatural == Dungeon.Type.NATURAL){
|
|
|
|
if(Dungeon.Natural(type)){
|
|
|
|
return new Room(predecessor, rand + 2, true, "große Höhle mit " + rand + " Ausgängen und einer Treppe", c);
|
|
|
|
return new Room(predecessor, rand + 2, true, "große Höhle mit " + rand + " Ausgängen und einer Treppe", c);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
return new Room(predecessor, rand + 2, true, "großer Raum mit " + rand + " Ausgängen und einer Treppe", c);
|
|
|
|
return new Room(predecessor, rand + 2, true, "großer Raum mit " + rand + " Ausgängen und einer Treppe", c);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static Room RoomSmallNoExits(Exit predecessor, Counter c, Dungeon.Type isNatural){
|
|
|
|
public static Room RoomSmallNoExits(Exit predecessor, Counter c, Dungeon.Type type){
|
|
|
|
if(isNatural == Dungeon.Type.NATURAL){
|
|
|
|
if(Dungeon.Natural(type)){
|
|
|
|
return new Room(predecessor, 1, true, "kleine Höhle ohne Ausgang", c);
|
|
|
|
return new Room(predecessor, 1, true, "kleine Höhle ohne Ausgang", c);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
return new Room(predecessor, 1, true, "kleiner Raum ohne Ausgang", c);
|
|
|
|
return new Room(predecessor, 1, true, "kleiner Raum ohne Ausgang", c);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static Room RoomSmallExitsStair(Exit predecessor, Counter c, Dungeon.Type isNatural){
|
|
|
|
public static Room RoomSmallExitsStair(Exit predecessor, Counter c, Dungeon.Type type){
|
|
|
|
int rand = Dice.Roll(2, 1);
|
|
|
|
int rand = Dice.Roll(2, 1);
|
|
|
|
if(isNatural == Dungeon.Type.NATURAL){
|
|
|
|
if(Dungeon.Natural(type)){
|
|
|
|
return new Room(predecessor, rand + 2, true, "kleine Höhle mit " + rand + " Ausgängen und einer Treppe", c);
|
|
|
|
return new Room(predecessor, rand + 2, true, "kleine Höhle mit " + rand + " Ausgängen und einer Treppe", c);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
return new Room(predecessor, rand + 2, true, "kleiner Raum mit " + rand + " Ausgängen und einer Treppe", c);
|
|
|
|
return new Room(predecessor, rand + 2, true, "kleiner Raum mit " + rand + " Ausgängen und einer Treppe", c);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static Room RoomGiant(Exit predecessor, Counter c, Dungeon.Type isNatural){
|
|
|
|
public static Room RoomGiant(Exit predecessor, Counter c, Dungeon.Type type){
|
|
|
|
int rand = Dice.Roll(2, 1);
|
|
|
|
int rand = Dice.Roll(2, 1);
|
|
|
|
if(isNatural == Dungeon.Type.NATURAL){
|
|
|
|
if(Dungeon.Natural(type)){
|
|
|
|
return new Room(predecessor, rand + 1, true, "gigantische Höhle mit " + rand + " Ausgängen", c);
|
|
|
|
return new Room(predecessor, rand + 1, true, "gigantische Höhle mit " + rand + " Ausgängen", c);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
return new Room(predecessor, rand + 1, true, "gigantischer Raum mit " + rand + " Ausgängen", c);
|
|
|
|
return new Room(predecessor, rand + 1, true, "gigantischer Raum mit " + rand + " Ausgängen", c);
|
|
|
@ -253,7 +253,7 @@ public class Room {
|
|
|
|
return new Room(predecessor, 1, false, "Sackgasse", c);
|
|
|
|
return new Room(predecessor, 1, false, "Sackgasse", c);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static Room RandomRoom(boolean first, Exit predecessor, Counter c, Dungeon.Type isNatural){
|
|
|
|
public static Room RandomRoom(boolean first, Exit predecessor, Counter c, Dungeon.Type type){
|
|
|
|
int number;
|
|
|
|
int number;
|
|
|
|
if(first){
|
|
|
|
if(first){
|
|
|
|
number = Dice.Roll(6, 1);
|
|
|
|
number = Dice.Roll(6, 1);
|
|
|
@ -263,18 +263,18 @@ public class Room {
|
|
|
|
switch(number){
|
|
|
|
switch(number){
|
|
|
|
case 1:
|
|
|
|
case 1:
|
|
|
|
case 2:
|
|
|
|
case 2:
|
|
|
|
case 3: return RoomBigExits(predecessor, c, isNatural);
|
|
|
|
case 3: return RoomBigExits(predecessor, c, type);
|
|
|
|
case 4:
|
|
|
|
case 4:
|
|
|
|
case 5:
|
|
|
|
case 5:
|
|
|
|
case 6: return RoomSmallExits(predecessor, c, isNatural);
|
|
|
|
case 6: return RoomSmallExits(predecessor, c, type);
|
|
|
|
case 7: return RoomBigNoExits(predecessor, c, isNatural);
|
|
|
|
case 7: return RoomBigNoExits(predecessor, c, type);
|
|
|
|
case 8:
|
|
|
|
case 8:
|
|
|
|
case 9: return RoomBigExitsStair(predecessor, c, isNatural);
|
|
|
|
case 9: return RoomBigExitsStair(predecessor, c, type);
|
|
|
|
case 10: return RoomSmallNoExits(predecessor, c, isNatural);
|
|
|
|
case 10: return RoomSmallNoExits(predecessor, c, type);
|
|
|
|
case 11:
|
|
|
|
case 11:
|
|
|
|
case 12: return RoomSmallExitsStair(predecessor, c, isNatural);
|
|
|
|
case 12: return RoomSmallExitsStair(predecessor, c, type);
|
|
|
|
case 13:
|
|
|
|
case 13:
|
|
|
|
case 14: return RoomGiant(predecessor, c, isNatural);
|
|
|
|
case 14: return RoomGiant(predecessor, c, type);
|
|
|
|
case 15: return CorridorStraight(predecessor, c);
|
|
|
|
case 15: return CorridorStraight(predecessor, c);
|
|
|
|
case 16: return CorridorRight(predecessor, c);
|
|
|
|
case 16: return CorridorRight(predecessor, c);
|
|
|
|
case 17: return CorridorLeft(predecessor, c);
|
|
|
|
case 17: return CorridorLeft(predecessor, c);
|
|
|
|