vlatkovski

Lights Out auto win

Apr 11th, 2015
424
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.     1. go to 9.138.34.56 on hacker experience and open puzzle.exe
  3.     2. press f12 and go to console
  4.     3. paste the below in there and click run
  5.     4. there you go, auto win. the next ip should appear
  6. */
  7.  
  8. var boards = [ [ [ 1, 1, 1, 1, 1 ], [ 1, 1, 1, 1, 1 ], [ 1, 1, 1, 1, 1 ], [ 1, 1, 1, 1, 1 ], [ 1, 1, 1, 1, 1 ] ] ];
  9.  
  10. var TransitionGroup = React.addons.TransitionGroup;
  11.  
  12. var classSet = React.addons.classSet;
  13.  
  14. var Switch = React.createClass({
  15.     displayName: "Switch",
  16.     render: function() {
  17.         var a = {
  18.             "switch": true,
  19.             "switch-done": this.props.done,
  20.             "switch-on": this.props.isOn,
  21.             "switch-off": !this.props.isOn
  22.         };
  23.         return React.DOM.div({
  24.             className: classSet(a),
  25.             onClick: this.props.onClick
  26.         });
  27.     }
  28. });
  29.  
  30. var LightsOut = React.createClass({
  31.     displayName: "LightsOut",
  32.     getInitialState: function() {
  33.         return {
  34.             board: this.getNewRandomBoard(),
  35.             done: false
  36.         };
  37.     },
  38.     getNewRandomBoard: function() {
  39.         return boards[Math.floor(Math.random() * boards.length)].map(function(a) {
  40.             return a.map(function(a) {
  41.                 return a;
  42.             });
  43.         });
  44.     },
  45.     handleReset: function() {
  46.         this.setState({
  47.             board: this.getNewRandomBoard(),
  48.             done: false
  49.         });
  50.     },
  51.     handleSwitchClick: function(a, b) {
  52.         var c = this.state.board;
  53.         var d = c.length - 1;
  54.         c[a][b] = !c[a][b];
  55.         if (0 !== a) c[a - 1][b] = !c[a - 1][b];
  56.         if (a !== c[a].length - 1) c[a + 1][b] = !c[a + 1][b];
  57.         if (0 !== b) c[a][b - 1] = !c[a][b - 1];
  58.         if (b !== c.length - 1) c[a][b + 1] = !c[a][b + 1];
  59.         var e = this.state.board.every(function(a) {
  60.             return a.every(function(a) {
  61.                 return !!a;
  62.             });
  63.         });
  64.         this.setState({
  65.             board: this.state.board,
  66.             done: e
  67.         }, function() {
  68.             if (e) $.ajax({
  69.                 type: "POST",
  70.                 url: "riddle.php",
  71.                 dataType: "json",
  72.                 data: {
  73.                     func: "lightsout"
  74.                 },
  75.                 success: function(a) {
  76.                     if ("OK" == a.status) {
  77.                         result = $.parseJSON(a.msg);
  78.                         $("#puzzle-header").html(result[0].header);
  79.                         $("#puzzle-status").html(result[0].result);
  80.                         $("#puzzle-next").html(result[0].next);
  81.                         $("#puzzle-isSolved").attr("value", result[0].isSolved);
  82.                         $("#puzzle-solve").hide();
  83.                     }
  84.                 }
  85.             });
  86.         }.bind(this));
  87.     },
  88.     render: function() {
  89.         return React.DOM.div(null, this.state.board.map(function(a, b) {
  90.             return TransitionGroup({
  91.                 transitionName: "switch",
  92.                 component: React.DOM.div
  93.             }, a.map(function(a, c) {
  94.                 return Switch({
  95.                     isOn: !!a,
  96.                     done: this.state.done,
  97.                     onClick: this.handleSwitchClick.bind(this, b, c)
  98.                 });
  99.             }, this));
  100.         }, this));
  101.     }
  102. });
  103.  
  104. React.renderComponent(LightsOut(null), document.getElementById("game"));
Advertisement
Add Comment
Please, Sign In to add comment