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 {
17
17
GetMatchResult (string , int ) []byte
18
18
PutMatch ([]byte )
19
19
GetMatchNum (string ) int
20
+ TimerMatch ()
20
21
}
Original file line number Diff line number Diff line change 1
1
package match
2
2
3
- // 匹配
3
+ import (
4
+ "LollipopGo/LollipopGo/log"
5
+ )
6
+
7
+ var PoolMax int // 匹配池的大小
8
+ var MapPoolMatch chan map [int ]* PoolMatch // 申请数据库
9
+
4
10
type 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
+
5
42
}
You can’t perform that action at this time.
0 commit comments