Skip to content

Commit fc448e2

Browse files
committed
update data
1 parent ad05f2f commit fc448e2

File tree

2 files changed

+3
-150
lines changed
  • 第一季 从零开始写游戏服务器 第二期/最新课节--课程代码/vender/src/LollipopGo/LollipopGo

2 files changed

+3
-150
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,7 @@
11
package match
22

3-
import (
4-
"time"
5-
)
6-
7-
/*
8-
玩家匹配算法:
9-
类型一: 1V1
10-
11-
1 一个玩家的结构,list 存储所有的报名的玩家(启动包括正在进入的玩家的)
12-
2 首先:玩家可以一直的加入,并不影响匹配,基本算法形成。
13-
14-
15-
*/
16-
17-
// 1 需要一个玩家报名后进来的,存储数据的结构信息
18-
// 2 匹配玩家,要求按照报名的时间的最长的开始匹配
19-
// 3 生产结果;匹配模块需要处理的
20-
// 4 实现方式:有一个匹配池子,每一个用户都是去池子里面匹配,成功返回结构
21-
// 5 匹配的池子包含很多因素:等级相近,金币相近等
22-
// 6 多线程匹配速度
23-
//*7 实现等级快速排序,多个goroutine去组合-->进入房间
24-
25-
type MatchMoudle interface {
26-
GetMatchResult()
27-
}
28-
29-
var SubPlayer []int
30-
31-
type MatchPlayer struct { // 匹配的数据
32-
}
33-
34-
//-------------------------------------------------------------
35-
363
type MatchMoudle interface {
37-
Init(selfGetter DModuleGetter) bool
38-
Destroy()
39-
Run(delta int64)
40-
}
41-
42-
type implMatchModule struct {
43-
module MatchMoudle
44-
tickUseTime time.Duration
45-
tickTimeTotal time.Duration
46-
moduleName string
47-
}
48-
49-
type MatchModuleMgr []implMatchModule
50-
51-
type MatchModuleGetter struct {
52-
mgr *MatchModuleMgr
53-
id int
54-
}
55-
56-
// NewDmodule ... ...
57-
func NewMatchmodule(num int) MatchModuleMgr {
58-
return make([]implMatchModule, num)
59-
}
60-
61-
// Get ... ...
62-
func (g *DModuleGetter) Get() MatchMoudle {
63-
return (*g.mgr)[g.id].module
64-
}
65-
66-
//Register ... ...
67-
func (mgr *MatchModuleMgr) Register(id int, m MatchMoudle) MatchModuleGetter {
68-
(*mgr)[id].module = m
69-
mName := strings.Replace(reflect.TypeOf(m).String(), "*", "_", -1)
70-
mName = "module" + strings.Replace(mName, ".", "_", -1)
71-
mName = strings.ToLower(mName)
72-
(*mgr)[id].moduleName = mName
73-
return mgr.Getter(id)
4+
GetMatchResult(string, int) []byte
5+
PutMatch([]byte)
6+
GetMatchNum(string) int
747
}

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

Lines changed: 0 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -70,83 +70,3 @@ func MD5_LollipopGO(data string) string {
7070
}
7171

7272
//------------------------------------------------------------------------------
73-
74-
// package main
75-
76-
// import (
77-
// "encoding/json"
78-
// "fmt"
79-
// "os"
80-
// )
81-
82-
// type ConfigStruct struct {
83-
// Host string `json:"host"`
84-
// Port int `json:"port"`
85-
// AnalyticsFile string `json:"analytics_file"`
86-
// StaticFileVersion int `json:"static_file_version"`
87-
// StaticDir string `json:"static_dir"`
88-
// TemplatesDir string `json:"templates_dir"`
89-
// SerTcpSocketHost string `json:"serTcpSocketHost"`
90-
// SerTcpSocketPort int `json:"serTcpSocketPort"`
91-
// Fruits []string `json:"fruits"`
92-
// }
93-
94-
// type Other struct {
95-
// SerTcpSocketHost string `json:"serTcpSocketHost"`
96-
// SerTcpSocketPort int `json:"serTcpSocketPort"`
97-
// Fruits []string `json:"fruits"`
98-
// }
99-
100-
// func main() {
101-
// jsonStr := `{"host": "http://localhost:9090","port": 9090,"analytics_file": "","static_file_version": 1,"static_dir": "E:/Project/goTest/src/","templates_dir": "E:/Project/goTest/src/templates/","serTcpSocketHost": ":12340","serTcpSocketPort": 12340,"fruits": ["apple", "peach"]}`
102-
103-
// //json str 转map
104-
// var dat map[string]interface{}
105-
// if err := json.Unmarshal([]byte(jsonStr), &dat); err == nil {
106-
// fmt.Println("==============json str 转map=======================")
107-
// fmt.Println(dat)
108-
// fmt.Println(dat["host"])
109-
// }
110-
111-
// //json str 转struct
112-
// var config ConfigStruct
113-
// if err := json.Unmarshal([]byte(jsonStr), &config); err == nil {
114-
// fmt.Println("================json str 转struct==")
115-
// fmt.Println(config)
116-
// fmt.Println(config.Host)
117-
// }
118-
119-
// //json str 转struct(部份字段)
120-
// var part Other
121-
// if err := json.Unmarshal([]byte(jsonStr), &part); err == nil {
122-
// fmt.Println("================json str 转struct==")
123-
// fmt.Println(part)
124-
// fmt.Println(part.SerTcpSocketPort)
125-
// }
126-
127-
// //struct 到json str
128-
// if b, err := json.Marshal(config); err == nil {
129-
// fmt.Println("================struct 到json str==")
130-
// fmt.Println(string(b))
131-
// }
132-
133-
// //map 到json str
134-
// fmt.Println("================map 到json str=====================")
135-
// enc := json.NewEncoder(os.Stdout)
136-
// enc.Encode(dat)
137-
138-
// //array 到 json str
139-
// arr := []string{"hello", "apple", "python", "golang", "base", "peach", "pear"}
140-
// lang, err := json.Marshal(arr)
141-
// if err == nil {
142-
// fmt.Println("================array 到 json str==")
143-
// fmt.Println(string(lang))
144-
// }
145-
146-
// //json 到 []string
147-
// var wo []string
148-
// if err := json.Unmarshal(lang, &wo); err == nil {
149-
// fmt.Println("================json 到 []string==")
150-
// fmt.Println(wo)
151-
// }
152-
// }

0 commit comments

Comments
 (0)