Remove unnecessary, package as tar
This commit is contained in:
parent
6a8d9a47af
commit
74a91f5a1f
1
.gitignore
vendored
1
.gitignore
vendored
@ -21,3 +21,4 @@ Cargo.lock
|
||||
.idea/
|
||||
|
||||
dist/
|
||||
sol_chess.tar.gz
|
||||
|
@ -1,6 +0,0 @@
|
||||
cargo build --target wasm32-unknown-unknown --release
|
||||
mkdir -p ./dist
|
||||
rm ./web/sol_chess.wasm
|
||||
mv ./target/wasm32-unknown-unknown/release/sol_chess.wasm ./dist/sol_chess.wasm
|
||||
|
||||
basic-http-server ./dist
|
17
build-web.sh
17
build-web.sh
@ -1,6 +1,15 @@
|
||||
cargo build --target wasm32-unknown-unknown --release
|
||||
mkdir -p ./dist
|
||||
rm ./web/sol_chess.wasm
|
||||
mv ./target/wasm32-unknown-unknown/release/sol_chess.wasm ./dist/sol_chess.wasm
|
||||
|
||||
basic-http-server ./dist
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Wasm build failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
rm -rf ./dist && mkdir -p ./dist && mv ./target/wasm32-unknown-unknown/release/sol_chess.wasm ./dist/sol_chess.wasm && cp ./web/index.html ./dist/index.html
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Failed to create create dist directory"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
tar -czvf ./sol_chess.tar.gz -C ./dist . && rm -rf ./dist && echo "Web build complete"
|
||||
|
34
src/main.rs
34
src/main.rs
@ -299,15 +299,22 @@ impl Game {
|
||||
std::process::exit(0);
|
||||
}
|
||||
|
||||
if is_mouse_button_pressed(MouseButton::Right) {
|
||||
if is_mouse_button_released(MouseButton::Left) {
|
||||
let current_state = self.state.clone();
|
||||
let new_state = match current_state {
|
||||
GameState::SelectSource(_) => GameState::SelectSource(None),
|
||||
GameState::SelectTarget((_, _)) => {
|
||||
self.reset_squares();
|
||||
GameState::SelectSource(None)
|
||||
GameState::SelectSource(previous_target) => {
|
||||
self.handle_select_source(mouse_position(), previous_target)
|
||||
}
|
||||
GameState::GameOver((i, j)) => GameState::SelectSource(Some((i, j))),
|
||||
GameState::SelectTarget(source) => {
|
||||
let next = self.handle_select_target(mouse_position(), source);
|
||||
if let GameState::SelectTarget(_) = next {
|
||||
self.reset_squares();
|
||||
GameState::SelectSource(None)
|
||||
} else {
|
||||
next
|
||||
}
|
||||
}
|
||||
GameState::GameOver(previous_target) => GameState::GameOver(previous_target),
|
||||
};
|
||||
self.state = new_state;
|
||||
return;
|
||||
@ -325,21 +332,6 @@ impl Game {
|
||||
|
||||
self.state = new_state;
|
||||
}
|
||||
|
||||
if is_mouse_button_released(MouseButton::Left) {
|
||||
let current_state = self.state.clone();
|
||||
let new_state = match current_state {
|
||||
GameState::SelectSource(previous_target) => {
|
||||
GameState::SelectSource(previous_target)
|
||||
}
|
||||
GameState::SelectTarget(source) => {
|
||||
self.handle_select_target(mouse_position(), source)
|
||||
}
|
||||
GameState::GameOver(previous_target) => GameState::GameOver(previous_target),
|
||||
};
|
||||
|
||||
self.state = new_state;
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_select_source(
|
||||
|
@ -1,26 +0,0 @@
|
||||
*********** Game 1 ************
|
||||
|
||||
Generating a puzzle with 7 pieces with a maximum of 5 solutions
|
||||
Total attempts: 328
|
||||
Total pieces placed: 3363
|
||||
Success pieces placed: 2296
|
||||
Total time (ms): 1840
|
||||
|
||||
♗ ♗ ♙ ♘
|
||||
|
||||
. . . ♖
|
||||
|
||||
. . ♙ .
|
||||
|
||||
. . . ♙
|
||||
|
||||
|
||||
id: 140771860875974
|
||||
|
||||
Found 1 solutions
|
||||
1. BxPc2
|
||||
2. BxPd1
|
||||
3. RxBd1
|
||||
4. RxNd4
|
||||
5. RxPc4
|
||||
6. RxBb4
|
@ -1,26 +0,0 @@
|
||||
*********** Game 10 ************
|
||||
|
||||
Generating a puzzle with 7 pieces with a maximum of 5 solutions
|
||||
Total attempts: 43
|
||||
Total pieces placed: 407
|
||||
Success pieces placed: 301
|
||||
Total time (ms): 238
|
||||
|
||||
♙ . ♖ .
|
||||
|
||||
. . ♘ ♙
|
||||
|
||||
. ♙ ♘ .
|
||||
|
||||
♗ . . .
|
||||
|
||||
|
||||
id: 211381923512704
|
||||
|
||||
Found 4 solutions
|
||||
1. BxPb2
|
||||
2. NxPa4
|
||||
3. RxNc2
|
||||
4. RxBb2
|
||||
5. NxRb2
|
||||
6. NxPd3
|
@ -1,26 +0,0 @@
|
||||
*********** Game 2 ************
|
||||
|
||||
Generating a puzzle with 7 pieces with a maximum of 5 solutions
|
||||
Total attempts: 47
|
||||
Total pieces placed: 473
|
||||
Success pieces placed: 329
|
||||
Total time (ms): 279
|
||||
|
||||
. . . ♗
|
||||
|
||||
♘ . ♗ .
|
||||
|
||||
♙ . . .
|
||||
|
||||
. ♘ ♖ ♗
|
||||
|
||||
|
||||
id: 25288852387844
|
||||
|
||||
Found 4 solutions
|
||||
1. RxBd1
|
||||
2. BxBc3
|
||||
3. RxNb1
|
||||
4. NxRb1
|
||||
5. NxBc3
|
||||
6. NxPa2
|
@ -1,26 +0,0 @@
|
||||
*********** Game 3 ************
|
||||
|
||||
Generating a puzzle with 7 pieces with a maximum of 5 solutions
|
||||
Total attempts: 22
|
||||
Total pieces placed: 239
|
||||
Success pieces placed: 154
|
||||
Total time (ms): 160
|
||||
|
||||
♗ . ♖ ♙
|
||||
|
||||
. . . ♙
|
||||
|
||||
. . . ♙
|
||||
|
||||
. ♙ . ♗
|
||||
|
||||
|
||||
id: 140737595313588
|
||||
|
||||
Found 5 solutions
|
||||
1. RxBa4
|
||||
2. RxPd4
|
||||
3. RxPd3
|
||||
4. RxPd2
|
||||
5. RxBd1
|
||||
6. RxPb1
|
@ -1,26 +0,0 @@
|
||||
*********** Game 4 ************
|
||||
|
||||
Generating a puzzle with 7 pieces with a maximum of 5 solutions
|
||||
Total attempts: 200
|
||||
Total pieces placed: 2059
|
||||
Success pieces placed: 1388
|
||||
Total time (ms): 929
|
||||
|
||||
♙ ♘ . ♗
|
||||
|
||||
. ♖ ♙ ♘
|
||||
|
||||
. . . .
|
||||
|
||||
. . ♙ .
|
||||
|
||||
|
||||
id: 211152405031232
|
||||
|
||||
Found 1 solutions
|
||||
1. RxNb4
|
||||
2. RxPa4
|
||||
3. RxBd4
|
||||
4. RxNd3
|
||||
5. RxPc3
|
||||
6. RxPc1
|
@ -1,26 +0,0 @@
|
||||
*********** Game 5 ************
|
||||
|
||||
Generating a puzzle with 7 pieces with a maximum of 5 solutions
|
||||
Total attempts: 74
|
||||
Total pieces placed: 771
|
||||
Success pieces placed: 512
|
||||
Total time (ms): 437
|
||||
|
||||
♗ ♙ . ♘
|
||||
|
||||
. ♖ . ♘
|
||||
|
||||
. . . .
|
||||
|
||||
. ♗ ♗ .
|
||||
|
||||
|
||||
id: 140792316316480
|
||||
|
||||
Found 4 solutions
|
||||
1. BxRb3
|
||||
2. BxNd3
|
||||
3. NxBb3
|
||||
4. NxBc1
|
||||
5. NxBd3
|
||||
6. NxPb4
|
@ -1,26 +0,0 @@
|
||||
*********** Game 6 ************
|
||||
|
||||
Generating a puzzle with 7 pieces with a maximum of 5 solutions
|
||||
Total attempts: 1
|
||||
Total pieces placed: 9
|
||||
Success pieces placed: 7
|
||||
Total time (ms): 0
|
||||
|
||||
. ♙ . .
|
||||
|
||||
. . . .
|
||||
|
||||
♗ . ♗ ♗
|
||||
|
||||
♖ ♙ . ♘
|
||||
|
||||
|
||||
id: 2456822087717
|
||||
|
||||
Found 5 solutions
|
||||
1. RxBa2
|
||||
2. RxBc2
|
||||
3. RxBd2
|
||||
4. RxNd1
|
||||
5. RxPb1
|
||||
6. RxPb4
|
@ -1,26 +0,0 @@
|
||||
*********** Game 7 ************
|
||||
|
||||
Generating a puzzle with 7 pieces with a maximum of 5 solutions
|
||||
Total attempts: 22
|
||||
Total pieces placed: 230
|
||||
Success pieces placed: 154
|
||||
Total time (ms): 109
|
||||
|
||||
♖ . . ♙
|
||||
|
||||
. . . ♗
|
||||
|
||||
♗ ♙ ♘ .
|
||||
|
||||
. . ♖ .
|
||||
|
||||
|
||||
id: 107752945007872
|
||||
|
||||
Found 2 solutions
|
||||
1. RxNc2
|
||||
2. RxPb2
|
||||
3. RxBa2
|
||||
4. RxRa4
|
||||
5. RxPd4
|
||||
6. RxBd3
|
@ -1,26 +0,0 @@
|
||||
*********** Game 8 ************
|
||||
|
||||
Generating a puzzle with 7 pieces with a maximum of 5 solutions
|
||||
Total attempts: 63
|
||||
Total pieces placed: 639
|
||||
Success pieces placed: 441
|
||||
Total time (ms): 345
|
||||
|
||||
. . ♖ .
|
||||
|
||||
. ♙ . .
|
||||
|
||||
♙ . ♗ .
|
||||
|
||||
♗ ♙ . ♗
|
||||
|
||||
|
||||
id: 3579962327044
|
||||
|
||||
Found 5 solutions
|
||||
1. BxBc2
|
||||
2. RxBc2
|
||||
3. RxPa2
|
||||
4. RxBa1
|
||||
5. RxPb1
|
||||
6. RxPb3
|
@ -1,26 +0,0 @@
|
||||
*********** Game 9 ************
|
||||
|
||||
Generating a puzzle with 7 pieces with a maximum of 5 solutions
|
||||
Total attempts: 250
|
||||
Total pieces placed: 2557
|
||||
Success pieces placed: 1750
|
||||
Total time (ms): 1298
|
||||
|
||||
. . . .
|
||||
|
||||
♘ ♘ . ♙
|
||||
|
||||
. ♙ . ♗
|
||||
|
||||
♙ . ♘ .
|
||||
|
||||
|
||||
id: 22408723452320
|
||||
|
||||
Found 1 solutions
|
||||
1. BxNc1
|
||||
2. NxBc1
|
||||
3. NxPd3
|
||||
4. NxPb2
|
||||
5. axNb2
|
||||
6. bxNa3
|
@ -1,9 +0,0 @@
|
||||
if [ ! -d games ]; then
|
||||
mkdir games
|
||||
fi
|
||||
|
||||
for i in {1..10}; do
|
||||
echo "*********** Game $i ************" >> games/$i.txt
|
||||
echo "" >> games/$i.txt
|
||||
sol_cli -g -n 7 --print >> games/$i.txt
|
||||
done
|
27
web/index.html
Normal file
27
web/index.html
Normal file
@ -0,0 +1,27 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>Solitaire Chess</title>
|
||||
<style>
|
||||
html,
|
||||
body,
|
||||
canvas {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
position: absolute;
|
||||
background: black;
|
||||
z-index: 0;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<canvas id="glcanvas" tabindex='1'></canvas>
|
||||
<script src="https://not-fl3.github.io/miniquad-samples/mq_js_bundle.js"></script>
|
||||
<script>load("sol_chess.wasm");</script> <!-- Your compiled WASM binary -->
|
||||
</body>
|
||||
</html>
|
Loading…
x
Reference in New Issue
Block a user