/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package xmlleveltool;

/**
 *
 * @author Karl
 */
public class LevelElement {
    public static final int MAX_LAYER = 10;
    public static final int MIN_HEIGHT_PLATEFORM = 3;
    
    public enum LevelTypes{
        JUMP(1, "BonusJump"),
        LIFE(2, "BonusLife"),
        SLOW(3, "BonusSlow"),
        SPEED(4, "BonusSpeed"),
        PLATFORM(5, "Platform"),
        ROCKET(6, "Rocket"),
        TRAP(7, "Trap"),
        WALL(8, "Wall");
        
        private String name;
        private int id;
        private LevelTypes(int id, String name){
            this.id = id;
            this.name = name;
        }
        public int getId(){
            return this.id;
        }

        @Override
        public String toString() {
            return name;
        }
        
    }
    
    private LevelTypes type;
    private int layer;

    public LevelElement(LevelTypes type, int layer) throws Exception {
        if(layer < MAX_LAYER){
            if(type == LevelTypes.PLATFORM){
                if(layer >= MIN_HEIGHT_PLATEFORM && layer < MAX_LAYER) {
                    this.type = type;
                    this.layer = layer;
                }
                else{
                    throw new Exception("ELEMENT ERROR");
                }
            }
            else{
                this.type = type;
                this.layer = layer;
            }
        }
        else{
            throw new Exception("ELEMENT ERROR");
        }
    }

    public LevelTypes getType() {
        return type;
    }

    public int getLayer() {
        return layer;
    }

    @Override
    public String toString() {
        return this.type.toString() + "(" + this.layer + ")";
    }
}

@@ -420,24 +420,54 @@
 nusSpeed%22),%0A
+        SWAP(9, %22BonusSwap%22),%0A
         PLAT
@@ -571,24 +571,33 @@
 );%0A        %0A
+        %0A
         priv

Add swap bonus in level editor