Skip to content

Commit

Permalink
Made agentDestroy functions work faster
Browse files Browse the repository at this point in the history
  • Loading branch information
v-chyou authored Oct 9, 2019
1 parent e9e3746 commit fc19dcd
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ namespace hourOfCode {
//% block="agent destroy %dir"
//% weight=40
export function agentDestroyL4(dir: SixDirection) {
if (hourOfCode.agentDetectDeadBush(dir) || hourOfCode.agentDetectDryGrass(dir)) {
let targetBlock = agent.inspect(AgentInspection.Block, dir)
if (targetBlock == Block.DeadBush || targetBlock == Block.Sunflower) {
targetsL4 -= 1
}
agent.destroy(dir)
Expand All @@ -53,7 +54,8 @@ namespace hourOfCode {
//% block="agent destroy %dir"
//% weight=50
export function agentDestroyL5(dir: SixDirection) {
if (hourOfCode.agentDetectDeadBush(dir) || hourOfCode.agentDetectDryGrass(dir)) {
let targetBlock = agent.inspect(AgentInspection.Block, dir)
if (targetBlock == Block.DeadBush || targetBlock == Block.Sunflower) {
targetsL5 -= 1
}
agent.destroy(dir)
Expand All @@ -67,7 +69,8 @@ namespace hourOfCode {
//% block="agent destroy %dir"
//% weight=60
export function agentDestroyL6(dir: SixDirection) {
if (hourOfCode.agentDetectDeadBush(dir) || hourOfCode.agentDetectDryGrass(dir)) {
let targetBlock = agent.inspect(AgentInspection.Block, dir)
if (targetBlock == Block.DeadBush || targetBlock == Block.Sunflower) {
targetsL6 -= 1
}
agent.destroy(dir)
Expand Down

0 comments on commit fc19dcd

Please sign in to comment.