1
0
Fork 0

Included experimental mode

main
MrMcX vor 10 Jahren
Ursprung 874f87c7ce
Commit 88c1d33c60

Binäre Datei nicht angezeigt.

Binäre Datei nicht angezeigt.

Binäre Datei nicht angezeigt.

Binäre Datei nicht angezeigt.

Binäre Datei nicht angezeigt.

@ -196,6 +196,30 @@
</Property>
</Properties>
</Component>
<Component class="javax.swing.Box$Filler" name="filler1">
<Properties>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[1, 32767]"/>
</Property>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[1, 0]"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[1, 0]"/>
</Property>
</Properties>
<AuxValues>
<AuxValue name="classDetails" type="java.lang.String" value="Box.Filler.HorizontalStrut"/>
</AuxValues>
</Component>
<Component class="javax.swing.JCheckBox" name="jCheckBoxExp">
<Properties>
<Property name="text" type="java.lang.String" value="Experimenteller Modus"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jCheckBoxExpActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="jLabel1">
<Properties>
<Property name="horizontalAlignment" type="int" value="0"/>

@ -23,15 +23,15 @@ public class Dungeon {
private final LinkedList<Room> toGenerate;
private final Counter counter;
public Dungeon(int size, Type isNatural, Mode mode){
public Dungeon(int size, Type type, Mode mode){
rooms = new ArrayList<>();
toGenerate = new LinkedList<>();
counter = new Counter();
generate(size, isNatural, mode);
generate(size, type, mode);
}
private void generate(int size, Type isNatural, Mode mode){
toGenerate.add(Room.RandomRoom(true, Exit.Start(), counter, isNatural));
private void generate(int size, Type type, Mode mode){
toGenerate.add(Room.RandomRoom(true, Exit.Start(), counter, type));
while(!toGenerate.isEmpty() && rooms.size() < size){
Room next;
switch(mode){
@ -48,7 +48,7 @@ public class Dungeon {
next = toGenerate.getFirst();
break;
}
next.generate(counter, isNatural).stream().forEach((r) -> {
next.generate(counter, type).stream().forEach((r) -> {
toGenerate.add(r);
});
toGenerate.remove(next);
@ -77,14 +77,20 @@ public class Dungeon {
return g;
}
public static boolean Natural(Type n){
return (n == Type.NATURAL || n == Type.EXP_NATURAL);
}
public static enum Mode{
STRAIGHT,
BRANCHED,
RANDOM
RANDOM,
}
public static enum Type{
NATURAL,
ARTIFICIAL
ARTIFICIAL,
EXP_NATURAL,
EXP_ARTIFICIAL
}
}

@ -14,9 +14,9 @@ import main.Dice;
public class Enemy{
private String enemy;
public Enemy(Dungeon.Type isNatural){
public Enemy(Dungeon.Type type){
enemy = "";
if(isNatural == Dungeon.Type.NATURAL){
if(Dungeon.Natural(type)){
switch(Dice.Roll(20, 1)){
case 1:
enemy = "Höhlendrache";

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

@ -196,6 +196,30 @@
</Property>
</Properties>
</Component>
<Component class="javax.swing.Box$Filler" name="filler1">
<Properties>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[1, 32767]"/>
</Property>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[1, 0]"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[1, 0]"/>
</Property>
</Properties>
<AuxValues>
<AuxValue name="classDetails" type="java.lang.String" value="Box.Filler.HorizontalStrut"/>
</AuxValues>
</Component>
<Component class="javax.swing.JCheckBox" name="jCheckBoxExp">
<Properties>
<Property name="text" type="java.lang.String" value="Experimenteller Modus"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jCheckBoxExpActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="jLabel1">
<Properties>
<Property name="horizontalAlignment" type="int" value="0"/>

@ -70,6 +70,8 @@ public class DungeonGeneratorUI extends javax.swing.JFrame {
jPanelSettings = new javax.swing.JPanel();
jLabel4 = new javax.swing.JLabel();
jSpinSize = new javax.swing.JSpinner();
filler1 = new javax.swing.Box.Filler(new java.awt.Dimension(1, 0), new java.awt.Dimension(1, 0), new java.awt.Dimension(1, 32767));
jCheckBoxExp = new javax.swing.JCheckBox();
jLabel1 = new javax.swing.JLabel();
jComboBoxNatural = new javax.swing.JComboBox<>();
jLabel2 = new javax.swing.JLabel();
@ -125,6 +127,15 @@ public class DungeonGeneratorUI extends javax.swing.JFrame {
jSpinSize.setMaximumSize(new java.awt.Dimension(40, 30));
jSpinSize.setValue(1);
jPanelSettings.add(jSpinSize);
jPanelSettings.add(filler1);
jCheckBoxExp.setText("Experimenteller Modus");
jCheckBoxExp.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jCheckBoxExpActionPerformed(evt);
}
});
jPanelSettings.add(jCheckBoxExp);
jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel1.setText("Wie ist der Dungeon entstanden?");
@ -423,6 +434,10 @@ public class DungeonGeneratorUI extends javax.swing.JFrame {
+ "Icons made by Revicon from www.flaticon.com", "Über", JOptionPane.QUESTION_MESSAGE);
}//GEN-LAST:event_jMenuItemAboutActionPerformed
private void jCheckBoxExpActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBoxExpActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_jCheckBoxExpActionPerformed
/**
* @param args the command line arguments
*/
@ -471,11 +486,23 @@ public class DungeonGeneratorUI extends javax.swing.JFrame {
}
private Dungeon.Type SelectedNatural() {
return jComboBoxNatural.getSelectedItem().equals("Künstlich") ? Dungeon.Type.ARTIFICIAL : Dungeon.Type.NATURAL;
if(jComboBoxNatural.getSelectedItem().equals("Künstlich")){
if(jCheckBoxExp.isSelected()){
return Dungeon.Type.EXP_ARTIFICIAL;
}
return Dungeon.Type.ARTIFICIAL;
} else {
if(jCheckBoxExp.isSelected()){
return Dungeon.Type.EXP_NATURAL;
}
return Dungeon.Type.NATURAL;
}
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.Box.Filler filler1;
private javax.swing.JButton jButtonGenerate;
private javax.swing.JCheckBox jCheckBoxExp;
private javax.swing.JComboBox<String> jComboBoxMode;
private javax.swing.JComboBox<String> jComboBoxNatural;
private javax.swing.JLabel jLabel1;

Laden…
Abbrechen
Speichern