add client

This commit is contained in:
wzdwc
2020-04-14 22:20:02 +08:00
parent 32dd3302f8
commit d98223a6c6
80 changed files with 8461 additions and 20 deletions
Regular → Executable
View File
+29
View File
@@ -0,0 +1,29 @@
# poke-game-front-ts
## Project setup
```
yarn install
```
### Compiles and hot-reloads for development
```
yarn run serve
```
### Compiles and minifies for production
```
yarn run build
```
### Run your tests
```
yarn run test
```
### Lints and fixes files
```
yarn run lint
```
### Customize configuration
See [Configuration Reference](https://cli.vuejs.org/config/).
+5
View File
@@ -0,0 +1,5 @@
module.exports = {
presets: [
'@vue/cli-plugin-babel/preset'
]
}
+27
View File
@@ -0,0 +1,27 @@
{
"name": "poke-game-front-ts",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"core-js": "^3.6.4",
"vue": "^2.6.11",
"vue-class-component": "^7.2.3",
"vue-property-decorator": "^8.4.1",
"vue-router": "^3.1.6",
"vuex": "^3.1.3"
},
"devDependencies": {
"@vue/cli-plugin-babel": "^4.3.0",
"@vue/cli-plugin-typescript": "^4.3.0",
"@vue/cli-service": "^4.3.0",
"less": "^3.0.4",
"less-loader": "^5.0.0",
"typescript": "~3.8.3",
"vue-template-compiler": "^2.6.11"
}
}
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

+17
View File
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<title><%= htmlWebpackPlugin.options.title %></title>
</head>
<body>
<noscript>
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
</noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html>
+29
View File
@@ -0,0 +1,29 @@
<template>
<div id="app">
<img alt="Vue logo" src="./assets/logo.png">
<HelloWorld msg="Welcome to Your Vue.js + TypeScript App"/>
</div>
</template>
<script lang="ts">
import { Component, Vue } from 'vue-property-decorator';
import HelloWorld from './components/HelloWorld.vue';
@Component({
components: {
HelloWorld,
},
})
export default class App extends Vue {}
</script>
<style lang="less">
#app {
font-family: Avenir, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
}
</style>
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

