diff --git a/src/app/games/massive-darkness2/MD2Base.ts b/src/app/games/massive-darkness2/MD2Base.ts index 4a3ea8a..a790635 100644 --- a/src/app/games/massive-darkness2/MD2Base.ts +++ b/src/app/games/massive-darkness2/MD2Base.ts @@ -83,6 +83,7 @@ export abstract class MD2Base { } abstract refreshUI(); handleSignalRCallback(message: SignalRMessage): void { + console.log('handleSignalRCallback', message); if (message.from) { if (message.from.isGroup) { if (!this.isHeroDashboard) return; @@ -146,6 +147,8 @@ export abstract class MD2Base { break; case 'update': if (this.isHeroDashboard) { + //Before update game info check the current Hero level + let playerHeroLevel = this.md2Service.playerHero?.level; this.md2Service.info = new MD2GameInfo(JSON.parse(message.parameters['gameInfo']) as MD2GameInfo); let playerHero = this.md2Service.heros.find(h => h.playerInfo.tabId == this.stateService.loginUserService.sessionTabId); if (playerHero) { @@ -154,6 +157,13 @@ export abstract class MD2Base { playerHero.playerInfo.isDisconnected = false; this.md2Service.playerHero = playerHero; this.md2Service.broadcastMyHeroInfo(); + //When fetch game info, if the hero level is changed, show the level up message + if (playerHeroLevel && playerHeroLevel != playerHero.level) { + //do i-- + for (let i = playerHero.level; i > playerHeroLevel; i--) { + this.md2Service.msgBoxService.show(`Level Up Lv.${i}`, { text: 'Please do a skill level up!', icon: ADIcon.INFO }); + } + } } this.detectChanges(); } @@ -172,9 +182,11 @@ export abstract class MD2Base { } break; case 'sendJoinInfo': + //When hero join the game, or reconnect to the game will receive this message if (this.isHeroDashboard && this.md2Service.playerHero) { this.md2Service.playerHero.playerInfo.signalRClientId = message.parameters['signalrconnid']; - this.md2Service.broadcastMyHeroInfo(); + //Send fetch game info to the hero + this.md2Service.broadcastFetchGameInfo(); } break; default: diff --git a/src/app/games/massive-darkness2/game-init-dlg/game-init-dlg.component.ts b/src/app/games/massive-darkness2/game-init-dlg/game-init-dlg.component.ts index 6efba2a..b825ab4 100644 --- a/src/app/games/massive-darkness2/game-init-dlg/game-init-dlg.component.ts +++ b/src/app/games/massive-darkness2/game-init-dlg/game-init-dlg.component.ts @@ -2,6 +2,7 @@ import { Component, OnInit, Input } from '@angular/core'; import { NbDialogRef } from '@nebular/theme'; import { GameBundle } from '../massive-darkness2.db.model'; import { MD2Service } from '../../../services/MD2/md2.service'; +import { StringUtils } from '../../../utilities/string-utils'; export interface GameInitConfig { enabledBundles: GameBundle[]; @@ -23,12 +24,7 @@ export class GameInitDlgComponent implements OnInit { enableMobSpecialRule: boolean = false; enableHeroBetrayal: boolean = false; - bundleOptions = [ - { value: GameBundle.CoreGame, label: 'Core Game' }, - { value: GameBundle.HeavenFallen, label: 'Heaven Fallen' }, - { value: GameBundle.Zombiecide, label: 'Zombiecide' }, - { value: GameBundle.ZombiecideWhiteDeath, label: 'Zombiecide White Death' } - ]; + bundleOptions = []; constructor( private dlgRef: NbDialogRef, @@ -36,6 +32,10 @@ export class GameInitDlgComponent implements OnInit { ) { } ngOnInit(): void { + //For each GameBundle, create a new option + this.bundleOptions = Object.values(GameBundle).filter(b => !isNaN(Number(b))).map(b => ({ + value: b as GameBundle, label: StringUtils.camelToTitle(GameBundle[b as GameBundle] as string) + })); // Initialize from context if provided if (this.initialConfig) { this.enabledBundles = [...this.initialConfig.enabledBundles]; diff --git a/src/app/games/massive-darkness2/hero-dashboard/hero-dashboard.component.ts b/src/app/games/massive-darkness2/hero-dashboard/hero-dashboard.component.ts index 4b24bfb..127fc86 100644 --- a/src/app/games/massive-darkness2/hero-dashboard/hero-dashboard.component.ts +++ b/src/app/games/massive-darkness2/hero-dashboard/hero-dashboard.component.ts @@ -15,6 +15,7 @@ import { HeroClass, MD2HeroInfo, MD2HeroProfile, MD2Icon } from '../massive-dark import { MD2Base } from '../MD2Base'; import { MD2HeroProfileService } from '../service/massive-darkness2.service'; import { SignalRService } from '../../../services/signal-r.service'; +import { NbToastrService } from '@nebular/theme'; @Component({ selector: 'ngx-hero-dashboard', @@ -46,7 +47,9 @@ export class HeroDashboardComponent extends MD2Base implements OnInit { } - heroUpdateDebounceTimer = new DebounceTimer(1000, () => { this.broadcastHeroInfo(); }) + heroUpdateDebounceTimer = new DebounceTimer(1000, () => { + this.broadcastHeroInfo(); + }) classOptions: DropDownOption[] = [ new DropDownOption(HeroClass.Berserker, 'Berserker'), @@ -92,7 +95,8 @@ export class HeroDashboardComponent extends MD2Base implements OnInit { protected route: ActivatedRoute, protected cdRef: ChangeDetectorRef, private msgBoxService: MsgBoxService, - private signalRService: SignalRService + private signalRService: SignalRService, + private toastrService: NbToastrService ) { super(md2Service, stateService, route, cdRef); this.isHeroDashboard = true; @@ -109,9 +113,10 @@ export class HeroDashboardComponent extends MD2Base implements OnInit { this.gameRoomService.joinGameRoom(this.roomId); //this.fetchGameInfo(); this.signalRService.signalRMessageConnSubject.subscribe(state => { - if (state.status == 'connected') { - this.fetchGameInfo(); - } + //fetchGameInfo is called in MD2Base.handleSignalRCallback sendJoinInfo message + // if (state.status == 'connected') { + // this.fetchGameInfo(); + // } }); } @@ -284,7 +289,6 @@ export class HeroDashboardComponent extends MD2Base implements OnInit { this.hero.uiActivating = false; } this.broadcastHeroInfo(); - } endActivation() { if (this.hero.remainActions > 0) { diff --git a/src/app/games/massive-darkness2/massive-darkness2.component.html b/src/app/games/massive-darkness2/massive-darkness2.component.html index c885982..0d52149 100644 --- a/src/app/games/massive-darkness2/massive-darkness2.component.html +++ b/src/app/games/massive-darkness2/massive-darkness2.component.html @@ -57,7 +57,9 @@ ({{md2Service.highestPlayerLevel}}) -->
-