This commit is contained in:
Chris Chen
2025-11-13 15:44:39 -08:00
parent 2ef9968920
commit f30c41afba
32 changed files with 480 additions and 424 deletions
+52 -20
View File
@@ -8,6 +8,7 @@ import { StateService } from "../../services/state.service";
import { ADIcon, MessageBoxConfig } from "../../ui/alert-dlg/alert-dlg.model";
import { MD2HeroInfo, MD2Icon, MobInfo, RoundPhase } from "./massive-darkness2.model";
import { LoginUserService } from "../../services/login-user.service";
import { GamePlayer } from "../games.model";
@Injectable()
export abstract class MD2Base {
@@ -59,14 +60,14 @@ export abstract class MD2Base {
}
imgUrl(imgPath: string) {
return this.md2Service.stateService.imgUrl(imgPath);
return this.md2Service.imgUrl(imgPath);
}
fileList(folderPath: string) {
return this.md2Service.fileList(folderPath);
}
iconHtml(icon: MD2Icon, cssClass = '') {
return this.md2Service.stateService.iconHtml(icon, cssClass);
return this.md2Service.iconHtml(icon, cssClass);
}
imgHtml(imgFile: string, cssClass = '') {
@@ -82,12 +83,17 @@ export abstract class MD2Base {
}
abstract refreshUI();
handleSignalRCallback(message: SignalRMessage): void {
// if (message.from.isGroup) {
// if (!this.isHeroDashboard) return;
// } else {
// if (this.isHeroDashboard && this.md2Service.playerHero.playerInfo.signalRClientId == message.from.sessionId) return;
// }
if (message.from) {
if (message.from.isGroup) {
if (!this.isHeroDashboard) return;
} else {
if (this.isHeroDashboard && this.md2Service.playerHero?.playerInfo?.signalRClientId == message.from.connectionId) return;
}
}
if (!this.isHeroDashboard) {
}
switch (message.actionType) {
case 'hero':
let heroInfo = new MD2HeroInfo(JSON.parse(message.parameters['hero']));
@@ -101,7 +107,7 @@ export abstract class MD2Base {
break;
case 'updateMyHero':
if (this.isHeroDashboard) {
this.md2Service.stateService.playerHero = heroInfo;
this.md2Service.playerHero = heroInfo;
}
break;
@@ -113,24 +119,42 @@ export abstract class MD2Base {
case 'heroes':
switch (message.actionName) {
case 'updateAll':
let allHeroes = (JSON.parse(message.parameters['heros']) as MD2HeroInfo[]).map(h => new MD2HeroInfo(h));
//Remove heroes that are not in the list
this.md2Service.info.heros = this.md2Service.heros.filter(h => !allHeroes.some(h2 => h2.playerInfo.tabId == h.playerInfo.tabId));
allHeroes.forEach(heroInfo => {
this.updateHeroInfo(heroInfo);
});
if (this.isHeroDashboard) {
let allHeroes = (JSON.parse(message.parameters['heros']) as MD2HeroInfo[]).map(h => new MD2HeroInfo(h));
//Remove heroes that are not in the list
this.md2Service.info.heros = this.md2Service.heros.filter(h => allHeroes.some(h2 => h2.playerInfo.tabId == h.playerInfo.tabId));
allHeroes.forEach(heroInfo => {
this.updateHeroInfo(heroInfo);
});
this.detectChanges();
}
break;
}
break;
case 'GameRoom':
switch (message.actionName) {
case 'Leaving':
this.md2Service.heros.splice(this.md2Service.heros.findIndex(h => h.playerInfo.tabId == message.from.sessionId));
let leavingPlayerInfo = message.value as GamePlayer;
let leavingHero = this.md2Service.heros.find(h => h.playerInfo.tabId == leavingPlayerInfo.tabId);
if (leavingHero) {
leavingHero.playerInfo.isDisconnected = true;
}
//var disconnectHero = this.md2Service.heros.splice(this.md2Service.heros.findIndex(h => h.playerInfo.signalRClientId == leavingPlayerInfo.signalRClientId));
//this.md2Service.info.disconnectedHeroes.push(...disconnectHero);
this.detectChanges();
break;
case 'update':
if (this.isHeroDashboard) {
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) {
playerHero.playerInfo = this.md2Service.gameRoomService.currentPlayer();
playerHero.playerInfo.isDisconnected = false;
this.md2Service.playerHero = playerHero;
this.md2Service.broadcastMyHeroInfo();
}
this.detectChanges();
}
break;
@@ -140,10 +164,17 @@ export abstract class MD2Base {
this.detectChanges();
}
break;
case 'getGameInfo':
if (!this.isHeroDashboard) {
this.md2Service.broadcastGameInfo();
}
break;
case 'sendJoinInfo':
if (this.isHeroDashboard && this.md2Service.playerHero) {
this.md2Service.playerHero.playerInfo.signalRClientId = message.parameters['signalrconnid'];
this.md2Service.broadcastService.broadcastMyHeroInfo();
this.md2Service.broadcastMyHeroInfo();
}
break;
default:
@@ -212,14 +243,15 @@ export abstract class MD2Base {
}
}
updateHeroInfo(heroInfo: MD2HeroInfo) {
let exitingHero = this.md2Service.heros.find(h => h.playerInfo.signalRClientId == heroInfo.playerInfo.signalRClientId);
let exitingHero = this.md2Service.heros.find(h => h.playerInfo.tabId == heroInfo.playerInfo.tabId);
if (exitingHero) {
//For boss fight, if the hero finished activating, activate the boss
let activateBoss = exitingHero.uiActivating && !heroInfo.uiActivating;
this.md2Service.heros[this.md2Service.heros.indexOf(exitingHero)] = heroInfo;
//My hero update
if (this.isHeroDashboard && this.md2Service.loginUserService.sessionTabId == heroInfo.playerInfo.tabId) {
this.md2Service.stateService.playerHero = heroInfo;
this.md2Service.playerHero = heroInfo;
}
if (!this.isHeroDashboard && this.md2Service.info.isBossFight && activateBoss) {
this.md2Service.activateBoss();
@@ -276,14 +308,14 @@ export abstract class MD2ComponentBase {
this.destroy$.complete();
}
imgUrl(imgPath: string) {
return this.md2Service.stateService.imgUrl(imgPath);
return this.md2Service.imgUrl(imgPath);
}
fileList(folderPath: string) {
return this.md2Service.fileList(folderPath);
}
iconHtml(icon: MD2Icon, cssClass = '') {
return this.md2Service.stateService.iconHtml(icon, cssClass);
return this.md2Service.iconHtml(icon, cssClass);
}
detectChanges() {
if (!this.cdRef['destroyed']) {
@@ -11,7 +11,7 @@
<div class="col-md-7">
<div class="row">
<div class="col-md">
<adj-number-input name="mob{{boss.info.name}}" [(ngModel)]="boss.info.unitRemainHp" minimum="0"
<adj-number-input name="mob{{boss.info.name}}" [(ngModel)]="boss.info.hp" minimum="0"
class="mb-3" title="Boss HP" (hitMinimum)="WIN()">
</adj-number-input>
<md2-mob-attack-info [mob]="boss.info">
@@ -52,7 +52,11 @@ export class BossFightComponent extends MD2ComponentBase {
this.boss.activating();
}
WIN() {
this.msgBoxService.show('Win', { text: 'You Win the Boss Fight', icon: ADIcon.INFO });
this.md2Service.info.isBossFight = false;
this.md2Service.info.boss = undefined;
this.md2Service.heros.forEach(h => h.uiBossFight = false);
this.md2Service.broadcastGameInfo();
}
attack(mob: MobInfo) {
@@ -62,6 +66,9 @@ export class BossFightComponent extends MD2ComponentBase {
let attackDamage = mobResult.uiWounds;
if (attackDamage) {
this.boss.info.hp -= attackDamage;
if (this.boss.info.hp <= 0) {
this.WIN();
}
this.cdRef.detectChanges();
}
}
@@ -139,7 +139,7 @@
<!-- <img class="MD2HeroCard " src="{{imgUrl('Heros/'+className+'.jpg')}}" (click)="toggleFlip()"> -->
<!-- Action Buttons (Desktop/Landscape) -->
<div class="hero-actions d-none d-sm-block">
<div class="hero-actions d-block">
<div class="action-buttons-group" *ngIf="hero.uiActivating && hero.remainActions > 0">
<button nbButton hero class="action-btn" status="info" (click)="moveAction()"
*ngIf="!showMoveAction">
@@ -14,6 +14,7 @@ import { DebounceTimer } from '../../../utilities/timer-utils';
import { HeroClass, MD2HeroInfo, MD2HeroProfile, MD2Icon } from '../massive-darkness2.model';
import { MD2Base } from '../MD2Base';
import { MD2HeroProfileService } from '../service/massive-darkness2.service';
import { SignalRService } from '../../../services/signal-r.service';
@Component({
selector: 'ngx-hero-dashboard',
@@ -70,6 +71,15 @@ export class HeroDashboardComponent extends MD2Base implements OnInit {
return this.md2Service.playerHero;
}
public get className() {
if (this.md2Service.playerHero) {
return HeroClass[this.md2Service.playerHero.class];
}
if (this.selectedHeroClass) {
return HeroClass[this.selectedHeroClass];
}
return '';
}
public get currentSelectingHero(): MD2HeroInfo {
return this.heros[this.currentHeroIndex];
}
@@ -82,6 +92,7 @@ export class HeroDashboardComponent extends MD2Base implements OnInit {
protected route: ActivatedRoute,
protected cdRef: ChangeDetectorRef,
private msgBoxService: MsgBoxService,
private signalRService: SignalRService
) {
super(md2Service, stateService, route, cdRef);
this.isHeroDashboard = true;
@@ -93,6 +104,15 @@ export class HeroDashboardComponent extends MD2Base implements OnInit {
ngOnInit(): void {
super.ngOnInit();
this.gameRoomService.gameRoomId = this.roomId;
this.gameRoomService.joinGameRoom(this.roomId);
//this.fetchGameInfo();
this.signalRService.signalRMessageConnSubject.subscribe(state => {
if (state.status == 'connected') {
this.fetchGameInfo();
}
});
}
override signalRInitialized() {
@@ -103,9 +123,7 @@ export class HeroDashboardComponent extends MD2Base implements OnInit {
// }
}
initHero() {
this.gameRoomService.gameRoomId = this.roomId;
this.gameRoomService.joinGameRoom(this.roomId);
if (!this.md2Service.heros.some(h => h.playerInfo.signalRClientId == this.stateService.loginUserService.userAccess.signalRSessionId)) {
if (!this.md2Service.heros.some(h => h.playerInfo.signalRClientId == this.stateService.loginUserService.userAccess.signalRConnectionId)) {
this.msgBoxService.showInputbox('Select Hero Class', '', { dropDownOptions: this.classOptions, inputType: 'dropdown' })
.pipe(first()).subscribe(heroClass => {
@@ -127,10 +145,11 @@ export class HeroDashboardComponent extends MD2Base implements OnInit {
});
}
}
className: string;
initClassHeroList(heroClass: HeroClass) {
this.heros = [];
this.className = HeroClass[heroClass];
this.selectedHeroClass = heroClass;
this.heroProfileService.getAll().pipe(first()).subscribe(result => {
@@ -161,7 +180,7 @@ export class HeroDashboardComponent extends MD2Base implements OnInit {
selectCurrentHero() {
if (this.currentSelectingHero) {
this.md2Service.playerJoin(this.currentSelectingHero);
this.md2Service.broadcastService.broadcastMyHeroInfo();
this.md2Service.broadcastMyHeroInfo();
this.isSelectingHero = false;
this.detectChanges();
}
@@ -189,8 +208,12 @@ export class HeroDashboardComponent extends MD2Base implements OnInit {
this.detectChanges();
}
fetchGameInfo() {
this.md2Service.broadcastFetchGameInfo();
}
broadcastHeroInfo() {
this.md2Service.broadcastService.broadcastMyHeroInfo();
this.md2Service.broadcastMyHeroInfo();
this.heroUpdateDebounceTimer.clearOut();
}
increaseRage() {
@@ -199,7 +222,7 @@ export class HeroDashboardComponent extends MD2Base implements OnInit {
}
}
openDoor() {
this.md2Service.broadcastService.broadcastHeroAction('openDoor');
this.md2Service.broadcastHeroAction('openDoor');
//this.showMoveAction = false;
this.detectChanges();
}
@@ -224,7 +247,7 @@ export class HeroDashboardComponent extends MD2Base implements OnInit {
default:
break;
}
this.md2Service.broadcastService.broadcastHeroAction(action);
this.md2Service.broadcastHeroAction(action);
this.reduceAction();
}
reduceAction() {
@@ -59,20 +59,28 @@
<div class="col-12" *ngFor="let hero of md2Service.heros">
<label class='label mr-1'>{{hero.playerInfo.name}} ({{heroClassName(hero)}} -
{{hero.name}})</label>
<span class="badge badge-primary mr-1">Lv.:{{hero.level}}</span>
<span class="badge badge-primary mr-1">HP: {{hero.hp}}/{{hero.hpMaximum}}</span>
<span class="badge badge-primary mr-1">Mana: {{hero.mp}}/{{hero.mpMaximum}}</span>
<span class="badge badge-success mr-1">Exp: {{hero.exp}}</span>
<span class="badge badge-primary mr-1"
(click)="adjustHeroValue(hero,'level')">Lv.:{{hero.level}}</span>
<span class="badge badge-primary mr-1" (click)="adjustHeroValue(hero,'hp')">HP:
{{hero.hp}}/{{hero.hpMaximum}}</span>
<span class="badge badge-primary mr-1" (click)="adjustHeroValue(hero,'mp')">Mana:
{{hero.mp}}/{{hero.mpMaximum}}</span>
<span class="badge badge-success mr-1" (click)="adjustHeroValue(hero,'exp')">Exp:
{{hero.exp}}</span>
<span class="badge mr-1" *ngIf="hero.fireToken">
<md2-icon [icon]="MD2Icon.FireToken" size="sm"></md2-icon> {{hero.fireToken}}
</span>
<span class="badge mr-1" *ngIf="hero.frozenToken">
<md2-icon [icon]="MD2Icon.FrozenToken" size="sm"></md2-icon>{{hero.frozenToken}}
</span>
<span class="badge badge-success mr-1" *ngIf="hero.remainActions>0">Actions:
<span class="badge badge-success mr-1" *ngIf="hero.remainActions>0"
(click)="adjustHeroValue(hero,'remainActions')">Actions:
{{hero.remainActions}}</span>
<span class="badge badge-light mr-1" *ngIf=" !hero.uiActivating">Inactive</span>
<span class="badge badge-light mr-1" *ngIf=" !hero.uiActivating"
(click)="activatingHero(hero)">Inactive</span>
<span class="badge badge-primary mr-1" *ngIf="hero.uiActivating">Activating</span>
<span class="badge badge-warning mr-1"
*ngIf="hero.playerInfo.isDisconnected">Disconnected</span>
<!-- <span class="badge badge-success mr-1">{{hero.playerInfo.signalRClientId}}</span> -->
<span class="badge badge-danger mr-1" (click)="removeHero(hero)">X
@@ -0,0 +1,3 @@
.badge {
cursor: pointer;
}
@@ -51,6 +51,31 @@ export class MassiveDarkness2Component extends MD2Base implements OnInit {
}
override signalRInitialized() {
}
adjustHeroValue(hero: MD2HeroInfo, value: string) {
this.msgBoxService.showInputbox(`Adjust ${value} for ${hero.playerInfo.name}`, `Enter the new value for ${value}`, {
inputType: 'number',
inputValue: hero[value].toString()
}).pipe(first()).subscribe(result => {
if (result) {
hero[value] = Number.parseInt(result);
this.md2Service.broadcastHeroInfoToAll(hero, true);
this.detectChanges();
}
});
}
activatingHero(hero: MD2HeroInfo) {
if (hero.remainActions > 0) {
this.msgBoxService.show('Activating', { text: `Are you sure you want to activate ${hero.playerInfo.name}?` }).pipe(first()).subscribe(result => {
if (result) {
this.md2Service.heros.forEach(h => h.uiActivating = false);
hero.uiActivating = true;
this.md2Service.broadcastAllHeroInfoToAll();
this.detectChanges();
}
});
}
}
showQrCode() {
if (this.md2Service.initialized == false) {
@@ -146,7 +171,7 @@ export class MassiveDarkness2Component extends MD2Base implements OnInit {
this.md2Service.heros.forEach(hero => {
hero.uiShowAttackBtn = this.md2Service.mobs.length > 0 || this.md2Service.roamingMonsters.length > 0 || this.md2Service.info.isBossFight;
});
this.md2Service.broadcastService.broadcastAllHeroInfoToAll();
this.md2Service.broadcastAllHeroInfoToAll();
}
removeHero(hero) {
this.msgBoxService.showConfirmDeleteBox().pipe(first()).subscribe(result => {
@@ -53,6 +53,7 @@ export interface IBossFight {
imgUrl: string
standUrl: string
extraRules: string
md2Service: MD2Service
activating(): boolean
prepareForBossFight(): void
darknessPhase(): void
@@ -73,7 +74,7 @@ export abstract class BossFight implements IBossFight {
extraRules: string
protected subscription: Subscription
constructor(protected md2Service: MD2Service) {
constructor(public md2Service: MD2Service) {
this.rounds = 1;
}
activating(): boolean {
@@ -105,26 +106,26 @@ export abstract class BossFight implements IBossFight {
}
export class BossMicheal extends BossFight {
constructor(protected md2Service: MD2Service) {
constructor(public md2Service: MD2Service) {
super(md2Service);
this.corruptionTokenHtml = this.md2Service.stateService.imgHtml('Tokens/CorruptToken.png');
this.corruptionTokenHtml = this.md2Service.imgHtml('Tokens/CorruptToken.png');
this.name = 'Michael - The Corrupted Archangel';
this.imgUrl = md2Service.stateService.imgUrl('/Boss/Michael - The Corrupted Archangel.jpg');
this.standUrl = md2Service.stateService.imgUrl('/Boss/Michael.png');
this.imgUrl = md2Service.imgUrl('/Boss/Michael - The Corrupted Archangel.jpg');
this.standUrl = md2Service.imgUrl('/Boss/Michael.png');
this.info = new MobInfo({
description: this.name,
type: MobType.Boss,
hpPerHero: 15,
level: 10,
imageUrl: md2Service.stateService.imgUrl('/Boss/Michael.png')
imageUrl: md2Service.imgUrl('/Boss/Michael.png')
});
if (!this.info.skills) {
this.info.skills = [];
}
this.info.skills.push({
name: `Combat 1 ${this.md2Service.stateService.iconHtml(MD2Icon.EnemySkill)}`,
name: `Combat 1 ${this.md2Service.iconHtml(MD2Icon.EnemySkill)}`,
description: `Deal 1 Wound for each ${this.corruptionTokenHtml} on the attacking or defending Hero. Discard the tokens afterwards(once per combat).`,
type: MobSkillType.Combat,
skillRoll: 1
@@ -135,9 +136,9 @@ export class BossMicheal extends BossFight {
this.actionBlackDice = 2;
this.extraRules = `Archangel Michael cant be the target of any attack, skill, ability or take Wounds until there are no Corruption tokens in the whole Tile.<br><br>` +
`Any Hero on a Zone with a ${this.corruptionTokenHtml} may spend 1 action to remove it. Each time a Hero removes a ${this.corruptionTokenHtml} from a Zone they must roll 1 ${this.md2Service.stateService.iconHtml(MD2Icon.BlackDice)}.` +
`If ${this.md2Service.stateService.iconHtml(MD2Icon.EnemyClaw)} the Hero takes 1 Wound.<br>If ${this.md2Service.stateService.iconHtml(MD2Icon.EnemySkill)} place 1 ${this.corruptionTokenHtml} on their Dashboard.<br>` +
`If ${this.md2Service.stateService.iconHtml(MD2Icon.EnemyClaw)}/${this.md2Service.stateService.iconHtml(MD2Icon.EnemySkill)} the Hero takes 1 Wound and places 1 ${this.corruptionTokenHtml} on their Dashboard.`
`Any Hero on a Zone with a ${this.corruptionTokenHtml} may spend 1 action to remove it. Each time a Hero removes a ${this.corruptionTokenHtml} from a Zone they must roll 1 ${this.md2Service.iconHtml(MD2Icon.BlackDice)}.` +
`If ${this.md2Service.iconHtml(MD2Icon.EnemyClaw)} the Hero takes 1 Wound.<br>If ${this.md2Service.iconHtml(MD2Icon.EnemySkill)} place 1 ${this.corruptionTokenHtml} on their Dashboard.<br>` +
`If ${this.md2Service.iconHtml(MD2Icon.EnemyClaw)}/${this.md2Service.iconHtml(MD2Icon.EnemySkill)} the Hero takes 1 Wound and places 1 ${this.corruptionTokenHtml} on their Dashboard.`
}
activatedTimes: number
acted: number
@@ -232,26 +233,26 @@ export class BossMicheal extends BossFight {
export class BossReaper extends BossFight {
constructor(protected md2Service: MD2Service) {
constructor(public md2Service: MD2Service) {
super(md2Service);
this.timeTokenHtml = this.md2Service.stateService.imgHtml('Tokens/TimeToken.png');
this.timeTokenHtml = this.md2Service.imgHtml('Tokens/TimeToken.png');
this.name = 'The Reaper';
this.imgUrl = md2Service.stateService.imgUrl('/Boss/The Reaper.jpg');
this.standUrl = md2Service.stateService.imgUrl('/Boss/The Reaper-Stand.png');
this.imgUrl = md2Service.imgUrl('/Boss/The Reaper.jpg');
this.standUrl = md2Service.imgUrl('/Boss/The Reaper-Stand.png');
this.info = new MobInfo({
description: this.name,
type: MobType.Boss,
hpPerHero: 25,
level: 10,
imageUrl: md2Service.stateService.imgUrl('/Boss/The Reaper-Stand.png')
imageUrl: md2Service.imgUrl('/Boss/The Reaper-Stand.png')
});
if (!this.info.skills) {
this.info.skills = [];
}
this.info.skills.push({
description: `If the Hero has no ${this.md2Service.stateService.iconHtml(MD2Icon.Mana_Color)}, they take 1 ${this.md2Service.stateService.iconHtml(MD2Icon.FrozenToken)}`,
description: `If the Hero has no ${this.md2Service.iconHtml(MD2Icon.Mana_Color)}, they take 1 ${this.md2Service.iconHtml(MD2Icon.FrozenToken)}`,
type: MobSkillType.Attack,
skillRoll: 1
} as MD2MobSkill);
@@ -304,8 +305,8 @@ export class BossReaper extends BossFight {
name: 'Death Is Coming',
description:
`Place The Reaper in the central Zone.<br>` +
`Roll 1 ${this.md2Service.stateService.iconHtml(MD2Icon.YellowDice)}. Remove ${this.timeTokenHtml} equal to ${this.md2Service.stateService.iconHtml(MD2Icon.Melee)} rolled from both <b>Hourglass Zone</b>.<br>` +
`Each Hero discards ${this.md2Service.stateService.iconHtml(MD2Icon.MP)} equal to ${this.md2Service.stateService.iconHtml(MD2Icon.Melee)} rolled.`
`Roll 1 ${this.md2Service.iconHtml(MD2Icon.YellowDice)}. Remove ${this.timeTokenHtml} equal to ${this.md2Service.iconHtml(MD2Icon.Melee)} rolled from both <b>Hourglass Zone</b>.<br>` +
`Each Hero discards ${this.md2Service.iconHtml(MD2Icon.MP)} equal to ${this.md2Service.iconHtml(MD2Icon.Melee)} rolled.`
});
break;
@@ -6,7 +6,6 @@ import { MsgBoxService } from '../../../services/msg-box.service';
import { DropDownOption } from '../../../entity/dropDownOption';
import { MD2Icon } from '../massive-darkness2.model';
import { first } from 'rxjs/operators';
import { MD2StateService } from '../../../services/MD2/md2-state.service';
import { MD2IconPickerDlgComponent } from './md2-icon-picker-dlg.component';
import { NbDialogService } from '@nebular/theme';
import { DOMParser as ProseMirrorDOMParser } from 'prosemirror-model';
@@ -59,7 +58,6 @@ export class MD2HtmlEditorComponent implements ControlValueAccessor, AfterViewIn
constructor(
private msgBoxService: MsgBoxService,
private md2StateService: MD2StateService,
private dialogService: DialogService,
private cdr: ChangeDetectorRef,
elementRef: ElementRef, ngZone: NgZone, @Inject(PLATFORM_ID) platformId: Object) {
@@ -1,8 +1,8 @@
import { Component, OnInit } from '@angular/core';
import { NbDialogRef } from '@nebular/theme';
import { MD2Icon } from '../massive-darkness2.model';
import { MD2StateService } from '../../../services/MD2/md2-state.service';
import { DialogRef } from '@progress/kendo-angular-dialog';
import { MD2Service } from '../../../services/MD2/md2.service';
@Component({
selector: 'md2-icon-picker-dlg',
@@ -63,7 +63,7 @@ export class MD2IconPickerDlgComponent implements OnInit {
constructor(
private dlgRef: DialogRef,
private md2StateService: MD2StateService
private md2Service: MD2Service
) { }
ngOnInit(): void {
@@ -72,7 +72,7 @@ export class MD2IconPickerDlgComponent implements OnInit {
this.iconList.push({
icon: icon,
name: MD2Icon[icon],
html: this.md2StateService.iconHtml(icon)
html: this.md2Service.iconHtml(icon)
});
}
}
@@ -1,6 +1,6 @@
import { Component, Input, OnInit } from '@angular/core';
import { MD2Icon, TreasureType } from '../massive-darkness2.model';
import { MD2StateService } from '../../../services/MD2/md2-state.service';
import { MD2Service } from '../../../services/MD2/md2.service';
@Component({
selector: 'md2-icon',
@@ -44,7 +44,7 @@ export class MD2IconComponent implements OnInit {
}
@Input() size: string = 'sm';
iconName: string;
constructor(private md2StateService: MD2StateService) { }
constructor(private md2Service: MD2Service) { }
ngOnInit(): void {
}
@@ -52,10 +52,10 @@ export class MD2IconComponent implements OnInit {
private initIcon(icon: MD2Icon): void {
if (icon < MD2Icon.TreasureToken) {
this.isImageIcon = false;
this.iconHtml = this.md2StateService.iconHtml(icon);
this.iconHtml = this.md2Service.iconHtml(icon);
} else {
this.isImageIcon = true;
this.imgUrl = this.md2StateService.iconHtml(icon);
this.imgUrl = this.md2Service.iconHtml(icon);
}
}
@@ -5,7 +5,7 @@ import { MD2MobLevelInfo } from '../../massive-darkness2.db.model';
import { MobSkillType } from '../../massive-darkness2.model.boss';
import { MD2MobLevelInfoService } from '../../service/massive-darkness2.service';
import { MD2Icon, MobType } from '../../massive-darkness2.model';
import { MD2StateService } from '../../../../services/MD2/md2-state.service';
import { MD2Service } from '../../../../services/MD2/md2.service';
@Component({
selector: 'ngx-md2-mob-level-editor',
@@ -30,7 +30,7 @@ export class MD2MobLevelEditorComponent extends DialogContentBase implements OnI
public dialog: DialogRef,
private mobLevelInfoService: MD2MobLevelInfoService,
private cdr: ChangeDetectorRef,
private md2StateService: MD2StateService
private md2Service: MD2Service
) {
super(dialog);
}
@@ -43,9 +43,9 @@ export class MD2MobLevelEditorComponent extends DialogContentBase implements OnI
public initializeEnums(): void {
this.attackTypes = [
{ value: MobSkillType.Attack, text: 'None' },
{ value: MobSkillType.MeleeAttack, text: this.md2StateService.iconHtml(MD2Icon.Melee) + ' Melee Attack' },
{ value: MobSkillType.RangeAttack, text: this.md2StateService.iconHtml(MD2Icon.Range) + ' Range Attack' },
{ value: MobSkillType.MagicAttack, text: this.md2StateService.iconHtml(MD2Icon.Magic) + ' Magic Attack' },
{ value: MobSkillType.MeleeAttack, text: this.md2Service.iconHtml(MD2Icon.Melee) + ' Melee Attack' },
{ value: MobSkillType.RangeAttack, text: this.md2Service.iconHtml(MD2Icon.Range) + ' Range Attack' },
{ value: MobSkillType.MagicAttack, text: this.md2Service.iconHtml(MD2Icon.Magic) + ' Magic Attack' },
];
this.selectedAttackType = this.attackTypes.find(t => t.value === this.model.attackInfo.type) || this.attackTypes[0] || null;
this.selectedAlterAttackType = this.attackTypes.find(t => t.value === this.model.alterAttackInfo?.type) || this.attackTypes[0] || null;
@@ -8,8 +8,8 @@
<div class="pl-2 col-md-6" *ngIf="mob.mobAmount">
<ng-container>
<label class='label g-text-nowrap'>Alive Units <b
class="MD2text g-font-size-18">{{mob.mobAmount}}</b></label><br>
<label class='label g-text-nowrap'>Minions <b
class="MD2text g-font-size-18">{{mob.mobAmount-1}}</b></label><br>
</ng-container>
</div>
@@ -1,7 +1,8 @@
<img class="g-width-95x img-thumbnail mobBg" src="{{imgUrl('/Mobs/BG.png')}}" />
<img class="mobImg roamingMonster" src="{{getMobImageUrl(mob)}}" (click)="showMobImage(mob)" *ngIf="!isMob" />
<div *ngIf="isMob">
<img class="mobImg mobLeader" src="{{mob.leaderImgUrl}}" (click)="showMobImage(mob)" />
<img class="mobImg mobMinion" src="{{mob.minionImgUrl}}" (click)="showMobImage(mob)" />
<img class="mobImg mobLeader" src="{{mob.leaderImgUrl}}" (click)="showMobImage(mob)"
[ngClass]="{'noMinions': mob.mobAmount==1}" />
<img class="mobImg mobMinion" src="{{mob.minionImgUrl}}" (click)="showMobImage(mob)" *ngIf="mob.mobAmount>1" />
</div>
@@ -1,6 +1,7 @@
.mobImg {
position: absolute;
z-index: 2;
object-fit: contain;
&.roamingMonster {
width: 95%;
max-height: 80%;
@@ -12,6 +13,10 @@
max-height: 80%;
top: 40px;
left: 0;
&.noMinions {
width: 95%;
max-height: 90%;
}
}
&.mobMinion {
width: 60%;
@@ -119,7 +119,7 @@ export class MobsComponent extends MD2ComponentBase implements OnInit {
afterSpawn() {
this.cdRef.detectChanges();
this.md2Service.broadcastService.broadcastMobsInfo();
this.md2Service.broadcastMobsInfo();
if (this.showRoundMessage) {
this.msgBoxService.show(`${NumberUtils.Ordinal(this.md2Service.info.round)} Hero Phase`, { icon: ADIcon.INFO });
}
@@ -150,7 +150,7 @@ export class MobsComponent extends MD2ComponentBase implements OnInit {
if (attacker) {
attacker.exp += 1;
this.msgBoxService.show(`${attacker.heroFullName} Gain 1 Exp`, { icon: ADIcon.INFO }).pipe(first()).subscribe(result => {
this.md2Service.broadcastService.broadcastHeroInfoToOwner(attacker);
this.md2Service.broadcastHeroInfoToOwner(attacker);
});
}