Skip to content

Commit 68c2044

Browse files
committed
PutMatch
1 parent c50a404 commit 68c2044

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed

第一季 从零开始写游戏服务器 第二期/最新课节--课程代码/vender/src/LollipopGo/LollipopGo/match/match.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff 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 numberDiff line numberDiff line change
@@ -1,5 +1,42 @@
11
package match
22

3-
// 匹配
3+
import (
4+
"LollipopGo/LollipopGo/log"
5+
)
6+
7+
var PoolMax int // 匹配池的大小
8+
var MapPoolMatch chan map[int]*PoolMatch // 申请数据库
9+
410
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+
542
}

0 commit comments

Comments
 (0)