node.js - MEAN-stack, organize structure for game logic -


i’m trying make simple card game (like hearthstone) using mean stack , socket.io game process.

but have no idea how better organize structure of server-side.

i have following structure:

  • server/
    • models/ (database schema models)
      • player.js
      • card.js
      • deck.js
    • controllers/
      • player.js
      • card.js
      • deck.js
    • routes/ (rest api)
      • player.js
      • card.js
      • deck.js
  • server.js (main)

here has implemented manipulation players', cards' , decks' data using http-requests.

but can't understand, have realize logic of game. have following questions:

  1. where should implement game logic player , cards, example, actions occur when 1 card attacking another?
  2. where should implement main part of game logic, includes player interaction (using socket.io), change of game state , on?

upd: or (and) share github projects.

thank , sorry english.

  1. you have implement logic in controllers. after action in front-end perform call server-side routes call function in controller have write logic.

  2. for general logic of game can create "core" module.


Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -