我目前正在制作一个纸牌游戏(制作一个定制的而不是la脚扑克),基本上我想根据卡片的价值添加图片。它分为 a/b(a 是花色,b 是价值)。
我假设的代码块将更改为添加图片(或者它是卡片类?)
cards = new ArrayList < > ();
for (int a = 0 ; a <= 3 ; a++)
{
for (int b = 0 ; b <= 12 ; b++)
{
cards.add (new Card (a, b));
}
}
}
//Method to draw a card and remove card from the current deck
public Card PlayerCardDraw ()
{
Random generator = new Random ();
int index = generator.nextInt (cards.size ());
return cards.remove (index);
}
//将一张牌添加到保存在数组列表中的玩家 1 的手上,以将牌分组给单个玩家
public ArrayList <Card> p1Hand;
public ArrayList Card> P1CardDraw ()
{
p1Hand = new ArrayList < > ();
p1Hand.add (PlayerCardDraw ());
return p1Hand;
}