少年修仙传客户端代码仓库
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
using Snxxz.UI;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Security.Cryptography;
using System.Text;
using UnityEngine;
 
public class LanguageVerify : Singleton<LanguageVerify>
{
    const string RequireVerifyAppid = "498mrgame";
    const string Sercret = "c345a165b566d1c421afd8a748373d7f";
    bool requireVerify
    {
        get
        {
            return VersionConfig.Get().appId.Equals(RequireVerifyAppid);
        }
    }
 
    static StringBuilder s_StringBuilder = new StringBuilder();
 
    const string VerifyPlayerNameUrl = "https://api.maoergame.com/game/role/response";
    /// <summary>
    /// 校验玩家名
    /// </summary>
    /// <param name="verifyName">需要检验的名字</param>
    /// <param name="playerId">玩家id</param>
    /// <param name="playerName">原来的角色名,创角传空</param>
    /// <param name="level">玩家等级</param>
    /// <param name="vipLv">玩家VIP等级</param>
    /// <param name="callback"></param>
    public void VerifyPlayerName(string verifyName, int playerId, string playerName, int level, int vipLv, Action<bool, string> callback)
    {
        if (!requireVerify)
        {
            if (callback != null)
            {
                callback(true, verifyName);
                callback = null;
            }
            return;
        }
        NetLinkWin.Show();
        var tables = new Dictionary<string, string>();
        tables["game_code"] = "snxxz";
        tables["server_id"] = ServerListCenter.Instance.currentServer.region_flag.ToString();
        tables["server_name"] = StringUtility.Contact("s", ServerListCenter.Instance.currentServer.region_flag);
        tables["role_name"] = verifyName;
        tables["sender_uid"] = ModelCenter.Instance.GetModel<LoginModel>().sdkLoginResult.account;
        tables["sender_rid"] = playerId.ToString();
        tables["sender_name"] = playerName;
        tables["sender_level"] = level.ToString();
        tables["sender_vip_level"] = vipLv.ToString();
        var ts = System.DateTime.UtcNow - new System.DateTime(1970, 1, 1, 0, 0, 0, 0);
        tables["timestamp"] = ((long)System.Convert.ToInt64(ts.TotalSeconds)).ToString();
        tables["key"] = FileExtersion.GetStringMD5Hash(StringUtility.Contact(Sercret, tables["timestamp"]));
        HttpRequest.Instance.RequestHttpPost(VerifyPlayerNameUrl, tables, HttpRequest.defaultHttpContentType, 3,
            (bool ok, string result) =>
               {
                   DebugEx.Log(result);
                   if (ok)
                   {
                       var response = LitJson.JsonMapper.ToObject<VerifyResponse>(result);
                       if (response != null)
                       {
                           if (response.result.Equals("success"))
                           {
                               if (callback != null)
                               {
                                   callback(true, verifyName);
                                   callback = null;
                                   return;
                               }
                           }
                       }
                   }
                   NetLinkWin.Hide();
               });
    }
 
    const string VerifyFairyUrl = "https://api.maoergame.com/game/sociaty/response";
    public void VerifyFairy(string verifyContent, int op_type, string fairyName, int title, Action<bool, string> callback)
    {
        if (!requireVerify)
        {
            if (callback != null)
            {
                callback(true, verifyContent);
                callback = null;
            }
            return;
        }
 
        var account = ModelCenter.Instance.GetModel<LoginModel>().sdkLoginResult.account;
        var playerId = PlayerDatas.Instance.baseData.PlayerID;
        var playerName = PlayerDatas.Instance.baseData.PlayerName;
 
        var tables = new Dictionary<string, string>();
        tables["game_code"] = "snxxz";
        tables["server_id"] = ServerListCenter.Instance.currentServer.region_flag.ToString();
        tables["server_name"] = StringUtility.Contact("s", ServerListCenter.Instance.currentServer.region_flag);
        tables["op_type"] = op_type.ToString();
        tables["name"] = op_type == 1 ? fairyName : verifyContent;
 
        tables["leader_uid"] = title == 3 ? account : string.Empty;
        tables["leader_rid"] = title == 3 ? playerId.ToString() : string.Empty;
        tables["leader_name"] = title == 3 ? playerName : string.Empty;
 
        tables["vice_leader_uid"] = title == 2 ? account : string.Empty;
        tables["vice_leader_rid"] = title == 2 ? playerId.ToString() : string.Empty;
        tables["vice_leader_name"] = title == 2 ? playerName : string.Empty;
 
        tables["edit_uid"] = account;
        tables["edit_rid"] = playerId.ToString();
        tables["edit_name"] = UIHelper.ServerStringTrim(playerName);
 
        tables["notice"] = op_type == 2 ? string.Empty : verifyContent;
        var ts = System.DateTime.UtcNow - new System.DateTime(1970, 1, 1, 0, 0, 0, 0);
        tables["timestamp"] = ((long)System.Convert.ToInt64(ts.TotalSeconds)).ToString();
        tables["key"] = FileExtersion.GetStringMD5Hash(StringUtility.Contact(Sercret, tables["timestamp"]));
 
        HttpRequest.Instance.RequestHttpPost(VerifyFairyUrl, tables, HttpRequest.defaultHttpContentType, 3,
            (bool ok, string result) =>
            {
                DebugEx.Log(result);
                if (ok)
                {
                    var response = LitJson.JsonMapper.ToObject<VerifyResponse>(result);
                    if (response != null)
                    {
                        if (response.result.Equals("success"))
                        {
                            if (callback != null)
                            {
                                callback(true, response.content);
                                callback = null;
                                return;
                            }
                        }
                    }
                }
            });
    }
 
