trucoshi 1.0.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +674 -0
- package/README.md +64 -0
- package/dist/lib/constants.d.ts +89 -0
- package/dist/lib/constants.js +89 -0
- package/dist/server/constants.d.ts +3 -0
- package/dist/server/constants.js +3 -0
- package/dist/types.d.ts +333 -0
- package/dist/types.js +113 -0
- package/package.json +71 -23
- package/.prettierrc.json +0 -3
- package/build/lib/constants.d.ts +0 -43
- package/build/lib/constants.js +0 -16
- package/build/lib/trucoshi.d.ts +0 -10
- package/build/lib/trucoshi.js +0 -363
- package/build/lib/types.d.ts +0 -101
- package/build/lib/types.js +0 -14
- package/build/lib/utils.d.ts +0 -5
- package/build/lib/utils.js +0 -66
- package/build/server/index.d.ts +0 -1
- package/build/server/index.js +0 -19
- package/build/server/types.d.ts +0 -0
- package/build/server/types.js +0 -1
- package/build/test/autoplay.d.ts +0 -1
- package/build/test/autoplay.js +0 -73
- package/build/test/legacy.d.ts +0 -1
- package/build/test/legacy.js +0 -146
- package/build/test/play.d.ts +0 -1
- package/build/test/play.js +0 -148
- package/nodemon.json +0 -6
- package/src/lib/constants.ts +0 -14
- package/src/lib/trucoshi.ts +0 -342
- package/src/lib/types.ts +0 -110
- package/src/lib/utils.ts +0 -69
- package/src/server/index.ts +0 -22
- package/src/server/types.ts +0 -0
- package/src/test/autoplay.ts +0 -41
- package/src/test/legacy.ts +0 -68
- package/src/test/play.ts +0 -70
- package/tsconfig.json +0 -18
package/src/test/play.ts
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import * as readline from 'readline'
|
|
2
|
-
import { COLORS } from '../lib/constants';
|
|
3
|
-
import { Match, Player, Team } from "../lib/trucoshi";
|
|
4
|
-
import { IRound } from '../lib/types';
|
|
5
|
-
|
|
6
|
-
(async () => {
|
|
7
|
-
const player1 = Player('lukini', 0)
|
|
8
|
-
const player2 = Player('guada', 0)
|
|
9
|
-
const player3 = Player('denoph', 1)
|
|
10
|
-
const player4 = Player('juli', 1)
|
|
11
|
-
|
|
12
|
-
const team1 = Team(COLORS[0], [player1, player2])
|
|
13
|
-
const team2 = Team(COLORS[1], [player3, player4])
|
|
14
|
-
|
|
15
|
-
const match = Match([team1, team2], 9);
|
|
16
|
-
|
|
17
|
-
while(!match.winner) {
|
|
18
|
-
|
|
19
|
-
const play = match.play()
|
|
20
|
-
|
|
21
|
-
if (!play || !play.player) {
|
|
22
|
-
break;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const name = play.player.id.toUpperCase()
|
|
26
|
-
|
|
27
|
-
process.stdout.write('\u001B[2J\u001B[0;0f');
|
|
28
|
-
process.stdout.write('\u001B[0;0f');
|
|
29
|
-
|
|
30
|
-
console.log(`=== Mano ${play.handIdx} === Ronda ${play.roundIdx} === Turno de ${name} ===`)
|
|
31
|
-
|
|
32
|
-
process.stdout.write('\u001B[2;0f');
|
|
33
|
-
|
|
34
|
-
match.teams.map((team, id) => console.log(`=== Team ${id} = ${team.points} Puntos ===`))
|
|
35
|
-
|
|
36
|
-
process.stdout.write('\u001B[5;0f');
|
|
37
|
-
|
|
38
|
-
console.log(play.rounds && play.rounds.length ? (play.rounds.map((round: IRound) => round.cards.length ? round.cards.map(c => [c.player.id, c.card]) : '')) : '')
|
|
39
|
-
|
|
40
|
-
const prom = () => new Promise<void>((resolve) => {
|
|
41
|
-
const rl = readline.createInterface(process.stdin, process.stdout);
|
|
42
|
-
rl.setPrompt(`\n${play.player?.id} elije una carta [1, 2, 3]: ${JSON.stringify(play.player?.hand)}\n`);
|
|
43
|
-
rl.prompt();
|
|
44
|
-
rl.on('line', (idx: string) => {
|
|
45
|
-
const playedCard = play.use(Number(idx) - 1)
|
|
46
|
-
if (!playedCard) {
|
|
47
|
-
rl.close();
|
|
48
|
-
return (async () => {
|
|
49
|
-
await prom()
|
|
50
|
-
resolve()
|
|
51
|
-
})();
|
|
52
|
-
}
|
|
53
|
-
process.stdout.write('\u001B[7;0f');
|
|
54
|
-
console.log(`\n${JSON.stringify(play.player?.hand)}\nUsing ${playedCard}`)
|
|
55
|
-
process.stdout.write('\u001B[10;0f');
|
|
56
|
-
console.log(play.rounds && play.rounds.length ? (play.rounds.map((round: IRound) => round.cards.length ? round.cards.map(c => [c.player.id, c.card]) : '')) : '')
|
|
57
|
-
rl.close();
|
|
58
|
-
resolve()
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
await prom()
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
process.stdout.write('\u001B[2J\u001B[2;0f');
|
|
67
|
-
match.teams.map((t, i) => console.log(`Equipo ${i}: ${t.players.map(p => ` ${p.id}`)} === ${t.points} puntos`))
|
|
68
|
-
console.log(`\nEquipo Ganador:${match.winner?.players.map(p => ` ${p.id}`)}`)
|
|
69
|
-
|
|
70
|
-
})();
|
package/tsconfig.json
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "es5",
|
|
4
|
-
"module": "commonjs",
|
|
5
|
-
"lib": ["es6"],
|
|
6
|
-
"allowJs": true,
|
|
7
|
-
"outDir": "build",
|
|
8
|
-
"rootDir": "src",
|
|
9
|
-
"strict": true,
|
|
10
|
-
"noImplicitAny": true,
|
|
11
|
-
"esModuleInterop": true,
|
|
12
|
-
"resolveJsonModule": true,
|
|
13
|
-
"declaration": true
|
|
14
|
-
},
|
|
15
|
-
"include": [
|
|
16
|
-
"src/**/*"
|
|
17
|
-
]
|
|
18
|
-
}
|