Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1.3 Release: add Tasks.chain(), add Tasks.withdrawAll, and fixes bugs
- Loading branch information
1 parent
7c49da6
commit e41540b
Showing
19 changed files
with
431 additions
and
124 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
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
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
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
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
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
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
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
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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import {Task} from '../Task'; | ||
|
||
|
||
export type withdrawAllTargetType = StructureStorage | StructureTerminal | StructureContainer | Tombstone; | ||
|
||
export class TaskWithdrawAll extends Task { | ||
|
||
static taskName = 'withdrawAll'; | ||
target: withdrawAllTargetType; | ||
|
||
constructor(target: withdrawAllTargetType, options = {} as TaskOptions) { | ||
super(TaskWithdrawAll.taskName, target, options); | ||
} | ||
|
||
isValidTask() { | ||
return (_.sum(this.creep.carry) < this.creep.carryCapacity); | ||
} | ||
|
||
isValidTarget() { | ||
return _.sum(this.target.store) > 0; | ||
} | ||
|
||
work() { | ||
for (let resourceType in this.target.store) { | ||
let amountInStore = this.target.store[<ResourceConstant>resourceType] || 0; | ||
if (amountInStore > 0) { | ||
return this.creep.withdraw(this.target, <ResourceConstant>resourceType); | ||
} | ||
} | ||
return -1; | ||
} | ||
} |
Oops, something went wrong.