Kingdom Ablaze
Sponsor
So im working on a C# Card Game, i have a piece of code that is sapose to assign a deck id to each card as it is added to the deck, but for some reason it gives all cards with the same id(database id) the deck id of the last card assigned. Example: i add 10 of the same card, instead of getting 1,2,3,4,5,6,7,8,9,10 i get: 10, 10, 10, 10, 10, 10, 10, 10, 10
Here is the add card code: (deckId is a public int in the Card class)
here is the get card method:
let me know if you need anymore information
Here is the add card code: (deckId is a public int in the Card class)
Code:
public void AddCard(int id)
{
// finds the next null in the deck[] and assigns the number to nextBlankSpot
NextBlank();
deck[nextBlankSpot] = cardDataBase.GetCard(id - 1);
deck[nextBlankSpot].deckId = nextBlankSpot;
}
here is the get card method:
Code:
public Card GetCard(int id)
{
return cards[id];
}
let me know if you need anymore information