refac: boostrap
This commit is contained in:
@@ -167,7 +167,6 @@ export class ResourceController implements IResourceController {
|
||||
}
|
||||
|
||||
resetAndFill(): Promise<void> {
|
||||
this._generalByTurnTime.clear();
|
||||
this.nationList.clear();
|
||||
this.cityList.clear();
|
||||
this.squadList.clear();
|
||||
@@ -186,16 +185,38 @@ export class ResourceController implements IResourceController {
|
||||
|
||||
|
||||
const generalIDByNation = new Map<NationID, GeneralID[]>();
|
||||
const generalIDByCity = new Map<CityID, GeneralID[]>();
|
||||
const generalIDListBySquad = new Map<SquadID, GeneralID[]>();
|
||||
for (const rawSquad of rawSquadList.values()) {
|
||||
generalIDListBySquad.set(rawSquad.id, []);
|
||||
}
|
||||
for (const rawGeneral of rawGeneralList.values()) {
|
||||
if (!rawGeneral.squadID) {
|
||||
continue;
|
||||
if (rawGeneral.squadID) {
|
||||
let list = generalIDListBySquad.get(rawGeneral.squadID);
|
||||
if (!list) {
|
||||
list = [];
|
||||
generalIDListBySquad.set(rawGeneral.squadID, list);
|
||||
}
|
||||
list.push(rawGeneral.id);
|
||||
}
|
||||
|
||||
{
|
||||
let list = generalIDByNation.get(rawGeneral.nationID);
|
||||
if (!list) {
|
||||
list = [];
|
||||
generalIDByNation.set(rawGeneral.nationID, list);
|
||||
}
|
||||
list.push(rawGeneral.id);
|
||||
}
|
||||
|
||||
{
|
||||
let list = generalIDByCity.get(rawGeneral.cityID);
|
||||
if (!list) {
|
||||
list = [];
|
||||
generalIDByCity.set(rawGeneral.cityID, list);
|
||||
}
|
||||
list.push(rawGeneral.id);
|
||||
}
|
||||
const list = must(generalIDListBySquad.get(rawGeneral.squadID));
|
||||
list.push(rawGeneral.id);
|
||||
}
|
||||
|
||||
const cityIDByNation = new Map<NationID, CityID[]>();
|
||||
@@ -214,9 +235,7 @@ export class ResourceController implements IResourceController {
|
||||
this._gameEnv.bootstrap();
|
||||
|
||||
for (const rawNation of rawNationList.values()) {
|
||||
const nation = new Nation(
|
||||
rawNation,
|
||||
this,
|
||||
const nation = new Nation(rawNation, this,
|
||||
{
|
||||
general: must(generalIDByNation.get(rawNation.id)),
|
||||
squad: squadIDByNation.get(rawNation.id) ?? [],
|
||||
@@ -226,7 +245,9 @@ export class ResourceController implements IResourceController {
|
||||
this.nationList.set(nation.id, nation);
|
||||
}
|
||||
for (const rawCity of rawCityList.values()) {
|
||||
const city = new City(rawCity, this);
|
||||
const city = new City(rawCity, this, {
|
||||
general: generalIDByCity.get(rawCity.id) ?? []
|
||||
});
|
||||
this.cityList.set(city.id, city);
|
||||
}
|
||||
for (const rawSquad of rawSquadList.values()) {
|
||||
@@ -247,6 +268,11 @@ export class ResourceController implements IResourceController {
|
||||
//iAction때문에 general의 lazyInit이 가장 마지막
|
||||
this.generalList.forEach(general => general.bootstrap());
|
||||
|
||||
//턴순서 정렬!
|
||||
const generalList = Array.from(this.generalList.values());
|
||||
generalList.sort((a, b) => a.compareTurnTime(b));
|
||||
this._generalByTurnTime = new Denque(generalList);
|
||||
|
||||
throw new NotYetImplemented();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user