aboutsummaryrefslogtreecommitdiff
path: root/Chopsticks/cSharpVersion/FingerGameCSharp/Program.cs
blob: 15b61fa8d7816a99c59366787a55407edf9e8567 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FingerGameCSharp
{
    class Program
    {
        static void Main(string[] args)
        {
            int p1 = 1;
            int p2 = 1;
            int e1 = 1;
            int e2 = 1;
            int sel = 0;

            for (; ; )
            {               
                if (sel == 0) Console.WriteLine($"{e1}   {e2}\r\n-----\r\n{p1} * {p2}\r\n");
                else Console.WriteLine($"{e1} * {e2}\r\n-----\r\n{p1}   {p2}\r\n");

                char yourHand = Console.ReadLine()[0];
                char toHand = Console.ReadLine()[0];
                Console.WriteLine();

                if (sel == 0)
                {
                    if (yourHand == 'l' && p1 != 5)
                    {
                        if (toHand == 'l' && e1 != 5) e1 += p1;
                        else if (toHand == 'r' && e2 != 5) e2 += p1;
                        sel = 1;
                    }
                    else if (yourHand == 'r' && p2 != 5)
                    {
                        if (toHand == 'l' && e1 != 5) { e1 += p2; sel = 1; }
                        else if (toHand == 'r' && e2 != 5) { e2 += p2; sel = 1; }
                        else Console.WriteLine("Please select valid enemy hand! (You will have to reselect your hand too!)");                        
                    }
                    else
                    {
                        Console.WriteLine("Please select a valid hand!");
                    }                    
                }
                else
                {
                    if (yourHand == 'l' && e1 != 5)
                    {
                        if (toHand == 'l' && p1 != 5) { p1 += e1; sel = 0; }
                        else if (toHand == 'r' && p2 != 5) { p2 += e1; sel = 0; }
                        else Console.WriteLine("Please select valid enemy hand! (You will have to reselect your hand too!)");
                    }
                    else if (yourHand == 'r' && e2 != 5)
                    {
                        if (toHand == 'l' && p1 != 5) { p1 += e2; sel = 0; }
                        else if (toHand == 'r' && p2 != 5) { p2 += e2; sel = 0; }
                        else Console.WriteLine("Please select valid enemy hand! (You will have to reselect your hand too!)");
                    }
                    else
                    {
                        Console.WriteLine("Please select a valid hand!");
                    }

                }

                if (p1 == 5 && p2 == 5)
                {
                    Console.WriteLine("Player 2 wins! New game.");
                    p1 = 1; p2 = 1; e1 = 1; e2 = 1;
                    sel = 0;
                }
                else if (e1 == 5 && e2 == 5)
                {
                    Console.WriteLine("Player 1 wins! New game.");
                    p1 = 1; p2 = 1; e1 = 1; e2 = 1;
                    sel = 1;
                }

                Console.WriteLine();
            }
        }
    }
}