Beispiel #1
0
    //Gets shop by its shopID
    public MagicShop getMagicShop(int shopID)
    {
        //Make query
        string query = "spGetMagicShop";

        //Obtain Parameters
        SqlParameter[] parameters = new SqlParameter[1];
        parameters[0] = new SqlParameter("shopID", shopID);

        //Retrieve Data
        DataSet data = database.downloadCommand(query, parameters);

        //Make sure the database found the encounter, else return an empty encounter
        MagicShop shop = new MagicShop();

        if (data.Tables[0].Rows.Count == 1)
        {
            string shopName = HttpUtility.HtmlEncode(data.Tables[0].Rows[0]["shopName"].ToString());
            if (shopName.Contains("'"))
            {
                shopName = shopName.Replace("'", "'");
            }
            string shopQuality = HttpUtility.HtmlEncode(data.Tables[0].Rows[0]["shopQuality"].ToString());
            int    gameID      = (int)data.Tables[0].Rows[0]["gameID"];

            shop.ShopID      = shopID;
            shop.ShopName    = shopName;
            shop.ShopQuality = shopQuality;
            shop.GameID      = gameID;
        }

        //Return (hopefully) useful data
        return(shop);
    }
    protected void loadButton_Click(object sender, EventArgs e)
    {
        Int32.TryParse(shopDropDownList.SelectedValue, out int shopID);
        //use this to make an encounter and save to session variable

        MagicsTable magicTable = new MagicsTable(new DatabaseConnection());

        shop = magicTable.getMagicShop(shopID);

        List <MagicItem> shopItems = magicTable.getMagicShopItems(shopID);

        shop.Items = new Dictionary <MagicItem, Color>();

        //Add to items dictionary
        foreach (MagicItem item in shopItems)
        {
            //Color color;
            //if (monster.IsFriendly) color = Color.LightGreen;
            //else color = Color.LightSalmon;
            shop.Items.Add(item, Color.White);
        }

        //Save to savedContent
        Session["savedContent"] = shop;
        Session["message"]      = new Message("Magic Shop Loaded!", System.Drawing.Color.Green);

        //Reload page to clear any nonsense before loading
        Response.Redirect("MagicShopTool");
    }
Beispiel #3
0
    //Updates the provided Shop in the DB.
    public void updateMagicShop(MagicShop shop)
    {
        string query = "spUpdateMagicShop";

        SqlParameter[] parameters = new SqlParameter[2];
        parameters[0] = new SqlParameter("shopID", shop.ShopID);
        parameters[1] = new SqlParameter("shopQuality", shop.ShopQuality);

        database.uploadCommand(query, parameters);
    }
Beispiel #4
0
        public PurchaseMagicalGearTests()
        {
            var wands = new List <IGear>();

            wands.Add(new Wand(new Spell("Cure Light Wounds", "healing"), 20, 1));
            wands.Add(new Wand(new Spell("Lightning Bolt", "evocation"), 20, 1));
            var magicShop = new MagicShop(wands);

            subject = new PurchaseMagicalGear(magicShop);
        }
Beispiel #5
0
    //Inserts the provided Shop
    public int insertMagicShop(MagicShop shop)
    {
        string query = "spInsertMagicShop";

        SqlParameter[] parameters = new SqlParameter[3];      //Add 1 sql parameter
        parameters[0] = new SqlParameter("gameID", shop.GameID);
        parameters[1] = new SqlParameter("shopName", shop.ShopName);
        parameters[2] = new SqlParameter("shopQuality", shop.ShopQuality);

        SqlParameter outputVal = new SqlParameter("@outputID", SqlDbType.Int);

        outputVal.Direction = ParameterDirection.Output;

        return(database.uploadAndReturnCommand(query, outputVal, parameters));
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        //Gate Keeper
        if (Session["userID"] == null)
        {
            Response.Redirect("~/Login");
        }
        if (Session["activeGame"] == null)
        {
            Response.Redirect("~/Home");
        }

        //Get Active Game
        game = (Game)Session["activeGame"];
        gameNameLabel.Text = game.GameName;

        //Load Encounter State if appropriate
        if (Session["savedContent"] != null && ((MagicShop)Session["savedContent"]).GameID != game.GameID)
        {
            Session.Remove("savedContent");   //Handles if there is savedContent from a wrong game.
        }
        if (Session["savedContent"] == null)  //Handles a fresh load with no saved content
        {
            shop        = new MagicShop();
            shop.GameID = game.GameID;
        }
        else    //Handles there is saved content from this game.
        {
            shop = (MagicShop)Session["savedContent"];
            shopNameLabel.Text = "Shop Name: " + shop.ShopName;
        }

        if (!this.IsPostBack)
        {
            populateEncounterDropdown();
        }
        if (shop.ShopName != "")
        {
            hiddenShopName.Value = shop.ShopName;
        }

        loadShopTable();
        //Add js resort function on load
        Main masterPage = this.Master as Main;

        masterPage.Body.Attributes.Add("onLoad", "resort(4);");
    }
    // Start is called before the first frame update
    void Start()
    {
        gameOverMenu.SetActive(false);

        canInput         = true;
        magicShop        = new MagicShop();
        weaponsShop      = new WeaponsShop();
        generalGoodsShop = new GeneralGoodsShop();

        actualBodyText.text = descriptionPrompt;

        totalMoney     = 2500;
        itemsAbleToBuy = 0;

        totalMoneyText.text     = "Total Money: $" + totalMoney;
        itemsAbleToBuyText.text = "Total Items: " + itemsAbleToBuy;
    }
Beispiel #8
0
 public MagicShopTests()
 {
     magicShop = new MagicShop();
 }
Beispiel #9
0
 public PurchaseMagicalGear(MagicShop injectedShop)
 {
     this.magicShop = injectedShop;
 }
Beispiel #10
0
 public PurchaseMagicalGear()
 {
     magicShop = new MagicShop();
 }