    public static uint toPlayer = 0;
    public static string toPlayerName = string.Empty;
    public static int toPlayerLevel = 0;
    const string VerifyChatUrl = "https://api.maoergame.com/game/chat/response";
    public void VerifyChat(string content, ChatInfoType channelType, Action<bool, string> callback)
    {
        int channel = 0;
        if (!requireVerify || !GetChannel(channelType, out channel) || PlayerDatas.Instance.baseData.VIPLv >= 4)
        {
            if (callback != null)
            {
                callback(true, content);
                callback = null;
            }
            return;
        }
 
        var account = ModelCenter.Instance.GetModel<LoginModel>().sdkLoginResult.account;
        var playerId = PlayerDatas.Instance.baseData.PlayerID;
        var playerName = PlayerDatas.Instance.baseData.PlayerName;
 
        var tables = new Dictionary<string, string>();
        tables["game_code"] = "snxxz";
        tables["server_id"] = ServerListCenter.Instance.currentServer.region_flag.ToString();
        tables["server_name"] = StringUtility.Contact("s", ServerListCenter.Instance.currentServer.region_flag);
        tables["chat_type"] = 1.ToString();
        tables["chat_channel"] = channel.ToString();
        tables["chat_content"] = WWW.EscapeURL(UIHelper.TrimContentToServer(content));
        tables["sender_uid"] = account;
        tables["sender_rid"] = playerId.ToString();
        tables["sender_name"] = UIHelper.ServerStringTrim(playerName);
        tables["sender_level"] = PlayerDatas.Instance.baseData.PlayerID.ToString();
        tables["sender_vip_level"] = PlayerDatas.Instance.baseData.VIPLv.ToString();
 
        tables["receiver_uid"] = string.Empty;
        tables["receiver_rid"] = channel == 3 ? toPlayer.ToString() : string.Empty;
        tables["receiver_name"] = channel == 3 ? UIHelper.ServerStringTrim(toPlayerName) : string.Empty;
        tables["receiver_level"] = channel == 3 ? (toPlayerLevel == 0 ? string.Empty : toPlayerLevel.ToString()) : string.Empty;
        tables["receiver_vip_level"] = string.Empty;
 
        var ts = System.DateTime.UtcNow - new System.DateTime(1970, 1, 1, 0, 0, 0, 0);
        tables["timestamp"] = ((long)System.Convert.ToInt64(ts.TotalSeconds)).ToString();
        tables["key"] = FileExtersion.GetStringMD5Hash(StringUtility.Contact(Sercret, tables["timestamp"]));
 
        HttpRequest.Instance.RequestHttpPost(VerifyChatUrl, tables, HttpRequest.defaultHttpContentType, 3,
            (bool ok, string result) =>
            {
                DebugEx.Log(result);
                if (ok)
                {
                    var response = LitJson.JsonMapper.ToObject<VerifyResponse>(result);
                    if (response != null)
                    {
                        if (response.result.Equals("success"))
                        {
                            if (callback != null)
                            {
                                callback(true, response.content);
                                callback = null;
                                return;
                            }
                        }
                        else if (response.result.Equals("verify_fail"))
                        {
                            switch (response.code)
                            {
                                case -1:
                                    MessageWin.Inst.ShowFixedTip(Language.Get("L1007"));
                                    break;
                                case -2:
                                    SysNotifyMgr.Instance.ShowTip("VerifyErrorCode2");
                                    break;
                                case -3:
                                    break;
                            }
                        }
                    }
                }
            });
    }
 
    bool GetChannel(ChatInfoType type, out int channel)
    {
        channel = 0;
        switch (type)
        {
            case ChatInfoType.World:
                channel = 0;
                break;
            case ChatInfoType.Team:
                channel = 4;
                break;
            case ChatInfoType.Area:
            case ChatInfoType.Trumpet:
                channel = 5;
                break;
            case ChatInfoType.Fairy:
                channel = 2;
                break;
            case ChatInfoType.Friend:
                channel = 3;
                break;
            default:
                return false;
        }
        return true;
    }
 
    public class VerifyResponse
    {
        public string result;
        public int code;
        public string content;
    }
}