elm-warrior icon indicating copy to clipboard operation
elm-warrior copied to clipboard

Looking at a Warrior on a SpawnPoint reveals the SpawnPoint

Open sparksp opened this issue 4 years ago • 2 comments

If a NPC is standing on a SpawnPoint then tileAtPosition (and therefore look) will return a SpawnPoint not a Warrior. The same is true for a NPC on an Exit (I'm not sure if NPCs moving on to an Exit should leave the map or stay?). Items placed on SpawnPoints or Exits are also invisible.

Below is a test where I am placing an Item and a NPC on a SpawnPoint - I expect to see a Warrior but actually see a SpawnPoint. If I remove the SpawnPoint then I see the Warrior, and if I remove the Warrior too then I see the Item.

If this is a valid bug then I'm happy to write a PR, please can you confirm what you expect:

  • Can a NPC move to or spawn on a SpawnPoint?
  • Can an Item be placed on a SpawnPoint?
  • Can a NPC move to or spawn on an Exit?
  • Can an Item be placed on an Exit?

Expectation

Builder.init { rows = 1, columns = 5 }
    |> Builder.withSpawnPoint { x = 4, y = 0 }
    |> Builder.withItem { x = 4, y = 0 } Item.Potion
    |> Builder.withNpc "Dummy" { x = 4, y = 0 } Dummy.takeTurn
    |> Builder.build
    |> Map.tileAtPosition { x = 4, y = 0 }
    |> Expect.equal (Tile.Warrior "Dummy")

Failure

    SpawnPoint
    ╷
    │ Expect.equal
    ╵
    Warrior "Dummy"

Bonus Thoughts

I can envisage some alternative ProgressionFunctions where:

  • Multiple players work together to reach all exits on the map (rather than first player to reach one exit).
  • Player races a NPC to reach the exit.
  • Player races to the Exit before the NPC gets to the SpawnPoint.

sparksp avatar Jun 29 '20 08:06 sparksp

A follow up thought, if an Item can be placed on a non-empty Tile then perhaps lookDown should return a tuple of ( Maybe Item, Tile ) (e.g., ( Just Item.Potion, Tile.SpawnPoint ) and ( Nothing, Tile.Empty )).

sparksp avatar Jun 29 '20 12:06 sparksp

This is a very good question. Both Items and Warriors can exist on top of a SpawnPoint and Exit however, you should still be able to see the SpawnPoint or Exit if that's what's most important to your AI.

Not sure how to solve this though. I'm open for suggestions.

robinheghan avatar Aug 18 '20 16:08 robinheghan