C#扑克:如何跟踪玩家,并使游戏引擎(类)预翻牌、翻牌、转身、河流?

C#扑克:如何跟踪玩家,并使游戏引擎(类)预翻牌、翻牌、转身、河流?,c#,C#,我最近在学习c#,想创建一个“简单”的控制台应用程序扑克游戏。 我创造了职业:玩家、手牌、牌组、庄家。庄家从牌组中取出牌并分配给玩家实例。我现在正在努力的是如何取得更大的进步?我需要让一些游戏成为可能 这就是我对thusfar的编码: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Conso

我最近在学习c#,想创建一个“简单”的控制台应用程序扑克游戏。 我创造了职业:玩家、手牌、牌组、庄家。庄家从牌组中取出牌并分配给玩家实例。我现在正在努力的是如何取得更大的进步?我需要让一些游戏成为可能

这就是我对thusfar的编码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication10
{
    class Program
    {
        static void Main(string[] args)
        {
            //Deck d = new Deck();
            Player[] players = new Player[2];
            Dealer dealer = new Dealer();

            players[0] = new Player("M");
            players[1] = new Player("T");


        foreach (var player in players)
        {
            Console.WriteLine(player.name);
        }

        Console.WriteLine();

        foreach (var player in players)
        {
            player.AddCardsToHand(dealer);
        }

        Console.WriteLine("View hand van player 1");
        foreach (string card in players[0].ViewHandCards())
        {
            Console.WriteLine(card);
        }
        Console.WriteLine();
        Console.WriteLine("View hand van player 2");

        foreach (string card in players[1].ViewHandCards())
        {
            Console.WriteLine(card);
        }

        Console.WriteLine();
        Console.WriteLine("Number of players instantiated:");
        Console.WriteLine(Player.playerCount);
        Console.WriteLine();
        Console.WriteLine("Number of hands instantiated:");
        Console.WriteLine(Hand.handCount);
        Console.WriteLine();

        dealer.SetMoneyAmount(players[0]);
        dealer.SetMoneyAmount(players[1], 150);

        Console.WriteLine("Money player 1:");
        Console.WriteLine(players[0].MoneyAmount);
        Console.WriteLine();
        Console.WriteLine("Money player 2:");
        Console.WriteLine(players[1].MoneyAmount);
        Console.WriteLine();

        int index = 0;
        dealer.SetDealer(players[index]);

        Console.WriteLine("Dealer: " + dealer.GetDealer());

        // how to know in a class how many players there are and there values?
        // create a class containing the players array?


    }
}
class Settings
{
    // static string dealer;
    public static int dealerIndex;
    public static string dealerName;
    public 
}
class User
{
    public string name;
}
class Player : User
{
    Hand h = new Hand();
    public static int playerCount;


    private double moneyAmount;
    public bool dealerButton;

    public double MoneyAmount
    {
        get
        {
            return moneyAmount;
        }
        set
        {
            moneyAmount = value;
        }
    }

    public int NumOfCardsInHand()
    {

        return h.cardsInHand;
    }
    public string[] ViewHandCards()
    {

        return h.handCards;
    }
    public void AddCardsToHand(Dealer d)
    {
        d.DealCard(h);
        d.DealCard(h);
    }
    public Player(string n)
    {
        this.name = n;
        playerCount++;
    }
}
class Hand
{
    public static int handCount;

    public int cardsInHand = 0;
    public string[] handCards = new string[2];
    public Hand()
    {
        handCount++;
    }

}
class Dealer
{
    Deck d = new Deck();
    //public void StartGame()
    //{

    //}
    public void DealCard(Hand h)
    {
        if (h.cardsInHand < 2)
        {


            if (h.cardsInHand == 0)
                h.handCards[0] = d.NextCard();
            if (h.cardsInHand == 1)
                h.handCards[1] = d.NextCard();
            h.cardsInHand++;

        }
        else
        {
            Console.WriteLine("Meer dan 2 kaarten per hand is niet toegestaan");

        }

    }
    public void SetMoneyAmount(Player p, double amount = 100)
    {
        p.MoneyAmount = amount;
    }
    public void SetDealer(Player p)
    {
        p.dealerButton = true;
        Settings.dealerName = p.name;

    }
    public string GetDealer()
    {
        return Settings.dealerName;
    }

}
class Deck
{
    public int numOfCards = 52;
    public string[] cards = new string[13];
    public string[] playingCards = new string[52];
    public string[] cardsDealt = new string[52];
    Random r = new Random();
    int y = 0;

    public string NextCard()
    {
        string nextCard = "-";

        int x = 0;

        while (x < 1)
        {
            nextCard = playingCards[r.Next(0, playingCards.Length)];

            if (!cardsDealt.Contains(nextCard))
            {
                cardsDealt[y] = nextCard;
                y++;
                x++;
            }
            else
            {
                Console.WriteLine("Reeds gedeelde kaart bijna opnieuw gedeeld!");
                x = 0;
            }

        }
        return nextCard;
    }
    public void ConstructDeck()
    {
        // spade club heart diamond
        this.cards[0] = "A";
        this.cards[1] = "K";
        this.cards[2] = "Q";
        this.cards[3] = "J";
        this.cards[4] = "10";
        this.cards[5] = "9";
        this.cards[6] = "8";
        this.cards[7] = "7";
        this.cards[8] = "6";
        this.cards[9] = "5";
        this.cards[10] = "4";
        this.cards[11] = "3";
        this.cards[12] = "2";

        int x = 0;
        foreach (string card in this.cards)
        {

            this.playingCards[x] = card + "s";
            x++;
            this.playingCards[x] = card + "c";
            x++;
            this.playingCards[x] = card + "h";
            x++;
            this.playingCards[x] = card + "d";
            x++;
        }

    }

    public Deck()
    {
        ConstructDeck();
    }
}
class Bet
{
    public double betAmount;
    public Bet(Player p, double betInput)
    {

        betAmount = betInput;
    }
}
}
使用系统;
使用System.Collections.Generic;
使用System.Linq;
使用系统文本;
使用System.Threading.Tasks;
命名空间控制台应用程序10
{
班级计划
{
静态void Main(字符串[]参数)
{
//甲板d=新甲板();
玩家[]玩家=新玩家[2];
经销商=新经销商();
玩家[0]=新玩家(“M”);
玩家[1]=新玩家(“T”);
foreach(玩家中的var玩家)
{
Console.WriteLine(播放器名称);
}
Console.WriteLine();
foreach(玩家中的var玩家)
{
玩家。添加卡牌手(经销商);
}
控制台。WriteLine(“查看手动面包车播放器1”);
foreach(玩家[0]中的字符串卡。ViewHandCards())
{
控制台写入线(卡);
}
Console.WriteLine();
控制台。WriteLine(“查看手动面包车播放器2”);
foreach(玩家[1]中的字符串卡。ViewHandCards())
{
控制台写入线(卡);
}
Console.WriteLine();
WriteLine(“实例化的玩家数量:”);
Console.WriteLine(Player.playerCount);
Console.WriteLine();
WriteLine(“实例化的手数:”);
控制台写入线(手动计数);
Console.WriteLine();
交易商.SetMoneyAmount(玩家[0]);
交易商。设置货币金额(玩家[1],150);
控制台。WriteLine(“金钱玩家1:”);
Console.WriteLine(玩家[0].MoneyAmount);
Console.WriteLine();
控制台.WriteLine(“金钱玩家2:”);
Console.WriteLine(玩家[1].MoneyAmount);
Console.WriteLine();
int指数=0;
庄家。集合庄家(玩家[索引]);
Console.WriteLine(“Dealer:+Dealer.GetDealer());
//如何知道一个班级里有多少球员,有多少价值观?
//创建一个包含玩家数组的类?
}
}
班级设置
{
//静态字符串交易商;
公共静态int-dealerIndex;
公共静态字符串dealName;
公开的
}
类用户
{
公共字符串名称;
}
类播放器:用户
{
手h=新手();
公共静态整数播放计数;
私人双倍现金数额;
公共布尔DealButton;
公帑双倍
{
得到
{
返还金额;
}
设置
{
金额=价值;
}
}
公共int NumOfCardsInHand()
{
返回h.cardsInHand;
}
公共字符串[]ViewHandCards()
{
归还h.名片;
}
公共无效添加卡手(经销商d)
{
d、 DealCard(h);
d、 DealCard(h);
}
公共播放器(字符串n)
{
this.name=n;
playerCount++;
}
}
班主任
{
公共静态整数手数;
公共int卡SINHAND=0;
公共字符串[]手卡=新字符串[2];
公职人员()
{
手数++;
}
}
等级经销商
{
甲板d=新甲板();
//公共无效StartName()
//{
//}
公共信用卡(h手)
{
如果(h.cardsInHand<2)
{
如果(h.cardsInHand==0)
h、 名片[0]=d.NextCard();
如果(h.cardsInHand==1)
h、 名片[1]=d.NextCard();
h、 cardsInHand++;
}
其他的
{
控制台。WriteLine(“Meer dan 2 kaarten/手是niet Toegestan”);
}
}
公共无效设置货币金额(玩家p,双倍金额=100)
{
p、 MoneyAmount=金额;
}
公共玩家(玩家p)
{
p、 DealButton=true;
Settings.dealerName=p.name;
}
公共字符串GetDealer()
{
返回设置.dealerName;
}
}
甲板
{
公共整数卡=52;
公共字符串[]卡=新字符串[13];
公共字符串[]playingCards=新字符串[52];
公共字符串[]cardsdelt=新字符串[52];
随机r=新随机();
int y=0;
公共字符串NextCard()
{
字符串nextCard=“-”;
int x=0;
而(x<1)
{
nextCard=玩卡[r.Next(0,playingCards.Length)];
如果(!cardsdelt.Contains(nextCard))
{
cardsDealt[y]=nextCard;
y++;
x++;
}
其他的
{
控制台.WriteLine(“Reeds gedeelde kaart bijna opnieuw gedeeld!”);
x=0;
}
}
返回nextCard;
}
公共甲板()
{
//黑桃俱乐部心形钻石
此.cards[0]=“A”;
此.cards[1]=“K”;
此.cards[2]=“Q”;
此.cards[3]=“J”;
这个.卡片[4]=“10”;
这个。卡片[5]=“9”;
这个.卡片[6]=“8”;
此.cards[7]=“7”;
这个.卡片[8]=“6”;
这个。卡片[9]=“5”;
这个。卡片[10]=“4”;
此.cards[11]=“3”;
此.cards[12]=“2”;
int x=0;
foreach(此.cards中的字符串卡)
{
这个.playingCards[x]=卡+“s”;
x++;
这个.playingCards[x]=卡+c;
x++;
这个.playingCards[x]=卡片+h;
x++;
这个.playingCards[x]=卡片+d;
x++;
}
}
公共甲板()
{
构造甲板();
}
}
下注
{
公共财政支出;
公众赌注(玩家p,双倍赌注)
{
betAmount=betInput;
}
}
}
我已将玩家实例放入数组a中