Giter VIP home page Giter VIP logo

local-games's Introduction

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);
})();

local-games's People

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.