Fix resources to level task
This commit is contained in:
parent
abb41dc86c
commit
822c4dc0ab
@ -22,7 +22,7 @@ export class UpgradeResourceToLevel extends ActionController {
|
|||||||
|
|
||||||
const requiredLevel = getNumber(args.level);
|
const requiredLevel = getNumber(args.level);
|
||||||
|
|
||||||
const notUpgraded = deposits.filter(dep => requiredLevel > dep.level);
|
const notUpgraded = deposits.filter(dep => !dep.underConstruction && requiredLevel > dep.level);
|
||||||
|
|
||||||
if (notUpgraded.length === 0) {
|
if (notUpgraded.length === 0) {
|
||||||
this.scheduler.removeTask(task.id);
|
this.scheduler.removeTask(task.id);
|
||||||
|
@ -7,15 +7,10 @@ export class BuildingQueueInfo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ResourceDeposit {
|
export interface ResourceDeposit {
|
||||||
readonly buildId: number;
|
readonly buildId: number;
|
||||||
readonly type: ResourceType;
|
readonly type: ResourceType;
|
||||||
readonly level: number;
|
readonly level: number;
|
||||||
readonly ready: boolean;
|
readonly ready: boolean;
|
||||||
constructor(buildId: number, type: ResourceType, level: number, ready: boolean) {
|
readonly underConstruction: boolean;
|
||||||
this.buildId = buildId;
|
|
||||||
this.type = type;
|
|
||||||
this.level = level;
|
|
||||||
this.ready = ready;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -60,11 +60,13 @@ export function onResourceSlotCtrlClick(cb: (buildId: number) => void): void {
|
|||||||
function slotToDepositMapper(slot: Slot): ResourceDeposit {
|
function slotToDepositMapper(slot: Slot): ResourceDeposit {
|
||||||
const el = slot.el;
|
const el = slot.el;
|
||||||
const classes = jQuery(el).attr('class');
|
const classes = jQuery(el).attr('class');
|
||||||
const buildId = getNumber(elClassId(classes, 'buildingSlot'));
|
return {
|
||||||
const level = getNumber(elClassId(classes, 'level'));
|
buildId: getNumber(elClassId(classes, 'buildingSlot')),
|
||||||
const type = getNumber(elClassId(classes, 'gid'));
|
type: numberToResourceType(getNumber(elClassId(classes, 'gid'))),
|
||||||
const ready = !jQuery(el).hasClass('notNow');
|
level: getNumber(elClassId(classes, 'level')),
|
||||||
return new ResourceDeposit(buildId, numberToResourceType(type), level, ready);
|
ready: !jQuery(el).hasClass('notNow'),
|
||||||
|
underConstruction: jQuery(el).hasClass('underConstruction'),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function grabResourceDeposits(): Array<ResourceDeposit> {
|
export function grabResourceDeposits(): Array<ResourceDeposit> {
|
||||||
|
Loading…
Reference in New Issue
Block a user