Welcome to SkidInc
Relevant source files
The following files were used as context for generating this wiki page:SkidInc is an idle game with a hacking theme, where players interact with the game primarily through a command-line interface. The game is built using web technologies (HTML, CSS, JavaScript) and is packaged as a desktop application using Electron. This allows it to run on Windows, macOS, and Linux, providing features like automatic updates and a local save system that enhances the web-based version. The core gameplay revolves around executing "scripts" to earn money and experience, upgrading servers, and progressing through levels.
The project includes a comprehensive set of scripts for automating the build, packaging, and deployment processes. It features a modular JavaScript structure for game logic, a detailed tutorial for new players, and a robust save management system for the Electron version to handle player progress seamlessly.
Sources: package.json:3-4, app/js/tutorial.js:10, ELECTRON-SETUP.md, scripts/README.md:3
Project Architecture
The application is composed of two main parts: the core web game logic and the Electron wrapper that provides desktop integration.
- Web Game (
app/): Contains the HTML, CSS, and JavaScript files that constitute the game itself. This includes modules for the console, game loop, player stats, scripts, and more. - Electron Shell (
src/): Contains the source code for the Electron main and renderer processes. This part handles window creation, application menus, and native functionalities like the save system. - Build System (
scripts/): A collection of Node.js scripts for automating builds for multiple platforms, creating releases, and managing deployments.
This diagram illustrates the high-level architecture of the SkidInc project.
Game Core & Loop
The heart of the game is a central skidinc object and a game loop that runs at a defined frame rate.
Sources: app/js/core.js
Core Object
The global skidinc object serves as the main namespace for all game modules, including console, script, player, tutorial, and more. It also manages the main game loop.
skidinc.fps: Set to 20, defining the game's update frequency.skidinc.interval: Calculated as1000 / skidinc.fps, resulting in an update every 50ms.skidinc.version: The current version of the game, e.g.,0.33.
Sources: app/js/core.js:2-4
Game Loop
The game loop is initiated by skidinc.init() and managed by skidinc.core(). It calculates the time elapsed since the last frame to determine how many update cycles (times) to run, ensuring consistent game progression regardless of minor performance fluctuations.
The skidinc.update(times) function is called on each cycle, which in turn calls the loop() function of various game modules like script, autoscript, and battery.
This flowchart shows the execution flow of the main game loop.
Sources: app/js/core.js:10-18, 49-56
Console Interface
The primary way a user interacts with SkidInc is through a simulated terminal. The skidinc.console module is responsible for parsing commands, displaying output, and managing command history.
Sources: app/js/console.js
Available Commands
The game features several commands for different actions.
| Command | Description | Arguments |
|---|---|---|
help | Shows a list of available commands. | None |
clear | Removes all logs from the terminal. | None |
username | Sets the player's username during the tutorial. | [yourUsername] |
script | Executes a script. Supports -l/-list and -h/-help. | [script_name] |
buy | Buys scripts, auto-scripts, and servers. Supports -l/-list. | [item_name] |
option | Changes in-game options. | [option] [value] |
achievements | Shows the player's achievements. | None |
Sources: app/js/console.js:15-80
Command Parsing
The skidinc.console.parse() function is triggered when the user submits a command. It validates the input, checks if the command exists, and routes the command and its arguments to the appropriate handler function.
This diagram shows the logic for parsing a user-entered command.
Sources: app/js/console.js:140-218
Tutorial System
New players are guided through an interactive tutorial managed by the skidinc.tutorial module. The tutorial is a state machine that progresses through several steps, introducing core game mechanics.
- Step 0: Introduction and prompts the user to set a username with the
usernamecommand. - Step 1: Instructs the user to use the
helpcommand. - Step 2: Explains the
scriptcommand for earning money and experience. - Step 3: Completes the tutorial, and the full game is unlocked.
The tutorial can be skipped, and it is automatically disabled when a saved game is loaded.
Sources: app/js/tutorial.js:1-74, src/renderer/save-manager.js:410-413
Build and Deployment
The project contains a sophisticated set of scripts to automate the building and deployment of the Electron application for Windows, macOS, and Linux.
Sources: scripts/README.md, scripts/build-all.js, scripts/deploy.js
NPM Scripts
Several npm scripts are configured in package.json to streamline the development and release workflow.
| Script | Description |
|---|---|
npm run electron | Starts the production Electron app. |
npm run electron-dev | Starts the app in development mode with DevTools. |
npm run build:automated | Runs the automated build script for all platforms. |
npm run build:win | Builds the application for Windows. |
npm run build:mac | Builds the application for macOS. |
npm run build:linux | Builds the application for Linux. |
npm run deploy | Packages build artifacts for distribution. |
npm run release | Runs the full build and deploy process. |
Sources: package.json:13-35
Build & Deploy Pipeline
The release process is handled by two main scripts: build-all.js and deploy.js.
build-all.js: Compiles the application for target platforms (win,mac,linux) usingelectron-builder. It includes features like environment validation, retry logic, and build reporting.deploy.js: Takes the artifacts from the build output directory (dist/), organizes them into a versioned release directory, calculates checksums, generates release notes, and creates a final release archive.
This diagram shows the automated release pipeline.
Electron Integration & Save System
For the desktop version, the web game is enhanced with native features provided by Electron. The most significant feature is a robust local save system, managed by the SaveStateManager class.
Sources: src/renderer/save-manager.js, index.html:412
SaveStateManager
The SaveStateManager class, loaded in index.html, acts as the bridge between the game's state and the Electron main process. It communicates with the main process via a preload script (preload.js) that exposes a secure window.electronAPI.
Key responsibilities include:
- Initializing the auto-save system.
- Automatically loading the latest save on startup.
- Monitoring the game state for changes and notifying the main process.
- Handling manual save/load requests from the application menu.
- Applying loaded game state and ensuring the tutorial is disabled.
Sources: src/renderer/save-manager.js:5-34, 73-95, 126-155
Save/Load Sequence
The following diagram illustrates the sequence of events when a user loads a game, either automatically on startup or manually.
Upon loading a save, the ensureTutorialCompleted() method is called to forcefully disable the tutorial interface and logic, allowing the player to jump directly into their saved game state.
Sources: src/renderer/save-manager.js:568-636