public async Task <IActionResult> PutShopkeeper(int id, Shopkeeper shopkeeper)
        {
            if (id != shopkeeper.ProductId)
            {
                return(BadRequest());
            }

            _context.Entry(shopkeeper).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ShopkeeperExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemple #2
0
 void Start()
 {
     serialController = GameObject.Find("Piezo Serial Controller").GetComponent <SerialController>();
     oresRequired     = GameObject.Find("Shopkeeper").GetComponent <OresRequired>();
     shopkeeper       = GameObject.Find("Shopkeeper").GetComponent <Shopkeeper>();
     minecartImages   = canvas.GetComponentsInChildren <Image>();
 }
Exemple #3
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,ItemName,Quantity,Price,amount,Date")] Shopkeeper shopkeeper)
        {
            if (id != shopkeeper.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(shopkeeper);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ShopkeeperExists(shopkeeper.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(shopkeeper));
        }
    public async Task <ActionResult <ShopkeeperSignUpResponse> > PostSignUp(ShopkeeperSignUpRequest request)
    {
        if (string.IsNullOrWhiteSpace(request.Email) ||
            string.IsNullOrWhiteSpace(request.Password))
        {
            return(BadRequest("Required parameters"));
        }

        if (ShopkeeperExists(request.Email))
        {
            return(Conflict());
        }

        request.Password = Hash.Create(request.Password);

        var shopkeeper = new Shopkeeper()
        {
            Email    = request.Email,
            Password = request.Password,
        };

        _context.Shopkeeper.Add(shopkeeper);
        await _context.SaveChangesAsync();

        return(CreatedAtAction("GetShopkeeper", new { id = shopkeeper.Id }, new ShopkeeperSignInResponse()
        {
            Id = shopkeeper.Id,
            Email = shopkeeper.Email,
            Name = shopkeeper.Name,
            Token = JwtSecurityTokenHelper.BuildToken(configuration["Jwt:Key"], shopkeeper),
        }));
    }
        public async Task <ActionResult <Shopkeeper> > PostShopkeeper(Shopkeeper shopkeeper)
        {
            _context.Shopkeeper.Add(shopkeeper);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetShopkeeper", new { id = shopkeeper.ProductId }, shopkeeper));
        }
    // Shopkeeper dialogue
    public void UpdateDialogueBoxShopkeeper(Shopkeeper shopkeeper)
    {
        dialogueText[0].fontSize  = 46;
        dialogueText[0].alignment = TextAnchor.UpperLeft;
        dialogueText[0].text      = shopkeeper.GetName();
        dialogueText[1].text      = shopkeeper.GetDialogue();

        UpdateDialogueButtons(true);
        dialogueButtons[2].onClick.RemoveAllListeners();
        dialogueButtons[2].onClick.AddListener(delegate {
            this.gameObject.GetComponent <UIWindow>().ExitWindow();

            if (shopkeeper.GetCategory() != "")
            {
                string[] categories = new string[] { shopkeeper.GetCategory() };

                QuizBox.GetComponent <UIWindow>().OpenWindow();
                QuizBox.GetComponent <QuizBox>().UpdateQuizBox(categories);
            }
            else
            {
                NutrientList.GetComponent <UIWindow>().OpenWindow();
                Inventory.GetComponent <Inventory>().OpenWindow();
            }
        });
    }
        public void ThiefEncounterNegativeCaseIfItems0()
        {
            //arrange
            Dictionary <Item, int> inv = new Dictionary <Item, int>();

            Cart cart = new Cart
            {
                Gold          = 100,
                ProtectionLvl = 0,
                Inventory     = inv
            };
            Thief theif = new Thief();

            theif.RobAmount = 100;
            Shopkeeper shopkeeper = new Shopkeeper("", cart);
            GameEngine gameEngine = new GameEngine(shopkeeper, theif);

            //act
            Result result = gameEngine.RunEncounter();

            //assert
            Assert.IsFalse(result.IsSuccess);
            Assert.AreEqual($"Rats! You encounter bandits, and they steal 100 gold. Fortunately? you" +
                            $" didn't have any items to steal.", result.Message);
        }
        private void PlaceShopkeeper()
        {
            var shopkeep = new Shopkeeper();

            shopkeep.X = _map.Rooms[0].Center.X + 1;
            shopkeep.Y = _map.Rooms[0].Center.Y + 1;
            _map.AddShopkeeper(shopkeep);
        }
Exemple #9
0
        private void Start()
        {
            dialogue = GetComponent <DialogueBehaviour>();
            flow     = dialogue.Conversation;

            player     = GameObject.FindWithTag("Player").transform;
            shopkeeper = GetComponent <Shopkeeper>();
        }
 public void set_clerk(Shopkeeper new_keeper)
 {
     clerk = new_keeper;
     for (int i = 0; i < clerk.stock.Length; i++)
     {
         transform.GetChild(i).GetComponent <shop_item_panel>().set_item(clerk.stock[i], clerk.costs[i]);
     }
 }
        IEnumerator SpawnShopkeeper()
        {
            yield return(new WaitForSeconds(1.5f));

            GameObject go         = Instantiate(ShopkeeperPrefab, SpawnPoint.position, Quaternion.identity);
            Shopkeeper shopKeeper = go.GetComponent <Shopkeeper>();

            shopKeeper.Platform = this;
            shopKeeper.SpawnShopkeeper();
        }
Exemple #12
0
        public async Task <IActionResult> Create([Bind("Id,ItemName,Quantity,Price,amount,Date")] Shopkeeper shopkeeper)
        {
            if (ModelState.IsValid)
            {
                _context.Add(shopkeeper);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(shopkeeper));
        }
        public void ShouldGreet()
        {
            // arrange
            FakeScrivener fakeScrivener = new FakeScrivener();
            IShopkeeper   shopkeeper    = new Shopkeeper(fakeScrivener);

            // act
            shopkeeper.Greet();

            // assert
            fakeScrivener.Messages[0].Should().Be("OMGHAI!");
        }
        public void TravelShouldIncreaseShopkeeperDistanceBy100()
        {
            //arrange
            Shopkeeper shopkeeper = new Shopkeeper("", new Cart());
            GameEngine gameEngine = new GameEngine(shopkeeper, new Traveler());

            //act
            gameEngine.Travel();
            Shopkeeper result = gameEngine.GetProtagInfo();

            //assert
            Assert.AreEqual(100, result.Distance);
        }
        public ActionResult saveorder(FormCollection fc)
        {
            Cart cart = Session["Cart"] as Cart;

            //shopkepper Address

            Shopkeeper shopkeeper = new Shopkeeper();

            shopkeeper.Shopkeeper_Name     = fc["Shopkeeper_Name"];
            shopkeeper.Shopkeeper_Location = fc["Shopkeeper_Location"];
            shopkeeper.Shopkeeper_Area     = fc["Shopkeeper_Area"];
            shopkeeper.Shopkeeper_Phone    = int.Parse(fc["Shopkeeper_Phone"]);
            db.Shopkeepers.Add(shopkeeper);
            db.SaveChanges();

            //Payment
            Payment payment = new Payment();

            payment.Payment_Type   = fc["Payment_Type"];
            payment.Payment_Phone  = int.Parse(fc["Payment_Phone"]);
            payment.Payment_Code   = int.Parse(fc["Payment_Code"]);
            payment.Payment_Amount = int.Parse(fc["Payment_Amount"]);
            db.Payments.Add(payment);
            db.Payments.Add(payment);

            //order main

            OrderMain orderMain = new OrderMain();

            orderMain.Shopkeeper_ID = shopkeeper.Shopkeeper_ID;
            orderMain.Payment_ID    = payment.Payment_ID;
            //supplier id ---
            orderMain.Delivery_Address = fc["Delivery_Address"];
            orderMain.Order_Date       = int.Parse(fc["Order_Date"]);
            orderMain.Delivery_Date    = int.Parse(fc["Delivery_Date"]);

            foreach (var item in cart.Items)
            {
                OrderSub orderSub = new OrderSub();
                double   Total    = item.PQuantity * item.Productiteams.Product_Price.Value;
                orderSub.OrderMain_ID = orderMain.OrderMain_ID;
                orderSub.Product_ID   = item.Productiteams.Product_ID;
                orderSub.Quantity     = item.PQuantity;
                orderSub.Total_price  = (int)Total;
                db.OrderSubs.Add(orderSub);
            }

            db.Payments.Add(payment);
            cart.Clear();
            return(View("Thanks"));
        }
Exemple #16
0
        public void Checkout_Without_Money_Return_False()
        {
            // Arrange
            var customer = new Customer("Adam", 10, 0);

            customer.shoppingCart.Add("test");
            customer.shoppingCartValue.Add(2);
            var shopkeeper = new Shopkeeper();
            // Act
            var result = customer.Checkout(shopkeeper);

            // Assert
            Assert.IsFalse(result);
        }
Exemple #17
0
    public void OpenShopDialog(Shopkeeper shopkeeper, List <Item> shopItems, float priceMultiplayer)
    {
        if (this.shopkeeper != null)
        {
            this.shopkeeper.CancelTransaction();
        }
        this.shopkeeper = shopkeeper;

        FillShopDialog(shopItems, priceMultiplayer);
        logAreaTxt.text = "Select items to buy/sell.";

        shopDialog.gameObject.SetActive(true);
        isDialogActive = true;
    }
 public void SetShopkeeper(Shopkeeper shopkeeper)
 {
     if (shopkeeper == null)
     {
         Preferences.Set(KEY_SHOPKEEPER, string.Empty);
         Preferences.Set(KEY_API_TOKEN, string.Empty);
     }
     else
     {
         string output = JsonConvert.SerializeObject(shopkeeper);
         Preferences.Set(KEY_SHOPKEEPER, output);
         Preferences.Set(KEY_API_TOKEN, shopkeeper.Token);
     }
 }
Exemple #19
0
    private async Task LogInSuccessful(Shopkeeper shopkeeper)
    {
        preferencesService.SetShopkeeper(shopkeeper);

        if (shopkeeper.IdStore != 0)
        {
            var responseStore = await storeApi.Get(shopkeeper.IdStore);

            preferencesService.SetStore(StoreResponse.Parse(responseStore));
            App.Current.MainPage = new AppHomeShell();
        }
        else
        {
            await Shell.Current.GoToAsync($"///{nameof(ChooseLocationPage)}");
        }
    }
Exemple #20
0
    // Update is called once per frame
    void Update()
    {
        if (playerWithinZone && actionButton.GetClicked())
        {
            UIElement.GetComponent <UIWindow>().OpenWindow();

            if (NPC != null)
            {
                UIElement.GetComponent <DialogueBox>().UpdateDialogueBox(NPC.GetComponent <NPC>());
            }

            if (Shopkeeper != null)
            {
                UIElement.GetComponent <DialogueBox>().UpdateDialogueBoxShopkeeper(Shopkeeper.GetComponent <Shopkeeper>());
            }
        }
    }
Exemple #21
0
    protected virtual Person CreatePerson(string personTypeString, string personNameString, Location personLocation)
    {
        Person person = null;

        switch (personTypeString)
        {
        case "shopkeeper":
            person = new Shopkeeper(personNameString, personLocation);
            break;

        case "traveller":
            person = new Traveller(personNameString, personLocation);
            break;

        default:
            break;
        }
        return(person);
    }
Exemple #22
0
    // Start is called before the first frame update
    void Awake()
    {
        // Keep only 1 instance of the object
        if (instance == null)
        {
            instance = this;

            // Allow shopkeeper to persist
            DontDestroyOnLoad(gameObject);
        }
        else
        {
            // Make sure we're deleting a "copy" and not a newly loaded "Shopkeeper" object
            if (instance != this)
            {
                Destroy(this.gameObject);
            }
        }
    }
Exemple #23
0
        protected virtual Person CreatePerson(string personType, string personName, Location personLocation)
        {
            Person person = null;

            switch (personType)
            {
            case Contants.ShopkeeperCreation:
                person = new Shopkeeper(personName, personLocation);
                break;

            case Contants.TravelerCreation:
                person = new Traveler(personName, personLocation);
                break;

            default:
                break;
            }

            return(person);
        }
Exemple #24
0
        public WndTradeItem(Shopkeeper keeper, Item item, WndBag owner)
        {
            _keeper = keeper;
            _item   = item;
            _owner  = owner;

            var pos = CreateDescription(item, false);

            if (item.Quantity() == 1)
            {
                var btnSell = new RedButton(Utils.Format(TxtSell, item.Price()));
                btnSell.ClickAction = SellAction;
                btnSell.SetRect(0, pos + Gap, WIDTH, BtnHeight);
                Add(btnSell);

                pos = btnSell.Bottom();
            }
            else
            {
                var priceAll = item.Price();
                var btnSell1 = new RedButton(Utils.Format(TxtSell1, priceAll / item.Quantity()));
                btnSell1.ClickAction = SellOneAction;
                btnSell1.SetRect(0, pos + Gap, WIDTH, BtnHeight);
                Add(btnSell1);

                var btnSellAll = new RedButton(Utils.Format(TxtSellAll, priceAll));
                btnSellAll.ClickAction = SellAction;
                btnSellAll.SetRect(0, btnSell1.Bottom() + Gap, WIDTH, BtnHeight);
                Add(btnSellAll);

                pos = btnSellAll.Bottom();
            }

            var btnCancel = new RedButton(TxtCancel);

            btnCancel.ClickAction = CancelAction;
            btnCancel.SetRect(0, pos + Gap, WIDTH, BtnHeight);
            Add(btnCancel);

            Resize(WIDTH, (int)btnCancel.Bottom());
        }
 public void PurchaseOrEquipProduct() //cuando se quiera comprar el producto llamar esta funcion
 {
     if (thisProduct.isPurchased == false)
     {
         Debug.Log("Intento de compra" + thisProduct.itemCode);
         if (Shopkeeper.BuyProduct(thisProduct))
         {
             thisProduct.isPurchased = true;
             PlayerPrefs.SetInt("G" + thisProduct.itemCode, 1);
         }
         else
         {
             thisProduct.isPurchased = false;
             PlayerPrefs.SetInt("G" + thisProduct.itemCode, 0);
             //puede salir un mensaje que diga que no hay suficiente dinero
         }
     }
     else //si el producto ya estaba comprado se equipa
     {
         SaveData.WeaponEquiped = thisProduct.itemCode;
     }
 }
        public void TravelerEncounterNegativeCaseIfItems0()
        {
            //arrange
            Dictionary <Item, int> inv = new Dictionary <Item, int>();

            Cart cart = new Cart
            {
                Gold          = 100,
                ProtectionLvl = 0,
                Inventory     = inv
            };

            Shopkeeper shopkeeper = new Shopkeeper("", cart);
            GameEngine gameEngine = new GameEngine(shopkeeper, new Traveler());

            //act
            Result result = gameEngine.RunEncounter();

            //assert
            Assert.IsFalse(result.IsSuccess);
            Assert.AreEqual($"You encounter a traveler, but because you have nothing to sell, you merely exchange" +
                            $" plesantries and continue on your way.", result.Message);
        }
Exemple #27
0
    public async Task RegisterCommandAsync(IBusyViewModel viewModel, Shopkeeper newShopkeeper)
    {
        var result = await taskHelperFactory.
                     CreateInternetAccessViewModelInstance(loggingService, viewModel).
                     TryExecuteAsync(
            () => authApi.SignUp(new Models.Requests.ShopkeeperSignUpRequest()
        {
            Email    = newShopkeeper.Email,
            Password = newShopkeeper.Password,
            ////Name = newShopkeeper.Name,
        }));

        if (result)
        {
            await RegisterSuccessesful(new Shopkeeper()
            {
                Id    = result.Value.Id,
                Email = result.Value.Email,
                Name  = result.Value.Name,
                Token = result.Value.Token,
            });
        }
    }
        public static Actor CreateNPC(int level, Point location)
        {
            Pool <Actor> npcPool = new Pool <Actor>();

            if (level <= 2)
            {
                npcPool.Add(Explorer.Create(level, new string[] { "Good luck, you will need it.\nBe sure to watch out for the rat-ant queen!\nHere is even more text.\nLine 4\nLine 5",
                                                                  "Watch out for mimics\nThey are mean!" }), 100);
            }
            else if (level <= 4)
            {
                npcPool.Add(Shopkeeper.Create(level), 100);
            }
            else if (level == 5)
            {
                npcPool.Add(Explorer.Create(level, new string[] { "Wow, it's cold down here.\nHope you brought a nice sweater!" }), 100);
            }
            else if (level == 6)
            {
                npcPool.Add(Shopkeeper.Create(level), 100);
            }
            else if (level == 7)
            {
                npcPool.Add(Explorer.Create(level, new string[] { "Watch out for Orks.\nThey are mean!" }), 100);
            }
            else
            {
                npcPool.Add(Shopkeeper.Create(level), 100);
            }

            Actor npc = npcPool.Get();

            npc.X = location.X;
            npc.Y = location.Y;

            return(npc);
        }
 // Start is called before the first frame update
 void Awake()
 {
     instance = this;
 }
Exemple #30
0
 protected virtual Person CreatePerson(string personTypeString, string personNameString, Location personLocation)
 {
     Person person = null;
     switch (personTypeString)
     {
         case "shopkeeper":
             person = new Shopkeeper(personNameString, personLocation);
             break;
         case "traveller":
             person = new Traveller(personNameString, personLocation);
             break;
         default:
             break;
     }
     return person;
 }
Exemple #31
0
 private async Task RegisterSuccessesful(Shopkeeper result)
 {
     preferencesService.SetShopkeeper(result);
     await Shell.Current.GoToAsync($"///{nameof(ChooseLocationPage)}");
 }
Exemple #32
0
 protected override Person CreatePerson(string personTypeString, string personNameString, Location personLocation)
 {
     Person person = null;
     switch (personTypeString)
     {
         case "merchant":
             person = new Shopkeeper(personNameString, personLocation);
             break;
         default: person = base.CreatePerson(personTypeString, personNameString, personLocation);
             break;
     }
     return person;
 }