Skip to content

Commit

Permalink
Merge branch 'main' of github.com:treasure-chess/chess-achievements i…
Browse files Browse the repository at this point in the history
…nto main
  • Loading branch information
pi0neerpat committed Dec 13, 2021
2 parents 3625317 + 8b62b80 commit bf4fec5
Show file tree
Hide file tree
Showing 15 changed files with 3,130 additions and 3,101 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/ci-canary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ jobs:
key: node_modules_${{ hashFiles('**/yarn.lock') }}
- name: Install dependencies
run: yarn install --frozen-lockfile
# No build step necessary, but this is where it would go
- name: Test
run: yarn test
# No build step necessary, but this is where it would go
- name: Setup canary package versions locally
run: |
shortRev=$(git rev-parse --short ${{ github.sha }})
Expand All @@ -39,5 +41,5 @@ jobs:
tasks/npmrc-use-npmjs.sh > .npmrc
tasks/npm-publish.sh . dev
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PAT: ${{ secrets.PAT }}
NPMJS_TOKEN: ${{ secrets.NPMJS_TOKEN }}
6 changes: 3 additions & 3 deletions .github/workflows/create-pr-artifact.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ jobs:
if: env.PUBLISH_PR_ARTIFACT == 1
run: yarn install --frozen-lockfile

# - name: Build
# if: env.PUBLISH_PR_ARTIFACT == 1
# run: yarn build
- name: Test
if: env.PUBLISH_PR_ARTIFACT == 1
run: yarn test

- name: Setup PR package versions locally
if: env.PUBLISH_PR_ARTIFACT == 1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ jobs:
Install this PR (you need to setup Github packages):
```bash
yarn add @treasure-chess/chess-acheivements@PR${{ steps.pr.outputs.pr_number }}
yarn add @treasure-chess/chess-achievements@PR${{ steps.pr.outputs.pr_number }}
```
<details><summary>:octocat: Click to learn how to use Github packages</summary>
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-release-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ jobs:
if: env.PUBLISH == 1
run: tasks/npm-publish.sh . latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PAT: ${{ secrets.PAT }}
NPMJS_TOKEN: ${{ secrets.NPMJS_TOKEN }}
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021 TreasureChess
Copyright (c) 2021 Nifty Chess, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
178 changes: 90 additions & 88 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,101 +28,103 @@ npm i @treasure-chess/chess-achievements
- `playerColor` - Either "white" or "black".

```js
import achievementsCalculator from "@treasure-chess/chess-achievements";

const { opening, achievements, score } = achievementsCalculator(
pgn,
playerColor
);
import achievementsCalculator from '@treasure-chess/chess-achievements';

const {
opening,
score,
achievements,
allAchievements
} = achievementsCalculator(pgn, playerColor);
```

#### Returns:

- `opening` - See `/eco-codes.json` for the full list.
- `achievements` - Top 3 achievements earned by `playerColor`.
- `score` - Sum of points for the top 3 achievements earned by `playerColor`.
- `achievements` - Top 3 achievements earned by `playerColor`.
- `allAchievements` - All achievements earned by `playerColor`.

## Achievements and Tested Sample PGNs
|number|name |description |points|
|------|------------------|---------------------------------------------------|------|
|0 |Winner |Win a game |2 |
|1 |Player |Play a game |1 |
|2 |750+ Winner |Win a game against opponent rated 750+ |2 |
|3 |Played 750+ |Play a game against opponent rated 750+ |1 |
|4 |1500+ Winner |Win a game against opponent rated 1500+ |3 |
|5 |Played 1500+ |Play a game against opponent rated 1500+ |2 |
|6 |Played 2000+ |Play a game against opponent rated 2000+ |3 |
|7 |Big Winner |Win a game against opponent rated 2000+ |4 |
|8 |Strongest Opponent|Play a game against opponent rated 2250+ |4 |
|9 |Mythic Winner |Win a game against opponent rated 2250+ |5 |
|10 |Defeat an IM |Defeat an IM |4 |
|11 |Defeat a NM |Defeat a NM |3 |
|12 |Defeat a GM |Defeat a GM |5 |
|13 |Criss Cross |Mate with a bishop |4 |
|14 |Jousting |Mate with a knight |4 |
|15 |Utter Disrespect |Mate with a pawn |4 |
|16 |Triple Digit Club |Complete a game with more than 100 moves |3 |
|17 |Excessive |Complete a game with more than 150 moves |4 |
|18 |Ultramarathoners |Complete a game with more than 250 moves |5 |
|19 |Opening Expert |Win with checkmate in less than 10 moves |2 |
|20 |Don't Blink |Win with checkmate in <5 moves |3 |
|21 |Fool's Mate |Win with checkmate in 2 moves |5 |
|22 |Leveled Field |Draw with a higher rated player |2 |
|23 |Hello, m'lady |Queen side castle |1 |
|24 |Horse Farmer |Under-promote to a knight |3 |
|25 |Holy Promotion |Under-promote to a bishop |5 |
|26 |The Sneaky Pawn |En Passant |2 |
|27 |God-Mode Glitch |Checkmate with an En Passant |5 |
|28 |Cutting it Close |Draw when opponent has a queen, without one |4 |
|29 |Déjà Vu |Draw by repetition |1 |
|30 |The Underdog |Defeat a higher rated player |3 |
|31 |Checkin' You Out |Put opponent in check |1 |
|32 |Pawn Shy |Capture <4 pawns |1 |
|33 |Pawn Shopper |Capture all pawns |2 |
|34 |A Minor Problem |Capture all knights and bishops without losing any.|5 |
|35 |Mr. Marathon Man |Move king >20 times |1 |
|36 |Pawn Hoarder |Capture all pawns without losing any |5 |



