Beispiel #1
0
        public void Load()
        {
            DataTable table = DatabaseConnection.ExecuteQuery("SELECT * FROM Players");

            if (table.Rows.Count == 0)
            {
                MessageBox.Show("There is nothing to load.");
                return;
            }

            foreach (DataRow row in table.Rows)
            {
                string playerType = (string)row["PlayerType"];
                int    score      = Convert.ToInt32(row["Score"]);

                if (playerType == "Human")
                {
                    Human.Score = score;
                }
                else if (playerType == "Computer")
                {
                    Computer.Score = score;
                }
            }

            DataTable fieldTable = DatabaseConnection.ExecuteQuery("SELECT * FROM Field");

            foreach (DataRow row in fieldTable.Rows)
            {
                int    x          = Convert.ToInt32(row["X"]);
                int    y          = Convert.ToInt32(row["Y"]);
                string playerType = (string)row["PlayerType"];

                FieldItem item = GetItem(new Point(x, y));
                if (!String.IsNullOrEmpty(playerType))
                {
                    if (playerType == "Human")
                    {
                        item.Select(Human, false);
                    }
                    else if (playerType == "Computer")
                    {
                        item.Select(Computer, false);
                    }
                }
                else
                {
                    item.Reset();
                }
            }
        }
Beispiel #2
0
 public void Select(Player player, FieldItem item)
 {
     item.Select(player);
 }