This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Mine Puzzle Game | |
# Created by James Jacoby, December 2018 | |
# | |
# A mine clearing game loosely based on minesweeper | |
# | |
# HOW TO PLAY: | |
# | |
# Press a key to clear a space | |
# If it's a mine, you lose | |
# Otherwise, the adjacent spaces will change color to indicate the number |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Mine Puzzle Game | |
# Created by James Jacoby, December 2018 | |
# | |
# A mine clearing game loosely based on minesweeper | |
# | |
# HOW TO PLAY: | |
# | |
# Press a key to clear a space | |
# If it's a mine, you lose | |
# Otherwise, the adjacent spaces will change color to indicate the number |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class BotClient { | |
client: Client; | |
room: Room<GameState>; | |
player: Player; | |
sessionId: string; | |
constructor(server: string | Client) { | |
this.client = server instanceof Client ? server : new Client(server); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const gameServer = new Server({ | |
gracefullyShutdown: false, | |
}); | |
registerGracefulShutdown(async (err) => { | |
console.log('shutting down...'); | |
await broadcastAll('Sorry to interrupt. Servers are restarting shortly.'); | |
await delay(10000); | |
await gameServer.gracefullyShutdown(true, err); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const PlayStateMachine = Machine( | |
{ | |
id: 'game', | |
initial: 'idle', | |
states: { | |
idle: { | |
on: { | |
INIT: 'waiting', | |
}, | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { pallet } from './pallet'; | |
import sharp from 'sharp'; | |
export async function renderCharacter(pixels: Array<number>) { | |
const width = 20; | |
const height = 20; | |
// create raw pixel buffer | |
// pixels are stored as numbers in red, green, blue, alpha format | |
// starting in top left |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import osUtils from "node-os-utils"; | |
import { matchMaker } from 'colyseus'; | |
async function getTotalConnections() { | |
const rooms = await matchMaker.query({}); | |
let total = rooms.reduce((acc, room) => { | |
return acc + room.clients; | |
}, 0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export async function beginAuthentication(email: string | null): Promise<boolean> { | |
if (!email || email.length === 0 || !email.includes('@')) { | |
throw ApiError.required('email'); | |
} | |
email = email.trim(); | |
const existingUser = await User.findOne({ email }); | |
let authKey = getRandomDigitString(4); | |
const authKeyExpiration = dateWithMinutesFromNow(10); |
OlderNewer