Commit 6c511ff0 authored by 神楽坂玲奈's avatar 神楽坂玲奈

merge

parents 3188b80a 211afbe9
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"project": {
"name": "mycard-mobile"
},
"apps": [
{
"root": "src",
"outDir": "dist",
"assets": [
"assets",
"favicon.ico"
],
"index": "index.html",
"main": "main.ts",
"polyfills": "polyfills.ts",
"test": "test.ts",
"tsconfig": "tsconfig.app.json",
"testTsconfig": "tsconfig.spec.json",
"prefix": "app",
"serviceWorker": true,
"styles": [
"styles.css"
],
"scripts": [],
"environmentSource": "environments/environment.ts",
"environments": {
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts"
}
}
],
"e2e": {
"protractor": {
"config": "./protractor.conf.js"
}
},
"lint": [
{
"project": "src/tsconfig.app.json",
"exclude": "**/node_modules/**"
},
{
"project": "src/tsconfig.spec.json",
"exclude": "**/node_modules/**"
},
{
"project": "e2e/tsconfig.e2e.json",
"exclude": "**/node_modules/**"
}
],
"test": {
"karma": {
"config": "./karma.conf.js"
}
},
"defaults": {
"styleExt": "css",
"class": {
"spec": false
},
"component": {
"spec": false
},
"directive": {
"spec": false
},
"guard": {
"spec": false
},
"module": {
"spec": false
},
"pipe": {
"spec": false
},
"service": {
"spec": false
}
}
}
......@@ -30,13 +30,10 @@
/coverage
/libpeerconnection.log
npm-debug.log
yarn-error.log
testem.log
/typings
# e2e
/e2e/*.js
/e2e/*.map
# System Files
.DS_Store
Thumbs.db
{
"printWidth": 140,
"singleQuote": true
}
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"mycard-mobile": {
"root": "",
"sourceRoot": "src",
"projectType": "application",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist",
"index": "src/index.html",
"main": "src/main.ts",
"tsConfig": "src/tsconfig.app.json",
"polyfills": "src/polyfills.ts",
"assets": [
"src/assets",
"src/favicon.ico",
"src/manifest.json"
],
"styles": [
"src/styles.css"
],
"scripts": []
},
"configurations": {
"production": {
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"serviceWorker": true,
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
]
}
}
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "mycard-mobile:build"
},
"configurations": {
"production": {
"browserTarget": "mycard-mobile:build:production"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "mycard-mobile:build"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "src/test.ts",
"karmaConfig": "./karma.conf.js",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.spec.json",
"scripts": [],
"styles": [
"src/styles.css"
],
"assets": [
"src/assets",
"src/favicon.ico"
]
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"src/tsconfig.app.json",
"src/tsconfig.spec.json"
],
"exclude": [
"**/node_modules/**"
]
}
}
}
},
"mycard-mobile-e2e": {
"root": "",
"sourceRoot": "e2e",
"projectType": "application",
"architect": {
"e2e": {
"builder": "@angular-devkit/build-angular:protractor",
"options": {
"protractorConfig": "./protractor.conf.js",
"devServerTarget": "mycard-mobile:serve"
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"e2e/tsconfig.e2e.json"
],
"exclude": [
"**/node_modules/**"
]
}
}
}
}
},
"defaultProject": "mycard-mobile",
"schematics": {
"@schematics/angular:class": {
"spec": false
},
"@schematics/angular:component": {
"spec": false,
"prefix": "app",
"styleext": "css"
},
"@schematics/angular:directive": {
"spec": false,
"prefix": "app"
},
"@schematics/angular:guard": {
"spec": false
},
"@schematics/angular:module": {
"spec": false
},
"@schematics/angular:pipe": {
"spec": false
},
"@schematics/angular:service": {
"spec": false
}
}
}
{
"index": "/index.html",
"assetGroups": [
{
"name": "app",
"installMode": "prefetch",
"resources": {
"files": ["/favicon.ico", "/index.html", "/*.css", "/*.js"]
}
},
{
"name": "assets",
"installMode": "lazy",
"updateMode": "prefetch",
"resources": {
"files": ["/assets/**", "/fontawesome-webfont.*", "/MaterialIcons-Regular.*"]
}
}
],
"dataGroups": [
{
"name": "api-freshness",
"urls": [
"https://ygobbs.com/top/quarterly.json",
"https://mycard.moe/ygopro/api/history",
"https://api.mycard.moe/ygopro/arena/user"
],
"cacheConfig": {
"maxSize": 100,
"maxAge": "3d",
"timeout": "1m",
"strategy": "freshness"
}
},
{
"name": "api-performance",
"urls": [
"https://api.mycard.moe/apps.json",
"https://cdn01.moecube.com/avatars/*",
"https://ygobbs.com/user_avatar/*",
"https://ygobbs.com/uploads/**"
],
"cacheConfig": {
"maxSize": 100,
"maxAge": "3d",
"timeout": "1m",
"strategy": "performance"
}
}
]
}
{
"routing": {
"index": "/mobile/index.html",
"routes": {
"/mobile/": {
"match": "exact"
},
"/mobile/?": {
"match": "prefix"
},
"/mobile/ygopro/": {
"match": "prefix"
}
}
}
}
This source diff could not be displayed because it is too large. You can view the blob instead.
{
"name": "mycard-mobile",
"version": "1.0.20",
"version": "1.0.21",
"license": "UNLISENCED",
"scripts": {
"ng": "ng",
"start": "ng serve --base-href /mobile/ --deploy-url /mobile --locale zh-CN --output-path mobile --open",
"build": "ng build --base-href /mobile/ --locale zh-CN --aot --build-optimizer --extract-css --prod",
"build:dev": "ng build --base-href /mobile2/ --locale zh-CN --aot --build-optimizer --extract-css",
"lint": "ng lint --type-check --fix"
"start": "ng serve --aot",
"build": "ng build --i18n-locale zh-CN --base-href /mobile/ --prod --build-optimizer",
"postinstall": "patch -i webpack.patch -p0 -t",
"lint": "ng lint"
},
"private": true,
"dependencies": {
"@angular/animations": "^4.3.6",
"@angular/cdk": "^2.0.0-beta.8",
"@angular/common": "^4.3.6",
"@angular/compiler": "^4.3.6",
"@angular/core": "^4.3.6",
"@angular/forms": "^4.3.6",
"@angular/http": "^4.3.6",
"@angular/material": "^2.0.0-beta.8",
"@angular/platform-browser": "^4.3.6",
"@angular/platform-browser-dynamic": "^4.3.6",
"@angular/router": "^4.3.6",
"core-js": "^2.5.0",
"@angular/animations": "6.0.5",
"@angular/cdk": "^6.2.1",
"@angular/common": "6.0.5",
"@angular/compiler": "6.0.5",
"@angular/core": "6.0.5",
"@angular/forms": "6.0.5",
"@angular/http": "6.0.5",
"@angular/material": "^6.2.1",
"@angular/platform-browser": "6.0.5",
"@angular/platform-browser-dynamic": "6.0.5",
"@angular/pwa": "^0.6.8",
"@angular/router": "6.0.5",
"@angular/service-worker": "6.0.5",
"font-awesome": "^4.7.0",
"hammerjs": "^2.0.8",
"lodash": "^4.17.4",
"lodash": "^4.17.10",
"material-design-icons": "^3.0.1",
"raven-js": "^3.26.2",
"rxjs": "^5.4.3",
"webdav": "https://github.com/moecube/webdav-client/releases/download/v1.0.1/webdav-1.0.1.tgz",
"zone.js": "^0.8.17"
"rxjs": "^6.2.1",
"webdav": "^1.5.2",
"zone.js": "^0.8.26"
},
"devDependencies": {
"@angular/cli": "^1.3.2",
"@angular/compiler-cli": "^4.3.6",
"@angular/language-service": "^4.3.6",
"@angular/service-worker": "^1.0.0-beta.16",
"@types/lodash": "^4.14.74",
"@types/node": "^8.0.25",
"codelyzer": "~3.1.1",
"tslint": "^5.6.0",
"typescript": "~2.3.3"
"@angular-devkit/build-angular": "~0.6.8",
"@angular/cli": "^6.0.8",
"@angular/compiler-cli": "6.0.5",
"@angular/language-service": "6.0.5",
"@types/lodash": "^4.14.109",
"@types/node": "^10.3.3",
"codelyzer": "^4.0.1",
"prettier": "^1.12.1",
"tslint": "~5.9.1",
"typescript": "2.7.2"
}
}
......@@ -18,15 +18,14 @@ const routes: Routes = [
{ path: 'ygopro/rooms', component: RoomListComponent },
{ path: 'ygopro/lobby', component: LobbyComponent },
{ path: 'ygopro/windbot', component: WindbotComponent },
{ path: 'ygopro/watch', component: WatchComponent },
{ path: 'ygopro/watch', component: WatchComponent }
]
},
}
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule],
providers: [AuthGuard, LoginService],
providers: [AuthGuard, LoginService]
})
export class AppRoutingModule {
}
export class AppRoutingModule {}
import { CdkTableModule } from '@angular/cdk';
import {ErrorHandler, isDevMode, NgModule} from '@angular/core';
import { NgModule } from '@angular/core';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { HttpModule, JsonpModule } from '@angular/http';
import {
MdAutocompleteModule,
MdButtonModule,
MdCardModule,
MdCheckboxModule,
MdDialogModule,
MdGridListModule,
MdIconModule,
MdInputModule,
MdListModule,
MdMenuModule,
MdProgressSpinnerModule,
MdSelectModule,
MdSlideToggleModule,
MdSnackBarModule,
MdTableModule,
MdToolbarModule
MatAutocompleteModule,
MatButtonModule,
MatCardModule,
MatCheckboxModule,
MatDialogModule,
MatGridListModule,
MatIconModule,
MatInputModule,
MatListModule,
MatMenuModule,
MatProgressSpinnerModule,
MatSelectModule,
MatSlideToggleModule,
MatSnackBarModule,
MatTableModule,
MatToolbarModule
} from '@angular/material';
import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import 'hammerjs';
import 'rxjs/Rx';
import { ServiceWorkerModule } from '@angular/service-worker';
import 'hammerjs';
import { environment } from '../environments/environment';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { LobbyComponent } from './lobby/lobby.component';
......@@ -37,17 +36,8 @@ import { ToolbarComponent } from './toolbar/toolbar.component';
import { WatchComponent } from './watch/watch.component';
import { WindbotComponent } from './windbot/windbot.component';
import { YGOProService } from './ygopro.service';
import * as Raven from 'raven-js';
Raven
.config('https://a43997ca0d3a4aee8640ab90af35144b@sentry.io/1227659')
.install();
export class RavenErrorHandler implements ErrorHandler {
handleError(err: any): void {
Raven.captureException(err.originalError || err);
}
}
import { HttpClientModule } from '@angular/common/http';
import { HttpModule } from '@angular/http';
@NgModule({
declarations: [
......@@ -63,33 +53,31 @@ export class RavenErrorHandler implements ErrorHandler {
],
imports: [
BrowserModule,
ServiceWorkerModule.register('ngsw-worker.js', { enabled: environment.production }),
FormsModule,
HttpModule,
HttpClientModule,
AppRoutingModule,
BrowserAnimationsModule,
MdInputModule,
MdSelectModule,
MdCheckboxModule,
MdButtonModule,
MdSlideToggleModule,
MdCardModule,
MdGridListModule,
MdIconModule,
MdTableModule,
CdkTableModule,
MdListModule,
MdDialogModule,
MdToolbarModule,
MdSnackBarModule,
MdAutocompleteModule,
MatInputModule,
MatSelectModule,
MatCheckboxModule,
MatButtonModule,
MatSlideToggleModule,
MatCardModule,
MatGridListModule,
MatIconModule,
MatTableModule,
MatListModule,
MatDialogModule,
MatToolbarModule,
MatSnackBarModule,
MatAutocompleteModule,
ReactiveFormsModule,
JsonpModule,
MdMenuModule,
MdProgressSpinnerModule
MatMenuModule,
MatProgressSpinnerModule
],
providers: [YGOProService, StorageService, { provide: ErrorHandler, useClass: RavenErrorHandler }],
providers: [YGOProService, StorageService],
bootstrap: [AppComponent],
entryComponents: [MatchDialogComponent, ResultDialogComponent]
})
export class AppModule {
}
export class AppModule {}
......@@ -35,33 +35,33 @@ input::placeholder {
/*color: lightgray;*/
/*}*/
md-input-container {
mat-form-field {
width: 100%;
}
[md-raised-button] {
[mat-raised-button] {
border-radius: 0;
box-shadow: none;
}
[md-button], [md-raised-button] {
[mat-button], [mat-raised-button] {
width: 100%;
height: 100%;
}
a[md-button], a[md-raised-button] {
a[mat-button], a[mat-raised-button] {
display: flex;
align-items: center;
justify-content: center;
}
md-card-content {
mat-card-content {
display: flex;
flex-direction: row;
}
[md-card-avatar] {
[mat-card-avatar] {
width: 128px;
height: 72px;
object-fit: cover;
......
<!--https://github.com/google/material-design-icons/blob/master/iconfont/codepoints-->
<md-toolbar color="primary">
<button id="menu" md-icon-button (click)="ygopro.openDrawer()">
<md-icon>menu</md-icon>
<mat-toolbar color="primary">
<button id="menu" mat-icon-button (click)="ygopro.openDrawer()">
<mat-icon>menu</mat-icon>
</button>
<form (submit)="search(key)">
<input type=search placeholder="卡片搜索" name="key" [(ngModel)]="key" mdAutocomplete="auto" [formControl]="searchCtrl">
<input type="search" placeholder="卡片搜索" name="key" [(ngModel)]="key" [matAutocomplete]="auto" [formControl]="searchCtrl">
<md-autocomplete #auto="mdAutocomplete">
<md-option *ngFor="let card of suggestion | async" [value]="card" (onSelectionChange)="search(card)">
<mat-autocomplete #auto="matAutocomplete">
<mat-option *ngFor="let card of suggestion | async" [value]="card" (onSelectionChange)="search(card)">
{{ card }}
</md-option>
</md-autocomplete>
</mat-option>
</mat-autocomplete>
</form>
<button md-icon-button *ngIf="storage.working">
<md-icon class="fa-spin">sync</md-icon>
<button mat-icon-button *ngIf="storage.working">
<mat-icon class="fa-spin">sync</mat-icon>
</button>
<a href="https://accounts.moecube.com/profiles" target="_blank" md-icon-button>
<a href="https://accounts.moecube.com/profiles" target="_blank" mat-icon-button>
<img id="avatar" [src]="login.user.avatar_url">
</a>
<button md-icon-button [mdMenuTriggerFor]="menu">
<md-icon>add</md-icon>
<button mat-icon-button [matMenuTriggerFor]="menu">
<mat-icon>add</mat-icon>
</button>
<md-menu #menu="mdMenu">
<a [href]="login.logout()" md-menu-item>切换用户</a>
<button md-menu-item>大厅版本 {{version}}</button>
<button md-menu-item *ngIf="build">应用版本 {{build.version_name}}</button>
</md-menu>
</md-toolbar>
<mat-menu #menu="matMenu">
<a [href]="login.logout()" mat-menu-item>切换用户</a>
<button mat-menu-item>大厅版本 {{version}}</button>
<button mat-menu-item *ngIf="build">应用版本 {{build.version_name}}</button>
</mat-menu>
</mat-toolbar>
<md-grid-list cols="4" rowHeight="100px" gutterSize="0">
<!--<md-grid-tile>-->
<!--<a href="https://accounts.moecube.com/profiles" id="avatar" md-raised-button [style.background-image]="'url(' + login.user.avatar_url + ')'">{{login.user.username}}</a>-->
<!--</md-grid-tile>-->
<md-grid-tile>
<button md-raised-button color="primary" (click)="ygopro.request_match('athletic')">
<md-icon fontSet="fa" fontIcon="fa-futbol-o"></md-icon>
<mat-grid-list cols="4" rowHeight="100px" gutterSize="0">
<!--<mat-grid-tile>-->
<!--<a href="https://accounts.moecube.com/profiles" id="avatar" mat-raised-button [style.background-image]="'url(' + login.user.avatar_url + ')'">{{login.user.username}}</a>-->
<!--</mat-grid-tile>-->
<mat-grid-tile>
<button mat-raised-button color="primary" (click)="ygopro.request_match('athletic')">
<mat-icon fontSet="fa" fontIcon="fa-futbol-o"></mat-icon>
<br>竞技匹配
</button>
</md-grid-tile>
<md-grid-tile>
<button md-raised-button color="primary" (click)="ygopro.request_match('entertain')">
<md-icon>toys</md-icon>
</mat-grid-tile>
<mat-grid-tile>
<button mat-raised-button color="primary" (click)="ygopro.request_match('entertain')">
<mat-icon>toys</mat-icon>
<br>娱乐匹配
</button>
</md-grid-tile>
<md-grid-tile><a md-raised-button color="primary" routerLink="/ygopro/rooms">
<md-icon>games</md-icon>
<br>房间列表</a></md-grid-tile>
<md-grid-tile><a md-raised-button color="primary" routerLink="/ygopro/rooms/new">
<md-icon>&#xe146;</md-icon><!--add_box-->
<br>创建房间</a></md-grid-tile>
<md-grid-tile><a md-raised-button routerLink="/ygopro/windbot">
<md-icon>&#xe195;</md-icon><!-- airplanemode_active -->
<br>单人模式</a></md-grid-tile>
<md-grid-tile><a md-raised-button routerLink="/ygopro/watch">
<md-icon>&#xe417;</md-icon><!--remove_red_eye-->
<br>观战</a></md-grid-tile>
<!--<md-grid-tile>-->
<!--<button md-raised-button (click)="ygopro.watch_replay()">-->
<!--<md-icon>history</md-icon>-->
</mat-grid-tile>
<mat-grid-tile><a mat-raised-button color="primary" routerLink="/ygopro/rooms">
<mat-icon>games</mat-icon>
<br>房间列表</a></mat-grid-tile>
<mat-grid-tile><a mat-raised-button color="primary" routerLink="/ygopro/rooms/new">
<mat-icon>&#xe146;</mat-icon><!--add_box-->
<br>创建房间</a></mat-grid-tile>
<mat-grid-tile><a mat-raised-button routerLink="/ygopro/windbot">
<mat-icon>&#xe195;</mat-icon><!-- airplanemode_active -->
<br>单人模式</a></mat-grid-tile>
<mat-grid-tile><a mat-raised-button routerLink="/ygopro/watch">
<mat-icon>&#xe417;</mat-icon><!--remove_red_eye-->
<br>观战</a></mat-grid-tile>
<!--<mat-grid-tile>-->
<!--<button mat-raised-button (click)="ygopro.watch_replay()">-->
<!--<mat-icon>history</mat-icon>-->
<!--<br>观看录像-->
<!--</button>-->
<!--</md-grid-tile>-->
<md-grid-tile>
<button md-raised-button (click)="ygopro.edit_deck()">
<md-icon>edit</md-icon>
<!--</mat-grid-tile>-->
<mat-grid-tile>
<button mat-raised-button (click)="ygopro.edit_deck()">
<mat-icon>edit</mat-icon>
<br>编辑卡组
</button>
</md-grid-tile>
<md-grid-tile><a md-raised-button href="https://ygobbs.com" target="_blank">
<md-icon>forum</md-icon>
<br>社区</a></md-grid-tile>
<md-grid-tile><a md-raised-button [href]="arena_url" target="_blank">
<md-icon fontSet="fa" fontIcon="fa-trophy"></md-icon>
<br>决斗数据库</a></md-grid-tile>
<md-grid-tile>
<button md-raised-button (click)="ygopro.backHome()"><span class="icon">233</span><br>直连</button>
</md-grid-tile>
</md-grid-list>
</mat-grid-tile>
<mat-grid-tile><a mat-raised-button href="https://ygobbs.com" target="_blank">
<mat-icon>forum</mat-icon>
<br>社区</a></mat-grid-tile>
<mat-grid-tile><a mat-raised-button [href]="arena_url" target="_blank">
<mat-icon fontSet="fa" fontIcon="fa-trophy"></mat-icon>
<br>决斗数据库</a></mat-grid-tile>
<mat-grid-tile>
<button mat-raised-button (click)="ygopro.backHome()"><span class="icon">233</span><br>直连</button>
</mat-grid-tile>
</mat-grid-list>
<md-card *ngIf="ygopro.points">
<md-grid-list id="points" cols="4" rowHeight="20px">
<md-grid-tile>
<mat-card *ngIf="ygopro.points">
<mat-grid-list id="points" cols="4" rowHeight="20px">
<mat-grid-tile>
<dt>竞技排名</dt>
</md-grid-tile>
<md-grid-tile>
</mat-grid-tile>
<mat-grid-tile>
<dd>{{ygopro.points.arena_rank}}</dd>
</md-grid-tile>
<md-grid-tile>
</mat-grid-tile>
<mat-grid-tile>
<dt>娱乐排名</dt>
</md-grid-tile>
<md-grid-tile>
</mat-grid-tile>
<mat-grid-tile>
<dd>{{ygopro.points.exp_rank}}</dd>
</md-grid-tile>
<md-grid-tile>
</mat-grid-tile>
<mat-grid-tile>
<dt>竞技胜率</dt>
</md-grid-tile>
<md-grid-tile>
</mat-grid-tile>
<mat-grid-tile>
<dd>{{ygopro.points.athletic_wl_ratio}}%</dd>
</md-grid-tile>
<md-grid-tile>
</mat-grid-tile>
<mat-grid-tile>
<dt>经验</dt>
</md-grid-tile>
<md-grid-tile>
</mat-grid-tile>
<mat-grid-tile>
<dd>{{ygopro.points.exp}}</dd>
</md-grid-tile>
<md-grid-tile>
</mat-grid-tile>
<mat-grid-tile>
<dt>胜场</dt>
</md-grid-tile>
<md-grid-tile>
</mat-grid-tile>
<mat-grid-tile>
<dd>{{ygopro.points.athletic_win}}</dd>
</md-grid-tile>
<md-grid-tile>
</mat-grid-tile>
<mat-grid-tile>
<dt>胜场</dt>
</md-grid-tile>
<md-grid-tile>
</mat-grid-tile>
<mat-grid-tile>
<dd>{{ygopro.points.entertain_win}}</dd>
</md-grid-tile>
<md-grid-tile>
</mat-grid-tile>
<mat-grid-tile>
<dt>负场</dt>
</md-grid-tile>
<md-grid-tile>
</mat-grid-tile>
<mat-grid-tile>
<dd>{{ygopro.points.athletic_lose}}</dd>
</md-grid-tile>
<md-grid-tile>
</mat-grid-tile>
<mat-grid-tile>
<dt>负场</dt>
</md-grid-tile>
<md-grid-tile>
</mat-grid-tile>
<mat-grid-tile>
<dd>{{ygopro.points.entertain_lose}}</dd>
</md-grid-tile>
<md-grid-tile>
</mat-grid-tile>
<mat-grid-tile>
<dt>平局</dt>
</md-grid-tile>
<md-grid-tile>
</mat-grid-tile>
<mat-grid-tile>
<dd>{{ygopro.points.athletic_draw}}</dd>
</md-grid-tile>
<md-grid-tile>
</mat-grid-tile>
<mat-grid-tile>
<dt>平局</dt>
</md-grid-tile>
<md-grid-tile>
</mat-grid-tile>
<mat-grid-tile>
<dd>{{ygopro.points.entertain_draw}}</dd>
</md-grid-tile>
<md-grid-tile>
</mat-grid-tile>
<mat-grid-tile>
<dt>总场</dt>
</md-grid-tile>
<md-grid-tile>
</mat-grid-tile>
<mat-grid-tile>
<dd>{{ygopro.points.athletic_all}}</dd>
</md-grid-tile>
<md-grid-tile>
</mat-grid-tile>
<mat-grid-tile>
<dt>总场</dt>
</md-grid-tile>
<md-grid-tile>
</mat-grid-tile>
<mat-grid-tile>
<dd>{{ygopro.points.entertain_all}}</dd>
</md-grid-tile>
</md-grid-list>
</md-card>
<md-card *ngFor="let item of ygopro.news" class="example-card">
</mat-grid-tile>
</mat-grid-list>
</mat-card>
<mat-card *ngFor="let item of ygopro.news" class="example-card">
<a [href]="item.url" target="_blank">
<md-card-header>
<img *ngIf="item.image" md-card-avatar [src]="item.image">
<md-card-title>{{item.title}}</md-card-title>
<md-card-subtitle>{{item.updated_at | date}}</md-card-subtitle>
</md-card-header>
<mat-card-header>
<img *ngIf="item.image" mat-card-avatar [src]="item.image">
<mat-card-title>{{item.title}}</mat-card-title>
<mat-card-subtitle>{{item.updated_at | date}}</mat-card-subtitle>
</mat-card-header>
</a>
</md-card>
</mat-card>
<md-card *ngFor="let item of ygopro.topics | async">
<mat-card *ngFor="let item of ygopro.topics | async">
<a [href]="item.url" target="_blank">
<md-card-header>
<img *ngIf="item.image_url" md-card-avatar [src]="item.image_url">
<md-card-title>{{item.title}}</md-card-title>
<md-card-subtitle>by {{item.last_poster_username}} / {{item.last_posted_at | date}}
</md-card-subtitle>
</md-card-header>
<mat-card-header>
<img *ngIf="item.image_url" mat-card-avatar [src]="item.image_url">
<mat-card-title>{{item.title}}</mat-card-title>
<mat-card-subtitle>by {{item.last_poster_username}} / {{item.last_posted_at | date}}
</mat-card-subtitle>
</mat-card-header>
</a>
</md-card>
</mat-card>
import { Component, HostBinding } from '@angular/core';
import { FormControl } from '@angular/forms';
import { Http, Jsonp } from '@angular/http';
import { environment } from '../../environments/environment';
import { LoginService } from '../login.service';
import { routerTransition2 } from '../router.animations';
import { StorageService } from '../storage.service';
import { YGOProService } from '../ygopro.service';
import { HttpClient } from '@angular/common/http';
import { filter, mergeMap } from 'rxjs/internal/operators';
@Component({
selector: 'app-lobby',
templateUrl: 'lobby.component.html',
......@@ -14,28 +16,22 @@ import { YGOProService } from '../ygopro.service';
animations: [routerTransition2]
})
export class LobbyComponent {
@HostBinding('@routerTransition2')
animation: '';
@HostBinding('@routerTransition2') animation: '';
version = environment.version;
build: BuildConfig;
searchCtrl = new FormControl();
suggestion = this.searchCtrl.valueChanges.filter(name => name).flatMap(name => this.jsonp.get('http://www.ourocg.cn/Suggest.aspx', {
params: {callback: 'JSONP_CALLBACK', key: name}
}).map(response => response.json().result));
suggestion = this.searchCtrl.valueChanges.pipe(
filter(name => name),
mergeMap(name => this.http.get(`https://www.ourocg.cn/search/suggest/${name}`))
);
key: string;
arena_url: string;
constructor(public login: LoginService,
public ygopro: YGOProService,
private http: Http,
private jsonp: Jsonp,
public storage: StorageService) {
constructor(public login: LoginService, public ygopro: YGOProService, private http: HttpClient, public storage: StorageService) {
const arena_url = new URL('https://mycard.moe/ygopro/arena');
arena_url.searchParams.set('sso', login.token);
this.arena_url = arena_url.toString();
......
import { Component, Inject, OnDestroy, OnInit } from '@angular/core';
import { Headers, Http } from '@angular/http';
import { MD_DIALOG_DATA, MdDialogRef } from '@angular/material';
import { Observable } from 'rxjs/Observable';
import { Subscription } from 'rxjs/Subscription';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material';
import { Subscription, timer } from 'rxjs';
import { LoginService } from '../login.service';
import { map } from 'rxjs/internal/operators';
import { HttpClient } from '@angular/common/http';
import { MatchResponse } from '../ygopro.service';
const second = 1000;
const offset = new Date().getTimezoneOffset() * 60 * second;
......@@ -14,34 +15,40 @@ const offset = new Date().getTimezoneOffset() * 60 * second;
styleUrls: ['./match.component.css']
})
export class MatchDialogComponent implements OnInit, OnDestroy {
expect_wait = this.http.get('https://api.mycard.moe/ygopro/match/stats/' + this.arena).map(response => response.json() * second + offset);
actual_wait = Observable.timer(0, second).map(timestamp => timestamp * second + offset);
expect_wait = this.http
.get('https://api.mycard.moe/ygopro/match/stats/' + this.arena)
.pipe(map((data: number) => data * second + offset));
actual_wait = timer(0, second).pipe(map(timestamp => timestamp * second + offset));
matching: Subscription;
constructor(@Inject(MD_DIALOG_DATA) public arena: string,
private dialogRef: MdDialogRef<MatchDialogComponent>,
private http: Http,
private login: LoginService) {
}
constructor(
@Inject(MAT_DIALOG_DATA) public arena: string,
private dialogRef: MatDialogRef<MatchDialogComponent>,
private http: HttpClient,
private login: LoginService
) {}
ngOnInit() {
this.matching = this.http.post('https://api.mycard.moe/ygopro/match', null, {
headers: new Headers({
Authorization: 'Basic ' + Buffer.from(this.login.user.username + ':' + this.login.user.external_id).toString('base64')
}),
params: {arena: this.arena, locale: 'zh-CN'}
}).map(response => response.json()).subscribe((data) => {
this.dialogRef.close(data);
}, (error) => {
alert(`匹配失败`);
this.dialogRef.close();
});
this.matching = this.http
.post<MatchResponse>('https://api.mycard.moe/ygopro/match', null, {
headers: {
Authorization: 'Basic ' + Buffer.from(this.login.user.username + ':' + this.login.user.external_id).toString('base64')
},
params: { arena: this.arena, locale: 'zh-CN' }
})
.subscribe(
data => {
this.dialogRef.close(data);
},
error => {
alert(`匹配失败`);
this.dialogRef.close();
}
);
}
ngOnDestroy() {
this.matching.unsubscribe();
}
}
<app-toolbar>创建房间</app-toolbar>
<form (submit)="ygopro.create_room(room, host_password)" ngNativeValidate>
<md-input-container *ngIf="!room.private" class="full-width">
<input mdInput placeholder="游戏标题" name="title" [(ngModel)]="room.title" minlength="1" maxlength="12" required>
<md-hint align="end">{{room.title?.length || 0}} / 12</md-hint>
</md-input-container>
<md-input-container *ngIf="room.private" class="full-width">
<md-placeholder>
<md-icon>&#xe0da;</md-icon><!-- vpn_key -->
<mat-form-field *ngIf="!room.private" class="full-width">
<input matInput placeholder="游戏标题" name="title" [(ngModel)]="room.title" minlength="1" maxlength="12" required>
<mat-hint align="end">{{room.title?.length || 0}} / 12</mat-hint>
</mat-form-field>
<mat-form-field *ngIf="room.private" class="full-width">
<mat-placeholder>
<mat-icon>&#xe0da;</mat-icon><!-- vpn_key -->
<span>房间密码</span>
</md-placeholder>
<input #hostPasswordInput mdInput name="title" [(ngModel)]="host_password" readonly>
<button type="button" md-icon-button mdSuffix (click)="copy(host_password)">
<md-icon>&#xe14d;</md-icon><!-- content_copy -->
</mat-placeholder>
<input #hostPasswordInput matInput name="title" [(ngModel)]="host_password" readonly>
<button type="button" mat-icon-button matSuffix (click)="copy(host_password)">
<mat-icon>&#xe14d;</mat-icon><!-- content_copy -->
</button>
<button type="button" md-icon-button mdSuffix (click)="share(host_password)">
<md-icon>share</md-icon>
<button type="button" mat-icon-button matSuffix (click)="share(host_password)">
<mat-icon>share</mat-icon>
</button>
<md-hint align="end">把这个分享给你的朋友</md-hint>
</md-input-container>
<md-select class="full-width" placeholder="卡片允许" name="rule" [(ngModel)]="room.options.rule" required>
<md-option [value]="0">OCG</md-option>
<md-option [value]="1">TCG</md-option>
<md-option [value]="2">OCG & TCG</md-option>
<md-option [value]="3">专有卡禁止</md-option>
</md-select>
<md-select class="full-width" placeholder="决斗模式" name="mode" [(ngModel)]="room.options.mode" (ngModelChange)="set_start_lp()" required>
<md-option [value]="0">单局模式</md-option>
<md-option [value]="1">比赛模式</md-option>
<md-option [value]="2">TAG</md-option>
</md-select>
<mat-hint align="end">把这个分享给你的朋友</mat-hint>
</mat-form-field>
<mat-select class="full-width" placeholder="卡片允许" name="rule" [(ngModel)]="room.options.rule" required>
<mat-option [value]="0">OCG</mat-option>
<mat-option [value]="1">TCG</mat-option>
<mat-option [value]="2">OCG & TCG</mat-option>
<mat-option [value]="3">专有卡禁止</mat-option>
</mat-select>
<mat-select class="full-width" placeholder="决斗模式" name="mode" [(ngModel)]="room.options.mode" (ngModelChange)="set_start_lp()" required>
<mat-option [value]="0">单局模式</mat-option>
<mat-option [value]="1">比赛模式</mat-option>
<mat-option [value]="2">TAG</mat-option>
</mat-select>
<!--<h2>额外选项</h2>-->
<!--<md-slide-toggle #extra class="example-margin" color="primary">额外选项</md-slide-toggle>-->
<!--<mat-slide-toggle #extra class="example-margin" color="primary">额外选项</mat-slide-toggle>-->
<md-input-container class="full-width">
<input name="start_lp" [(ngModel)]="room.options.start_lp" mdInput type="number" min="1" max="65536" placeholder="初始 LP" required>
</md-input-container>
<md-input-container class="full-width">
<input name="start_hand" [(ngModel)]="room.options.start_hand" mdInput type="number" min="0" max="16" placeholder="初始手牌数" required>
</md-input-container>
<md-input-container class="full-width">
<input name="draw_count" [(ngModel)]="room.options.draw_count" mdInput type="number" min="0" max="16" placeholder="每回合抽卡" required>
</md-input-container>
<mat-form-field class="full-width">
<input name="start_lp" [(ngModel)]="room.options.start_lp" matInput type="number" min="1" max="65536" placeholder="初始 LP" required>
</mat-form-field>
<mat-form-field class="full-width">
<input name="start_hand" [(ngModel)]="room.options.start_hand" matInput type="number" min="0" max="16" placeholder="初始手牌数" required>
</mat-form-field>
<mat-form-field class="full-width">
<input name="draw_count" [(ngModel)]="room.options.draw_count" matInput type="number" min="0" max="16" placeholder="每回合抽卡" required>
</mat-form-field>
<md-checkbox class="full-width" name="room.private" [(ngModel)]="room.private">私密房间</md-checkbox>
<md-checkbox class="full-width" name="room.enable_priority" [(ngModel)]="room.options.enable_priority">旧规则
</md-checkbox>
<md-checkbox class="full-width" name="room.no_check_deck" [(ngModel)]="room.options.no_check_deck">不检查卡组</md-checkbox>
<md-checkbox class="full-width" name="room.no_shuffle_deck" [(ngModel)]="room.options.no_shuffle_deck">不洗切卡组
</md-checkbox>
<mat-checkbox class="full-width" name="room.private" [(ngModel)]="room.private">私密房间</mat-checkbox>
<mat-checkbox class="full-width" name="room.enable_priority" [(ngModel)]="room.options.enable_priority">旧规则
</mat-checkbox>
<mat-checkbox class="full-width" name="room.no_check_deck" [(ngModel)]="room.options.no_check_deck">不检查卡组</mat-checkbox>
<mat-checkbox class="full-width" name="room.no_shuffle_deck" [(ngModel)]="room.options.no_shuffle_deck">不洗切卡组
</mat-checkbox>
<div id="actions">
<!--<button routerLink="/ygopro/lobby" md-raised-button>返回大厅</button>-->
<button type="submit" color="primary" md-raised-button>创建游戏</button>
<!--<button routerLink="/ygopro/lobby" mat-raised-button>返回大厅</button>-->
<button type="submit" color="primary" mat-raised-button>创建游戏</button>
</div>
</form>
......@@ -26,9 +26,10 @@
flex: 2
}
md-table {
#container {
flex: 1;
padding-bottom: 36px;
position: relative;
}
form {
......
<app-toolbar>房间列表</app-toolbar>
<div class="hint" *ngIf="dataSource.loading"><md-spinner></md-spinner></div>
<div class="hint" *ngIf="dataSource.empty">现在没有等待中的游戏,可以自行创建一个房间或者去匹配</div>
<div class="hint" *ngIf="dataSource.error">网络错误</div>
<md-table #table [dataSource]="dataSource">
<!--- Note that these columns can be defined in any order.
The actual rendered columns are set as a property on room row definition" -->
<!-- ID Column -->
<ng-container cdkColumnDef="title">
<md-header-cell class="game-title" *cdkHeaderCellDef>游戏标题</md-header-cell>
<md-cell class="game-title" *cdkCellDef="let room">{{room.title}}</md-cell>
</ng-container>
<!-- Progress Column -->
<ng-container cdkColumnDef="users">
<md-header-cell *cdkHeaderCellDef>玩家</md-header-cell>
<md-cell *cdkCellDef="let room">
<img *ngFor="let user of room.users" class="avatar" [src]="login.avatar(user.username)">
</md-cell>
</ng-container>
<!-- Name Column -->
<ng-container cdkColumnDef="mode">
<md-header-cell *cdkHeaderCellDef>决斗模式</md-header-cell>
<md-cell *cdkCellDef="let room">
<span *ngIf="room.options.mode === 0">单局模式</span>
<span *ngIf="room.options.mode === 1">比赛模式</span>
<span *ngIf="room.options.mode === 2">TAG</span>
</md-cell>
</ng-container>
<!-- Color Column -->
<ng-container cdkColumnDef="extra">
<md-header-cell *cdkHeaderCellDef>额外选项</md-header-cell>
<md-cell *cdkCellDef="let room">
<span *ngIf="room.options.rule != ygopro.default_options.rule">{{{'0': 'OCG', '1': 'TCG', '2': 'O/T', '3': '专有卡禁止'}[room.options.rule]}}</span>
<span *ngIf="room.options.start_lp != ygopro.default_options.start_lp">{{room.options.start_lp}} LP</span>
<span *ngIf="room.options.start_hand != ygopro.default_options.start_hand">{{room.options.start_hand}} 初始</span>
<span *ngIf="room.options.draw_count != ygopro.default_options.draw_count">{{room.options.draw_count}} 抽卡</span>
<span *ngIf="room.options.enable_priority != ygopro.default_options.enable_priority">旧规则</span>
<span *ngIf="room.options.no_check_deck != ygopro.default_options.no_check_deck">不检查</span>
<span *ngIf="room.options.no_shuffle_deck != ygopro.default_options.no_shuffle_deck">不洗卡</span>
</md-cell>
</ng-container>
<md-header-row *cdkHeaderRowDef="displayedColumns"></md-header-row>
<md-row *cdkRowDef="let room; columns: displayedColumns;" (click)="ygopro.join_room(room)"></md-row>
</md-table>
<div id="container">
<div class="hint" *ngIf="dataSource.loading">
<mat-spinner></mat-spinner>
</div>
<div class="hint" *ngIf="dataSource.empty">现在没有等待中的游戏,可以自行创建一个房间或者去匹配</div>
<div class="hint" *ngIf="dataSource.error">网络错误</div>
<mat-table #table [dataSource]="dataSource">
<!--- Note that these columns can be defined in any order.
The actual rendered columns are set as a property on room row definition" -->
<!-- ID Column -->
<ng-container matColumnDef="title">
<mat-header-cell class="game-title" *matHeaderCellDef>游戏标题</mat-header-cell>
<mat-cell class="game-title" *matCellDef="let room">{{room.title}}</mat-cell>
</ng-container>
<!-- Progress Column -->
<ng-container matColumnDef="users">
<mat-header-cell *matHeaderCellDef>玩家</mat-header-cell>
<mat-cell *matCellDef="let room">
<img *ngFor="let user of room.users" class="avatar" [src]="login.avatar(user.username)">
</mat-cell>
</ng-container>
<!-- Name Column -->
<ng-container matColumnDef="mode">
<mat-header-cell *matHeaderCellDef>决斗模式</mat-header-cell>
<mat-cell *matCellDef="let room">
<span *ngIf="room.options.mode === 0">单局模式</span>
<span *ngIf="room.options.mode === 1">比赛模式</span>
<span *ngIf="room.options.mode === 2">TAG</span>
</mat-cell>
</ng-container>
<!-- Color Column -->
<ng-container matColumnDef="extra">
<mat-header-cell *matHeaderCellDef>额外选项</mat-header-cell>
<mat-cell *matCellDef="let room">
<span *ngIf="room.options.rule != ygopro.default_options.rule">{{{'0': 'OCG', '1': 'TCG', '2': 'O/T', '3': '专有卡禁止'}[room.options.rule]}}</span>
<span *ngIf="room.options.start_lp != ygopro.default_options.start_lp">{{room.options.start_lp}} LP</span>
<span *ngIf="room.options.start_hand != ygopro.default_options.start_hand">{{room.options.start_hand}} 初始</span>
<span *ngIf="room.options.draw_count != ygopro.default_options.draw_count">{{room.options.draw_count}} 抽卡</span>
<span *ngIf="room.options.enable_priority != ygopro.default_options.enable_priority">旧规则</span>
<span *ngIf="room.options.no_check_deck != ygopro.default_options.no_check_deck">不检查</span>
<span *ngIf="room.options.no_shuffle_deck != ygopro.default_options.no_shuffle_deck">不洗卡</span>
</mat-cell>
</ng-container>
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
<mat-row *matRowDef="let room; columns: displayedColumns;" (click)="ygopro.join_room(room)"></mat-row>
</mat-table>
</div>
<form (submit)="ygopro.join_private(joinPassword.value)" ngNativeValidate>
<input #joinPassword placeholder="在这输入你朋友的私密房间密码就可以进去了哦!" required>
<button md-raised-button color="primary">加入私密房间</button>
<button mat-raised-button color="primary">加入私密房间</button>
</form>
import { animate, state, style, transition, trigger } from '@angular/animations';
export const routerTransition = trigger('routerTransition', [
state('void', style({position: 'absolute', width: '100%'})),
state('*', style({position: 'absolute', width: '100%'})),
transition(':enter', [ // before 2.1: transition('void => *', [
style({transform: 'translateX(100%)'}),
animate('.5s ease-in-out', style({transform: 'translateX(0%)'}))
state('void', style({ position: 'absolute', width: '100%' })),
state('*', style({ position: 'absolute', width: '100%' })),
transition(':enter', [
// before 2.1: transition('void => *', [
style({ transform: 'translateX(100%)' }),
animate('.4s', style({ transform: 'translateX(0%)' }))
]),
transition(':leave', [ // before 2.1: transition('* => void', [
style({transform: 'translateX(0%)'}),
animate('.5s ease-in-out', style({transform: 'translateX(100%)'}))
transition(':leave', [
// before 2.1: transition('* => void', [
style({ transform: 'translateX(0%)' }),
animate('.4s', style({ transform: 'translateX(100%)' }))
])
]);
export const routerTransition2 = trigger('routerTransition2', [
state('void', style({position: 'absolute', width: '100%'})),
state('*', style({position: 'absolute', width: '100%'})),
transition(':enter', [ // before 2.1: transition('void => *', [
style({transform: 'translateX(-100%)'}),
animate('.5s ease-in-out', style({transform: 'translateX(0%)'}))
state('void', style({ position: 'absolute', width: '100%' })),
state('*', style({ position: 'absolute', width: '100%' })),
transition(':enter', [
// before 2.1: transition('void => *', [
style({ transform: 'translateX(-100%)' }),
animate('.4s', style({ transform: 'translateX(0%)' }))
]),
transition(':leave', [ // before 2.1: transition('* => void', [
style({transform: 'translateX(0%)'}),
animate('.5s ease-in-out', style({transform: 'translateX(-100%)'}))
transition(':leave', [
// before 2.1: transition('* => void', [
style({ transform: 'translateX(0%)' }),
animate('.4s', style({ transform: 'translateX(-100%)' }))
])
]);
......@@ -26,3 +26,6 @@
flex: 2
}
#container {
position: relative;
}
<app-toolbar>观战</app-toolbar>
<div class="hint" *ngIf="dataSource.loading"><md-spinner></md-spinner></div>
<div class="hint" *ngIf="dataSource.empty">现在没有进行中的游戏</div>
<div class="hint" *ngIf="dataSource.error">网络错误</div>
<md-table #table [dataSource]="dataSource">
<!--- Note that these columns can be defined in any order.
The actual rendered columns are set as a property on room row definition" -->
<!-- ID Column -->
<ng-container cdkColumnDef="mode">
<md-header-cell *cdkHeaderCellDef>游戏模式</md-header-cell>
<md-cell *cdkCellDef="let room">
<span i18n *ngIf="room.id.startsWith('AI#')">单人模式</span>
<span i18n *ngIf="room.arena === 'athletic'">竞技匹配</span>
<span i18n *ngIf="room.arena === 'entertain'">娱乐匹配</span>
<span i18n *ngIf="!(room.arena || room.id.startsWith('AI#')) && room.options.mode === 0">单局模式</span>
<span i18n *ngIf="!(room.arena || room.id.startsWith('AI#')) && room.options.mode === 1">比赛模式</span>
<span i18n *ngIf="!(room.arena || room.id.startsWith('AI#')) && room.options.mode === 2">TAG</span>
</md-cell>
</ng-container>
<!-- ID Column -->
<ng-container cdkColumnDef="title">
<md-header-cell class="game-title" *cdkHeaderCellDef>游戏标题</md-header-cell>
<md-cell class="game-title" *cdkCellDef="let room">
<span *ngIf="room.private">{{room.users[0] && room.users[0].username}}的私密房间</span>
<span i18n *ngIf="room.arena || room.id.startsWith('AI#')">{{room.users[0] && room.users[0].username}} Vs. {{room.users[1] && room.users[1].username}}</span>
<span *ngIf="!(room.arena || room.id.startsWith('AI#') || room.private)">{{room.title}}</span>
</md-cell>
</ng-container>
<!-- Progress Column -->
<ng-container cdkColumnDef="users">
<md-header-cell *cdkHeaderCellDef>玩家</md-header-cell>
<md-cell *cdkCellDef="let room">
<img *ngFor="let user of room.users" class="avatar" [src]="login.avatar(user.username)">
</md-cell>
</ng-container>
<!-- Color Column -->
<ng-container cdkColumnDef="extra">
<md-header-cell *cdkHeaderCellDef>额外选项</md-header-cell>
<md-cell *cdkCellDef="let room">
<span *ngIf="room.options.rule != ygopro.default_options.rule">{{{'0': 'OCG', '1': 'TCG', '2': 'O/T', '3': '专有卡禁止'}[room.options.rule]}}</span>
<span *ngIf="room.options.start_lp != ygopro.default_options.start_lp">{{room.options.start_lp}} LP</span>
<span *ngIf="room.options.start_hand != ygopro.default_options.start_hand">{{room.options.start_hand}} 初始</span>
<span *ngIf="room.options.draw_count != ygopro.default_options.draw_count">{{room.options.draw_count}} 抽卡</span>
<span *ngIf="room.options.enable_priority != ygopro.default_options.enable_priority">旧规则</span>
<span *ngIf="room.options.no_check_deck != ygopro.default_options.no_check_deck">不检查</span>
<span *ngIf="room.options.no_shuffle_deck != ygopro.default_options.no_shuffle_deck">不洗卡</span>
</md-cell>
</ng-container>
<md-header-row *cdkHeaderRowDef="displayedColumns"></md-header-row>
<md-row *cdkRowDef="let room; columns: displayedColumns;" (click)="ygopro.join_room(room)"></md-row>
</md-table>
<div id="container">
<div class="hint" *ngIf="dataSource.loading">
<mat-spinner></mat-spinner>
</div>
<div class="hint" *ngIf="dataSource.empty">现在没有进行中的游戏</div>
<div class="hint" *ngIf="dataSource.error">网络错误</div>
<mat-table #table [dataSource]="dataSource">
<!--- Note that these columns can be defined in any order.
The actual rendered columns are set as a property on room row definition" -->
<!-- ID Column -->
<ng-container matColumnDef="mode">
<mat-header-cell *matHeaderCellDef>游戏模式</mat-header-cell>
<mat-cell *matCellDef="let room">
<span i18n *ngIf="room.id.startsWith('AI#')">单人模式</span>
<span i18n *ngIf="room.arena === 'athletic'">竞技匹配</span>
<span i18n *ngIf="room.arena === 'entertain'">娱乐匹配</span>
<span i18n *ngIf="!(room.arena || room.id.startsWith('AI#')) && room.options.mode === 0">单局模式</span>
<span i18n *ngIf="!(room.arena || room.id.startsWith('AI#')) && room.options.mode === 1">比赛模式</span>
<span i18n *ngIf="!(room.arena || room.id.startsWith('AI#')) && room.options.mode === 2">TAG</span>
</mat-cell>
</ng-container>
<!-- ID Column -->
<ng-container matColumnDef="title">
<mat-header-cell class="game-title" *matHeaderCellDef>游戏标题</mat-header-cell>
<mat-cell class="game-title" *matCellDef="let room">
<span *ngIf="room.private">{{room.users[0] && room.users[0].username}}的私密房间</span>
<span i18n *ngIf="room.arena || room.id.startsWith('AI#')">{{room.users[0] && room.users[0].username}} Vs. {{room.users[1] && room.users[1].username}}</span>
<span *ngIf="!(room.arena || room.id.startsWith('AI#') || room.private)">{{room.title}}</span>
</mat-cell>
</ng-container>
<!-- Progress Column -->
<ng-container matColumnDef="users">
<mat-header-cell *matHeaderCellDef>玩家</mat-header-cell>
<mat-cell *matCellDef="let room">
<img *ngFor="let user of room.users" class="avatar" [src]="login.avatar(user.username)">
</mat-cell>
</ng-container>
<!-- Color Column -->
<ng-container matColumnDef="extra">
<mat-header-cell *matHeaderCellDef>额外选项</mat-header-cell>
<mat-cell *matCellDef="let room">
<span *ngIf="room.options.rule != ygopro.default_options.rule">{{{'0': 'OCG', '1': 'TCG', '2': 'O/T', '3': '专有卡禁止'}[room.options.rule]}}</span>
<span *ngIf="room.options.start_lp != ygopro.default_options.start_lp">{{room.options.start_lp}} LP</span>
<span *ngIf="room.options.start_hand != ygopro.default_options.start_hand">{{room.options.start_hand}} 初始</span>
<span *ngIf="room.options.draw_count != ygopro.default_options.draw_count">{{room.options.draw_count}} 抽卡</span>
<span *ngIf="room.options.enable_priority != ygopro.default_options.enable_priority">旧规则</span>
<span *ngIf="room.options.no_check_deck != ygopro.default_options.no_check_deck">不检查</span>
<span *ngIf="room.options.no_shuffle_deck != ygopro.default_options.no_shuffle_deck">不洗卡</span>
</mat-cell>
</ng-container>
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
<mat-row *matRowDef="let room; columns: displayedColumns;" (click)="ygopro.join_room(room)"></mat-row>
</mat-table>
</div>
import { DataSource } from '@angular/cdk';
import { DataSource } from '@angular/cdk/collections';
import { Injectable } from '@angular/core';
import { Http } from '@angular/http';
import { MdDialog } from '@angular/material';
import { MatDialog } from '@angular/material';
import { sortBy } from 'lodash';
import { Observable } from 'rxjs/Observable';
import { combineLatest, fromEvent, Observable, of } from 'rxjs';
import { LoginService } from './login.service';
import { MatchDialogComponent } from './match/match.component';
import { ResultDialogComponent } from './result/result.dialog';
import { StorageService } from './storage.service';
import { HttpClient } from '@angular/common/http';
import { catchError, filter, map, scan } from 'rxjs/internal/operators';
import { webSocket } from 'rxjs/webSocket';
export interface User {
admin: boolean;
......@@ -23,10 +26,10 @@ export interface Room {
id?: string;
title?: string;
server?: Server;
'private'?: boolean;
private?: boolean;
options: Options;
arena?: string;
users?: { username: string, position: number }[];
users?: { username: string; position: number }[];
}
export interface Options {
......@@ -42,7 +45,6 @@ export interface Options {
time_limit?: number;
}
export interface Server {
id?: string;
url?: string;
......@@ -110,7 +112,6 @@ export interface Points {
@Injectable()
export class YGOProService {
news: News[];
windbot: string[];
topics: Observable<any>;
......@@ -131,52 +132,58 @@ export class YGOProService {
time_limit: 180
};
readonly servers: Server[] = [{
id: 'tiramisu',
url: 'wss://tiramisu.mycard.moe:7923',
address: '112.124.105.11',
port: 7911,
custom: true,
replay: true
}, {
id: 'tiramisu-athletic',
url: 'wss://tiramisu.mycard.moe:8923',
address: '112.124.105.11',
port: 8911,
custom: false,
replay: true
}];
constructor(private login: LoginService, private http: Http, private dialog: MdDialog, private storage: StorageService) {
readonly servers: Server[] = [
{
id: 'tiramisu',
url: 'wss://tiramisu.mycard.moe:7923',
address: '112.124.105.11',
port: 7911,
custom: true,
replay: true
},
{
id: 'tiramisu-athletic',
url: 'wss://tiramisu.mycard.moe:8923',
address: '112.124.105.11',
port: 8911,
custom: false,
replay: true
}
];
constructor(private login: LoginService, private http: HttpClient, private dialog: MatDialog, private storage: StorageService) {
this.load().catch(alert);
}
async load() {
const apps: App[] = await this.http.get('https://api.mycard.moe/apps.json').map(response => response.json()).toPromise();
const apps = await this.http.get<App[]>('https://api.mycard.moe/apps.json').toPromise();
const app = apps.find(_app => _app.id === 'ygopro')!;
this.news = app.news['zh-CN'];
this.windbot = (<YGOProData>app.data).windbot['zh-CN'];
this.topics = this.http.get('https://ygobbs.com/top/quarterly.json').map(
response => response.json().topic_list.topics.slice(0, 5).map((topic: any) => ({
...topic,
url: new URL(`/t/${topic.slug}/${topic.id}`, 'https://ygobbs.com').toString(),
image_url: topic.image_url && new URL(topic.image_url, 'https://ygobbs.com').toString()
})));
this.topics = this.http.get<TopResponse>('https://ygobbs.com/top/quarterly.json').pipe(
map(data =>
data.topic_list.topics.slice(0, 5).map((topic: any) => ({
...topic,
url: new URL(`/t/${topic.slug}/${topic.id}`, 'https://ygobbs.com').toString(),
image_url: topic.image_url && new URL(topic.image_url, 'https://ygobbs.com').toString()
}))
)
);
this.storage.sync('ygopro');
this.load_points();
await this.load_result(false);
this.listen_result();
}
async load_result(load_points = true) {
const last = await this.http.get('https://mycard.moe/ygopro/api/history', {
params: {username: this.login.user.username, type: 0, page_num: 1}
}).map((response) => response.json().data[0]).toPromise();
const last = await this.http
.get<{ data: any[] }>('https://mycard.moe/ygopro/api/history', {
params: { username: this.login.user.username, type: '0', page_num: '1' }
})
.pipe(map(data => data.data[0]))
.toPromise();
// 从来没打过
if (!last) {
......@@ -201,7 +208,10 @@ export class YGOProService {
if (load_points) {
this.load_points();
}
const again = await this.dialog.open(ResultDialogComponent, {data: last}).afterClosed().toPromise();
const again = await this.dialog
.open(ResultDialogComponent, { data: last })
.afterClosed()
.toPromise();
if (again) {
this.request_match(last.type);
}
......@@ -209,28 +219,30 @@ export class YGOProService {
}
async request_match(arena: string) {
const data = await this.dialog.open(MatchDialogComponent, {data: arena, disableClose: true}).afterClosed().toPromise();
const data = await this.dialog
.open(MatchDialogComponent, { data: arena, disableClose: true })
.afterClosed()
.toPromise();
if (data) {
this.join(data['password'], {address: data['address'], port: data['port']});
this.join(data['password'], { address: data['address'], port: data['port'] });
}
}
listen_result() {
// 那些兼容性的垃圾事儿
// https://www.html5rocks.com/en/tutorials/pagevisibility/intro/
const hidden = ['hidden', 'webkitHidden', 'mozHidden', 'msHidden', 'oHidden'].find((prop) => prop in document);
const hidden = ['hidden', 'webkitHidden', 'mozHidden', 'msHidden', 'oHidden'].find(prop => prop in document);
if (hidden) {
const evtname = hidden.replace(/[H|h]idden/, '') + 'visibilitychange';
Observable.fromEvent(document, evtname).subscribe(() => {
fromEvent(document, evtname).subscribe(() => {
if (!document[hidden]) {
this.load_result();
this.storage.sync('ygopro');
}
});
} else {
Observable.fromEvent(window, 'focus').subscribe(() => {
fromEvent(window, 'focus').subscribe(() => {
this.load_result();
this.storage.sync('ygopro');
});
......@@ -238,8 +250,9 @@ export class YGOProService {
}
async load_points() {
this.points = await this.http.get('https://api.mycard.moe/ygopro/arena/user', {params: {username: this.login.user.username}}).map(
response => response.json()).toPromise();
this.points = await this.http
.get<Points>('https://api.mycard.moe/ygopro/arena/user', { params: { username: this.login.user.username } })
.toPromise();
}
create_room(room: Room, host_password: string) {
......@@ -247,27 +260,28 @@ export class YGOProService {
// 建主密码 https://docs.google.com/document/d/1rvrCGIONua2KeRaYNjKBLqyG9uybs9ZI-AmzZKNftOI/edit
options_buffer.writeUInt8((room.private ? 2 : 1) << 4, 1);
options_buffer.writeUInt8(
room.options.rule << 5 |
room.options.mode << 3 |
(room.options.enable_priority ? 1 << 2 : 0) |
(room.options.no_check_deck ? 1 << 1 : 0) |
(room.options.no_shuffle_deck ? 1 : 0)
, 2);
(room.options.rule << 5) |
(room.options.mode << 3) |
(room.options.enable_priority ? 1 << 2 : 0) |
(room.options.no_check_deck ? 1 << 1 : 0) |
(room.options.no_shuffle_deck ? 1 : 0),
2
);
options_buffer.writeUInt16LE(room.options.start_lp, 3);
options_buffer.writeUInt8(room.options.start_hand << 4 | room.options.draw_count, 5);
options_buffer.writeUInt8((room.options.start_hand << 4) | room.options.draw_count, 5);
let checksum = 0;
for (let i = 1; i < options_buffer.length; i++) {
checksum -= options_buffer.readUInt8(i);
}
options_buffer.writeUInt8(checksum & 0xFF, 0);
options_buffer.writeUInt8(checksum & 0xff, 0);
const secret = this.login.user.external_id % 65535 + 1;
for (let i = 0; i < options_buffer.length; i += 2) {
options_buffer.writeUInt16LE(options_buffer.readUInt16LE(i) ^ secret, i);
}
const password = options_buffer.toString('base64') + (room.private ? host_password :
room.title!.replace(/\s/, String.fromCharCode(0xFEFF)));
const password =
options_buffer.toString('base64') + (room.private ? host_password : room.title!.replace(/\s/, String.fromCharCode(0xfeff)));
// let room_id = crypto.createHash('md5').update(password + this.loginService.user.username).digest('base64')
// .slice(0, 10).replace('+', '-').replace('/', '_');
......@@ -286,7 +300,7 @@ export class YGOProService {
for (let i = 1; i < options_buffer.length; i++) {
checksum -= options_buffer.readUInt8(i);
}
options_buffer.writeUInt8(checksum & 0xFF, 0);
options_buffer.writeUInt8(checksum & 0xff, 0);
const secret = this.login.user.external_id % 65535 + 1;
for (let i = 0; i < options_buffer.length; i += 2) {
......@@ -305,14 +319,14 @@ export class YGOProService {
for (let i = 1; i < options_buffer.length; i++) {
checksum -= options_buffer.readUInt8(i);
}
options_buffer.writeUInt8(checksum & 0xFF, 0);
options_buffer.writeUInt8(checksum & 0xff, 0);
const secret = this.login.user.external_id % 65535 + 1;
for (let i = 0; i < options_buffer.length; i += 2) {
options_buffer.writeUInt16LE(options_buffer.readUInt16LE(i) ^ secret, i);
}
const name = options_buffer.toString('base64') + password.replace(/\s/, String.fromCharCode(0xFEFF));
const name = options_buffer.toString('base64') + password.replace(/\s/, String.fromCharCode(0xfeff));
this.join(name, this.servers[0]);
}
......@@ -329,10 +343,12 @@ export class YGOProService {
window.ygopro.join(server.address, server.port, this.login.user.username, password);
} catch (error) {
console.error(error);
alert(JSON.stringify({
method: 'join',
params: [server.address, server.port, this.login.user.username, password]
}));
alert(
JSON.stringify({
method: 'join',
params: [server.address, server.port, this.login.user.username, password]
})
);
}
}
......@@ -341,7 +357,7 @@ export class YGOProService {
window.ygopro.edit_deck();
} catch (error) {
console.error(error);
alert(JSON.stringify({method: 'edit_deck', params: []}));
alert(JSON.stringify({ method: 'edit_deck', params: [] }));
}
}
......@@ -350,7 +366,7 @@ export class YGOProService {
window.ygopro.watch_replay();
} catch (error) {
console.error(error);
alert(JSON.stringify({method: 'watch_replay', params: []}));
alert(JSON.stringify({ method: 'watch_replay', params: [] }));
}
}
......@@ -359,7 +375,7 @@ export class YGOProService {
window.ygopro.puzzle_mode();
} catch (error) {
console.error(error);
alert(JSON.stringify({method: 'puzzle_mode', params: []}));
alert(JSON.stringify({ method: 'puzzle_mode', params: [] }));
}
}
......@@ -368,7 +384,7 @@ export class YGOProService {
window.ygopro.openDrawer();
} catch (error) {
console.error(error);
alert(JSON.stringify({method: 'openDrawer', params: []}));
alert(JSON.stringify({ method: 'openDrawer', params: [] }));
}
}
......@@ -377,7 +393,7 @@ export class YGOProService {
window.ygopro.backHome();
} catch (error) {
console.error(error);
alert(JSON.stringify({method: 'backHome', params: []}));
alert(JSON.stringify({ method: 'backHome', params: [] }));
}
}
......@@ -386,54 +402,56 @@ export class YGOProService {
window.ygopro.share(text);
} catch (error) {
console.error(error);
alert(JSON.stringify({method: 'share', params: [text]}));
alert(JSON.stringify({ method: 'share', params: [text] }));
}
}
}
type Message =
{ event: 'init', data: Room[] }
| { event: 'update', data: Room }
| { event: 'create', data: Room }
| { event: 'delete', data: string };
export class RoomListDataSource extends DataSource<any> {
| { event: 'init'; data: Room[] }
| { event: 'update'; data: Room }
| { event: 'create'; data: Room }
| { event: 'delete'; data: string };
export class RoomListDataSource extends DataSource<Room> {
loading = true;
empty = false;
error: any;
constructor(private servers: Server[], private filter = 'waiting') {
constructor(private servers: Server[], private type = 'waiting') {
super();
}
/** Connect function called by the table to retrieve one stream containing the data to render. */
connect(): Observable<Room[]> {
return Observable.combineLatest(this.servers.map(server => {
const url = new URL(server.url!);
url.searchParams.set('filter', this.filter);
// 协议处理
return Observable.webSocket({url: url.toString()})
.scan((rooms: Room[], message: Message) => {
switch (message.event) {
case 'init':
return message.data.map(room => ({server: server, ...room}));
case 'create':
return rooms.concat({server: server, ...message.data});
case 'update':
Object.assign(rooms.find(room => room.id === message.data.id), message.data);
return rooms;
case 'delete':
return rooms.filter(room => room.id !== message.data);
}
}, []);
// 把多个服务器的数据拼接起来,这里是 combineLatest 的第二个参数
}), (...sources: Room[][]) => (<Room[]>[]).concat(...sources))
// 房间排序
.map(rooms => sortBy(rooms, (room) => {
return combineLatest(
this.servers.map(server => {
const url = new URL(server.url!);
url.searchParams.set('filter', this.type);
// 协议处理
return webSocket<Message>(url.toString()).pipe(
scan((rooms: Room[], message: Message, index: number) => {
switch (message.event) {
case 'init':
return message.data.map(room => ({ server: server, ...room }));
case 'create':
return rooms.concat({ server: server, ...message.data });
case 'update':
Object.assign(rooms.find(room => room.id === message.data.id), message.data);
return rooms;
case 'delete':
return rooms.filter(room => room.id !== message.data);
}
}, [])
);
})
).pipe(
// 把多个服务器的数据拼接起来
map((sources: Room[][]) => (<Room[]>[]).concat(...sources)),
// 房间排序
map(rooms =>
sortBy(rooms, room => {
if (room.arena === 'athletic') {
return 0;
} else if (room.arena === 'entertain') {
......@@ -444,19 +462,30 @@ export class RoomListDataSource extends DataSource<any> {
return room.options.mode + 2;
}
})
// loading、empty、error
).filter((rooms) => {
),
// loading、empty、error
filter(rooms => {
this.loading = false;
this.empty = rooms.length === 0;
return true;
}).catch((error) => {
}),
catchError(error => {
this.loading = false;
this.error = error;
return [];
});
return of([]);
})
);
}
disconnect() {
}
disconnect() {}
}
export interface MatchResponse {
password: string;
address: string;
port: number;
}
export interface TopResponse {
topic_list: { topics: { slug: string; id: string }[] };
}
# This file is currently used by autoprefixer to adjust CSS to support the below specified browsers
# For additional information regarding the format and rule options, please see:
# https://github.com/browserslist/browserslist#queries
# For IE 9-11 support, please uncomment the last line of the file and adjust as needed
> 0.5%
last 2 versions
Firefox ESR
not dead
# IE 9-11
\ No newline at end of file
......@@ -3,9 +3,11 @@
<head>
<meta charset="utf-8">
<title>MyCard Mobile</title>
<base href="/mobile/">
<base href="/">
<meta name="theme-color" content="#673ab7">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<meta name="theme-color" content="#1976d2">
</head>
<body>
<app-root>
......
......@@ -37,22 +37,38 @@
/** IE10 and IE11 requires the following for NgClass support on SVG elements */
// import 'classlist.js'; // Run `npm install --save classlist.js`.
/** Evergreen browsers require these. **/
/** IE10 and IE11 requires the following for the Reflect API. */
// import 'core-js/es6/reflect';
/** Evergreen browsers require these. **/
// Used for reflect-metadata in JIT. If you use AOT (and only Angular decorators), you can remove.
// import 'core-js/es7/reflect';
import 'core-js/shim';
/**
* Required to support Web Animations `@angular/animation`.
* Required to support Web Animations `@angular/platform-browser/animations`.
* Needed for: All but Chrome, Firefox and Opera. http://caniuse.com/#feat=web-animation
**/
// import 'web-animations-js'; // Run `npm install --save web-animations-js`.
/**
* By default, zone.js will patch all possible macroTask and DomEvents
* user can disable parts of macroTask/DomEvents patch by setting following flags
*/
// (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
// (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
// (window as any).__zone_symbol__BLACK_LISTED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
/*
* in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
* with the following flag, it will bypass `zone.js` patch for IE/Edge
*/
// (window as any).__Zone_enable_cross_context_check = true;
/***************************************************************************************************
* Zone JS is required by Angular itself.
* Zone JS is required by default for Angular itself.
*/
import 'zone.js/dist/zone'; // Included with Angular CLI.
......@@ -61,13 +77,3 @@ import 'zone.js/dist/zone'; // Included with Angular CLI.
/***************************************************************************************************
* APPLICATION IMPORTS
*/
/**
* Date, curm -rf node_modules/rrency, decimal and percent pipes.
* Needed for: All but Chrome, Firefox, Edge, IE11 and Safari 10
*/
// import 'intl'; // Run `npm install --save intl`.
/**
* Need to import at least one locale-data with intl.
*/
// import 'intl/locale-data/jsonp/en';
......@@ -2,14 +2,10 @@
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/app",
"baseUrl": "./",
"module": "es2015",
"types": [
"node"
]
"types": ["node"]
},
"exclude": [
"test.ts",
"**/*.spec.ts"
"node_modules"
]
}
{
"extends": "../tslint.json",
"rules": {
"directive-selector": [
true,
"attribute",
"app",
"camelCase"
],
"component-selector": [
true,
"element",
"app",
"kebab-case"
]
}
}
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"downlevelIteration": true,
"target": "es5",
"strict": true,
"suppressImplicitAnyIndexErrors": true,
"noImplicitAny": false,
"target": "es2017",
"typeRoots": [
"node_modules/@types"
],
......
......@@ -11,11 +11,14 @@
"check-space"
],
"curly": true,
"deprecation": {
"severity": "warn"
},
"eofline": true,
"forin": true,
"import-blacklist": [
true,
"rxjs"
"rxjs/Rx"
],
"import-spacing": true,
"indent": [
......@@ -103,7 +106,6 @@
"variable-declaration": "nospace"
}
],
"typeof-compare": true,
"unified-signatures": true,
"variable-name": false,
"whitespace": [
......@@ -114,18 +116,7 @@
"check-separator",
"check-type"
],
"directive-selector": [
true,
"attribute",
"app",
"camelCase"
],
"component-selector": [
true,
"element",
"app",
"kebab-case"
],
"no-output-on-prefix": true,
"use-input-property-decorator": true,
"use-output-property-decorator": true,
"use-host-property-decorator": true,
......@@ -134,9 +125,6 @@
"use-life-cycle-interface": true,
"use-pipe-transform-interface": true,
"component-class-suffix": true,
"directive-class-suffix": true,
"no-access-missing-member": true,
"templates-use-public": true,
"invoke-injectable": true
"directive-class-suffix": true
}
}
Index: node_modules/@angular-devkit/build-angular/src/browser/index.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- node_modules/@angular-devkit/build-angular/src/browser/index.js (date 1529225778000)
+++ node_modules/@angular-devkit/build-angular/src/browser/index.js (date 1529225778000)
@@ -115,6 +115,13 @@
webpack_configs_1.getCommonConfig(wco),
webpack_configs_1.getBrowserConfig(wco),
webpack_configs_1.getStylesConfig(wco),
+ {
+ node: {
+ Buffer: true,
+ path: true,
+ stream: true
+ }
+ }
];
if (wco.buildOptions.main || wco.buildOptions.polyfills) {
const typescriptConfigPartial = wco.buildOptions.aot
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment