Commit 310894ef authored by 2breakegg's avatar 2breakegg

showResult

parent 9e718d7e
......@@ -47,6 +47,10 @@ progress {
border-top-left-radius: 0;
}
.i-b{
display: inline-block;
}
.custom-file {
width: 100%;
}
......
......@@ -15,14 +15,14 @@
<!--应用已购买,未安装-->
<div *ngIf="currentApp.isBought() && !currentApp.isInstalled()">
<div *ngIf="currentApp.isBought() && !currentApp.isInstalled()" class="i-b">
<button i18n (click)="updateInstallOption(currentApp)" type="button" class="btn btn-primary btn-sm" data-toggle="modal" data-target="#install-modal">安装</button>
<button i18n *ngIf="currentApp.runnable()" (click)="updateInstallOption(currentApp)" type="button" class="btn btn-secondary btn-sm" data-toggle="modal" data-target="#import-modal">导入</button>
</div>
<!--应用变更中-->
<div *ngIf="currentApp.isInstalled() && !currentApp.isReady()">
<div id="status">
<div *ngIf="currentApp.isInstalled() && !currentApp.isReady()" class="i-b">
<div id="status" class="i-b">
<span i18n *ngIf="currentApp.isDownloading()">正在下载</span>
<span i18n *ngIf="currentApp.isInstalling()">正在安装...</span>
<span i18n *ngIf="currentApp.isUninstalling()">正在卸载...</span>
......@@ -35,29 +35,35 @@
</div>
<!--应用ready-->
<div *ngIf="currentApp.isReady() && (currentApp.id != 'ygopro')">
<div *ngIf="currentApp.isReady() && (currentApp.id != 'ygopro')" class="i-b">
<button *ngIf="currentApp.runnable()" (click)="runApp(currentApp)" [disabled]="!appsService.allReady(currentApp)" type="button" class="btn btn-primary btn-sm">
<i class="fa fa-play" aria-hidden="true"></i> <span i18n>运行</span></button>
<button *ngIf="currentApp.actions.get('network')" [disabled]="!appsService.allReady(currentApp)" (click)="runApp(currentApp,'network')" type="button" class="btn btn-primary btn-sm">
<i class="fa fa-play" aria-hidden="true"></i> <span>运行 (联机版)</span></button>
<button i18n *ngIf="currentApp.runnable() && currentApp.actions.get('custom')" [disabled]="!appsService.allReady(currentApp)" (click)="custom(currentApp)" type="button" class="btn btn-secondary btn-sm">设置</button>
<div id="network" *ngIf="currentApp.network && currentApp.network.protocol == 'maotama'">
<div class="input-group input-group-sm">
<input *ngIf="appsService.connections.get(currentApp)" [value]="appsService.connections.get(currentApp).address || 'Loading...'" readonly type="text" class="form-control" title="address">
<div class="input-group-btn" style="flex-direction: row">
<button i18n *ngIf="!appsService.connections.get(currentApp)" [disabled]="!appsService.allReady(currentApp)" (click)="appsService.network(currentApp, currentApp.network.servers[0])" type="button" class="btn btn-secondary btn-sm">联机</button>
<button i18n *ngIf="appsService.connections.get(currentApp)" (click)="copy(appsService.connections.get(currentApp).address)" [disabled]="!appsService.connections.get(currentApp).address" type="button" class="btn btn-secondary btn-sm">复制</button>
<button type="button" class="btn btn-sm btn-secondary dropdown-toggle dropdown-toggle-split" data-toggle="dropdown"></button>
<div class="dropdown-menu" [class.dropdown-menu-right]="appsService.connections.get(currentApp)">
<h6 i18n class="dropdown-header">选择服务器</h6>
<a *ngFor="let server of currentApp.network.servers" (click)="appsService.network(currentApp, server)" class="dropdown-item" href="#">{{server.id}}</a>
<div *ngIf="appsService.connections.get(currentApp)" class="dropdown-divider"></div>
<a i18n *ngIf="appsService.connections.get(currentApp)" (click)="appsService.connections.get(currentApp).connection.close()" class="dropdown-item" href="#">取消</a>
</div>
</div>
</div>
</div>
<!--<div id="network" *ngIf="currentApp.network && currentApp.network.protocol == 'maotama'">-->
<!--<div class="input-group input-group-sm">-->
<!--<input *ngIf="appsService.connections.get(currentApp)" [value]="appsService.connections.get(currentApp).address || 'Loading...'" readonly type="text" class="form-control" title="address">-->
<!--<div class="input-group-btn" style="flex-direction: row">-->
<!--<button i18n *ngIf="!appsService.connections.get(currentApp)" [disabled]="!appsService.allReady(currentApp)" (click)="appsService.network(currentApp, currentApp.network.servers[0])" type="button" class="btn btn-secondary btn-sm">联机</button>-->
<!--<button i18n *ngIf="appsService.connections.get(currentApp)" (click)="copy(appsService.connections.get(currentApp).address)" [disabled]="!appsService.connections.get(currentApp).address" type="button" class="btn btn-secondary btn-sm">复制</button>-->
<!--<button type="button" class="btn btn-sm btn-secondary dropdown-toggle dropdown-toggle-split" data-toggle="dropdown"></button>-->
<!--<div class="dropdown-menu" [class.dropdown-menu-right]="appsService.connections.get(currentApp)">-->
<!--<h6 i18n class="dropdown-header">选择服务器</h6>-->
<!--<a *ngFor="let server of currentApp.network.servers" (click)="appsService.network(currentApp, server)" class="dropdown-item" href="#">{{server.id}}</a>-->
<!--<div *ngIf="appsService.connections.get(currentApp)" class="dropdown-divider"></div>-->
<!--<a i18n *ngIf="appsService.connections.get(currentApp)" (click)="appsService.connections.get(currentApp).connection.close()" class="dropdown-item" href="#">取消</a>-->
<!--</div>-->
<!--</div>-->
<!--</div>-->
<!--</div>-->
</div>
<!--<button (click)="log(appsService)">test</button>-->
<network *ngIf="(currentApp.id != 'ygopro') && currentApp && currentApp.network && currentApp.network.protocol == 'maotama'" [currentApp]="currentApp"></network>
<ygopro *ngIf="currentApp.isReady() && (currentApp.id == 'ygopro')" [app]="currentApp" [currentApp]="currentApp" (points)="onPoints($event)"></ygopro>
</div>
......
import { ChangeDetectorRef, Component, ElementRef, Input, OnChanges, OnInit, SimpleChanges } from '@angular/core';
import { AppsService } from './apps.service';
import { InstallOption } from './install-option';
import { SettingsService } from './settings.sevices';
import { App } from './app';
import { DownloadService } from './download.service';
import { clipboard, remote } from 'electron';
import {ChangeDetectorRef, Component, ElementRef, Input, OnChanges, OnInit, SimpleChanges} from '@angular/core';
import {AppsService} from './apps.service';
import {InstallOption} from './install-option';
import {SettingsService} from './settings.sevices';
import {App} from './app';
import {DownloadService} from './download.service';
import {clipboard, remote} from 'electron';
import * as path from 'path';
import * as fs from 'fs';
import * as $ from 'jquery';
import { Points } from './ygopro.component';
import { Http } from '@angular/http';
import { LoginService } from './login.service';
import {Points} from './ygopro.component';
import {Http} from '@angular/http';
import {LoginService} from './login.service';
declare const Notification: any;
......@@ -34,7 +34,7 @@ export class AppDetailComponent implements OnInit, OnChanges {
installOption: InstallOption;
availableLibraries: string[] = [];
references: App[];
referencesInstall: {[id: string]: boolean};
referencesInstall: { [id: string]: boolean };
import_path: string;
background: string;
......@@ -51,18 +51,18 @@ export class AppDetailComponent implements OnInit, OnChanges {
private http: Http, private loginService: LoginService) {
this.tags = this.settingsService.getLocale().startsWith('zh') ? {
'recommend': '推荐',
'mysterious': '迷之物体',
'touhou': '东方 Project',
'touhou_pc98': '东方旧作',
'language': '语言包'
} : {
'recommend': 'Recommended',
'mysterious': 'Something',
'touhou': 'Touhou Project',
'touhou_pc98': 'Touhou old series',
'language': 'Language Pack'
};
'recommend': '推荐',
'mysterious': '迷之物体',
'touhou': '东方 Project',
'touhou_pc98': '东方旧作',
'language': '语言包'
} : {
'recommend': 'Recommended',
'mysterious': 'Something',
'touhou': 'Touhou Project',
'touhou_pc98': 'Touhou old series',
'language': 'Language Pack'
};
}
async ngOnChanges(changes: SimpleChanges) {
......@@ -147,7 +147,7 @@ export class AppDetailComponent implements OnInit, OnChanges {
}
}
async install(targetApp: App, options: InstallOption, referencesInstall: {[id: string]: boolean}) {
async install(targetApp: App, options: InstallOption, referencesInstall: { [id: string]: boolean }) {
$('#install-modal').modal('hide');
try {
......@@ -203,7 +203,7 @@ export class AppDetailComponent implements OnInit, OnChanges {
this.appsService.runApp(app, 'custom');
}
async importGame(targetApp: App, option: InstallOption, referencesInstall: {[id: string]: boolean}) {
async importGame(targetApp: App, option: InstallOption, referencesInstall: { [id: string]: boolean }) {
$('#import-modal').modal('hide');
let dir = path.dirname(this.import_path);
// TODO: 执行依赖和references安装
......
......@@ -1274,24 +1274,32 @@ export class AppsService {
app.reset();
}
showResult(data: any) {
showResult(url: string, data: any, width = 320, height = 180) {
const data_str = JSON.stringify(data);
const BrowserWindow = require('electron').remote.BrowserWindow;
let y = screen.availHeight - 190;
let x = screen.availWidth - 330;
let win = new BrowserWindow({
width: 330,
height: 190,
const BrowserWindow = remote.BrowserWindow;
width += 10;
height += 10;
let y = screen.availHeight - height;
let x = screen.availWidth - width;
let littleWindow = new BrowserWindow({
width: width,
height: height,
x: x,
y: y,
frame: process.platform === 'darwin',
titleBarStyle: process.platform === 'darwin' ? 'hidden' : undefined
titleBarStyle: process.platform === 'darwin' ? 'hidden' : undefined,
parent: remote.getCurrentWindow()
});
win.on('closed', function () {
win = null!;
littleWindow.on('closed', function () {
littleWindow = null!;
});
let urlt = new URL('end.html', window.location.toString());
let urlt = new URL(url, window.location.toString());
urlt.searchParams.set('data', data_str);
win.loadURL(urlt.toString());
littleWindow.loadURL(urlt.toString());
remote.ipcMain.on('massage', () => {
alert('from littleWindow');
});
}
}
......@@ -16,13 +16,14 @@ import { DownloadService } from './download.service';
import { AboutComponent } from './about.component';
import { CandyComponent } from './candy.component';
import { RavenErrorHandler } from './error-handler';
import { NetworkComponent } from './network.component';
@NgModule({
imports: [BrowserModule, FormsModule, ReactiveFormsModule, HttpModule],
declarations: [
MyCardComponent, LoginComponent, StoreComponent, LobbyComponent,
AppDetailComponent, RosterComponent, YGOProComponent, AboutComponent, CandyComponent
AppDetailComponent, RosterComponent, YGOProComponent, AboutComponent, CandyComponent, NetworkComponent
],
bootstrap: [MyCardComponent],
providers: [
......@@ -31,10 +32,10 @@ import { RavenErrorHandler } from './error-handler';
provide: LOCALE_ID,
deps: [SettingsService],
useFactory: (settingsService: SettingsService) => settingsService.getLocale()
},
{
provide: ErrorHandler, useClass: RavenErrorHandler
}
// , {
// provide: ErrorHandler, useClass: RavenErrorHandler
// }
],
schemas: [NO_ERRORS_SCHEMA]
})
......
#network {
display: inline-block;
vertical-align: middle;
width: 230px;
}
#network .input-group-btn > .btn:not(:last-child):not(.dropdown-toggle) {
border-bottom-right-radius: 0;
border-top-right-radius: 0;
}
#network .input-group-btn > .dropdown-toggle {
border-bottom-left-radius: 0;
border-top-left-radius: 0;
}
\ No newline at end of file
<div id="network" *ngIf="currentApp.network && currentApp.network.protocol == 'maotama'">
<!--<button (click)="log(appsService)">test</button>-->
<div class="input-group input-group-sm">
<input *ngIf="appsService.connections.get(currentApp)" [value]="appsService.connections.get(currentApp).address || 'Loading...'" readonly type="text" class="form-control" title="address">
<div class="input-group-btn" style="flex-direction: row">
<button i18n *ngIf="!appsService.connections.get(currentApp)" [disabled]="!appsService.allReady(currentApp)" (click)="appsService.network(currentApp, currentApp.network.servers[0])" type="button" class="btn btn-secondary btn-sm">联机</button>
<button i18n *ngIf="appsService.connections.get(currentApp)" (click)="copy(appsService.connections.get(currentApp).address)" [disabled]="!appsService.connections.get(currentApp).address" type="button" class="btn btn-secondary btn-sm">复制</button>
<button type="button" class="btn btn-sm btn-secondary dropdown-toggle dropdown-toggle-split" data-toggle="dropdown"></button>
<div class="dropdown-menu" [class.dropdown-menu-right]="appsService.connections.get(currentApp)">
<h6 i18n class="dropdown-header">选择服务器</h6>
<a *ngFor="let server of currentApp.network.servers" (click)="appsService.network(currentApp, server)" class="dropdown-item" href="#">{{server.id}}</a>
<div *ngIf="appsService.connections.get(currentApp)" class="dropdown-divider"></div>
<a i18n *ngIf="appsService.connections.get(currentApp)" (click)="appsService.connections.get(currentApp).connection.close()" class="dropdown-item" href="#">取消</a>
</div>
</div>
</div>
</div>
\ No newline at end of file
import { ChangeDetectorRef, Component, ElementRef, Input, OnChanges, OnInit, SimpleChanges, Injectable } from '@angular/core';
import { AppsService } from './apps.service';
import {App} from './app';
@Component({
moduleId: module.id,
selector: 'network',
templateUrl: 'network.component.html',
styleUrls: ['network.component.css'],
})
@Injectable()
export class NetworkComponent {
@Input()
currentApp: App;
constructor(private appsService: AppsService) {
console.log( 'constructor' );
}
}
......@@ -6,7 +6,6 @@
<button i18n [disabled]="!appsService.allReady(app)" type="button" class="btn btn-secondary btn-sm" data-toggle="modal" data-target="#game-create-windbot">单人模式</button>
<button i18n [disabled]="!appsService.allReady(app)" type="button" class="btn btn-secondary btn-sm" data-toggle="modal" data-target="#game-replay-modal">观战录像</button>
</div>
<!-- 匹配中 -->
<div *ngIf="matching" id="match-time" class="input-group input-group-sm">
<span class="input-group-addon">
......
......@@ -513,9 +513,13 @@ export class YGOProComponent implements OnInit, OnDestroy {
}
async start_game(args: string[]) {
let data: any;
let start_time: string ;
let exp_rank_ex: number;
let arena_rank_ex: number;
let win = remote.getCurrentWindow();
win.minimize();
return new Promise((resolve, reject) => {
await new Promise((resolve, reject) => {
let child = child_process.spawn(path.join(this.app.local!.path, this.app.actions.get('main')!.execute), args, {
cwd: this.app.local!.path,
stdio: 'inherit'
......@@ -530,7 +534,75 @@ export class YGOProComponent implements OnInit, OnDestroy {
resolve();
win.restore();
});
try {
this.http.get('https://mycard.moe/ygopro/api/history', {
search: {
page: 1,
username: this.loginService.user.username,
type: 0,
page_num: 1
}
})
.map((response) => response.json())
.toPromise()
.then((d) => {
start_time = d.data[0].start_time;
});
}catch (error) {
console.log(error);
}
try {
this.http.get('https://api.mycard.moe/ygopro/arena/user', {search: {username: this.loginService.user.username } })
.map((response) => response.json())
.toPromise()
.then((d2) => {
exp_rank_ex = d2.exp_rank;
arena_rank_ex = d2.arena_rank;
});
}catch (error) {
console.log(error);
}
});
try {
await this.http.get('https://mycard.moe/ygopro/api/history', {
search: {
page: 1,
username: this.loginService.user.username,
// username: "星光pokeboy",
type: 0,
page_num: 1
}
})
.map((response) => response.json())
.toPromise()
.then((d) => {
data = d.data[0];
data.myname = this.loginService.user.username;
});
await this.http.get('https://api.mycard.moe/ygopro/arena/user', {
search: {
username: this.loginService.user.username,
}
})
.map((response) => response.json())
.toPromise()
.then((data2) => {
data.athletic_win = data2.athletic_win;
data.athletic_lose = data2.athletic_lose;
data.entertain_win = data2.entertain_win;
data.entertain_lose = data2.entertain_lose;
data.exp_rank = data2.exp_rank;
data.arena_rank = data2.arena_rank;
data.exp_rank_ex = exp_rank_ex;
data.arena_rank_ex = arena_rank_ex;
if (start_time !== data.start_time) {
this.appsService.showResult('end_YGOPro_single.html', data, 202, 222);
}
});
}catch (error) {
console.log(error);
}
};
create_room(room: Room) {
......
......@@ -6,25 +6,25 @@ import * as $ from 'jquery';
let data_url = (new URL(document.location.toString())).searchParams;
let data_str = data_url.get('data');
console.log(data_str);
// data={
// 'win':true,
// 'users_info':[{
// 'isPlay':true,
// 'icon':'http://himg.bdimg.com/sys/portrait/item/55c177633531343132333435f20c.jpg',
// 'name':'刘大耳',
// 'score':'5555',
// 'exp':'123',
// 'gold':'321'
// },{
// 'isPlay':false,
// 'icon':'http://himg.bdimg.com/sys/portrait/item/55c177633531343132333435f20c.jpg',
// 'name':'关绿帽',
// 'score':'008',
// 'exp':'789',
// 'gold':'999'
// }
// ]
// }
// data={
// 'win':true,
// 'users_info':[{
// 'isPlay':true,
// 'icon':'http://himg.bdimg.com/sys/portrait/item/55c177633531343132333435f20c.jpg',
// 'name':'刘大耳',
// 'score':'5555',
// 'exp':'123',
// 'gold':'321'
// },{
// 'isPlay':false,
// 'icon':'http://himg.bdimg.com/sys/portrait/item/55c177633531343132333435f20c.jpg',
// 'name':'关绿帽',
// 'score':'008',
// 'exp':'789',
// 'gold':'999'
// }
// ]
// }
let data = JSON.parse(data_str!);
console.log(data);
let win = data.win;
......
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link href="./node_modules/font-awesome/css/font-awesome.min.css" rel="stylesheet" />
<style>
html,div,body,td,tr{
background: rgba(0,0,0,0);
font-size:14px;
font-family:-apple-system, Arial, 'Source Sans Pro', "Microsoft YaHei", 'Microsoft JhengHei', "WenQuanYi Micro Hei", sans-serif;
padding:0;
margin:0;
color:#00a4d9;
}
i:hover{
color:#0b88b1;
}
td{
text-align:center;
width:50px;
height:20px;
line-height: 20px;
padding:2px;
}
td:nth-child(1){
width:auto;
}
td:nth-child(2){
text-align:left;
width:150px
}
img{
display: block;
height: 100%;
}
.window{
position:relative;
width:320px;
height:180px;
background:linear-gradient(to bottom, #bfcdd2, rgba(218, 218, 218, 0.17));
padding:5px;
}
.myIcon{
float:left;
height:100%
}
.close{
position:absolute;
top:5px;
right:5px
}
.title{
/*display: table;*/
height:50px;
line-height:30px;
padding:5px;
border-bottom:1px #fff solid;
color:#00a4d9
}
.winOrLose{
font-size:30px;
display:table-cell;
vertical-align:middle;
padding-right:10px;
display: none;
}
.myInfo_tr{background:linear-gradient(to right, rgba(255,255,255,1), rgba(255,255,255,0.5));}
#myName{
height:50%;
line-height:100%;
font-size:25px;
}
#myScore{font-size:25px; padding-right: 10px}
#myExp{font-size:15px; color:green; padding-right: 10px}
#myGold{font-size:15px; color:#ec6d20; padding-right: 10px}
#win{color:green;}
#lose{color:red;}
#users_info{border-collapse:collapse;}
</style>
</head>
<body>
<div class="window">
<i onclick="window.opener=null;window.close();" class="fa fa-times close" title="关闭"></i>
<div class="title">
<div class="myIcon">
<img id="myIcon" >
</div>
<div style="float:left; padding-left:10px">
<div id="myName"></div>
<div style="height:50%;">
<span id="myScore"></span>
<span id="myExp"></span>
<span id="myGold"></span>
</div>
</div>
<div style="height:100%; float:right; display:table;">
<span id="win" class="winOrLose"></span>
<span id="lose" class="winOrLose"></span>
<span id="a_draw" class="winOrLose"></span>
</div>
</div>
<div class="clear:both"></div>
<div style="padding:5px;">
<table id="users_info">
<tr>
<th colspan="2">玩家</th>
<th>评价</th>
<th>经验</th>
<th>金币</th>
</tr>
</table>
</div>
</div>
<script>
window.exports = {}
</script>
<script src="end_YGOPro.js"></script>
</body>
</html>
/**
* Created by break on 2017/6/9.
*/
import * as $ from 'jquery';
let data_url = (new URL(document.location.toString())).searchParams;
let data_str = data_url.get('data');
console.log(data_str);
// {"usernamea": "loyi",
// "usernameb": "saten",
// "userscorea": 2,
// "userscoreb": 0,
// "expa": 36.5,
// "expb": 9,
// "expa_ex": 35.5,
// "expb_ex": 8.5,
// "pta": 479.950607945308,
// "ptb": 494.012345698275,
// "pta_ex": 479.950607945308,
// "ptb_ex": 494.012345698275,
// "type": "entertain",
// "start_time": "2017-06-12T17:07:54.000Z",
// "end_time": "2017-06-12T17:23:16.000Z"}
let data = JSON.parse(data_str!);
let icona = 'https://ygobbs.com/user_avatar/ygobbs.com/' + data.usernamea + '/25/1.png';
let iconb = 'https://ygobbs.com/user_avatar/ygobbs.com/' + data.usernameb + '/25/1.png';
console.log(data);
if (data.usernamea === data.myname) {
if ( data.userscorea > data.userscoreb) {
$('#win').show();
}else if ( data.userscorea < data.userscoreb) {
$('#lose').show();
}else {
$('#a_draw').show();
}
$('#myIcon').attr('src', icona);
$('#myName').html(data.usernamea);
$('#myScore').html(data.userscorea);
$('#myExp').html(parseInt(data.expa).toString());
$('#myGold').html(parseInt(data.pta).toString());
let tr = '<tr class="myInfo_tr"><td><img src="' + icona + '"></td><td>' + data.usernamea + '</td><td>' + data.userscorea + '</td><td>' + parseInt(data.expa).toString() + '</td><td>' + parseInt(data.pta).toString() + '</td></tr>';
$('#users_info').append(tr);
tr = '<tr><td><img src="' + iconb + '"></td><td>' + data.usernameb + '</td><td>' + data.userscoreb + '</td><td>' + parseInt(data.expb).toString() + '</td><td>' + parseInt(data.ptb).toString() + '</td></tr>';
$('#users_info').append(tr);
}else {
if ( data.userscorea > data.userscoreb) {
$('#lose').show();
}else if ( data.userscorea < data.userscoreb) {
$('#win').show();
}else {
$('#a_draw').show();
}
$('#myIcon').attr('src', iconb);
$('#myName').html(data.usernameb);
$('#myScore').html(data.userscoreb);
$('#myExp').html(parseInt(data.expb).toString());
$('#myGold').html(parseInt(data.ptb).toString());
let tr = '<tr><td><img src="' + icona + '"></td><td>' + data.usernamea + '</td><td>' + data.userscorea + '</td><td>' + parseInt(data.expa).toString() + '</td><td>' + parseInt(data.pta).toString() + '</td></tr>';
$('#users_info').append(tr);
tr = '<tr class="myInfo_tr"><td><img src="' + iconb + '"></td><td>' + data.usernameb + '</td><td>' + data.userscoreb + '</td><td>' + parseInt(data.expb).toString() + '</td><td>' + parseInt(data.ptb).toString() + '</td></tr>';
$('#users_info').append(tr);
}
let t = setTimeout(function () {
window.opener = null;
window.close();
}, 5000);
$('html').hover(function () {
clearTimeout(t);
});
// let {ipcRenderer} = require('electron');
// setTimeout( function(){ipcRenderer.send('massage', '')} , 1000);
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link href="./node_modules/font-awesome/css/font-awesome.min.css" rel="stylesheet" />
<style>
@font-face {
font-family: 'Mogra';
font-style: normal;
font-weight: 400;
src: url('font/Mogra-Regular.ttf');
}
html,div,body,td,tr{
background: rgba(0,0,0,0);
font-size:14px;
font-family:-apple-system, Arial, 'Source Sans Pro', "Microsoft YaHei", 'Microsoft JhengHei', "WenQuanYi Micro Hei", sans-serif;
/*font-family: Mogra;*/
padding:0;
margin:0;
/*color:#00a4d9;*/
}
td{
line-height: 17px;
}
i:hover {
color: #0b88b1;
}
.window{
padding:5px;
border: #00a4d9 1px solid;
width:200px;
position: relative;
height: 220px;
}
.icon{
width:60px;
height:60px;
float: left;
}
.icon img{
height: 100%
}
.info{
float:left;
line-height: 20px;
}
.again{
cursor: pointer;
font-size: 12px;
background:#00a4d9;
color:#fff;
border-radius: 15px;
width:130px;
height: 30px;
line-height: 30px;
text-align: center;
margin:5px auto 0;
position: absolute;
bottom : 5px;
left: 35px;
}
.red{
color:red;
}
.green{
color:green;
}
.close{
position:absolute;
top:5px;
left:5px;
z-index: 999;
}
#winOrLose{
position: absolute;
right: 5px;
top: 5px;
}
#winOrLose div{
font-family: Mogra;
font-weight: 900;
font-size: 25px;
display: none;
}
#win{
color:#00a4d9;
}
#lose{
color:#922
}
#draw{
color: green;
}
#title{
text-align: center;
}
#info td:nth-child(1){
width:70px;
}
#rewards td:nth-child(1){
width:150px;
}
</style>
</head>
<body>
<div class="window">
<i onclick="window.opener=null;window.close();" class="fa fa-times close" title="关闭"></i>
<div>
<div id="title"></div>
<div>
<div class="icon">
<img id="icon" src="https://ygobbs.com/user_avatar/ygobbs.com/breakegg/25/1.png"/>
</div>
<div class="info">
<span id="myName">myname</span>
<table id="info">
</table>
</div>
</div>
<div id="winOrLose">
<div id="win">Win!</div>
<div id="lose">LOSE</div>
<div id="draw">DRAW</div>
</div>
<div style="clear:both"></div>
</div>
<hr/>
<div>
奖励结算
<table id="rewards">
</table>
<div class="again" onclick="again()">再来一局!</div>
</div>
</div>
<!--<div class="window">-->
<!--<div>-->
<!--<div id="title">竞技匹配</div>-->
<!--<div>-->
<!--<div class="icon">-->
<!--<img src="https://ygobbs.com/user_avatar/ygobbs.com/breakegg/25/1.png"/>-->
<!--</div>-->
<!--<div class="info">-->
<!--<span id="myName">myname</span>-->
<!--<table id="info">-->
<!--<tr>-->
<!--<td>胜:<span id="winTimes">11</span></td>-->
<!--<td>负:<span id="loseTimes">10</span></td>-->
<!--</tr>-->
<!--<tr>-->
<!--<td>排名:<span id="rank">10</span></td>-->
<!--<td><span id="EXPORDP">DP:</span><span id="EXP_DP">793</span></td>-->
<!--</tr>-->
<!--</table>-->
<!--</div>-->
<!--</div>-->
<!--<div id="winOrLose">-->
<!--<div id="win">Win!</div>-->
<!--<div id="lose">LOSE</div>-->
<!--<div id="draw">DRAW</div>-->
<!--</div>-->
<!--<div style="clear:both"></div>-->
<!--</div>-->
<!--<hr/>-->
<!--<div>-->
<!--奖励结算-->
<!--<table id="rewards">-->
<!--<tr>-->
<!--<td>D.P</td>-->
<!--<td>+7</td>-->
<!--</tr>-->
<!--<tr>-->
<!--<td>EXP</td>-->
<!--<td>+1</td>-->
<!--</tr>-->
<!--<tr>-->
<!--<td>D.P(首胜)</td>-->
<!--<td>+4</td>-->
<!--</tr>-->
<!--</table>-->
<!--<div class="again">再来一局!</div>-->
<!--</div>-->
<!--</div>-->
<script>
window.exports = {}
</script>
<script src="end_YGOPro_single.js"></script>
</body>
</html>
/**
* Created by break on 2017/6/9.
*/
import * as $ from 'jquery';
let data_url = (new URL(document.location.toString())).searchParams;
let data_str = data_url.get('data');
console.log(data_str);
// {
// "usernamea": "Joe1991",
// "usernameb": "zh99998",
// "userscorea": 1,
// "userscoreb": 2,
// "expa": 1,
// "expb": 30,
// "expa_ex": 0.5,
// "expb_ex": 29,
// "pta": -2.45677803214143,
// "ptb": 562.760086898395,
// "pta_ex": -1.25048918195558,
// "ptb_ex": 561.553798048209,
// "type": "athletic",
// "start_time": "2017-06-17T12:26:33.000Z",
// "end_time": "2017-06-17T12:26:33.000Z",
// "winner": "zh99998",
// "isfirstwin": false,
// "myname":"zh99998",
// "athletic_win":23,
// "athletic_lose":0,
// "entertain_win":7,
// "entertain_lose":0,
// "exp_rank":"1685",
// "arena_rank":"335",
// "exp_rank_ex":"1685",
// "arena_rank_ex":"335",
// }
let data = JSON.parse(data_str!);
let titleStr;
let icon = 'https://ygobbs.com/user_avatar/ygobbs.com/' + data.myname + '/25/1.png';
let myMame = data.myname;
let winTimes, loseTimes, rank, rank_up, DP, DP_up, DP_up_sum, EXP, EXP_up;
let winOrLose = 0;
let isMyFirstWin;
if (data.type === 'entertain') {
titleStr = '娱乐匹配';
winTimes = data.entertain_win;
loseTimes = data.entertain_lose;
rank = data.exp_rank;
rank_up = data.exp_rank_ex - data.exp_rank ;
} else {
titleStr = '竞技匹配';
winTimes = data.athletic_win;
loseTimes = data.athletic_lose;
rank = data.arena_rank;
rank_up = data.arena_rank_ex - data.arena_rank ;
}
if (data.usernamea === data.myname) {
if ( data.userscorea > data.userscoreb) {
winOrLose = 1;
}else if ( data.userscorea < data.userscoreb) {
winOrLose = -1;
}else {
winOrLose = 0;
}
DP = parseInt(data.pta);
DP_up_sum = Math.floor( data.pta - data.pta_ex );
EXP = parseInt(data.expa);
EXP_up = Math.floor( data.expa - data.expa_ex );
}else {
if ( data.userscorea < data.userscoreb) {
winOrLose = 1;
}else if ( data.userscorea > data.userscoreb) {
winOrLose = -1;
}else {
winOrLose = 0;
}
DP = parseInt(data.ptb);
DP_up_sum = Math.floor( data.ptb - data.ptb_ex );
EXP = parseInt(data.expb);
EXP_up = Math.floor( data.expb - data.expb_ex );
}
isMyFirstWin = (winOrLose > 0 && data.isfirstwin) ? true : false;
DP_up = DP_up_sum - (isMyFirstWin ? 4 : 0);
// =========================================================================
$('#title').html(titleStr);
$('#icon').attr('src', icon);
$('#myName').html(myMame);
$('#' + (winOrLose ? (winOrLose > 0 ? 'win' : 'lose') : 'draw') ).show();
let tr1 = '<tr>' +
'<td>胜:<span class="' + (winOrLose > 0 ? 'green' : '') + '">' + winTimes + '</span></td>' +
'<td>负:<span class="' + (winOrLose < 0 ? 'red' : '') + '">' + loseTimes + '</span></td>' +
'</tr>';
let tr2 = `<tr>
<td>排名:<span id="rank" class="${rank_up ? (rank_up > 0 ? 'green' : 'red') : '' } ">${rank}</span></td>
<td>${data.type === 'entertain' ? 'EXP:' : 'DP:'}
<span id="EXP_DP" ${data.type === 'entertain' ?
('class="' + (EXP_up > 0 ? 'green' : (EXP_up < 0 ? 'red' : '')) + '">' + EXP) :
('class="' + (DP_up_sum > 0 ? 'green' : (DP_up_sum < 0 ? 'red' : '')) + '">' + DP)
}</span>
</td>
</tr>`;
$('#info').append(tr1).append(tr2);
let tr_DP = DP_up ? `
<tr>
<td>D.P</td>
${DP_up > 0 ? `<td class="green">+${ DP_up }</td>` : `<td class="red">${ DP_up }</td>`}
</tr>
` : ``;
let tr_EXP = EXP_up ? `
<tr>
<td>EXP</td>
${EXP_up > 0 ? `<td class="green">+${ EXP_up }</td>` : `<td class="red">${ EXP_up }</td>`}
</tr>
` : ``;
let tr_FirstWin = isMyFirstWin ? `
<tr>
<td>首胜</td>
<td class="green">+4</td>
</tr>
` : ``
let tr_rewards = tr_EXP + tr_DP + tr_FirstWin;
tr_rewards = tr_rewards === '' ? '<tr><td>无</td></tr>' : tr_rewards;
$('#rewards').append(tr_rewards);
function again() {
let {ipcRenderer} = require('electron');
ipcRenderer.send('YGOPro', data.type);
}
let t = setTimeout(function () {
window.opener = null;
window.close();
}, 5000);
$('html').hover(function () {
clearTimeout(t);
});
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