### This one is for testing, and verifying the achievements

| Achievement | Description | Example PGN | Color |
|:-------------: |:-------------: |:-------------:|:-------------:|
| Scrub Dub | Win a game | 11 | Black
| Participation Medal | Play a game | 8 | White
| Semi-Scrub Dub | Win a game against opponent rated 750+ | 7 | Black
| Participation Medal | Play a game against opponent rated 750+ | 10 | White
| Mediocre Dub | Win a game against opponent rated 1500+ | 9 | Black
| Participation Medal | Play a game against opponent rated 1500+ | 6 | Black
| Participation Medal | Play a game against opponent rated 2000+ | 22 | White
| Decent Dub | Win a game against opponent rated 2000+ | 12 | Black
| Participation Medal | Play a game against opponent rated 2250+ | 2 | Black
| Poggers Dub | Win a game against opponent rated 2250+ | 2 | White
| Criss Cross | Mate with a bishop | 24 | Black
| Horsey Move in L | Mate with a knight | 6 | White
| Utter Disrespect | Mate with a pawn | 20 | White
| Triple Digit Club | Complete a game with more than 100 moves | 23 | White
| Excessive | Complete a game with more than 150 moves | 16 | White
| Nothing Better to Do | Complete a game with more than 250 moves | 15 | White
| Yeah, I'm Good | Win with checkmate in less than 10 moves | 13 | Black
| for real, bro? | Win with checkmate in <5 moves | 14 | White
| Fool's Mate | Win with checkmate in 2 moves | 12 | Black
| Emotional Dub | Draw with a higher rated player | 3 | White
| Hello, m'lady | Queen side castle | 3 | White
| Horse Farmer | Under-promote to a knight | 17 | Black
| Troll Promotion | Under-promote to a bishop | 18 | White
| The Game Glitched | En Passant | 5 | Black
| God-Mode Glitch | Checkmate with an En Passant | 9 | Black
| Cutting it Close | Draw when opponent has a queen, without one | 8 | Black
| Déjà Vu | Draw by repetition | 3 | White
| ELO is a Mindset | Defeat a higher rated player | 19 | White
| Checkin' You Out | Put opponent in check | 2 | White
| Pawn Shy | Capture <4 pawns | 3 | White
| Pawn Shopper | Capture all pawns | 15 | White
| A Minor Problem | Capture all knights and bishops without losing any | 24 | Black
| Mr. Marathon Man | Move king >20 times | 5 | White
| Pawn Hoarder | Capture all pawns without losing any | 21 | Black

| number | name | description | points |
| ------ | ------------------ | --------------------------------------------------- | ------ |
| 0 | Winner | Win a game | 2 |
| 1 | Player | Play a game | 1 |
| 2 | 750+ Winner | Win a game against opponent rated 750+ | 2 |
| 3 | Played 750+ | Play a game against opponent rated 750+ | 1 |
| 4 | 1500+ Winner | Win a game against opponent rated 1500+ | 3 |
| 5 | Played 1500+ | Play a game against opponent rated 1500+ | 2 |
| 6 | Played 2000+ | Play a game against opponent rated 2000+ | 3 |
| 7 | Big Winner | Win a game against opponent rated 2000+ | 4 |
| 8 | Strongest Opponent | Play a game against opponent rated 2250+ | 4 |
| 9 | Mythic Winner | Win a game against opponent rated 2250+ | 5 |
| 10 | Defeat an IM | Defeat an IM | 4 |
| 11 | Defeat a NM | Defeat a NM | 3 |
| 12 | Defeat a GM | Defeat a GM | 5 |
| 13 | Criss Cross | Mate with a bishop | 4 |
| 14 | Jousting | Mate with a knight | 4 |
| 15 | Utter Disrespect | Mate with a pawn | 4 |
| 16 | Triple Digit Club | Complete a game with more than 100 moves | 3 |
| 17 | Excessive | Complete a game with more than 150 moves | 4 |
| 18 | Ultramarathoners | Complete a game with more than 250 moves | 5 |
| 19 | Opening Expert | Win with checkmate in less than 10 moves | 2 |
| 20 | Don't Blink | Win with checkmate in <5 moves | 3 |
| 21 | Fool's Mate | Win with checkmate in 2 moves | 5 |
| 22 | Leveled Field | Draw with a higher rated player | 2 |
| 23 | Hello, m'lady | Queen side castle | 1 |
| 24 | Horse Farmer | Under-promote to a knight | 3 |
| 25 | Holy Promotion | Under-promote to a bishop | 5 |
| 26 | The Sneaky Pawn | En Passant | 2 |
| 27 | God-Mode Glitch | Checkmate with an En Passant | 5 |
| 28 | Cutting it Close | Draw when opponent has a queen, without one | 4 |
| 29 | Déjà Vu | Draw by repetition | 1 |
| 30 | The Underdog | Defeat a higher rated player | 3 |
| 31 | Checkin' You Out | Put opponent in check | 1 |
| 32 | Pawn Shy | Capture <4 pawns | 1 |
| 33 | Pawn Shopper | Capture all pawns | 2 |
| 34 | A Minor Problem | Capture all knights and bishops without losing any. | 5 |
| 35 | Mr. Marathon Man | Move king >20 times | 1 |
| 36 | Pawn Hoarder | Capture all pawns without losing any | 5 |

