Skip to content

Commit b30c70e

Browse files
committed
Adding CI, adding website version
1 parent 26e967d commit b30c70e

File tree

7 files changed

+128
-59
lines changed

7 files changed

+128
-59
lines changed

.github/workflows/ci.yaml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Metacity Website CI
2+
3+
on:
4+
push:
5+
branches: [release, dev]
6+
pull_request:
7+
branches: [dev]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v3
14+
- name: 'Setup Node.js'
15+
uses: 'actions/setup-node@v3'
16+
with:
17+
node-version: 18
18+
- name: Install dependencies
19+
run: |
20+
npm i
21+
- name: Build library
22+
run: |
23+
npm run build
24+
25+
tag-and-release:
26+
runs-on: ubuntu-latest
27+
if: github.event_name == 'push' && contains(github.ref, 'release')
28+
needs: build
29+
steps:
30+
- uses: actions/checkout@v3
31+
- name: 'Setup Node.js'
32+
uses: actions/setup-node@v3
33+
with:
34+
node-version: 18
35+
- name: Install dependencies
36+
run: |
37+
npm i
38+
- name: 'Get release version'
39+
run: |
40+
CURRENT_VERSION=$(node -p "require('./package.json').version")
41+
echo "Current version: $CURRENT_VERSION"
42+
echo "CURRENT_VERSION=v$CURRENT_VERSION" >> $GITHUB_ENV
43+
- name: Build library
44+
run: |
45+
npm run build
46+
- name: Create Release ZIP file
47+
run: |
48+
zip -r website.zip dist
49+
- uses: rickstaa/action-create-tag@v1
50+
with:
51+
tag: ${{ env.CURRENT_VERSION }}
52+
- uses: ncipollo/release-action@v1
53+
with:
54+
artifacts: 'website.zip'
55+
token: ${{ secrets.GITHUB_TOKEN }}
56+
generateReleaseNotes: true
57+
tag: ${{ env.CURRENT_VERSION }}
58+
- name: Deploying to server
59+
uses: appleboy/ssh-action@v0.1.10
60+
with:
61+
host: ${{ secrets.SERVER_HOST }}
62+
username: ${{ secrets.SERVER_USERNAME }}
63+
key: ${{ secrets.SERVER_SSH_KEY }}
64+
port: ${{ secrets.PORT }}
65+
script: |
66+
rm -rf Website
67+
git clone https://github.com/MetacityTools/Website.git
68+
cd Website
69+
npm i
70+
npm run build

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"name": "website",
2+
"name": "metacity-website",
33
"private": true,
4-
"version": "0.0.0",
4+
"version": "0.0.1",
55
"type": "module",
66
"scripts": {
77
"dev": "vite",

src/App.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,9 @@ function App() {
9696
</a>
9797
</div>
9898
</div>
99-
<div className="text-neutral-700 my-4">
100-
&copy; 2022 st.dio s.r.o. All rights reserved, www.stdio.cz
99+
<div className="text-neutral-700 my-4 flex flex-row justify-between">
100+
<div>&copy; 2023 st.dio s.r.o. All rights reserved, www.stdio.cz</div>
101+
<div className="text-neutral-400">Website version v{APP_VERSION}</div>
101102
</div>
102103
</div>
103104
</div>

src/citygen/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { City } from './city';
66
import { genTrees } from './tree.js';
77

88
const BLOCKSIZE = 2;
9+
const CITYSIZE = 15;
910

1011
export class CityAnimation {
1112
roadMaterial: THREE.MeshLambertMaterial;
@@ -36,7 +37,7 @@ export class CityAnimation {
3637
this.camera.position.y = -400;
3738
this.camera.position.z = 400;
3839
this.camera.up = new THREE.Vector3(0, 0, 1);
39-
this.camera.lookAt(new THREE.Vector3(30, 30, 0));
40+
this.camera.lookAt(new THREE.Vector3(CITYSIZE * BLOCKSIZE, CITYSIZE * BLOCKSIZE, 0));
4041
this.renderer = new THREE.WebGLRenderer({
4142
canvas: this.canvas,
4243
antialias: true,
@@ -76,7 +77,7 @@ export class CityAnimation {
7677
}
7778

7879
generate() {
79-
const grid = generateWithRiver(15, 15);
80+
const grid = generateWithRiver(CITYSIZE, CITYSIZE);
8081
const roads: THREE.BoxGeometry[] = [];
8182
const bridges: THREE.BoxGeometry[] = [];
8283
const buildings: THREE.BoxGeometry[] = [];

src/citygen/layout.js

Lines changed: 41 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
2-
31
function strReverse(str) {
42
return str.split('').reverse().join('');
53
}
@@ -48,7 +46,6 @@ class LayoutTile {
4846
}
4947
}
5048

51-
5249
const tiles = [
5350
new LayoutTile('BRRB', 'BR', 'RR', 'RB', 'BB'),
5451
new LayoutTile('BRRR', 'BR', 'RR', 'RR', 'RB'),
@@ -76,11 +73,10 @@ const tiles = [
7673

7774
const colors = {
7875
//'P': [84, 186, 185],
79-
'P': [158, 210, 198],
80-
'R': [255, 255, 255],
81-
'B': [233, 218, 193],
82-
}
83-
76+
P: [158, 210, 198],
77+
R: [255, 255, 255],
78+
B: [233, 218, 193],
79+
};
8480

8581
class TileList {
8682
constructor(tiles) {
@@ -90,25 +86,33 @@ class TileList {
9086

9187
evaluateTileBellow(otherTiles) {
9288
let len = this.tiles.length;
93-
this.tiles = this.tiles.filter(option => otherTiles.some((tile => option.canHaveBellow(tile))));
89+
this.tiles = this.tiles.filter((option) =>
90+
otherTiles.some((tile) => option.canHaveBellow(tile))
91+
);
9492
this.changed = this.tiles.length !== len;
9593
}
9694

9795
evaluateTileAbove(otherTiles) {
9896
let len = this.tiles.length;
99-
this.tiles = this.tiles.filter(option => otherTiles.some((tile => option.canHaveAbove(tile))));
97+
this.tiles = this.tiles.filter((option) =>
98+
otherTiles.some((tile) => option.canHaveAbove(tile))
99+
);
100100
this.changed = this.tiles.length !== len;
101101
}
102102

103103
evaluateTileLeft(otherTiles) {
104104
let len = this.tiles.length;
105-
this.tiles = this.tiles.filter(option => otherTiles.some((tile => option.canHaveLeft(tile))));
105+
this.tiles = this.tiles.filter((option) =>
106+
otherTiles.some((tile) => option.canHaveLeft(tile))
107+
);
106108
this.changed = this.tiles.length !== len;
107109
}
108110

109111
evaluateTileRight(otherTiles) {
110112
let len = this.tiles.length;
111-
this.tiles = this.tiles.filter(option => otherTiles.some((tile => option.canHaveRight(tile))));
113+
this.tiles = this.tiles.filter((option) =>
114+
otherTiles.some((tile) => option.canHaveRight(tile))
115+
);
112116
this.changed = this.tiles.length !== len;
113117
}
114118

@@ -127,8 +131,7 @@ class TileList {
127131
draw(x, y) {
128132
//stroke(0);
129133
//rect(x * 20, y * 20, 20, 20);
130-
if (!this.converged)
131-
return;
134+
if (!this.converged) return;
132135

133136
const tile = this.tile;
134137
noStroke();
@@ -151,7 +154,7 @@ class TileList {
151154
}
152155

153156
clone() {
154-
return new TileList(this.tiles.map(tile => tile.clone()));
157+
return new TileList(this.tiles.map((tile) => tile.clone()));
155158
}
156159
}
157160

@@ -163,8 +166,7 @@ export class Layout {
163166
constructor(dimX, dimY) {
164167
this.options = [];
165168
for (let i = 0; i < tiles.length; i++) {
166-
for (let r = 0; r < 4; r++)
167-
this.options.push(tiles[i].rotate().clone());
169+
for (let r = 0; r < 4; r++) this.options.push(tiles[i].rotate().clone());
168170
}
169171

170172
this.init(dimX, dimY);
@@ -182,7 +184,7 @@ export class Layout {
182184
reinit() {
183185
for (let i = 0; i < this.arr.length; i++) {
184186
for (let j = 0; j < this.arr[i].length; j++) {
185-
this.arr[i][j] = new TileList(this.options.map(option => option));
187+
this.arr[i][j] = new TileList(this.options.map((option) => option));
186188
}
187189
}
188190

@@ -192,9 +194,8 @@ export class Layout {
192194
//this.propagate(coords);
193195
}
194196

195-
196197
generateStep() {
197-
if(this.status === FAILED) {
198+
if (this.status === FAILED) {
198199
this.reinit();
199200
}
200201

@@ -209,7 +210,6 @@ export class Layout {
209210
return this.status === CONVERGED;
210211
}
211212

212-
213213
generate() {
214214
while (!this.converged) {
215215
this.generateStep();
@@ -233,10 +233,10 @@ export class Layout {
233233

234234
printArrState() {
235235
const state = [];
236-
for(let i = 0; i < this.arr.length; i++) {
236+
for (let i = 0; i < this.arr.length; i++) {
237237
const row = [];
238-
for(let j = 0; j < this.arr[i].length; j++) {
239-
row.push(this.arr[i][j].tiles.map(tile => tile.code));
238+
for (let j = 0; j < this.arr[i].length; j++) {
239+
row.push(this.arr[i][j].tiles.map((tile) => tile.code));
240240
}
241241
state.push(row);
242242
}
@@ -254,8 +254,7 @@ export class Layout {
254254
if (coords.y > 0) {
255255
const above = this.arr[coords.x][coords.y - 1];
256256
above.evaluateTileBellow(tilesList.tiles);
257-
if (above.failed)
258-
return;
257+
if (above.failed) return;
259258
if (above.changed && !inQueue.has(above)) {
260259
queue.push({ x: coords.x, y: coords.y - 1 });
261260
inQueue.add(above);
@@ -265,9 +264,8 @@ export class Layout {
265264
if (coords.y < this.arr[coords.x].length - 1) {
266265
const below = this.arr[coords.x][coords.y + 1];
267266
below.evaluateTileAbove(tilesList.tiles);
268-
if (below.failed)
269-
return;
270-
267+
if (below.failed) return;
268+
271269
if (below.changed && !inQueue.has(below)) {
272270
queue.push({ x: coords.x, y: coords.y + 1 });
273271
inQueue.add(below);
@@ -277,8 +275,7 @@ export class Layout {
277275
if (coords.x > 0) {
278276
const left = this.arr[coords.x - 1][coords.y];
279277
left.evaluateTileRight(tilesList.tiles);
280-
if (left.failed)
281-
return;
278+
if (left.failed) return;
282279

283280
if (left.changed && !inQueue.has(left)) {
284281
queue.push({ x: coords.x - 1, y: coords.y });
@@ -289,13 +286,12 @@ export class Layout {
289286
if (coords.x < this.arr.length - 1) {
290287
const right = this.arr[coords.x + 1][coords.y];
291288
right.evaluateTileLeft(tilesList.tiles);
292-
if (right.failed)
293-
return;
289+
if (right.failed) return;
294290

295291
if (right.changed && !inQueue.has(right)) {
296292
queue.push({ x: coords.x + 1, y: coords.y });
297293
inQueue.add(right);
298-
};
294+
}
299295
}
300296
}
301297
}
@@ -307,8 +303,7 @@ export class Layout {
307303
return FAILED;
308304
}
309305

310-
if (!this.arr[i][j].converged)
311-
return NOTCOVERGED;
306+
if (!this.arr[i][j].converged) return NOTCOVERGED;
312307
}
313308
}
314309
return CONVERGED;
@@ -340,7 +335,6 @@ export class Layout {
340335
}
341336
}
342337

343-
344338
function validSize(index, size) {
345339
return index >= 0 && index < size;
346340
}
@@ -363,30 +357,29 @@ function addRiver(grid) {
363357
grid[pos[0] + 3][pos[1]] = 'W';
364358
//TODO check boundries
365359

366-
367360
next = [pos[0], pos[1] + 1];
368-
361+
369362
if (stp % 8 === 0) {
370363
do {
371364
const moveDir = Math.round(Math.random()) * 2 - 1;
372365
next = [pos[0], pos[1]];
373366
next[0] += moveDir;
374-
} while(!validSize(next[0], sizeX) || !validSize(next[1], sizeY));
367+
} while (!validSize(next[0], sizeX) || !validSize(next[1], sizeY));
375368
}
376369

377370
pos = next;
378371
stp++;
379-
} while(!reachedBorder(pos[0], sizeX) && !reachedBorder(pos[1], sizeY));
372+
} while (!reachedBorder(pos[0], sizeX) && !reachedBorder(pos[1], sizeY));
380373
}
381374

382375
function addBridgeAlongYAxis(grid) {
383376
let lastBefore, firstAfter, waterEncoutered;
384-
for(let i = Math.min(5, grid[0].length - 1); i < grid[0].length; i++) {
377+
for (let i = Math.min(5, grid[0].length - 1); i < grid[0].length; i++) {
385378
lastBefore = grid[0][i];
386379
waterEncoutered = false;
387380
firstAfter = null;
388-
389-
for(let j = 0; j < grid.length; j++) {
381+
382+
for (let j = 0; j < grid.length; j++) {
390383
if (grid[j][i] == 'W') {
391384
waterEncoutered = true;
392385
} else if (!waterEncoutered) {
@@ -397,18 +390,17 @@ function addBridgeAlongYAxis(grid) {
397390
}
398391
}
399392

400-
if (waterEncoutered && (lastBefore == 'R' && firstAfter == 'R')) {
401-
for(let j = 0; j < grid.length; j++) {
393+
if (waterEncoutered && lastBefore == 'R' && firstAfter == 'R') {
394+
for (let j = 0; j < grid.length; j++) {
402395
if (grid[j][i] == 'W') {
403396
grid[j][i] = 'M';
404-
}
397+
}
405398
}
406399
return;
407400
}
408401
}
409402
}
410403

411-
412404
export function generateWithRiver(x, y) {
413405
const layout = new Layout(x, y);
414406
layout.generate();
@@ -417,4 +409,4 @@ export function generateWithRiver(x, y) {
417409
addBridgeAlongYAxis(grid);
418410
addBridgeAlongYAxis(grid);
419411
return grid;
420-
}
412+
}

src/vite-env.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
/// <reference types="vite/client" />
2+
3+
declare const APP_VERSION: string;

0 commit comments

Comments
 (0)