game_01

module
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 10, 2018 License: AGPL-3.0

README

GAME_01

GAME_01 is a multi services scalable MMORPG server

GAME_01 is an UDP client/server with its own ACK protocol. Client writes user action and send them to API while receiving world data from sync. Core establish world rules and events order.

client <-> api -> core -> redis-lru
redis-lru -> sync -> client

Authentication and char creation/connect is handled by auth and associate a session token at each signin. Revoker regularly revokes unused tokens. GAME_01 also comes with a Tool API to create world data like entities/abilities/sectors.

Code architecture

 _bin #executables
|
|_cmd_ #executables code
|     |_api #UDP API for game events + ACK client
|     |_auth #HTTPS JSON API for signin/connect
|     |_client #client/server to communicate with API and JSON serialize
|     |_core #order and apply game events
|     |_revoker #revoke unused tokens
|     |_sync #send entity data to clients
|     |_tool #HTTPS JSON API for world data. Must be private.
|
|_configs #config files
|
|_docker #docker files
|
|_pkg_ #common code
|     |_ability #domain
|     |_account #domain
|     |_dto #external format input/output
|     |_entity #domain
|     |_event #domain
|     |_geometry #domain
|     |_infra #domain
|     |_mocks #domain mocks
|     |_sector #domain
|     |_storage #domain mapper implementations
|     |_ulid #domain
|     |_usecase #domain aggregations
|
|_templates #example template files for tool
|
|_vendor #vendoring packages (dep)

Installation

OS X & Linux & Windows:

go get -u github.com/elojah/game_01

Development setup

# Start services
docker-compose -d
make dep
make sync && bin/game_sync configs/config_sync.json
make core && bin/game_core configs/config_core.json
make api && bin/game_api configs/config_api.json
make auth && bin/game_auth configs/config_auth.json
make tool && bin/game_tool configs/config_tool.json

Usage example

# Fill static data
curl -k -X POST https://127.0.0.1:8081/entity/template -d @templates/entity_templates.json
curl -k -X POST https://127.0.0.1:8081/sector -d @templates/sector.json
curl -k -X POST https://127.0.0.1:8081/sector/starter -d @templates/sector_starter.json

# Obtain access token
curl -k -X POST https://127.0.0.1:8080/subscribe -d '{"username": "test", "password": "test"}'
curl -k -X POST https://127.0.0.1:8080/signin -d '{"username": "test", "password": "testtest"}'
{"ID":"01CJ1R3RNSM30M5JSSZ0PCY2T3"}
curl -k -X POST https://127.0.0.1:8080/pc/create -d '{"token":"01CJ1R3RNSM30M5JSSZ0PCY2T3","type":"01CE3J5ASXJSVC405QTES4M221", "name": "roger_lemour"}'
# Token is token obtained at signin and type is an entity ID described in templates/entity_templates.json.
curl -k -X POST https://127.0.0.1:8080/pc/list -d '{"token":"01CJ1R3RNSM30M5JSSZ0PCY2T3"}'
[{"id":"01CHX275W59NGGJ072YFY7RT29","type":"00000000000000000000000000","name":"mesmerist","hp":150,"mp":250,"position":{"Coord":{"x":39.19956060954395,"y":37.77876652333657,"z":36.315239570760646},"SectorID":"01CF001HTBA3CDR1ERJ6RF183A"}}]
curl -k -X POST https://127.0.0.1:8080/pc/connect -d '{"token":"01CJ1R3RNSM30M5JSSZ0PCY2T3","target":"01CHX275W59NGGJ072YFY7RT29"}'
{"ID":"01CHX2RB2DHJYJ2XAWBYVBMGB9"}
# Target is a PC ID in /list results

# Paste token in config_client.json: {... "app": {"token": 01CJ1R3RNSM30M5JSSZ0PCY2T3,...}}
make client && bin/game_client configs/config_client.json
{"type":"move","action":{"source":"01CHX2RB2DHJYJ2XAWBYVBMGB9","target":"01CHX2RB2DHJYJ2XAWBYVBMGB9","position":{"X":94.0164,"Y":80.5287,"Z":70.7539}}}
...

# Disconnect PC only (may reconnect with same token)
curl -k -X POST https://127.0.0.1:8080/pc/disconnect -d '{"token": "01CJ1R3RNSM30M5JSSZ0PCY2T3"}'
# Signout
curl -k -X POST https://127.0.0.1:8080/signout -d '{"username": "test", "token": "01CJ1R3RNSM30M5JSSZ0PCY2T3"}'

For more examples and usage, please refer to the Wiki.

Release History

  • 0.0.1
    • Work in progress

Meta

Elojah – swingcastor@gmail.com

Distributed under the GNU AFFERO GENERAL PUBLIC license. See LICENSE for more information.

https://github.com/elojah/

Contributing

  1. Fork it (https://github.com/yourname/yourproject/fork)
  2. Create your feature branch (git checkout -b feature/fooBar)
  3. Commit your changes (git commit -am 'Add some fooBar')
  4. Push to the branch (git push origin feature/fooBar)
  5. Create a new Pull Request

TODO

  • Remove NATS streaming
  • Change log to zap (uber faster log)
  • Add context + use it with sync.errgroup
  • Use TCP + rename UDP to mux
  • Set new https service to create new token
  • Set new bin to read events
  • Add NATS mqueue to cancel replay mechanism (in context usage ?)
  • Fix NATS slow consumer, mouais
  • Add sequencer_test.go, 100% plz (ok)
  • Add state/entity service impl + interactions
  • Handle token permissions/entity actions (linked to above)
  • Refacto skill mechanic to be like class definition (json template + tool)
  • Cast/Skill can have multiple effects on multiple targets
  • AbilityFeedback service get/set
  • Add core app handler skill
  • Implement SkillFeedback mechanism
  • Response server to update all clients with delta compression named sync
    • Think about entity interactions limit to "what's around" to scale efficiently (tile38 Entity Service) ?
    • recurrer test 100%
  • ack service
  • Edit client to make it sensitive to sync calls and save in a local rocksdb ? + first graphic client
  • Split auth (with set/list/connect PC) and remove all pc stuff elsewhere.
  • Add token revoker after X incativity
  • Change EntitySubset key string into ID ID
  • Add redis services for core and syncs ids apps
  • Add redis service for initial positions.
  • Move all Start into Dial (for clean/up down)
  • Add up/down mechanic
  • Save pool ID in token.
  • Save PC + Delete all token-associated data.
  • Add use cases for entity (create/delete) and token(create/delete)
  • Switch nats to redis pub/sub
  • Add Pool for listeners + ListenerMapper Set/Get
  • Del for everything (not yet but token/entity ok)
  • Put everything as usecase and use (almost) only them in controllers (not yet but entity/token ok)
  • Prevent multiple /signin -> retrieve multiple tokens
  • Add server ack sending to client <-done and client resend
  • Add Name at create PC
  • Add account disconnect /account/disconnect -d {"username"} (disconnect token + delete token + reset account.Token)
  • Integration test binary with correct set
  • Add minimal graphic interface to client (minimal calls and print entity states)
  • Implement tool to generate/check/visualize sectors and entity movements
  • Add context everywhere

TO DEBATE

  • Add sequencer cancelling mechanism (CancelEvent(id)->id(don't do me)->event...)
  • Add cast time mechanic

RANDOM

  • Trickster entity can switch position with his own entities and switch them
  • Mesmerist entity can take control of enemy entities
  • Inquisitor entity can merge entities (allies/enemies)
  • Totemist entity can clone his own entities
  • Scavenger entity can sacrify his own entities

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL