Skip to content

Commit

Permalink
third time lucky
Browse files Browse the repository at this point in the history
  • Loading branch information
scheibo committed Oct 28, 2023
1 parent e2f28cd commit 9e9a5fa
Show file tree
Hide file tree
Showing 39 changed files with 128 additions and 609 deletions.
3 changes: 0 additions & 3 deletions .eslintrc

This file was deleted.

22 changes: 3 additions & 19 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,14 @@
# This workflow will do an install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Tests

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [14.x]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: Zarel/setup-node@patch-1
with:
node-version: ${{ matrix.node-version }}
- uses: actions/checkout@v3
- run: npm install
- run: npm run test
env:
CI: true
- run: npm test
- run: npm run lint
26 changes: 22 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,27 @@
node_modules/
build/
# Mac
.DS_Store
Thumbs.db
.vscode

# Zig
zig-cache/
zig-out/
build/
/docgen_tmp/

# C
*.o

# JS
coverage/
node_modules/
dist/
*package-lock.json
*npm-debug.log
.eslintcache
.tsbuildinfo
.vscode
*-debug.log
.parcel-cache/

# Project
logs/
release/
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2020-2022 pkmn contributors
Copyright (c) 2020-2023 pkmn contributors

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
Expand Down
12 changes: 1 addition & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,6 @@ perspective of the client. EPOké is designed to be useful in many domains, expo
information from replays, extending the Pokémon Showdown client tooltips/UI, or inside the engine
of a Pokemon AI.

- [`@pkmn/epoke`](epoke): a wrapper around
[`@pkmn/client`](https://github.com/pkmn/ps/tree/master/client) which ties together `@pkmn/gmd`,
`@pkmn/predictor` and `@pkmn/spreads` to produce an enhanced client representation of a battle
- [`@pkmn/gmd`](gmd): a reverse damage calculator built on top of
[`@pkmn/dmg`](https://github.com/pkmn/dmg) to deduce information about a Pokémon's moveset based
on the damage it deals or receives in battle
- [`@pkmn/predictor`](predictor): logic which combines usage stats information from
[`@pkmn/stats`](https://github.com/pkmn/stats) with minimal heuristics to predict likely instances
of an opponent's team
- [`@pkmn/spreads`](spreads): a lightweight, standalone package for manipulating and displaying
stats, spreads, and ranges
TODO

Everything in this repository is distributed under the terms of the [MIT License](LICENSE).
53 changes: 2 additions & 51 deletions epoke/README.md
Original file line number Diff line number Diff line change
@@ -1,67 +1,18 @@
<p align="center"><img alt="EPOké" width="364" height="148" src="https://pkmn.cc/EPOke.png" /></p>

# `@pkmn/epoke`

![Test Status](https://github.com/pkmn/EPOke/workflows/Tests/badge.svg)
![License](https://img.shields.io/badge/License-MIT-blue.svg)

`@pkmn/epoke` extends [`@pkmn/client`](https://github.com/pkmn/ps/tree/master/client) with
information from [`@pkmn/gmd`](../gmd), [`@pkmn/predictor`](../predictor), and
[`@pkmn/spreads`](../spreads) to produce an enhanced client representation of a Pokémon battle.
EPOké offers several key features over `@pkmn/client`:

- **spread information**: `@pkmn/client` can determine information about a side's `stats` from the
`|request|` protocol message and provides support for setting a side's `sets` to known values so
that its state can be used with [`@pkmn/dmg`](https://github.com/pkmn/dmg) in a limited number of
circumstances, but with EPOké `@pkmn/dmg` can *always* be used as it can additionally:
- reverse the `stats` from `|request|` into a spread using `@pkmn/spreads`
- track the `StatsRange` for a Pokémon, winnow it down with information from `@pkmn/gmd`, and
finally, return the most likely estimate for the spread with help from `@pkmn/predictor` and
usage stats
- allow for a user to override predicted values for stats (while still maintaining accurate tracking)
- **inferred state**: EPOké leverages `@pkmn/gmd` to deduce information about the battle state (eg.
an opponent Pokémon's item or ability) on top of what is already known from `@pkmn/client`
- **possible state instantiation**: EPOké provides the ability to generate possible instantiations
of the simulator's [`State`](https://github.com/pkmn/ps/blob/master/sim/sim/state.ts) using the
information it has collected and with help from `@pkmn/predictor` and usage stats

If information in battle can be determined conclusively and without the help of anything in this
repository it is in scope for `@pkmn/client`, everything else is the domain of `@pkmn/epoke`.

TODO
## Installation

```sh
$ npm install @pkmn/epoke
```

Alternatively, as [detailed below](#browser), if you are using `@pkmn/epoke` in the browser and
want a convenient way to get started, simply depend on a transpiled and minified version via
[unpkg](https://unpkg.com/):

```html
<script src="https://unpkg.com/@pkmn/epoke"></script>
```

## Usage

FIXME

```ts
```

### Browser

The recommended way of using `@pkmn/epoke` in a web browser is to **configure your bundler**
([Webpack](https://webpack.js.org/), [Rollup](https://rollupjs.org/),
[Parcel](https://parceljs.org/), etc) to minimize it and package it with the rest of your
application. If you do not use a bundler, a minified `index.umd.js` bundle is included in the
package. You simply need to depend on `./node_modules/@pkmn/epoke/build/index.umd.js` in a
`script` tag (which is what the unpkg shortcut above is doing), after which **`epoke` will be
accessible as a global**:

```html
<script src="./node_modules/@pkmn/epoke/build/index.umd.js"></script>
```
TODO

## License

Expand Down
40 changes: 6 additions & 34 deletions epoke/package.json
Original file line number Diff line number Diff line change
@@ -1,53 +1,25 @@
{
"name": "@pkmn/epoke",
"version": "0.0.1",
"main": "build/index.js",
"types": "build/index.d.ts",
"description": "Enhanced client representation of a Pokémon battle",
"repository": "github:pkmn/EPOke",
"license": "MIT",
"sideEffects": false,
"main": "build/index.js",
"module": "build/index.mjs",
"types": "build/index.d.ts",
"files": ["build"],
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pkmn/client": "^0.6.0",
"@pkmn/data": "^0.7.0",
"@pkmn/protocol": "^0.6.0",
"@pkmn/spreads": "^0.1.0"
"@pkmn/spreads": "file:../spreads"
},
"scripts": {
"lint": "eslint --cache src --ext ts",
"fix": "eslint --fix src --ext ts",
"compile": "tsc -p .",
"build": "npm run compile && tsup src/index.ts",
"test": "jest",
"prepare": "npm run build",
"pretest": "npm run build",
"posttest": "npm run lint"
},
"tsup": {
"outDir": "build",
"format": ["cjs", "esm"],
"sourcemap": true,
"dts": true,
"clean": true
},
"jest": {
"preset": "ts-jest",
"testEnvironment": "node",
"testPathIgnorePatterns": ["node_modules/", "build/"]
"build": "npm run compile",
"test": "vitest src"
},
"eslintConfig": {
"extends": "@pkmn",
"ignorePatterns": ["node_modules/", "build/"],
"overrides": [{
"files": ["src/index.ts"],
"rules": {
"@typescript-eslint/no-shadow": "off"
}
}]
"extends": "@pkmn"
}
}
74 changes: 0 additions & 74 deletions epoke/src/client.ts

This file was deleted.

File renamed without changes.
70 changes: 0 additions & 70 deletions epoke/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,70 +0,0 @@
import {BoostsTable, ID, StatsTable, StatusName, TypeName} from '@pkmn/data';

export type Slot = 1 | 2 | 3 | 4 | 5 | 6;
export type Battle = Gen1.Battle;
export type Side = Gen1.Side;
export type Pokemon = Gen1.Pokemon;
export type MoveSlot = Gen1.MoveSlot;

export namespace Gen1 {
export interface Battle {
sides: Iterable<Side>;
turn: number;
lastDamage: number;
prng: readonly number[];
}

export interface Side {
active: Pokemon | undefined;
pokemon: Iterable<Pokemon>;
lastUsedMove: ID | undefined;
lastSelectedMove: ID | undefined;
lastSelectedIndex: 1 | 2 | 3 | 4 | undefined;
}

export interface Pokemon {
species: ID;
types: readonly [TypeName, TypeName];
level: number;
hp: number;
status: StatusName | undefined;
statusData: {sleep: number; self: boolean; toxic: number};
stats: StatsTable;
boosts: BoostsTable;
moves: Iterable<MoveSlot>;
volatiles: Volatiles;
stored: {
species: ID;
types: readonly [TypeName, TypeName];
stats: StatsTable;
moves: Iterable<Omit<MoveSlot, 'disabled'>>;
};
position: Slot;
}

export interface MoveSlot {
id: ID;
pp: number;
disabled?: number;
}

export interface Volatiles {
bide?: {duration: number; damage: number};
thrashing?: {duration: number; accuracy: number};
multihit?: unknown;
flinch?: unknown;
charging?: unknown;
trapping?: {duration: number};
invulnerable?: unknown;
confusion?: {duration: number};
mist?: unknown;
focusenergy?: unknown;
substitute?: {hp: number};
recharging?: unknown;
rage?: {accuracy: number};
leechseed?: unknown;
lightscreen?: unknown;
reflect?: unknown;
transform?: {player: 'p1' | 'p2'; slot: number};
}
}
Loading

0 comments on commit 9e9a5fa

Please sign in to comment.