-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
755 additions
and
163 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,93 +1,106 @@ | ||
// import { BuildQueueAccesor } from '../build-queue/build-queue' | ||
// import { copyMapArrange, MapArrange, MapArrangeData, offsetMapArrange } from '../map-arrange/map-arrange' | ||
// import { Rect } from '../util/geometry' | ||
// import { ObjectEntriesT } from '../util/modify-prototypes' | ||
// import { assert } from '../util/util' | ||
// | ||
// export {} | ||
// declare global { | ||
// namespace sc { | ||
// namespace AreaLoadable { | ||
// interface Data { | ||
// shaduungeonCustom?: boolean | ||
// } | ||
// /* SD - ShaDuungeon */ | ||
// namespace SDCustom { | ||
// // @ts-expect-error | ||
// interface Data extends sc.AreaLoadable.Data { | ||
// shaduungeonCustom: true | ||
// floors: Floor[] | ||
// } | ||
// interface Floor { | ||
// level: number | ||
// name: ig.LangLabel.Data | ||
// | ||
// maps: Map[] | ||
// connections: Connection[] | ||
// icons: Icon[] | ||
// landmarks: Landmark[] | ||
// rooms?: sc.AreaRoomBounds[] | ||
// } | ||
// interface Map extends sc.AreaLoadable.Map {} | ||
// } | ||
// } | ||
// } | ||
// } | ||
// | ||
// export function createAreaJsonFromBuildQueue( | ||
// accesor: BuildQueueAccesor<MapArrangeData>, | ||
// areaName: string, | ||
// defaultFloor: number, | ||
// chests: number, | ||
// floorNames: Record<number, ig.LangLabel.Data>, | ||
// ): sc.AreaLoadable.SDCustom.Data { | ||
// const maps: MapArrange[] = [] | ||
// for (let id = 0; ; id++) { | ||
// const res = accesor.tryGet(id) | ||
// if (!res) break | ||
// maps.push(copyMapArrange(res)) | ||
// } | ||
// | ||
// const bounds: Rect = Rect.boundsOfArr(maps.flatMap(a => a.rects)) | ||
// const offset = Vec2.mulC(bounds, -1) | ||
// for (const map of maps) offsetMapArrange(map, offset) | ||
// | ||
// const mapsByFloor: Record<number, MapArrange[]> = {} | ||
// for (const map of maps) { | ||
// ;(mapsByFloor[map.floor ?? 0] ??= []).push(map) | ||
// } | ||
// | ||
// const floors: sc.AreaLoadable.SDCustom.Floor[] = [] | ||
// let actualDefaultFloor!: number | ||
// for (const [floor, maps] of ObjectEntriesT(mapsByFloor)) { | ||
// if (floor == defaultFloor) actualDefaultFloor = floors.length | ||
// | ||
// const areaMaps: sc.AreaLoadable.SDCustom.Map[] = maps.map(map => { | ||
// return map as any | ||
// }) | ||
// | ||
// const name = floorNames[floor] | ||
// assert(name) | ||
// floors.push({ | ||
// level: floor, | ||
// name, | ||
// | ||
// maps: areaMaps, | ||
// connections: [], | ||
// icons: [], | ||
// landmarks: [], | ||
// }) | ||
// } | ||
// | ||
// assert(actualDefaultFloor) | ||
// return { | ||
// DOCTYPE: 'AREAS_MAP', | ||
// shaduungeonCustom: true, | ||
// name: areaName, | ||
// width: bounds.width, | ||
// height: bounds.height, | ||
// defaultFloor: actualDefaultFloor, | ||
// chests, | ||
// floors, | ||
// } | ||
// } | ||
import { unique } from 'jquery' | ||
import { AreaInfo, MapConstruct } from '../map-construct/map-construct' | ||
import { Rect } from '../util/geometry' | ||
import { ObjectEntriesT } from '../util/modify-prototypes' | ||
import { allLangs, Array2d, assert } from '../util/util' | ||
|
||
export {} | ||
declare global { | ||
namespace sc { | ||
namespace AreaLoadable { | ||
interface Data { | ||
shaduungeonCustom?: boolean | ||
} | ||
/* SD - ShaDuungeon */ | ||
namespace SDCustom { | ||
// @ts-expect-error | ||
interface Data extends sc.AreaLoadable.Data { | ||
shaduungeonCustom: true | ||
floors: Floor[] | ||
} | ||
interface Floor { | ||
level: number | ||
name: ig.LangLabel.Data | ||
|
||
maps: Map[] | ||
connections: Connection[] | ||
icons: Icon[] | ||
landmarks: Landmark[] | ||
rooms?: sc.AreaRoomBounds[] | ||
} | ||
interface Map extends sc.AreaLoadable.Map {} | ||
} | ||
} | ||
} | ||
} | ||
|
||
export function createArea( | ||
maps: MapConstruct[], | ||
areaInfo: AreaInfo, | ||
defaultFloor: number, | ||
chests: number, | ||
floorNames: Record<number, ig.LangLabel.Data> | ||
): sc.AreaLoadable.SDCustom.Data { | ||
const { width, height }: Rect = Rect.boundsOfArr(maps.flatMap(a => a.rects)) | ||
|
||
const mapsByFloor: Record<number, MapConstruct[]> = {} | ||
for (const map of maps) { | ||
;(mapsByFloor[map.floor ?? 0] ??= []).push(map) | ||
} | ||
|
||
const floors: sc.AreaLoadable.SDCustom.Floor[] = [] | ||
let actualDefaultFloor!: number | ||
for (const [floor, maps] of ObjectEntriesT(mapsByFloor)) { | ||
if (floor == defaultFloor) actualDefaultFloor = floors.length | ||
|
||
const areaMaps: sc.AreaLoadable.SDCustom.Map[] = maps.map(map => { | ||
return { | ||
path: map.constructed.name, | ||
name: allLangs(map.title), | ||
offset: { x: 0, y: 0 }, | ||
dungeon: 'DUNGEON', | ||
} | ||
}) | ||
|
||
const name = floorNames[floor] | ||
assert(name) | ||
floors.push({ | ||
level: floor, | ||
name, | ||
tiles: Array2d.empty({ x: width, y: height }, 0), | ||
|
||
maps: areaMaps, | ||
connections: [], | ||
icons: [], | ||
landmarks: [], | ||
}) | ||
} | ||
|
||
assert(actualDefaultFloor !== undefined) | ||
return { | ||
DOCTYPE: 'AREAS_MAP', | ||
shaduungeonCustom: true, | ||
name: areaInfo.id, | ||
width, | ||
height, | ||
defaultFloor: actualDefaultFloor, | ||
chests, | ||
floors, | ||
} | ||
} | ||
|
||
export function createAreaDbEntry(area: sc.AreaLoadable.SDCustom.Data, areaInfo: AreaInfo): sc.MapModel.Area { | ||
return { | ||
boosterItem: areaInfo.boosterItem.toString(), | ||
landmarks: {}, | ||
name: allLangs(areaInfo.title), | ||
description: allLangs(areaInfo.description), | ||
keyItem: areaInfo.keyItem.toString(), | ||
masterKeyItem: areaInfo.masterKeyItem.toString(), | ||
areaType: areaInfo.type, | ||
order: 1001, | ||
track: true, | ||
chests: area.chests, | ||
position: areaInfo.pos, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,12 @@ | ||
import './setup-test' | ||
|
||
import { DungeonBuilder } from './dungeon/builder' | ||
const b = new DungeonBuilder() | ||
b.build('das') | ||
import { initLibraries } from './library-providers' | ||
;(async () => { | ||
await initLibraries() | ||
|
||
const b = new DungeonBuilder() | ||
b.build('das') | ||
})() | ||
// const b = new Test_DungeonBuilder() | ||
// b.samePlaceFail() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.