Compare commits
2 Commits
73e2ccdcb8
...
249a48807a
| Author | SHA1 | Date | |
|---|---|---|---|
|
249a48807a
|
|||
|
be405887e2
|
@@ -114,7 +114,7 @@ class TurtleCtl extends CLIAppBase {
|
|||||||
|
|
||||||
registerAsyncSubcommand("tunnel", (args) -> {
|
registerAsyncSubcommand("tunnel", (args) -> {
|
||||||
var len = args.getInt("length");
|
var len = args.getInt("length");
|
||||||
return asynPerform(Helper.combine.bind([Turtle.dig.bind(Front), Turtle.forward, Turtle.dig.bind(Up)]), len);
|
return asynPerform(Helper.combine.bind([Turtle.digEmpty.bind(Front), Turtle.forward, Turtle.digEmpty.bind(Up)]), len);
|
||||||
}, [Int("length")]);
|
}, [Int("length")]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -72,6 +72,11 @@ class Turtle {
|
|||||||
return r2;
|
return r2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Dig in the provided direction.
|
||||||
|
Keep in mind that digging on a empty space is considerd a failure.
|
||||||
|
Also see `digEmpty`.
|
||||||
|
**/
|
||||||
public static function dig(dir:InteractDirections, ?toolSide:ToolSide):Outcome<Noise, String> {
|
public static function dig(dir:InteractDirections, ?toolSide:ToolSide):Outcome<Noise, String> {
|
||||||
var r:cc.Turtle.TurtleActionResult;
|
var r:cc.Turtle.TurtleActionResult;
|
||||||
|
|
||||||
@@ -87,6 +92,36 @@ class Turtle {
|
|||||||
return conterToOutcome(r);
|
return conterToOutcome(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Dig in the provided direction.
|
||||||
|
Does not fail if there is nothing to dig.
|
||||||
|
Also see `dig`.
|
||||||
|
**/
|
||||||
|
public static function digEmpty(dir:InteractDirections, ?toolSide:ToolSide):Outcome<Noise, String> {
|
||||||
|
var r:cc.Turtle.TurtleActionResult;
|
||||||
|
|
||||||
|
// FIXME: upstream needs to be fixed to accept ToolSide
|
||||||
|
switch dir {
|
||||||
|
case Front:
|
||||||
|
r = cc.Turtle.dig();
|
||||||
|
case Up:
|
||||||
|
r = cc.Turtle.digUp();
|
||||||
|
case Down:
|
||||||
|
r = cc.Turtle.digDown();
|
||||||
|
}
|
||||||
|
var result = conterToOutcome(r);
|
||||||
|
|
||||||
|
switch (result) {
|
||||||
|
case Success(_):
|
||||||
|
return result;
|
||||||
|
case Failure(failure):
|
||||||
|
if (failure == "Nothing to dig here") {
|
||||||
|
return Success(null);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static function place(dir:InteractDirections):Outcome<Noise, String> {
|
public static function place(dir:InteractDirections):Outcome<Noise, String> {
|
||||||
var r:cc.Turtle.TurtleActionResult;
|
var r:cc.Turtle.TurtleActionResult;
|
||||||
switch dir {
|
switch dir {
|
||||||
|
|||||||
Reference in New Issue
Block a user