Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

salien-script-js

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

salien-script-js - npm Package Compare versions

Comparing version 0.0.16 to 0.0.17

2

package.json
{
"name": "salien-script-js",
"version": "0.0.16",
"version": "0.0.17",
"description": "A easy to install, run and update Node.js script for the Steam salien mini-game.",

@@ -5,0 +5,0 @@ "keywords": [

@@ -60,3 +60,3 @@ /**

this.steamThinksPlanet = null;
this.skippedPlanets = [];
this.lastKnownPlanetId = null;

@@ -71,2 +71,3 @@ // script variables that don't get reset

this.cutoff = 0.99;
this.defaultAllowedBossFails = 10;
}

@@ -79,3 +80,3 @@

this.steamThinksPlanet = null;
this.skippedPlanets = [];
this.lastKnownPlanetId = null;
}

@@ -137,2 +138,6 @@

if (playerInfo.active_boss_game) {
await this.apiLeaveGame(playerInfo.active_boss_game);
}
if (playerInfo.active_zone_game) {

@@ -207,13 +212,18 @@ await this.apiLeaveGame(playerInfo.active_zone_game);

async playBossZone() {
const min = 120;
const max = 180;
const defaultAllowedFailures = 10;
const healMin = 0;
const healMax = 120;
let nextHeal = Math.floor(new Date().getTime() / 1000) + Math.floor(Math.random() * (max - min + 1) + min);
let allowedBossFails = defaultAllowedFailures;
// Avoid first time not sync error
await delay(4000);
let allowedBossFails = this.defaultAllowedBossFails;
let nextHeal = Number.MAX_SAFE_INTEGER;
let waitingForPlayers = true;
const oldPlayerInfo = await this.apiGetPlayerInfo();
// eslint-disable-next-line no-constant-condition
while (true) {
let useHeal = 0;
const damageToBoss = 1;
const damageToBoss = waitingForPlayers ? 0 : 1;
const damageTaken = 0;

@@ -225,3 +235,3 @@

this.logger('@@ Boss -- Using heal ability');
this.logger(chalk.green('@@ Boss -- Using heal ability'));
}

@@ -232,2 +242,7 @@

// eslint-disable-next-line no-underscore-dangle
if (Number(report.___headers.get('x-eresult')) === 11) {
throw new SalienScriptRestart('Recieved invalid boss state!');
}
// eslint-disable-next-line no-underscore-dangle
if (Number(report.___headers.get('x-eresult')) !== 1 && Number(report.___headers.get('x-eresult')) !== 93) {

@@ -237,3 +252,5 @@ allowedBossFails -= 1;

if (allowedBossFails < 1) {
throw new SalienScriptRestart('Boss battle had too many errors!');
this.logger(chalk.green('@@ Boss -- Battle had too many errors!'));
break;
}

@@ -243,8 +260,20 @@ }

// if we didn't get an error, reset the allowed failure count
allowedBossFails = defaultAllowedFailures;
allowedBossFails = this.defaultAllowedBossFails;
if (report.waiting_for_players) {
this.logger(chalk.green('@@ Boss -- Waiting for players...'));
await delay(this.defaultDelayMs);
continue; // eslint-disable-line no-continue
} else if (waitingForPlayers) {
waitingForPlayers = false;
nextHeal =
Math.floor(new Date().getTime() / 1000) + Math.floor(Math.random() * (healMax - healMin + 1) + healMin);
}
if (!report.boss_status) {
this.logger('@@ Boss -- Waiting...');
await delay(3000);
await delay(this.defaultDelayMs);

@@ -257,6 +286,5 @@ continue; // eslint-disable-line no-continue

// TODO: format player name better so it doesn't screw up our neat output
report.boss_status.boss_players.forEach(player => {
let scoreCard = ` ${`${player.name}`.padEnd(30)}`;
// eslint-disable-next-line no-control-regex
let scoreCard = ` ${`${player.name.replace(/[^\x00-\x7F]/g, '')}`.padEnd(30)}`;
scoreCard += ` - HP: ${chalk.yellow(`${player.hp}`.padStart(6))} / ${`${player.max_hp}`.padStart(6)}`;

@@ -271,12 +299,5 @@ scoreCard += ` - XP Gained: ${chalk.yellow(`${Number(player.xp_earned).toLocaleString()}`.padStart(12))}`;

if (report.game_over) {
this.logger('@@ Boss -- The battle is over!');
throw new SalienScriptRestart('Boss battle is over!');
}
this.logger(chalk.green('@@ Boss -- The battle has ended!'));
if (report.waiting_for_players) {
this.logger('@@ Boss -- Waiting for players...');
await delay(3000);
continue; // eslint-disable-line no-continue
break;
}

@@ -292,48 +313,31 @@

await delay(this.defaultDelayMs);
console.log(''); // eslint-disable-line no-console
}
}
async doGameLoop() {
let leaveAttempts = 0;
const newPlayerInfo = await this.apiGetPlayerInfo();
while (this.currentPlanetAndZone.id !== this.steamThinksPlanet) {
if (leaveAttempts > 3) {
throw new SalienScriptRestart('Unable to leave planet...');
}
if (newPlayerInfo.score) {
const newXp = Number(newPlayerInfo.score) - Number(oldPlayerInfo.score);
this.steamThinksPlanet = await this.leaveCurrentGame(this.currentPlanetAndZone.id);
let bossReport = `++ Your score after boss battle:`;
bossReport += ` ${chalk.yellow(Number(newPlayerInfo.score).toLocaleString())}`;
bossReport += ` (+ ${chalk.yellow(`${newXp.toLocaleString()}`)} XP)`;
bossReport += ` - Current Level: ${chalk.green(newPlayerInfo.level)}`;
if (this.currentPlanetAndZone.id !== this.steamThinksPlanet) {
await this.apiJoinPlanet(this.currentPlanetAndZone.id);
this.steamThinksPlanet = await this.leaveCurrentGame();
}
leaveAttempts += 1;
this.logger(bossReport);
}
let zone;
if (this.currentPlanetAndZone.bestZone.boss_active) {
zone = await this.apiJoinBossZone(this.currentPlanetAndZone.bestZone.zone_position);
// eslint-disable-next-line no-underscore-dangle
if (Number(zone.___headers.get('x-eresult')[0]) !== 1) {
throw new SalienScriptRestart('!! Failed to join boss zone', zone);
}
await this.playBossZone();
return;
if (newPlayerInfo.active_boss_game) {
await this.apiLeaveGame(newPlayerInfo.active_boss_game);
}
zone = await this.apiJoinZone(this.currentPlanetAndZone.bestZone.zone_position);
// rescan if we failed to join
if (!zone.zone_info) {
throw new SalienScriptRestart('!! Failed to join a zone', zone);
if (newPlayerInfo.active_planet) {
await this.apiLeaveGame(newPlayerInfo.active_planet);
}
}
const zoneInfo = zone.zone_info;
async playNormalZone(zone) {
const { zone_info: zoneInfo } = zone;

@@ -404,3 +408,50 @@ const zoneCapturePercent = getPercentage(zoneInfo.capture_progress);

async doGameLoop() {
if (!this.currentPlanetAndZone) {
await this.doGameSetup();
}
if (this.lastKnownPlanetId !== this.currentPlanetAndZone.id) {
while (this.currentPlanetAndZone.id !== this.steamThinksPlanet) {
this.steamThinksPlanet = await this.leaveCurrentGame(this.currentPlanetAndZone.id);
if (this.currentPlanetAndZone.id !== this.steamThinksPlanet) {
await this.apiJoinPlanet(this.currentPlanetAndZone.id);
this.steamThinksPlanet = await this.leaveCurrentGame();
}
}
this.lastKnownPlanetId = this.currentPlanetAndZone.id;
}
let zone;
// if the best zone is a boss zone
if (this.currentPlanetAndZone.bestZone.boss_active) {
zone = await this.apiJoinBossZone(this.currentPlanetAndZone.bestZone.zone_position);
// eslint-disable-next-line no-underscore-dangle
if (Number(zone.___headers.get('x-eresult')) !== 1) {
throw new SalienScriptRestart('!! Failed to join boss zone', zone);
}
await this.playBossZone();
return;
}
// otherwise we're in a normal zone and play the game normally
zone = await this.apiJoinZone(this.currentPlanetAndZone.bestZone.zone_position);
if (!zone.zone_info) {
throw new SalienScriptRestart('!! Failed to join a zone', zone);
}
await this.playNormalZone(zone);
}
async init() {
this.resetScript();
this.startTime = new Date().getTime();

@@ -414,4 +465,2 @@

this.resetScript();
try {

@@ -418,0 +467,0 @@ await this.doClanSetup();

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc