<commit_before>package ru.org.codingteam.keter.game.actions

import ru.org.codingteam.keter.game.GameState
import ru.org.codingteam.keter.game.objects.{Door, ObjectPosition, Actor}

case class MoveAction(override val actor: Actor, x: Int, y: Int) extends Action(actor) {

  override def process(state: GameState): GameState = {
    val map = state.map
    val position = actor.position
    val newX = position.x + x
    val newY = position.y + y
    val surface = map.surfaceAt(newX, newY)
    val topObject = map.firstObjectAt(newX, newY)
    lazy val cannotMove = state.copy(state.messages :+ "You cannot move this way")
    surface match {
      case None => cannotMove
      case Some(tile) if !tile.passable => cannotMove
      case Some(tile) => {
        val newObjects = map.objects
        topObject match {
          case None => {}
          case Some(door:Door) if (!door.open) => {
            val newDoor = door.copy(tile = door.openTile, open = true, passable = true)
            newObjects(newY)(newX) = newObjects(newY)(newX).updated(0, newDoor)
          }
        }
        val newActor = actor.copy(position = ObjectPosition(newX, newY))<commit_msg>Open door fix<commit_after>package ru.org.codingteam.keter.game.actions

import ru.org.codingteam.keter.game.GameState
import ru.org.codingteam.keter.game.objects.{Door, ObjectPosition, Actor}

case class MoveAction(override val actor: Actor, x: Int, y: Int) extends Action(actor) {

  override def process(state: GameState): GameState = {
    val map = state.map
    val position = actor.position
    val newX = position.x + x
    val newY = position.y + y
    val surface = map.surfaceAt(newX, newY)
    val topObject = map.firstObjectAt(newX, newY)
    lazy val cannotMove = state.copy(state.messages :+ "You cannot move this way")
    surface match {
      case None => cannotMove
      case Some(tile) if !tile.passable => cannotMove
      case Some(tile) => {
        val newObjects = map.objects
        topObject match {
          case None => {}
          case Some(door:Door) if (!door.open) => {
            val newDoor = door.copy(tile = door.openTile, open = true, passable = true)
            newObjects(newY)(newX) = newObjects(newY)(newX).updated(0, newDoor)
          }
          case Some(wtf:Any) => {}
        }
        val newActor = actor.copy(position = ObjectPosition(newX, newY))
{'fraction_non_alphanumeric': 0.11420143278550358, 'fraction_numerical': 0.0008428150021070375, 'mean_word_length': 2.8601626016260164, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4333626', 'n_tokens_mistral': 747, 'n_tokens_neox': 736, 'n_words': 195}