-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
267 additions
and
65 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,35 +1,28 @@ | ||
import wollok.game.* | ||
import sokoban.* | ||
|
||
class Caja { | ||
var property position | ||
const property llegadas | ||
|
||
method movete(direccion) { | ||
self.validarLugarLibre(direccion) | ||
self.validarLugarLibre(direccion) | ||
position = direccion.siguiente(position) | ||
} | ||
|
||
method validarLugarLibre(direccion) { | ||
const posAlLado = direccion.siguiente(position) | ||
var lugarLibre = game.getObjectsIn(posAlLado) | ||
.all{ obj => obj.puedePisarte(self) } | ||
|
||
if (!lugarLibre) | ||
throw new Exception(message = "Algo traba la caja.") | ||
const posAlLado = direccion.siguiente(position) | ||
const lugarLibre = game.getObjectsIn(posAlLado).all( | ||
{ obj => obj.puedePisarte(self) } | ||
) | ||
if (!lugarLibre) { | ||
throw new DomainException(message = "Algo traba la caja.", source = sokoban) | ||
} | ||
} | ||
|
||
method puedePisarte(_) = false | ||
|
||
method image() { | ||
if (self.estaBienPosicionada()) | ||
return "caja_ok.png" | ||
|
||
return "caja.png" | ||
} | ||
|
||
method estaBienPosicionada() { | ||
return llegadas | ||
.map{ llegada => llegada.position() } | ||
.contains(self.position()) //TODO: Redefinir el (==) en Position! | ||
} | ||
} | ||
method image() = if (self.estaBienPosicionada()) "caja_ok.png" else "caja.png" | ||
|
||
method estaBienPosicionada() = llegadas.any({ llegada => llegada.position() == position }) | ||
} |
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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.