+58
View File
@@ -0,0 +1,58 @@
<template>
<div class="hello">
<h1>{{ msg }}</h1>
<p>
For a guide and recipes on how to configure / customize this project,<br>
check out the
<a href="https://cli.vuejs.org" target="_blank" rel="noopener">vue-cli documentation</a>.
</p>
<h3>Installed CLI Plugins</h3>
<ul>
<li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-babel" target="_blank" rel="noopener">babel</a></li>
<li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-typescript" target="_blank" rel="noopener">typescript</a></li>
</ul>
<h3>Essential Links</h3>
<ul>
<li><a href="https://vuejs.org" target="_blank" rel="noopener">Core Docs</a></li>
<li><a href="https://forum.vuejs.org" target="_blank" rel="noopener">Forum</a></li>
<li><a href="https://chat.vuejs.org" target="_blank" rel="noopener">Community Chat</a></li>
<li><a href="https://twitter.com/vuejs" target="_blank" rel="noopener">Twitter</a></li>
<li><a href="https://news.vuejs.org" target="_blank" rel="noopener">News</a></li>
</ul>
<h3>Ecosystem</h3>
<ul>
<li><a href="https://router.vuejs.org" target="_blank" rel="noopener">vue-router</a></li>
<li><a href="https://vuex.vuejs.org" target="_blank" rel="noopener">vuex</a></li>
<li><a href="https://github.com/vuejs/vue-devtools#vue-devtools" target="_blank" rel="noopener">vue-devtools</a></li>
<li><a href="https://vue-loader.vuejs.org" target="_blank" rel="noopener">vue-loader</a></li>
<li><a href="https://github.com/vuejs/awesome-vue" target="_blank" rel="noopener">awesome-vue</a></li>
</ul>
</div>
</template>
<script lang="ts">
import { Component, Prop, Vue } from 'vue-property-decorator';
@Component
export default class HelloWorld extends Vue {
@Prop() private msg!: string;
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang="less">
h3 {
margin: 40px 0 0;
}
ul {
list-style-type: none;
padding: 0;
}
li {
display: inline-block;
margin: 0 10px;
}
a {
color: #42b983;
}
</style>
+12
View File
@@ -0,0 +1,12 @@
import Vue from 'vue';
import App from './App.vue';
import router from './router';
import store from './store';
Vue.config.productionTip = false;
new Vue({
router,
store,
render: (h) => h(App),
}).$mount('#app');
+27
View File
@@ -0,0 +1,27 @@
import Vue from 'vue';
import VueRouter, { RouteConfig } from 'vue-router';
import Home from '../views/Home.vue';
Vue.use(VueRouter);
const routes: RouteConfig[] = [
{
path: '/',
name: 'Home',
component: Home,
},
{
path: '/about',
name: 'About',
// route level code-splitting
// this generates a separate chunk (about.[hash].js) for this route
// which is lazy-loaded when the route is visited.
component: () => import(/* webpackChunkName: "about" */ '../views/About.vue'),
},
];
const router = new VueRouter({
routes,
});
export default router;
Vendored Executable
+13
View File
@@ -0,0 +1,13 @@
import Vue, { VNode } from 'vue';
declare global {
namespace JSX {
// tslint:disable no-empty-interface
interface Element extends VNode {}
// tslint:disable no-empty-interface
interface ElementClass extends Vue {}
interface IntrinsicElements {
[elem: string]: any;
}
}
}
Vendored Executable
+4
View File
@@ -0,0 +1,4 @@
declare module '*.vue' {
import Vue from 'vue';
export default Vue;
}
+15
View File
@@ -0,0 +1,15 @@
import Vue from 'vue';
import Vuex from 'vuex';
Vue.use(Vuex);
export default new Vuex.Store({
state: {
},
mutations: {
},
actions: {
},
modules: {
},
});
+5
View File
@@ -0,0 +1,5 @@
<template>
<div class="about">
<h1>This is an about page</h1>
</div>
</template>
+18
View File
@@ -0,0 +1,18 @@
<template>
<div class="home">
<img alt="Vue logo" src="../assets/logo.png">
<HelloWorld msg="Welcome to Your Vue.js App"/>
</div>
</template>
<script>
// @ is an alias to /src
import HelloWorld from '@/components/HelloWorld.vue'
export default {
name: 'Home',
components: {
HelloWorld
}
}
</script>
+39
View File
@@ -0,0 +1,39 @@
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"strict": true,
"jsx": "preserve",
"importHelpers": true,
"moduleResolution": "node",
"experimentalDecorators": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"sourceMap": true,
"baseUrl": ".",
"types": [
"webpack-env"
],
"paths": {
"@/*": [
"src/*"
]
},
"lib": [
"esnext",
"dom",
"dom.iterable",
"scripthost"
]
},
"include": [
"src/**/*.ts",
"src/**/*.tsx",
"src/**/*.vue",
"tests/**/*.ts",
"tests/**/*.tsx"
],
"exclude": [
"node_modules"
]
}
+19
View File
@@ -0,0 +1,19 @@
{
"defaultSeverity": "warning",
"extends": [
"tslint:recommended"
],
"linterOptions": {
"exclude": [
"node_modules/**"
]
},
"rules": {
"indent": [true, "spaces", 2],
"interface-name": false,
"no-consecutive-blank-lines": false,
"object-literal-sort-keys": false,
"ordered-imports": false,
"quotemark": [true, "single"]
}
}
+7997
View File
File diff suppressed because it is too large Load Diff
+12
View File
@@ -0,0 +1,12 @@
sudo: false
language: node_js
node_js:
- '10'
before_install:
- npm i npminstall -g
install:
- npminstall
script:
- npm run ci
after_script:
- npminstall codecov && codecov
Regular → Executable
View File
View File
View File
View File
+12
View File
@@ -0,0 +1,12 @@
2020-04-14 22:10:45,972 INFO 36442 [egg:logger] init all loggers with options: {"dir":"/Users/jorky/code/TexasPokerGame/server/logs/game-node-center","encoding":"utf8","env":"local","level":"INFO","consoleLevel":"INFO","disableConsoleAfterReady":false,"outputJSON":false,"buffer":true,"appLogName":"app.log","coreLogName":"core.log","agentLogName":"agent.log","errorLogName":"error.log","coreLogger":{"consoleLevel":"WARN"},"allowDebugAtProd":false,"type":"agent"}
2020-04-14 22:10:45,983 INFO 36442 [egg:core] dump config after load, 6ms
2020-04-14 22:10:46,034 INFO 36442 [egg-watcher] Start watching: ["/Users/jorky/code/TexasPokerGame/server/src/app","/Users/jorky/code/TexasPokerGame/server/src/lib","/Users/jorky/code/TexasPokerGame/server/src/service","/Users/jorky/code/TexasPokerGame/server/src/config","/Users/jorky/code/TexasPokerGame/server/src/app.ts","/Users/jorky/code/TexasPokerGame/server/src/agent.ts","/Users/jorky/code/TexasPokerGame/server/src/interface.ts"]
2020-04-14 22:10:46,034 INFO 36442 [egg-watcher] Start watching: "/Users/jorky/code/TexasPokerGame/server/src/app"
2020-04-14 22:10:46,035 INFO 36442 [egg-watcher] Start watching: "/Users/jorky/code/TexasPokerGame/server/src/lib"
2020-04-14 22:10:46,035 INFO 36442 [egg-watcher] Start watching: "/Users/jorky/code/TexasPokerGame/server/src/service"
2020-04-14 22:10:46,035 INFO 36442 [egg-watcher] Start watching: "/Users/jorky/code/TexasPokerGame/server/src/config"
2020-04-14 22:10:46,035 INFO 36442 [egg-watcher] Start watching: "/Users/jorky/code/TexasPokerGame/server/src/app.ts"
2020-04-14 22:10:46,036 INFO 36442 [egg-watcher] Start watching: "/Users/jorky/code/TexasPokerGame/server/src/agent.ts"
2020-04-14 22:10:46,036 INFO 36442 [egg-watcher] Start watching: "/Users/jorky/code/TexasPokerGame/server/src/interface.ts"
2020-04-14 22:10:46,037 INFO 36442 [egg-watcher:agent] watcher start success
2020-04-14 22:10:46,045 INFO 36442 [egg:core] dump config after ready, 5ms
View File
+49
View File
@@ -0,0 +1,49 @@
2020-04-14 22:10:47,071 INFO 36443 [egg:logger] init all loggers with options: {"dir":"/Users/jorky/code/TexasPokerGame/server/logs/game-node-center","encoding":"utf8","env":"local","level":"INFO","consoleLevel":"INFO","disableConsoleAfterReady":false,"outputJSON":false,"buffer":true,"appLogName":"app.log","coreLogName":"core.log","agentLogName":"agent.log","errorLogName":"error.log","coreLogger":{"consoleLevel":"WARN"},"allowDebugAtProd":false,"type":"application"}
2020-04-14 22:10:47,096 INFO 36443 [egg-multipart] stream mode enable
2020-04-14 22:10:47,154 INFO 36443 [egg-redis] server connecting redis://:***@127.0.0.1:6379/0
2020-04-14 22:10:47,176 INFO 36443 [egg-mysql] connecting root@127.0.0.1:3306/poker
2020-04-14 22:10:47,342 INFO 36443 [egg-static] starting static serve /public/ -> /Users/jorky/code/TexasPokerGame/server/src/app/public
2020-04-14 22:10:47,343 INFO 36443 [egg-security] use noopen middleware
2020-04-14 22:10:47,344 INFO 36443 [egg-security] use nosniff middleware
2020-04-14 22:10:47,345 INFO 36443 [egg-security] use xssProtection middleware
2020-04-14 22:10:47,345 INFO 36443 [egg-security] use xframe middleware
2020-04-14 22:10:47,346 INFO 36443 [egg-security] use dta middleware
2020-04-14 22:10:47,346 INFO 36443 [egg-security] compose 5 middlewares into one security middleware
2020-04-14 22:10:47,355 INFO 36443 [egg:core] dump config after load, 6ms
2020-04-14 22:10:47,370 INFO 36443 [egg-redis] client connect success
2020-04-14 22:10:47,380 ERROR 36443 nodejs.ReplyError: Ready check failed: NOAUTH Authentication required.
at parseError (/Users/jorky/code/TexasPokerGame/server/node_modules/redis/node_modules/redis-parser/lib/parser.js:193:12)
at parseType (/Users/jorky/code/TexasPokerGame/server/node_modules/redis/node_modules/redis-parser/lib/parser.js:303:14)
command: "INFO"
code: "NOAUTH"
pid: 36443
hostname: 192.168.0.100
2020-04-14 22:10:47,380 ERROR 36443 nodejs.ReplyError: Ready check failed: NOAUTH Authentication required.
at parseError (/Users/jorky/code/TexasPokerGame/server/node_modules/redis/node_modules/redis-parser/lib/parser.js:193:12)
at parseType (/Users/jorky/code/TexasPokerGame/server/node_modules/redis/node_modules/redis-parser/lib/parser.js:303:14)
command: "INFO"
code: "NOAUTH"
pid: 36443
hostname: 192.168.0.100
2020-04-14 22:10:47,390 ERROR 36443 nodejs.ReplyError: Ready check failed: NOAUTH Authentication required.
at parseError (/Users/jorky/code/TexasPokerGame/server/node_modules/redis/node_modules/redis-parser/lib/parser.js:193:12)
at parseType (/Users/jorky/code/TexasPokerGame/server/node_modules/redis/node_modules/redis-parser/lib/parser.js:303:14)
command: "INFO"
code: "NOAUTH"
pid: 36443
hostname: 192.168.0.100
2020-04-14 22:10:47,391 ERROR 36443 nodejs.ReplyError: Ready check failed: NOAUTH Authentication required.
at parseError (/Users/jorky/code/TexasPokerGame/server/node_modules/redis/node_modules/redis-parser/lib/parser.js:193:12)
at parseType (/Users/jorky/code/TexasPokerGame/server/node_modules/redis/node_modules/redis-parser/lib/parser.js:303:14)
command: "INFO"
code: "NOAUTH"
pid: 36443
hostname: 192.168.0.100
2020-04-14 22:10:47,394 INFO 36443 [egg-redis] instance[0] status OK, client ready
2020-04-14 22:10:47,400 INFO 36443 [egg-watcher:application] watcher start success
2020-04-14 22:10:47,434 INFO 36443 [egg-mysql] instance[0] status OK, rds currentTime: Tue Apr 14 2020 22:10:47 GMT+0800 (China Standard Time)
2020-04-14 22:10:47,458 INFO 36443 [egg:core] dump config after ready, 5ms
+6
View File
@@ -0,0 +1,6 @@
2020-04-14 22:10:47,463 INFO 36442 [Timer] /Users/jorky/code/TexasPokerGame/server/node_modules/egg-multipart/app/schedule/clean_tmpdir.js next time will execute after 22752539ms at 2020-04-15 04:30:00.002
2020-04-14 22:10:47,463 INFO 36442 [Timer] /Users/jorky/code/TexasPokerGame/server/node_modules/egg-logrotator/app/schedule/clean_log.js next time will execute after 6552537ms at 2020-04-15 00:00:00.000
2020-04-14 22:10:47,463 INFO 36442 [Timer] /Users/jorky/code/TexasPokerGame/server/node_modules/egg-logrotator/app/schedule/rotate_by_file.js next time will execute after 6553537ms at 2020-04-15 00:00:01.000
2020-04-14 22:10:47,096 INFO 36443 [egg-schedule]: register schedule /Users/jorky/code/TexasPokerGame/server/node_modules/egg-multipart/app/schedule/clean_tmpdir.js
2020-04-14 22:10:47,096 INFO 36443 [egg-schedule]: register schedule /Users/jorky/code/TexasPokerGame/server/node_modules/egg-logrotator/app/schedule/clean_log.js
2020-04-14 22:10:47,096 INFO 36443 [egg-schedule]: register schedule /Users/jorky/code/TexasPokerGame/server/node_modules/egg-logrotator/app/schedule/rotate_by_file.js
+32
View File
@@ -0,0 +1,32 @@
2020-04-14 22:10:47,379 ERROR 36443 nodejs.ReplyError: Ready check failed: NOAUTH Authentication required.
at parseError (/Users/jorky/code/TexasPokerGame/server/node_modules/redis/node_modules/redis-parser/lib/parser.js:193:12)
at parseType (/Users/jorky/code/TexasPokerGame/server/node_modules/redis/node_modules/redis-parser/lib/parser.js:303:14)
command: "INFO"
code: "NOAUTH"
pid: 36443
hostname: 192.168.0.100
2020-04-14 22:10:47,380 ERROR 36443 nodejs.ReplyError: Ready check failed: NOAUTH Authentication required.
at parseError (/Users/jorky/code/TexasPokerGame/server/node_modules/redis/node_modules/redis-parser/lib/parser.js:193:12)
at parseType (/Users/jorky/code/TexasPokerGame/server/node_modules/redis/node_modules/redis-parser/lib/parser.js:303:14)
command: "INFO"
code: "NOAUTH"
pid: 36443
hostname: 192.168.0.100
2020-04-14 22:10:47,381 ERROR 36443 nodejs.ReplyError: Ready check failed: NOAUTH Authentication required.
at parseError (/Users/jorky/code/TexasPokerGame/server/node_modules/redis/node_modules/redis-parser/lib/parser.js:193:12)
at parseType (/Users/jorky/code/TexasPokerGame/server/node_modules/redis/node_modules/redis-parser/lib/parser.js:303:14)
command: "INFO"
code: "NOAUTH"
pid: 36443
hostname: 192.168.0.100
2020-04-14 22:10:47,390 ERROR 36443 nodejs.ReplyError: Ready check failed: NOAUTH Authentication required.
at parseError (/Users/jorky/code/TexasPokerGame/server/node_modules/redis/node_modules/redis-parser/lib/parser.js:193:12)
at parseType (/Users/jorky/code/TexasPokerGame/server/node_modules/redis/node_modules/redis-parser/lib/parser.js:303:14)
command: "INFO"
code: "NOAUTH"
pid: 36443
hostname: 192.168.0.100
View File
Regular → Executable
View File
View File
View File
View File
+2 -2
View File
@@ -35,7 +35,7 @@ export class Player {
// commandRecord: Array<string> = [];
constructor(config: IPlayer = { counter: 0, position: 0, userId: '' }) {
this.counter = config.counter;
this.position = config.position;
this.position = config.position || 0;
this.userId = config.userId;
if (this.position === 0) {
this.type = EPlayerType.DEALER;
@@ -62,7 +62,7 @@ export class Player {
* @param {number} prevSize
* @example action('command:raise:10')
*/
action(commandString: string, prevSize?: number) {
action(commandString: string, prevSize: number = 0) {
const commandArr = commandString.split(':');
const command = commandArr[0];
const raiseSize = Number(commandArr[1]);
View File
+31 -15
View File
@@ -46,6 +46,10 @@ export class PokerGame {
}
init(users: IPlayer[]) {
if (this.playerSize < 2) {
throw 'player Inadequate';
}
this.status = EGameStatus.GAME_READY;
// init playerLink
this.playerLink = this.setPlayer(users);
@@ -60,16 +64,20 @@ export class PokerGame {
// sb blind
const SBPlayerNode = this.playerLink.getNode(1);
const SBPlayer = SBPlayerNode.node;
// big blind
const BBPlayerNode = SBPlayerNode.next;
const BBPlayer = BBPlayerNode.node;
SBPlayer.action(`small_blind:${this.smallBlind}`);
BBPlayer.action(`big_blind:${this.smallBlind * 2}`);
this.prevSize = this.smallBlind * 2;
// add counter to pot
// this.pots.push(this.smallBlind * 3);
this.pot = this.smallBlind * 3;
// todo straddle
if (SBPlayerNode.next) {
// big blind
const BBPlayerNode: ILinkNode<Player> = SBPlayerNode.next;
const BBPlayer = BBPlayerNode.node;
SBPlayer.action(`small_blind:${this.smallBlind}`);
BBPlayer.action(`big_blind:${this.smallBlind * 2}`);
this.prevSize = this.smallBlind * 2;
// add counter to pot
// this.pots.push(this.smallBlind * 3);
this.pot = this.smallBlind * 3;
// todo straddle
} else {
throw 'player Inadequate';
}
}
play() {
@@ -78,7 +86,7 @@ export class PokerGame {
}
action(commandString: string) {
if (this.status === EGameStatus.GAME_ACTION) {
if (this.status === EGameStatus.GAME_ACTION && this.currPlayer.next) {
const commandArr = commandString.split(':');
const command = commandArr[0];
let size = Number(commandArr[1]);
@@ -152,7 +160,11 @@ export class PokerGame {
if (this.commonCard.length === 0
&& this.currPlayer.node.actionSize === this.smallBlind * 2
&& this.currPlayer.node.type !== EPlayerType.BIG_BLIND) {
this.currPlayer = this.currPlayer.next;
if (this.currPlayer.next) {
this.currPlayer = this.currPlayer.next;
} else {
throw 'currPlayer.next is null';
}
return;
}
// action has allin, sum the allin player ev_pot
@@ -259,11 +271,13 @@ export class PokerGame {
getPlayers(type= 'all', withoutPlayers?: Player[]) {
let players = [];
let nextPlayer = this.playerLink.link;
let nextPlayer: ILinkNode<Player> = this.playerLink.link;
let i = 0;
while (i < this.playerSize) {
players.push(nextPlayer.node);
nextPlayer = nextPlayer.next;
if (nextPlayer.next) {
nextPlayer = nextPlayer.next;
}
i++;
}
players = type === 'all' ? [ ...players, ...this.allInPlayers ] : players;
@@ -366,7 +380,9 @@ export class PokerGame {
while (j < this.playerSize) {
player = playerLink.node;
player.handCard.push(this.poker.getCard());
playerLink = playerLink.next;
if (playerLink.next) {
playerLink = playerLink.next;
}
j++;
}
}
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
+2 -2
View File
@@ -20,9 +20,9 @@ export class Link<T> {
next: null,
};
nodes.forEach((node, key) => {
const currNode = {
const currNode: ILinkNode<T> = {
node,
next: null as ILinkNode<T>,
next: null,
};
// head
if (key === 0) {
View File
+1 -1
View File
@@ -15,7 +15,7 @@
"strict": true,
"strictPropertyInitialization": false,
"stripInternal": true,
"strictNullChecks": false,
"strictNullChecks": true,
"suppressImplicitAnyIndexErrors": true,
"target": "ES2018"
},
View File
Regular → Executable
View File