This commit is contained in:
Chris Chen 2025-11-06 21:47:04 -08:00
parent 349510db56
commit d8db9f650b
11 changed files with 166 additions and 152 deletions

View File

@ -8,99 +8,6 @@ import { MobSkillType } from "../../massive-darkness2.model.boss";
import { MD2DiceSet, MD2MobSkill } from "../../massive-darkness2.db.model"; import { MD2DiceSet, MD2MobSkill } from "../../massive-darkness2.db.model";
const MD2_IMG_URL = (id: string = null) => { return `${environment.apiUrl}/Files/Images/MD2/Mobs${(id ? `${encodeURI(id)}` : '')}` } const MD2_IMG_URL = (id: string = null) => { return `${environment.apiUrl}/Files/Images/MD2/Mobs${(id ? `${encodeURI(id)}` : '')}` }
const CORE_GAME_MOB_LEVEL = [
new MobInfo({
name: 'Andra', level: 1, hp: 5,
attackInfos: [new AttackInfo(MD2Icon.Melee, 1, 0, 0, 1), new AttackInfo(MD2Icon.Range, 1, 0, 0, 1)],
defenseInfo: { blue: 2, black: 1 } as MD2DiceSet,
}),
new MobInfo({
name: 'Andra', level: 3, hp: 7,
attackInfos: [new AttackInfo(MD2Icon.Melee, 1, 1, 0, 1), new AttackInfo(MD2Icon.Range, 1, 1, 0, 1)],
defenseInfo: { blue: 3, black: 1 } as MD2DiceSet,
}),
new MobInfo({
name: 'Andra', level: 5, hp: 5,
attackInfos: [new AttackInfo(MD2Icon.Melee, 1, 2, 0, 1), new AttackInfo(MD2Icon.Range, 1, 2, 0, 1)],
defenseInfo: { blue: 5, black: 1 } as MD2DiceSet,
}),
new MobInfo({
name: 'Ytheria, Undead Queen', level: 1, hp: 4,
attackInfos: [new AttackInfo(MD2Icon.Melee, 1), new AttackInfo(MD2Icon.Range, 2, 0, 0, 1)],
defenseInfo: { blue: 1, black: 1 } as MD2DiceSet,
}),
new MobInfo({
name: 'Ytheria, Undead Queen', level: 3, hp: 6,
attackInfos: [new AttackInfo(MD2Icon.Melee, 0, 1), new AttackInfo(MD2Icon.Range, 1, 1, 0, 1)],
defenseInfo: { blue: 2, black: 1 } as MD2DiceSet,
}),
new MobInfo({
name: 'Ytheria, Undead Queen', level: 5, hp: 8,
attackInfos: [new AttackInfo(MD2Icon.Melee, 2, 1), new AttackInfo(MD2Icon.Range, 2, 1, 0, 1)],
defenseInfo: { blue: 4, black: 1 } as MD2DiceSet,
}),
new MobInfo({
name: 'Lyidan, Incubus Lord', level: 1, hp: 7,
attackInfos: [new AttackInfo(MD2Icon.Melee, 0, 1, 0, 2)],
defenseInfo: { blue: 2, black: 1 } as MD2DiceSet,
}),
new MobInfo({
name: 'Lyidan, Incubus Lord', level: 3, hp: 10,
attackInfos: [new AttackInfo(MD2Icon.Melee, 0, 2, 0, 1)],
defenseInfo: { blue: 2, black: 1 } as MD2DiceSet,
}),
new MobInfo({
name: 'Lyidan, Incubus Lord', level: 5, hp: 12,
attackInfos: [new AttackInfo(MD2Icon.Melee, 2, 2, 0, 1)],
defenseInfo: { blue: 4, black: 1 } as MD2DiceSet,
}),
new MobInfo({
name: 'The Ghoul', level: 1, hp: 5,
attackInfos: [new AttackInfo(MD2Icon.Melee, 0, 1, 0, 1)],
defenseInfo: { blue: 2, black: 1 } as MD2DiceSet,
}),
new MobInfo({
name: 'The Ghoul', level: 3, hp: 8,
attackInfos: [new AttackInfo(MD2Icon.Melee, 0, 2, 0, 2)],
defenseInfo: { blue: 3, black: 1 } as MD2DiceSet,
}),
new MobInfo({
name: 'The Ghoul', level: 5, hp: 10,
attackInfos: [new AttackInfo(MD2Icon.Melee, 0, 3, 0, 3)],
defenseInfo: { blue: 4, black: 1 } as MD2DiceSet,
}),
new MobInfo({
name: 'Balrog', level: 1, hp: 5,
attackInfos: [
new AttackInfo(MD2Icon.Magic, 0, 1, 0, 2),
],
defenseInfo: { blue: 2, black: 1 } as MD2DiceSet,
}),
new MobInfo({
name: 'Balrog', level: 3, hp: 8,
attackInfos: [
new AttackInfo(MD2Icon.Magic, 0, 2, 0, 2),
],
defenseInfo: { blue: 3, black: 1 } as MD2DiceSet,
}),
new MobInfo({
name: 'Balrog', level: 5, hp: 10,
attackInfos: [
new AttackInfo(MD2Icon.Magic, 0, 3, 0, 2),
],
defenseInfo: { blue: 4, black: 1 } as MD2DiceSet,
}),
]
export abstract class CoreGameRMFactory implements IMobFactory { export abstract class CoreGameRMFactory implements IMobFactory {
abstract mobName: string; abstract mobName: string;
@ -192,7 +99,7 @@ export class RMUndeadQueenFactory extends CoreGameRMFactory {
} }
}); });
} }
});; });
} }
this.mob.skills = [ this.mob.skills = [

View File

@ -377,7 +377,6 @@ export class MobInfo implements IDrawingItem {
return 0; return 0;
} }
} }
public actionSubject: Subject<string>;
public activateFunction?: (mob: MobInfo, msgBoxService: MsgBoxService, heros: MD2HeroInfo[]) => void; public activateFunction?: (mob: MobInfo, msgBoxService: MsgBoxService, heros: MD2HeroInfo[]) => void;
} }
export interface MD2HeroProfile { export interface MD2HeroProfile {

View File

@ -21,7 +21,7 @@
</md2-icon> </md2-icon>
</label> --> </label> -->
<div *ngFor="let skill of mob.skills" class=" g-brd-bottom--dashed g-brd-gray-light-v2"> <div *ngFor="let skill of mob.skills" class=" g-brd-bottom--dashed g-brd-gray-light-v2">
<div *ngIf="showAllSkill || skill.uiDisplay"> <div *ngIf="skill.uiDisplay">
<label for='' class='MD2text g-font-size-22 label mb-2'> <label for='' class='MD2text g-font-size-22 label mb-2'>
{{MobSkillType[skill.type]}} {{skill.skillRoll}} <md2-icon icon="enemySkill" size="md"></md2-icon> {{MobSkillType[skill.type]}} {{skill.skillRoll}} <md2-icon icon="enemySkill" size="md"></md2-icon>
</label> </label>

View File

@ -39,7 +39,8 @@ export class MobCombatInfoComponent implements OnInit {
element.uiDisplay = [MobSkillType.Combat, MobSkillType.Defense].includes(element.type); element.uiDisplay = [MobSkillType.Combat, MobSkillType.Defense].includes(element.type);
break; break;
case MobDlgType.PreView: case MobDlgType.PreView:
element.uiDisplay = true; case MobDlgType.Dashboard:
element.uiDisplay = [MobSkillType.Combat, MobSkillType.Attack, MobSkillType.Defense].includes(element.type);
break; break;
case MobDlgType.Spawn: case MobDlgType.Spawn:
element.uiDisplay = false; element.uiDisplay = false;

View File

@ -34,11 +34,21 @@
<ng-container *ngIf="showAdjustment"> <ng-container *ngIf="showAdjustment">
<div class="row">
<div class="col-md-6">
<adj-number-input name="mob{{mob.name}}" [ngModel]="mob.unitRemainHp" [maximum]="mob.hp" minimum="1" <adj-number-input name="mob{{mob.name}}" [ngModel]="mob.unitRemainHp" [maximum]="mob.hp" minimum="1"
title="Target Unit HP" (hitChange)="adjustMobHp($event)" (hitMinimum)="adjustMobHp(-1)" title="Target Unit HP" (hitChange)="adjustMobHp($event)" (hitMinimum)="adjustMobHp(-1)"
(hitMaximum)="adjustMobHp(1)"> (hitMaximum)="adjustMobHp(1)">
</adj-number-input> </adj-number-input>
</div>
<div class="col-md-6" *ngIf="mode==MobDlgType.Activating">
<adj-number-input name="mob{{mob.name}}Actions" [(ngModel)]="mob.actions" title="Remaining Actions"
hideIncreaseBtn>
</adj-number-input>
</div>
</div>
</ng-container> </ng-container>

View File

@ -11,7 +11,6 @@ import { StateService } from '../../../services/state.service';
import { ADButtons, ADIcon } from '../../../ui/alert-dlg/alert-dlg.model'; import { ADButtons, ADIcon } from '../../../ui/alert-dlg/alert-dlg.model';
import { NumberUtils } from '../../../utilities/number-utils'; import { NumberUtils } from '../../../utilities/number-utils';
import { StringUtils } from '../../../utilities/string-utils'; import { StringUtils } from '../../../utilities/string-utils';
import { CoreGameRMFactories } from '../factorys/roamingMonsters/CoreGame';
import { DrawingBag, DrawingItem, MD2Icon, MobDlgType, MobInfo, TreasureType } from '../massive-darkness2.model'; import { DrawingBag, DrawingItem, MD2Icon, MobDlgType, MobInfo, TreasureType } from '../massive-darkness2.model';
import { MD2Base, MD2ComponentBase } from '../MD2Base'; import { MD2Base, MD2ComponentBase } from '../MD2Base';
import { SpawnMobDlgComponent } from './spawn-mob-dlg/spawn-mob-dlg.component'; import { SpawnMobDlgComponent } from './spawn-mob-dlg/spawn-mob-dlg.component';
@ -89,7 +88,7 @@ export class MobsComponent extends MD2ComponentBase implements OnInit {
} }
spawnSpecificMob() { spawnSpecificMob() {
let mobOptions = this.isRoamingMonster ? CoreGameRMFactories.map(f => new DropDownOption(f.mobName, f.mobName)) : this.md2Service.allMobInfos.map(f => new DropDownOption(f.name, f.name)); let mobOptions = this.isRoamingMonster ? this.md2Service.allRoamingMonsterInfos.map(f => new DropDownOption(f.name, f.name)) : this.md2Service.allMobInfos.map(f => new DropDownOption(f.name, f.name));
this.msgBoxService.showInputbox('Spawn', '', this.msgBoxService.showInputbox('Spawn', '',
{ {
inputType: 'dropdown', dropDownOptions: mobOptions, inputType: 'dropdown', dropDownOptions: mobOptions,

View File

@ -5,20 +5,21 @@
</nb-card-header> </nb-card-header>
<nb-card-body> <nb-card-body>
<div class="row no-gutters"> <div class="row no-gutters">
<div class="col-md-7 g-height-90vh"> <div class="col-md-7">
<!-- <img src="{{mob.imageUrl}}" class="g-width-90x"> --> <!-- <img src="{{mob.imageUrl}}" class="g-width-90x"> -->
<md2-mob-stand-info [mob]="mob" [mode]="mode"></md2-mob-stand-info> <md2-mob-stand-info [mob]="mob" [mode]="mode"></md2-mob-stand-info>
<div *ngIf="activeSkill">
<div class="alert alert-warning" role="alert">
<h4>{{activeSkill.name}}</h4>
<div [innerHtml]="activeSkill.description"></div>
</div>
</div>
</div> </div>
<div class="col-md-5"> <div class="col-md-5">
<md2-mob-detail-info [mob]="mob" [mode]="mode"> <md2-mob-detail-info [mob]="mob" [mode]="mode">
</md2-mob-detail-info> </md2-mob-detail-info>
<div *ngIf="actionInfoHtml">
<div class="alert alert-warning" role="alert" [innerHtml]="actionInfoHtml">
</div>
</div>
<ng-container *ngIf="mode==MobDlgType.Spawn&&mob.type==MobType.Mob"> <ng-container *ngIf="mode==MobDlgType.Spawn&&mob.type==MobType.Mob">
<div class="row form-group mt-2"> <div class="row form-group mt-2">

View File

@ -1,7 +1,7 @@
import { ChangeDetectorRef, Component, OnInit } from '@angular/core'; import { ChangeDetectorRef, Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router'; import { ActivatedRoute } from '@angular/router';
import { NbDialogRef } from '@nebular/theme'; import { NbDialogRef } from '@nebular/theme';
import { first } from 'rxjs/operators'; import { concatMap, find, defaultIfEmpty, first, map, switchMap } from 'rxjs/operators';
import { FileService } from '../../../../services/file.service'; import { FileService } from '../../../../services/file.service';
import { MD2Service } from '../../../../services/MD2/md2.service'; import { MD2Service } from '../../../../services/MD2/md2.service';
import { MsgBoxService } from '../../../../services/msg-box.service'; import { MsgBoxService } from '../../../../services/msg-box.service';
@ -9,6 +9,12 @@ import { StateService } from '../../../../services/state.service';
import { StringUtils } from '../../../../utilities/string-utils'; import { StringUtils } from '../../../../utilities/string-utils';
import { AttackInfo, AttackTarget, AttackType, MD2HeroInfo, MD2Icon, MobDlgType, MobInfo, MobType } from '../../massive-darkness2.model'; import { AttackInfo, AttackTarget, AttackType, MD2HeroInfo, MD2Icon, MobDlgType, MobInfo, MobType } from '../../massive-darkness2.model';
import { MD2ComponentBase } from '../../MD2Base'; import { MD2ComponentBase } from '../../MD2Base';
import { ADButtons, ADIcon } from '../../../../ui/alert-dlg/alert-dlg.model';
import { MobSkillType } from '../../massive-darkness2.model.boss';
import { Observable, from, of } from 'rxjs';
import { MD2MobSkill } from '../../massive-darkness2.db.model';
type SkillResolutionResult = { result: boolean; skill: MD2MobSkill | null };
@Component({ @Component({
selector: 'ngx-spawn-mob-dlg', selector: 'ngx-spawn-mob-dlg',
@ -38,16 +44,34 @@ export class SpawnMobDlgComponent extends MD2ComponentBase implements OnInit {
) { ) {
super(md2Service, stateService, route, cdRef); super(md2Service, stateService, route, cdRef);
} }
activeSkill: MD2MobSkill = null;;
ngOnInit(): void { ngOnInit(): void {
//this.mob = new MobInfo(this.mob); //this.mob = new MobInfo(this.mob);
if (this.mode == MobDlgType.Spawn && this.mob.type == MobType.Mob) { if (this.mode == MobDlgType.Spawn && this.mob.type == MobType.Mob) {
this.mob.attackInfos = [new AttackInfo(MD2Icon.Melee), new AttackInfo(MD2Icon.Range), new AttackInfo(MD2Icon.Magic)]; this.mob.attackInfos = [new AttackInfo(MD2Icon.Melee), new AttackInfo(MD2Icon.Range), new AttackInfo(MD2Icon.Magic)];
} else if (this.mode == MobDlgType.Activating) { } else if (this.mode == MobDlgType.Activating) {
if (this.mob.actionSubject) { if (this.mob.skills) {
this.mob.actionSubject.pipe(first()).subscribe(result => {
this.actionInfoHtml = result; //this.mobActivate(this.mob, this.md2Service.info.heros);
//this.mob.activateFunction(this.mob, this.md2Service.msgBoxService, this.md2Service.info.heros);
this.mobActivate(this.mob, this.md2Service.info.heros).pipe(first()).subscribe(result => {
if (result && result.skill) {
this.activeSkill = result.skill;
//this.actionInfoHtml = `<h4>${result.skill.name}</h4><div>${result.skill.description}</div>`;
}
if (this.mob.type == MobType.Mob) {
this.mob.actions = 2;
} else {
if (result && result.skill) {
this.mob.actions = 1;
} else {
this.mob.actions = 2;
this.activeSkill = { name: 'Normal Action', description: '${this.mob.name} Gains 2 Actions.' } as MD2MobSkill;
//this.actionInfoHtml = `${this.mob.name} Gains 2 Actions.`;
}
}
}); });
this.mob.activateFunction(this.mob, this.md2Service.msgBoxService, this.md2Service.info.heros);
} }
} }
this.mob.uiWounds = 0; this.mob.uiWounds = 0;
@ -55,6 +79,52 @@ export class SpawnMobDlgComponent extends MD2ComponentBase implements OnInit {
this.mob.uiFrozenTokens = 0; this.mob.uiFrozenTokens = 0;
this.initTitleHtml(); this.initTitleHtml();
} }
mobActivate(mob: MobInfo, heros: MD2HeroInfo[]): Observable<SkillResolutionResult> {
switch (mob.type) {
case MobType.Mob:
return of({ result: false, skill: null } as SkillResolutionResult);
case MobType.RoamingMonster:
if (!mob.skills || mob.skills.length === 0) {
return of({ result: false, skill: null } as SkillResolutionResult);
}
const orderedSkills = mob.skills
.filter(s => [MobSkillType.ConditionalSkill, MobSkillType.OtherWiseSkill].includes(s.type))
.sort((a, b) => (a.seq ?? Number.MAX_SAFE_INTEGER) - (b.seq ?? Number.MAX_SAFE_INTEGER));
if (orderedSkills.length === 0) {
return of({ result: false, skill: null } as SkillResolutionResult);
}
return from(orderedSkills).pipe(
concatMap(skill => this.resolveSkillPrompt(skill)),
find(resolution => resolution.result === true),
defaultIfEmpty({ result: false, skill: null } as SkillResolutionResult)
);
case MobType.Boss:
default:
return of({ result: false, skill: null } as SkillResolutionResult);
}
}
private resolveSkillPrompt(skill: MD2MobSkill): Observable<SkillResolutionResult> {
if (skill.type === MobSkillType.OtherWiseSkill) {
return of({ result: true, skill } as SkillResolutionResult);
}
const title = skill.name || 'Resolve Skill?';
const prompt = skill.skillCondition || skill.description || 'Resolve this skill?';
return this.msgBoxService.show(title, {
text: prompt,
icon: ADIcon.QUESTION,
buttons: ADButtons.YesNo
}).pipe(
map(answer => ({ result: !!answer, skill } as SkillResolutionResult))
);
}
submit() { submit() {
if (this.mode == MobDlgType.Spawn) { if (this.mode == MobDlgType.Spawn) {

View File

@ -1,6 +1,5 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { CoreGameRMFactories } from '../../games/massive-darkness2/factorys/roamingMonsters/CoreGame'; import { DrawingBag, MobInfo, MobType, TreasureItem, TreasureType } from '../../games/massive-darkness2/massive-darkness2.model';
import { DrawingBag, MobInfo, TreasureItem, TreasureType } from '../../games/massive-darkness2/massive-darkness2.model';
import { MD2StateService } from './md2-state.service'; import { MD2StateService } from './md2-state.service';
import { MD2MobInfoService } from '../../games/massive-darkness2/service/massive-darkness2.service'; import { MD2MobInfoService } from '../../games/massive-darkness2/service/massive-darkness2.service';
import { first } from 'rxjs/operators'; import { first } from 'rxjs/operators';
@ -19,20 +18,10 @@ export class MD2InitService {
this.stateService.mobDeck = new DrawingBag(); this.stateService.mobDeck = new DrawingBag();
this.stateService.roamingMobDeck = new DrawingBag(); this.stateService.roamingMobDeck = new DrawingBag();
this.initCoreGameMobs(); this.initCoreGameMobAndRoamingMonsters();
this.initCoreGameRoamingMonsters();
} }
private initCoreGameRoamingMonsters() { private initCoreGameMobAndRoamingMonsters() {
CoreGameRMFactories.forEach(factory => {
for (let i = 1; i <= 5; i++) {
this.stateService.roamingMobDeck.AddItem(new MobInfo({ name: factory.mobName, level: i, drawingWeight: 1 }));
i++;
}
});
}
private initCoreGameMobs() {
// CoreGameMobFactories.forEach(factory => { // CoreGameMobFactories.forEach(factory => {
// for (let i = 1; i <= 5; i++) { // for (let i = 1; i <= 5; i++) {
// this.stateService.mobDeck.AddItem(new MobInfo({ name: factory.mobName, level: i, drawingWeight: 1 })); // this.stateService.mobDeck.AddItem(new MobInfo({ name: factory.mobName, level: i, drawingWeight: 1 }));
@ -40,13 +29,20 @@ export class MD2InitService {
// } // }
// }); // });
this.mobInfoService.getAll().pipe(first()).subscribe(result => { this.mobInfoService.getAll().pipe(first()).subscribe(result => {
this.stateService.mobInfos = result; this.stateService.mobInfos = result.filter(m => m.type == MobType.Mob);
this.stateService.roamingMobInfos = result.filter(m => m.type == MobType.RoamingMonster);
for (let i = 0; i < result.length; i++) { for (let i = 0; i < result.length; i++) {
const mobInfo = result[i]; const mobInfo = result[i];
for (let j = 0; j < mobInfo.mobLevelInfos.length; j++) { for (let j = 0; j < mobInfo.mobLevelInfos.length; j++) {
const levelInfo = mobInfo.mobLevelInfos[j]; const levelInfo = mobInfo.mobLevelInfos[j];
switch (mobInfo.type) {
case MobType.Mob:
this.stateService.mobDeck.AddItem(new MobInfo({ name: mobInfo.name, level: levelInfo.level, drawingWeight: 1 })); this.stateService.mobDeck.AddItem(new MobInfo({ name: mobInfo.name, level: levelInfo.level, drawingWeight: 1 }));
break;
case MobType.RoamingMonster:
this.stateService.roamingMobDeck.AddItem(new MobInfo({ name: mobInfo.name, level: levelInfo.level, drawingWeight: 1 }));
break;
}
} }
} }

View File

@ -15,6 +15,7 @@ export class MD2StateService {
public info: MD2GameInfo; public info: MD2GameInfo;
public playerHero: MD2HeroInfo; public playerHero: MD2HeroInfo;
public mobInfos: MD2MobInfo[] = []; public mobInfos: MD2MobInfo[] = [];
public roamingMobInfos: MD2MobInfo[] = [];
public mobDeck: DrawingBag<MobInfo>; public mobDeck: DrawingBag<MobInfo>;
public roamingMobDeck: DrawingBag<MobInfo>; public roamingMobDeck: DrawingBag<MobInfo>;
public treasureBag: DrawingBag<TreasureItem> = new DrawingBag<TreasureItem>(); public treasureBag: DrawingBag<TreasureItem> = new DrawingBag<TreasureItem>();

View File

@ -15,11 +15,10 @@ import { SignalRService, SignalRSession, SignalRMessage } from '../signal-r.serv
import { MD2StateService } from './md2-state.service'; import { MD2StateService } from './md2-state.service';
import { MD2BroadcastService } from './md2-broadcast.service'; import { MD2BroadcastService } from './md2-broadcast.service';
import { MD2Logic } from '../../games/massive-darkness2/massive-darkness2.logic'; import { MD2Logic } from '../../games/massive-darkness2/massive-darkness2.logic';
import { CoreGameRMFactories } from '../../games/massive-darkness2/factorys/roamingMonsters/CoreGame';
import { MD2InitService } from './md2-init.service'; import { MD2InitService } from './md2-init.service';
import { ArrayUtils } from '../../utilities/array-utils'; import { ArrayUtils } from '../../utilities/array-utils';
import { DropDownOption } from '../../entity/dropDownOption'; import { DropDownOption } from '../../entity/dropDownOption';
import { GameBundle, MD2MobInfo } from '../../games/massive-darkness2/massive-darkness2.db.model'; import { GameBundle, MD2DiceSet, MD2MobInfo } from '../../games/massive-darkness2/massive-darkness2.db.model';
import { environment } from '../../../environments/environment'; import { environment } from '../../../environments/environment';
@ -51,6 +50,9 @@ export class MD2Service {
public get mobs() { public get mobs() {
return this.stateService.info.mobs; return this.stateService.info.mobs;
} }
public get allRoamingMonsterInfos() {
return this.stateService.roamingMobInfos;
}
public get allMobInfos() { public get allMobInfos() {
return this.stateService.mobInfos; return this.stateService.mobInfos;
} }
@ -184,13 +186,10 @@ export class MD2Service {
exitingMob.skills = newSpawnMob.skills; exitingMob.skills = newSpawnMob.skills;
} else { } else {
if (isRoamingMonster) { if (isRoamingMonster) {
newSpawnMob = CoreGameRMFactories.find(f => f.mobName == newSpawnMob.name).generate(level); newSpawnMob = this.generateMob(isRoamingMonster, newSpawnMob.name, level);
newSpawnMob.hp = newSpawnMob.hpPerHero * this.playerAmount;
newSpawnMob.unitRemainHp = newSpawnMob.hp;
newSpawnMob.mobAmount = 0;
this.roamingMonsters.push(newSpawnMob); this.roamingMonsters.push(newSpawnMob);
} else { } else {
newSpawnMob = this.generateMob(newSpawnMob.name, level); newSpawnMob = this.generateMob(isRoamingMonster, newSpawnMob.name, level);
this.mobs.push(newSpawnMob); this.mobs.push(newSpawnMob);
} }
@ -202,16 +201,12 @@ export class MD2Service {
return { exitingMob, mob: newSpawnMob }; return { exitingMob, mob: newSpawnMob };
} }
private generateMob(mobName: string, level: number) { private generateMob(isRoamingMonster: boolean, mobName: string, level: number) {
let dbMobInfo = this.allMobInfos.find(m => m.name == mobName); let dbMobInfo = isRoamingMonster ? this.allRoamingMonsterInfos.find(m => m.name == mobName) : this.allMobInfos.find(m => m.name == mobName);
let levelInfo = dbMobInfo.mobLevelInfos.find(l => l.level <= level); let levelInfo = dbMobInfo.mobLevelInfos.find(l => l.level <= level);
let skills = dbMobInfo.skills.filter(s => s.level <= level).sort((a, b) => b.level - a.level); let skills = dbMobInfo.skills.filter(s => s.level <= level).sort((a, b) => b.seq - a.seq);
//Distinct by SkillType and Skill Name, take the one with the highest level //Distinct by SkillType and Skill Name, take the one with the highest level
let mobInfo = new MobInfo({ let mobInfo = new MobInfo({
name: dbMobInfo.name, name: dbMobInfo.name,
hp: levelInfo.hpPerHero, hp: levelInfo.hpPerHero,
@ -219,6 +214,7 @@ export class MD2Service {
level: level, level: level,
rewardTokens: levelInfo.rewardTokens, rewardTokens: levelInfo.rewardTokens,
defenseInfo: levelInfo.defenceInfo, defenseInfo: levelInfo.defenceInfo,
type: dbMobInfo.type,
skills: [] skills: []
}); });
@ -229,18 +225,52 @@ export class MD2Service {
} }
} }
mobInfo.skills = mobInfo.skills.sort((a, b) => b.seq - a.seq); mobInfo.skills = mobInfo.skills.sort((a, b) => b.seq - a.seq);
switch (dbMobInfo.type) {
case MobType.Mob:
mobInfo.leaderImgUrl = mobInfo.leaderImgUrl || MD2_IMG_URL(`/${GameBundle[dbMobInfo.from]}/Mobs/${mobInfo.name}/Leader.png`); mobInfo.leaderImgUrl = mobInfo.leaderImgUrl || MD2_IMG_URL(`/${GameBundle[dbMobInfo.from]}/Mobs/${mobInfo.name}/Leader.png`);
mobInfo.minionImgUrl = mobInfo.minionImgUrl || MD2_IMG_URL(`/${GameBundle[dbMobInfo.from]}/Mobs/${mobInfo.name}/Minion.png`); mobInfo.minionImgUrl = mobInfo.minionImgUrl || MD2_IMG_URL(`/${GameBundle[dbMobInfo.from]}/Mobs/${mobInfo.name}/Minion.png`);
break;
case MobType.RoamingMonster:
mobInfo.leaderImgUrl = mobInfo.leaderImgUrl || MD2_IMG_URL(`/${GameBundle[dbMobInfo.from]}/RoamingMonsters/${mobInfo.name}/Stand.png`);
mobInfo.minionImgUrl = null;
break;
case MobType.Boss:
mobInfo.leaderImgUrl = mobInfo.leaderImgUrl || MD2_IMG_URL(`/Boss/${mobInfo.name}-Stand.png`);
mobInfo.minionImgUrl = null;
break;
default:
break;
}
mobInfo.fixedCarriedTreasure = []; mobInfo.fixedCarriedTreasure = [];
levelInfo.fixedRareTreasure > 0 && mobInfo.fixedCarriedTreasure.push(new TreasureItem(TreasureType.Rare, levelInfo.fixedRareTreasure)); levelInfo.fixedRareTreasure > 0 && mobInfo.fixedCarriedTreasure.push(new TreasureItem(TreasureType.Rare, levelInfo.fixedRareTreasure));
levelInfo.fixedEpicTreasure > 0 && mobInfo.fixedCarriedTreasure.push(new TreasureItem(TreasureType.Epic, levelInfo.fixedEpicTreasure)); levelInfo.fixedEpicTreasure > 0 && mobInfo.fixedCarriedTreasure.push(new TreasureItem(TreasureType.Epic, levelInfo.fixedEpicTreasure));
levelInfo.fixedLegendTreasure > 0 && mobInfo.fixedCarriedTreasure.push(new TreasureItem(TreasureType.Legendary, levelInfo.fixedLegendTreasure)); levelInfo.fixedLegendTreasure > 0 && mobInfo.fixedCarriedTreasure.push(new TreasureItem(TreasureType.Legendary, levelInfo.fixedLegendTreasure));
switch (dbMobInfo.type) {
case MobType.Mob:
//Maybe add more mobs later //Maybe add more mobs later
mobInfo.mobAmount = this.playerAmount + 1; mobInfo.mobAmount = this.playerAmount + 1;
break;
case MobType.RoamingMonster:
case MobType.Boss:
mobInfo.hp = levelInfo.hpPerHero * this.playerAmount;
mobInfo.unitRemainHp = mobInfo.hp;
mobInfo.mobAmount = 0;
mobInfo.attackInfos = [this.getAttackInfo(levelInfo.attackInfo)];
let altAttackInfo = levelInfo.alterAttackInfo;
if (altAttackInfo
&& (altAttackInfo.black > 0 || altAttackInfo.blue > 0 || altAttackInfo.green > 0 || altAttackInfo.orange > 0 || altAttackInfo.red > 0 || altAttackInfo.yellow > 0)
) {
mobInfo.attackInfos.push(this.getAttackInfo(altAttackInfo));
}
break;
}
return mobInfo; return mobInfo;
} }
private getAttackInfo(attackInfo: MD2DiceSet): AttackInfo {
return new AttackInfo(attackInfo.type as unknown as MD2Icon, attackInfo.yellow, attackInfo.orange, attackInfo.red, attackInfo.black);
}
public enemyPhase() { public enemyPhase() {
//this.msgBoxService //this.msgBoxService
this.enemyPhaseMobs = this.roamingMonsters.concat(this.mobs); this.enemyPhaseMobs = this.roamingMonsters.concat(this.mobs);