0. Preface

This repository introduces an intact "multillayer online arena" game, with centralized framesync@30fps(tunable), room management and player session management.

Currently both frontend and backend are aligned to support only 1v1 mode, but the backend is comparatively easy to be configured to support 2v2 ~ 5v5 etc. (tested), while the frontend is not as easy to tune. The sync algorithm is applicable to UDP as well.

The corresponding BotSpawningService can be found here.

We decided to open source this project due to lack of resource to maintain it, therefore new feature proposal, bug report or pull-request might not be handled in time -- and we'll try our best.

1. Database Server

The database product to be used for this project is MySQL 5.7.

We use skeema for schematic synchronization under <proj-root>/database/skeema-repo-root/ which intentionally doesn't contain a .skeema file. Please read this tutorial for more information.

You can use this node module (still under development) instead under Windows10, other versions of Windows are not yet tested for compatibility.

The following command(s)

### Optional.
user@proj-root/database/skeema-repo-root> cp .skeema.template .skeema

###
user@proj-root/database/skeema-repo-root> skeema diff

is recommended to be used for checking difference from your "live MySQL server" to the latest expected schema tracked in git.

2. Building & running

2.1 Golang1.11

See https://github.com/genxium/Go111ModulePrac for details.

2.2 MySQL

On a product machine, you can install and manage MySQL server by these scripts.

2.3 Required Config Files

2.3.1 Backend

  • It needs <proj-root>/battle_srv/configs/* which is generated by cd <proj-root>/battle_srv && cp -r ./configs.template ./configs and necessary customization.

2.3.2 Frontend

  • It needs <proj-root>/frontend/assets/plugin_scripts/conf.js which is generated by cd <proj-root>/frontend/assets/plugin_scripts && cp conf.js.template conf.js.

Please check "Map.js > forceBigEndianFloatingNumDecoding = true" when building for cc.sys.WECHAT_GAME and uncheck it for others.

2.4 Different "ServerEnv"s for the runtime of backend service

本游戏具备账号系统且主要注册方式为"Phonenum+SMSCaptcha",考虑到开发者和公司内部测试的需要,服务器将提供以下的"ServerEnv"s供在runtime of backend service按需采用。

2.4.1 ServerEnv == PROD (如不指定ServerEnv则默认为PROD)

user@proj-root/battle_srv> make run-prod

将不允许使用“测试账号”。

2.4.2 ServerEnv == TEST

user@proj-root/battle_srv> make run-test

将允许使用“测试账号”,详见 https://shimo.im/docs/Q7wqNHlvyYQu0nYP 说明。

2.5 Troubleshooting

2.5.1 Redis snapshot writing failure

ErrFatal        {"err": "MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk. Commands that may modify the data set are disabled. Please check Redis logs for details about the error."}

Just restart your redis-server process.

2.5.2 Uploading <proj-root>/frontend/build/wechatgame/res/ to remote resource directory

Please make sure that you've read "https://app.yinxiang.com/shard/s61/nl/13267014/d6b1f7aa-8c6b-4200-b8e4-8b5a21b22fa1" as a prerequisite.

To publish this game to wechatgame platform, you'll have to first upload it to the platform which requires the whole package to be no larger than 8MB.

A non-tricky way to make package size always uploadable is to

  • upload the local <proj-root>/frontend/build/wechatgame/res/ to wherever specified by magic variable wxDownloader.REMOTE_SERVER_ROOT in <proj-root>/frontend/build-templates/wechatgame/game.js (often an additional nginx config file lookup effort is necessary), then
  • delete the local <proj-root>/frontend/build/wechatgame/res/, then
  • upload the residual package files in "微信开发者工具(downloaded from https://developers.weixin.qq.com/miniprogram/dev/devtools/download.html)".
shell> nslookup bgmoba.lokcol.com
Server:  XiaoQiang
Address:  192.168.31.1

Non-authoritative answer:
Name:    bgmoba.lokcol.com
Address:  58.87.122.61

# Shows 2 lines before as well as 2 lines after the matching line.
shell> cat ~/.ssh/config | grep -B 2 -A 2 58.87.122.61
Host lokcol-4-ubuntu
  Hostname 58.87.122.61
  User ubuntu

Host lokcol-4-pomelo
  Hostname 58.87.122.61
  User pomelo
# The file `/etc/nginx/vhost/bgmoba.lokcol.com` on `58.87.122.61`. 

server {
  listen 443;
  server_name bgmoba.lokcol.com;

  root         "/var/www/html/bgmoba";
  index index.html;
  access_log /var/log/nginx/bgmoba-access.log;
  error_log /var/log/nginx/bgmoba-err.log;

  ssl on;
  ssl_certificate  /etc/nginx/certs/bgmoba.lokcol.com.fullchain.cer;
  ssl_certificate_key /etc/nginx/certs/bgmoba.lokcol.com.key;
  gzip on;
  gzip_min_length 1k;
  gzip_buffers 4 16k;
  gzip_comp_level 5;
  gzip_types text/plain application/x-javascript text/css application/xml text/javascript application/x-http
    hp application/json application/javascript;
  gzip_vary on;
}

, you should

  • set REMOTE_SERVER_ROOT = "https://bgmoba.lokcol.com/static/" in the build panel

and then upload by the following command(s).

shell> scp -r ./frontend/build/wechatgame/res/* ubuntu@bgmoba.lokcol.com:/var/www/html/bgmoba/static/res/

3. Git configs cautions

Please make sure that you've set ignorecase = false in your [core] section of <proj-root>/.git/config.