Update README and fix linting issues (#37)
continuous-integration/drone/push Build is passing Details

Solves #16
This commit is contained in:
Hamcha 2019-09-20 14:41:24 +00:00 committed by Gitea
parent 7156fe23e5
commit 70fe698c22
8 changed files with 88 additions and 18 deletions

View File

@ -1,3 +1,4 @@
---
kind: pipeline kind: pipeline
name: default name: default
@ -14,11 +15,19 @@ steps:
- name: dependencies - name: dependencies
image: node image: node
failure: ignore
commands: commands:
- yarn - yarn
depends_on: depends_on:
- restore-cache - restore-cache
- name: lint
image: node
commands:
- yarn lint
depends_on:
- dependencies
- name: build_versioned - name: build_versioned
image: node image: node
commands: commands:
@ -165,6 +174,7 @@ steps:
- name: rebuild-cache - name: rebuild-cache
image: drillster/drone-volume-cache image: drillster/drone-volume-cache
failure: ignore
volumes: volumes:
- name: cache - name: cache
path: /cache path: /cache
@ -174,3 +184,13 @@ steps:
- ./node_modules - ./node_modules
depends_on: depends_on:
- dependencies - dependencies
volumes:
- name: cache
host:
path: /opt/gitea/drone-cache/mcg/mlpcardgame
---
kind: signature
hmac: 6aee8b5c1125f8f2fe31f5e927f8007084b0226979e27825336191bf76275fa3
...

View File

@ -18,9 +18,7 @@ module.exports = {
overrides: [ overrides: [
{ {
files: [ files: ["**/__tests__/*.{j,t}s?(x)"],
'**/__tests__/*.{j,t}s?(x)'
],
env: { env: {
jest: true jest: true
} }

View File

@ -4,6 +4,58 @@
Work in progress name, work in progress game Work in progress name, work in progress game
Try the latest build here: [mcg-builds.zyg.ovh/latest](https://mcg-builds.zyg.ovh/latest/)
## Development
### Dependencies
Fetch dependencies with `yarn`:
```sh
yarn --dev
```
### Run local server for development
Run this command:
```sh
yarn serve
```
then visit [localhost:8080](http://localhost:8080) (URL might be different if something is already listening on port 8080)
### Run tests
Run unit tests with Jest:
```sh
yarn test:unit
```
Generate a coverage profile with:
```sh
yarn test:unit --coverage
```
### Lint code
Before you submit a PR, make sure the code is formatted correctly with:
```sh
yarn lint
```
## Building for release
### Build
```sh
yarn build
```
## License ## License
Code is ISC, Assets "depends", some stuff is taken from FreeSound and DeviantArt so your best bet is to just praise the copyright gods. Code is ISC, Assets "depends", some stuff is taken from FreeSound and DeviantArt so your best bet is to just praise the copyright gods.

View File

@ -2,8 +2,7 @@
<img :src="imageURL" /> <img :src="imageURL" />
</template> </template>
<style lang="scss" scoped> <style lang="scss" scoped></style>
</style>
<script lang="ts"> <script lang="ts">
import { Component, Vue, Prop } from "vue-property-decorator"; import { Component, Vue, Prop } from "vue-property-decorator";

View File

@ -57,7 +57,7 @@ export class Session extends EventEmitter {
// Place players in the pod // Place players in the pod
switch (this.options.spacing) { switch (this.options.spacing) {
case "evenly": case "evenly": {
const playerRatio = spots / playerNum; const playerRatio = spots / playerNum;
let i = 0; let i = 0;
for (const player of players) { for (const player of players) {
@ -67,16 +67,15 @@ export class Session extends EventEmitter {
i += 1; i += 1;
} }
break; break;
}
case "randomly": case "randomly":
for (const player of players) { for (const player of players) {
while (true) { const free = [...Array(spots).keys()].filter(
const idx = Math.floor(Math.random() * spots); i => this.pod[i].name == ""
if (this.pod[idx].name == "") { );
this.pod[idx].name = player; const idx = Math.floor(Math.random() * free.length);
assignFn(name, this.pod[idx]); const chosen = free[idx];
break; assignFn(player, this.pod[chosen]);
}
}
} }
break; break;
} }
@ -179,10 +178,11 @@ export class Session extends EventEmitter {
const provider = DraftProvider.set(factory, options.packs); const provider = DraftProvider.set(factory, options.packs);
return new Session(options, provider); return new Session(options, provider);
} }
case "i8pcube": case "i8pcube": {
const cube = await I8PCube.fromURL(options.url); const cube = await I8PCube.fromURL(options.url);
const provider = new DraftProvider(cube.schema()); const provider = new DraftProvider(cube.schema());
return new Session(options, provider); return new Session(options, provider);
}
default: default:
throw new Error("Unknown draft source"); throw new Error("Unknown draft source");
} }

View File

@ -12,12 +12,13 @@ export async function cardImageURL(cardid: string): Promise<string> {
return remoteImageURL(cardid); return remoteImageURL(cardid);
} }
switch (cardImageSource()) { switch (cardImageSource()) {
case "local": case "local": {
const card = await Database.images.get(`${cardid}.webp`); const card = await Database.images.get(`${cardid}.webp`);
if (!card) { if (!card) {
return remoteImageURL(cardid); return remoteImageURL(cardid);
} }
return URL.createObjectURL(card.image); return URL.createObjectURL(card.image);
}
//TODO //TODO
case "remote": case "remote":
return remoteImageURL(cardid); return remoteImageURL(cardid);

View File

@ -2,4 +2,4 @@ module.exports = {
env: { env: {
jest: true jest: true
} }
} };

View File

@ -21,7 +21,7 @@ const testSessionOptions: DraftOptions = {
describe("mlpccg/draft", () => { describe("mlpccg/draft", () => {
beforeAll(async () => { beforeAll(async () => {
jest.setTimeout(15000); jest.setTimeout(30000);
await initDB(); await initDB();
await loadSets(); await loadSets();
}); });