Beispiel #1
0
        public static Game createGame(string gameName, string loggedInUserId)
        {
            BR.Model.Game gc = null; //the created game

            using (SqlConnection cn = DataAccess.DataAccessFactory.GetDataAccess())
            {
                SqlCommand cmd = new SqlCommand("CreateGame", cn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add(new SqlParameter("@GameName", gameName));
                cmd.Parameters.AddWithValue("@Creator", loggedInUserId);
                cn.Open();
                using (SqlDataReader reader = cmd.ExecuteReader())
                {
                    DataTable dt = new DataTable();
                    dt.Load(reader);

                    if (dt != null)
                    {
                        foreach (DataRow dr in dt.Rows)
                        {
                            gc = new BR.Model.Game(dr);
                        }
                    }
                }
            }
            return(gc);
        }
Beispiel #2
0
 private void itsEventPhase()
 {
     this.lblPhase.Text = "Phase: Event & Combat";
     Model.Game theGame = Model.Game.GetSpecificGame(Convert.ToInt32(Session["GameId"]));
     if (theGame.creator == Convert.ToInt32(Session["LoggedInUserId"]))
     {
         this.panelEventCombat.Visible = true;
     }
 }
Beispiel #3
0
        public void showPanels(Panel england, Panel france, Panel germany, Panel italy, Panel spain)
        {
            Model.User    loggedInUser           = ExtraLib.Sql.getUserFromId(Convert.ToInt32(Session["LoggedInUserId"]));
            Model.Game    theGame                = Model.Game.GetSpecificGame(Convert.ToInt32(Session["GameId"]));
            Model.Dynasty loggedInDynasty        = ExtraLib.Sql.getDynasty(loggedInUser.userId, theGame.gameId);
            char          LoggedInDynastyCountry = ' ';

            if (loggedInDynasty != null)
            {
                LoggedInDynastyCountry = loggedInDynasty.country;
            }

            if (LoggedInDynastyCountry.Equals('E') || theGame.creator == Convert.ToInt32(Session["LoggedInUserId"]))
            {
                //So non-played countries dosnt show up to creator
                if (ExtraLib.Sql.getDynastyId(theGame.gameId, 'E') > 0)
                {
                    england.Visible = true;
                }
            }

            if (LoggedInDynastyCountry.Equals('F') || theGame.creator == Convert.ToInt32(Session["LoggedInUserId"]))
            {
                //So non-played countries dosnt show up to creator
                if (ExtraLib.Sql.getDynastyId(theGame.gameId, 'F') > 0)
                {
                    france.Visible = true;
                }
            }

            if (LoggedInDynastyCountry.Equals('G') || theGame.creator == Convert.ToInt32(Session["LoggedInUserId"]))
            {
                //So non-played countries dosnt show up to creator
                if (ExtraLib.Sql.getDynastyId(theGame.gameId, 'G') > 0)
                {
                    germany.Visible = true;
                }
            }

            if (LoggedInDynastyCountry.Equals('I') || theGame.creator == Convert.ToInt32(Session["LoggedInUserId"]))
            {
                //So non-played countries dosnt show up to creator
                if (ExtraLib.Sql.getDynastyId(theGame.gameId, 'I') > 0)
                {
                    italy.Visible = true;
                }
            }

            if (LoggedInDynastyCountry.Equals('S') || theGame.creator == Convert.ToInt32(Session["LoggedInUserId"]))
            {
                //So non-played countries dosnt show up to creator
                if (ExtraLib.Sql.getDynastyId(theGame.gameId, 'S') > 0)
                {
                    spain.Visible = true;
                }
            }
        }
Beispiel #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.IsPostBack) //so page_load dosn't trigger when pressing a button
            {
                if (Session["LoggedInUserId"] == null)
                {
                    Session["Error"] = "You need to login";
                    Response.Redirect("Login.aspx");
                }
                if (Session["GameId"] == null)
                {
                    Session["Error"] = "No game choosen";
                    Response.Redirect("default.aspx");
                }

                this.lblYear.Text = "Year: " + ((Convert.ToInt32(Session["Turn"]) * 5) + 1300).ToString();
                this.lblGame.Text = "Game: " + Convert.ToString(Session["GameName"]);


                //Make country panels visible

                Model.User    loggedInUser           = ExtraLib.Sql.getUserFromId(Convert.ToInt32(Session["LoggedInUserId"]));
                Model.Game    theGame                = Model.Game.GetSpecificGame(Convert.ToInt32(Session["GameId"]));
                Model.Dynasty loggedInDynasty        = ExtraLib.Sql.getDynasty(loggedInUser.userId, theGame.gameId);
                char          LoggedInDynastyCountry = ' ';

                if (loggedInDynasty != null)
                {
                    LoggedInDynastyCountry = loggedInDynasty.country;
                }


                if (theGame.creator == Convert.ToInt32(Session["LoggedInUserId"]))
                {
                    this.panelDynasticSequence.Visible = true;
                }
                if (LoggedInDynastyCountry.Equals('E') || theGame.creator == Convert.ToInt32(Session["LoggedInUserId"]))
                {
                    //So non-played countries dosnt show up to creator
                    if (ExtraLib.Sql.getDynastyId(theGame.gameId, 'E') > 0)
                    {
                        panelEnglandBirth.Visible    = true;
                        panelEnglandSurvival.Visible = true;
                        panelEnglandMarriage.Visible = true;
                    }
                }
                if (LoggedInDynastyCountry.Equals('F') || theGame.creator == Convert.ToInt32(Session["LoggedInUserId"]))
                {
                    if (ExtraLib.Sql.getDynastyId(theGame.gameId, 'F') > 0)
                    {
                        panelFranceBirth.Visible    = true;
                        panelFranceSurvival.Visible = true;
                        panelFranceMarriage.Visible = true;
                    }
                }
                if (LoggedInDynastyCountry.Equals('G') || theGame.creator == Convert.ToInt32(Session["LoggedInUserId"]))
                {
                    if (ExtraLib.Sql.getDynastyId(theGame.gameId, 'G') > 0)
                    {
                        panelGermanyBirth.Visible    = true;
                        panelGermanySurvival.Visible = true;
                        panelGermanyMarriage.Visible = true;
                    }
                }
                if (LoggedInDynastyCountry.Equals('I') || theGame.creator == Convert.ToInt32(Session["LoggedInUserId"]))
                {
                    if (ExtraLib.Sql.getDynastyId(theGame.gameId, 'I') > 0)
                    {
                        panelItalyBirth.Visible    = true;
                        panelItalySurvival.Visible = true;
                        panelItalyMarriage.Visible = true;
                    }
                }
                if (LoggedInDynastyCountry.Equals('S') || theGame.creator == Convert.ToInt32(Session["LoggedInUserId"]))
                {
                    if (ExtraLib.Sql.getDynastyId(theGame.gameId, 'S') > 0)
                    {
                        panelSpainBirth.Visible    = true;
                        panelSpainSurvival.Visible = true;
                        panelSpainMarriage.Visible = true;
                    }
                }

                //Make panels visible acording to phase

                int ds = ExtraLib.Sql.getDynasticSequence(Convert.ToInt32(Session["GameId"]));

                switch (ds)
                {
                case 1:
                    itsBirthPhase();
                    break;

                case 2:
                    itsSurvivalPhase();
                    break;

                case 3:
                    itsMarriagePhase();
                    break;

                case 4:
                    itsEventPhase();
                    break;
                }
            }
        }