Skip to content

Commit

Permalink
Merge branch 'main' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
danguilherme committed Apr 30, 2024
2 parents 0056958 + 31da9f2 commit 57c174d
Show file tree
Hide file tree
Showing 32 changed files with 7,896 additions and 5,327 deletions.
21 changes: 21 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"presets": ["@babel/env", "@babel/typescript"],
"plugins": [
"@babel/plugin-proposal-numeric-separator",
"@babel/proposal-class-properties",
"@babel/proposal-object-rest-spread",
"@babel/plugin-proposal-optional-chaining",
"@babel/plugin-proposal-nullish-coalescing-operator",
[
"@babel/plugin-transform-runtime",
{
"regenerator": true
}
]
],
"env": {
"test": {
"plugins": ["@babel/plugin-transform-runtime"]
}
}
}
7 changes: 7 additions & 0 deletions .browserslistrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Browsers that we support

last 5 Chrome major versions
last 5 Firefox major versions
last 5 Edge major versions
last 3 Safari major versions
maintained node versions
29 changes: 29 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Build

on:
pull_request:
branches:
- master

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [10.x, 12.x]

steps:
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Install, build and test
run: |
yarn install
yarn build
yarn test
env:
CI: true
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,6 @@ dist/**/*

# Ignore output from coverage report
coverage

# Ignore generated api documentation
docs/api
2 changes: 2 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ src/
docs/
coverage/

.babelrc
.browserslistrc
.prettierrc
.travis.yml
jest.config.js
Expand Down
1 change: 0 additions & 1 deletion .vscode/extensions.json

This file was deleted.

69 changes: 0 additions & 69 deletions .vscode/launch.json

This file was deleted.

19 changes: 0 additions & 19 deletions .vscode/settings.json

This file was deleted.

13 changes: 0 additions & 13 deletions .vscode/tasks.json

This file was deleted.

29 changes: 17 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
# UNO
> Uno game implemented in JavaScript

