Coder Social home page Coder Social logo

game-ddz's Introduction

斗地主

♦️ 基于Hyperf框架开发斗地主游戏,实现斗地主游戏服务端逻辑,并采用原生js和WebSocket实现简单的客户端打牌逻辑,可以做到简单的玩斗地主游戏。

特性

  • 实现前后端二进制封包解包,采用的是msgpack扩展,msgpack对数据进行了压缩,并实现粘包处理;
  • 数据采用固定包头,包头4个字节存包体长度,包体前2个字节分别为cmd(主命令字),scmd(子命令字),后面为包体内容
  • 采用策略模式解耦游戏中的每个协议逻辑
  • 实现定义游戏开发cmd(主命令字)和scmd(子命令字)定义,cmd和scmd主要用来路由到游戏协议逻辑处理

依赖

  • 运行 Hyperf 的环境
  • msgpack 扩展

安装

git clone https://github.com/sy-records/game-ddz.git

cd game-ddz
composer install --no-dev
php bin/hyperf.php start

安装完成后访问 URL:http://127.0.0.1:9501

使用示例

登陆

请随意输入英文或数字账号,这里是将用户账号当做uid使用,存入redis当中

登陆

打牌

根据按钮来操作打牌逻辑,消息框里会提示打牌逻辑过程

打牌

写在最后

此repo示例修改自swoft-ddz,已和原作者联系。

如有定制开发需求可以联系QQ。点此即可联系我

game-ddz's People

Contributors

sy-records avatar

Watchers

 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.