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
- models/ (database schema models)
- 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:
- where should implement game logic player , cards, example, actions occur when 1 card attacking another?
- 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.
you have implement logic in controllers. after action in front-end perform call server-side routes call function in controller have write logic.
for general logic of game can create "core" module.
Comments
Post a Comment