File tree Expand file tree Collapse file tree 3 files changed +39
-1
lines changed
第一季 从零开始写游戏服务器 第二期/最新课节--课程代码/vender/src/LollipopGo/LollipopGo Expand file tree Collapse file tree 3 files changed +39
-1
lines changed Original file line number Diff line number Diff line change @@ -17,4 +17,5 @@ type MatchMoudle interface {
1717 GetMatchResult (string , int ) []byte
1818 PutMatch ([]byte )
1919 GetMatchNum (string ) int
20+ TimerMatch ()
2021}
Original file line number Diff line number Diff line change 11package match
22
3- // 匹配
3+ import (
4+ "LollipopGo/LollipopGo/log"
5+ )
6+
7+ var PoolMax int // 匹配池的大小
8+ var MapPoolMatch chan map [int ]* PoolMatch // 申请数据库
9+
410type PoolMatch struct {
11+ PlayerUID int // 玩家的UID信息
12+ MatchTime int // 玩家匹配的耗时 --- conf配置 数据需要
13+ PlayerScore int // 玩家的分数
14+ }
15+
16+ func newPoolMatch (IMax int ) (MapPoolMatch chan map [int ]* PoolMatch ) {
17+
18+ if IMax <= 0 {
19+ IMax = 100
20+ }
21+ return make (chan map [int ]* PoolMatch , IMax )
22+ }
23+
24+ func (this * PoolMatch ) PutMatch (data map [int ]* PoolMatch ) {
25+ if len (MapPoolMatch ) >= PoolMax {
26+ log .Debug ("超过了pool的上限!" )
27+ return
28+ }
29+ MapPoolMatch <- data
30+ }
31+
32+ func (this * PoolMatch ) GetMatchResult () {
33+
34+ }
35+
36+ func (this * PoolMatch ) GetMatchNum () {
37+
38+ }
39+
40+ func (this * PoolMatch ) TimerMatch () {
41+
542}
You can’t perform that action at this time.
0 commit comments