Skip to content

Commit

Permalink
Hangman (#97)
Browse files Browse the repository at this point in the history
* link to local games

* lol

* wip

* its late

* cool

* cool

* cool

* cool

* more

* almost

* saving

* wip

* awesome

* ayy lmao

* nice

* wip

* ayo

* delete

* ah fuck

* wip

* almost

* moe

* fix
  • Loading branch information
prosif authored Apr 28, 2024
1 parent bda640f commit 1e044b7
Show file tree
Hide file tree
Showing 11 changed files with 1,211 additions and 95 deletions.
21 changes: 21 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
"squish-1005": "npm:[email protected]",
"squish-1006": "npm:[email protected]",
"squish-1007": "npm:[email protected]",
"squish-1008": "npm:[email protected]",
"squish-1009": "npm:[email protected]",
"squish-1010": "npm:[email protected]",
"ws": "7.4.6"
}
}
17 changes: 0 additions & 17 deletions src/GameSession.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,23 +89,6 @@ class GameSession {
const playerSettings = this.playerSettingsMap[playerId] || {};

let playerFrame = this.squisher.getPlayerFrame(playerId);

if (playerSettings) {
if ((!playerSettings.SOUND || !playerSettings.SOUND.enabled) && playerFrame) {
playerFrame = playerFrame.filter(f => {
const unsquished = this.squisher.unsquish(f);
if (unsquished.node.asset) {
if (this.game.getAssets && this.game.getAssets() && this.game.getAssets()[Object.keys(unsquished.node.asset)[0]]) {
if (this.game.getAssets()[Object.keys(unsquished.node.asset)[0]].info.type === 'audio') {
return false;
}
}
}

return true;
});
}
}

if (playerFrame) {
this.players[playerId].receiveUpdate(playerFrame.flat());
Expand Down
5 changes: 4 additions & 1 deletion src/common/squish-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,8 @@ module.exports = {
'1004': require.resolve('squish-1004'),
'1005': require.resolve('squish-1005'),
'1006': require.resolve('squish-1006'),
'1007': require.resolve('squish-1007')
'1007': require.resolve('squish-1007'),
'1008': require.resolve('squish-1008'),
'1009': require.resolve('squish-1009'),
'1010': require.resolve('squish-1010')
};
117 changes: 65 additions & 52 deletions src/dashboard/HomegamesDashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const https = require('https');
const path = require('path');
const fs = require('fs');

const { Asset, Game, ViewableGame, GameNode, Colors, ShapeUtils, Shapes, squish, unsquish, ViewUtils } = require('squish-1006');
const { Asset, Game, ViewableGame, GameNode, Colors, ShapeUtils, Shapes, squish, unsquish, ViewUtils } = require('squish-1009');

const squishMap = require('../common/squish-map');

Expand Down Expand Up @@ -227,25 +227,30 @@ const getGameMap = () => {
if (isLocal) {

const gameClass = require(gamePath);
const gameMetadata = gameClass.metadata ? gameClass.metadata() : {};

games[gameClass.name] = {
metadata: {
name: gameMetadata.name || gameClass.name,
thumbnail: gameMetadata.thumbnail,
author: gameMetadata.createdBy || 'Unknown author',
isTest: gameMetadata.isTest || false
},
versions: {
'local-game-version': {
gameId: gameClass.name,
class: gameClass,
metadata: {...gameMetadata },
gamePath,
versionId: 'local-game-version',
description: gameMetadata.description || 'No description available',
version: 0,
isReviewed: true
if (!gameClass.name || !gameClass.metadata) {
log.info('Unknown game at path ' + gamePath);
} else {
const gameMetadata = gameClass.metadata ? gameClass.metadata() : {};

games[gameClass.name] = {
metadata: {
name: gameMetadata.name || gameClass.name,
thumbnail: gameMetadata.thumbnail,
author: gameMetadata.createdBy || 'Unknown author',
isTest: gameMetadata.isTest || false
},
versions: {
'local-game-version': {
gameId: gameClass.name,
class: gameClass,
metadata: {...gameMetadata },
gamePath,
versionId: 'local-game-version',
description: gameMetadata.description || 'No description available',
version: 0,
isReviewed: true
}
}
}
}
Expand Down Expand Up @@ -322,7 +327,7 @@ class HomegamesDashboard extends ViewableGame {
return {
aspectRatio: {x: 16, y: 9},
author: 'Joseph Garcia',
squishVersion: '1006'
squishVersion: '1009'
};
}

Expand Down Expand Up @@ -682,45 +687,53 @@ class HomegamesDashboard extends ViewableGame {
if (requestedGame) {

let { gameId, versionId } = requestedGame;

networkHelper.getGameDetails(gameId).then(gameDetails => {
if (!versionId) {
if (gameDetails.versions.length > 0) {
versionId = gameDetails.versions[gameDetails.versions.length - 1].versionId;

const lowerCaseToOriginalKey = {};
Object.keys(this.localGames).forEach(k => {
lowerCaseToOriginalKey[k.toLowerCase()] = k;
});
if (lowerCaseToOriginalKey[gameId.toLowerCase()] && this.localGames[lowerCaseToOriginalKey[gameId.toLowerCase()]].versions?.['local-game-version']) {
this.showGameModalNew(playerId, lowerCaseToOriginalKey[gameId.toLowerCase()], 'local-game-version');
} else {
networkHelper.getGameDetails(gameId).then(gameDetails => {
if (!versionId) {
if (gameDetails.versions.length > 0) {
versionId = gameDetails.versions[gameDetails.versions.length - 1].versionId;
}
}
}

networkHelper.getGameVersionDetails(gameId, versionId).then(version => {
const ting = {
[gameId]: {
metadata: {
game: gameDetails,
version
},
versions: {
[versionId]: version
networkHelper.getGameVersionDetails(gameId, versionId).then(version => {
const ting = {
[gameId]: {
metadata: {
game: gameDetails,
version
},
versions: {
[versionId]: version
}
}
}
};
};

if (!this.assets[gameId]) {
const asset = new Asset({
'id': gameDetails.thumbnail,
'type': 'image'
});
if (!this.assets[gameId]) {
const asset = new Asset({
'id': gameDetails.thumbnail,
'type': 'image'
});

this.assets[gameId] = asset;
this.assets[gameId] = asset;

this.addAsset(gameId, asset).then(() => {
this.showGameModalNew(playerId, gameId, version.versionId);
});
} else {
this.showGameModalNew(playerId, gameId, version.versionId);
}
this.addAsset(gameId, asset).then(() => {
this.showGameModalNew(playerId, gameId, version.versionId);
});
} else {
this.showGameModalNew(playerId, gameId, version.versionId);
}
});
}).catch(err => {
log.error(err);
});
}).catch(err => {
log.error(err);
});
}
}
}

Expand Down
55 changes: 55 additions & 0 deletions src/games/grid-test/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
const { Asset, Colors, Game, GameNode, Shapes, ShapeUtils } = require('squish-1009');

const COLORS = Colors.COLORS;

class GridTest extends Game {
static metadata() {
return {
aspectRatio: {x: 16, y: 9},
squishVersion: '1009',
author: 'Joseph Garcia',
thumbnail: '1e844026921f7662a62ce72da869da63'
};
}

constructor() {
super();

this.base = new GameNode.Shape({
shapeType: Shapes.POLYGON,
coordinates2d: ShapeUtils.rectangle(0, 0, 100, 100)
});
}

handleNewPlayer({playerId}) {
const playerRoot = new GameNode.Shape({
shapeType: Shapes.POLYGON,
coordinates2d: ShapeUtils.rectangle(0, 0, 0, 0)
});

for (let i = 0; i < 10; i++) {
for (let j = 0; j < 10; j++) {
const node = new GameNode.Shape({
shapeType: Shapes.POLYGON,
coordinates2d: ShapeUtils.rectangle(i * 10, j * 10, 10, 10),
fill: [255, 255, 255, 255],
onHover: () => {
node.node.fill = [255, 0, 0, 255];
node.node.onStateChange();
},
onClick: () => {

}
});
playerRoot.addChild(node);
}
}
this.base.addChild(playerRoot);
}

getLayers() {
return [{root: this.base}];
}
}

module.exports = GridTest;
Loading

0 comments on commit 1e044b7

Please sign in to comment.