Giter Site home page Giter Site logo

nerdland's Introduction

NerdLand

This is yet (boring) another attempt to have constructive fun with Haskell.

In this pet project I use a turn-based strategy "with a twist": after waiting 3 seconds for user input, the code gives up and moves on with the game loop. See my other project, https://github.com/miladhub/rpgfun, for another pet example demonstrating the two extreme approaches (pure turn or pure concurrent event-based).

The game logic is decoupled from intrastructure, Hexagonal architecture style, by using a Monad that is bound to IO in the real game and to a mocked instance in the tests.

Running the game

stack build
stack exec nerdland-exe

Developing

Just open the REPL via stack ghci or use https://github.com/ndmitchell/ghcid:

ghcid -c "stack ghci --main-is nerdland:exe:nerdland-exe"

Testing

Same, expect now the main belong to the tests:

stack ghci --main-is nerdland:nerdland-test

ghcid -c "stack ghci --main-is nerdland:nerdland-test"

Running the tests

Easy way:

stack test

In REPL:

stack ghci --main-is nerdland:nerdland-test
...
λ> main

Game
  stop after quit command
  does not log player actions
  logs when npcs become visible
  logs when npcs are out of sight
Events
  should alert when ogre is in sight

Finished in 0.0019 seconds
5 examples, 0 failures

TODO

  • Draw current area - e.g., grid
  • Make moving switch between areas - e.g., rooms
  • Define spawn events that add NPCs to the world
  • Make random event have effects such as damage to life attribute
  • Define spawn events that add NPCs to the world
  • Add items such as more/less powerful weapons
  • Add levels
  • Add pre-defined behaviours such as "ogre", "wolf", etc, that determine basic interaction patterns - e.g., attacks, ignores, etc (I'm thinking of using records such as data Behaviour = { attacks :: Distance -> Bool, ... })
  • Make quests depend on other quests
  • Allow defining quests from a DSL - e.g., parse them from a text file (could use parsec for this)

nerdland's People

Contributors

miladhub avatar

Stargazers

Valerio Marzulli avatar

Watchers

James Cloos avatar  avatar Valerio Marzulli avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.