Esempio n. 1
0
        static void Main(string[] args)
        {
            List <Player> players = new List <Player>();

            Console.WriteLine("플레이어수");
            Console.Title = "원파고 콘솔";
            int howmany = Convert.ToInt32(Console.ReadLine());

            if (howmany == 2)
            {
                players.Add(new AI()
                {
                    Horizon = true, ID = 0
                });
                players.Add(new Human()
                {
                    Horizon = true, ID = 1
                });
            }
            else
            {
                for (int i = 0; i != howmany; i++)
                {
                    if (i == 2)
                    {
                        players.Add(new Human()
                        {
                            Horizon = true, ID = 2
                        });
                    }
                    else
                    {
                        players.Add(new AI()
                        {
                            Horizon = (i == 0 || i == 2 ? true : false), ID = i
                        });
                    }
                }
            }

            GUI GUI_system = new GUI(howmany == 2 ? true : false);

            OneCard Game   = new OneCard(players, GUI_system);
            Thread  thread = new Thread(() => Game.Start(), 125000 * 1000);

            thread.Start();

            GUI_system.LOOP();
            thread.Join();
            Console.Read();
        }
Esempio n. 2
0
 public void Reverse(OneCard system)
 {
     reversed = !reversed;
 }
Esempio n. 3
0
            public Player Next(OneCard system, List <Player> Players, bool IsJ = false)
            {
                if (system.GameStarted)
                {
                    if (Players.Count == 1)
                    {
                        if (!LastTurnWin)
                        {
                            system.Win(Players[0]);
                        }
                        system.End();
                        goto End;
                    }
                    LastTurnWin = false;
                    cumulation++;

                    if (PlayerChanged && Count_Turn >= Players.Count)
                    {
                        if (Count_Turn >= Players.Count - 1 && !reversed)
                        {
                            reset      = true;
                            Count_Turn = 0;
                        }
                        if (Count_Turn <= -1 && reversed)
                        {
                            reset      = true;
                            Count_Turn = Players.Count;
                        }

                        if (!reset)
                        {
                            if (reversed)
                            {
                                Count_Turn--;
                                if (Count_Turn < 0)
                                {
                                    Count_Turn = Players.Count - 1;
                                }
                            }
                            else
                            {
                                Count_Turn++;
                            }
                        }
                        reset = false;
                    }
                    int repeat = IsJ ? 2 : 1;
                    for (int i = 0; i != repeat; i++)
                    {
                        if (Count_Turn == Players.Count - 1 && !reversed)
                        {
                            reset      = true;
                            Count_Turn = 0;
                        }
                        if (Count_Turn == -1 && reversed)
                        {
                            reset      = true;
                            Count_Turn = Players.Count;
                        }

                        if (!reset)
                        {
                            if (reversed)
                            {
                                Count_Turn--;
                                if (Count_Turn < 0)
                                {
                                    Count_Turn = Players.Count - 1;
                                }
                            }
                            else
                            {
                                Count_Turn++;
                            }
                        }

                        reset = false;
                    }
                    Player output = Players[Count_Turn];
                    system.GUI_system.whosturn = output;
                    output.Do(system, output, Players);
                    return(output);
                }
End:
                return(new AI());
            }
Esempio n. 4
0
            public override void Do(OneCard system, Player who, List <Player> Players)
            {
K:
                bool OneMore = false;

                CardInfo.Shape tempcard = CardInfo.Shape.None;
                bool           IsJ      = false;
                bool           IsSeven  = false;

                Console.WriteLine("카드를 낼시간");
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine("마지막카드" + system.LastCard);
                Console.ForegroundColor = ConsoleColor.Gray;
                if (system.Attack != 0)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("경고! 공격받는중" + system.Attack + "장!");
                    Console.ForegroundColor = ConsoleColor.Gray;
                }
                for (int i = 0; i != Cards.Count; i++)
                {
                    Cards[i].ID = i;
                    Console.WriteLine(i + ":" + Cards[i]);
                }
                Console.WriteLine("먹을려면" + Cards.Count);
                int want = 0;

                try
                {
                    want = int.Parse(Console.ReadLine());
                }
                catch (FormatException e)
                {
                    Console.ForegroundColor = ConsoleColor.DarkRed;
                    Console.WriteLine("올바른 입력이 아닙니다");
                    Console.ForegroundColor = ConsoleColor.Gray;

                    goto K;
                }
                if (want == Cards.Count)
                {
                    if (system.Attack != 0)
                    {
                        for (int j = 0; j != system.Attack; j++)
                        {
                            Console.ForegroundColor = ConsoleColor.White;
                            Console.WriteLine(ID + ": " + system.Take(ref who) + "먹음");
                            Console.ForegroundColor = ConsoleColor.Gray;
                        }
                        system.Attack = 0;
                    }
                    else
                    {
                        Console.ForegroundColor = ConsoleColor.White;
                        Console.WriteLine(ID + ": " + system.Take(ref who) + "먹음");
                        Console.ForegroundColor = ConsoleColor.Gray;
                    }
                    goto Exit;
                }
                if (want > Cards.Count)
                {
                    Console.ForegroundColor = ConsoleColor.DarkRed;
                    Console.WriteLine("올바른 입력이 아닙니다");
                    Console.ForegroundColor = ConsoleColor.Gray;

                    goto K;
                }
                CardInfo card = Cards[want];

                if (system.Attack != 0) //공격받는중
                {
                    if (system.Vaildate(card))
                    {
                        switch (card.Card_Number)
                        {
                        case 1:
                            //A
                            system.Attack += 3;
                            break;

                        case 2:
                            system.Attack += 2;
                            break;

                        case 3:
                            system.Attack = 0;
                            break;
                        }
                        switch (card.Card_Shape)
                        {
                        case CardInfo.Shape.BlackJocker:
                            system.Attack += 5;
                            break;

                        case CardInfo.Shape.ColorJocker:
                            system.Attack += 10;
                            break;
                        }
                        Console.WriteLine(ID + ": 공격대응 " + card + "제출");
                        system.Play(card, ref who, false);
                        if (OneMore)
                        {
                            goto K;
                        }

                        goto Exit;
                    }
                    else
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine("올바른 카드가 아닙니다!");
                        Console.ForegroundColor = ConsoleColor.Gray;
                        goto K;
                    }
                }
                else //평상시
                {
                    if (system.Vaildate(card))
                    {
                        switch (card.Card_Number)
                        {
                        case 1:
                            //A
                            system.Attack += 3;
                            break;

                        case 2:
                            system.Attack += 2;
                            break;

                        case 3:
                            system.Attack = 0;
                            break;

                        case 11:
                            //J
                            IsJ = true;
                            break;

                        case 12:
                            //Q
                            system.GameTurn.Reverse(system);
                            break;

                        case 13:
                            //K
                            OneMore = true;
                            break;

                        case 7:
                            Console.ForegroundColor = ConsoleColor.Blue;
                            Console.WriteLine("무슨 모양으로 변경하겠습니까?");
                            Console.WriteLine("1. 다이아 2.하트 3.스페이드 4. 클로버");
                            try
                            {
                                tempcard = (CardInfo.Shape) int.Parse(Console.ReadLine());
                            }
                            catch (FormatException e)
                            {
                                Console.ForegroundColor = ConsoleColor.Red;
                                Console.WriteLine("올바른 입력이 아닙니다");
                                goto K;
                            }
                            system.LastCard = new CardInfo(tempcard, 7)
                            {
                                temp = true
                            };
                            IsSeven = true;
                            Console.ForegroundColor = ConsoleColor.Gray;
                            break;
                        }

                        switch (card.Card_Shape)
                        {
                        case CardInfo.Shape.BlackJocker:
                            system.Attack += 5;
                            break;

                        case CardInfo.Shape.ColorJocker:
                            system.Attack += 10;
                            break;
                        }

                        Console.WriteLine(ID + ": " + card + "제출 남은 카드 " + Cards.Count);
                        if (tempcard != CardInfo.Shape.None)
                        {
                            Console.WriteLine("카드 모양 변경: " + tempcard);
                        }

                        system.Play(card, ref who, IsSeven);
                        if (OneMore)
                        {
                            goto K;
                        }

                        goto Exit;
                    }
                    else
                    {
                        Console.WriteLine("올바른 카드가 아닙니다!");
                        goto K;
                    }
                }
Exit:
                if (who.Cards.Count >= 20)
                {
                    system.Bankrupt(who);
                }

                Console.WriteLine(ID + ": " + Cards.Count + "장");
                system.GameTurn.Next(system, Players, IsJ);
            }
Esempio n. 5
0
            public override void Do(OneCard system, Player who, List <Player> Players)
            {
K:
                bool Card_found = false;
                bool OneMore = false;

                CardInfo.Shape tempcard = CardInfo.Shape.None;
                bool           IsJ      = false;
                bool           IsSeven  = false;

                if (system.Attack != 0) //공격받는중
                {
                    for (int i = 0; i < Cards.Count; i++)
                    {
                        CardInfo card = Cards[i];
                        if (system.Vaildate(card))
                        {
                            switch (card.Card_Number)
                            {
                            case 1:
                                //A
                                system.Attack += 3;
                                break;

                            case 2:
                                system.Attack += 2;
                                break;

                            case 3:
                                system.Attack = 0;
                                break;
                            }
                            switch (card.Card_Shape)
                            {
                            case CardInfo.Shape.BlackJocker:
                                system.Attack += 5;
                                break;

                            case CardInfo.Shape.ColorJocker:
                                system.Attack += 10;
                                break;
                            }
                            Console.WriteLine(ID + ": 공격대응 " + card + "제출");
                            Card_found = true;
                            system.Play(card, ref who, false);
                            if (OneMore)
                            {
                                goto K;
                            }

                            goto Exit;
                        }
                    }
                    if (!Card_found)
                    {
                        Card_found = false;
                        for (int j = 0; j != system.Attack; j++)
                        {
                            Console.WriteLine(ID + ": " + system.Take(ref who) + "먹음");
                        }
                        system.Attack = 0;
                        goto Exit;
                    }
                }
                else //평상시
                {
                    for (int i = 0; i < Cards.Count; i++)
                    {
                        CardInfo card = Cards[i];
                        if (system.Vaildate(card))
                        {
                            switch (card.Card_Number)
                            {
                            case 1:
                                //A
                                system.Attack += 3;
                                break;

                            case 2:
                                system.Attack += 2;
                                break;

                            case 3:
                                system.Attack = 0;
                                break;

                            case 11:
                                //J
                                IsJ = true;
                                break;

                            case 12:
                                //Q
                                system.GameTurn.Reverse(system);
                                break;

                            case 13:
                                //K
                                OneMore = true;
                                break;

                            case 7:
                                int[] Check_list = new int[5];
                                if (Cards.Count != 0)
                                {
                                    foreach (CardInfo Check_card in Cards)
                                    {
                                        switch (Check_card.Card_Shape)
                                        {
                                        case CardInfo.Shape.Spade:
                                            Check_list[3]++;
                                            break;

                                        case CardInfo.Shape.Heart:
                                            Check_list[2]++;
                                            break;

                                        case CardInfo.Shape.Diamond:
                                            Check_list[1]++;
                                            break;

                                        case CardInfo.Shape.Clover:
                                            Check_list[4]++;
                                            break;
                                        }
                                    }
                                    tempcard        = (CardInfo.Shape)Check_list.ToList().IndexOf(Check_list.Max());
                                    system.LastCard = new CardInfo(tempcard, 7)
                                    {
                                        temp = true
                                    };
                                    IsSeven = true;
                                }
                                break;
                            }

                            switch (card.Card_Shape)
                            {
                            case CardInfo.Shape.BlackJocker:
                                system.Attack += 5;
                                break;

                            case CardInfo.Shape.ColorJocker:
                                system.Attack += 10;
                                break;
                            }
                            Console.ForegroundColor = ConsoleColor.DarkYellow;
                            Console.WriteLine(ID + ": " + card + "제출 남은 카드 " + Cards.Count);
                            if (tempcard != CardInfo.Shape.None)
                            {
                                Console.WriteLine("카드 모양 변경: " + tempcard);
                            }
                            Console.ForegroundColor = ConsoleColor.Gray;

                            Card_found = true;
                            system.Play(card, ref who, IsSeven);
                            if (OneMore)
                            {
                                goto K;
                            }

                            goto Exit;
                        }
                    }
                    if (!Card_found)
                    {
                        Card_found = false;
                        Console.WriteLine(ID + ": " + system.Take(ref who) + "먹음");
                        goto Exit;
                    }
                }
Exit:
                if (who.Cards.Count >= 20)
                {
                    system.Bankrupt(who);
                }
                Console.ForegroundColor = ConsoleColor.DarkYellow;
                Console.WriteLine(ID + ": " + Cards.Count + "장");
                if (Cards.Count == 1)
                {
                    SpeechSynthesizer synthesizer = new SpeechSynthesizer
                    {
                        Volume = 100, // 0...100
                        Rate   = 7    // -10...10
                    };

                    synthesizer.Speak("OneCard");
                }
                Console.ForegroundColor = ConsoleColor.Gray;
                system.GameTurn.Next(system, Players, IsJ);
            }
Esempio n. 6
0
 public abstract void Do(OneCard system, Player who, List <Player> Players);