Giter Site home page Giter Site logo

alioth-center / genius-invokation-simulator-backend Goto Github PK

View Code? Open in Web Editor NEW
35.0 35.0 7.0 402 KB

原神七圣召唤模拟器后端

Home Page: https://sunist-c.github.io/genius-invokation-simulator-backend/

License: MIT License

Go 100.00%
backend card-game game genius-invokation genius-invokation-tcg genshin-impact golang simulator

genius-invokation-simulator-backend's People

Contributors

chengdaqi2023 avatar sunist-c avatar sunist-chan avatar thehrz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

genius-invokation-simulator-backend's Issues

SyncMessage设计不全面

#4 中存在信息不全面的问题,缺失信息如下:

  1. 对局附加信息,如回合状态,回合数等
  2. 部份对战信息,如召唤物,支援物等

Sqlite3DB实现中存在范型错误

#8 中的Sqlite3DB实现存在BUG,具体为:

  1. DeleteOne() 接口报错:Delete action needs at least one condition,初步判断为范型错误
  2. UpdateByID() 接口报错: No content found to be updated,初步判断为范型错误

完善mod模块的实现类

影响的包: mod/implement

为mod/definition中的接口添加其实现类,以供mod开发者快速实现,预期添加的实现类:

  1. CardImpl(s)
  2. EventImpl
  3. CharacterImpl
  4. ModifierImpl(s)
  5. SkillImpl(s)

持久化模块设计

Summary

影响的包:persistence, model
描述: 用于托管玩家信息,游戏内容(卡牌、角色、技能等)的数据持久化模块,最好不引入第三方组件(redis/mysql之类的)

Details

模块需完成下述功能:

  1. 玩家信息存储与CRUD
  2. 游戏实体内容持久化,需托管实体id->实体的KV关系,用于在初始化游戏时根据玩家提交的信息进行Character和Player等实体的实例化等场景
  3. 游戏场景内容持久化,需托管实体id->实体内容(角色描述,多语言数据等)的KV关系

日志器设计

Summary

影响的包:util/log
描述: 贯穿全项目的日志器实现,最好可以自动生成日志内容,不需要显式调用(?)

http服务设计

Summary

影响的包:protocol/http
预计修改文件: protocol/http/engine.go, protocol/http/service.go
描述: 为项目提供HTTP服务,包括房间查询,加入房间,初始化战斗框架,升级websocket连接等功能

Details

预计使用go-gin作为HTTP服务框架,gorilla-websocket作为websocket框架,简单的HTTP路由设计如下:

GET /room -> 获取所有房间列表
GET /room/:room_id -> 获取room_id的房间信息
POST /room -> 创建一个房间,并将连接升级到websocket
POST /room/:room_id -> 加入一个房间,并将连接升级到websocket
GET /setting -> 获取所有可配置的选项,需鉴权
PUT /setting/:setting_options -> 更改配置项,需鉴权
POST /user -> 新玩家注册
PUT /user/:user_id -> 更新玩家数据
GET /user/:user_id -> 获取玩家数据
DELETE /user/:user_id -> 注销玩家数据

完善Preview系统

Summary

影响的包:entity
修改文件:entity/player.go, entity/character.go. entity/core.go
描述: 完善玩家各种操作的预览操作与相关接口,在不触发Modifiers的情况下进行效果预览

Details

增加下列接口及实现:

  1. PreviewAttack 实现攻击效果预览
  2. PreviewEquip 实现装备效果预览
  3. PreveiwEatFood 实现食物效果预览
  4. PreviewHeal 实现治疗效果预览
  5. PreviewCharge 实现充能效果预览

完善mod模块的自动化测试流程

影响的包: mod/testing, mod/definition, mod/implement

为mod模块中定义的各类实体添加标准化测试流程,方便在mod制作工具中从模板直接生成单元测试文件

完善开发文档

Summary

预计新增分支: document
描述: 预期使用Hugo+Doks构建一个好看点的静态GitHub Pages,用作开发文档页面

运行时规则设计

Summary

影响的包:entity
预计修改文件: entity/rule.go
描述: 运行时调用的规则,例如元素反应规则,作用是将具体实现与框架的调用分离

Details

预计增加以下接口:

  1. 元素反应相关

战斗框架设计

Summary

影响的包:entity, framework
预计修改文件: entity/core.go, framework/battle.go
描述: 用于解析、执行玩家的操作,将编排entity/character与entity/player

Details

预计新增以下结构:

  1. 具体执行玩家操作的战斗框架entity/core,提供粒度较细的接口以供一些自定义程度较高的内容实现调用
  2. 解析玩家操作并转换为战斗框架指令的framework/battle,围绕玩家可进行的操作提供接口与参数校验

无法构建

.../opt/genius-invokation-simulator-backend $ go build
main.go:4:2: no required module provides package github.com/sunist-c/genius-invokation-simulator-backend/protocal/http; to add it:
        go get github.com/sunist-c/genius-invokation-simulator-backend/protocal/http
.../opt/genius-invokation-simulator-backend $ go get github.com/sunist-c/genius-invokation-simulator-backend/protocal/http
go: github.com/sunist-c/genius-invokation-simulator-backend/protocal/http: no matching versions for query "upgrade"
.../opt/genius-invokation-simulator-backend $

相关代码:
main.go

1 package main
2
3 import (
4    "github.com/sunist-c/genius-invokation-simulator-backend/protocal/http"  <--
5     "time"
6 )
7
8 func main() {
9     http.StartHttpServer(8080)
10     time.Sleep(10 * time.Second)
11 }

websocket服务设计

Summary

影响的包:protocol/websocket
描述: 为客户端、服务端之间的双向通信提供websocket服务

Details

预计使用gorilla/websocket包作为websocket实现

命令行客户端实现

Summary

影响的包:cli
描述: 用于在命令行进行对局的客户端实现,可以连接服务端并进行基本的战斗操作

Details

目测是一个很阴间的东西,甚至可能不是客户端,直接在服务端scanf()

完善使用文档

Summary

预计新增分支: document
描述: 预期使用Hugo+Doks构建一个好看点的静态GitHub Pages,用作使用文档页面

设计Mod接口

Summary

预计新增包: mod
描述:

  1. 定义Mod中应实现的各种接口
  2. 实现model.adapter中的Adapter接口,以期将Mod实现中的接口转换为游戏内实体
  3. 设计针对Mod的覆盖测试,供Mod作者测试

完善日志器

Summary

受影响的包: entity, framework, http, websocket, mod, persistence, util
描述:

  1. 将通过chan记录 error, info, trace 三个级别的日志
  2. 在已完成的包中加入日志相关的调用
  3. 设计util.log包,以期实现基于chan的日志器

战斗框架的支援物实现

Summary

影响的包:entity, framework
预计修改文件: entity/core.go, framework/battle.go, entity/support.go
描述:

  1. 定义支援物接口
  2. 召唤物相关被动接口(事件触发)

Details

预计新增以下接口:

  1. entity.Support

完成mod模块的适配器

影响的包: mod/adapter, mod/definition

为mod/definition中的接口添加与entity/model和entity的adapter,以让mod实现类转换为游戏核心内的实体

战斗框架的召唤物实现

Summary

影响的包:entity, framework
预计修改文件: entity/core.go, framework/battle.go, entity/summon.go
描述:

  1. 用于解析、执行玩家对召唤物的操作
  2. 定义召唤物类型(攻击性/防御性)
  3. 召唤物相关改变接口(增加可用次数/销毁)
  4. 召唤物相关主动接口(剑鬼/艾咪的主动使用)
  5. 召唤物相关被动接口(回合末攻击)
  6. 玩家对召唤物的调用实现(调用主动接口)
  7. 框架对召唤物的调用实现(调用被动接口)

Details

预计新增以下接口:

  1. entity.Summon 召唤物接口
  2. entity.AggressiveSummon 攻击性召唤物接口
  3. entity.DefensiveSummon 防御性召唤物接口

网络通信包设计

Summary

影响的包:message
预计修改文件: message/sync.go, message/action.go
描述: 服务端与客户端的同步消息结构与玩家进行相关操作的消息结构

Details

预计增加以下结构:

  1. 服务端向客户端发送的sync消息,用于同步其他玩家对服务端的修改,使用场景为websocket
  2. 客户端向服务端发送的action消息,用于向服务端提交玩家的操作,使用场景为websocket

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.