fix rule match

add debug
This commit is contained in:
tony_all 2023-06-07 16:05:45 +08:00
parent 84baa309e3
commit 764ead46c2
1 changed files with 5 additions and 3 deletions

View File

@ -39,17 +39,19 @@ class GamePlaceBreakRule(val game: Game) {
game.map.teams.flatMap {
it.sides + it.mine
}.map {
it.containsBlock(loc)
it.containsBlock(loc).also { result -> debug("area $it contains $loc is $result") }
}.reduce { a, b -> a || b }
}
// allow enemy wall
addRule("allow_enemy_wall") { player, type, loc ->
val team = player.team ?: return@addRule false
val result = game.teams.filterNot { it == team }
val isWall = game.teams
.map { team.teamInfo.wall.containsBlock(loc) }
.reduce { a, b -> a || b }
if (type == BREAK) result else !result
if (!isWall) return@addRule false
val isHome = team.teamInfo.wall.containsBlock(loc)
(type == BREAK) xor isHome
}
}
}