Commits

Shlomi Fish committed 6794e0a

Start implementing the FinalLayoutObj.

  • Participants
  • Parent commits c8ba10b

Comments (0)

Files changed (3)

File abc-path/js/Makefile

 all:
 
 edit:
-	gvim -o abc-path.js abc-path-test.js ../Games-ABC_Path-Generator/t/ms-rand.t ../Games-ABC_Path-Generator/lib/Games/ABC_Path/MicrosoftRand.pm
+	gvim -o abc-path.js abc-path-test.js ../Games-ABC_Path-Generator/t/ms-rand.t ../Games-ABC_Path-Generator/lib/Games/ABC_Path/Generator/FinalLayoutObj.pm
 
 test:
 	firefox abc-path-test.html

File abc-path/js/abc-path-test.js

         // TEST
         equals (ret, myarr, 'shuffle returns the same array.');
     });
+
+    module("FinalLayoutObj");
+
+    test("FinalLayoutObj", function() {
+        expect(1);
+        
+        var myboard = new ABC_Path.Solver.Board({});
+        // TEST
+        var layout_string = myboard._perl_range(1,25).map(
+            function (x) { return String.fromCharCode(x); }
+        ).join('');
+        
+        var obj = new ABC_Path.Generator.FinalLayoutObj({ s: layout_string });
+
+        // TEST
+        deepEqual (obj.get_A_xy(), {x : 0, y: 0}, 'A xy is OK.');
+    });
 }

File abc-path/js/abc-path.js

         },
     },
 });
+Class('ABC_Path.Generator', {
+});
+Class('ABC_Path.Generator.FinalLayoutObj', {
+    isa: ABC_Path.Solver.Base,
+    has: {
+        _s: { is: ro },
+    },
+    methods: {
+        get_A_pos: function() {
+            return this.getS().indexOf(String.fromCharCode(1));
+        },
+        get_A_xy: function() {
+            var xy = this._to_xy(this.get_A_pos());
+            return {y : xy[this.Y()], x: xy[this.X()], };
+        },
+    },
+});