Skip to content

Commit

Permalink
refactor: fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
vinceau committed Apr 13, 2021
1 parent baf8ec7 commit 3b96473
Show file tree
Hide file tree
Showing 18 changed files with 75 additions and 54 deletions.
16 changes: 8 additions & 8 deletions src/SlippiGame.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import _ from "lodash";
import { openSlpFile, closeSlpFile, iterateEvents, getMetadata, SlpInputSource, SlpReadInput } from "./utils/slpReader";

// Type imports
import { MetadataType, GameStartType, GameEndType, FrameEntryType, FramesType } from "./types";
import { SlpParser, SlpParserEvent } from "./utils/slpParser";
import {
StockComputer,
ComboComputer,
ActionsComputer,
ComboComputer,
ConversionComputer,
generateOverallStats,
InputComputer,
StatOptions,
Stats,
StatsType,
generateOverallStats,
StatOptions,
StockComputer,
} from "./stats";
// Type imports
import { FrameEntryType, FramesType, GameEndType, GameStartType, MetadataType } from "./types";
import { SlpParser, SlpParserEvent } from "./utils/slpParser";
import { closeSlpFile, getMetadata, iterateEvents, openSlpFile, SlpInputSource, SlpReadInput } from "./utils/slpReader";

/**
* Slippi Game class that wraps a file
Expand Down
7 changes: 3 additions & 4 deletions src/console/consoleConnection.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import net from "net";
import { EventEmitter } from "events";

import net from "net";
import inject from "reconnect-core";

import { ConsoleCommunication, CommunicationType, CommunicationMessage } from "./communication";
import { ConnectionDetails, Connection, ConnectionStatus, Ports, ConnectionSettings, ConnectionEvent } from "./types";
import { CommunicationMessage, CommunicationType, ConsoleCommunication } from "./communication";
import { Connection, ConnectionDetails, ConnectionEvent, ConnectionSettings, ConnectionStatus, Ports } from "./types";

export const NETWORK_MESSAGE = "HELO\0";

Expand Down
3 changes: 2 additions & 1 deletion src/console/dolphinConnection.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { EventEmitter } from "events";
import { Connection, ConnectionStatus, ConnectionSettings, ConnectionDetails, Ports, ConnectionEvent } from "./types";

import { Connection, ConnectionDetails, ConnectionEvent, ConnectionSettings, ConnectionStatus, Ports } from "./types";

const MAX_PEERS = 32;

Expand Down
2 changes: 1 addition & 1 deletion src/console/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export * from "./types";
export * from "./consoleConnection";
export * from "./dolphinConnection";
export * from "./types";
5 changes: 3 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,20 @@ import { SlippiGame } from "./SlippiGame";
export * from "./melee";

// Export types
export * from "./types";
export * from "./stats";
export * from "./types";

// Utils
export * from "./utils/slpFile";
export * from "./utils/slpFileWriter";
export * from "./utils/slpStream";
export * from "./utils/slpParser";
export * from "./utils/slpStream";

// Console networking
export * from "./console";

// Support both named and default exports
export * from "./SlippiGame";

// eslint-disable-next-line import/no-default-export
export default SlippiGame;
3 changes: 2 additions & 1 deletion src/stats/actions.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import _ from "lodash";
import { State, ActionCountsType } from "./common";

import { FrameEntryType, GameStartType } from "../types";
import { ActionCountsType, State } from "./common";
import { StatComputer } from "./stats";

// Frame pattern that indicates a dash dance turn was executed
Expand Down
16 changes: 9 additions & 7 deletions src/stats/combos.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import _ from "lodash";
import { FrameEntryType, FramesType, PostFrameUpdateType, GameStartType } from "../types";
import { MoveLandedType, ComboType } from "./common";

import { FrameEntryType, FramesType, GameStartType, PostFrameUpdateType } from "../types";
import {
calcDamageTaken,
ComboType,
didLoseStock,
isCommandGrabbed,
isDamaged,
isDead,
isDown,
isGrabbed,
isCommandGrabbed,
calcDamageTaken,
isTeching,
didLoseStock,
MoveLandedType,
Timers,
isDown,
isDead,
} from "./common";
import { StatComputer } from "./stats";

Expand Down
1 change: 1 addition & 0 deletions src/stats/common.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import _ from "lodash";

import { PostFrameUpdateType } from "../types";

export interface StatsType {
Expand Down
14 changes: 12 additions & 2 deletions src/stats/conversions.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
import _ from "lodash";

import { FrameEntryType, FramesType, GameStartType, PostFrameUpdateType } from "../types";
import { MoveLandedType, ConversionType } from "./common";
import { isDamaged, isGrabbed, isCommandGrabbed, calcDamageTaken, isInControl, didLoseStock, Timers } from "./common";
import {
calcDamageTaken,
ConversionType,
didLoseStock,
isCommandGrabbed,
isDamaged,
isGrabbed,
isInControl,
MoveLandedType,
Timers,
} from "./common";
import { StatComputer } from "./stats";

interface PlayerConversionState {
Expand Down
9 changes: 4 additions & 5 deletions src/stats/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
export * from "./common";

export { ActionsComputer } from "./actions";
export { ConversionComputer } from "./conversions";
export { ComboComputer } from "./combos";
export { StockComputer } from "./stocks";
export * from "./common";
export { ConversionComputer } from "./conversions";
export { InputComputer } from "./inputs";
export { Stats, StatComputer, StatOptions } from "./stats";
export { generateOverallStats } from "./overall";
export { StatComputer, StatOptions, Stats } from "./stats";
export { StockComputer } from "./stocks";
2 changes: 1 addition & 1 deletion src/stats/inputs.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import _ from "lodash";
import { FramesType, FrameEntryType, Frames, GameStartType } from "../types";

import { FrameEntryType, Frames, FramesType, GameStartType } from "../types";
import { StatComputer } from "./stats";

enum JoystickRegion {
Expand Down
11 changes: 8 additions & 3 deletions src/stats/overall.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import _ from "lodash";

import { GameStartType } from "../types";
import { ConversionType, StockType, OverallType, RatioType, InputCountsType } from "./common";
import { ConversionType, InputCountsType, OverallType, RatioType, StockType } from "./common";
import { PlayerInput } from "./inputs";

interface ConversionsByPlayerByOpening {
Expand Down Expand Up @@ -61,9 +62,13 @@ export function generateOverallStats(
// const opponentEndedStocks = _.filter(opponentStocks, "endFrame");

originalConversions.reduce((accum, conversion) => {
if (conversion.playerIndex === playerIndex) return totalDamage;
if (conversion.playerIndex === playerIndex) {
return totalDamage;
}
conversionCount++;
if (conversion.moves.length > 1) successfulConversionCount++;
if (conversion.moves.length > 1) {
successfulConversionCount++;
}
conversion.moves.forEach((move) => {
totalDamage += move.damage;
if (conversion.didKill && conversion.lastHitBy === playerIndex) {
Expand Down
2 changes: 1 addition & 1 deletion src/stats/stocks.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import _ from "lodash";

import { isDead, didLoseStock, StockType } from "./common";
import { FrameEntryType, FramesType, GameStartType } from "../types";
import { didLoseStock, isDead, StockType } from "./common";
import { StatComputer } from "./stats";

interface StockState {
Expand Down
5 changes: 3 additions & 2 deletions src/utils/slpFile.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { get, forEach } from "lodash";
import fs, { WriteStream } from "fs";
import { forEach, get } from "lodash";
import moment, { Moment } from "moment";
import { Writable, WritableOptions } from "stream";
import { SlpStream, SlpStreamMode, SlpStreamEvent, SlpCommandEventPayload } from "./slpStream";

import { Command, PostFrameUpdateType } from "../types";
import { SlpCommandEventPayload, SlpStream, SlpStreamEvent, SlpStreamMode } from "./slpStream";

const DEFAULT_NICKNAME = "unknown";

Expand Down
8 changes: 4 additions & 4 deletions src/utils/slpFileWriter.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import path from "path";
import moment, { Moment } from "moment";
import path from "path";
import { WritableOptions } from "stream";

import { SlpFile } from "./slpFile";
import { SlpStream, SlpStreamEvent, SlpRawEventPayload, SlpStreamSettings } from "./slpStream";
import { Command } from "../types";
import { WritableOptions } from "stream";
import { SlpFile } from "./slpFile";
import { SlpRawEventPayload, SlpStream, SlpStreamEvent, SlpStreamSettings } from "./slpStream";

/**
* The default function to use for generating new SLP files.
Expand Down
16 changes: 8 additions & 8 deletions src/utils/slpParser.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import { EventEmitter } from "events";
import _ from "lodash";
import semver from "semver";

import {
PostFrameUpdateType,
GameStartType,
GameEndType,
Command,
PreFrameUpdateType,
ItemUpdateType,
FrameBookendType,
GameMode,
FrameEntryType,
FramesType,
Frames,
FramesType,
GameEndType,
GameMode,
GameStartType,
ItemUpdateType,
PostFrameUpdateType,
PreFrameUpdateType,
} from "../types";
import { EventEmitter } from "events";

export const MAX_ROLLBACK_FRAMES = 7;

Expand Down
6 changes: 3 additions & 3 deletions src/utils/slpReader.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import _ from "lodash";
import { decode } from "@shelacek/ubjson";
import fs from "fs";
import iconv from "iconv-lite";
import { decode } from "@shelacek/ubjson";
import _ from "lodash";

import { toHalfwidth } from "./fullwidth";
import {
Command,
EventCallbackFunc,
Expand All @@ -12,6 +11,7 @@ import {
PlayerType,
SelfInducedSpeedsType,
} from "../types";
import { toHalfwidth } from "./fullwidth";

export enum SlpInputSource {
BUFFER = "buffer",
Expand Down
3 changes: 2 additions & 1 deletion src/utils/slpStream.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Writable, WritableOptions } from "stream";

import { NETWORK_MESSAGE } from "../console";
import { Command, EventPayloadTypes } from "../types";
import { parseMessage } from "./slpReader";
import { NETWORK_MESSAGE } from "../console";

export enum SlpStreamMode {
AUTO = "AUTO", // Always reading data, but errors on invalid command
Expand Down

0 comments on commit 3b96473

Please sign in to comment.