forked from kemot90/GameClient
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlayer.cs
109 lines (99 loc) · 2.55 KB
/
Player.cs
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
using System;
using System.Windows;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Net.Sockets;
using MySql.Data.MySqlClient;
using Commands;
namespace RPGClient
{
class Player
{
//właściwości gracza
private ulong id;
private string login;
private string password;
private int access;
private string email;
//ustawienie połączenia z serwerem
//obiekt gniazda do połączenia z serwerem
private TcpClient client;
//koder/dekoder danych z serwera
private UTF8Encoding code;
//właściwości gniazda
private string host;
private int port;
//konstruktor gracza
public Player(ulong _id, TcpClient userClient)
{
//ustawienie identyfikatora gracza
id = _id;
//wczytanie ustawień dla połączenia z serwerem
host = Properties.Settings.Default.Host;
port = Properties.Settings.Default.Port;
//inicjalizacja gniazda połączenia z serwerem
try
{
client = userClient;
code = new UTF8Encoding();
Command request = new Command(ClientCmd.GET_PLAYER_DATA);
request.Add(id.ToString());
string[] dane = request.Apply(client.Client, true);
if (dane[0] == ServerCmd.PLAYER_DATA)
{
login = dane[1];
password = dane[2];
access = int.Parse(dane[3]);
email = dane[4];
}
}
catch
{
//obsługa wyjątku
}
}
public ulong Id
{
get
{
return id;
}
}
public string Login
{
get
{
return login;
}
}
public string Password
{
get
{
return password;
}
}
public string Email
{
get
{
return email;
}
}
public int Access
{
get
{
return access;
}
}
//zamiana stringa cmd na akcję i ciąg argumentów
private string[] cmdToArgs(string command)
{
string[] args = command.Split(';');
return args;
}
}
}