Update README and fix linting issues (#37)
All checks were successful
continuous-integration/drone/push Build is passing

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
name: default
@ -14,11 +15,19 @@ steps:
- name: dependencies
image: node
failure: ignore
commands:
- yarn
depends_on:
- restore-cache
- name: lint
image: node
commands:
- yarn lint
depends_on:
- dependencies
- name: build_versioned
image: node
commands:
@ -165,6 +174,7 @@ steps:
- name: rebuild-cache
image: drillster/drone-volume-cache
failure: ignore
volumes:
- name: cache
path: /cache
@ -174,3 +184,13 @@ steps:
- ./node_modules
depends_on:
- 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: [
{
files: [
'**/__tests__/*.{j,t}s?(x)'
],
files: ["**/__tests__/*.{j,t}s?(x)"],
env: {
jest: true
}

View file

@ -4,6 +4,58 @@
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
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" />
</template>
<style lang="scss" scoped>
</style>
<style lang="scss" scoped></style>
<script lang="ts">
import { Component, Vue, Prop } from "vue-property-decorator";

View file

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

View file

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

View file

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

View file

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