Skip to content

Commit 07b0da7

Browse files
DEV (replays): first working version of replays after coliseum migration
Card text is always small though, need to find a better solution
1 parent aca6504 commit 07b0da7

File tree

59 files changed

+254
-253
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+254
-253
lines changed

dependencies/coliseum.js

-2
This file was deleted.

libs/legacy/feature-shell/src/lib/js/components/replays/game-replay.component.ts

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { HttpClient, HttpHeaders } from '@angular/common/http';
2-
import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
2+
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, Input, ViewRef } from '@angular/core';
33
import { loadAsync } from 'jszip';
44
import { MatchDetail } from '../../models/mainwindow/replays/match-detail';
55

@@ -21,7 +21,7 @@ export class GameReplayComponent {
2121
_replayXml: string;
2222
reviewId: string;
2323

24-
constructor(private http: HttpClient) {}
24+
constructor(private http: HttpClient, private readonly cdr: ChangeDetectorRef) {}
2525

2626
@Input() set replay(value: MatchDetail) {
2727
this.setReplay(value);
@@ -44,12 +44,15 @@ export class GameReplayComponent {
4444
}
4545
this._replayXml = replayXml;
4646
this.reviewId = reviewId;
47+
if (!(this.cdr as ViewRef).destroyed) {
48+
this.cdr.detectChanges();
49+
}
4750
}
4851

4952
private async getReplayXml(reviewId: string): Promise<string> {
50-
window['coliseum'].zone.run(() => {
51-
window['coliseum'].component.updateStatus('Downloading replay file');
52-
});
53+
// window['coliseum'].zone.run(() => {
54+
// window['coliseum'].component.updateStatus('Downloading replay file');
55+
// });
5356
const review: any = await this.http
5457
.get(`https://static-api.firestoneapp.com/retrieveReview/${reviewId}`)
5558
.toPromise();

libs/replay/coliseum/src/lib/components/coliseum.component.ts

+12-9
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ import { GameConfService } from '../services/game-conf.service';
6565
export class ColiseumComponent implements OnDestroy {
6666
@Input() reviewId: string;
6767
@Input() set replayXml(value: string) {
68+
if (!value?.length) {
69+
return;
70+
}
6871
this.setReplay(value);
6972
}
7073

@@ -167,7 +170,7 @@ export class ColiseumComponent implements OnDestroy {
167170
}
168171

169172
public updateStatus(newStatus: string) {
170-
console.log('updating status', newStatus);
173+
// console.debug('updating status', newStatus);
171174
this.status = newStatus;
172175
if (!(this.cdr as ViewRef).destroyed) {
173176
this.cdr.detectChanges();
@@ -206,7 +209,7 @@ export class ColiseumComponent implements OnDestroy {
206209
console.warn('[app] game not present, not performing operation', 'onSeek');
207210
return;
208211
}
209-
console.debug('[app] seeking target timestamp', targetTimestamp);
212+
// console.debug('[app] seeking target timestamp', targetTimestamp);
210213
let lastActionIndex = 0;
211214
let lastTurnIndex = 0;
212215
for (let turnIndex = 0; turnIndex < this.game.turns.size; turnIndex++) {
@@ -225,13 +228,13 @@ export class ColiseumComponent implements OnDestroy {
225228
}
226229
this.currentTurn = lastTurnIndex;
227230
this.currentActionInTurn = lastActionIndex;
228-
console.debug(
229-
'[app] finished seeking',
230-
this.currentTurn,
231-
this.currentActionInTurn,
232-
this.game.turns.toJS(),
233-
this.game.turns.get(this.currentTurn)?.actions,
234-
);
231+
// console.debug(
232+
// '[app] finished seeking',
233+
// this.currentTurn,
234+
// this.currentActionInTurn,
235+
// this.game.turns.toJS(),
236+
// this.game.turns.get(this.currentTurn)?.actions,
237+
// );
235238
this.populateInfo();
236239
// So that the value is always what the user actually selected, and there are no weird jumps
237240
this.currentTime = targetTimestamp;

libs/replay/coliseum/src/lib/components/controls.component.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ export class ControlsComponent implements OnInit, OnDestroy {
306306
this.currentSpeed = 1;
307307
this.showingHiddenCards = true;
308308
this._reviewId = value;
309-
console.log('set review id', this._reviewId);
309+
// console.log('set review id', this._reviewId);
310310
}
311311

312312
@Input() set active(value: boolean) {
@@ -325,7 +325,7 @@ export class ControlsComponent implements OnInit, OnDestroy {
325325
case Key.Space:
326326
// eslint-disable-next-line no-case-declarations
327327
const focusedElement = document.activeElement;
328-
console.debug('[controls] pressed space while focused on', focusedElement);
328+
// console.debug('[controls] pressed space while focused on', focusedElement);
329329
// If the focus is on a player control, we don't trigger the play action,
330330
// so that the control's action can trigger instead
331331
if (focusedElement && !focusedElement.classList.contains('player-control-element')) {

libs/replay/coliseum/src/lib/components/game/active-spell.component.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ export class ActiveSpellComponent {
2323
_controller: Entity | undefined;
2424

2525
@Input() set entity(value: Entity | undefined) {
26-
console.debug('[active-spell] setting new entity', value);
26+
// console.debug('[active-spell] setting new entity', value);
2727
this._entity = value;
2828
}
2929

3030
@Input() set controller(value: Entity | undefined) {
31-
console.debug('[active-spell] setting controller', value);
31+
// console.debug('[active-spell] setting controller', value);
3232
this._controller = value;
3333
}
3434
}

libs/replay/coliseum/src/lib/components/game/board/board-card-stats.component.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ export class BoardCardStatsComponent {
3232
healthClass: string | undefined;
3333
healthLeft: number;
3434

35-
_attack: number;
35+
_attack: number | undefined;
3636
_cardType: string;
3737

3838
private _cardId: string;
39-
private _health: number;
39+
private _health: number | undefined;
4040
private _damage: number;
4141

4242
constructor(private cards: AllCardsService, private cdr: ChangeDetectorRef, private elRef: ElementRef) {}
@@ -76,10 +76,10 @@ export class BoardCardStatsComponent {
7676
const originalCard = this.cards.getCard(this._cardId);
7777

7878
if (this._attack == null) {
79-
this._attack = originalCard.attack ?? 0;
79+
this._attack = originalCard.attack;
8080
}
8181
if (this._health == null) {
82-
this._health = originalCard.health ?? 0;
82+
this._health = originalCard.health;
8383
}
8484
if (this._damage == null) {
8585
this._damage = 0;
@@ -90,7 +90,7 @@ export class BoardCardStatsComponent {
9090
(originalCard.durability ?? 0) > 0 ||
9191
(originalCard.armor ?? 0) > 0;
9292

93-
this.healthLeft = this._health - this._damage;
93+
this.healthLeft = (this._health ?? 0) - this._damage;
9494
this.updateAttackClass(originalCard);
9595
this.updateHealthClass(originalCard);
9696
if (!(this.cdr as ViewRef).destroyed) {
@@ -100,9 +100,9 @@ export class BoardCardStatsComponent {
100100

101101
private updateAttackClass(originalCard) {
102102
this.attackClass = 'attack';
103-
if (this._attack > originalCard.attack) {
103+
if ((this._attack ?? 0) > originalCard.attack) {
104104
this.attackClass += ' buff';
105-
} else if (this._attack < originalCard.attack) {
105+
} else if ((this._attack ?? 0) < originalCard.attack) {
106106
this.attackClass += ' debuff';
107107
}
108108
}

libs/replay/coliseum/src/lib/components/game/board/board.component.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,17 @@ export class BoardComponent {
3131
@Input() isRecruitPhase: boolean;
3232

3333
@Input() set entities(entities: readonly Entity[]) {
34-
console.debug('[board] setting new entities', entities);
34+
// console.debug('[board] setting new entities', entities);
3535
this._entities = entities;
3636
}
3737

3838
@Input() set enchantmentCandidates(value: readonly Entity[]) {
39-
console.debug('[board] setting enchantmentCandidates', value);
39+
// console.debug('[board] setting enchantmentCandidates', value);
4040
this._enchantmentCandidates = value;
4141
}
4242

4343
@Input() set options(value: readonly number[]) {
44-
console.debug('[board] setting options', value);
44+
// console.debug('[board] setting options', value);
4545
this._options = value;
4646
}
4747

libs/replay/coliseum/src/lib/components/game/board/card-on-board-overlays.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export class CardOnBoardOverlaysComponent {
1616
overlays: string[][];
1717

1818
@Input() set entity(value: Entity) {
19-
console.debug('[card-on-board-overlays] setting entity', value);
19+
// console.debug('[card-on-board-overlays] setting entity', value);
2020
this.overlays = [];
2121
if (!value) {
2222
return;

libs/replay/coliseum/src/lib/components/game/board/card-on-board.component.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,12 @@ export class CardOnBoardComponent {
6161
cardClass: CardClass;
6262
originalCard: any;
6363
premium: boolean;
64-
attack: number;
65-
health: number;
66-
damage: number;
67-
durability: number;
68-
armor: number;
69-
cost: number;
64+
attack: number | undefined;
65+
health: number | undefined;
66+
damage: number | undefined;
67+
durability: number | undefined;
68+
armor: number | undefined;
69+
cost: number | undefined;
7070
taunt: boolean;
7171
shownDamage: number;
7272
hideStats: boolean;
@@ -79,7 +79,7 @@ export class CardOnBoardComponent {
7979
@Input() isRecruitPhase: boolean;
8080

8181
@Input() set entity(entity: Entity) {
82-
console.debug('[card-on-board] setting entity', entity.id, entity, entity.tags.toJS());
82+
// console.debug('[card-on-board] setting entity', entity.id, entity, entity.tags.toJS());
8383

8484
this._entity = entity;
8585

@@ -120,7 +120,7 @@ export class CardOnBoardComponent {
120120
}
121121

122122
@Input() set enchantments(value: readonly Entity[]) {
123-
console.debug('[card-on-board] setting enchantments', value);
123+
// console.debug('[card-on-board] setting enchantments', value);
124124
this._enchantments = value;
125125
}
126126
}

libs/replay/coliseum/src/lib/components/game/board/power-indicator.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export class PowerIndicatorComponent {
1717
effectImage: string;
1818

1919
@Input() set entity(value: Entity) {
20-
console.debug('[power-indicator] setting entity', value);
20+
// console.debug('[power-indicator] setting entity', value);
2121
let image = '';
2222
this.effect = undefined;
2323
if (value.getTag(GameTag.POISONOUS) === 1) {

libs/replay/coliseum/src/lib/components/game/card/card-art.component.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ export class CardArtComponent {
1212
_cardType: string;
1313

1414
@Input() set cardId(cardId: string | undefined) {
15-
console.debug('[card-art] setting cardId', cardId);
15+
// console.debug('[card-art] setting cardId', cardId);
1616
this.image = cardId
1717
? `https://static.zerotoheroes.com/hearthstone/cardart/256x/${cardId}.jpg`
1818
: `https://static.zerotoheroes.com/hearthstone/asset/manastorm/card_unknown.png`;
1919
}
2020

2121
@Input() set cardType(cardType: CardType | undefined) {
22-
console.debug('[card-art] setting cardType', cardType);
22+
// console.debug('[card-art] setting cardType', cardType);
2323
this._cardType = cardType ? CardType[cardType]?.toLowerCase() : 'unknown';
2424
}
2525
}

libs/replay/coliseum/src/lib/components/game/card/card-cost.component.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { AllCardsService } from '@firestone-hs/replay-parser';
1616
changeDetection: ChangeDetectionStrategy.OnPush,
1717
})
1818
export class CardCostComponent {
19-
_cost: number;
19+
_cost: number | undefined;
2020
costClass: string | undefined;
2121
_cardType: string | null;
2222
fontSizeRatio: number;
@@ -26,20 +26,20 @@ export class CardCostComponent {
2626
constructor(private cards: AllCardsService, private cdr: ChangeDetectorRef) {}
2727

2828
@Input() set cardId(cardId: string) {
29-
console.debug('[card-cost] setting cardId', cardId);
29+
// console.debug('[card-cost] setting cardId', cardId);
3030
this._cardId = cardId;
3131
this.updateCost();
3232
}
3333

3434
@Input() set cost(cost: number) {
35-
console.debug('[card-cost] setting cost', cost);
35+
// console.debug('[card-cost] setting cost', cost);
3636
this._cost = cost;
3737
this.costClass = undefined;
3838
this.updateCost();
3939
}
4040

4141
@Input() set cardType(cardType: CardType | undefined) {
42-
console.debug('[card-text] setting cardType', cardType);
42+
// console.debug('[card-text] setting cardType', cardType);
4343
this._cardType = !cardType ? null : CardType[cardType]?.toLowerCase();
4444
this.fontSizeRatio = this._cardType === CardType[CardType.HERO_POWER]?.toLowerCase() ? 0.6 : 0.8;
4545
this.updateCost();
@@ -50,15 +50,15 @@ export class CardCostComponent {
5050
return;
5151
}
5252
const originalCard = this.cards.getCard(this._cardId);
53-
const originalCost: number = originalCard.cost ?? 0;
53+
const originalCost: number | undefined = originalCard.cost;
5454

5555
if (this._cost == null) {
5656
this._cost = originalCost;
5757
}
5858

59-
if (this._cost < originalCost) {
59+
if ((this._cost ?? 0) < (originalCost ?? 0)) {
6060
this.costClass = 'lower-cost';
61-
} else if (this._cost > originalCost) {
61+
} else if ((this._cost ?? 0) > (originalCost ?? 0)) {
6262
this.costClass = 'higher-cost';
6363
}
6464
if (!(this.cdr as ViewRef).destroyed) {

libs/replay/coliseum/src/lib/components/game/card/card-enchantment.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export class CardEnchantmentComponent {
2828
constructor(private cards: AllCardsService) {}
2929

3030
@Input() set enchantment(value: Entity) {
31-
console.debug('[card-enchantment] setting enchantment', value);
31+
// console.debug('[card-enchantment] setting enchantment', value);
3232
this._enchantment = value;
3333
const cardId = value.cardID;
3434
const card = this.cards.getCard(cardId);

libs/replay/coliseum/src/lib/components/game/card/card-enchantments.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export class CardEnchantmentsComponent {
1616
_enchantments: readonly Entity[];
1717

1818
@Input() set enchantments(value: readonly Entity[]) {
19-
console.debug('[card-enchantments] setting enchantments', value);
19+
// console.debug('[card-enchantments] setting enchantments', value);
2020
this._enchantments = value;
2121
}
2222

libs/replay/coliseum/src/lib/components/game/card/card-frame.component.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ export class CardFrameComponent {
1717
constructor(private cards: AllCardsService) {}
1818

1919
@Input() set cardId(cardId: string) {
20-
console.debug('[card-frame] setting cardId', cardId);
20+
// console.debug('[card-frame] setting cardId', cardId);
2121
this._cardId = cardId;
2222
this.updateImage();
2323
}
2424

2525
@Input() set premium(premium: boolean | undefined) {
26-
console.debug('[card-frame] setting premium', premium);
26+
// console.debug('[card-frame] setting premium', premium);
2727
this._premium = premium ?? false;
2828
this.updateImage();
2929
}

libs/replay/coliseum/src/lib/components/game/card/card-name.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export class CardNameComponent {
2121
constructor(private cards: AllCardsService, private domSanitizer: DomSanitizer) {}
2222

2323
@Input() set cardId(cardId: string) {
24-
console.debug('[card-name] setting cardId', cardId);
24+
// console.debug('[card-name] setting cardId', cardId);
2525
const originalCard = this.cards.getCard(cardId);
2626
const cardType: CardType =
2727
originalCard && originalCard.type ? CardType[originalCard.type.toUpperCase() as string] : undefined;

libs/replay/coliseum/src/lib/components/game/card/card-race.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export class CardRaceComponent {
1818
_race: string;
1919

2020
@Input() set race(value: string) {
21-
console.debug('[card-race] setting race', value);
21+
// console.debug('[card-race] setting race', value);
2222
this._race = value;
2323
}
2424
}

libs/replay/coliseum/src/lib/components/game/card/card-rarity.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export class CardRarityComponent {
1414
constructor(private cards: AllCardsService) {}
1515

1616
@Input() set cardId(cardId: string) {
17-
console.debug('[card-rarity] setting cardId', cardId);
17+
// console.debug('[card-rarity] setting cardId', cardId);
1818
this.image = undefined;
1919
const originalCard = this.cards.getCard(cardId);
2020
const cardRarity: CardRarity | undefined = this.buildRarity(originalCard);

0 commit comments

Comments
 (0)