Log Browser > index.php | |
Recent files:
|
File contains 3205
lines and was last altered on Jul 1 2020
Showing the last 200 lines of this file ( 20 lines 200 lines 500 lines )
$sq[$square] = array( $value );
$board[$square] = 0;
}
$flg = 0;
foreach( $lines as $line ) {
$type = array_shift( $line );
if ( in_array( $square,$line ) ) {
foreach( $line as $p ) {
if ( $board[$p] == $value ) {
$flg = 1;
$msg = "<font color=red>There is a $value already " .
"in that $type</font>";
}
}
}
}
if ( $flg == 0 ) {
play_move( $square,$value );
if ( $mode == 'Create' ) {
$pos = array(99);
$val = array(99);
$orig = $board;
$square = ($square + 1) %81;
}
}
} else {
$msg = "<font color=red>You must select a square and then choose a value</font>";
}
} elseif ( $action == 'Empty' && $square >= 0 ) {
if ( $square >= 0 and $square <= 80
and $board[$square] > 0
&& ( in_array( $square,$pos ) or count($pos) == 1 ) ) {
$board[$square] = 0;
$orig[$square] = 0;
init_options();
if ( count($pos) == 1 ) {
$action = 'Create';
} else {
$action = 'Pause';
}
# remove from playlist
$tmp = array_search( $square, $pos );
if ( $tmp > 0 ) {
$pos[$tmp] = 82;
$val[$tmp] = 0;
}
save_state($ip);
}
} elseif ( $action == 'Next' ) {
$str = get_param( 'str' );
$level = 'Next';
$mode = 'Play';
create_new_sudoku( $str );
$action = 'Pause';
} elseif ( $action == 'Restart' ) {
$mode = 'Play';
restart_puzzle();
$orig[83] = time();
} elseif ( $action == 'Normal' ) {
$mode = 'Play';
$last_move = -1;
$info_screen = 0;
$mode='Play';
} elseif ( $action == 'Hint' ) {
$orig[83]=-1;
if ( $mode != 'Info' ) {
$mode = 'Info';
$last_move = -1;
$info_screen = 1;
$old_sq = $sq;
$old_pos = $pos;
$old_val = $val;
$old_board = $board;
$old_orig = $orig;
make_a_move( 4 );
$sq = $old_sq;
$pos = $old_pos;
$val = $old_val;
$board = $old_board;
$orig = $old_orig;
# show hint
if ( finished() ) {
$msg = "The puzzle is finished !";
} elseif ( $last_move == -1 ) {
$msg = ereg_replace( ').*$', ')Can you see a move here?',$msg );
} else {
$msg = "($last_move)Can you see a move here?";
}
$orig[83]=-1;
} else {
$mode='Play';
}
} elseif ( $action == 'Play' || $action == 'Step' ) {
$mode = 'Play';
$orig[83]=-1;
# square is set to 99 on first call so we can reset the board
if ( $action == 'Step' && $square != 99 ) {
restart_puzzle();
$square = 0;
$total_comp_time = 0;
$msg = 'Sit back and watch the puzzle get solved';
} else {
$last_move = -1;
$prev_opt_cnt = count_options_left();
$start_time = time();
make_a_move( 4 );
$total_comp_time += (time() - $start_time);
}
if ( $testing ) { echo $last_move; }
if ( finished() ) {
save_in_db( 0 );
if ( ! finished() ) {
$msg = "Oh dear, I'm stuck !!!";
} else {
$msg = "finished !";
log_msg( $msg );
}
$action = 'Pause';
}
} elseif ( $action == 'Create' or $action == 'Clear' ) {
$mode = 'Create';
$orig[83]=-1;
if ( $action == 'Clear' ) {
for( $c=0; $c<81; $c++ ) {
$board[$c] = 0;
$orig[$c] = 0;
}
init_options();
$action = 'Create';
}
$pos = array(99);
$val = array(99);
$orig = $board;
$orig[81] = '';
$msg = "To edit select squares and enter starting values";
}
save_state($ip);
start_screen_html();
print_board( );
print( "<input type=hidden name=mode value=$mode>" );
if ( $action == 'About' ) {
$mode = 'Play';
$action = 'Pause';
}
end_screen_html();
?>
|