├── .gitattributes ├── README.md └── server ├── LICENSE ├── README.md ├── bin ├── conf │ └── server.json └── gamedata │ ├── MineLocation.txt │ ├── Shop.txt │ └── TestTable.txt ├── doc ├── blockchain.sql └── 区块链游戏服务端介绍.pdf ├── goland_cfg.png ├── golandcfg2.png └── src └── server ├── Test ├── TestTest.go ├── client.go ├── t.go ├── t1.go ├── testgorm.go └── testmysql.go ├── base └── skeleton.go ├── chain ├── blockmachine.go └── minemachine.go ├── common ├── common.go ├── genkey.go └── rsa.go ├── conf ├── conf.go └── json.go ├── game ├── external.go └── internal │ ├── blockmachine.go │ ├── chanrpc.go │ ├── command.go │ ├── handler.go │ ├── minemachine.go │ ├── module.go │ ├── player.go │ └── rank.go ├── gamedata ├── minelocation.go ├── reader.go ├── shop.go ├── tables.go └── testtable.go ├── gate ├── external.go ├── internal │ └── module.go └── router.go ├── login ├── external.go └── internal │ ├── account.go │ ├── handler.go │ └── module.go ├── main.go ├── msg ├── message.pb.go └── msg.go └── mysql └── mysql.go /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # blockchain-game 2 | 采用Leaf游戏服务器框架实现一款向上与线下相关联的区块链游戏,利用丰富的矿场资源,给与玩家真实的挖矿体验,通过游戏的社交系统,营造一个良好的玩家交流氛围,通过打造游戏的品牌效应,数据上联,给与玩家可视化的游戏体验,增加玩家信任度和粘度,利用游戏的自己的经济系统,对玩家进行运营,丰富游戏的收入体系。 3 | -------------------------------------------------------------------------------- /server/LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | Copyright 2015-2017 Name5566. 180 | 181 | Licensed under the Apache License, Version 2.0 (the "License"); 182 | you may not use this file except in compliance with the License. 183 | You may obtain a copy of the License at 184 | 185 | http://www.apache.org/licenses/LICENSE-2.0 186 | 187 | Unless required by applicable law or agreed to in writing, software 188 | distributed under the License is distributed on an "AS IS" BASIS, 189 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 190 | See the License for the specific language governing permissions and 191 | limitations under the License. 192 | -------------------------------------------------------------------------------- /server/README.md: -------------------------------------------------------------------------------- 1 | # blockchaingame 2 | -------------------------------------------------------------------------------- /server/bin/conf/server.json: -------------------------------------------------------------------------------- 1 | { 2 | "LogLevel": "debug", 3 | "LogPath": "log", 4 | "TCPAddr": "0.0.0.0:3563", 5 | "MaxConnNum": 20000, 6 | "MySqlUrl":"root:123@tcp(localhost:3306)/blockchain?parseTime=true", 7 | "ConsolePort":3333 8 | } 9 | -------------------------------------------------------------------------------- /server/bin/gamedata/MineLocation.txt: -------------------------------------------------------------------------------- 1 | Location Name Icon Electric ManageCost Output Coord Num 2 | 1 水电矿点 Img_huoli 0.4 0.5 100.0 0.0 100 3 | 2 火电矿点 Img_shuili 0.4 0.5 110.0 0.0 85 4 | 3 风电矿点 Img_fengli 0.4 0.5 90.0 0.0 85 5 | -------------------------------------------------------------------------------- /server/bin/gamedata/Shop.txt: -------------------------------------------------------------------------------- 1 | ProductID ID Name Icon TypeID Producer Repertory Price Kwh Ghs Electric ManageCost Output Minimum 2 | 900001 1 蚂蚁S9i 14T icon_kuangji1 1 1.0 100 5500.0 1.32 14.0 12.672 0.5 7.0 3600 3 | 900002 2 蚂蚁S9i 13.5T icon_kuangji1 1 1.0 100 5300.0 1.31 13.5 12.576 0.5 6.75 3600 4 | 900003 3 蚂蚁S9i 13T icon_kuangji1 1 1.0 100 5100.0 1.29 13.0 12.384 0.5 6.5 3600 5 | 900004 4 蚂蚁T9 icon_kuangji1 1 1.0 100 3000.0 1.43 10.5 13.728 0.5 5.25 7200 6 | 900005 5 蚂蚁V9 icon_kuangji1 1 1.0 100 1100.0 1.027 4.0 9.8592 0.5 2.0 10800 7 | 900006 6 蚂蚁V9 icon_kuangji1 1 1.0 100 1100.0 1.027 4.0 9.8592 0.5 2.0 10800 8 | 900007 7 阿瓦隆A841 icon_kuangji2 2 1.0 100 7600.0 1.29 13.0 12.384 0.5 6.5 3600 9 | 900008 8 阿瓦隆A821 icon_kuangji2 2 1.0 100 5600.0 1.2 11.0 11.52 0.5 5.5 3600 10 | 900009 9 阿瓦隆A841 icon_kuangji2 2 1.0 100 7600.0 1.29 13.0 12.384 0.5 6.5 3600 11 | 900010 10 阿瓦隆A821 icon_kuangji2 2 1.0 100 5600.0 1.2 11.0 11.52 0.5 5.5 3600 12 | 900011 11 阿瓦隆A841 icon_kuangji2 2 1.0 100 7600.0 1.29 13.0 12.384 0.5 6.5 3600 13 | 900012 12 阿瓦隆A821 icon_kuangji2 2 1.0 100 5600.0 1.2 11.0 11.52 0.5 5.5 3600 14 | 900013 13 翼比特E9.3 icon_kuangji3 3 1.0 100 6150.0 1.29 13.0 12.384 0.5 6.5 3600 15 | 900014 14 翼比特E9.2 icon_kuangji3 3 1.0 100 7185.0 1.2 11.0 11.52 0.5 5.5 3600 16 | 900015 15 翼比特E10 icon_kuangji3 3 1.0 100 34000.0 1.2 9.0 11.52 0.5 4.5 7200 17 | 900016 16 翼比特E9+ icon_kuangji3 3 1.0 100 7500.0 1.29 7.0 12.384 0.5 3.5 7200 18 | 900017 17 翼比特E9 icon_kuangji3 3 1.0 100 4800.0 1.2 5.0 11.52 0.5 2.5 7200 19 | 900018 18 翼比特E11 icon_kuangji3 3 1.0 100 10000.0 1.29 3.0 12.384 0.5 1.5 10800 20 | -------------------------------------------------------------------------------- /server/bin/gamedata/TestTable.txt: -------------------------------------------------------------------------------- 1 | ID Name HP LevelAP 2 | 1 one 100 [1, 2, 3] 3 | 2 two 100 [1, 2, 3] 4 | 3 three 100 [1, 2, 3] 5 | -------------------------------------------------------------------------------- /server/doc/blockchain.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Navicat Premium Data Transfer 3 | 4 | Source Server : 127.0.0.1 5 | Source Server Type : MySQL 6 | Source Server Version : 50720 7 | Source Host : 127.0.0.1:3306 8 | Source Schema : blockchain 9 | 10 | Target Server Type : MySQL 11 | Target Server Version : 50720 12 | File Encoding : 65001 13 | 14 | Date: 03/08/2018 14:32:42 15 | */ 16 | 17 | SET NAMES utf8mb4; 18 | SET FOREIGN_KEY_CHECKS = 0; 19 | 20 | -- ---------------------------- 21 | -- Table structure for accounts 22 | -- ---------------------------- 23 | DROP TABLE IF EXISTS `accounts`; 24 | CREATE TABLE `accounts` ( 25 | `id` int(32) UNSIGNED NOT NULL AUTO_INCREMENT, 26 | `account` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, 27 | `sdk_account` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL, 28 | `sdk_client_id` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL, 29 | `sdk_access_token` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL, 30 | `channel_id` int(10) UNSIGNED NULL DEFAULT NULL, 31 | `imei` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL, 32 | `game_ver` int(10) UNSIGNED NULL DEFAULT NULL, 33 | `extra` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL, 34 | `phone` varchar(32) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL, 35 | `createtime` bigint(64) NULL DEFAULT 0, 36 | `name` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, 37 | `style` int(10) UNSIGNED NULL DEFAULT 0, 38 | `app_coins` double NULL DEFAULT 0, 39 | `compute_power` double NULL DEFAULT 0, 40 | `logintime` bigint(20) NULL DEFAULT NULL, 41 | `offflinetime` bigint(20) NULL DEFAULT NULL, 42 | `btc` double NULL DEFAULT 0, 43 | PRIMARY KEY (`id`) USING BTREE, 44 | UNIQUE INDEX `account`(`account`) USING BTREE, 45 | UNIQUE INDEX `name`(`name`) USING BTREE 46 | ) ENGINE = InnoDB AUTO_INCREMENT = 268435456 CHARACTER SET = utf8 COLLATE = utf8_bin ROW_FORMAT = Dynamic; 47 | 48 | -- ---------------------------- 49 | -- Table structure for block_machines 50 | -- ---------------------------- 51 | DROP TABLE IF EXISTS `block_machines`; 52 | CREATE TABLE `block_machines` ( 53 | `index` int(11) NULL DEFAULT NULL, 54 | `timestamp` bigint(64) NULL DEFAULT NULL, 55 | `player_id` int(32) UNSIGNED NULL DEFAULT NULL, 56 | `data_id` int(11) NULL DEFAULT NULL, 57 | `price` double(64, 0) NULL DEFAULT NULL, 58 | `count` int(11) NULL DEFAULT NULL, 59 | `hash` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL, 60 | `prev_hash` varchar(64) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL 61 | ) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_bin ROW_FORMAT = Dynamic; 62 | 63 | -- ---------------------------- 64 | -- Table structure for mine_machines 65 | -- ---------------------------- 66 | DROP TABLE IF EXISTS `mine_machines`; 67 | CREATE TABLE `mine_machines` ( 68 | `id` int(11) NOT NULL AUTO_INCREMENT, 69 | `data_id` int(11) NULL DEFAULT NULL, 70 | `player_id` int(10) UNSIGNED NULL DEFAULT NULL, 71 | `location` int(11) NULL DEFAULT NULL, 72 | `start_time` bigint(64) NULL DEFAULT NULL, 73 | `end_time` bigint(64) NULL DEFAULT NULL, 74 | PRIMARY KEY (`id`) USING BTREE 75 | ) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_bin ROW_FORMAT = Dynamic; 76 | 77 | SET FOREIGN_KEY_CHECKS = 1; 78 | -------------------------------------------------------------------------------- /server/doc/区块链游戏服务端介绍.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/go2004/blockchain-game/b5dc7be3c5821354799dd506b1f743e50320b75c/server/doc/区块链游戏服务端介绍.pdf -------------------------------------------------------------------------------- /server/goland_cfg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/go2004/blockchain-game/b5dc7be3c5821354799dd506b1f743e50320b75c/server/goland_cfg.png -------------------------------------------------------------------------------- /server/golandcfg2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/go2004/blockchain-game/b5dc7be3c5821354799dd506b1f743e50320b75c/server/golandcfg2.png -------------------------------------------------------------------------------- /server/src/server/Test/TestTest.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type TableAAA struct { 4 | IndexInt int "index" 5 | } 6 | 7 | type TableAAAManager struct { 8 | data map[string]TableAAA 9 | } 10 | 11 | var ( 12 | Instance = new(TableAAAManager) 13 | ) 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /server/src/server/Test/client.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | 4 | import ( 5 | //"encoding/binary" 6 | "net" 7 | //"fmt" 8 | "github.com/golang/protobuf/proto" 9 | "server/msg" 10 | //"log" 11 | "encoding/binary" 12 | "fmt" 13 | //"github.com/name5566/leaf/network/protobuf" 14 | _ "github.com/name5566/leaf/network/protobuf" 15 | 16 | ) 17 | 18 | func main() { 19 | conn, err := net.Dial("tcp", "127.0.0.1:3563") 20 | if err != nil { 21 | panic(err) 22 | } 23 | /* 24 | // Hello 消息(JSON 格式) 25 | // 对应游戏服务器 Hello 消息结构体 26 | data := []byte(`{ 27 | "Hello": { 28 | "Name": "炒在工" 29 | } 30 | }`) 31 | 32 | // len + data 33 | m := make([]byte, 2+len(data)) 34 | 35 | // 默认使用大端序 36 | binary.BigEndian.PutUint16(m, uint16(len(data))) 37 | 38 | copy(m[2:], data) 39 | 40 | // 发送消息 41 | conn.Write(m) 42 | 43 | m1 := make([] byte, 1024) 44 | len, err := conn.Read(m1) 45 | fmt.Print(len,string(m1)) 46 | */ 47 | 48 | //test := &msg.U2LS_Login{ 49 | // SdkAccount: *proto.String("SdkAccount"), 50 | // SdkClientId:*proto.String("SdkClientId"), 51 | // SdkAccessToken:*proto.String("SdkAccessToken"), 52 | //} 53 | 54 | //test := &msg.Login{ 55 | // Account: "ac23", 56 | // Passward: "123", 57 | //} 58 | 59 | data := []byte(`{ 60 | "Hello": { 61 | "Name": "炒在工" 62 | } 63 | }`) 64 | 65 | // len + data 66 | m := make([]byte, 2+len(data)) 67 | 68 | // 默认使用大端序 69 | binary.BigEndian.PutUint16(m, uint16(len(data))) 70 | 71 | copy(m[2:], data) 72 | 73 | // 发送消息 74 | conn.Write(m) 75 | 76 | m1 := make([] byte, 1024) 77 | len, err := conn.Read(m1) 78 | fmt.Print(len,string(m1)) 79 | 80 | /* 81 | 82 | var Processor = protobuf.NewProcessor() 83 | Processor.Register(&msg.Login{}) 84 | 85 | data, err := Processor.Marshal(&msg.Login{ 86 | Account: "a123", 87 | Passward: "ac23", 88 | }) 89 | if err != nil { 90 | println("marshaling error: ", err) 91 | } 92 | 93 | // len + id + data 94 | m := make([]byte, 4 + len(data[1])) 95 | 96 | // 默认使用大端序 97 | binary.BigEndian.PutUint16(m, uint16(2 + len(data[1]))) 98 | 99 | //binary.LittleEndian.PutUint16(m[2:], 10010) 100 | //copy(m[2:], data[0]) 101 | copy(m[2:], data[1]) 102 | 103 | // 发送消息 104 | conn.Write(m) 105 | 106 | 107 | buf := make([]byte, 32) 108 | // 接收消息 109 | n, err := conn.Read(buf) 110 | if err != nil { 111 | return 112 | } 113 | println("Read=",n) 114 | 115 | recv := &msg.LS2U_LoginResult{} 116 | err = proto.Unmarshal(buf[4:n], recv) 117 | if err != nil { 118 | 119 | } 120 | fmt.Println("Result=",recv.GetResult()) 121 | fmt.Println("Gametoken=",recv.GetGametoken()) 122 | */ 123 | /* 124 | // 进行编码 125 | data, err := proto.Marshal(test) 126 | if err != nil { 127 | log.Fatal("marshaling error: ", err) 128 | } 129 | m := make([]byte, 4+len(data)) 130 | binary.BigEndian.PutUint16(m, uint16(len(data))) 131 | copy(m[4:], data) 132 | // 发送消息 133 | conn.Write(m) 134 | 135 | buf := make([]byte, 1024) 136 | // 接收消息 137 | n, err := conn.Read(buf) 138 | if err != nil { 139 | log.Fatal("marshaling error: ", err) 140 | } 141 | 142 | recv := &msg.LS2U_LoginResult{} 143 | err = proto.Unmarshal(buf[4:n], recv) 144 | if err != nil { 145 | 146 | } 147 | fmt.Println(recv.GetResult()) 148 | fmt.Println(recv.GetGametoken()) 149 | */ 150 | 151 | } 152 | 153 | type Hello struct { 154 | Name string 155 | } -------------------------------------------------------------------------------- /server/src/server/Test/t.go: -------------------------------------------------------------------------------- 1 | //package Test 2 | 3 | //import "reflect" 4 | 5 | package main 6 | 7 | import ( 8 | "fmt" 9 | _ "reflect" 10 | "time" 11 | "math/rand" 12 | "net/http" 13 | "io/ioutil" 14 | "encoding/json" 15 | ) 16 | 17 | type Skills interface { 18 | reading() 19 | running() 20 | } 21 | 22 | type Student struct { 23 | Name string 24 | Age int 25 | } 26 | 27 | func (self Student) runing() { 28 | fmt.Printf("%s is running\n", self.Name) 29 | } 30 | func (self Student) reading() { 31 | fmt.Printf("%s is reading\n", self.Name) 32 | } 33 | 34 | //生成随机字符串 35 | func GetRandomString(strlen int) string { 36 | str := "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" 37 | bytes := []byte(str) 38 | var result []byte 39 | r := rand.New(rand.NewSource(time.Now().UnixNano())) 40 | 41 | for i := 0; i < strlen; i++ { 42 | result = append(result, bytes[r.Intn(len(bytes))]) 43 | } 44 | return string(result) 45 | } 46 | func main() { 47 | /* stu1 := Student{Name:"wd",Age:22} 48 | inf := new(Skills) 49 | stu_type := reflect.TypeOf(stu1) 50 | inf_type := reflect.TypeOf(inf).Elem() // 特别说明,引用类型需要用Elem()获取指针所指的对象类型 51 | fmt.Println(stu_type.String()) //main.Student 52 | fmt.Println(stu_type.Name()) //Student 53 | fmt.Println(stu_type.PkgPath()) //main 54 | fmt.Println(stu_type.Kind()) //struct 55 | fmt.Println(stu_type.Size()) //24 56 | fmt.Println(inf_type.NumMethod()) //2 57 | fmt.Println(inf_type.Method(0),inf_type.Method(0).Name) // {reading main func() 0} reading 58 | fmt.Println(inf_type.MethodByName("reading")) //{reading main func() 0} true 59 | */ 60 | /* 61 | str := "abc123" 62 | 63 | //方法一 64 | data := []byte(str) 65 | has := md5.Sum(data) 66 | md5str1 := fmt.Sprintf("%x", has) //将[]byte转成16进制 67 | 68 | fmt.Println(md5str1) 69 | fmt.Println(GetRandomString(10)) 70 | */ 71 | 72 | /* 73 | data := make(map[int] string) 74 | data[1]= "a" 75 | data[2]= "b" 76 | data[3]= "c" 77 | data[4]= "d" 78 | 79 | 80 | if _, ok := data[4]; ok { 81 | fmt.Println("r=",data[4]) 82 | } 83 | 84 | */ 85 | /* 86 | type blockMachine struct { 87 | Index int 88 | Timestamp string 89 | PlayerID uint 90 | DataID int 91 | Price int //单价 92 | Count int //数量 93 | Hash string 94 | PrevHash string 95 | } 96 | 97 | 98 | db, err := gorm.Open("mysql", "root:123@tcp(localhost:3306)/blockchain?parseTime=true") 99 | defer db.Close() 100 | if err != nil { 101 | panic("connect db error") 102 | } 103 | defer db.Close() 104 | */ 105 | /* 106 | //读矿机连数据 107 | var list []blockMachine 108 | 109 | db.Table("block_machines").Select("index,timestamp,player_id,data_id,price,count,hash,prev_hash").Scan(&list) 110 | println(list) 111 | */ 112 | //fmt.Sprintf("a %s", "string") 113 | 114 | //矿机数据 (列表) 115 | type worker struct { 116 | //位置 0 矿机名称 117 | //位置 1 矿机算力 118 | //位置 2 过去1小时算力 119 | //位置 3 过去1小时过期拒绝数 120 | //位置 4 过去24小时算力 121 | //位置 5 过去24小时过期拒绝数 122 | //位置 6 最近提交Share时间 123 | //位置 7 扩展字段 124 | } 125 | 126 | //历史收益 (字典) 127 | type value_workers struct { 128 | 129 | //矿机 1 历史收益 130 | //矿机 2 历史收益 131 | } 132 | type Hashratehistory struct { 133 | Time string 134 | value float32 135 | } 136 | type Message struct { 137 | //Balance float32 // 余额 138 | //Paid float32 //已支付工资 139 | //Payout_history float32 //支付记录 140 | //Value float32 //总收益 141 | Value_last_day float32 //过去24小时收益 142 | //Stale_hashes_rejected_last_day float32 //过去24小时过期拒绝数 143 | //Hashes_last_day float32 //过去24小时算力 144 | //Hashrate float32 //实时算力 145 | Hashrate_history string // 历史算力(过去24小时) 146 | //Worker_length float32 //矿机总数 147 | //Worker_length_online float32 //在线矿机数 148 | //Workers float32 //矿机数据 (列表) 149 | //Value_workers float32 //历史收益 (字典) 150 | } 151 | 152 | resp, err := http.Get("http://api.f2pool.com/bitcoin/user") 153 | if err != nil { 154 | fmt.Println(err) 155 | } 156 | defer resp.Body.Close() 157 | body, err := ioutil.ReadAll(resp.Body) 158 | if err != nil { 159 | return 160 | } 161 | /*message := Message{} 162 | err = json.Unmarshal(body,&message) 163 | fmt.Println(string(body)) 164 | fmt.Println(message.Hashrate_history) 165 | */ 166 | /* 167 | var f interface{} 168 | json.Unmarshal(body, &f) 169 | 170 | m := f.(map[string]interface{}) 171 | fmt.Println(m["hashrate_history"]) // 读取 json 内容 172 | */ 173 | //json str 转map 174 | var dat map[string]interface{} 175 | if err := json.Unmarshal(body, &dat); err == nil { 176 | fmt.Println(dat["hashrate_history"]) 177 | } 178 | } 179 | -------------------------------------------------------------------------------- /server/src/server/Test/t1.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "github.com/opesun/goquery" 5 | "fmt" 6 | "strings" 7 | "strconv" 8 | "github.com/name5566/leaf/timer" 9 | "time" 10 | "sort" 11 | ) 12 | 13 | 14 | //%%游戏币排名 15 | type RankInfo struct { 16 | //角色信息 17 | playerID uint //玩家ID 18 | name string //玩家名字 19 | style uint32 //外形头像 20 | value float32 //数据 21 | noID uint32 //排名 22 | } 23 | 24 | type Person struct { 25 | Name string 26 | Age int 27 | } 28 | 29 | type Persons []Person 30 | 31 | func (s Persons) Len() int { return len(s) } 32 | func (s Persons) Less(i, j int) bool { return s[i].Age < s[j].Age } 33 | func (s Persons) Swap(i, j int) { s[i], s[j] = s[j], s[i] } 34 | 35 | func main() { 36 | /*conn, err := net.Dial("tcp", "127.0.0.1:3563") 37 | if err != nil { 38 | panic(err) 39 | } 40 | //data := []byte(`{ 41 | // "Hello": { 42 | // "Name": "炒在工" 43 | // } 44 | //}`) 45 | 46 | test := &msg.U2LS_Login{ 47 | SdkAccount: *proto.String("SdkAccount"), 48 | SdkClientId:*proto.String("SdkClientId"), 49 | SdkAccessToken:*proto.String("SdkAccessToken"), 50 | } 51 | 52 | data, err := proto.Marshal(test) 53 | if err != nil { 54 | fmt.Println("marshaling error: ", err) 55 | } 56 | 57 | // len + data 58 | len := 4+ len(data) 59 | m := make([]byte, len) 60 | 61 | // 默认使用大端序 62 | binary.BigEndian.PutUint16(m, uint16(len)+2) 63 | binary.BigEndian.PutUint16(m[2:], 0) 64 | 65 | copy(m[4:], data) 66 | 67 | // 发送消息 68 | conn.Write(m) 69 | 70 | m1 := make([] byte, 1024) 71 | len1, err := conn.Read(m1) 72 | fmt.Print(len1,string(m1)) 73 | */ 74 | //chain.Init() 75 | //chain.WriteBlockMachine(uint(1001245), 12) 76 | 77 | /* 78 | //map 序列化为json 79 | type value_workers struct { 80 | 81 | name string 82 | dic map[string]string 83 | } 84 | 85 | var p2 *value_workers = &value_workers{name:"abcd"} 86 | 87 | var m map[string]string = make(map[string]string) 88 | m["Go"] = "No.1" 89 | m["Java"] = "No.2" 90 | m["C"] = "No.3" 91 | p2.dic = m 92 | if bs, err := json.Marshal(p2); err != nil { 93 | panic(err) 94 | } else { 95 | //result --> {"C":"No.3","Go":"No.1","Java":"No.2"} 96 | fmt.Println(string(bs)) 97 | } 98 | */ 99 | 100 | /* 101 | jsonStr := `{ 102 | "hashes_last_hour": 0, 103 | "worker_length": 0, 104 | "balance": 0.000062923771232195, 105 | "stale_hashes_rejected_last_day": 0, 106 | "paid": 0, 107 | "hashrate": 0, 108 | "last": {}, 109 | "hashrate_history": { 110 | "2018-07-30T17:30:00Z": 0, 111 | "2018-07-30T19:30:00Z": 0, 112 | "2018-07-31T02:30:00Z": 0 113 | }, 114 | "hashes_last_day": 0, 115 | "payout_history": [], 116 | "stale_hashes_rejected_last_hour": 0, 117 | "value": 0.000062923771232195, 118 | "value_last_day": 0, 119 | "workers": [], 120 | "worker_length_online": 0 121 | }` 122 | 123 | 124 | //json str 转map 125 | var dat map[string]interface{} 126 | if err := json.Unmarshal([]byte(jsonStr), &dat); err == nil { 127 | fmt.Println("==============json str 转map=======================") 128 | //fmt.Println(dat) 129 | fmt.Println(dat["balance"]) 130 | } 131 | */ 132 | 133 | 134 | var url = "https://www.antpool.com/earnComparison.htm" 135 | p, err := goquery.ParseUrl(url) 136 | if err != nil { 137 | panic(err) 138 | } else { 139 | t := p.Find("span").Text() 140 | startpos :=strings.Index(t, "BTC:0.") 141 | endpos :=strings.Index(t, "BCH:0.") 142 | 143 | btcStr := t[startpos+4:endpos] 144 | vtc, _ := strconv.ParseFloat(btcStr, 32) 145 | fmt.Println(vtc) 146 | //for i := 0; i < t.Length(); i++ { 147 | // d := t.Eq(i).Attr("href") 148 | // fmt.Println(d) 149 | //} 150 | } 151 | 152 | var a uint 153 | a= 1 154 | println("a=", a << 28) 155 | 156 | /* 157 | v := 3.1415926535 158 | s1 := strconv.FormatFloat(v, 'f', -1, 64) 159 | println("s1:",s1) 160 | 161 | aChan := make(chan int, 1) 162 | ticker := time.NewTicker(time.Minute * 1) 163 | go func() { 164 | for { 165 | select { 166 | case <-ticker.C: 167 | fmt.Printf("ticked at %v\n", time.Now()) 168 | } 169 | } 170 | 171 | }() 172 | //阻塞主线程 173 | <-aChan 174 | 175 | */ 176 | 177 | 178 | 179 | p1 := []Person{Person{"Lily", 20}, Person{"Bing", 18}, Person{"Tom", 23}, Person{"Vivy", 16}, Person{"John", 18}} 180 | 181 | sort.Sort(sort.Reverse(Persons(p1))) //sort.Reverse 生成递减序列 182 | fmt.Println(p) 183 | 184 | 185 | 186 | } 187 | 188 | 189 | 190 | 191 | 192 | func ExampleCronExpr() { 193 | cronExpr, err := timer.NewCronExpr("0 * * * *") 194 | if err != nil { 195 | return 196 | } 197 | 198 | fmt.Println(cronExpr.Next(time.Date( 199 | 2000, 1, 1, 200 | 20, 10, 5, 201 | 0, time.UTC, 202 | ))) 203 | 204 | // Output: 205 | // 2000-01-01 21:00:00 +0000 UTC 206 | } -------------------------------------------------------------------------------- /server/src/server/Test/testgorm.go: -------------------------------------------------------------------------------- 1 | package main 2 | import ( 3 | _"fmt" 4 | "github.com/jinzhu/gorm" 5 | _ "github.com/jinzhu/gorm/dialects/mysql" 6 | 7 | ) 8 | 9 | func main() { 10 | 11 | Test() 12 | } 13 | 14 | 15 | //type Player struct { 16 | // ID uint 17 | // //初始化之后自己写函数读取BaseInfo和CardsInfo吧,保存信息也一样。 18 | // //本来想用ORM的级联发现各种不习惯。还是自己写代码控制下逻辑好了,也多不了几行代码。 19 | // playerBaseInfo PlayerBaseInfo 20 | // cards_map map[uint]PlayersCards // key is cardID , value is PlayersCards info 21 | // 22 | // //...其他信息 23 | //} 24 | 25 | type PlayerBaseInfo struct { 26 | PlayerID uint `gorm:"primary_key"` 27 | Name string `gorm:"not null;unique"` 28 | Style uint`gorm:"default:'0'"` 29 | AppCoins uint`gorm:"default:'0'"` 30 | ComputePower uint`gorm:"default:'0'"` 31 | } 32 | 33 | /* 34 | type PlayersCards struct { 35 | ID uint 36 | PlayerID uint `gorm:"unique_index:idx_name_code"` 37 | CardID uint `gorm:"unique_index:idx_name_code"` 38 | Amount uint`gorm:"default:'0'"` 39 | Level uint `gorm:"default:'1'"` 40 | } 41 | 42 | type Card struct { 43 | ID uint `gorm:"primary_key"` 44 | Name string `gorm:"not null"` // e.a. Knights of the Round Table 45 | } 46 | */ 47 | 48 | type Account struct { 49 | ID uint `gorm:"primary_key"` 50 | Account string `gorm:"not null;unique"` 51 | SdkAccount string `protobuf:"bytes,1,opt,name=SdkAccount,proto3" json:"SdkAccount,omitempty"` 52 | SdkClientID string `protobuf:"bytes,2,opt,name=SdkClientID,proto3" json:"SdkClientID,omitempty"` 53 | SdkAccessToken string `protobuf:"bytes,3,opt,name=SdkAccessToken,proto3" json:"SdkAccessToken,omitempty"` 54 | ChannelID uint32 `protobuf:"varint,4,opt,name=ChannelID,proto3" json:"ChannelID,omitempty"` 55 | Imei string `protobuf:"bytes,6,opt,name=Imei,proto3" json:"Imei,omitempty"` 56 | GameVer uint32 `protobuf:"varint,11,opt,name=Game_ver,json=GameVer,proto3" json:"Game_ver,omitempty"` 57 | Extra string `protobuf:"bytes,13,opt,name=Extra,proto3" json:"Extra,omitempty"` 58 | 59 | Phone string `gorm:"default:'0'` 60 | Createtime int64 `gorm:"default:'0'"` 61 | 62 | Name string `gorm:"not null;unique"` 63 | Style uint32 `gorm:"default:'0'"` 64 | AppCoins float32 `gorm:"default:'0'"` 65 | ComputePower float32 `gorm:"default:'0'"` 66 | Logintime int64 //登录时间 67 | Offflinetime int64 //离线时间 68 | Btc float32 `gorm:"default:'0'"` 69 | } 70 | 71 | type MineMachine struct { 72 | ID int `gorm:"primary_key"` //矿机实例ID 73 | DataID int //矿机配置ID 74 | PlayerID uint //玩家ID 75 | Location int //矿机存放位置,0:仓库,其它:矿场点编号 76 | StartTime int64 //挖矿开始时间 77 | EndTime int64 //挖矿结束时间 78 | } 79 | 80 | type BlockMachine struct { 81 | Index int 82 | Timestamp string 83 | PlayerID uint 84 | DataID int 85 | Price float32 //单价 86 | Count int //数量 87 | Hash string 88 | PrevHash string 89 | } 90 | 91 | func Test() { 92 | db, err := gorm.Open("mysql", "root:123@tcp(localhost:3306)/blockchain?parseTime=true") 93 | defer db.Close() 94 | if err != nil { 95 | panic("connect db error") 96 | } 97 | defer db.Close() 98 | db.DropTableIfExists(&Account{},&MineMachine{},&BlockMachine{}) 99 | //&Card{}, &PlayersCards{},&PlayerBase{}) 100 | //// 101 | db.AutoMigrate(&Account{}) 102 | db.AutoMigrate(&MineMachine{}) 103 | db.AutoMigrate(&BlockMachine{}) 104 | //db.AutoMigrate(&Card{}) 105 | //db.AutoMigrate(&PlayersCards{}) 106 | /* 107 | block := BlockMachine{PlayerID:1} 108 | err = db.Save(&block).Error 109 | 110 | block = BlockMachine{PlayerID:2} 111 | err = db.Save(&block).Err 112 | /* 113 | playersCard1 := PlayersCards{PlayerID:1,CardID:1,Amount:20} 114 | err = db.Save(&playersCard1).Error 115 | if nil != err { 116 | fmt.Println("create 1 error:",err) 117 | } 118 | 119 | playersCard2 := PlayersCards{PlayerID:1,CardID:2,Amount:65} 120 | err = db.Save(&playersCard2).Error 121 | if nil != err { 122 | fmt.Println("create 2 error:",err) 123 | } 124 | 125 | playersCard1.Amount = 0 126 | err = db.Save(playersCard1).Error 127 | if nil != err { 128 | fmt.Println("Update 1 error:",err) 129 | } 130 | 131 | playersCard3 := PlayersCards{PlayerID:2,CardID:3,Amount:615} 132 | err = db.Save(&playersCard3).Error 133 | if nil != err { 134 | fmt.Println("create 3 error:",err) 135 | } 136 | 137 | player1 := PlayerBaseInfo{ID:2,Name:"Mike11221"} 138 | err = db.Save(&player1).Error 139 | if nil != err { 140 | fmt.Println("create 3 error:",err) 141 | } 142 | 143 | 144 | //err2 := db.Create(&Player{ 145 | // Name: "Mike", 146 | //}).Error 147 | //if nil != err2 { 148 | // fmt.Println("already exist:",err2) 149 | //} 150 | 151 | 152 | //query player Mike 153 | var player PlayerBaseInfo 154 | err = db.Where("Name = ?", "Mike11221"). Limit(1).Find(&player).Error 155 | if nil != err { 156 | fmt.Println(err) 157 | } 158 | fmt.Println(player) 159 | */ 160 | 161 | type blockMachine struct { 162 | Index int 163 | Timestamp string 164 | PlayerID uint 165 | DataID int 166 | Price int //单价 167 | Count int //数量 168 | Hash string 169 | PrevHash string 170 | } 171 | 172 | //读矿机连数据 173 | var list []blockMachine 174 | 175 | db.Table("block_machines").Select("*").Scan(&list) 176 | //rows, err := db.Table("block_machines").Select("*").Rows() 177 | for _, r := range list { 178 | println(r.PlayerID,r.Index) 179 | } 180 | println(list) 181 | } 182 | 183 | -------------------------------------------------------------------------------- /server/src/server/Test/testmysql.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "database/sql" 5 | "fmt" 6 | _ "github.com/go-sql-driver/mysql" 7 | ) 8 | 9 | func main() { 10 | 11 | db, _ := sql.Open("mysql", "root:123@tcp(localhost:3306)/blockchain?parseTime=true") 12 | 13 | sqlStr := "SELECT id,`name`,style,app_coins,(SELECT count(DISTINCT app_coins) FROM accounts AS b WHERE a.app_coins 0 { 49 | return 50 | } 51 | 52 | //没有才初始化 53 | t := time.Now().Unix() 54 | genesisBlock := BlockMachine{} 55 | genesisBlock = BlockMachine{0, t, 0, 0, 0, 0, calculateHash(genesisBlock), ""} 56 | //spew.Dump(genesisBlock) 57 | 58 | mutex.Lock() 59 | DepotChain = append(DepotChain, genesisBlock) 60 | mutex.Unlock() 61 | 62 | 63 | 64 | } 65 | func GetBlockMachinechain(playerID uint) { 66 | var playerDepotChain []BlockMachine 67 | for _, r := range DepotChain { 68 | playerDepotChain = append(playerDepotChain, r) 69 | } 70 | } 71 | 72 | //得到某个矿机的库存量 73 | func GetRepertory(productID int, maxCount int) int { 74 | value := 0 75 | for _, r := range DepotChain { 76 | if (r.DataID == productID) { 77 | value ++ 78 | } 79 | } 80 | return (maxCount - value) 81 | } 82 | 83 | func WriteBlockMachine(playerID uint, dataID int, price float32, count int) BlockMachine { 84 | 85 | mutex.Lock() 86 | newBlock := generateBlock(DepotChain[len(DepotChain)-1], playerID, dataID, price, count) 87 | mutex.Unlock() 88 | 89 | if isBlockValid(newBlock, DepotChain[len(DepotChain)-1]) { 90 | DepotChain = append(DepotChain, newBlock) 91 | //spew.Dump(DepotChain) 92 | 93 | db := mysql.MysqlDB() 94 | 95 | stmt, err := db.Prepare("insert block_machines values(?,?,?,?,?,?,?,?)") 96 | if nil == err { 97 | _, err = stmt.Exec(newBlock.Index, newBlock.Timestamp, newBlock.PlayerID, newBlock.DataID, newBlock.Price, newBlock.Count, newBlock.Hash, newBlock.PrevHash) 98 | } 99 | if nil != err { 100 | log.Error("create WriteBlockMachine error:", err) 101 | } 102 | } 103 | 104 | return newBlock 105 | 106 | } 107 | 108 | // make sure block is valid by checking index, and comparing the hash of the previous block 109 | func isBlockValid(newBlock, oldBlock BlockMachine) bool { 110 | if oldBlock.Index+1 != newBlock.Index { 111 | return false 112 | } 113 | 114 | if oldBlock.Hash != newBlock.PrevHash { 115 | return false 116 | } 117 | 118 | if calculateHash(newBlock) != newBlock.Hash { 119 | return false 120 | } 121 | 122 | return true 123 | } 124 | 125 | // SHA256 hasing 126 | func calculateHash(block BlockMachine) string { 127 | record := strconv.Itoa(block.Index) + string(block.Timestamp) + string(block.PlayerID) + string(block.DataID) + block.PrevHash 128 | h := sha256.New() 129 | h.Write([]byte(record)) 130 | hashed := h.Sum(nil) 131 | return hex.EncodeToString(hashed) 132 | } 133 | 134 | // create a new block using previous block's hash 135 | func generateBlock(oldBlock BlockMachine, playerID uint, dataID int, price float32, count int) BlockMachine { 136 | 137 | var newBlock BlockMachine 138 | t := time.Now().Unix() 139 | newBlock.Index = oldBlock.Index + 1 140 | newBlock.Timestamp = t 141 | newBlock.PlayerID = playerID 142 | newBlock.DataID = dataID 143 | newBlock.Price = price 144 | newBlock.Count = count 145 | newBlock.PrevHash = oldBlock.Hash 146 | newBlock.Hash = calculateHash(newBlock) 147 | 148 | return newBlock 149 | } 150 | 151 | //当前PPS+理论每天收益(1TH/s) 152 | func UpdatePeerDayBtc() { 153 | 154 | var url = "https://www.antpool.com/earnComparison.htm" 155 | p, err := goquery.ParseUrl(url) 156 | if err != nil { 157 | panic(err) 158 | } else { 159 | t := p.Find("span").Text() 160 | startpos := strings.Index(t, "BTC:0.") 161 | endpos := strings.Index(t, "BCH:0.") 162 | 163 | btcStr := t[startpos+4 : endpos] 164 | vtc, _ := strconv.ParseFloat(btcStr, 32) 165 | PeerDayBtc = float32(vtc) 166 | log.Release("PeerDayBtc:%v", strconv.FormatFloat(vtc, 'f', -1, 32)) 167 | fmt.Println("PeerDayBtc:%v",strconv.FormatFloat(vtc, 'f', -1, 32)) 168 | } 169 | } 170 | 171 | //每分钟更新 172 | func OnTickMinute() { 173 | ticker := time.NewTicker(time.Minute * 1) 174 | go func() { 175 | for { 176 | select { 177 | case <-ticker.C: 178 | //fmt.Printf("ticked at %v\n", time.Now()) 179 | //UpdatePeerDayBtc() 180 | } 181 | } 182 | 183 | }() 184 | } 185 | 186 | //每小时更新 187 | func OnTickHour() { 188 | ticker := time.NewTicker(time.Hour * 1) 189 | go func() { 190 | for { 191 | select { 192 | case <-ticker.C: 193 | mysql.PingDB() 194 | 195 | UpdatePeerDayBtc() 196 | } 197 | } 198 | }() 199 | } 200 | -------------------------------------------------------------------------------- /server/src/server/game/internal/chanrpc.go: -------------------------------------------------------------------------------- 1 | package internal 2 | 3 | import ( 4 | "github.com/name5566/leaf/gate" 5 | "server/msg" 6 | "github.com/name5566/leaf/log" 7 | "server/common" 8 | ) 9 | 10 | func init() { 11 | skeleton.RegisterChanRPC("NewAgent", rpcNewAgent) 12 | skeleton.RegisterChanRPC("CloseAgent", rpcCloseAgent) 13 | skeleton.RegisterChanRPC("UserLogin", rpcUserLogin) 14 | } 15 | 16 | func rpcNewAgent(args []interface{}) { 17 | //fmt.Println("rpcNewAgent") 18 | a := args[0].(gate.Agent) 19 | _ = a 20 | } 21 | 22 | func rpcCloseAgent(args []interface{}) { 23 | //fmt.Println("rpcCloseAgent:1") 24 | a := args[0].(gate.Agent) 25 | //fmt.Println("rpcCloseAgent:2") 26 | //fmt.Println("rpcCloseAgent:2 ->",a.UserData().(uint)) 27 | if a.UserData() != nil { 28 | playerID := a.UserData().(uint) 29 | player := playerID2Player[playerID] 30 | player.state = userGame 31 | player.onLogout() 32 | delete(playerID2Player,playerID) 33 | //fmt.Println("rpcCloseAgent:2->",playerID) 34 | } 35 | 36 | _ = a 37 | } 38 | 39 | func rpcUserLogin(args []interface{}) { 40 | agent := args[0].(gate.Agent) 41 | playerID := args[1].(uint) 42 | account := args[2].(string) 43 | channelID := args[3].(uint32) 44 | name := args[4].(string) 45 | style := args[5].(uint32) 46 | appCoins := args[6].(float32) 47 | computePower := args[7].(float32) 48 | btc := args[8].(float32) 49 | // network closed 50 | if agent.UserData() == nil { 51 | return 52 | } 53 | 54 | oldUser := playerID2Player[playerID] 55 | if oldUser != nil { 56 | m := &msg.S2U_LoginResult{Result: 3} 57 | agent.WriteMsg(m) 58 | oldUser.WriteMsg(m) 59 | agent.Close() 60 | oldUser.Close() 61 | log.Debug("acc %v login repeated", playerID) 62 | delete(playerID2Player,playerID) 63 | return 64 | } 65 | log.Debug("acc %v login", playerID) 66 | //fmt.Println("rpcUserLogin: ", playerID) 67 | // login 68 | //newPlayer := new(Player) 69 | newPlayer := &Player{} 70 | newPlayer.Agent = agent 71 | newPlayer.LinearContext = skeleton.NewLinearContext() 72 | newPlayer.state = userLogin 73 | //newPlayer.UserData().(*PlayerBaseInfo).PlayerID = playerID 74 | 75 | newPlayer.account = account 76 | newPlayer.channelID = channelID 77 | newPlayer.playerID = playerID 78 | newPlayer.name = name 79 | newPlayer.style = style 80 | newPlayer.appCoins = appCoins 81 | newPlayer.computePower = computePower 82 | newPlayer.logintime = common.GetTimestamp() 83 | newPlayer.btc = btc 84 | playerID2Player[playerID] = newPlayer 85 | newPlayer.login(playerID) 86 | } 87 | 88 | -------------------------------------------------------------------------------- /server/src/server/game/internal/command.go: -------------------------------------------------------------------------------- 1 | package internal 2 | 3 | import ( 4 | "fmt" 5 | "github.com/name5566/leaf/log" 6 | ) 7 | 8 | func init() { 9 | skeleton.RegisterCommand("echo", "echo user inputs", commandEcho) 10 | } 11 | 12 | func commandEcho(args []interface{}) interface{} { 13 | log.Release("commandEcho:%v", args) 14 | return fmt.Sprintf("commandEcho:%v", args[0]) 15 | } 16 | -------------------------------------------------------------------------------- /server/src/server/game/internal/handler.go: -------------------------------------------------------------------------------- 1 | package internal 2 | 3 | import ( 4 | "github.com/name5566/leaf/gate" 5 | "github.com/name5566/leaf/log" 6 | "reflect" 7 | "server/msg" 8 | "server/gamedata" 9 | 10 | "server/common" 11 | "fmt" 12 | ) 13 | 14 | func init() { 15 | handler(&msg.U2S_Chat{}, handleTosChat) 16 | handler(&msg.U2S_ShopList{}, handleU2S_ShopList) 17 | handler(&msg.U2S_Buy{}, handleU2S_Buy) 18 | handler(&msg.U2S_MineMachineList{}, handleU2S_MineMachineList) 19 | handler(&msg.U2S_Mining{}, handleU2S_Mining) 20 | handler(&msg.U2S_GatherMine{}, handleU2S_GatherMine) 21 | handler(&msg.U2S_MineList{}, handleU2S_MineList) 22 | handler(&msg.U2S_StopMining{}, handleU2S_StopMining) 23 | handler(&msg.U2S_ModifyPlayer{}, handleU2S_ModifyPlayer) 24 | handler(&msg.U2S_Rank{}, handleU2S_Rank) 25 | } 26 | 27 | func handler(m interface{}, h interface{}) { 28 | skeleton.RegisterChanRPC(reflect.TypeOf(m), h) 29 | } 30 | 31 | //把聊天 32 | func handleTosChat(args []interface{}) { 33 | // 收到的 Hello 消息 34 | m := args[0].(*msg.U2S_Chat) 35 | // 消息的发送者 36 | a := args[1].(gate.Agent) 37 | if a.UserData() == nil { 38 | return 39 | } 40 | 41 | //直接全服广播,暂不保存及字符验证处理 todo 42 | playerID := a.UserData().(uint) 43 | fromPlayer := playerID2Player[playerID] 44 | for _, p := range playerID2Player { 45 | p.WriteMsg(&msg.S2U_Chat{Name: fromPlayer.name, Style: fromPlayer.style, Content: m.Content,}) 46 | } 47 | 48 | } 49 | 50 | //请求商城列表 51 | func handleU2S_ShopList(args []interface{}) { 52 | //_ = args[0].(*msg.U2S_ShopList) 53 | a := args[1].(gate.Agent) 54 | if a.UserData() == nil { 55 | return 56 | } 57 | onShopList(a) 58 | } 59 | func onShopList(a gate.Agent) { 60 | sndmsg := &msg.S2U_ShopList{} 61 | shoplist := gamedata.ShopData 62 | for _, r := range shoplist { 63 | p1 := &msg.ShopInfo{ 64 | ProductID: int32(r.ProductID), 65 | Repertory: int32(GetRepertory(r.ProductID, r.Repertory)), 66 | Electric: r.Electric, 67 | ManageCost: r.ManageCost, 68 | Output: r.Output, 69 | Price: r.Price, 70 | } 71 | sndmsg.List = append(sndmsg.List, p1) 72 | } 73 | a.WriteMsg(sndmsg) 74 | } 75 | 76 | //购买矿机 77 | func handleU2S_Buy(args []interface{}) { 78 | m := args[0].(*msg.U2S_Buy) 79 | a := args[1].(gate.Agent) 80 | if a.UserData() == nil { 81 | return 82 | } 83 | 84 | productID := int(m.ProductID) 85 | count := int(m.Count) 86 | 87 | //检查数据 88 | record, exists := gamedata.GetShopByID(productID) 89 | if (!exists) { 90 | a.WriteMsg(&msg.S2U_BuyResult{ErrorCode: 1}) 91 | return 92 | } 93 | 94 | //数量 95 | freeCount := GetRepertory(productID, record.Repertory) 96 | if (count < 0) && (freeCount > 0) && (freeCount < count) { 97 | a.WriteMsg(&msg.S2U_BuyResult{ErrorCode: 2}) 98 | return 99 | } 100 | 101 | //检查游戏币是否足够 102 | var total float32 103 | total = record.Price * float32(count) 104 | playerID := a.UserData().(uint) 105 | player := playerID2Player[playerID] 106 | 107 | if (player.appCoins < total) { 108 | a.WriteMsg(&msg.S2U_BuyResult{ErrorCode: 3}) 109 | return 110 | } 111 | player.appCoins = player.appCoins - total 112 | //购买操作 113 | for i := 0; i < count; i++ { 114 | //写节点 115 | block := WriteBlockMachine(playerID, productID, record.Price, 1) 116 | 117 | //写仓库数据 118 | AddMineMachine(block.Index, productID, playerID, 0) 119 | } 120 | log.Debug("handleU2S_Buy productID:%v,count:%v", productID, count) 121 | 122 | //给发送者回应消息 123 | a.WriteMsg(&msg.S2U_BuyResult{ErrorCode: 0}) 124 | 125 | //更新完成数据 126 | player.send() 127 | onShopList(a) 128 | onMineMachineList(a, playerID) 129 | } 130 | 131 | //矿机列表 132 | func handleU2S_MineMachineList(args []interface{}) { 133 | 134 | //m := args[0].(*msg.U2S_MineMachineList) 135 | a := args[1].(gate.Agent) 136 | if a.UserData() == nil { 137 | return 138 | } 139 | 140 | playerID := a.UserData().(uint) 141 | onMineMachineList(a, playerID) 142 | } 143 | 144 | func onMineMachineList(a gate.Agent, playerID uint) { 145 | sndmsg := &msg.S2U_MineMachineList{} 146 | list := GetMineMachineByPlayerID(playerID) 147 | timestamp := common.GetTimestamp() 148 | 149 | for _, r := range list { 150 | 151 | if r.Location > 0 { 152 | runTime := timestamp - r.StartTime 153 | outputCoin, _ := calGatherMine(r) 154 | p1 := msg.MineMachine{ 155 | ID: int32(r.ID), 156 | ProductID: int32(r.DataID), 157 | Location: int32(r.Location), 158 | RunTime: runTime, 159 | EndTime: r.EndTime, 160 | OutputCoin: float32(outputCoin), 161 | } 162 | sndmsg.List = append(sndmsg.List, &p1) 163 | } else { 164 | p1 := msg.MineMachine{ 165 | ID: int32(r.ID), 166 | ProductID: int32(r.DataID), 167 | Location: 0, 168 | RunTime: 0, 169 | EndTime: 0, 170 | OutputCoin: 0.0, 171 | } 172 | sndmsg.List = append(sndmsg.List, &p1) 173 | } 174 | } 175 | a.WriteMsg(sndmsg) 176 | } 177 | 178 | //开始采矿 179 | func handleU2S_Mining(args []interface{}) { 180 | m := args[0].(*msg.U2S_Mining) 181 | a := args[1].(gate.Agent) 182 | if a.UserData() == nil { 183 | return 184 | } 185 | id := int(m.ID) 186 | playerID := a.UserData().(uint) 187 | location := int(m.Location) 188 | days := int(m.WillDay) 189 | 190 | if days < 1 { 191 | return 192 | } 193 | mineRecord, exist := gamedata.GetMineLocationByID(location) 194 | if !exist { 195 | return 196 | } 197 | if GetMineLocationFreeCount(location) < 1 { 198 | a.WriteMsg(&msg.S2U_MiningResult{ErrorCode: 1}) 199 | return 200 | } 201 | 202 | record, exists := GetMineMachine(id) 203 | if !exists { 204 | a.WriteMsg(&msg.S2U_MiningResult{ErrorCode: 2}) 205 | return 206 | } 207 | if record.PlayerID != playerID { 208 | a.WriteMsg(&msg.S2U_MiningResult{ErrorCode: 3}) 209 | return 210 | } 211 | 212 | //扣费处理 (电费+管理费)*天数 213 | value := (mineRecord.Electric + mineRecord.ManageCost) * float32(days) 214 | player := playerID2Player[playerID] 215 | if player.appCoins < value { 216 | a.WriteMsg(&msg.S2U_MiningResult{ErrorCode: 4}) 217 | return 218 | } 219 | 220 | player.appCoins = player.appCoins - value 221 | player.onSaveDB() 222 | player.send() 223 | 224 | record.StartTime = common.GetTimestamp() 225 | record.EndTime = common.GetTimestamp() + int64(days*86400) 226 | record.Location = location 227 | SetMineMachine(id, record) 228 | 229 | a.WriteMsg(&msg.S2U_MiningResult{ErrorCode: 0}) 230 | 231 | onMineMachineList(a, playerID) 232 | } 233 | 234 | //收集矿 235 | func handleU2S_GatherMine(args []interface{}) { 236 | 237 | m := args[0].(*msg.U2S_GatherMine) 238 | // 消息的发送者 239 | a := args[1].(gate.Agent) 240 | if a.UserData() == nil { 241 | return 242 | } 243 | 244 | id := int(m.ID) 245 | //locate := m.Location 246 | playerID := a.UserData().(uint) 247 | 248 | onGatherMine(a, id, playerID) 249 | } 250 | 251 | func onGatherMine(a gate.Agent, id int, playerID uint) int32 { 252 | record, exists := GetMineMachine(id) 253 | if !exists { 254 | return 1 255 | } 256 | if record.PlayerID != playerID { 257 | return 2 258 | } 259 | 260 | //计算收益 todo 261 | value, freeMinute := calGatherMine(record) 262 | 263 | //改矿机时间 264 | restartTime := common.GetTimestamp() - freeMinute 265 | record.StartTime = restartTime 266 | SetMineMachine(id, record) 267 | 268 | //改帐号的数据 269 | 270 | a.WriteMsg(&msg.S2U_GatherMine{ID: int32(id), Btc: value}) 271 | 272 | fmt.Println("Btc=", value) 273 | //更新消息 274 | player := playerID2Player[playerID] 275 | player.btc = player.btc + value 276 | player.onSaveDB() 277 | player.send() 278 | 279 | //刷新仓库 280 | onMineMachineList(a, playerID) 281 | return 0 282 | } 283 | 284 | //计算收益 285 | func calGatherMine(r MineMachine) (float32, int64) { 286 | if r.EndTime <= r.StartTime { 287 | return 0.0, 0 288 | } 289 | //收益公式:每天收益(1TH/s)*算力/24*已过小时数 290 | //计算收益, todo暂时定为1秒0.1个BTC 291 | record, exists := gamedata.GetShopByID(r.DataID) 292 | if !exists { 293 | return 0.0, 0 294 | } 295 | ghs := record.Ghs 296 | //为了测试方便,默认为1小时,正式使用前,请打开此处 297 | //useHours := (common.GetTimestamp() - r.StartTime) / 3600 298 | useHours := 1 299 | freeMinute := (common.GetTimestamp() - r.StartTime) % 3600 300 | //timeLen := float32(common.GetTimestamp() - r.StartTime) 301 | 302 | value := PeerDayBtc * ghs / 24 * float32(useHours) 303 | return value, freeMinute 304 | } 305 | 306 | //请求矿点信息 307 | func handleU2S_MineList(args []interface{}) { 308 | //m := args[0].(*msg.U2S_MineMachineList) 309 | a := args[1].(gate.Agent) 310 | if a.UserData() == nil { 311 | return 312 | } 313 | 314 | //矿点信息 315 | sndmsg1 := &msg.S2U_MineList{} 316 | minelist := gamedata.MineLocationData 317 | for _, r1 := range minelist { 318 | //todo 这里电费,管理费,产出率,可空余机位可调,待做 319 | p1 := &msg.MineInfo{ 320 | Location: int32(r1.Location), 321 | Electric: r1.Electric, 322 | Tip: r1.ManageCost, 323 | Ratio: r1.Output, 324 | Num: int32(GetMineLocationFreeCount(r1.Location)), 325 | } 326 | sndmsg1.List = append(sndmsg1.List, p1) 327 | } 328 | //fmt.Println("minelist=", sndmsg1) 329 | a.WriteMsg(sndmsg1) 330 | } 331 | 332 | //停止挖矿 333 | func handleU2S_StopMining(args []interface{}) { 334 | m := args[0].(*msg.U2S_StopMining) 335 | a := args[1].(gate.Agent) 336 | if a.UserData() == nil { 337 | return 338 | } 339 | 340 | id := int(m.ID) 341 | playerID := a.UserData().(uint) 342 | 343 | //验证数据 344 | record, exists := GetMineMachine(id) 345 | if !exists { 346 | a.WriteMsg(&msg.S2U_StopMiningResult{ErrorCode: 1}) 347 | return 348 | } 349 | if record.PlayerID != playerID { 350 | a.WriteMsg(&msg.S2U_StopMiningResult{ErrorCode: 2}) 351 | return 352 | } 353 | 354 | //给收益 355 | errorCode := onGatherMine(a, id, playerID) 356 | a.WriteMsg(&msg.S2U_StopMiningResult{ID: m.ID, ErrorCode: errorCode}) 357 | 358 | //放进仓库 359 | record.StartTime = common.GetTimestamp() 360 | record.Location = 0 361 | SetMineMachine(id, record) 362 | 363 | //刷新仓库 364 | onMineMachineList(a, playerID) 365 | } 366 | 367 | //修改玩家信息 368 | func handleU2S_ModifyPlayer(args []interface{}) { 369 | m := args[0].(*msg.U2S_ModifyPlayer) 370 | a := args[1].(gate.Agent) 371 | if a.UserData() == nil { 372 | return 373 | } 374 | playerID := a.UserData().(uint) 375 | 376 | //名字为空,默认改的是头像 377 | if len(m.Name) > 0 { 378 | //检查名字是否重名 379 | if checkNameIsExits(m.Name) { 380 | a.WriteMsg(&msg.S2U_ModifyPlayer{ErrorCode: 1}) 381 | return 382 | } 383 | } 384 | 385 | //更新消息 386 | player := playerID2Player[playerID] 387 | if len(m.Name) > 0 { 388 | player.name = m.Name 389 | } 390 | player.style = m.Style 391 | player.onSaveDB() 392 | a.WriteMsg(&msg.S2U_ModifyPlayer{ErrorCode: 0}) 393 | player.send() 394 | } 395 | 396 | //修改玩家信息 397 | func handleU2S_Rank(args []interface{}) { 398 | //m := args[0].(*msg.U2S_Rank) 399 | a := args[1].(gate.Agent) 400 | if a.UserData() == nil { 401 | return 402 | } 403 | playerID := a.UserData().(uint) 404 | 405 | //最大名次 406 | var maxRow uint32 407 | maxRow = 10 408 | 409 | //资产排行榜 410 | sndmsg := &msg.S2U_AppCoinRank{} 411 | for _, r := range AppRank { 412 | if r.noID > maxRow { 413 | continue 414 | } 415 | 416 | p := &msg.RankInfo{ 417 | NoID: r.noID, 418 | PlayerID: uint32(r.playerID), 419 | Name: r.name, 420 | Style: r.style, 421 | Value: r.value, 422 | } 423 | sndmsg.List = append(sndmsg.List, p) 424 | } 425 | //增加自己的排行榜数据 426 | r, exists := GetRankByPlayerID(playerID, 1) 427 | if exists { 428 | p2 := &msg.RankInfo{ 429 | NoID: r.noID, 430 | PlayerID: uint32(r.playerID), 431 | Name: r.name, 432 | Style: r.style, 433 | Value: r.value, 434 | } 435 | sndmsg.List = append(sndmsg.List, p2) 436 | } 437 | a.WriteMsg(sndmsg) 438 | 439 | fmt.Println("S2U_AppCoinRank:",sndmsg) 440 | //今日收益排行榜 441 | sndmsg2 := &msg.S2U_BtcRank{} 442 | for _, r := range BtcRank { 443 | if r.noID > maxRow { 444 | continue 445 | } 446 | p1 := &msg.RankInfo{ 447 | NoID: r.noID, 448 | PlayerID: uint32(r.playerID), 449 | Name: r.name, 450 | Style: r.style, 451 | Value: r.value, 452 | } 453 | sndmsg2.List = append(sndmsg2.List, p1) 454 | } 455 | 456 | //增加自己的排行榜数据 457 | r, exists = GetRankByPlayerID(playerID, 2) 458 | if exists { 459 | p := &msg.RankInfo{ 460 | NoID: r.noID, 461 | PlayerID: uint32(r.playerID), 462 | Name: r.name, 463 | Style: r.style, 464 | Value: r.value, 465 | } 466 | sndmsg2.List = append(sndmsg2.List, p) 467 | } 468 | a.WriteMsg(sndmsg2) 469 | fmt.Println("sndmsg2:",sndmsg2) 470 | } 471 | -------------------------------------------------------------------------------- /server/src/server/game/internal/minemachine.go: -------------------------------------------------------------------------------- 1 | package internal 2 | 3 | import ( 4 | "server/mysql" 5 | "github.com/name5566/leaf/log" 6 | "server/gamedata" 7 | ) 8 | 9 | //玩家矿机信息 10 | type MineMachine struct { 11 | ID int `gorm:"primary_key"` //矿机实例ID 12 | DataID int //矿机配置ID 13 | PlayerID uint //玩家ID 14 | Location int //矿机存放位置,0:仓库,其它:矿场点编号 15 | StartTime int64 //挖矿开始时间 16 | EndTime int64 //挖矿结束时间 17 | } 18 | 19 | var ( 20 | MineMachineList = make(map[int]MineMachine) 21 | ) 22 | 23 | func MineMachineInit() { 24 | //加载数据库 25 | db := mysql.MysqlDB() 26 | rows, err := db.Query("select `id`,`data_id`, `player_id`, `location`, `start_time`,`end_time` from `mine_machines`" + 27 | " where `location` <>0 order by `start_time` desc limit 8192") 28 | if nil == err { 29 | for rows.Next() { 30 | u := MineMachine{} 31 | err = rows.Scan(&u.ID, &u.DataID, &u.PlayerID, &u.Location, &u.StartTime, &u.EndTime) 32 | if nil == err { 33 | MineMachineList[u.ID] = u 34 | } 35 | } 36 | } 37 | if nil != err { 38 | log.Error("MineMachineInit error:", err) 39 | } 40 | } 41 | 42 | func MineMachineLoad(playerID uint) { 43 | //加载数据库 44 | db := mysql.MysqlDB() 45 | stmt, err := db.Prepare("select `id`,`data_id`, `player_id`, `location`, `start_time`,`end_time` from `mine_machines` WHERE `player_id`=?") 46 | if nil == err { 47 | rows, err := stmt.Query(playerID) 48 | if nil == err { 49 | for rows.Next() { 50 | u := MineMachine{} 51 | err = rows.Scan(&u.ID, &u.DataID, &u.PlayerID, &u.Location, &u.StartTime, &u.EndTime) 52 | if nil == err { 53 | MineMachineList[u.ID] = u 54 | } 55 | } 56 | } 57 | } 58 | 59 | if nil != err { 60 | log.Error("MineMachineInit error:", err) 61 | } 62 | } 63 | 64 | func GetMineMachine(id int) (MineMachine, bool) { 65 | record, exists := MineMachineList[id] 66 | return record, exists 67 | } 68 | 69 | func GetMineMachineByPlayerID(playerID uint) ([]MineMachine) { 70 | 71 | var list []MineMachine 72 | for _, record := range MineMachineList { 73 | if (record.PlayerID == playerID) { 74 | list = append(list, record) 75 | } 76 | } 77 | return list 78 | } 79 | 80 | func AddMineMachine(objectID int, dataID int, fromPlayerID uint, fromLocation int) bool { 81 | _, exists := MineMachineList[objectID] 82 | if (exists) { 83 | return false 84 | } 85 | 86 | p1 := &MineMachine{ 87 | ID: objectID, 88 | DataID: dataID, 89 | PlayerID: fromPlayerID, 90 | Location: fromLocation, 91 | } 92 | MineMachineList[objectID] = *p1 93 | 94 | db := mysql.MysqlDB() 95 | stmt, err := db.Prepare("insert mine_machines values(?,?,?,?,?,?)") 96 | if nil == err { 97 | _, err = stmt.Exec(p1.ID, p1.DataID, p1.PlayerID, p1.Location, p1.StartTime, p1.EndTime) 98 | } 99 | if nil != err { 100 | log.Error("create AddMineMachine error:", err) 101 | } 102 | 103 | return true 104 | } 105 | 106 | func SetMineMachine(objectID int, record MineMachine) { 107 | MineMachineList[objectID] = record 108 | 109 | db := mysql.MysqlDB() 110 | stmt, err := db.Prepare("update mine_machines set location=?,start_time=?,end_time=? where id =?") 111 | if nil == err { 112 | _, err = stmt.Exec(record.Location, record.StartTime, record.EndTime, record.ID) 113 | } 114 | if nil != err { 115 | log.Error("SetMineMachine error:", err) 116 | } 117 | } 118 | 119 | //清除玩家所属矿机 120 | func DeleteMineMachine(objectID int) { 121 | delete(MineMachineList, objectID) 122 | 123 | db := mysql.MysqlDB() 124 | stmt, err := db.Prepare("delete from table mine_machines where id =?") 125 | if nil == err { 126 | _, err = stmt.Exec(objectID) 127 | } 128 | 129 | if nil != err { 130 | log.Error("DeleteMineMachine error:", err) 131 | } 132 | } 133 | 134 | //得到某个矿点的空闲机位数 135 | func GetMineLocationFreeCount(location int) int { 136 | value := 0 137 | record, exists := gamedata.GetMineLocationByID(location) 138 | if !exists { 139 | return 0 140 | } 141 | 142 | for _, r := range MineMachineList { 143 | if (r.Location == location) { 144 | value ++ 145 | } 146 | } 147 | if record.Num <= value { 148 | return 0 149 | } 150 | return record.Num - value 151 | 152 | } 153 | -------------------------------------------------------------------------------- /server/src/server/game/internal/module.go: -------------------------------------------------------------------------------- 1 | package internal 2 | 3 | import ( 4 | "github.com/name5566/leaf/module" 5 | "server/base" 6 | "fmt" 7 | "github.com/name5566/leaf/log" 8 | ) 9 | 10 | var ( 11 | skeleton = base.NewSkeleton() 12 | ChanRPC = skeleton.ChanRPCServer 13 | ) 14 | 15 | type Module struct { 16 | *module.Skeleton 17 | } 18 | 19 | func (m *Module) OnInit() { 20 | m.Skeleton = skeleton 21 | InitGameTables() 22 | OnTickHour() 23 | 24 | log.Release("gameModule Ready ok") 25 | fmt.Println("gameModule Ready ok") 26 | } 27 | 28 | func InitGameTables() { 29 | UpdatePeerDayBtc() 30 | MineMachineInit() 31 | DepotChainInit() 32 | RankInit() 33 | } 34 | 35 | func (m *Module) OnDestroy() { 36 | 37 | } 38 | -------------------------------------------------------------------------------- /server/src/server/game/internal/player.go: -------------------------------------------------------------------------------- 1 | package internal 2 | 3 | import ( 4 | "github.com/name5566/leaf/gate" 5 | "github.com/name5566/leaf/timer" 6 | "github.com/name5566/leaf/go" 7 | "time" 8 | "server/msg" 9 | "server/mysql" 10 | "github.com/name5566/leaf/log" 11 | "fmt" 12 | ) 13 | 14 | var ( 15 | playerID2Player = make(map[uint]*Player) 16 | ) 17 | 18 | const ( 19 | userLogin = iota 20 | userLogout 21 | userGame 22 | ) 23 | 24 | type Player struct { 25 | gate.Agent 26 | *g.LinearContext 27 | state int 28 | saveDBTimer *timer.Timer 29 | 30 | //帐号信息 31 | account string 32 | channelID uint32 33 | playerID uint 34 | 35 | //角色信息 36 | name string 37 | style uint32 38 | appCoins float32 39 | computePower float32 40 | logintime int64 41 | offflinetime int64 42 | btc float32 43 | 44 | } 45 | 46 | func (player *Player) login(playerID uint) { 47 | skeleton.Go(func() { 48 | MineMachineLoad(playerID) 49 | }, func() { 50 | // network closed 51 | if player.state == userLogout { 52 | player.logout(playerID) 53 | return 54 | } 55 | 56 | // db error 57 | player.state = userGame 58 | 59 | player.onLogin() 60 | player.autoSaveDB() 61 | }) 62 | 63 | player.WriteMsg(&msg.S2U_LoginResult{Result: 0}) 64 | //log.Debug("%v:S2U_LoginResult{Result: 0} ", playerID) 65 | player.send() 66 | } 67 | //更新玩家数据 68 | func (player *Player) send() { 69 | sndMsg := msg.S2U_PlayerBase{ 70 | PlayerID: uint32(player.playerID), 71 | Account: player.account, 72 | Name: player.name, 73 | Style: player.style, 74 | AppCoins: player.appCoins, 75 | ComputePower: player.computePower, 76 | Btc: player.btc, 77 | } 78 | player.WriteMsg(&sndMsg) 79 | fmt.Println("S2U_PlayerBase ", sndMsg) 80 | } 81 | 82 | func (player *Player) isOffline() bool { 83 | return player.state == userLogout 84 | } 85 | 86 | func (player *Player) logout(playerID uint) { 87 | player.onLogout() 88 | } 89 | 90 | func (player *Player) autoSaveDB() { 91 | const duration = 5 * time.Minute 92 | // save 93 | player.saveDBTimer = skeleton.AfterFunc(duration, func() { 94 | 95 | player.Go(func() { 96 | player.onSaveDB() 97 | 98 | }, func() { 99 | player.autoSaveDB() 100 | }) 101 | }) 102 | } 103 | 104 | func (player *Player) onLogin() { 105 | 106 | } 107 | 108 | func (player *Player) onLogout() { 109 | log.Debug("player Logout %v", player.playerID) 110 | player.onSaveDB() 111 | } 112 | 113 | func (player *Player) onSaveDB() { 114 | db := mysql.MysqlDB() 115 | db.Exec("update accounts set name=?,style=?,app_coins=?,compute_power=?,btc=? where id =?", 116 | player.name, player.style, player.appCoins, player.computePower, player.btc, player.playerID) 117 | } 118 | 119 | //重名检查 120 | func checkNameIsExits(NewName string) bool { 121 | db := mysql.MysqlDB() 122 | stmt, err := db.Prepare("select `id` from `accounts` WHERE `name`=? limit 1") 123 | accountid := 0 124 | if nil == err { 125 | rows, err := stmt.Query(NewName) 126 | if nil == err { 127 | for rows.Next() { 128 | err = rows.Scan(&accountid) 129 | } 130 | } 131 | } 132 | if nil != err { 133 | log.Error("checkNameIsExits error:", err) 134 | return true 135 | } 136 | 137 | return accountid > 0 138 | } 139 | -------------------------------------------------------------------------------- /server/src/server/game/internal/rank.go: -------------------------------------------------------------------------------- 1 | package internal 2 | 3 | import ( 4 | "server/mysql" 5 | "github.com/name5566/leaf/log" 6 | ) 7 | 8 | //var ( 9 | // AppRank = make(map[uint]*rankInfo) 10 | // BtcRank = make(map[uint]*rankInfo) 11 | //) 12 | 13 | //%%游戏币排名 14 | type RankInfo struct { 15 | //角色信息 16 | playerID uint //玩家ID 17 | name string //玩家名字 18 | style uint32 //外形头像 19 | value float32 //数据 20 | noID uint32 //排名 21 | } 22 | 23 | var AppRank []RankInfo 24 | var BtcRank []RankInfo 25 | 26 | //从数据库加载 27 | func RankInit() { 28 | 29 | //游戏币 30 | db := mysql.MysqlDB() 31 | rows, err := db.Query("SELECT id,`name`,style,app_coins FROM accounts ORDER BY app_coins desc") 32 | //rows, err := db.Query("SELECT id,`name`,style,app_coins,(SELECT count(DISTINCT app_coins) " + 33 | // "FROM accounts AS b WHERE a.app_coins 12 { 28 | log.Debug("%v:S2U_LoginResult{Result: 1} ", m.SdkAccount) 29 | a.WriteMsg(&msg.S2U_LoginResult{Result: 1}) 30 | return 31 | } 32 | 33 | accountID := makeAccount(m.SdkAccount, m.ChannelID) 34 | accountInfo := getAccountByAccountID(accountID) 35 | //data := []byte(m.SdkAccessToken) 36 | //var hash = md5.Sum(data) 37 | //password := hex.EncodeToString(hash[:]) 38 | // 帐号不存在 39 | if nil == accountInfo { 40 | a.WriteMsg(&msg.S2U_LoginResult{Result: 4}) 41 | log.Debug("%v:S2U_LoginResult{Result: 4} ", m.SdkAccount) 42 | return 43 | } 44 | 45 | // match password 46 | if m.SdkAccessToken != accountInfo.SdkAccessToken { 47 | a.WriteMsg(&msg.S2U_LoginResult{Result: 1}) 48 | log.Debug("%v:S2U_LoginResult{Result: 1} ", m.SdkAccount) 49 | return 50 | 51 | } 52 | 53 | a.SetUserData(accountInfo.ID) 54 | game.ChanRPC.Go("UserLogin", a, accountInfo.ID, accountInfo.Account, accountInfo.ChannelID, accountInfo.Name, accountInfo.Style, 55 | accountInfo.AppCoins,accountInfo.ComputePower, accountInfo.Btc) 56 | log.Debug("%v:S2U_LoginResult{Result: 0} ", m.SdkAccount) 57 | //fmt.Println("%v:S2U_LoginResult{Result: 0} ", m.SdkAccount) 58 | } 59 | 60 | //生成帐号 帐号生成规则,SDK帐号+KEY+渠道编号 61 | func makeAccount(sdkAccount string, channelID int32) string { 62 | accountKey := "0Vf363e6Gd0yz41m" //游戏服的帐名key 63 | sdkAccount1 := strings.Replace(sdkAccount, "-", "*", 0) 64 | accountStr := sdkAccount1 + "-" + accountKey + "-" + string(channelID) 65 | newAccount := common.MD5(accountStr) 66 | return newAccount 67 | } 68 | 69 | //创建帐号信息 70 | func handleRegistAccount(args []interface{}) { 71 | m := args[0].(*msg.U2S_RegistAccount) 72 | a := args[1].(gate.Agent) 73 | 74 | //处理过滤字 todo 75 | 76 | //帐号长度异常 77 | if len(m.SdkAccount) < 2 || len(m.SdkAccount) > 12 { 78 | log.Debug("%v:G2U_RegistAccountResult{ErrorCode: 1} ", m.SdkAccount) 79 | a.WriteMsg(&msg.G2U_RegistAccountResult{ErrorCode: 1}) 80 | return 81 | } 82 | 83 | accountID := makeAccount(m.SdkAccount, m.ChannelID) 84 | 85 | accountInfo := getAccountByAccountID(accountID) 86 | if nil != accountInfo { 87 | log.Debug("%v:G2U_RegistAccountResult{ErrorCode: 5} ", m.SdkAccount) 88 | a.WriteMsg(&msg.G2U_RegistAccountResult{ErrorCode: 5}) 89 | return 90 | } 91 | 92 | //not having this account,creat account 93 | newAccount := RegistAccount(accountID, m) 94 | if nil != newAccount { 95 | log.Debug("%v:G2U_RegistAccountResult{ErrorCode: 0} ", m.SdkAccount) 96 | a.WriteMsg(&msg.G2U_RegistAccountResult{ErrorCode: 0}) 97 | a.SetUserData(newAccount.ID) 98 | game.ChanRPC.Go("UserLogin", a, newAccount.ID, newAccount.Account, newAccount.ChannelID, newAccount.Name, newAccount.Style, 99 | newAccount.AppCoins, newAccount.ComputePower,newAccount.Btc) 100 | 101 | } else { 102 | log.Release("%v:G2U_RegistAccountResult{ErrorCode: 2} ", m.SdkAccount) 103 | a.WriteMsg(&msg.G2U_RegistAccountResult{ErrorCode: 2}) 104 | } 105 | 106 | } 107 | -------------------------------------------------------------------------------- /server/src/server/login/internal/module.go: -------------------------------------------------------------------------------- 1 | package internal 2 | 3 | import ( 4 | 5 | "github.com/name5566/leaf/module" 6 | "server/base" 7 | "github.com/name5566/leaf/log" 8 | "fmt" 9 | ) 10 | 11 | var ( 12 | skeleton = base.NewSkeleton() 13 | ChanRPC = skeleton.ChanRPCServer 14 | ) 15 | 16 | type Module struct { 17 | *module.Skeleton 18 | } 19 | 20 | 21 | 22 | func (m *Module) OnInit() { 23 | m.Skeleton = skeleton 24 | InitLoginTables() 25 | log.Release("loginModule Ready ok") 26 | fmt.Println("loginModule Ready ok") 27 | } 28 | 29 | func InitLoginTables() { 30 | //db := mysql.MysqlDB() 31 | //db.AutoMigrate(&Account{}) 32 | } 33 | 34 | 35 | func (m *Module) OnDestroy() { 36 | 37 | } 38 | -------------------------------------------------------------------------------- /server/src/server/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "github.com/name5566/leaf" 5 | lconf "github.com/name5566/leaf/conf" 6 | "server/conf" 7 | "server/game" 8 | "server/gate" 9 | "server/login" 10 | "server/gamedata" 11 | "server/mysql" 12 | "fmt" 13 | ) 14 | 15 | func main() { 16 | fmt.Println("server start.... ") 17 | mysql.OpenDB() 18 | lconf.LogLevel = conf.Server.LogLevel 19 | lconf.LogPath = conf.Server.LogPath 20 | lconf.LogFlag = conf.LogFlag 21 | lconf.ConsolePort = conf.Server.ConsolePort 22 | lconf.ProfilePath = conf.Server.ProfilePath 23 | gamedata.LoadTables() 24 | InitDBTable() 25 | fmt.Println("start module...") 26 | leaf.Run( 27 | game.Module, 28 | gate.Module, 29 | login.Module, 30 | ) 31 | 32 | } 33 | 34 | func InitDBTable() { 35 | 36 | 37 | } -------------------------------------------------------------------------------- /server/src/server/msg/message.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go. DO NOT EDIT. 2 | // source: message.proto 3 | 4 | package msg 5 | 6 | /* 7 | 包名,通过protoc生成时go文件时 8 | */ 9 | 10 | import proto "github.com/golang/protobuf/proto" 11 | import fmt "fmt" 12 | import math "math" 13 | 14 | // Reference imports to suppress errors if they are not otherwise used. 15 | var _ = proto.Marshal 16 | var _ = fmt.Errorf 17 | var _ = math.Inf 18 | 19 | // This is a compile-time assertion to ensure that this generated file 20 | // is compatible with the proto package it is being compiled against. 21 | // A compilation error at this line likely means your copy of the 22 | // proto package needs to be updated. 23 | const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package 24 | 25 | // 帐号登录 26 | type U2S_Login struct { 27 | SdkAccount string `protobuf:"bytes,1,opt,name=SdkAccount,proto3" json:"SdkAccount,omitempty"` 28 | SdkClientID string `protobuf:"bytes,2,opt,name=SdkClientID,proto3" json:"SdkClientID,omitempty"` 29 | SdkAccessToken string `protobuf:"bytes,3,opt,name=SdkAccessToken,proto3" json:"SdkAccessToken,omitempty"` 30 | ChannelID int32 `protobuf:"varint,4,opt,name=ChannelID,proto3" json:"ChannelID,omitempty"` 31 | GameVer uint32 `protobuf:"varint,6,opt,name=GameVer,proto3" json:"GameVer,omitempty"` 32 | Extra string `protobuf:"bytes,7,opt,name=Extra,proto3" json:"Extra,omitempty"` 33 | XXX_NoUnkeyedLiteral struct{} `json:"-"` 34 | XXX_unrecognized []byte `json:"-"` 35 | XXX_sizecache int32 `json:"-"` 36 | } 37 | 38 | func (m *U2S_Login) Reset() { *m = U2S_Login{} } 39 | func (m *U2S_Login) String() string { return proto.CompactTextString(m) } 40 | func (*U2S_Login) ProtoMessage() {} 41 | func (*U2S_Login) Descriptor() ([]byte, []int) { 42 | return fileDescriptor_message_0cde66bc4e56949c, []int{0} 43 | } 44 | func (m *U2S_Login) XXX_Unmarshal(b []byte) error { 45 | return xxx_messageInfo_U2S_Login.Unmarshal(m, b) 46 | } 47 | func (m *U2S_Login) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 48 | return xxx_messageInfo_U2S_Login.Marshal(b, m, deterministic) 49 | } 50 | func (dst *U2S_Login) XXX_Merge(src proto.Message) { 51 | xxx_messageInfo_U2S_Login.Merge(dst, src) 52 | } 53 | func (m *U2S_Login) XXX_Size() int { 54 | return xxx_messageInfo_U2S_Login.Size(m) 55 | } 56 | func (m *U2S_Login) XXX_DiscardUnknown() { 57 | xxx_messageInfo_U2S_Login.DiscardUnknown(m) 58 | } 59 | 60 | var xxx_messageInfo_U2S_Login proto.InternalMessageInfo 61 | 62 | func (m *U2S_Login) GetSdkAccount() string { 63 | if m != nil { 64 | return m.SdkAccount 65 | } 66 | return "" 67 | } 68 | 69 | func (m *U2S_Login) GetSdkClientID() string { 70 | if m != nil { 71 | return m.SdkClientID 72 | } 73 | return "" 74 | } 75 | 76 | func (m *U2S_Login) GetSdkAccessToken() string { 77 | if m != nil { 78 | return m.SdkAccessToken 79 | } 80 | return "" 81 | } 82 | 83 | func (m *U2S_Login) GetChannelID() int32 { 84 | if m != nil { 85 | return m.ChannelID 86 | } 87 | return 0 88 | } 89 | 90 | func (m *U2S_Login) GetGameVer() uint32 { 91 | if m != nil { 92 | return m.GameVer 93 | } 94 | return 0 95 | } 96 | 97 | func (m *U2S_Login) GetExtra() string { 98 | if m != nil { 99 | return m.Extra 100 | } 101 | return "" 102 | } 103 | 104 | // 帐号登录反馈 105 | type S2U_LoginResult struct { 106 | Result uint32 `protobuf:"varint,1,opt,name=Result,proto3" json:"Result,omitempty"` 107 | Account string `protobuf:"bytes,2,opt,name=Account,proto3" json:"Account,omitempty"` 108 | Gametoken int64 `protobuf:"varint,3,opt,name=Gametoken,proto3" json:"Gametoken,omitempty"` 109 | Msg string `protobuf:"bytes,4,opt,name=Msg,proto3" json:"Msg,omitempty"` 110 | XXX_NoUnkeyedLiteral struct{} `json:"-"` 111 | XXX_unrecognized []byte `json:"-"` 112 | XXX_sizecache int32 `json:"-"` 113 | } 114 | 115 | func (m *S2U_LoginResult) Reset() { *m = S2U_LoginResult{} } 116 | func (m *S2U_LoginResult) String() string { return proto.CompactTextString(m) } 117 | func (*S2U_LoginResult) ProtoMessage() {} 118 | func (*S2U_LoginResult) Descriptor() ([]byte, []int) { 119 | return fileDescriptor_message_0cde66bc4e56949c, []int{1} 120 | } 121 | func (m *S2U_LoginResult) XXX_Unmarshal(b []byte) error { 122 | return xxx_messageInfo_S2U_LoginResult.Unmarshal(m, b) 123 | } 124 | func (m *S2U_LoginResult) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 125 | return xxx_messageInfo_S2U_LoginResult.Marshal(b, m, deterministic) 126 | } 127 | func (dst *S2U_LoginResult) XXX_Merge(src proto.Message) { 128 | xxx_messageInfo_S2U_LoginResult.Merge(dst, src) 129 | } 130 | func (m *S2U_LoginResult) XXX_Size() int { 131 | return xxx_messageInfo_S2U_LoginResult.Size(m) 132 | } 133 | func (m *S2U_LoginResult) XXX_DiscardUnknown() { 134 | xxx_messageInfo_S2U_LoginResult.DiscardUnknown(m) 135 | } 136 | 137 | var xxx_messageInfo_S2U_LoginResult proto.InternalMessageInfo 138 | 139 | func (m *S2U_LoginResult) GetResult() uint32 { 140 | if m != nil { 141 | return m.Result 142 | } 143 | return 0 144 | } 145 | 146 | func (m *S2U_LoginResult) GetAccount() string { 147 | if m != nil { 148 | return m.Account 149 | } 150 | return "" 151 | } 152 | 153 | func (m *S2U_LoginResult) GetGametoken() int64 { 154 | if m != nil { 155 | return m.Gametoken 156 | } 157 | return 0 158 | } 159 | 160 | func (m *S2U_LoginResult) GetMsg() string { 161 | if m != nil { 162 | return m.Msg 163 | } 164 | return "" 165 | } 166 | 167 | // 帐号注册 168 | type U2S_RegistAccount struct { 169 | SdkAccount string `protobuf:"bytes,1,opt,name=SdkAccount,proto3" json:"SdkAccount,omitempty"` 170 | SdkClientID string `protobuf:"bytes,2,opt,name=SdkClientID,proto3" json:"SdkClientID,omitempty"` 171 | SdkAccessToken string `protobuf:"bytes,3,opt,name=SdkAccessToken,proto3" json:"SdkAccessToken,omitempty"` 172 | ChannelID int32 `protobuf:"varint,4,opt,name=ChannelID,proto3" json:"ChannelID,omitempty"` 173 | Imei string `protobuf:"bytes,5,opt,name=Imei,proto3" json:"Imei,omitempty"` 174 | Phone string `protobuf:"bytes,6,opt,name=Phone,proto3" json:"Phone,omitempty"` 175 | Name string `protobuf:"bytes,7,opt,name=Name,proto3" json:"Name,omitempty"` 176 | Style uint32 `protobuf:"varint,8,opt,name=Style,proto3" json:"Style,omitempty"` 177 | XXX_NoUnkeyedLiteral struct{} `json:"-"` 178 | XXX_unrecognized []byte `json:"-"` 179 | XXX_sizecache int32 `json:"-"` 180 | } 181 | 182 | func (m *U2S_RegistAccount) Reset() { *m = U2S_RegistAccount{} } 183 | func (m *U2S_RegistAccount) String() string { return proto.CompactTextString(m) } 184 | func (*U2S_RegistAccount) ProtoMessage() {} 185 | func (*U2S_RegistAccount) Descriptor() ([]byte, []int) { 186 | return fileDescriptor_message_0cde66bc4e56949c, []int{2} 187 | } 188 | func (m *U2S_RegistAccount) XXX_Unmarshal(b []byte) error { 189 | return xxx_messageInfo_U2S_RegistAccount.Unmarshal(m, b) 190 | } 191 | func (m *U2S_RegistAccount) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 192 | return xxx_messageInfo_U2S_RegistAccount.Marshal(b, m, deterministic) 193 | } 194 | func (dst *U2S_RegistAccount) XXX_Merge(src proto.Message) { 195 | xxx_messageInfo_U2S_RegistAccount.Merge(dst, src) 196 | } 197 | func (m *U2S_RegistAccount) XXX_Size() int { 198 | return xxx_messageInfo_U2S_RegistAccount.Size(m) 199 | } 200 | func (m *U2S_RegistAccount) XXX_DiscardUnknown() { 201 | xxx_messageInfo_U2S_RegistAccount.DiscardUnknown(m) 202 | } 203 | 204 | var xxx_messageInfo_U2S_RegistAccount proto.InternalMessageInfo 205 | 206 | func (m *U2S_RegistAccount) GetSdkAccount() string { 207 | if m != nil { 208 | return m.SdkAccount 209 | } 210 | return "" 211 | } 212 | 213 | func (m *U2S_RegistAccount) GetSdkClientID() string { 214 | if m != nil { 215 | return m.SdkClientID 216 | } 217 | return "" 218 | } 219 | 220 | func (m *U2S_RegistAccount) GetSdkAccessToken() string { 221 | if m != nil { 222 | return m.SdkAccessToken 223 | } 224 | return "" 225 | } 226 | 227 | func (m *U2S_RegistAccount) GetChannelID() int32 { 228 | if m != nil { 229 | return m.ChannelID 230 | } 231 | return 0 232 | } 233 | 234 | func (m *U2S_RegistAccount) GetImei() string { 235 | if m != nil { 236 | return m.Imei 237 | } 238 | return "" 239 | } 240 | 241 | func (m *U2S_RegistAccount) GetPhone() string { 242 | if m != nil { 243 | return m.Phone 244 | } 245 | return "" 246 | } 247 | 248 | func (m *U2S_RegistAccount) GetName() string { 249 | if m != nil { 250 | return m.Name 251 | } 252 | return "" 253 | } 254 | 255 | func (m *U2S_RegistAccount) GetStyle() uint32 { 256 | if m != nil { 257 | return m.Style 258 | } 259 | return 0 260 | } 261 | 262 | // 帐号注册反馈 263 | type G2U_RegistAccountResult struct { 264 | ErrorCode int32 `protobuf:"varint,1,opt,name=ErrorCode,proto3" json:"ErrorCode,omitempty"` 265 | XXX_NoUnkeyedLiteral struct{} `json:"-"` 266 | XXX_unrecognized []byte `json:"-"` 267 | XXX_sizecache int32 `json:"-"` 268 | } 269 | 270 | func (m *G2U_RegistAccountResult) Reset() { *m = G2U_RegistAccountResult{} } 271 | func (m *G2U_RegistAccountResult) String() string { return proto.CompactTextString(m) } 272 | func (*G2U_RegistAccountResult) ProtoMessage() {} 273 | func (*G2U_RegistAccountResult) Descriptor() ([]byte, []int) { 274 | return fileDescriptor_message_0cde66bc4e56949c, []int{3} 275 | } 276 | func (m *G2U_RegistAccountResult) XXX_Unmarshal(b []byte) error { 277 | return xxx_messageInfo_G2U_RegistAccountResult.Unmarshal(m, b) 278 | } 279 | func (m *G2U_RegistAccountResult) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 280 | return xxx_messageInfo_G2U_RegistAccountResult.Marshal(b, m, deterministic) 281 | } 282 | func (dst *G2U_RegistAccountResult) XXX_Merge(src proto.Message) { 283 | xxx_messageInfo_G2U_RegistAccountResult.Merge(dst, src) 284 | } 285 | func (m *G2U_RegistAccountResult) XXX_Size() int { 286 | return xxx_messageInfo_G2U_RegistAccountResult.Size(m) 287 | } 288 | func (m *G2U_RegistAccountResult) XXX_DiscardUnknown() { 289 | xxx_messageInfo_G2U_RegistAccountResult.DiscardUnknown(m) 290 | } 291 | 292 | var xxx_messageInfo_G2U_RegistAccountResult proto.InternalMessageInfo 293 | 294 | func (m *G2U_RegistAccountResult) GetErrorCode() int32 { 295 | if m != nil { 296 | return m.ErrorCode 297 | } 298 | return 0 299 | } 300 | 301 | // 帐号信息 302 | type S2U_PlayerBase struct { 303 | PlayerID uint32 `protobuf:"varint,1,opt,name=PlayerID,proto3" json:"PlayerID,omitempty"` 304 | Account string `protobuf:"bytes,2,opt,name=Account,proto3" json:"Account,omitempty"` 305 | Name string `protobuf:"bytes,3,opt,name=Name,proto3" json:"Name,omitempty"` 306 | Style uint32 `protobuf:"varint,4,opt,name=Style,proto3" json:"Style,omitempty"` 307 | AppCoins float32 `protobuf:"fixed32,5,opt,name=AppCoins,proto3" json:"AppCoins,omitempty"` 308 | ComputePower float32 `protobuf:"fixed32,6,opt,name=ComputePower,proto3" json:"ComputePower,omitempty"` 309 | Btc float32 `protobuf:"fixed32,7,opt,name=Btc,proto3" json:"Btc,omitempty"` 310 | XXX_NoUnkeyedLiteral struct{} `json:"-"` 311 | XXX_unrecognized []byte `json:"-"` 312 | XXX_sizecache int32 `json:"-"` 313 | } 314 | 315 | func (m *S2U_PlayerBase) Reset() { *m = S2U_PlayerBase{} } 316 | func (m *S2U_PlayerBase) String() string { return proto.CompactTextString(m) } 317 | func (*S2U_PlayerBase) ProtoMessage() {} 318 | func (*S2U_PlayerBase) Descriptor() ([]byte, []int) { 319 | return fileDescriptor_message_0cde66bc4e56949c, []int{4} 320 | } 321 | func (m *S2U_PlayerBase) XXX_Unmarshal(b []byte) error { 322 | return xxx_messageInfo_S2U_PlayerBase.Unmarshal(m, b) 323 | } 324 | func (m *S2U_PlayerBase) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 325 | return xxx_messageInfo_S2U_PlayerBase.Marshal(b, m, deterministic) 326 | } 327 | func (dst *S2U_PlayerBase) XXX_Merge(src proto.Message) { 328 | xxx_messageInfo_S2U_PlayerBase.Merge(dst, src) 329 | } 330 | func (m *S2U_PlayerBase) XXX_Size() int { 331 | return xxx_messageInfo_S2U_PlayerBase.Size(m) 332 | } 333 | func (m *S2U_PlayerBase) XXX_DiscardUnknown() { 334 | xxx_messageInfo_S2U_PlayerBase.DiscardUnknown(m) 335 | } 336 | 337 | var xxx_messageInfo_S2U_PlayerBase proto.InternalMessageInfo 338 | 339 | func (m *S2U_PlayerBase) GetPlayerID() uint32 { 340 | if m != nil { 341 | return m.PlayerID 342 | } 343 | return 0 344 | } 345 | 346 | func (m *S2U_PlayerBase) GetAccount() string { 347 | if m != nil { 348 | return m.Account 349 | } 350 | return "" 351 | } 352 | 353 | func (m *S2U_PlayerBase) GetName() string { 354 | if m != nil { 355 | return m.Name 356 | } 357 | return "" 358 | } 359 | 360 | func (m *S2U_PlayerBase) GetStyle() uint32 { 361 | if m != nil { 362 | return m.Style 363 | } 364 | return 0 365 | } 366 | 367 | func (m *S2U_PlayerBase) GetAppCoins() float32 { 368 | if m != nil { 369 | return m.AppCoins 370 | } 371 | return 0 372 | } 373 | 374 | func (m *S2U_PlayerBase) GetComputePower() float32 { 375 | if m != nil { 376 | return m.ComputePower 377 | } 378 | return 0 379 | } 380 | 381 | func (m *S2U_PlayerBase) GetBtc() float32 { 382 | if m != nil { 383 | return m.Btc 384 | } 385 | return 0 386 | } 387 | 388 | // 公告 389 | type S2U_Notice struct { 390 | Type int32 `protobuf:"varint,1,opt,name=Type,proto3" json:"Type,omitempty"` 391 | Msg []byte `protobuf:"bytes,2,opt,name=Msg,proto3" json:"Msg,omitempty"` 392 | XXX_NoUnkeyedLiteral struct{} `json:"-"` 393 | XXX_unrecognized []byte `json:"-"` 394 | XXX_sizecache int32 `json:"-"` 395 | } 396 | 397 | func (m *S2U_Notice) Reset() { *m = S2U_Notice{} } 398 | func (m *S2U_Notice) String() string { return proto.CompactTextString(m) } 399 | func (*S2U_Notice) ProtoMessage() {} 400 | func (*S2U_Notice) Descriptor() ([]byte, []int) { 401 | return fileDescriptor_message_0cde66bc4e56949c, []int{5} 402 | } 403 | func (m *S2U_Notice) XXX_Unmarshal(b []byte) error { 404 | return xxx_messageInfo_S2U_Notice.Unmarshal(m, b) 405 | } 406 | func (m *S2U_Notice) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 407 | return xxx_messageInfo_S2U_Notice.Marshal(b, m, deterministic) 408 | } 409 | func (dst *S2U_Notice) XXX_Merge(src proto.Message) { 410 | xxx_messageInfo_S2U_Notice.Merge(dst, src) 411 | } 412 | func (m *S2U_Notice) XXX_Size() int { 413 | return xxx_messageInfo_S2U_Notice.Size(m) 414 | } 415 | func (m *S2U_Notice) XXX_DiscardUnknown() { 416 | xxx_messageInfo_S2U_Notice.DiscardUnknown(m) 417 | } 418 | 419 | var xxx_messageInfo_S2U_Notice proto.InternalMessageInfo 420 | 421 | func (m *S2U_Notice) GetType() int32 { 422 | if m != nil { 423 | return m.Type 424 | } 425 | return 0 426 | } 427 | 428 | func (m *S2U_Notice) GetMsg() []byte { 429 | if m != nil { 430 | return m.Msg 431 | } 432 | return nil 433 | } 434 | 435 | // 聊天上行 436 | type U2S_Chat struct { 437 | Content string `protobuf:"bytes,2,opt,name=content,proto3" json:"content,omitempty"` 438 | XXX_NoUnkeyedLiteral struct{} `json:"-"` 439 | XXX_unrecognized []byte `json:"-"` 440 | XXX_sizecache int32 `json:"-"` 441 | } 442 | 443 | func (m *U2S_Chat) Reset() { *m = U2S_Chat{} } 444 | func (m *U2S_Chat) String() string { return proto.CompactTextString(m) } 445 | func (*U2S_Chat) ProtoMessage() {} 446 | func (*U2S_Chat) Descriptor() ([]byte, []int) { 447 | return fileDescriptor_message_0cde66bc4e56949c, []int{6} 448 | } 449 | func (m *U2S_Chat) XXX_Unmarshal(b []byte) error { 450 | return xxx_messageInfo_U2S_Chat.Unmarshal(m, b) 451 | } 452 | func (m *U2S_Chat) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 453 | return xxx_messageInfo_U2S_Chat.Marshal(b, m, deterministic) 454 | } 455 | func (dst *U2S_Chat) XXX_Merge(src proto.Message) { 456 | xxx_messageInfo_U2S_Chat.Merge(dst, src) 457 | } 458 | func (m *U2S_Chat) XXX_Size() int { 459 | return xxx_messageInfo_U2S_Chat.Size(m) 460 | } 461 | func (m *U2S_Chat) XXX_DiscardUnknown() { 462 | xxx_messageInfo_U2S_Chat.DiscardUnknown(m) 463 | } 464 | 465 | var xxx_messageInfo_U2S_Chat proto.InternalMessageInfo 466 | 467 | func (m *U2S_Chat) GetContent() string { 468 | if m != nil { 469 | return m.Content 470 | } 471 | return "" 472 | } 473 | 474 | // 聊天下发 475 | type S2U_Chat struct { 476 | Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` 477 | Style uint32 `protobuf:"varint,2,opt,name=Style,proto3" json:"Style,omitempty"` 478 | Content string `protobuf:"bytes,3,opt,name=content,proto3" json:"content,omitempty"` 479 | XXX_NoUnkeyedLiteral struct{} `json:"-"` 480 | XXX_unrecognized []byte `json:"-"` 481 | XXX_sizecache int32 `json:"-"` 482 | } 483 | 484 | func (m *S2U_Chat) Reset() { *m = S2U_Chat{} } 485 | func (m *S2U_Chat) String() string { return proto.CompactTextString(m) } 486 | func (*S2U_Chat) ProtoMessage() {} 487 | func (*S2U_Chat) Descriptor() ([]byte, []int) { 488 | return fileDescriptor_message_0cde66bc4e56949c, []int{7} 489 | } 490 | func (m *S2U_Chat) XXX_Unmarshal(b []byte) error { 491 | return xxx_messageInfo_S2U_Chat.Unmarshal(m, b) 492 | } 493 | func (m *S2U_Chat) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 494 | return xxx_messageInfo_S2U_Chat.Marshal(b, m, deterministic) 495 | } 496 | func (dst *S2U_Chat) XXX_Merge(src proto.Message) { 497 | xxx_messageInfo_S2U_Chat.Merge(dst, src) 498 | } 499 | func (m *S2U_Chat) XXX_Size() int { 500 | return xxx_messageInfo_S2U_Chat.Size(m) 501 | } 502 | func (m *S2U_Chat) XXX_DiscardUnknown() { 503 | xxx_messageInfo_S2U_Chat.DiscardUnknown(m) 504 | } 505 | 506 | var xxx_messageInfo_S2U_Chat proto.InternalMessageInfo 507 | 508 | func (m *S2U_Chat) GetName() string { 509 | if m != nil { 510 | return m.Name 511 | } 512 | return "" 513 | } 514 | 515 | func (m *S2U_Chat) GetStyle() uint32 { 516 | if m != nil { 517 | return m.Style 518 | } 519 | return 0 520 | } 521 | 522 | func (m *S2U_Chat) GetContent() string { 523 | if m != nil { 524 | return m.Content 525 | } 526 | return "" 527 | } 528 | 529 | // 打开商城 530 | type U2S_ShopList struct { 531 | XXX_NoUnkeyedLiteral struct{} `json:"-"` 532 | XXX_unrecognized []byte `json:"-"` 533 | XXX_sizecache int32 `json:"-"` 534 | } 535 | 536 | func (m *U2S_ShopList) Reset() { *m = U2S_ShopList{} } 537 | func (m *U2S_ShopList) String() string { return proto.CompactTextString(m) } 538 | func (*U2S_ShopList) ProtoMessage() {} 539 | func (*U2S_ShopList) Descriptor() ([]byte, []int) { 540 | return fileDescriptor_message_0cde66bc4e56949c, []int{8} 541 | } 542 | func (m *U2S_ShopList) XXX_Unmarshal(b []byte) error { 543 | return xxx_messageInfo_U2S_ShopList.Unmarshal(m, b) 544 | } 545 | func (m *U2S_ShopList) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 546 | return xxx_messageInfo_U2S_ShopList.Marshal(b, m, deterministic) 547 | } 548 | func (dst *U2S_ShopList) XXX_Merge(src proto.Message) { 549 | xxx_messageInfo_U2S_ShopList.Merge(dst, src) 550 | } 551 | func (m *U2S_ShopList) XXX_Size() int { 552 | return xxx_messageInfo_U2S_ShopList.Size(m) 553 | } 554 | func (m *U2S_ShopList) XXX_DiscardUnknown() { 555 | xxx_messageInfo_U2S_ShopList.DiscardUnknown(m) 556 | } 557 | 558 | var xxx_messageInfo_U2S_ShopList proto.InternalMessageInfo 559 | 560 | // 商品名明细 价格,库存,电费,管理费,产出币 561 | type ShopInfo struct { 562 | ProductID int32 `protobuf:"varint,1,opt,name=productID,proto3" json:"productID,omitempty"` 563 | Repertory int32 `protobuf:"varint,2,opt,name=repertory,proto3" json:"repertory,omitempty"` 564 | Electric float32 `protobuf:"fixed32,3,opt,name=electric,proto3" json:"electric,omitempty"` 565 | ManageCost float32 `protobuf:"fixed32,4,opt,name=manageCost,proto3" json:"manageCost,omitempty"` 566 | Output float32 `protobuf:"fixed32,5,opt,name=output,proto3" json:"output,omitempty"` 567 | Price float32 `protobuf:"fixed32,6,opt,name=price,proto3" json:"price,omitempty"` 568 | XXX_NoUnkeyedLiteral struct{} `json:"-"` 569 | XXX_unrecognized []byte `json:"-"` 570 | XXX_sizecache int32 `json:"-"` 571 | } 572 | 573 | func (m *ShopInfo) Reset() { *m = ShopInfo{} } 574 | func (m *ShopInfo) String() string { return proto.CompactTextString(m) } 575 | func (*ShopInfo) ProtoMessage() {} 576 | func (*ShopInfo) Descriptor() ([]byte, []int) { 577 | return fileDescriptor_message_0cde66bc4e56949c, []int{9} 578 | } 579 | func (m *ShopInfo) XXX_Unmarshal(b []byte) error { 580 | return xxx_messageInfo_ShopInfo.Unmarshal(m, b) 581 | } 582 | func (m *ShopInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 583 | return xxx_messageInfo_ShopInfo.Marshal(b, m, deterministic) 584 | } 585 | func (dst *ShopInfo) XXX_Merge(src proto.Message) { 586 | xxx_messageInfo_ShopInfo.Merge(dst, src) 587 | } 588 | func (m *ShopInfo) XXX_Size() int { 589 | return xxx_messageInfo_ShopInfo.Size(m) 590 | } 591 | func (m *ShopInfo) XXX_DiscardUnknown() { 592 | xxx_messageInfo_ShopInfo.DiscardUnknown(m) 593 | } 594 | 595 | var xxx_messageInfo_ShopInfo proto.InternalMessageInfo 596 | 597 | func (m *ShopInfo) GetProductID() int32 { 598 | if m != nil { 599 | return m.ProductID 600 | } 601 | return 0 602 | } 603 | 604 | func (m *ShopInfo) GetRepertory() int32 { 605 | if m != nil { 606 | return m.Repertory 607 | } 608 | return 0 609 | } 610 | 611 | func (m *ShopInfo) GetElectric() float32 { 612 | if m != nil { 613 | return m.Electric 614 | } 615 | return 0 616 | } 617 | 618 | func (m *ShopInfo) GetManageCost() float32 { 619 | if m != nil { 620 | return m.ManageCost 621 | } 622 | return 0 623 | } 624 | 625 | func (m *ShopInfo) GetOutput() float32 { 626 | if m != nil { 627 | return m.Output 628 | } 629 | return 0 630 | } 631 | 632 | func (m *ShopInfo) GetPrice() float32 { 633 | if m != nil { 634 | return m.Price 635 | } 636 | return 0 637 | } 638 | 639 | // 商城信息 640 | type S2U_ShopList struct { 641 | List []*ShopInfo `protobuf:"bytes,1,rep,name=list,proto3" json:"list,omitempty"` 642 | XXX_NoUnkeyedLiteral struct{} `json:"-"` 643 | XXX_unrecognized []byte `json:"-"` 644 | XXX_sizecache int32 `json:"-"` 645 | } 646 | 647 | func (m *S2U_ShopList) Reset() { *m = S2U_ShopList{} } 648 | func (m *S2U_ShopList) String() string { return proto.CompactTextString(m) } 649 | func (*S2U_ShopList) ProtoMessage() {} 650 | func (*S2U_ShopList) Descriptor() ([]byte, []int) { 651 | return fileDescriptor_message_0cde66bc4e56949c, []int{10} 652 | } 653 | func (m *S2U_ShopList) XXX_Unmarshal(b []byte) error { 654 | return xxx_messageInfo_S2U_ShopList.Unmarshal(m, b) 655 | } 656 | func (m *S2U_ShopList) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 657 | return xxx_messageInfo_S2U_ShopList.Marshal(b, m, deterministic) 658 | } 659 | func (dst *S2U_ShopList) XXX_Merge(src proto.Message) { 660 | xxx_messageInfo_S2U_ShopList.Merge(dst, src) 661 | } 662 | func (m *S2U_ShopList) XXX_Size() int { 663 | return xxx_messageInfo_S2U_ShopList.Size(m) 664 | } 665 | func (m *S2U_ShopList) XXX_DiscardUnknown() { 666 | xxx_messageInfo_S2U_ShopList.DiscardUnknown(m) 667 | } 668 | 669 | var xxx_messageInfo_S2U_ShopList proto.InternalMessageInfo 670 | 671 | func (m *S2U_ShopList) GetList() []*ShopInfo { 672 | if m != nil { 673 | return m.List 674 | } 675 | return nil 676 | } 677 | 678 | // 购买矿机 679 | type U2S_Buy struct { 680 | ProductID int32 `protobuf:"varint,1,opt,name=ProductID,proto3" json:"ProductID,omitempty"` 681 | Count int32 `protobuf:"varint,2,opt,name=Count,proto3" json:"Count,omitempty"` 682 | XXX_NoUnkeyedLiteral struct{} `json:"-"` 683 | XXX_unrecognized []byte `json:"-"` 684 | XXX_sizecache int32 `json:"-"` 685 | } 686 | 687 | func (m *U2S_Buy) Reset() { *m = U2S_Buy{} } 688 | func (m *U2S_Buy) String() string { return proto.CompactTextString(m) } 689 | func (*U2S_Buy) ProtoMessage() {} 690 | func (*U2S_Buy) Descriptor() ([]byte, []int) { 691 | return fileDescriptor_message_0cde66bc4e56949c, []int{11} 692 | } 693 | func (m *U2S_Buy) XXX_Unmarshal(b []byte) error { 694 | return xxx_messageInfo_U2S_Buy.Unmarshal(m, b) 695 | } 696 | func (m *U2S_Buy) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 697 | return xxx_messageInfo_U2S_Buy.Marshal(b, m, deterministic) 698 | } 699 | func (dst *U2S_Buy) XXX_Merge(src proto.Message) { 700 | xxx_messageInfo_U2S_Buy.Merge(dst, src) 701 | } 702 | func (m *U2S_Buy) XXX_Size() int { 703 | return xxx_messageInfo_U2S_Buy.Size(m) 704 | } 705 | func (m *U2S_Buy) XXX_DiscardUnknown() { 706 | xxx_messageInfo_U2S_Buy.DiscardUnknown(m) 707 | } 708 | 709 | var xxx_messageInfo_U2S_Buy proto.InternalMessageInfo 710 | 711 | func (m *U2S_Buy) GetProductID() int32 { 712 | if m != nil { 713 | return m.ProductID 714 | } 715 | return 0 716 | } 717 | 718 | func (m *U2S_Buy) GetCount() int32 { 719 | if m != nil { 720 | return m.Count 721 | } 722 | return 0 723 | } 724 | 725 | // 购买矿机反馈 726 | type S2U_BuyResult struct { 727 | ErrorCode int32 `protobuf:"varint,1,opt,name=ErrorCode,proto3" json:"ErrorCode,omitempty"` 728 | XXX_NoUnkeyedLiteral struct{} `json:"-"` 729 | XXX_unrecognized []byte `json:"-"` 730 | XXX_sizecache int32 `json:"-"` 731 | } 732 | 733 | func (m *S2U_BuyResult) Reset() { *m = S2U_BuyResult{} } 734 | func (m *S2U_BuyResult) String() string { return proto.CompactTextString(m) } 735 | func (*S2U_BuyResult) ProtoMessage() {} 736 | func (*S2U_BuyResult) Descriptor() ([]byte, []int) { 737 | return fileDescriptor_message_0cde66bc4e56949c, []int{12} 738 | } 739 | func (m *S2U_BuyResult) XXX_Unmarshal(b []byte) error { 740 | return xxx_messageInfo_S2U_BuyResult.Unmarshal(m, b) 741 | } 742 | func (m *S2U_BuyResult) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 743 | return xxx_messageInfo_S2U_BuyResult.Marshal(b, m, deterministic) 744 | } 745 | func (dst *S2U_BuyResult) XXX_Merge(src proto.Message) { 746 | xxx_messageInfo_S2U_BuyResult.Merge(dst, src) 747 | } 748 | func (m *S2U_BuyResult) XXX_Size() int { 749 | return xxx_messageInfo_S2U_BuyResult.Size(m) 750 | } 751 | func (m *S2U_BuyResult) XXX_DiscardUnknown() { 752 | xxx_messageInfo_S2U_BuyResult.DiscardUnknown(m) 753 | } 754 | 755 | var xxx_messageInfo_S2U_BuyResult proto.InternalMessageInfo 756 | 757 | func (m *S2U_BuyResult) GetErrorCode() int32 { 758 | if m != nil { 759 | return m.ErrorCode 760 | } 761 | return 0 762 | } 763 | 764 | // 请求矿机信息 765 | type U2S_MineMachineList struct { 766 | XXX_NoUnkeyedLiteral struct{} `json:"-"` 767 | XXX_unrecognized []byte `json:"-"` 768 | XXX_sizecache int32 `json:"-"` 769 | } 770 | 771 | func (m *U2S_MineMachineList) Reset() { *m = U2S_MineMachineList{} } 772 | func (m *U2S_MineMachineList) String() string { return proto.CompactTextString(m) } 773 | func (*U2S_MineMachineList) ProtoMessage() {} 774 | func (*U2S_MineMachineList) Descriptor() ([]byte, []int) { 775 | return fileDescriptor_message_0cde66bc4e56949c, []int{13} 776 | } 777 | func (m *U2S_MineMachineList) XXX_Unmarshal(b []byte) error { 778 | return xxx_messageInfo_U2S_MineMachineList.Unmarshal(m, b) 779 | } 780 | func (m *U2S_MineMachineList) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 781 | return xxx_messageInfo_U2S_MineMachineList.Marshal(b, m, deterministic) 782 | } 783 | func (dst *U2S_MineMachineList) XXX_Merge(src proto.Message) { 784 | xxx_messageInfo_U2S_MineMachineList.Merge(dst, src) 785 | } 786 | func (m *U2S_MineMachineList) XXX_Size() int { 787 | return xxx_messageInfo_U2S_MineMachineList.Size(m) 788 | } 789 | func (m *U2S_MineMachineList) XXX_DiscardUnknown() { 790 | xxx_messageInfo_U2S_MineMachineList.DiscardUnknown(m) 791 | } 792 | 793 | var xxx_messageInfo_U2S_MineMachineList proto.InternalMessageInfo 794 | 795 | // 矿机信息 796 | type MineMachine struct { 797 | ID int32 `protobuf:"varint,1,opt,name=ID,proto3" json:"ID,omitempty"` 798 | ProductID int32 `protobuf:"varint,2,opt,name=ProductID,proto3" json:"ProductID,omitempty"` 799 | Location int32 `protobuf:"varint,3,opt,name=Location,proto3" json:"Location,omitempty"` 800 | RunTime int64 `protobuf:"varint,4,opt,name=RunTime,proto3" json:"RunTime,omitempty"` 801 | EndTime int64 `protobuf:"varint,5,opt,name=EndTime,proto3" json:"EndTime,omitempty"` 802 | OutputCoin float32 `protobuf:"fixed32,6,opt,name=OutputCoin,proto3" json:"OutputCoin,omitempty"` 803 | XXX_NoUnkeyedLiteral struct{} `json:"-"` 804 | XXX_unrecognized []byte `json:"-"` 805 | XXX_sizecache int32 `json:"-"` 806 | } 807 | 808 | func (m *MineMachine) Reset() { *m = MineMachine{} } 809 | func (m *MineMachine) String() string { return proto.CompactTextString(m) } 810 | func (*MineMachine) ProtoMessage() {} 811 | func (*MineMachine) Descriptor() ([]byte, []int) { 812 | return fileDescriptor_message_0cde66bc4e56949c, []int{14} 813 | } 814 | func (m *MineMachine) XXX_Unmarshal(b []byte) error { 815 | return xxx_messageInfo_MineMachine.Unmarshal(m, b) 816 | } 817 | func (m *MineMachine) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 818 | return xxx_messageInfo_MineMachine.Marshal(b, m, deterministic) 819 | } 820 | func (dst *MineMachine) XXX_Merge(src proto.Message) { 821 | xxx_messageInfo_MineMachine.Merge(dst, src) 822 | } 823 | func (m *MineMachine) XXX_Size() int { 824 | return xxx_messageInfo_MineMachine.Size(m) 825 | } 826 | func (m *MineMachine) XXX_DiscardUnknown() { 827 | xxx_messageInfo_MineMachine.DiscardUnknown(m) 828 | } 829 | 830 | var xxx_messageInfo_MineMachine proto.InternalMessageInfo 831 | 832 | func (m *MineMachine) GetID() int32 { 833 | if m != nil { 834 | return m.ID 835 | } 836 | return 0 837 | } 838 | 839 | func (m *MineMachine) GetProductID() int32 { 840 | if m != nil { 841 | return m.ProductID 842 | } 843 | return 0 844 | } 845 | 846 | func (m *MineMachine) GetLocation() int32 { 847 | if m != nil { 848 | return m.Location 849 | } 850 | return 0 851 | } 852 | 853 | func (m *MineMachine) GetRunTime() int64 { 854 | if m != nil { 855 | return m.RunTime 856 | } 857 | return 0 858 | } 859 | 860 | func (m *MineMachine) GetEndTime() int64 { 861 | if m != nil { 862 | return m.EndTime 863 | } 864 | return 0 865 | } 866 | 867 | func (m *MineMachine) GetOutputCoin() float32 { 868 | if m != nil { 869 | return m.OutputCoin 870 | } 871 | return 0 872 | } 873 | 874 | // 玩家所属矿机列表 875 | type S2U_MineMachineList struct { 876 | List []*MineMachine `protobuf:"bytes,1,rep,name=list,proto3" json:"list,omitempty"` 877 | XXX_NoUnkeyedLiteral struct{} `json:"-"` 878 | XXX_unrecognized []byte `json:"-"` 879 | XXX_sizecache int32 `json:"-"` 880 | } 881 | 882 | func (m *S2U_MineMachineList) Reset() { *m = S2U_MineMachineList{} } 883 | func (m *S2U_MineMachineList) String() string { return proto.CompactTextString(m) } 884 | func (*S2U_MineMachineList) ProtoMessage() {} 885 | func (*S2U_MineMachineList) Descriptor() ([]byte, []int) { 886 | return fileDescriptor_message_0cde66bc4e56949c, []int{15} 887 | } 888 | func (m *S2U_MineMachineList) XXX_Unmarshal(b []byte) error { 889 | return xxx_messageInfo_S2U_MineMachineList.Unmarshal(m, b) 890 | } 891 | func (m *S2U_MineMachineList) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 892 | return xxx_messageInfo_S2U_MineMachineList.Marshal(b, m, deterministic) 893 | } 894 | func (dst *S2U_MineMachineList) XXX_Merge(src proto.Message) { 895 | xxx_messageInfo_S2U_MineMachineList.Merge(dst, src) 896 | } 897 | func (m *S2U_MineMachineList) XXX_Size() int { 898 | return xxx_messageInfo_S2U_MineMachineList.Size(m) 899 | } 900 | func (m *S2U_MineMachineList) XXX_DiscardUnknown() { 901 | xxx_messageInfo_S2U_MineMachineList.DiscardUnknown(m) 902 | } 903 | 904 | var xxx_messageInfo_S2U_MineMachineList proto.InternalMessageInfo 905 | 906 | func (m *S2U_MineMachineList) GetList() []*MineMachine { 907 | if m != nil { 908 | return m.List 909 | } 910 | return nil 911 | } 912 | 913 | // 请求矿点列表 914 | type U2S_MineList struct { 915 | XXX_NoUnkeyedLiteral struct{} `json:"-"` 916 | XXX_unrecognized []byte `json:"-"` 917 | XXX_sizecache int32 `json:"-"` 918 | } 919 | 920 | func (m *U2S_MineList) Reset() { *m = U2S_MineList{} } 921 | func (m *U2S_MineList) String() string { return proto.CompactTextString(m) } 922 | func (*U2S_MineList) ProtoMessage() {} 923 | func (*U2S_MineList) Descriptor() ([]byte, []int) { 924 | return fileDescriptor_message_0cde66bc4e56949c, []int{16} 925 | } 926 | func (m *U2S_MineList) XXX_Unmarshal(b []byte) error { 927 | return xxx_messageInfo_U2S_MineList.Unmarshal(m, b) 928 | } 929 | func (m *U2S_MineList) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 930 | return xxx_messageInfo_U2S_MineList.Marshal(b, m, deterministic) 931 | } 932 | func (dst *U2S_MineList) XXX_Merge(src proto.Message) { 933 | xxx_messageInfo_U2S_MineList.Merge(dst, src) 934 | } 935 | func (m *U2S_MineList) XXX_Size() int { 936 | return xxx_messageInfo_U2S_MineList.Size(m) 937 | } 938 | func (m *U2S_MineList) XXX_DiscardUnknown() { 939 | xxx_messageInfo_U2S_MineList.DiscardUnknown(m) 940 | } 941 | 942 | var xxx_messageInfo_U2S_MineList proto.InternalMessageInfo 943 | 944 | // 矿点名明细 序号,电费,管理费,效率,剩余机位 945 | type MineInfo struct { 946 | Location int32 `protobuf:"varint,1,opt,name=Location,proto3" json:"Location,omitempty"` 947 | Electric float32 `protobuf:"fixed32,2,opt,name=Electric,proto3" json:"Electric,omitempty"` 948 | Tip float32 `protobuf:"fixed32,3,opt,name=Tip,proto3" json:"Tip,omitempty"` 949 | Ratio float32 `protobuf:"fixed32,4,opt,name=Ratio,proto3" json:"Ratio,omitempty"` 950 | Num int32 `protobuf:"varint,5,opt,name=Num,proto3" json:"Num,omitempty"` 951 | XXX_NoUnkeyedLiteral struct{} `json:"-"` 952 | XXX_unrecognized []byte `json:"-"` 953 | XXX_sizecache int32 `json:"-"` 954 | } 955 | 956 | func (m *MineInfo) Reset() { *m = MineInfo{} } 957 | func (m *MineInfo) String() string { return proto.CompactTextString(m) } 958 | func (*MineInfo) ProtoMessage() {} 959 | func (*MineInfo) Descriptor() ([]byte, []int) { 960 | return fileDescriptor_message_0cde66bc4e56949c, []int{17} 961 | } 962 | func (m *MineInfo) XXX_Unmarshal(b []byte) error { 963 | return xxx_messageInfo_MineInfo.Unmarshal(m, b) 964 | } 965 | func (m *MineInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 966 | return xxx_messageInfo_MineInfo.Marshal(b, m, deterministic) 967 | } 968 | func (dst *MineInfo) XXX_Merge(src proto.Message) { 969 | xxx_messageInfo_MineInfo.Merge(dst, src) 970 | } 971 | func (m *MineInfo) XXX_Size() int { 972 | return xxx_messageInfo_MineInfo.Size(m) 973 | } 974 | func (m *MineInfo) XXX_DiscardUnknown() { 975 | xxx_messageInfo_MineInfo.DiscardUnknown(m) 976 | } 977 | 978 | var xxx_messageInfo_MineInfo proto.InternalMessageInfo 979 | 980 | func (m *MineInfo) GetLocation() int32 { 981 | if m != nil { 982 | return m.Location 983 | } 984 | return 0 985 | } 986 | 987 | func (m *MineInfo) GetElectric() float32 { 988 | if m != nil { 989 | return m.Electric 990 | } 991 | return 0 992 | } 993 | 994 | func (m *MineInfo) GetTip() float32 { 995 | if m != nil { 996 | return m.Tip 997 | } 998 | return 0 999 | } 1000 | 1001 | func (m *MineInfo) GetRatio() float32 { 1002 | if m != nil { 1003 | return m.Ratio 1004 | } 1005 | return 0 1006 | } 1007 | 1008 | func (m *MineInfo) GetNum() int32 { 1009 | if m != nil { 1010 | return m.Num 1011 | } 1012 | return 0 1013 | } 1014 | 1015 | // 矿点信息 1016 | type S2U_MineList struct { 1017 | List []*MineInfo `protobuf:"bytes,1,rep,name=list,proto3" json:"list,omitempty"` 1018 | XXX_NoUnkeyedLiteral struct{} `json:"-"` 1019 | XXX_unrecognized []byte `json:"-"` 1020 | XXX_sizecache int32 `json:"-"` 1021 | } 1022 | 1023 | func (m *S2U_MineList) Reset() { *m = S2U_MineList{} } 1024 | func (m *S2U_MineList) String() string { return proto.CompactTextString(m) } 1025 | func (*S2U_MineList) ProtoMessage() {} 1026 | func (*S2U_MineList) Descriptor() ([]byte, []int) { 1027 | return fileDescriptor_message_0cde66bc4e56949c, []int{18} 1028 | } 1029 | func (m *S2U_MineList) XXX_Unmarshal(b []byte) error { 1030 | return xxx_messageInfo_S2U_MineList.Unmarshal(m, b) 1031 | } 1032 | func (m *S2U_MineList) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 1033 | return xxx_messageInfo_S2U_MineList.Marshal(b, m, deterministic) 1034 | } 1035 | func (dst *S2U_MineList) XXX_Merge(src proto.Message) { 1036 | xxx_messageInfo_S2U_MineList.Merge(dst, src) 1037 | } 1038 | func (m *S2U_MineList) XXX_Size() int { 1039 | return xxx_messageInfo_S2U_MineList.Size(m) 1040 | } 1041 | func (m *S2U_MineList) XXX_DiscardUnknown() { 1042 | xxx_messageInfo_S2U_MineList.DiscardUnknown(m) 1043 | } 1044 | 1045 | var xxx_messageInfo_S2U_MineList proto.InternalMessageInfo 1046 | 1047 | func (m *S2U_MineList) GetList() []*MineInfo { 1048 | if m != nil { 1049 | return m.List 1050 | } 1051 | return nil 1052 | } 1053 | 1054 | // 开始挖矿 1055 | type U2S_Mining struct { 1056 | ID int32 `protobuf:"varint,1,opt,name=ID,proto3" json:"ID,omitempty"` 1057 | Location int32 `protobuf:"varint,2,opt,name=Location,proto3" json:"Location,omitempty"` 1058 | WillDay int32 `protobuf:"varint,3,opt,name=WillDay,proto3" json:"WillDay,omitempty"` 1059 | XXX_NoUnkeyedLiteral struct{} `json:"-"` 1060 | XXX_unrecognized []byte `json:"-"` 1061 | XXX_sizecache int32 `json:"-"` 1062 | } 1063 | 1064 | func (m *U2S_Mining) Reset() { *m = U2S_Mining{} } 1065 | func (m *U2S_Mining) String() string { return proto.CompactTextString(m) } 1066 | func (*U2S_Mining) ProtoMessage() {} 1067 | func (*U2S_Mining) Descriptor() ([]byte, []int) { 1068 | return fileDescriptor_message_0cde66bc4e56949c, []int{19} 1069 | } 1070 | func (m *U2S_Mining) XXX_Unmarshal(b []byte) error { 1071 | return xxx_messageInfo_U2S_Mining.Unmarshal(m, b) 1072 | } 1073 | func (m *U2S_Mining) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 1074 | return xxx_messageInfo_U2S_Mining.Marshal(b, m, deterministic) 1075 | } 1076 | func (dst *U2S_Mining) XXX_Merge(src proto.Message) { 1077 | xxx_messageInfo_U2S_Mining.Merge(dst, src) 1078 | } 1079 | func (m *U2S_Mining) XXX_Size() int { 1080 | return xxx_messageInfo_U2S_Mining.Size(m) 1081 | } 1082 | func (m *U2S_Mining) XXX_DiscardUnknown() { 1083 | xxx_messageInfo_U2S_Mining.DiscardUnknown(m) 1084 | } 1085 | 1086 | var xxx_messageInfo_U2S_Mining proto.InternalMessageInfo 1087 | 1088 | func (m *U2S_Mining) GetID() int32 { 1089 | if m != nil { 1090 | return m.ID 1091 | } 1092 | return 0 1093 | } 1094 | 1095 | func (m *U2S_Mining) GetLocation() int32 { 1096 | if m != nil { 1097 | return m.Location 1098 | } 1099 | return 0 1100 | } 1101 | 1102 | func (m *U2S_Mining) GetWillDay() int32 { 1103 | if m != nil { 1104 | return m.WillDay 1105 | } 1106 | return 0 1107 | } 1108 | 1109 | // 挖矿操作反馈 1110 | type S2U_MiningResult struct { 1111 | ID int32 `protobuf:"varint,1,opt,name=ID,proto3" json:"ID,omitempty"` 1112 | ErrorCode int32 `protobuf:"varint,2,opt,name=ErrorCode,proto3" json:"ErrorCode,omitempty"` 1113 | XXX_NoUnkeyedLiteral struct{} `json:"-"` 1114 | XXX_unrecognized []byte `json:"-"` 1115 | XXX_sizecache int32 `json:"-"` 1116 | } 1117 | 1118 | func (m *S2U_MiningResult) Reset() { *m = S2U_MiningResult{} } 1119 | func (m *S2U_MiningResult) String() string { return proto.CompactTextString(m) } 1120 | func (*S2U_MiningResult) ProtoMessage() {} 1121 | func (*S2U_MiningResult) Descriptor() ([]byte, []int) { 1122 | return fileDescriptor_message_0cde66bc4e56949c, []int{20} 1123 | } 1124 | func (m *S2U_MiningResult) XXX_Unmarshal(b []byte) error { 1125 | return xxx_messageInfo_S2U_MiningResult.Unmarshal(m, b) 1126 | } 1127 | func (m *S2U_MiningResult) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 1128 | return xxx_messageInfo_S2U_MiningResult.Marshal(b, m, deterministic) 1129 | } 1130 | func (dst *S2U_MiningResult) XXX_Merge(src proto.Message) { 1131 | xxx_messageInfo_S2U_MiningResult.Merge(dst, src) 1132 | } 1133 | func (m *S2U_MiningResult) XXX_Size() int { 1134 | return xxx_messageInfo_S2U_MiningResult.Size(m) 1135 | } 1136 | func (m *S2U_MiningResult) XXX_DiscardUnknown() { 1137 | xxx_messageInfo_S2U_MiningResult.DiscardUnknown(m) 1138 | } 1139 | 1140 | var xxx_messageInfo_S2U_MiningResult proto.InternalMessageInfo 1141 | 1142 | func (m *S2U_MiningResult) GetID() int32 { 1143 | if m != nil { 1144 | return m.ID 1145 | } 1146 | return 0 1147 | } 1148 | 1149 | func (m *S2U_MiningResult) GetErrorCode() int32 { 1150 | if m != nil { 1151 | return m.ErrorCode 1152 | } 1153 | return 0 1154 | } 1155 | 1156 | // 收集矿 1157 | type U2S_GatherMine struct { 1158 | ID int32 `protobuf:"varint,1,opt,name=ID,proto3" json:"ID,omitempty"` 1159 | Location int32 `protobuf:"varint,2,opt,name=Location,proto3" json:"Location,omitempty"` 1160 | XXX_NoUnkeyedLiteral struct{} `json:"-"` 1161 | XXX_unrecognized []byte `json:"-"` 1162 | XXX_sizecache int32 `json:"-"` 1163 | } 1164 | 1165 | func (m *U2S_GatherMine) Reset() { *m = U2S_GatherMine{} } 1166 | func (m *U2S_GatherMine) String() string { return proto.CompactTextString(m) } 1167 | func (*U2S_GatherMine) ProtoMessage() {} 1168 | func (*U2S_GatherMine) Descriptor() ([]byte, []int) { 1169 | return fileDescriptor_message_0cde66bc4e56949c, []int{21} 1170 | } 1171 | func (m *U2S_GatherMine) XXX_Unmarshal(b []byte) error { 1172 | return xxx_messageInfo_U2S_GatherMine.Unmarshal(m, b) 1173 | } 1174 | func (m *U2S_GatherMine) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 1175 | return xxx_messageInfo_U2S_GatherMine.Marshal(b, m, deterministic) 1176 | } 1177 | func (dst *U2S_GatherMine) XXX_Merge(src proto.Message) { 1178 | xxx_messageInfo_U2S_GatherMine.Merge(dst, src) 1179 | } 1180 | func (m *U2S_GatherMine) XXX_Size() int { 1181 | return xxx_messageInfo_U2S_GatherMine.Size(m) 1182 | } 1183 | func (m *U2S_GatherMine) XXX_DiscardUnknown() { 1184 | xxx_messageInfo_U2S_GatherMine.DiscardUnknown(m) 1185 | } 1186 | 1187 | var xxx_messageInfo_U2S_GatherMine proto.InternalMessageInfo 1188 | 1189 | func (m *U2S_GatherMine) GetID() int32 { 1190 | if m != nil { 1191 | return m.ID 1192 | } 1193 | return 0 1194 | } 1195 | 1196 | func (m *U2S_GatherMine) GetLocation() int32 { 1197 | if m != nil { 1198 | return m.Location 1199 | } 1200 | return 0 1201 | } 1202 | 1203 | // 收集矿反馈 1204 | type S2U_GatherMine struct { 1205 | ID int32 `protobuf:"varint,1,opt,name=ID,proto3" json:"ID,omitempty"` 1206 | Btc float32 `protobuf:"fixed32,2,opt,name=Btc,proto3" json:"Btc,omitempty"` 1207 | XXX_NoUnkeyedLiteral struct{} `json:"-"` 1208 | XXX_unrecognized []byte `json:"-"` 1209 | XXX_sizecache int32 `json:"-"` 1210 | } 1211 | 1212 | func (m *S2U_GatherMine) Reset() { *m = S2U_GatherMine{} } 1213 | func (m *S2U_GatherMine) String() string { return proto.CompactTextString(m) } 1214 | func (*S2U_GatherMine) ProtoMessage() {} 1215 | func (*S2U_GatherMine) Descriptor() ([]byte, []int) { 1216 | return fileDescriptor_message_0cde66bc4e56949c, []int{22} 1217 | } 1218 | func (m *S2U_GatherMine) XXX_Unmarshal(b []byte) error { 1219 | return xxx_messageInfo_S2U_GatherMine.Unmarshal(m, b) 1220 | } 1221 | func (m *S2U_GatherMine) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 1222 | return xxx_messageInfo_S2U_GatherMine.Marshal(b, m, deterministic) 1223 | } 1224 | func (dst *S2U_GatherMine) XXX_Merge(src proto.Message) { 1225 | xxx_messageInfo_S2U_GatherMine.Merge(dst, src) 1226 | } 1227 | func (m *S2U_GatherMine) XXX_Size() int { 1228 | return xxx_messageInfo_S2U_GatherMine.Size(m) 1229 | } 1230 | func (m *S2U_GatherMine) XXX_DiscardUnknown() { 1231 | xxx_messageInfo_S2U_GatherMine.DiscardUnknown(m) 1232 | } 1233 | 1234 | var xxx_messageInfo_S2U_GatherMine proto.InternalMessageInfo 1235 | 1236 | func (m *S2U_GatherMine) GetID() int32 { 1237 | if m != nil { 1238 | return m.ID 1239 | } 1240 | return 0 1241 | } 1242 | 1243 | func (m *S2U_GatherMine) GetBtc() float32 { 1244 | if m != nil { 1245 | return m.Btc 1246 | } 1247 | return 0 1248 | } 1249 | 1250 | // 停止挖矿 1251 | type U2S_StopMining struct { 1252 | ID int32 `protobuf:"varint,1,opt,name=ID,proto3" json:"ID,omitempty"` 1253 | XXX_NoUnkeyedLiteral struct{} `json:"-"` 1254 | XXX_unrecognized []byte `json:"-"` 1255 | XXX_sizecache int32 `json:"-"` 1256 | } 1257 | 1258 | func (m *U2S_StopMining) Reset() { *m = U2S_StopMining{} } 1259 | func (m *U2S_StopMining) String() string { return proto.CompactTextString(m) } 1260 | func (*U2S_StopMining) ProtoMessage() {} 1261 | func (*U2S_StopMining) Descriptor() ([]byte, []int) { 1262 | return fileDescriptor_message_0cde66bc4e56949c, []int{23} 1263 | } 1264 | func (m *U2S_StopMining) XXX_Unmarshal(b []byte) error { 1265 | return xxx_messageInfo_U2S_StopMining.Unmarshal(m, b) 1266 | } 1267 | func (m *U2S_StopMining) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 1268 | return xxx_messageInfo_U2S_StopMining.Marshal(b, m, deterministic) 1269 | } 1270 | func (dst *U2S_StopMining) XXX_Merge(src proto.Message) { 1271 | xxx_messageInfo_U2S_StopMining.Merge(dst, src) 1272 | } 1273 | func (m *U2S_StopMining) XXX_Size() int { 1274 | return xxx_messageInfo_U2S_StopMining.Size(m) 1275 | } 1276 | func (m *U2S_StopMining) XXX_DiscardUnknown() { 1277 | xxx_messageInfo_U2S_StopMining.DiscardUnknown(m) 1278 | } 1279 | 1280 | var xxx_messageInfo_U2S_StopMining proto.InternalMessageInfo 1281 | 1282 | func (m *U2S_StopMining) GetID() int32 { 1283 | if m != nil { 1284 | return m.ID 1285 | } 1286 | return 0 1287 | } 1288 | 1289 | // 停止挖矿 1290 | type S2U_StopMiningResult struct { 1291 | ID int32 `protobuf:"varint,1,opt,name=ID,proto3" json:"ID,omitempty"` 1292 | ErrorCode int32 `protobuf:"varint,2,opt,name=ErrorCode,proto3" json:"ErrorCode,omitempty"` 1293 | XXX_NoUnkeyedLiteral struct{} `json:"-"` 1294 | XXX_unrecognized []byte `json:"-"` 1295 | XXX_sizecache int32 `json:"-"` 1296 | } 1297 | 1298 | func (m *S2U_StopMiningResult) Reset() { *m = S2U_StopMiningResult{} } 1299 | func (m *S2U_StopMiningResult) String() string { return proto.CompactTextString(m) } 1300 | func (*S2U_StopMiningResult) ProtoMessage() {} 1301 | func (*S2U_StopMiningResult) Descriptor() ([]byte, []int) { 1302 | return fileDescriptor_message_0cde66bc4e56949c, []int{24} 1303 | } 1304 | func (m *S2U_StopMiningResult) XXX_Unmarshal(b []byte) error { 1305 | return xxx_messageInfo_S2U_StopMiningResult.Unmarshal(m, b) 1306 | } 1307 | func (m *S2U_StopMiningResult) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 1308 | return xxx_messageInfo_S2U_StopMiningResult.Marshal(b, m, deterministic) 1309 | } 1310 | func (dst *S2U_StopMiningResult) XXX_Merge(src proto.Message) { 1311 | xxx_messageInfo_S2U_StopMiningResult.Merge(dst, src) 1312 | } 1313 | func (m *S2U_StopMiningResult) XXX_Size() int { 1314 | return xxx_messageInfo_S2U_StopMiningResult.Size(m) 1315 | } 1316 | func (m *S2U_StopMiningResult) XXX_DiscardUnknown() { 1317 | xxx_messageInfo_S2U_StopMiningResult.DiscardUnknown(m) 1318 | } 1319 | 1320 | var xxx_messageInfo_S2U_StopMiningResult proto.InternalMessageInfo 1321 | 1322 | func (m *S2U_StopMiningResult) GetID() int32 { 1323 | if m != nil { 1324 | return m.ID 1325 | } 1326 | return 0 1327 | } 1328 | 1329 | func (m *S2U_StopMiningResult) GetErrorCode() int32 { 1330 | if m != nil { 1331 | return m.ErrorCode 1332 | } 1333 | return 0 1334 | } 1335 | 1336 | // 更新玩家信息 1337 | type U2S_ModifyPlayer struct { 1338 | Name string `protobuf:"bytes,1,opt,name=Name,proto3" json:"Name,omitempty"` 1339 | Style uint32 `protobuf:"varint,2,opt,name=Style,proto3" json:"Style,omitempty"` 1340 | XXX_NoUnkeyedLiteral struct{} `json:"-"` 1341 | XXX_unrecognized []byte `json:"-"` 1342 | XXX_sizecache int32 `json:"-"` 1343 | } 1344 | 1345 | func (m *U2S_ModifyPlayer) Reset() { *m = U2S_ModifyPlayer{} } 1346 | func (m *U2S_ModifyPlayer) String() string { return proto.CompactTextString(m) } 1347 | func (*U2S_ModifyPlayer) ProtoMessage() {} 1348 | func (*U2S_ModifyPlayer) Descriptor() ([]byte, []int) { 1349 | return fileDescriptor_message_0cde66bc4e56949c, []int{25} 1350 | } 1351 | func (m *U2S_ModifyPlayer) XXX_Unmarshal(b []byte) error { 1352 | return xxx_messageInfo_U2S_ModifyPlayer.Unmarshal(m, b) 1353 | } 1354 | func (m *U2S_ModifyPlayer) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 1355 | return xxx_messageInfo_U2S_ModifyPlayer.Marshal(b, m, deterministic) 1356 | } 1357 | func (dst *U2S_ModifyPlayer) XXX_Merge(src proto.Message) { 1358 | xxx_messageInfo_U2S_ModifyPlayer.Merge(dst, src) 1359 | } 1360 | func (m *U2S_ModifyPlayer) XXX_Size() int { 1361 | return xxx_messageInfo_U2S_ModifyPlayer.Size(m) 1362 | } 1363 | func (m *U2S_ModifyPlayer) XXX_DiscardUnknown() { 1364 | xxx_messageInfo_U2S_ModifyPlayer.DiscardUnknown(m) 1365 | } 1366 | 1367 | var xxx_messageInfo_U2S_ModifyPlayer proto.InternalMessageInfo 1368 | 1369 | func (m *U2S_ModifyPlayer) GetName() string { 1370 | if m != nil { 1371 | return m.Name 1372 | } 1373 | return "" 1374 | } 1375 | 1376 | func (m *U2S_ModifyPlayer) GetStyle() uint32 { 1377 | if m != nil { 1378 | return m.Style 1379 | } 1380 | return 0 1381 | } 1382 | 1383 | // 更新玩家信息 1384 | type S2U_ModifyPlayer struct { 1385 | ErrorCode int32 `protobuf:"varint,1,opt,name=ErrorCode,proto3" json:"ErrorCode,omitempty"` 1386 | XXX_NoUnkeyedLiteral struct{} `json:"-"` 1387 | XXX_unrecognized []byte `json:"-"` 1388 | XXX_sizecache int32 `json:"-"` 1389 | } 1390 | 1391 | func (m *S2U_ModifyPlayer) Reset() { *m = S2U_ModifyPlayer{} } 1392 | func (m *S2U_ModifyPlayer) String() string { return proto.CompactTextString(m) } 1393 | func (*S2U_ModifyPlayer) ProtoMessage() {} 1394 | func (*S2U_ModifyPlayer) Descriptor() ([]byte, []int) { 1395 | return fileDescriptor_message_0cde66bc4e56949c, []int{26} 1396 | } 1397 | func (m *S2U_ModifyPlayer) XXX_Unmarshal(b []byte) error { 1398 | return xxx_messageInfo_S2U_ModifyPlayer.Unmarshal(m, b) 1399 | } 1400 | func (m *S2U_ModifyPlayer) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 1401 | return xxx_messageInfo_S2U_ModifyPlayer.Marshal(b, m, deterministic) 1402 | } 1403 | func (dst *S2U_ModifyPlayer) XXX_Merge(src proto.Message) { 1404 | xxx_messageInfo_S2U_ModifyPlayer.Merge(dst, src) 1405 | } 1406 | func (m *S2U_ModifyPlayer) XXX_Size() int { 1407 | return xxx_messageInfo_S2U_ModifyPlayer.Size(m) 1408 | } 1409 | func (m *S2U_ModifyPlayer) XXX_DiscardUnknown() { 1410 | xxx_messageInfo_S2U_ModifyPlayer.DiscardUnknown(m) 1411 | } 1412 | 1413 | var xxx_messageInfo_S2U_ModifyPlayer proto.InternalMessageInfo 1414 | 1415 | func (m *S2U_ModifyPlayer) GetErrorCode() int32 { 1416 | if m != nil { 1417 | return m.ErrorCode 1418 | } 1419 | return 0 1420 | } 1421 | 1422 | // 请求排行榜 1423 | type U2S_Rank struct { 1424 | XXX_NoUnkeyedLiteral struct{} `json:"-"` 1425 | XXX_unrecognized []byte `json:"-"` 1426 | XXX_sizecache int32 `json:"-"` 1427 | } 1428 | 1429 | func (m *U2S_Rank) Reset() { *m = U2S_Rank{} } 1430 | func (m *U2S_Rank) String() string { return proto.CompactTextString(m) } 1431 | func (*U2S_Rank) ProtoMessage() {} 1432 | func (*U2S_Rank) Descriptor() ([]byte, []int) { 1433 | return fileDescriptor_message_0cde66bc4e56949c, []int{27} 1434 | } 1435 | func (m *U2S_Rank) XXX_Unmarshal(b []byte) error { 1436 | return xxx_messageInfo_U2S_Rank.Unmarshal(m, b) 1437 | } 1438 | func (m *U2S_Rank) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 1439 | return xxx_messageInfo_U2S_Rank.Marshal(b, m, deterministic) 1440 | } 1441 | func (dst *U2S_Rank) XXX_Merge(src proto.Message) { 1442 | xxx_messageInfo_U2S_Rank.Merge(dst, src) 1443 | } 1444 | func (m *U2S_Rank) XXX_Size() int { 1445 | return xxx_messageInfo_U2S_Rank.Size(m) 1446 | } 1447 | func (m *U2S_Rank) XXX_DiscardUnknown() { 1448 | xxx_messageInfo_U2S_Rank.DiscardUnknown(m) 1449 | } 1450 | 1451 | var xxx_messageInfo_U2S_Rank proto.InternalMessageInfo 1452 | 1453 | // 排行榜单行数据 1454 | type RankInfo struct { 1455 | NoID uint32 `protobuf:"varint,1,opt,name=NoID,proto3" json:"NoID,omitempty"` 1456 | PlayerID uint32 `protobuf:"varint,2,opt,name=PlayerID,proto3" json:"PlayerID,omitempty"` 1457 | Name string `protobuf:"bytes,3,opt,name=Name,proto3" json:"Name,omitempty"` 1458 | Style uint32 `protobuf:"varint,4,opt,name=Style,proto3" json:"Style,omitempty"` 1459 | Value float32 `protobuf:"fixed32,5,opt,name=Value,proto3" json:"Value,omitempty"` 1460 | XXX_NoUnkeyedLiteral struct{} `json:"-"` 1461 | XXX_unrecognized []byte `json:"-"` 1462 | XXX_sizecache int32 `json:"-"` 1463 | } 1464 | 1465 | func (m *RankInfo) Reset() { *m = RankInfo{} } 1466 | func (m *RankInfo) String() string { return proto.CompactTextString(m) } 1467 | func (*RankInfo) ProtoMessage() {} 1468 | func (*RankInfo) Descriptor() ([]byte, []int) { 1469 | return fileDescriptor_message_0cde66bc4e56949c, []int{28} 1470 | } 1471 | func (m *RankInfo) XXX_Unmarshal(b []byte) error { 1472 | return xxx_messageInfo_RankInfo.Unmarshal(m, b) 1473 | } 1474 | func (m *RankInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 1475 | return xxx_messageInfo_RankInfo.Marshal(b, m, deterministic) 1476 | } 1477 | func (dst *RankInfo) XXX_Merge(src proto.Message) { 1478 | xxx_messageInfo_RankInfo.Merge(dst, src) 1479 | } 1480 | func (m *RankInfo) XXX_Size() int { 1481 | return xxx_messageInfo_RankInfo.Size(m) 1482 | } 1483 | func (m *RankInfo) XXX_DiscardUnknown() { 1484 | xxx_messageInfo_RankInfo.DiscardUnknown(m) 1485 | } 1486 | 1487 | var xxx_messageInfo_RankInfo proto.InternalMessageInfo 1488 | 1489 | func (m *RankInfo) GetNoID() uint32 { 1490 | if m != nil { 1491 | return m.NoID 1492 | } 1493 | return 0 1494 | } 1495 | 1496 | func (m *RankInfo) GetPlayerID() uint32 { 1497 | if m != nil { 1498 | return m.PlayerID 1499 | } 1500 | return 0 1501 | } 1502 | 1503 | func (m *RankInfo) GetName() string { 1504 | if m != nil { 1505 | return m.Name 1506 | } 1507 | return "" 1508 | } 1509 | 1510 | func (m *RankInfo) GetStyle() uint32 { 1511 | if m != nil { 1512 | return m.Style 1513 | } 1514 | return 0 1515 | } 1516 | 1517 | func (m *RankInfo) GetValue() float32 { 1518 | if m != nil { 1519 | return m.Value 1520 | } 1521 | return 0 1522 | } 1523 | 1524 | // 游戏币排行榜 1525 | type S2U_AppCoinRank struct { 1526 | List []*RankInfo `protobuf:"bytes,1,rep,name=list,proto3" json:"list,omitempty"` 1527 | XXX_NoUnkeyedLiteral struct{} `json:"-"` 1528 | XXX_unrecognized []byte `json:"-"` 1529 | XXX_sizecache int32 `json:"-"` 1530 | } 1531 | 1532 | func (m *S2U_AppCoinRank) Reset() { *m = S2U_AppCoinRank{} } 1533 | func (m *S2U_AppCoinRank) String() string { return proto.CompactTextString(m) } 1534 | func (*S2U_AppCoinRank) ProtoMessage() {} 1535 | func (*S2U_AppCoinRank) Descriptor() ([]byte, []int) { 1536 | return fileDescriptor_message_0cde66bc4e56949c, []int{29} 1537 | } 1538 | func (m *S2U_AppCoinRank) XXX_Unmarshal(b []byte) error { 1539 | return xxx_messageInfo_S2U_AppCoinRank.Unmarshal(m, b) 1540 | } 1541 | func (m *S2U_AppCoinRank) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 1542 | return xxx_messageInfo_S2U_AppCoinRank.Marshal(b, m, deterministic) 1543 | } 1544 | func (dst *S2U_AppCoinRank) XXX_Merge(src proto.Message) { 1545 | xxx_messageInfo_S2U_AppCoinRank.Merge(dst, src) 1546 | } 1547 | func (m *S2U_AppCoinRank) XXX_Size() int { 1548 | return xxx_messageInfo_S2U_AppCoinRank.Size(m) 1549 | } 1550 | func (m *S2U_AppCoinRank) XXX_DiscardUnknown() { 1551 | xxx_messageInfo_S2U_AppCoinRank.DiscardUnknown(m) 1552 | } 1553 | 1554 | var xxx_messageInfo_S2U_AppCoinRank proto.InternalMessageInfo 1555 | 1556 | func (m *S2U_AppCoinRank) GetList() []*RankInfo { 1557 | if m != nil { 1558 | return m.List 1559 | } 1560 | return nil 1561 | } 1562 | 1563 | // 今日产出(比特币)排行榜 1564 | type S2U_BtcRank struct { 1565 | List []*RankInfo `protobuf:"bytes,1,rep,name=list,proto3" json:"list,omitempty"` 1566 | XXX_NoUnkeyedLiteral struct{} `json:"-"` 1567 | XXX_unrecognized []byte `json:"-"` 1568 | XXX_sizecache int32 `json:"-"` 1569 | } 1570 | 1571 | func (m *S2U_BtcRank) Reset() { *m = S2U_BtcRank{} } 1572 | func (m *S2U_BtcRank) String() string { return proto.CompactTextString(m) } 1573 | func (*S2U_BtcRank) ProtoMessage() {} 1574 | func (*S2U_BtcRank) Descriptor() ([]byte, []int) { 1575 | return fileDescriptor_message_0cde66bc4e56949c, []int{30} 1576 | } 1577 | func (m *S2U_BtcRank) XXX_Unmarshal(b []byte) error { 1578 | return xxx_messageInfo_S2U_BtcRank.Unmarshal(m, b) 1579 | } 1580 | func (m *S2U_BtcRank) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 1581 | return xxx_messageInfo_S2U_BtcRank.Marshal(b, m, deterministic) 1582 | } 1583 | func (dst *S2U_BtcRank) XXX_Merge(src proto.Message) { 1584 | xxx_messageInfo_S2U_BtcRank.Merge(dst, src) 1585 | } 1586 | func (m *S2U_BtcRank) XXX_Size() int { 1587 | return xxx_messageInfo_S2U_BtcRank.Size(m) 1588 | } 1589 | func (m *S2U_BtcRank) XXX_DiscardUnknown() { 1590 | xxx_messageInfo_S2U_BtcRank.DiscardUnknown(m) 1591 | } 1592 | 1593 | var xxx_messageInfo_S2U_BtcRank proto.InternalMessageInfo 1594 | 1595 | func (m *S2U_BtcRank) GetList() []*RankInfo { 1596 | if m != nil { 1597 | return m.List 1598 | } 1599 | return nil 1600 | } 1601 | 1602 | func init() { 1603 | proto.RegisterType((*U2S_Login)(nil), "msg.U2S_Login") 1604 | proto.RegisterType((*S2U_LoginResult)(nil), "msg.S2U_LoginResult") 1605 | proto.RegisterType((*U2S_RegistAccount)(nil), "msg.U2S_RegistAccount") 1606 | proto.RegisterType((*G2U_RegistAccountResult)(nil), "msg.G2U_RegistAccountResult") 1607 | proto.RegisterType((*S2U_PlayerBase)(nil), "msg.S2U_PlayerBase") 1608 | proto.RegisterType((*S2U_Notice)(nil), "msg.S2U_Notice") 1609 | proto.RegisterType((*U2S_Chat)(nil), "msg.U2S_Chat") 1610 | proto.RegisterType((*S2U_Chat)(nil), "msg.S2U_Chat") 1611 | proto.RegisterType((*U2S_ShopList)(nil), "msg.U2S_ShopList") 1612 | proto.RegisterType((*ShopInfo)(nil), "msg.ShopInfo") 1613 | proto.RegisterType((*S2U_ShopList)(nil), "msg.S2U_ShopList") 1614 | proto.RegisterType((*U2S_Buy)(nil), "msg.U2S_Buy") 1615 | proto.RegisterType((*S2U_BuyResult)(nil), "msg.S2U_BuyResult") 1616 | proto.RegisterType((*U2S_MineMachineList)(nil), "msg.U2S_MineMachineList") 1617 | proto.RegisterType((*MineMachine)(nil), "msg.MineMachine") 1618 | proto.RegisterType((*S2U_MineMachineList)(nil), "msg.S2U_MineMachineList") 1619 | proto.RegisterType((*U2S_MineList)(nil), "msg.U2S_MineList") 1620 | proto.RegisterType((*MineInfo)(nil), "msg.MineInfo") 1621 | proto.RegisterType((*S2U_MineList)(nil), "msg.S2U_MineList") 1622 | proto.RegisterType((*U2S_Mining)(nil), "msg.U2S_Mining") 1623 | proto.RegisterType((*S2U_MiningResult)(nil), "msg.S2U_MiningResult") 1624 | proto.RegisterType((*U2S_GatherMine)(nil), "msg.U2S_GatherMine") 1625 | proto.RegisterType((*S2U_GatherMine)(nil), "msg.S2U_GatherMine") 1626 | proto.RegisterType((*U2S_StopMining)(nil), "msg.U2S_StopMining") 1627 | proto.RegisterType((*S2U_StopMiningResult)(nil), "msg.S2U_StopMiningResult") 1628 | proto.RegisterType((*U2S_ModifyPlayer)(nil), "msg.U2S_ModifyPlayer") 1629 | proto.RegisterType((*S2U_ModifyPlayer)(nil), "msg.S2U_ModifyPlayer") 1630 | proto.RegisterType((*U2S_Rank)(nil), "msg.U2S_Rank") 1631 | proto.RegisterType((*RankInfo)(nil), "msg.RankInfo") 1632 | proto.RegisterType((*S2U_AppCoinRank)(nil), "msg.S2U_AppCoinRank") 1633 | proto.RegisterType((*S2U_BtcRank)(nil), "msg.S2U_BtcRank") 1634 | } 1635 | 1636 | func init() { proto.RegisterFile("message.proto", fileDescriptor_message_0cde66bc4e56949c) } 1637 | 1638 | var fileDescriptor_message_0cde66bc4e56949c = []byte{ 1639 | // 964 bytes of a gzipped FileDescriptorProto 1640 | 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x56, 0xdf, 0x6e, 0xe3, 0xc4, 1641 | 0x17, 0x96, 0x9d, 0xb8, 0x4d, 0x4e, 0x9b, 0xfc, 0xfa, 0xf3, 0x16, 0x88, 0xaa, 0x15, 0x0a, 0xa3, 1642 | 0x15, 0xea, 0x0d, 0xd5, 0x12, 0x90, 0xb8, 0x00, 0x24, 0xb6, 0x49, 0x55, 0x45, 0x6a, 0x4a, 0x35, 1643 | 0x69, 0x97, 0x4b, 0x64, 0x9c, 0x59, 0x67, 0x54, 0x7b, 0xc6, 0xb2, 0xc7, 0x82, 0x20, 0xde, 0x88, 1644 | 0x1b, 0x9e, 0x01, 0x1e, 0x88, 0x57, 0x40, 0x67, 0xfe, 0xd8, 0x4e, 0x36, 0xaa, 0x2a, 0xae, 0xb8, 1645 | 0xca, 0xf9, 0x8e, 0xc7, 0x33, 0xe7, 0xfb, 0xce, 0x37, 0xc7, 0x81, 0x41, 0xc6, 0xca, 0x32, 0x4a, 1646 | 0xd8, 0x45, 0x5e, 0x48, 0x25, 0xc3, 0x4e, 0x56, 0x26, 0xe4, 0x2f, 0x0f, 0xfa, 0x0f, 0x93, 0xe5, 1647 | 0x8f, 0x37, 0x32, 0xe1, 0x22, 0xfc, 0x18, 0x60, 0xb9, 0x7a, 0x7c, 0x13, 0xc7, 0xb2, 0x12, 0x6a, 1648 | 0xe4, 0x8d, 0xbd, 0xf3, 0x3e, 0x6d, 0x65, 0xc2, 0x31, 0x1c, 0x2d, 0x57, 0x8f, 0xd3, 0x94, 0x33, 1649 | 0xa1, 0xe6, 0xb3, 0x91, 0xaf, 0x17, 0xb4, 0x53, 0xe1, 0xa7, 0x30, 0x34, 0xeb, 0x59, 0x59, 0xde, 1650 | 0xcb, 0x47, 0x26, 0x46, 0x1d, 0xbd, 0x68, 0x27, 0x1b, 0xbe, 0x84, 0xfe, 0x74, 0x1d, 0x09, 0xc1, 1651 | 0xd2, 0xf9, 0x6c, 0xd4, 0x1d, 0x7b, 0xe7, 0x01, 0x6d, 0x12, 0xe1, 0x08, 0x0e, 0xaf, 0xa3, 0x8c, 1652 | 0xbd, 0x65, 0xc5, 0xe8, 0x60, 0xec, 0x9d, 0x0f, 0xa8, 0x83, 0xe1, 0x29, 0x04, 0x57, 0xbf, 0xa8, 1653 | 0x22, 0x1a, 0x1d, 0xea, 0x6d, 0x0d, 0x20, 0x25, 0xfc, 0x6f, 0x39, 0x79, 0x30, 0x24, 0x28, 0x2b, 1654 | 0xab, 0x54, 0x85, 0x1f, 0xc2, 0x81, 0x89, 0x34, 0x8d, 0x01, 0xb5, 0x08, 0xb7, 0x76, 0xfc, 0x4c, 1655 | 0xf9, 0x0e, 0x62, 0x49, 0x78, 0x8a, 0xaa, 0xab, 0xee, 0xd0, 0x26, 0x11, 0x9e, 0x40, 0x67, 0x51, 1656 | 0x26, 0xba, 0xd4, 0x3e, 0xc5, 0x90, 0xfc, 0xed, 0xc1, 0xff, 0x51, 0x3a, 0xca, 0x12, 0x5e, 0x2a, 1657 | 0xb7, 0xcb, 0x7f, 0x45, 0xc2, 0x10, 0xba, 0xf3, 0x8c, 0xf1, 0x51, 0xa0, 0xdf, 0xd5, 0x31, 0x8a, 1658 | 0x77, 0xb7, 0x96, 0x82, 0x69, 0x51, 0xfb, 0xd4, 0x00, 0x5c, 0x79, 0x1b, 0x65, 0xcc, 0x2a, 0xaa, 1659 | 0x63, 0x5c, 0xb9, 0x54, 0x9b, 0x94, 0x8d, 0x7a, 0x5a, 0x3c, 0x03, 0xc8, 0x57, 0xf0, 0xd1, 0xf5, 1660 | 0xe4, 0x61, 0x9b, 0xb0, 0x95, 0xf5, 0x25, 0xf4, 0xaf, 0x8a, 0x42, 0x16, 0x53, 0xb9, 0x62, 0x9a, 1661 | 0x75, 0x40, 0x9b, 0x04, 0xf9, 0xd3, 0x83, 0x21, 0x36, 0xe8, 0x2e, 0x8d, 0x36, 0xac, 0xb8, 0x8c, 1662 | 0x4a, 0x16, 0x9e, 0x41, 0xcf, 0xa0, 0xf9, 0xcc, 0x76, 0xa8, 0xc6, 0x4f, 0xf4, 0xc8, 0xd5, 0xda, 1663 | 0xd9, 0x57, 0x6b, 0xb7, 0x55, 0x2b, 0xee, 0xff, 0x26, 0xcf, 0xa7, 0x92, 0x8b, 0x52, 0x6b, 0xe0, 1664 | 0xd3, 0x1a, 0x87, 0x04, 0x8e, 0xa7, 0x32, 0xcb, 0x2b, 0xc5, 0xee, 0xe4, 0xcf, 0xd6, 0x63, 0x3e, 1665 | 0xdd, 0xca, 0x61, 0xbf, 0x2f, 0x55, 0xac, 0x45, 0xf1, 0x29, 0x86, 0x64, 0x02, 0x80, 0x1c, 0x6e, 1666 | 0xa5, 0xe2, 0xb1, 0x56, 0xed, 0x7e, 0x93, 0x3b, 0xae, 0x3a, 0x76, 0x1e, 0xc1, 0x9a, 0x8f, 0x8d, 1667 | 0x47, 0x5e, 0x41, 0x0f, 0x2d, 0x32, 0x5d, 0x47, 0xda, 0x79, 0xb1, 0x14, 0x8a, 0x35, 0xac, 0x2c, 1668 | 0x24, 0xb7, 0xd0, 0xc3, 0x9d, 0xf5, 0xaa, 0x10, 0xba, 0x02, 0x19, 0x1a, 0xe7, 0xe8, 0xb8, 0x61, 1669 | 0xe8, 0xb7, 0x19, 0xb6, 0xf6, 0xeb, 0x6c, 0xef, 0x37, 0x84, 0x63, 0x3c, 0x75, 0xb9, 0x96, 0xf9, 1670 | 0x0d, 0x2f, 0x15, 0xf9, 0xc3, 0x83, 0x1e, 0x82, 0xb9, 0x78, 0x27, 0xb1, 0x53, 0x79, 0x21, 0x57, 1671 | 0x55, 0xac, 0xac, 0xf2, 0x01, 0x6d, 0x12, 0xf8, 0xb4, 0x60, 0x39, 0x2b, 0x94, 0x2c, 0x36, 0xfa, 1672 | 0xb8, 0x80, 0x36, 0x09, 0x14, 0x95, 0xa5, 0x2c, 0x56, 0x05, 0x8f, 0xf5, 0x99, 0x3e, 0xad, 0x31, 1673 | 0x1a, 0x3f, 0x8b, 0x44, 0x94, 0xb0, 0xa9, 0x2c, 0x95, 0xee, 0x85, 0x4f, 0x5b, 0x19, 0xbc, 0x90, 1674 | 0xb2, 0x52, 0x79, 0xa5, 0x6c, 0x3b, 0x2c, 0x42, 0x72, 0x79, 0xc1, 0x63, 0x66, 0xbb, 0x60, 0x00, 1675 | 0xf9, 0x1c, 0x8e, 0x51, 0x12, 0x47, 0x21, 0xfc, 0x04, 0xba, 0x29, 0x2f, 0xf1, 0x42, 0x75, 0xce, 1676 | 0x8f, 0x26, 0x83, 0x8b, 0xac, 0x4c, 0x2e, 0x1c, 0x25, 0xaa, 0x1f, 0x91, 0x6f, 0xe1, 0x10, 0x59, 1677 | 0x5f, 0x56, 0x1b, 0x64, 0x71, 0xb7, 0xcb, 0xb1, 0x4e, 0xe0, 0x89, 0xd3, 0xda, 0x5c, 0x01, 0x35, 1678 | 0x80, 0x7c, 0x06, 0x03, 0x3c, 0xf1, 0xb2, 0xda, 0x3c, 0xcb, 0xd2, 0x1f, 0xc0, 0x0b, 0x3c, 0x6d, 1679 | 0xc1, 0x05, 0x5b, 0x44, 0xf1, 0x9a, 0x0b, 0xa6, 0xa5, 0xfe, 0xdd, 0x83, 0xa3, 0x56, 0x2e, 0x1c, 1680 | 0x82, 0x5f, 0x97, 0xe0, 0x1b, 0x7d, 0x9b, 0xca, 0xfc, 0xdd, 0xca, 0xce, 0xa0, 0x77, 0x23, 0xe3, 1681 | 0x48, 0x71, 0x69, 0x2e, 0x7d, 0x40, 0x6b, 0x8c, 0xed, 0xa6, 0x95, 0xb8, 0xe7, 0x99, 0x31, 0x7a, 1682 | 0x87, 0x3a, 0x88, 0x4f, 0xae, 0xc4, 0x4a, 0x3f, 0x09, 0xcc, 0x13, 0x0b, 0xb1, 0x27, 0xdf, 0x6b, 1683 | 0x95, 0xd1, 0xf7, 0x56, 0xe0, 0x56, 0x86, 0x7c, 0x0d, 0x2f, 0x90, 0xf3, 0x0e, 0x89, 0xf0, 0xd5, 1684 | 0x96, 0xd8, 0x27, 0x5a, 0xec, 0xd6, 0x1a, 0xab, 0xb7, 0x75, 0xd9, 0xc2, 0x51, 0xff, 0x0d, 0x7a, 1685 | 0x18, 0x6b, 0x93, 0xb5, 0x89, 0x78, 0x3b, 0x44, 0xce, 0xa0, 0x77, 0xe5, 0x4c, 0xe4, 0x1b, 0x13, 1686 | 0x39, 0x8c, 0x37, 0xe8, 0x9e, 0xe7, 0xd6, 0x5b, 0x18, 0x62, 0xb3, 0x28, 0xbe, 0x67, 0x1d, 0x65, 1687 | 0x00, 0xae, 0xbb, 0xad, 0x32, 0x4d, 0x37, 0xa0, 0x18, 0x3a, 0xc3, 0xb8, 0x6a, 0xf6, 0x1a, 0xc6, 1688 | 0x95, 0x67, 0x09, 0x50, 0x00, 0x4b, 0x80, 0x8b, 0xe4, 0xbd, 0x4e, 0xb5, 0x29, 0xf8, 0xef, 0xf7, 1689 | 0xe2, 0x07, 0x9e, 0xa6, 0xb3, 0x68, 0x63, 0xdb, 0xe4, 0x20, 0xf9, 0x0e, 0x4e, 0x6c, 0x19, 0x5c, 1690 | 0x24, 0xd6, 0x48, 0x7b, 0x3c, 0xd0, 0x18, 0xcb, 0xdf, 0x35, 0xd6, 0x37, 0x30, 0xc4, 0xaa, 0xae, 1691 | 0x23, 0xb5, 0x66, 0xc5, 0x62, 0x9f, 0x87, 0x9e, 0xa8, 0x8c, 0x4c, 0xcc, 0xa0, 0x7d, 0xe2, 0x6d, 1692 | 0x3b, 0xd8, 0xfc, 0x66, 0xb0, 0x8d, 0xcd, 0x89, 0x4b, 0x25, 0xf3, 0xfd, 0x5a, 0x90, 0x19, 0x9c, 1693 | 0xea, 0xdb, 0x58, 0xaf, 0xf8, 0x97, 0xcc, 0x4e, 0xb4, 0xde, 0x72, 0xc5, 0xdf, 0x6d, 0xcc, 0xb0, 1694 | 0xaf, 0x07, 0xba, 0xb7, 0x6f, 0xa0, 0xb7, 0xc7, 0x1d, 0x79, 0x6d, 0x95, 0x6d, 0xbf, 0xfd, 0xf4, 1695 | 0x15, 0x05, 0x33, 0x7c, 0x69, 0x24, 0x1e, 0xc9, 0xaf, 0xd0, 0xc3, 0x5f, 0x6d, 0x4e, 0x3c, 0x53, 1696 | 0xd6, 0x9f, 0x1d, 0x1d, 0x6f, 0x7d, 0x8e, 0xfc, 0x9d, 0xcf, 0xd1, 0xf3, 0x3f, 0x3a, 0xa7, 0x10, 1697 | 0xbc, 0x8d, 0xd2, 0x8a, 0xd9, 0x11, 0x67, 0x00, 0xf9, 0xd2, 0xfc, 0x3b, 0xb1, 0x9f, 0x1f, 0x2c, 1698 | 0x63, 0xaf, 0x3b, 0x5d, 0x7d, 0xd6, 0x9d, 0xaf, 0xe1, 0x48, 0xcf, 0x23, 0x15, 0x3f, 0xf3, 0x8d, 1699 | 0x9f, 0x0e, 0xf4, 0xff, 0xba, 0x2f, 0xfe, 0x09, 0x00, 0x00, 0xff, 0xff, 0xcb, 0xa9, 0x5c, 0xde, 1700 | 0xe8, 0x09, 0x00, 0x00, 1701 | } 1702 | -------------------------------------------------------------------------------- /server/src/server/msg/msg.go: -------------------------------------------------------------------------------- 1 | package msg 2 | import ( 3 | "github.com/name5566/leaf/network/protobuf" 4 | ) 5 | 6 | var ( 7 | Processor = protobuf.NewProcessor() 8 | ) 9 | 10 | func init() { // 这里我们注册 protobuf 消息) 11 | Processor.SetByteOrder(true) 12 | Processor.Register(&U2S_Login{}) 13 | Processor.Register(&S2U_LoginResult{}) 14 | Processor.Register(&U2S_RegistAccount{}) 15 | Processor.Register(&G2U_RegistAccountResult{}) 16 | Processor.Register(&S2U_PlayerBase{}) 17 | Processor.Register(&S2U_Notice{}) 18 | Processor.Register(&U2S_Chat{}) 19 | Processor.Register(&S2U_Chat{}) 20 | Processor.Register(&U2S_ShopList{}) 21 | Processor.Register(&ShopInfo{}) 22 | Processor.Register(&S2U_ShopList{}) 23 | Processor.Register(&U2S_Buy{}) 24 | Processor.Register(&S2U_BuyResult{}) 25 | Processor.Register(&U2S_MineMachineList{}) 26 | Processor.Register(&MineMachine{}) 27 | Processor.Register(&S2U_MineMachineList{}) 28 | Processor.Register(&U2S_MineList{}) 29 | Processor.Register(&MineInfo{}) 30 | Processor.Register(&S2U_MineList{}) 31 | Processor.Register(&U2S_Mining{}) 32 | Processor.Register(&S2U_MiningResult{}) 33 | Processor.Register(&U2S_GatherMine{}) 34 | Processor.Register(&S2U_GatherMine{}) 35 | Processor.Register(&U2S_StopMining{}) 36 | Processor.Register(&S2U_StopMiningResult{}) 37 | Processor.Register(&U2S_ModifyPlayer{}) 38 | Processor.Register(&S2U_ModifyPlayer{}) 39 | Processor.Register(&U2S_Rank{}) 40 | Processor.Register(&RankInfo{}) 41 | Processor.Register(&S2U_AppCoinRank{}) 42 | Processor.Register(&S2U_BtcRank{}) 43 | 44 | } -------------------------------------------------------------------------------- /server/src/server/mysql/mysql.go: -------------------------------------------------------------------------------- 1 | package mysql 2 | 3 | import ( 4 | "database/sql" 5 | _ "github.com/go-sql-driver/mysql" 6 | "server/conf" 7 | "github.com/name5566/leaf/log" 8 | ) 9 | 10 | var ( 11 | db *sql.DB 12 | ) 13 | 14 | func OpenDB() { 15 | log.Release("mysqldb->open db") 16 | db1, err := sql.Open("mysql", conf.Server.MySqlUrl) 17 | if err != nil { 18 | db.Close() 19 | panic("connect db error") 20 | } 21 | db = db1 22 | } 23 | 24 | func MysqlDB() *sql.DB { 25 | return db 26 | } 27 | 28 | func CheckErr(err error) { 29 | if err != nil { 30 | panic(err) 31 | } 32 | } 33 | 34 | func PingDB() { 35 | db :=MysqlDB() 36 | db.Ping() 37 | } 38 | --------------------------------------------------------------------------------