-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlayer.cs
87 lines (78 loc) · 2.84 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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml.Linq;
using System.Media;
namespace yugioh
{
public class Player
{
#region ctor
public Player()
{
LifePoints = 8000;
KaibaOrYugi = "kaiba";
DeckFile = XDocument.Load(@"C:\Users\USER\Documents\Visual Studio 2015\Projects\yugioh\yugioh\Deck2.xml");
Graveyard = new List<Card>();
Hand = new List<Card>();
FieldATK = new List<Card>();
FieldDEF = new List<Card>();
DeckCardCount = int.Parse(DeckFile.Root.Element("CardCount").Value);
Deck = new List<Card>();
for(int DeckPosition = 0; DeckPosition < DeckCardCount; DeckPosition++)
{
Card card = new Card(DeckFile.Root.Elements("card").ElementAt(DeckCardCount));
Deck.Add(card);
}
Deck = shuffling(Deck);
}
#endregion
#region shuffling
public List<Card> shuffling(List<Card> deck)
{
// the suffleing
Random rnd = new Random(1);
int newDeckPosition = 0;
for (int deckPosition = 1; deckPosition <= DeckCardCount; deckPosition++)
{
int position = Deck.ElementAt(deckPosition).CurrentDeckPosition;
newDeckPosition = rnd.Next(1, 30);
int positionCount = 0;
for (int deckCheck = 1; deckCheck <= DeckCardCount; deckCheck++)
{
if (newDeckPosition == deckCheck)
{
positionCount = positionCount + 1;
}
}
while (positionCount > 1)
{
DeckFile.Root.Elements("card").ElementAt(deckPosition);
newDeckPosition = rnd.Next(1, 30);
positionCount = 0;
for (int deckCheck = 1; deckCheck <= DeckCardCount; deckCheck++)
{
if (newDeckPosition == deckCheck)
{
positionCount = positionCount + 1;
}
}
}
Deck.ElementAt(deckPosition).CurrentDeckPosition = newDeckPosition;
}
return Deck;
}
#endregion
#region properties
public int LifePoints { get; set; }
public string KaibaOrYugi { get; set; }
XDocument DeckFile { get; set; }
public List<Card> Deck { get; set; }
public List<Card> Graveyard { get; set; }
public List<Card> Hand { get; set; }
public List<Card> FieldATK { get; set; }
public List<Card> FieldDEF { get; set; }
public int DeckCardCount { get; set; }
#endregion
}
}