### This one is for testing, and verifying the achievements

| Achievement | Description | Example PGN | Color |
| :------------------: | :------------------------------------------------: | :---------: | :---: |
| Scrub Dub | Win a game | 11 | Black |
| Participation Medal | Play a game | 8 | White |
| Semi-Scrub Dub | Win a game against opponent rated 750+ | 7 | Black |
| Participation Medal | Play a game against opponent rated 750+ | 10 | White |
| Mediocre Dub | Win a game against opponent rated 1500+ | 9 | Black |
| Participation Medal | Play a game against opponent rated 1500+ | 6 | Black |
| Participation Medal | Play a game against opponent rated 2000+ | 22 | White |
| Decent Dub | Win a game against opponent rated 2000+ | 12 | Black |
| Participation Medal | Play a game against opponent rated 2250+ | 2 | Black |
| Poggers Dub | Win a game against opponent rated 2250+ | 2 | White |
| Criss Cross | Mate with a bishop | 24 | Black |
| Horsey Move in L | Mate with a knight | 6 | White |
| Utter Disrespect | Mate with a pawn | 20 | White |
| Triple Digit Club | Complete a game with more than 100 moves | 23 | White |
| Excessive | Complete a game with more than 150 moves | 16 | White |
| Nothing Better to Do | Complete a game with more than 250 moves | 15 | White |
| Yeah, I'm Good | Win with checkmate in less than 10 moves | 13 | Black |
| for real, bro? | Win with checkmate in <5 moves | 14 | White |
| Fool's Mate | Win with checkmate in 2 moves | 12 | Black |
| Emotional Dub | Draw with a higher rated player | 3 | White |
| Hello, m'lady | Queen side castle | 3 | White |
| Horse Farmer | Under-promote to a knight | 17 | Black |
| Troll Promotion | Under-promote to a bishop | 18 | White |
| The Game Glitched | En Passant | 5 | Black |
| God-Mode Glitch | Checkmate with an En Passant | 9 | Black |
| Cutting it Close | Draw when opponent has a queen, without one | 8 | Black |
| Déjà Vu | Draw by repetition | 3 | White |
| ELO is a Mindset | Defeat a higher rated player | 19 | White |
| Checkin' You Out | Put opponent in check | 2 | White |
| Pawn Shy | Capture <4 pawns | 3 | White |
| Pawn Shopper | Capture all pawns | 15 | White |
| A Minor Problem | Capture all knights and bishops without losing any | 24 | Black |
| Mr. Marathon Man | Move king >20 times | 5 | White |
| Pawn Hoarder | Capture all pawns without losing any | 21 | Black |

## 🤝 Contributing

Expand All @@ -148,7 +150,7 @@ Give a ⭐️ if this project helped you!

## 📝 License

Copyright © 2021 [Treasure Chess <[email protected]>](https://github.com/Treasure-Chess).<br />
Copyright © 2021 Nifty Chess, Inc.<br />
This project is [MIT](https://github.com/Treasure-Chess/chess-achievements/blob/master/LICENSE) licensed.

---
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@
"version": "0.1.0",
"description": "Calculate chess achievements based on moves ",
"main": "src/index.js",
"files": [
"src/achievementsList.json"
],
"scripts": {
"test": "node test.js",
"test": "node tests/full.test.js",
"lint": "eslint ./src"
},
"dependencies": {
Expand All @@ -29,8 +26,11 @@
"url": "git+https://github.com/Treasure-Chess/chess-achievements.git"
},
"keywords": [
"treasure",
"chess",
"achievement"
"achievement",
"chess.com",
"smart contract"
],
"author": "Treasure Chess Community <[email protected]>",
"license": "MIT",
Expand Down
Loading

0 comments on commit bf4fec5

Please sign in to comment.