示例#1
0
        public List <Pozition> GetAllMoves(Pice[,] bord, int up)
        {
            List <Pozition> pozitionToMove = new List <Pozition>();

            if (!moved)
            {
                if (bord[this.pozition.pozX + (up * 2), this.pozition.pozY] == null)
                {
                    pozitionToMove.Add(new Pozition(this.pozition.pozX + (up * 2), this.pozition.pozY));
                }
            }

            if (bord[this.pozition.pozX + up, this.pozition.pozY].player == null)
            {
                pozitionToMove.Add(new Pozition(this.pozition.pozX + up, this.pozition.pozY));
            }

            Pozition newPozition = new Pozition(this.pozition.pozX + up, this.pozition.pozY + 1);

            if (DiferentPlayer(bord, newPozition))
            {
                pozitionToMove.Add(newPozition.Clone());
            }

            newPozition.pozY -= 2;

            if (DiferentPlayer(bord, newPozition))
            {
                pozitionToMove.Add(newPozition.Clone());
            }

            return(pozitionToMove);
        }
示例#2
0
 protected bool DiferentPlayer(Pice[,] bord, Pozition pozition)
 {
     if (this.player != bord[pozition.pozX, pozition.pozY].player)
     {
         return(true);
     }
     return(false);
 }
示例#3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            CheckAccount();
            if (!IsPostBack)
            {
                App_Code.Base db = new App_Code.Base(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString());
                List <string> s  = db.GetIdU();
                IdU.DataSource = s;
                IdU.DataBind();
                if (s.Count > 0)
                {
                    IdU.SelectedIndex = 0;
                }
                IdU_SelectedIndexChanged(sender, e);
            }

            if (!IsPostBack)
            {
                App_Code.Base db    = new App_Code.Base(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString());
                List <string> areas = db.GetWZAreas();
                Area.DataSource = areas;
                Area.DataBind();
                Area.SelectedIndex = 0;
                List <string> nodes = db.GetWZNodes(Area.SelectedValue);
                Node.DataSource = nodes;
                Node.DataBind();
                Node.SelectedIndex = 0;
                List <string> poz = db.GetWZPozition(Area.SelectedValue, Node.SelectedValue);
                Pozition.DataSource = poz;
                Pozition.DataBind();
                Pozition.SelectedIndex = 0;
            }
            if (!IsPostBack)
            {
                using (SqlConnection conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString()))
                {
                    conn.Open();
                    //выбор производителя и модели
                    SqlCommand cmd;
                    cmd = new SqlCommand("select Manufacturer, Model from PhisicalAddr " +
                                         "where LiftID=@lift", conn);
                    cmd.Parameters.AddWithValue("lift", LiftId.SelectedValue);
                    SqlDataReader dr = cmd.ExecuteReader();
                    //     dr = cmd.ExecuteReader();
                    if (dr.Read())
                    {
                        Disp.Text = dr[0].ToString() + "-" + dr[1].ToString() + ":";
                    }
                    string mf = dr[0].ToString(); string md = dr[1].ToString();
                    dr.Close();
                }
            }
        }
示例#4
0
        public void playGame()
        {
            int playerTurn = 0;

            while (!gameState)
            {
                PrintBord();
                Console.WriteLine("Player" + listOfPlayers[playerTurn].playerNumber + " next to move");
                Console.WriteLine("select pozition x :");
                int x = Convert.ToInt16(Console.ReadLine());
                Console.WriteLine("select Pozition y :");
                int y = Convert.ToInt16(Console.ReadLine());

                Pice selectedPice = bord[x, y];
                if (selectedPice == null && !listOfPlayers[playerTurn].playerPices.Contains(bord[x, y]))
                {
                    continue;
                }
                List <Pozition> poz = selectedPice.GetAllMoves(this.bord);
                // implement later a way to stop mooving foward till we select where to move
                PrintPozitions(poz);

                Console.WriteLine("select pozition x :");
                int chozePozition = Convert.ToInt16(Console.ReadLine());

                Pozition newPozition = poz[chozePozition];

                if (bord[newPozition.pozX, newPozition.pozY] != null)
                {
                    bord[newPozition.pozX, newPozition.pozY].player.DeletePice(bord[newPozition.pozX, newPozition.pozY]);
                }
                bord[x, y] = null;
                bord[newPozition.pozX, newPozition.pozY] = selectedPice;
                selectedPice.pozition = newPozition;

                playerTurn = (playerTurn + 1) % listOfPlayers.Length;
            }
        }
