Example #1
0
 public UserAccount(UserAccount otheraccount)
 {
     username = otheraccount.username;
     password = otheraccount.password;
     name = otheraccount.name;
     winscore = otheraccount.winscore;
     losescore = otheraccount.losescore;
     invalidinput = false;
 }
Example #2
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     UserAccount user = new UserAccount();
     user.LoadFromFile(txtUserName.Text, txtPassword.Text);
     if (user.invalidinput == false)
     {
         FormTitleScreen.user = new UserAccount(user);
         Close();
     }
     else
     {
         MessageBox.Show("Username or password is incorrect.");
     }
 }
Example #3
0
        //the all important constructors
        public FormPoker()
        {
            InitializeComponent();
            this.Icon = new Icon("Poker.ico");
            timerCount = 0;
            screenWidth = Screen.PrimaryScreen.Bounds.Width;
            screenHeight = Screen.PrimaryScreen.Bounds.Height;
            width_ratio = (screenWidth / this.Width);
            height_ratio = (screenHeight / this.Height);

            SizeF scale = new SizeF(width_ratio, height_ratio);
            pbMain.Scale(scale);
            this.Size = pbMain.Size;
            foreach (Control control in this.Controls)
            {
                control.Font = new Font(control.Font.Name, control.Font.SizeInPoints * height_ratio * width_ratio, control.Font.Style);
            }
            cardWidth = Convert.ToInt32(71f * width_ratio);
            cardHeight = Convert.ToInt32(96f * height_ratio);
            user = new UserAccount();
            Random rand = new Random();
            Player me = new Player(playerName, BuyInAmount);
            playerList = new PlayerList();
            playerList.Add(me);
            lblName.Text = me.Name;
            List<int> AI = new List<int>(playerAmount);
            for (int i = 0; i < 3; i++)
            {
                AI.Add(i);
            }
            for (int i = 0; i < 4 - playerAmount; i++)
            {
                AI.Remove(rand.Next(AI.Count));
            }
            AI = shuffle(AI);
            for (int i = 1; i < playerAmount; i++)
            {
                playerList.Add(new AIPlayer(BuyInAmount, difficulty, AI[i - 1]));
                //labelListName[i].Text = playerList[i].Name;
            }
            FormInformation Information = new FormInformation(playerList);
            Information.StartPosition = FormStartPosition.CenterScreen;
            Information.ShowDialog();
            Information.Dispose();
            pokerTable = new Table(playerList);
            SoundPlayer sound = new SoundPlayer();
        }
Example #4
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     if (txtUserName.Text == "default" || txtPass.Text == "default") //default must not become a viable username (it is the default for a reason and also to indicate that no user has logged in)
     {
         MessageBox.Show("<default> as a password or a username is not allowed.");
     }
     else if (txtUserName.Text == "" || txtPass.Text == "" || txtPass.Text == "" || txtReEnterPass.Text == "")
     {
         MessageBox.Show("Please fill in the all the boxes to register.");
     }
     else if (txtPass.Text != txtReEnterPass.Text)
     {
         MessageBox.Show("Re-entered password must be the same as password.");
     }
     else
     {
         UserAccount user = new UserAccount(txtUserName.Text, txtPass.Text, txtPlayerName.Text);
         user.WriteToFile();
         Close();
     }
 }
Example #5
0
 private void btnLogin_Click(object sender, EventArgs e)
 {
     if (btnLogin.Text == "Login")
     {
         FormLogin FormLogin = new FormLogin();
         FormLogin.FormTitleScreen = this;
         FormLogin.ShowDialog();
         if (user.getUserName() != "default" && user.getPassword() != "default")
         {
             btnLogin.Text = "Logout"; //user can only logout once they are logged in,
             lblLoggedInAs.Text = "Logged in As : " + user.getUserName();
             btnScore.Show();
         }
         else
             lblLoggedInAs.Text = "";
     }
     else //when user logs out, they have the option to log into another account
     {
         btnLogin.Text = "Login";
         user = new UserAccount();
         btnScore.Hide();
         lblLoggedInAs.Text = "";
     }
 }
Example #6
0
        public FormPoker(string playerName, int BuyInAmount, int playerAmount, int difficulty, UserAccount user)
        {
            InitializeComponent();
            this.Icon = new Icon("Poker.ico");
            this.playerName = playerName;
            if (playerName == null)
                throw new ArgumentOutOfRangeException();
            if (playerAmount < 2)
                throw new ArgumentOutOfRangeException();
            this.difficulty = difficulty;
            if (difficulty > 2)
                throw new ArgumentOutOfRangeException();
            this.BuyInAmount = BuyInAmount;
            this.playerAmount = playerAmount;
            timerCount = 0;
            //code to resize screen
            screenWidth = Screen.PrimaryScreen.Bounds.Width;
            screenHeight = Screen.PrimaryScreen.Bounds.Height;
            width_ratio = (screenWidth / 1366f);
            height_ratio = (screenHeight / 768f);
            SizeF scale = new SizeF(width_ratio, height_ratio);
            this.Scale(scale);
            foreach (Control control in this.Controls)
            {
                control.Font = new Font(control.Font.Name, control.Font.SizeInPoints * height_ratio * width_ratio, control.Font.Style);
            }

            cardWidth = Convert.ToInt32(71f * width_ratio);
            cardHeight = Convert.ToInt32(96f * height_ratio);
            this.user = new UserAccount(user);
            //add 3 archetytes randomly to list
            Random rand = new Random();
            Player me = new Player(playerName, BuyInAmount);
            playerList = new PlayerList();
            playerList.Add(me);
            lblName.Text = me.Name;
            List<int> AI = new List<int>(playerAmount);
            for (int i = 0; i < 3; i++)
            {
                AI.Add(i);
            }
            for (int i = 0; i < 4 - playerAmount; i++)
            {
                AI.Remove(rand.Next(AI.Count));
            }
            AI = shuffle(AI);
            for (int i = 1; i < playerAmount; i++)
            {
                playerList.Add(new AIPlayer(BuyInAmount, difficulty, AI[i - 1]));
                //labelListName[i].Text = playerList[i].Name;
            }
            FormInformation Information = new FormInformation(playerList);
            Information.StartPosition = FormStartPosition.CenterScreen;
            Information.ShowDialog();
            Information.Dispose();
            pokerTable = new Table(playerList);
        }
Example #7
0
 private void FormGameOptions_Load(object sender, EventArgs e)
 {
     user = new UserAccount(FormTitleScreen.user);
     txtYourName.Text = user.getName();
     if (user.getName() != "Player") //players logged in have a specified name they that shouldn't be able to change
         txtYourName.Enabled = false;
 }