0.4.0 • Published 9 months ago

@elschnagoo/local-games v0.4.0

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

Local-Games

NPM Version NPM Downloads

Read local game launcher config files and launch games

Features

  • Read local game launcher config files
  • Get game info
  • Get game image
  • Get game executable
  • Open Game Launcher
  • Install game (partial steam, epic)
  • Open shop page (partial steam, epic)

Currently supported launchers

Docs

Quickstart

Install

Install the package via npm

npm install @elschnagoo/local-games
import { LocalGames, BattleNetLauncher, EpicLauncher, SteamLauncher, UplayLauncher, } from '@elschnagoo/local-games';

(async () => {
    const localGames = new LocalGames();

    // Register a launcher [Battle.net, Epic Games, Steam, Uplay] @see docs for more info
    const report = await localGames.registerLauncher(
        new BattleNetLauncher(),
        new EpicLauncher(),
        new UplayLauncher(),
        new SteamLauncher({
            apiKey: '$STEAM_WEB_API_KEY', // get on https://steamcommunity.com/dev/apikey
            steamVanity: '$STEAM_USER_VANITY', // Show on your steam profile
        })
    );

    if (report.success) {
        console.log('All Launchers registered successfully');
    } else {
        report.result.forEach(([name, success]) => {
            if (!success) {
                console.log(`${name} failed to register`);
            }
        });
    }

    const games = await localGames.getGames();

    const [game] = games;

    console.log('Game Name', game.name);
    console.log('Game is on Wishlist', game.wishList);
    console.log('Game is installed', game.installed);

    // ...

    // Returns the executable path or protocol link
    const cmd = await game.getLauncherCMD();
    console.log(cmd);
    // Returns the shop cmd if exist
    const shop = await game.getOpenShopCMD();
    console.log(shop);
    // Returns a default command to  "Start Game" > "Install" > "Open Shop"
    const def = await game.defaultCMD();
    console.log(def);

    // Returns the game image as base64 encoded string (webp)
    const images = await game.getGameImageBase64(false);
    console.log(images?.portrait);

    // ... pop child process with cmd to start the game from nodejs
    // import * as child_process from 'child_process';
    // if (def) child_process.exec(def);
})();
0.4.0

9 months ago

0.3.4

9 months ago

0.3.3

9 months ago

0.3.2

9 months ago

0.3.1

9 months ago

0.1.0

9 months ago

0.0.2

9 months ago