Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- 1. go to 9.138.34.56 on hacker experience and open puzzle.exe
- 2. press f12 and go to console
- 3. paste the below in there and click run
- 4. there you go, auto win. the next ip should appear
- */
- 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 ] ] ];
- var TransitionGroup = React.addons.TransitionGroup;
- var classSet = React.addons.classSet;
- var Switch = React.createClass({
- displayName: "Switch",
- render: function() {
- var a = {
- "switch": true,
- "switch-done": this.props.done,
- "switch-on": this.props.isOn,
- "switch-off": !this.props.isOn
- };
- return React.DOM.div({
- className: classSet(a),
- onClick: this.props.onClick
- });
- }
- });
- var LightsOut = React.createClass({
- displayName: "LightsOut",
- getInitialState: function() {
- return {
- board: this.getNewRandomBoard(),
- done: false
- };
- },
- getNewRandomBoard: function() {
- return boards[Math.floor(Math.random() * boards.length)].map(function(a) {
- return a.map(function(a) {
- return a;
- });
- });
- },
- handleReset: function() {
- this.setState({
- board: this.getNewRandomBoard(),
- done: false
- });
- },
- handleSwitchClick: function(a, b) {
- var c = this.state.board;
- var d = c.length - 1;
- c[a][b] = !c[a][b];
- if (0 !== a) c[a - 1][b] = !c[a - 1][b];
- if (a !== c[a].length - 1) c[a + 1][b] = !c[a + 1][b];
- if (0 !== b) c[a][b - 1] = !c[a][b - 1];
- if (b !== c.length - 1) c[a][b + 1] = !c[a][b + 1];
- var e = this.state.board.every(function(a) {
- return a.every(function(a) {
- return !!a;
- });
- });
- this.setState({
- board: this.state.board,
- done: e
- }, function() {
- if (e) $.ajax({
- type: "POST",
- url: "riddle.php",
- dataType: "json",
- data: {
- func: "lightsout"
- },
- success: function(a) {
- if ("OK" == a.status) {
- result = $.parseJSON(a.msg);
- $("#puzzle-header").html(result[0].header);
- $("#puzzle-status").html(result[0].result);
- $("#puzzle-next").html(result[0].next);
- $("#puzzle-isSolved").attr("value", result[0].isSolved);
- $("#puzzle-solve").hide();
- }
- }
- });
- }.bind(this));
- },
- render: function() {
- return React.DOM.div(null, this.state.board.map(function(a, b) {
- return TransitionGroup({
- transitionName: "switch",
- component: React.DOM.div
- }, a.map(function(a, c) {
- return Switch({
- isOn: !!a,
- done: this.state.done,
- onClick: this.handleSwitchClick.bind(this, b, c)
- });
- }, this));
- }, this));
- }
- });
- React.renderComponent(LightsOut(null), document.getElementById("game"));
Advertisement
Add Comment
Please, Sign In to add comment