-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlayer.cs
62 lines (61 loc) · 2.08 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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MinTetris
{
//Class Player is used to create top players list
//Клас "Гравець". Використовується для створення списку кращих гравців
[Serializable]
public class Player : IComparable <Player>
{
public Player()
{
name = "Player";
score = 0;
lines = 0;
level = 0;
}
public string name { get; set; }
public int score { get; set; }
public int lines { get; set; }
public int level { get; set; }
public string gameType { get; set; }
//Compare two players by score
//Метод для порівняння двох гравців за їхніми очками
public int CompareTo (Player other)
{
return score.CompareTo(other.score);
}
//Create Default Top List
//Створення списку за замовчуванням
public List<Player> DefaultList()
{
List<Player> list = new List<Player>();
for (int lines = 10; lines <=100; lines+=10)
{
Player player = new Player();
player.lines = lines;
player.score = lines * 100;
player.level = lines / 10;
player.name = "Player " + (11-player.level).ToString();
player.gameType = "Tetromino";
list.Add(player);
}
for (int lines = 1; lines <= 10; lines ++)
{
Player player = new Player();
player.lines = lines;
player.score = lines * 100;
player.level = lines / 10;
player.name = "Player " + (11 - player.lines).ToString();
player.gameType = "Pentomino";
list.Add(player);
}
list.Sort();
list.Reverse();
return list;
}
}
}