Example #1
0
 //Default constructor, for testing purposes.
 public Player()
 {
     playerNumber = 1;
     playerBox = new PlayerBox();
     db = null;
     hand = new Dictionary<string, Card>();
     hand.Add("card", new Card(new Vector2(375, 0)));
 }
Example #2
0
 //Parameter: int playerNumber - the number assigned to the player
 //Parameter: DatabaseLink db - the class that possesses the
 //link to the database for card loading purposes.
 public Player(int playerNumber, DatabaseLink db)
 {
     this.playerNumber = playerNumber;
     playerBox = new PlayerBox(playerNumber, health);
     //Chooses the location of the player's hand.
     Vector2 position = (this.playerNumber == 1) ? new Vector2(375, 0) : new Vector2(375, 550);
     this.db = db;
     //"Select" in the DatabaseLink class returns an array of lists of strings.
     //We here parse the list of strings into its component database entries
     //and add those to the player's hand.
     List<string>[] availableCards = db.Select(playerNumber);
     hand = new Dictionary<string, Card>();
     List<string> names = availableCards[0];
     List<string> powers = availableCards[1];
     int i = 0;
     foreach (string name in names)
     {
         string power = powers[i++];
         hand.Add(name, new Card(position, name, Int32.Parse(power)));
     }
 }