mirror of
				https://github.com/unanmed/HumanBreak.git
				synced 2025-10-31 04:02:59 +08:00 
			
		
		
		
	Merge branch 'dev' of https://github.com/unanmed/HumanBreak into dev
This commit is contained in:
		
						commit
						156869b5f4
					
				| @ -3,6 +3,7 @@ | |||||||
|     "dependencies": { |     "dependencies": { | ||||||
|         "@motajs/legacy-common": "workspace:*", |         "@motajs/legacy-common": "workspace:*", | ||||||
|         "@user/data-state": "workspace:*", |         "@user/data-state": "workspace:*", | ||||||
|         "@user/data-base": "workspace:*" |         "@user/data-base": "workspace:*", | ||||||
|  |         "@user/data-utils": "workspace:*" | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  | |||||||
| @ -1,12 +1,11 @@ | |||||||
| import { | import { | ||||||
|     DamageEnemy, |     DamageEnemy, | ||||||
|     ensureFloorDamage, |     ensureFloorDamage, | ||||||
|     getSingleEnemy, |  | ||||||
|     getEnemy, |     getEnemy, | ||||||
|     HeroSkill, |     HeroSkill, | ||||||
|     NightSpecial |     NightSpecial | ||||||
| } from '@user/data-state'; | } from '@user/data-state'; | ||||||
| import { hook, loading } from '@user/data-base'; | import { hook } from '@user/data-base'; | ||||||
| import { Patch, PatchClass } from '@motajs/legacy-common'; | import { Patch, PatchClass } from '@motajs/legacy-common'; | ||||||
| import { isNil } from 'lodash-es'; | import { isNil } from 'lodash-es'; | ||||||
| 
 | 
 | ||||||
| @ -47,7 +46,7 @@ export function patchBattle() { | |||||||
|             ); |             ); | ||||||
|         } |         } | ||||||
|         // 非强制战斗
 |         // 非强制战斗
 | ||||||
|         // @ts-ignore
 |         // @ts-expect-error 2.c 重构
 | ||||||
