Commit 61d0a2f8 authored by nanahira's avatar nanahira

finish

parent 2694f95c
...@@ -26,9 +26,9 @@ ...@@ -26,9 +26,9 @@
</div> </div>
<div class="col-sm-8 input-group input-group-sm"> <div class="col-sm-8 input-group input-group-sm">
<label i18n class="input-group-text" id="basic-addon1">卡组</label> <label i18n class="input-group-text" id="basic-addon1">卡组</label>
<select class="form-select form-select-sm" id="exampleSelect1" name="deck" [(ngModel)]="currentDeck"> <select class="form-select form-select-sm" id="exampleSelect1" name="deck" [(ngModel)]="currentDeckSymbol" (change)="onDeckChange()">
<optgroup *ngFor="let group of decks_grouped" [label]="group[0] === '.' ? '未分类卡组' : group[0]"> <optgroup *ngFor="let group of decks_grouped" [label]="group[0] === '.' ? '未分类卡组' : group[0]">
<option *ngFor="let deck of group[1]" [value]="deck">{{deck.deck}}</option> <option *ngFor="let deck of group[1]" [value]="deck.symbol">{{deck.deck}}</option>
</optgroup> </optgroup>
</select> </select>
<span class="input-group-btn"> <span class="input-group-btn">
......
...@@ -112,9 +112,24 @@ let matching: Subscription | undefined; ...@@ -112,9 +112,24 @@ let matching: Subscription | undefined;
let matching_arena: string | undefined; let matching_arena: string | undefined;
let match_started_at: Date; let match_started_at: Date;
export interface DeckAndCategory { export class DeckAndCategory {
category: string; category: string;
deck: string; deck: string;
get param() {
return {
category: this.category === '.' ? '': this.category,
deck: this.deck
}
}
get symbol() {
return `${this.category}/${this.deck}`;
}
set symbol(str: string) {
this.category = path.dirname(str);
this.deck = path.basename(str, '.ydk');
}
} }
@Component({ @Component({
...@@ -135,6 +150,7 @@ export class YGOProComponent implements OnInit, OnDestroy { ...@@ -135,6 +150,7 @@ export class YGOProComponent implements OnInit, OnDestroy {
decks_grouped: [string, DeckAndCategory[]][]; decks_grouped: [string, DeckAndCategory[]][];
replays: string[] = []; replays: string[] = [];
currentDeck: DeckAndCategory; currentDeck: DeckAndCategory;
currentDeckSymbol: string;
system_conf?: string; system_conf?: string;
numfont: string[]; numfont: string[];
...@@ -441,11 +457,15 @@ export class YGOProComponent implements OnInit, OnDestroy { ...@@ -441,11 +457,15 @@ export class YGOProComponent implements OnInit, OnDestroy {
}); });
} }
onDeckChange() {
this.currentDeck = this.getDeckObject(this.currentDeckSymbol);
console.log(`Current deck changed to ${this.currentDeck.symbol}`);
}
async refresh(init?: boolean) { async refresh(init?: boolean) {
this.decks = await this.get_decks(); this.decks = await this.get_decks();
this.decks_grouped = this.deckGroup(); this.decks_grouped = this.deckGroup();
const allDecks = _.flatten(this.decks_grouped.map(g => g[1])); const allDecks = this.decks;
if (this.lastDeckFormat) { if (this.lastDeckFormat) {
const systemConfString = await this.load_system_conf(); const systemConfString = await this.load_system_conf();
...@@ -488,6 +508,10 @@ export class YGOProComponent implements OnInit, OnDestroy { ...@@ -488,6 +508,10 @@ export class YGOProComponent implements OnInit, OnDestroy {
this.currentDeck = allDecks[0]; this.currentDeck = allDecks[0];
} }
if(this.currentDeck) {
this.currentDeckSymbol = this.currentDeck.symbol;
}
this.replays = await this.get_replays(); this.replays = await this.get_replays();
// https://mycard.moe/ygopro/api/user?username=ozxdno // https://mycard.moe/ygopro/api/user?username=ozxdno
...@@ -514,10 +538,9 @@ export class YGOProComponent implements OnInit, OnDestroy { ...@@ -514,10 +538,9 @@ export class YGOProComponent implements OnInit, OnDestroy {
} }
getDeckObject(deckPath: string) { getDeckObject(deckPath: string) {
return { const deck = new DeckAndCategory();
deck: path.basename(deckPath, '.ydk'), deck.symbol = deckPath;
category: path.dirname(deckPath) return deck;
}
} }
deckGroup(): [string, DeckAndCategory[]][] { deckGroup(): [string, DeckAndCategory[]][] {
......
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