示例#5
0
        public Performance()
        {
            Console.WriteLine("Choose your pozition on court: (0: PG, 1: SG, 2: SF, 3: PF, 4: C)");
            i = Convert.ToInt32(Console.ReadLine());

            if (i == 0)
            {
                MyPozition = Pozition.PG;
            }
            else
            if (i == 1)
            {
                MyPozition = Pozition.SG;
            }
            else
            if (i == 2)
            {
                MyPozition = Pozition.SF;
            }
            else
            if (i == 3)
            {
                MyPozition = Pozition.PF;
            }
            else
            if (i == 4)
            {
                MyPozition = Pozition.C;
            }
            else
            {
                throw new ArgumentException("Wrong pozition!");
            }


            Console.WriteLine("Write your performance from previous match:");
            Console.WriteLine("Opposite Team: ");
            OppositeTeam = Console.ReadLine();

            Console.WriteLine("Points: ");
            Points = Convert.ToInt32(Console.ReadLine());
            if (Points < 0)
            {
                throw new ArgumentException("Points must be positive!");
            }

            Console.Write("Field goals made: ");
            FGM = Convert.ToInt32(Console.ReadLine());
            Console.Write("Field goal attempts: ");
            FGA = Convert.ToInt32(Console.ReadLine());
            if (FGM > FGA || FGM < 0 || FGA < 0)
            {
                throw new ArgumentException("Field goals made can't be bigger than field goals attempts or must be positive!");
            }
            FGPersentage = (FGM / FGA) * 100;
            FGPersentage = Math.Round(FGPersentage);

            Console.WriteLine("3 point field goals made: ");
            ThreePM = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("3 point field goals attempts: ");
            ThreePA = Convert.ToInt32(Console.ReadLine());
            if (ThreePM > ThreePA || ThreePM < 0 || ThreePA < 0)
            {
                throw new ArgumentException("3 Field goals made can't be bigger than 3 field  goals attempts or must be positive!");
            }
            ThreePPersentage = (ThreePM / ThreePA) * 100;
            ThreePPersentage = Math.Round(ThreePPersentage);

            Console.WriteLine("Free throws made: ");
            FTM = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Free throws attempts: ");
            FTA = Convert.ToInt32(Console.ReadLine());
            if (FTM > FTA || FTM < 0 || FTA < 0)
            {
                throw new ArgumentException("Free throws made can't be bigger than free throws attempts or must be positive!");
            }
            FTPersentage = (FTM / FTA) * 100;
            FTPersentage = Math.Round(FTPersentage);

            Console.WriteLine("Assists: ");
            Assists = Convert.ToInt32(Console.ReadLine());
            if (Assists < 0)
            {
                throw new ArgumentException("Assists must be positive!");
            }
            Console.WriteLine("Rebounds: ");
            Rebounds = Convert.ToInt32(Console.ReadLine());
            if (Rebounds < 0)
            {
                throw new ArgumentException("Rebounds must be positive!");
            }
            Console.WriteLine("Steals: ");
            Steals = Convert.ToInt32(Console.ReadLine());
            if (Steals < 0)
            {
                throw new ArgumentException("Steals must be positive!");
            }
            Console.WriteLine("Turnovers: ");
            Turnovers = Convert.ToInt32(Console.ReadLine());
            if (Turnovers < 0)
            {
                throw new ArgumentException("Turnovers must be positive!");
            }
            Console.WriteLine("Blocks: ");
            Blocks = Convert.ToInt32(Console.ReadLine());
            if (Blocks < 0)
            {
                throw new ArgumentException("Blocks must be positive!");
            }

            Rating = (5 * FGPersentage + 4 * ThreePPersentage + FTPersentage
                      + (Blocks + Steals + Assists + Rebounds - Turnovers) * 2) / 100;
        }