|         if (!core.canBattle(x, y) && !force && !core.status.event.id) { |         if (!core.canBattle(x, y) && !force && !core.status.event.id) { | ||||||
|             core.stopSound(); |             core.stopSound(); | ||||||
|             core.playSound('操作失败'); |             core.playSound('操作失败'); | ||||||
| @ -116,7 +115,7 @@ export function patchBattle() { | |||||||
|             core.clearContinueAutomaticRoute(); |             core.clearContinueAutomaticRoute(); | ||||||
| 
 | 
 | ||||||
|             // 自动存档
 |             // 自动存档
 | ||||||
|             var inAction = core.status.event.id == 'action'; |             const inAction = core.status.event.id === 'action'; | ||||||
|             if (inAction) { |             if (inAction) { | ||||||
|                 core.insertAction(beforeBattle, data.x, data.y); |                 core.insertAction(beforeBattle, data.x, data.y); | ||||||
|                 core.doAction(); |                 core.doAction(); | ||||||
| @ -131,7 +130,7 @@ export function patchBattle() { | |||||||
| 
 | 
 | ||||||
|     patch2.add('_action_battle', function (data, x, y, prefix) { |     patch2.add('_action_battle', function (data, x, y, prefix) { | ||||||
|         if (data.id) { |         if (data.id) { | ||||||
|             const enemy = getSingleEnemy(data.id as EnemyIds); |             // const enemy = getSingleEnemy(data.id as EnemyIds);
 | ||||||
|             // todo: 与不在地图上的怪物战斗
 |             // todo: 与不在地图上的怪物战斗
 | ||||||
|         } else { |         } else { | ||||||
|             if (data.floorId != core.status.floorId) { |             if (data.floorId != core.status.floorId) { | ||||||
| @ -256,7 +255,6 @@ export function patchBattle() { | |||||||
|         } |         } | ||||||
|     ); |     ); | ||||||
| } | } | ||||||
| loading.once('coreInit', patchBattle); |  | ||||||
| 
 | 
 | ||||||
| declare global { | declare global { | ||||||
|     interface Enemys { |     interface Enemys { | ||||||
|  | |||||||
| @ -1,43 +1,49 @@ | |||||||
|  | import { Patch, PatchClass } from '@motajs/legacy-common'; | ||||||
| import { EnemyCollection, ensureFloorDamage } from '@user/data-state'; | import { EnemyCollection, ensureFloorDamage } from '@user/data-state'; | ||||||
| import { formatDamage } from '@user/data-utils'; | import { formatDamage } from '@user/data-utils'; | ||||||
| 
 | 
 | ||||||
| export function init() { | export function patchDamage() { | ||||||
|     core.control.updateDamage = function ( |     const patch = new Patch(PatchClass.Control); | ||||||
|         floorId = core.status.floorId, |     patch.add( | ||||||
|         ctx, |         'updateDamage', | ||||||
|         thumbnail: boolean = false |         function ( | ||||||
|     ) { |             floorId = core.status.floorId, | ||||||
|         if (!floorId || core.status.gameOver || main.mode !== 'play') return; |             ctx, | ||||||
|         const onMap = ctx == null; |             thumbnail: boolean = false | ||||||
|         const floor = core.status.maps[floorId]; |         ) { | ||||||
|  |             if (!floorId || core.status.gameOver || main.mode !== 'play') | ||||||
|  |                 return; | ||||||
|  |             const onMap = ctx == null; | ||||||
|  |             const floor = core.status.maps[floorId]; | ||||||
| 
 | 
 | ||||||
|         // 没有怪物手册
 |             // 没有怪物手册
 | ||||||
|         // if (!core.hasItem('book')) return;
 |             // if (!core.hasItem('book')) return;
 | ||||||
|         core.status.damage.posX = core.bigmap.posX; |             core.status.damage.posX = core.bigmap.posX; | ||||||
|         core.status.damage.posY = core.bigmap.posY; |             core.status.damage.posY = core.bigmap.posY; | ||||||
|         if (!onMap) { |             if (!onMap) { | ||||||
|             const width = core.floors[floorId].width, |                 const width = core.floors[floorId].width, | ||||||
|                 height = core.floors[floorId].height; |                     height = core.floors[floorId].height; | ||||||
|             // 地图过大的缩略图不绘制显伤
 |                 // 地图过大的缩略图不绘制显伤
 | ||||||
|             if (width * height > core.bigmap.threshold) return; |                 if (width * height > core.bigmap.threshold) return; | ||||||
|  |             } | ||||||
|  |             // 计算伤害
 | ||||||
|  |             ensureFloorDamage(floorId); | ||||||
|  | 
 | ||||||
|  |             floor.enemy.extract(); | ||||||
|  |             floor.enemy.calRealAttribute(); | ||||||
|  |             floor.enemy.calMapDamage(); | ||||||
|  |             floor.enemy.emit('calculated'); | ||||||
|  |             core.status.damage.data = []; | ||||||
|  | 
 | ||||||
|  |             // floor.enemy.render(true);
 | ||||||
|  | 
 | ||||||
|  |             // getItemDetail(floorId, onMap); // 宝石血瓶详细信息
 | ||||||
|  |             if (thumbnail) { | ||||||
|  |                 renderThumbnailDamage(floor.enemy); | ||||||
|  |                 core.control.drawDamage(ctx, floorId); | ||||||
|  |             } | ||||||
|         } |         } | ||||||
|         // 计算伤害
 |     ); | ||||||
|         ensureFloorDamage(floorId); |  | ||||||
| 
 |  | ||||||
|         floor.enemy.extract(); |  | ||||||
|         floor.enemy.calRealAttribute(); |  | ||||||
|         floor.enemy.calMapDamage(); |  | ||||||
|         floor.enemy.emit('calculated'); |  | ||||||
|         core.status.damage.data = []; |  | ||||||
| 
 |  | ||||||
|         // floor.enemy.render(true);
 |  | ||||||
| 
 |  | ||||||
|         // getItemDetail(floorId, onMap); // 宝石血瓶详细信息
 |  | ||||||
|         if (thumbnail) { |  | ||||||
|             renderThumbnailDamage(floor.enemy); |  | ||||||
|             this.drawDamage(ctx, floorId); |  | ||||||
|         } |  | ||||||
|     }; |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| function renderThumbnailDamage(col: EnemyCollection) { | function renderThumbnailDamage(col: EnemyCollection) { | ||||||
| @ -1,5 +1,7 @@ | |||||||
| import { patchBattle } from './battle'; | import { patchBattle } from './battle'; | ||||||
|  | import { patchDamage } from './damage'; | ||||||
| 
 | 
 | ||||||
| export function patchAll() { | export function patchAll() { | ||||||
|     patchBattle(); |     patchBattle(); | ||||||
|  |     patchDamage(); | ||||||
| } | } | ||||||
|  | |||||||
| @ -1,5 +0,0 @@ | |||||||
| import { init as initItemDetail } from './itemDetail'; |  | ||||||
| 
 |  | ||||||
| initItemDetail(); |  | ||||||
| 
 |  | ||||||
| export * from './itemDetail'; |  | ||||||
							
								
								
									
										3
									
								
								packages-user/types/package.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								packages-user/types/package.json
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,3 @@ | |||||||
|  | { | ||||||
|  |     "name": "@user/types" | ||||||
|  | } | ||||||
							
								
								
									
										85
									
								
								packages-user/types/src/enemy.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										85
									
								
								packages-user/types/src/enemy.ts
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,85 @@ | |||||||
|  | export interface IEnemyInfo {} | ||||||
|  | 
 | ||||||
|  | export interface IDamageInfo {} | ||||||
|  | 
 | ||||||
|  | export interface IDamageEnemy { | ||||||
|  |     /** 原始怪物信息 */ | ||||||
|  |     readonly enemy: Enemy; | ||||||
|  |     /** 该怪物所属的怪物列表 */ | ||||||
|  |     readonly collection: IEnemyCollection | null; | ||||||
|  |     /** 怪物横坐标 */ | ||||||
|  |     readonly x: number | undefined; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * 获取怪物属性信息 | ||||||
|  |      */ | ||||||
|  |     getEnemyInfo(): IEnemyInfo; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * 获取这个怪物的伤害信息 | ||||||
|  |      */ | ||||||
|  |     getDamageInfo(): IDamageInfo; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | export interface IMapDamage { | ||||||
|  |     /** 伤害类型 */ | ||||||
|  |     readonly type: string; | ||||||
|  |     /** 伤害值 */ | ||||||
|  |     readonly damage: number; | ||||||
|  |     /** 伤害优先级 */ | ||||||
|  |     readonly priority: number; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | export interface IMapDamageSummary { | ||||||
|  |     /** 该点的总伤害 */ | ||||||
|  |     readonly totalDamage: number; | ||||||
|  |     /** 该点的伤害信息 */ | ||||||
|  |     readonly damages: IMapDamage[]; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | export interface IEnemyCollection { | ||||||
|  |     /** 怪物列表,索引为 x + width * y,值表示该点对应的怪物 */ | ||||||
|  |     readonly list: Map<number, IDamageEnemy>; | ||||||
|  | 
 | ||||||
|  |     /** 楼层 id */ | ||||||
|  |     readonly floorId: FloorIds; | ||||||
|  |     /** 楼层宽度 */ | ||||||
|  |     readonly width: number; | ||||||
|  |     /** 楼层高度 */ | ||||||
|  |     readonly height: number; | ||||||
|  | 
 | ||||||
|  |     /** 地图伤害 */ | ||||||
|  |     readonly mapDamage: Map<number, IMapDamageSummary>; | ||||||
|  | 
 | ||||||
|  |     /** 用于计算本怪物列表中怪物信息的勇士属性 */ | ||||||
|  |     readonly hero: HeroStatus; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * 获取一点的怪物信息,不存在时返回 null | ||||||
|  |      * @param x 怪物横坐标 | ||||||
|  |      * @param y 怪物纵坐标 | ||||||
|  |      */ | ||||||
|  |     getEnemy(x: number, y: number): IDamageEnemy | null; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * 获取一点的地图伤害信息,每一点都包含地图伤害对象,传入地图外坐标时返回 null | ||||||
|  |      * @param x 横坐标 | ||||||
|  |      * @param y 纵坐标 | ||||||
|  |      */ | ||||||
|  |     getMapDamage(x: number, y: number): IMapDamageSummary | null; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * 重置此地图的怪物信息,并重新计算 | ||||||
|  |      */ | ||||||
|  |     refresh(): void; | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |      * 复制这个怪物列表,同时将复制后的列表中勇士属性设为指定值 | ||||||
|  |      * @param status 新的勇士属性 | ||||||
|  |      */ | ||||||
|  |     with(status: HeroStatus): IEnemyCollection; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | export interface IDamageSystem { | ||||||
|  |     readonly collections: Map<FloorIds, IEnemyCollection>; | ||||||
|  | } | ||||||
							
								
								
									
										1
									
								
								packages-user/types/src/index.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								packages-user/types/src/index.ts
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1 @@ | |||||||
|  | export * from './enemy'; | ||||||
| @ -161,7 +161,7 @@ export class Logger { | |||||||
|             const n = Math.floor(code / 50) + 1; |             const n = Math.floor(code / 50) + 1; | ||||||
|             const n2 = code % 50; |             const n2 = code % 50; | ||||||
|             const url = `${location.origin}/_docs/logger/warn/warn${n}.html#warn-code-${n2}`; |             const url = `${location.origin}/_docs/logger/warn/warn${n}.html#warn-code-${n2}`; | ||||||
|             console.warn(`[WARNING Code ${code}] ${text}. See ${url}`); |             console.warn(`[WARNING Code ${code}] ${text} See ${url}`); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -118,9 +118,12 @@ export class Patch<T extends PatchClass> { | |||||||
|         const set = this.patched[patchClass]; |         const set = this.patched[patchClass]; | ||||||
|         const obj = this.getPatchClass(patchClass); |         const obj = this.getPatchClass(patchClass); | ||||||
|         for (const [key, func] of patch.patches) { |         for (const [key, func] of patch.patches) { | ||||||
|  |             // console.log(key);
 | ||||||
|  | 
 | ||||||
|             if (set.has(key)) { |             if (set.has(key)) { | ||||||
|                 logger.warn(49, patchName[patchClass], key); |                 logger.warn(49, patchName[patchClass], key); | ||||||
|             } |             } | ||||||
|  |             set.add(key); | ||||||
|             obj[key] = func; |             obj[key] = func; | ||||||
|         } |         } | ||||||
|         this.patchList.delete(patch); |         this.patchList.delete(patch); | ||||||
|  | |||||||
							
								
								
									
										1313
									
								
								pnpm-lock.yaml
									
									
									
									
									
								
							
							
						
						
									
										1313
									
								
								pnpm-lock.yaml
									
									
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
		Loading…
	
		Reference in New Issue
	
	Block a user
	 ShakeFlower
						ShakeFlower