[![Build Status](https://travis-ci.org/danguilherme/uno.svg?branch=master)](https://travis-ci.org/danguilherme/uno)
Uno game implemented in JavaScript.

[![npm package](https://img.shields.io/npm/v/uno-engine.svg?label=uno-engine)](https://www.npmjs.com/package/uno-engine)
[![Build Status](https://img.shields.io/travis/danguilherme/uno/master.svg)](https://travis-ci.org/danguilherme/uno)
[![License](https://img.shields.io/github/license/danguilherme/uno.svg)](LICENSE)
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)


## Installation
```bash
Expand Down Expand Up @@ -39,34 +44,34 @@ const card = player.getCardByValue(value); // get the exact card in the player'

### Card Properties
```ts
import { Colors, Values } from 'uno-engine';
import { Color, Value } from 'uno-engine';

const card = game.discardedCard; // current card in-play
const cardColor = card.color; // get the index of the card color: 0 to 3
// (WILD and WILD DRAW FOUR will not have this property set)
Colors[cardColor]; // get the name of the color: RED, BLUE, GREEN, or YELLOW
Color[cardColor]; // get the name of the color: RED, BLUE, GREEN, or YELLOW

// Card value
const cardValue = card.value; // get the index of the card value: 0 to 14
Values[cardValue]; // get the name of the card:
Value[cardValue]; // get the name of the card:
// 0-9, SKIP, REVERSE, DRAW_TWO, WILD, or WILD_DRAW_TWO

// Get card from value/color strings
const value = Values.SIX;
const color = Colors.BLUE;
const value = Value.SIX;
const color = Color.BLUE;
const card = new Card(value, color);

// Set WILD or WD4 color
const [color, value] = ['GREEN', 'WILD']; // get args from player input
const card = player.getCardByValue(value); // get exact WILD/WD4 in player's hand
card.color = Colors[color]; // set color of WILD/WD4 in hand
card.color = Color[color]; // set color of WILD/WD4 in hand

// Get Card from args function
const getCard = ([color, value], player) => {
let card = new Card(Values[value], Colors[color]);
let card = new Card(Value[value], Color[color]);
if (value === 'WILD' || value === 'WILD_DRAW_FOUR') {
card = player.getCardByValue(Values[value]);
card.color = Colors[color];
card = player.getCardByValue(Value[value]);
card.color = Color[color];
}
return card;
};
Expand Down Expand Up @@ -143,4 +148,4 @@ game.on('end', ({ data: { winner, score } }) => {
## Game Rules
Check all the [official game rules](RULES.md).
Check all the [official game rules](RULES.md).
14 changes: 5 additions & 9 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
module.exports = {
globals: {
'ts-jest': {
tsConfigFile: 'tsconfig.json',
},
},
moduleFileExtensions: ['ts', 'js'],
transform: {
'^.+\\.ts$': 'ts-jest',
},
moduleFileExtensions: ['js', 'ts'],
testMatch: ['**/test/**/*.(ts|js)'],
testEnvironment: 'node',
preset: 'ts-jest',
transform: {
'^.+\\.ts$': ['ts-jest', { babel: true, tsConfig: 'tsconfig.json' }],
},
};
54 changes: 38 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,19 @@
"version": "0.0.0",
"description": "Uno game implementation in JavaScript",
"homepage": "https://github.com/danguilherme/uno#readme",
"main": "dist/main.js",
"main": "dist/uno-engine.node.js",
"browser": "dist/uno-engine.browser.js",
"types": "dist/uno-engine.d.ts",
"scripts": {
"build:web": "webpack --config webpack.config.js",
"build": "yarn run build:ts && yarn run lint",
"build:ts": "tsc --declaration",
"build:ts:watch": "tsc -w",
"build": "yarn run build:types && yarn run build:javascript",
"build:javascript": "webpack",
"build:types": "tsc --emitDeclarationOnly",
"docs": "typedoc --mode file --out docs/api/ src/",
"lint": "tslint -c tslint.json -p tsconfig.json",
"test": "jest --coverage --verbose",
"test": "jest",
"test:report": "yarn test --coverage --verbose",
"test:watch": "yarn test --watchAll",
"prepare": "yarn build",
"semantic-release": "semantic-release",
"lint:commit-message": "commitlint --help-url https://github.com/danguilherme/uno/blob/main/CONTRIBUTING.md#committing"
},
Expand All @@ -32,22 +36,40 @@
},
"license": "MIT",
"dependencies": {
"events": "^3.1.0",
"shuffle": "^0.2.2"
},
"devDependencies": {
"@commitlint/cli": "^19.3.0",
"@commitlint/config-conventional": "^19.2.2",
"@babel/cli": "^7.8.4",
"@babel/core": "^7.8.6",
"@babel/plugin-proposal-class-properties": "^7.8.3",
"@babel/plugin-proposal-decorators": "^7.8.3",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.8.3",
"@babel/plugin-proposal-numeric-separator": "^7.8.3",
"@babel/plugin-proposal-object-rest-spread": "^7.9.5",
"@babel/plugin-proposal-optional-chaining": "^7.9.0",
"@babel/plugin-transform-runtime": "^7.9.0",
"@babel/preset-env": "^7.8.6",
"@babel/preset-modules": "^0.1.3",
"@babel/preset-typescript": "^7.8.3",
"@commitlint/cli": "^17.8.1",
"@commitlint/config-conventional": "^17.8.1",
"@semantic-release/changelog": "^5.0.1",
"@semantic-release/git": "^9.0.1",
"@types/events": "^1.2.0",
"@types/jest": "^23.1.0",
"chai": "^3.5.0",
"jest": "^23.1.0",
"semantic-release": "22.0.12",
"ts-jest": "^22.4.6",
"tslint": "^5.10.0",
"@types/events": "^3.0.0",
"@types/jest": "^24.9.1",
"babel-loader": "^8.0.6",
"chai": "^4.2.0",
"jest": "^29.7.0",
"semantic-release": "^17.0.0",
"ts-jest": "^29.1.2",
"tslint": "^6.1.3",
"typedoc": "^0.25.13",
"typescript": "^5.4.5",
"webpack": "^2.2.1"
"webpack": "^4.42.1",
"webpack-cli": "^3.3.11",
"webpack-merge": "^4.2.2",
"webpack-node-externals": "^1.7.2"
},
"commitlint": {
"extends": [
Expand Down
Loading

0 comments on commit 57c174d

Please sign in to comment.