icfp-model/src/main/java/ru/bosony/model/cellscontents/CellContent.java
changeset 27 505c25412b16
parent 6 0dbbc8983926
child 29 66aa96e8fd92
     1.1 --- a/icfp-model/src/main/java/ru/bosony/model/cellscontents/CellContent.java	Sun Jul 15 19:26:28 2012 +0400
     1.2 +++ b/icfp-model/src/main/java/ru/bosony/model/cellscontents/CellContent.java	Sun Jul 15 21:20:04 2012 +0400
     1.3 @@ -1,5 +1,8 @@
     1.4  package ru.bosony.model.cellscontents;
     1.5  
     1.6 +import java.util.HashSet;
     1.7 +import java.util.Set;
     1.8 +
     1.9  import ru.bosony.model.io.TextRepresentable;
    1.10  
    1.11  /**
    1.12 @@ -8,7 +11,7 @@
    1.13   * 
    1.14   */
    1.15  public enum CellContent implements TextRepresentable {
    1.16 -	
    1.17 +
    1.18  	ClosedLambdaLift("L"),
    1.19  	Earth("."),
    1.20  	Empty(" "),
    1.21 @@ -16,9 +19,50 @@
    1.22  	MiningRobot("R"),
    1.23  	OpenLambdaLift("O"),
    1.24  	Rock("*"),
    1.25 -	Wall("#");
    1.26 +	Wall("#"),
    1.27 +	TrampolineA("A"),
    1.28 +	TrampolineB("B"),
    1.29 +	TrampolineC("C"),
    1.30 +	TrampolineD("D"),
    1.31 +	TrampolineE("E"),
    1.32 +	TrampolineF("F"),
    1.33 +	TrampolineG("G"),
    1.34 +	TrampolineH("H"),
    1.35 +	TrampolineI("I"),
    1.36 +	Target1("1"),
    1.37 +	Target2("2"),
    1.38 +	Target3("3"),
    1.39 +	Target4("4"),
    1.40 +	Target5("5"),
    1.41 +	Target6("6"),
    1.42 +	Target7("7"),
    1.43 +	Target8("8"),
    1.44 +	Target9("9");
    1.45  
    1.46 -	private String	text;
    1.47 +	private String					text;
    1.48 +	private CellContent				trampolineTarget	= null;
    1.49 +	private static Set<CellContent>	trampolines			= new HashSet<CellContent>();
    1.50 +	private static Set<CellContent>	targets				= new HashSet<CellContent>();
    1.51 +	static {
    1.52 +		trampolines.add(TrampolineA);
    1.53 +		trampolines.add(TrampolineB);
    1.54 +		trampolines.add(TrampolineC);
    1.55 +		trampolines.add(TrampolineD);
    1.56 +		trampolines.add(TrampolineE);
    1.57 +		trampolines.add(TrampolineF);
    1.58 +		trampolines.add(TrampolineG);
    1.59 +		trampolines.add(TrampolineH);
    1.60 +		trampolines.add(TrampolineI);
    1.61 +		targets.add(Target1);
    1.62 +		targets.add(Target2);
    1.63 +		targets.add(Target3);
    1.64 +		targets.add(Target4);
    1.65 +		targets.add(Target5);
    1.66 +		targets.add(Target6);
    1.67 +		targets.add(Target7);
    1.68 +		targets.add(Target8);
    1.69 +		targets.add(Target9);
    1.70 +	}
    1.71  
    1.72  	private CellContent(String text) {
    1.73  		this.text = text;
    1.74 @@ -37,4 +81,22 @@
    1.75  		return null;
    1.76  	}
    1.77  
    1.78 +	public CellContent getTrampolineTarget() {
    1.79 +		return trampolineTarget;
    1.80 +	}
    1.81 +
    1.82 +	public void setTrampolineTarget(CellContent trampolineTarget) {
    1.83 +		if (!trampolines.contains(this) || trampolineTarget != null && !targets.contains(trampolineTarget))
    1.84 +			throw new RuntimeException("Only references from Trampolines to Targets allowed");
    1.85 +		this.trampolineTarget = trampolineTarget;
    1.86 +	}
    1.87 +
    1.88 +	public static Set<CellContent> getTrampolines() {
    1.89 +		return trampolines;
    1.90 +	}
    1.91 +
    1.92 +	public static Set<CellContent> getTargets() {
    1.93 +		return targets;
    1.94 +	}
    1.95 +
    1.96  }