Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
5f4f7604ce | ||
|
e10124b261 | ||
|
ccd98ee88d | ||
|
de12672138 |
12
.github/workflows/cd-backend.yml
vendored
12
.github/workflows/cd-backend.yml
vendored
@@ -1,4 +1,4 @@
|
||||
name: Deploy backend
|
||||
name: Deploy
|
||||
|
||||
on:
|
||||
push:
|
||||
@@ -7,12 +7,9 @@ on:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
docker-azure:
|
||||
docker:
|
||||
runs-on: ubuntu-latest
|
||||
environment: battleship
|
||||
permissions:
|
||||
id-token: write
|
||||
contents: read
|
||||
steps:
|
||||
-
|
||||
name: Login to Docker Hub
|
||||
@@ -31,7 +28,6 @@ jobs:
|
||||
tags: ${{ secrets.DOCKER_IMAGE_PATH }}:${{ github.sha }}
|
||||
cache-from: type=registry,ref=${{ secrets.DOCKER_IMAGE_PATH }}:buildcache
|
||||
cache-to: type=registry,ref=${{ secrets.DOCKER_IMAGE_PATH }}:buildcache,mode=max
|
||||
|
||||
-
|
||||
name: Azure login
|
||||
uses: azure/login@v2
|
||||
@@ -43,8 +39,8 @@ jobs:
|
||||
name: Deploy Container
|
||||
uses: azure/container-apps-deploy-action@v1
|
||||
with:
|
||||
registryUrl: docker.io
|
||||
acrName: dockerhub
|
||||
containerAppName: battleship
|
||||
resourceGroup: Battleship
|
||||
imageToDeploy: docker.io/${{ secrets.DOCKER_IMAGE_PATH }}:${{ github.sha }}
|
||||
imageToDeploy: ${{ secrets.DOCKER_IMAGE_PATH }}:${{ github.sha }}
|
||||
|
||||
|
12
.github/workflows/cd-frontend.yml
vendored
12
.github/workflows/cd-frontend.yml
vendored
@@ -1,13 +1,11 @@
|
||||
name: Deploy frontend
|
||||
name: Deploy
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- v**
|
||||
workflow_dispatch:
|
||||
branches: [ "main" ]
|
||||
|
||||
jobs:
|
||||
build_frontend:
|
||||
build_site:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
@@ -36,8 +34,8 @@ jobs:
|
||||
# this should match the `pages` option in your adapter-static options
|
||||
path: 'app/build/'
|
||||
|
||||
deploy-frontend:
|
||||
needs: build_frontend
|
||||
deploy-site:
|
||||
needs: build_site
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
permissions:
|
||||
|
24
.github/workflows/ci.yml
vendored
24
.github/workflows/ci.yml
vendored
@@ -11,30 +11,14 @@ env:
|
||||
SQLX_OFFLINE: true
|
||||
|
||||
jobs:
|
||||
backend:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
- name: cargo-check
|
||||
- name: Check
|
||||
run: cargo check
|
||||
- name: cargo-clippy
|
||||
- name: Clippy
|
||||
run: cargo clippy
|
||||
- name: cargo-fmt
|
||||
- name: Format
|
||||
run: cargo fmt --all --check
|
||||
frontend:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
cache: npm
|
||||
cache-dependency-path: 'app/package-lock.json'
|
||||
- name: Install dependencies
|
||||
working-directory: app
|
||||
run: npm install
|
||||
- name: lint
|
||||
working-directory: app
|
||||
run: npm run lint
|
||||
|
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -154,7 +154,7 @@ checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b"
|
||||
|
||||
[[package]]
|
||||
name = "battleship"
|
||||
version = "1.1.0"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"axum",
|
||||
"dotenv",
|
||||
|
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "battleship"
|
||||
version = "1.1.0"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
|
@@ -8,7 +8,7 @@
|
||||
"preview": "vite preview",
|
||||
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
||||
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
|
||||
"lint": "eslint .",
|
||||
"lint": "prettier --check . && eslint .",
|
||||
"format": "prettier --write ."
|
||||
},
|
||||
"devDependencies": {
|
||||
|
@@ -38,7 +38,7 @@ export class State {
|
||||
});
|
||||
this.socket.on('attacked', ({ by, at, hit, sunk }) => {
|
||||
const [i, j]: [number, number] = at;
|
||||
const board = by == this.socket.id ? this.opponentBoard : this.playerBoard;
|
||||
let board = by == this.socket.id ? this.opponentBoard : this.playerBoard;
|
||||
if (by == this.socket.id) {
|
||||
this.turn = (hit) ? 1 : -1;
|
||||
} else {
|
||||
@@ -46,7 +46,7 @@ export class State {
|
||||
}
|
||||
if (hit) {
|
||||
board.board[i][j] = 'h';
|
||||
for (const [x, y] of [[-1, -1], [1, 1], [1, -1], [-1, 1]]) {
|
||||
for (let [x, y] of [[-1, -1], [1, 1], [1, -1], [-1, 1]]) {
|
||||
const [tx, ty] = [i + x, j + y];
|
||||
if (tx < 0 || tx >= 10 || ty < 0 || ty >= 10) continue;
|
||||
if (board.board[tx][ty] == 'e')
|
||||
@@ -132,7 +132,7 @@ export class Board {
|
||||
isOverlapping(x: number, y: number, length: number, dir: number): boolean {
|
||||
for (let i = -1; i < 2; i++) {
|
||||
for (let j = -1; j < length + 1; j++) {
|
||||
const [tx, ty] = [x + (dir ? i : j), y + (dir ? j : i)];
|
||||
let [tx, ty] = [x + (dir ? i : j), y + (dir ? j : i)];
|
||||
if (tx < 0 || tx >= 10 || ty < 0 || ty >= 10) continue;
|
||||
if (this.board[tx][ty] != 'e') return true;
|
||||
}
|
||||
|
@@ -5,7 +5,7 @@ export default {
|
||||
extend: {},
|
||||
},
|
||||
plugins: [
|
||||
require('daisyui'), // eslint-disable-line
|
||||
require('daisyui'),
|
||||
],
|
||||
|
||||
daisyui: {
|
||||
|
Reference in New Issue
Block a user