public ActionResult AddAuctinoProduct()
        {
            AuctionHandler mHandler = new AuctionHandler();

            ViewBag.Brands = AuctionHelper.ToSelectItemList(mHandler.GetCategories());
            return(View());
        }
Exemplo n.º 2
0
    public void DecreaseBid()
    {
        Debug.Log("Decrease bid");
        AuctionHandler auction     = State.getAuctionHandler();
        App            app         = UnityEngine.Object.FindObjectOfType <App>();
        int            playerIndex = app.GetHumanIndex();
        Nation         player      = State.getNations()[playerIndex];

        auction.decreasePlayerTempBid(playerIndex);
        // TextMeshProUGUI playerBid = playerBidText.GetComponent<TextMeshProUGUI>();
        playersCurrentBid.text   = auction.getTempHumanBidLevel().ToString();
        increaseBid.interactable = true;
        if (auction.getPlayerBid(playerIndex) == 0)
        {
            decreaseBid.interactable = false;
        }
        Debug.Log("Current high bid: " + State.CurrentColonyAuctionBid);
        if (auction.getTempHumanBidLevel() > State.CurrentColonyAuctionBid)
        {
            bid.interactable = true;
        }
        else
        {
            bid.interactable = false;
        }
        playerRemainingPoints.text = (player.GetColonialPoints() - auction.getTempHumanBidLevel()).ToString();

        Debug.Log("Colonial Points: " + player.GetColonialPoints());
        Debug.Log("Player Bid: " + auction.getPlayerBid(playerIndex));
    }
Exemplo n.º 3
0
    public void DecreaseBid()
    {
        AuctionHandler auction     = State.getAuctionHandler();
        App            app         = UnityEngine.Object.FindObjectOfType <App>();
        int            playerIndex = app.GetHumanIndex();
        Nation         player      = State.getNations()[playerIndex];

        auction.decreasePlayerBid(playerIndex);
        TextMeshProUGUI playerBid = playerBidText.GetComponent <TextMeshProUGUI>();

        playerBid.text = auction.getPlayerBid(playerIndex).ToString();
        if (auction.getPlayerBid(playerIndex) == 0)
        {
            increceBid.gameObject.SetActive(true);
            decreaseBid.gameObject.SetActive(false);
        }
        if (auction.getPlayerBid(playerIndex) > auction.getCurrentBid())
        {
            bid.interactable = true;
        }
        else
        {
            bid.interactable = false;
        }
    }
Exemplo n.º 4
0
 public void AuctionHello(Character chr, NPC auctioneer)
 {
     if (!DoAuctioneerInteraction(chr, auctioneer))
     {
         return;
     }
     AuctionHandler.SendAuctionHello(chr.Client, auctioneer);
 }
Exemplo n.º 5
0
 public void AuctionHello(Character chr, NPC auctioneer)
 {
     if (!AuctionMgr.DoAuctioneerInteraction(chr, auctioneer))
     {
         return;
     }
     AuctionHandler.SendAuctionHello((IPacketReceiver)chr.Client, auctioneer);
 }
Exemplo n.º 6
0
 public void AuctionListItems(Character chr, NPC auctioneer, AuctionSearch searcher)
 {
     if (!DoAuctioneerInteraction(chr, auctioneer))
     {
         return;
     }
     Auction[] array = searcher.RetrieveMatchedAuctions(auctioneer.AuctioneerEntry.Auctions).ToArray();
     AuctionHandler.SendAuctionListItems(chr.Client, array);
 }
Exemplo n.º 7
0
 public void AuctionListOwnerItems(Character chr, NPC auctioneer)
 {
     if (!AuctionMgr.DoAuctioneerInteraction(chr, auctioneer))
     {
         return;
     }
     Auction[] array = Auction.GetAuctionsForCharacter(chr.EntityId.Low).ToArray <Auction>();
     AuctionHandler.SendAuctionListOwnerItems((IPacketReceiver)chr.Client, array);
 }
Exemplo n.º 8
0
 public void AuctionListBidderItems(Character chr, NPC auctioneer)
 {
     if (!DoAuctioneerInteraction(chr, auctioneer))
     {
         return;
     }
     Auction[] array = Auction.GetBidderAuctionsForCharacter(chr.EntityId.Low).ToArray();
     AuctionHandler.SendAuctionListBidderItems(chr.Client, array);
 }
Exemplo n.º 9
0
    private void playerBid()
    {
        AuctionHandler auction     = State.getAuctionHandler();
        App            app         = UnityEngine.Object.FindObjectOfType <App>();
        int            playerIndex = app.GetHumanIndex();

        auction.setIndexOfHighestBidderSoFar(playerIndex);
        auction.setCurrentBid(auction.getPlayerBid(playerIndex));
        playerTurn = false;
    }
Exemplo n.º 10
0
    private void playerPass()
    {
        AuctionHandler auction     = State.getAuctionHandler();
        App            app         = UnityEngine.Object.FindObjectOfType <App>();
        int            playerIndex = app.GetHumanIndex();

        auction.passOnBid(playerIndex);

        // Nation player = State.getNations()[playerIndex];
        playerTurn = false;
    }
Exemplo n.º 11
0
        public void CancelAuction(Character chr, NPC auctioneer, uint auctionId)
        {
            if (!DoAuctioneerInteraction(chr, auctioneer))
            {
                return;
            }
            Auction auction;

            if (auctioneer.AuctioneerEntry.Auctions.TryGetAuction(auctionId, out auction))
            {
                if ((int)auction.OwnerLowId == (int)chr.EntityId.Low)
                {
                    ItemRecord recordById = ItemRecord.GetRecordByID(auction.ItemLowId);
                    if (recordById != null)
                    {
                        if ((int)auction.BidderLowId != (int)auction.OwnerLowId)
                        {
                            uint amount = CalcAuctionCut(auction.HouseFaction, auction.CurrentBid);
                            if (chr.Money < amount)
                            {
                                AuctionHandler.SendAuctionCommandResult(chr.Client, auction,
                                                                        AuctionAction.CancelAuction, AuctionError.NotEnoughMoney);
                                return;
                            }

                            auction.SendMail(MailAuctionAnswers.CancelledToBidder, auction.CurrentBid);
                            chr.SubtractMoney(amount);
                        }

                        auction.SendMail(MailAuctionAnswers.Cancelled, recordById);
                        auctioneer.AuctioneerEntry.Auctions.RemoveAuction(auction);
                        AuctionHandler.SendAuctionCommandResult(chr.Client, auction,
                                                                AuctionAction.CancelAuction, AuctionError.Ok);
                        auctioneer.AuctioneerEntry.Auctions.RemoveAuction(auction);
                    }
                    else
                    {
                        AuctionHandler.SendAuctionCommandResult(chr.Client, auction,
                                                                AuctionAction.CancelAuction, AuctionError.ItemNotFound);
                    }
                }
                else
                {
                    AuctionHandler.SendAuctionCommandResult(chr.Client, auction,
                                                            AuctionAction.CancelAuction, AuctionError.ItemNotFound);
                }
            }
            else
            {
                AuctionHandler.SendAuctionCommandResult(chr.Client, auction,
                                                        AuctionAction.CancelAuction, AuctionError.ItemNotFound);
            }
        }
        // GET: FeedBack
        public ActionResult Index()
        {
            User user = (User)Session[WebUtils.Current_User];

            if (!(user != null && user.IsInRole(WebUtils.Admin)))
            {
                return(RedirectToAction("Login", "Users", new { ctl = "Feedback", act = "GetFeedBack" }));
            }
            List <FeedBack> feed = new AuctionHandler().GetAllFeedBacks();

            return(View(feed));
        }
        public ActionResult UpdateAuction(int id)
        {
            User user = (User)Session[WebUtils.Current_User];

            if (!(user != null && user.IsInRole(WebUtils.Admin)))
            {
                return(RedirectToAction("Login", "Users", new { ctl = "Auction", act = "Getauction" }));
            }
            Auction auction = new AuctionHandler().GetAuctionById(id);

            return(View(auction));
        }
Exemplo n.º 14
0
    private void playerPass()
    {
        Debug.Log("Player Passes  >>>>>>>>>>>>>>>>>>>>>>>>>>");
        AuctionHandler auction     = State.getAuctionHandler();
        App            app         = UnityEngine.Object.FindObjectOfType <App>();
        int            playerIndex = app.GetHumanIndex();
        Text           bidText     = bid.GetComponentInChildren <Text>();

        auction.tempHumanBidLevel = auction.getPlayerBid(playerIndex);
        auction.passOnBid(playerIndex);
        auction.incrementBiddingPosition();
        nextAuctionPhase();
        // Nation player = State.getNations()[playerIndex];
    }
Exemplo n.º 15
0
        private static void SendOutbidMail(Auction auction, uint newBid)
        {
            if (auction == null)
            {
                return;
            }
            Character character = World.GetCharacter(auction.BidderLowId);

            if (character != null)
            {
                AuctionHandler.SendAuctionOutbidNotification(character.Client, auction, newBid,
                                                             GetMinimumNewBidIncrement(auction));
            }
            auction.SendMail(MailAuctionAnswers.Outbid, auction.CurrentBid);
        }
Exemplo n.º 16
0
    public void auctionControlFlow()
    {
        AuctionHandler auction = State.getAuctionHandler();

        Debug.Log("Begin Auction Control Flow");
        App    app         = UnityEngine.Object.FindObjectOfType <App>();
        int    playerIndex = app.GetHumanIndex();
        Nation humanPlayer = State.getNations()[playerIndex];

        // int start = currentBidPosition;
        //for (int i = start; i < biddingOrder.Count; i++)
        //{
        while (true)
        {
            Debug.Log("Top of while loop");
            Nation currentPlayer = State.getNations()[auction.getBiddingOrder()[auction.CurrentBidPosition]];
            State.setCurrentPlayer(auction.getBiddingOrder()[auction.CurrentBidPosition]);

            Debug.Log("Current Position is: " + auction.CurrentBidPosition);
            Debug.Log("Current Bidder is: " + currentPlayer.getName());
            Debug.Log("Curret Bidder Index is: " + currentPlayer.getIndex());
            //Debug.Log("Current player - " + currentPlayer.nationName);
            Debug.Log("Current player passed already? :" + auction.getIfPlayerPass(currentPlayer.getIndex()));
            if (humanPlayer.getIndex() == currentPlayer.getIndex() && !auction.getIfPlayerPass(humanPlayer.getIndex()))
            //  if (humanPlayer.getIndex() == currentPlayer.getIndex())
            {
                Debug.Log("Current is human");
                return;
            }
            if (humanPlayer.getIndex() == currentPlayer.getIndex() && auction.getIfPlayerPass(humanPlayer.getIndex()))
            {
                auction.incrementBiddingPosition();
                return;
            }

            else if (currentPlayer.getIndex() == auction.getHighestBidderSoFar())
            {
                Debug.Log("Returned to highest bidder (auction presumably over) " + auction.CurrentBidPosition);
                return;
            }
            else
            {
                Debug.Log("AI bid");
                auction.newBid(currentPlayer);
            }
            auction.incrementBiddingPosition();
        }
    }
Exemplo n.º 17
0
    private void playerBid()
    {
        Debug.Log("Player bids >>>>>>>>>>>>>>>>>>>>>>>>>>>>");
        AuctionHandler auction     = State.getAuctionHandler();
        App            app         = UnityEngine.Object.FindObjectOfType <App>();
        int            playerIndex = app.GetHumanIndex();
        int            playerBid   = auction.getTempHumanBidLevel();

        auction.setPlayerBid(playerIndex, playerBid);
        auction.setIndexOfHighestBidderSoFar(playerIndex);
        //State.CurrentColonyAuctionBid = auction.getPlayerBid(playerIndex);
        State.UpdateColonyAuctionBid(auction.getPlayerBid(playerIndex));
        auction.incrementBiddingPosition();

        nextAuctionPhase();
    }
Exemplo n.º 18
0
    public void contiueToAuction()
    {
        increaseBid.gameObject.SetActive(true);
        decreaseBid.gameObject.SetActive(true);
        App    app         = UnityEngine.Object.FindObjectOfType <App>();
        int    playerIndex = app.GetHumanIndex();
        Nation player      = State.getNations()[playerIndex];

        Debug.Log("Coutinune to Auction @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" + State.GetPhase().ToString());

        tradeResultsExit.Play();
        tradeResultsPanel.SetActive(false);

        //State.advanceGamePhase();
        Debug.Log("GamePhase is: " + State.GetPhase().ToString());
        // Check if should to go auction (if enough turns have gone by)
        int turn = State.turn;

        if (turn > 5 && turn % 3 == 0)
        {
            // Debug.Log("Auction Time? It is Turn: " + State.turn);
            AuctionHandler auction = State.getAuctionHandler();

            auction.NewAuction();
            prepareAuctionPanel(auction);
            openAuctionPanel();

            nextAuctionPhase();
            turnButton.interactable = true;
        }
        else
        {
            // turnButton.interactable = true;
            continueToEvents();
            // Have these guys only get called after all events are resolved
            // Probably want to have at least one Decision Event come up and have the final one call continueToNextTurn when
            // the event queue is empty
            turnButton.interactable = true;

            continueToNextTurn();
        }
    }
Exemplo n.º 19
0
    public void prepareWinnerPanel()
    {
        Debug.Log("Prepare winner Panel");
        AuctionHandler auction    = State.getAuctionHandler();
        int            itemIndex  = auction.getIndexOfCurrentItem();
        Nation         itemNation = State.getNations()[itemIndex];

        Debug.Log(itemNation.getNationName());
        GameObject itemFlag = Instantiate(Resources.Load <GameObject>("Flags/Prefabs/" + itemNation.getNationName()));

        itemFlag2.ObjectPrefab = itemFlag.transform;

        Nation     winner      = State.getNations()[auction.getHighestBidderSoFar()];
        GameObject _winnerFlag = Instantiate(Resources.Load <GameObject>("Flags/Prefabs/" + winner.getNationName()));

        winnerFlag.ObjectPrefab = _winnerFlag.transform;

        auctionPrizeText.text  = "The colony of " + itemNation.getName();
        auctionWinnerText.text = "Goes to " + winner.getName() + "!";
    }
Exemplo n.º 20
0
    private void declareAuctionResults()
    {
        App            app         = UnityEngine.Object.FindObjectOfType <App>();
        int            playerIndex = app.GetHumanIndex();
        Nation         player      = State.getNations()[playerIndex];
        AuctionHandler auction     = State.getAuctionHandler();
        Nation         winner      = State.getNations()[auction.getHighestBidderSoFar()];
        Nation         item        = State.getNations()[0];

        item = State.getNations()[auction.getIndexCurrentCol()];
        if (winner.getIndex() == player.getIndex())
        {
            ministerText.text = "Congratulations! We may now bring the light of civilization to the people of " + item.getNationName() +
                                " asking for nothing in return other than unrestricted access to their resources and labour!";
            //  ministerPanel.SetActive(true);
        }
        else
        {
            ministerText.text = "It looks like " + winner.getNationName() + " has managed to seal control of " + item.getNationName() +
                                " for now.... Not that we really wanted anything to do with that insignifigant nation anyway.";
        }
        ministerPanel.SetActive(true);
    }
Exemplo n.º 21
0
        public void AuctionPlaceBid(Character chr, NPC auctioneer, uint auctionId, uint bid)
        {
            if (!DoAuctioneerInteraction(chr, auctioneer))
            {
                return;
            }
            Auction auction = null;

            if (!auctioneer.AuctioneerEntry.Auctions.TryGetAuction(auctionId, out auction))
            {
                AuctionHandler.SendAuctionCommandResult(chr.Client, null,
                                                        AuctionAction.PlaceBid, AuctionError.InternalError);
            }
            else
            {
                AuctionError error = AuctionBidChecks(auction, chr, bid);
                if (error != AuctionError.Ok)
                {
                    AuctionHandler.SendAuctionCommandResult(chr.Client, auction,
                                                            AuctionAction.PlaceBid, error);
                }
                else if (bid < auction.BuyoutPrice || auction.BuyoutPrice == 0U)
                {
                    if (auction.BidderLowId == (long)(ulong)chr.EntityId)
                    {
                        chr.SubtractMoney(bid - auction.CurrentBid);
                    }
                    else
                    {
                        chr.SubtractMoney(bid);
                        SendOutbidMail(auction, bid);
                    }

                    auction.BidderLowId = chr.EntityId.Low;
                    auction.CurrentBid  = bid;
                    AuctionHandler.SendAuctionCommandResult(chr.Client, auction,
                                                            AuctionAction.PlaceBid, AuctionError.Ok);
                }
                else
                {
                    if (auction.BidderLowId == (long)(ulong)chr.EntityId)
                    {
                        chr.SubtractMoney(auction.BuyoutPrice - auction.CurrentBid);
                    }
                    else
                    {
                        chr.SubtractMoney(auction.BuyoutPrice);
                        if ((int)auction.BidderLowId != (int)auction.OwnerLowId)
                        {
                            SendOutbidMail(auction, auction.BuyoutPrice);
                        }
                    }

                    auction.BidderLowId = chr.EntityId.Low;
                    auction.CurrentBid  = auction.BuyoutPrice;
                    SendAuctionSuccessfullMail(auction);
                    SendAuctionWonMail(auction);
                    AuctionHandler.SendAuctionCommandResult(chr.Client, auction,
                                                            AuctionAction.PlaceBid, AuctionError.Ok);
                    auctioneer.AuctioneerEntry.Auctions.RemoveAuction(auction);
                }
            }
        }
Exemplo n.º 22
0
 public GameSocket(ISerializer serializer) : base(serializer)
 {
     _achievementHandler       = new AchievementHandler(this);
     _activityHandler          = new ActivityHandler(this);
     _activityFavorHandler     = new ActivityFavorHandler(this);
     _amuletHandler            = new AmuletHandler(this);
     _arenaHandler             = new ArenaHandler(this);
     _attendanceHandler        = new AttendanceHandler(this);
     _bagHandler               = new BagHandler(this);
     _battleHandler            = new BattleHandler(this);
     _cardHandler              = new CardHandler(this);
     _consignmentLineHandler   = new ConsignmentLineHandler(this);
     _crossServerHandler       = new CrossServerHandler(this);
     _dailyActivityHandler     = new DailyActivityHandler(this);
     _demonTowerHandler        = new DemonTowerHandler(this);
     _equipHandler             = new EquipHandler(this);
     _exchangeHandler          = new ExchangeHandler(this);
     _fashionHandler           = new FashionHandler(this);
     _fightLevelHandler        = new FightLevelHandler(this);
     _fleeHandler              = new FleeHandler(this);
     _friendHandler            = new FriendHandler(this);
     _functionHandler          = new FunctionHandler(this);
     _functionOpenHandler      = new FunctionOpenHandler(this);
     _giftOnlineHandler        = new GiftOnlineHandler(this);
     _goddessHandler           = new GoddessHandler(this);
     _guildBlessHandler        = new GuildBlessHandler(this);
     _guildBossHandler         = new GuildBossHandler(this);
     _guildDepotHandler        = new GuildDepotHandler(this);
     _guildHandler             = new GuildHandler(this);
     _guildShopHandler         = new GuildShopHandler(this);
     _guildTechHandler         = new GuildTechHandler(this);
     _hookSetHandler           = new HookSetHandler(this);
     _interactHandler          = new InteractHandler(this);
     _intergalMallHandler      = new IntergalMallHandler(this);
     _itemHandler              = new ItemHandler(this);
     _leaderBoardHandler       = new LeaderBoardHandler(this);
     _limitTimeActivityHandler = new LimitTimeActivityHandler(this);
     _mailHandler              = new MailHandler(this);
     _mapHandler               = new MapHandler(this);
     _masteryHandler           = new MasteryHandler(this);
     _medalHandler             = new MedalHandler(this);
     _messageHandler           = new MessageHandler(this);
     _mountHandler             = new MountHandler(this);
     _npcHandler               = new NpcHandler(this);
     _offlineAwardHandler      = new OfflineAwardHandler(this);
     _onlineGiftHandler        = new OnlineGiftHandler(this);
     _payGiftHandler           = new PayGiftHandler(this);
     _petHandler               = new PetHandler(this);
     _petNewHandler            = new PetNewHandler(this);
     _playerHandler            = new PlayerHandler(this);
     _prepaidHandler           = new PrepaidHandler(this);
     _rankHandler              = new RankHandler(this);
     _resourceDungeonHandler   = new ResourceDungeonHandler(this);
     _resourceHandler          = new ResourceHandler(this);
     _rewardHandler            = new RewardHandler(this);
     _saleHandler              = new SaleHandler(this);
     _shopMallHandler          = new ShopMallHandler(this);
     _skillHandler             = new SkillHandler(this);
     _skillKeysHandler         = new SkillKeysHandler(this);
     _soloHandler              = new SoloHandler(this);
     _stealHandler             = new StealHandler(this);
     _sysSetHandler            = new SysSetHandler(this);
     _taskHandler              = new TaskHandler(this);
     _teamHandler              = new TeamHandler(this);
     _tradeHandler             = new TradeHandler(this);
     _treasureHandler          = new TreasureHandler(this);
     _upLevelHandler           = new UpLevelHandler(this);
     _vipHandler               = new VipHandler(this);
     _vitalityHandler          = new VitalityHandler(this);
     _wingHandler              = new WingHandler(this);
     _activityRevelryHandler   = new ActivityRevelryHandler(this);
     _auctionHandler           = new AuctionHandler(this);
     _chatHandler              = new ChatHandler(this);
     _daoYouHandler            = new DaoYouHandler(this);
     _entryHandler             = new EntryHandler(this);
     _roleHandler              = new RoleHandler(this);
     _farmHandler              = new FarmHandler(this);
     _five2FiveHandler         = new Five2FiveHandler(this);
     _guildManagerHandler      = new GuildManagerHandler(this);
     _xianYuanHandler          = new XianYuanHandler(this);
 }
Exemplo n.º 23
0
    public void nextAuctionPhase()
    {
        Debug.Log("Begin new auction phase");
        //   waitASec(0.8f);

        AuctionHandler auction     = State.getAuctionHandler();
        App            app         = UnityEngine.Object.FindObjectOfType <App>();
        int            humanIndex  = app.GetHumanIndex();
        Nation         humanPlayer = State.getNations()[humanIndex];

        updateAuctionPanel();
        if (auction.checkIfAuctionIsOver())
        {
            Debug.Log("Auction Should be Over now");
            continueToNextTurn();
            AuctionPanel.SetActive(false);
            auction.concludeAuction();
            prepareWinnerPanel();
            AuctionWinnerPanel.SetActive(true);
            terrainUpdater.ColourContries();
        }
        else
        {
            Debug.Log("Auction Will Continue");
            //If all players have bid and auction is not over - go back to the first bidder
            //  Debug.Log(auction.CurrentBidPosition);
            //  if(auction.CurrentBidPosition == State.getMajorNations().Count)
            //  {
            //      Debug.Log("Return to first remaining bidder");
            //      auction.CurrentBidPosition = 0;
            //  }
            // Go to auction control flow - it will have each AI player bid or pass until reaching the Human controlled player
            auctionControlFlow();
            updateAuctionPanel();
            // If human has passed
            Debug.Log("Human has passed?: " + humanPlayer.getIndex());
            if (auction.getIfPlayerPass(humanPlayer.getIndex()))
            {   // Check if all players have now passed
                Debug.Log("Human Player has passed");

                /*  if (auction.checkIfAuctionIsOver())
                 * {
                 *
                 *    Debug.Log("Auction Should be Over now");
                 *    continueToNextTurn();
                 *    AuctionPanel.SetActive(false);
                 *    auction.concludeAuction();
                 *    prepareWinnerPanel();
                 *    AuctionWinnerPanel.SetActive(true);
                 *    terrainUpdater.ColourContries();
                 * } */
                // NextPhaseAfterPlayerPasses(1.5f);
                // else
                // {
                Debug.Log("Bidding continues without human");
                auctionControlFlow();
                // }
            }
            Debug.Log(auction.CurrentBidPosition);
            int indexOfCurrentBidder = auction.getBiddingOrder()[auction.CurrentBidPosition];
            if (indexOfCurrentBidder != humanIndex)
            {
                auctionControlFlow();
            }
            // nextAuctionPhase();
            Debug.Log("Should be player's turn now?");
            //If player has not passed, control will now be handed to the player
        }
    }
        public ActionResult GetAuctionDetail()
        {
            List <Auction> auctions = new AuctionHandler().GetAllAuctions();

            return(View(auctions));
        }
Exemplo n.º 25
0
        public void AuctionSellItem(Character chr, NPC auctioneer, EntityId itemId, uint bid, uint buyout, uint time, uint stackSize)
        {
            if (!DoAuctioneerInteraction(chr, auctioneer))
            {
                return;
            }

            var item = chr.Inventory.GetItem(itemId, false);

            var msg = AuctionCheatChecks(auctioneer, item, bid, time);

            if (msg == AuctionError.Ok)
            {
                // Check that character has enough money to cover the deposit
                var houseFaction = auctioneer.AuctioneerEntry.LinkedHouseFaction;
                var deposit      = GetAuctionDeposit(item, houseFaction, time);
                if (chr.Money < deposit)
                {
                    AuctionHandler.SendAuctionCommandResult(chr.Client, null, AuctionAction.SellItem, AuctionError.NotEnoughMoney);
                    return;
                }

                if (item.Amount > stackSize)
                {
                    item = item.Split((int)stackSize);
                }

                if (item == null)
                {
                    AuctionHandler.SendAuctionCommandResult(chr.Client, null, AuctionAction.SellItem, AuctionError.ItemNotFound);
                    return;
                }


                // Charge the deposit to the character
                chr.Money -= deposit;


                // Create the new Auction and add it to the list.

                var newAuction = new Auction
                {
                    BidderLowId    = 0,
                    BuyoutPrice    = buyout,
                    CurrentBid     = bid,
                    Deposit        = deposit,
                    HouseFaction   = houseFaction,
                    ItemLowId      = item.EntityId.Low,
                    ItemTemplateId = item.Template.Id,
                    OwnerLowId     = chr.EntityId.Low,
                    TimeEnds       = DateTime.Now.AddMinutes(time),
                    IsNew          = true
                };



                //save new auction to database and add item to items container
                RealmServer.IOQueue.AddMessage(new Util.Threading.Message(() =>
                {
                    ItemRecord record  = item.Record;
                    record.IsAuctioned = true;
                    record.Save();
                    auctioneer.AuctioneerEntry.Auctions.AddAuction(
                        newAuction);
                    AuctionItems.Add(newAuction.ItemLowId, record);
                    item.Remove(false);
                    AuctionListOwnerItems(chr, auctioneer);
                }));

                // Send the all-good message
                AuctionHandler.SendAuctionCommandResult(chr.Client, newAuction, AuctionAction.SellItem, AuctionError.Ok);
            }
            else
            {
                AuctionHandler.SendAuctionCommandResult(chr.Client, null, AuctionAction.SellItem, msg);
            }
        }
        public ActionResult GetAuctionDetailForCustomer(int id)
        {
            Auction auctions = new AuctionHandler().GetAuctionById(id);

            return(View(auctions));
        }
Exemplo n.º 27
0
        public void AuctionPlaceBid(Character chr, NPC auctioneer, uint auctionId, uint bid)
        {
            if (!DoAuctioneerInteraction(chr, auctioneer))
            {
                return;
            }

            Auction auction = null;

            if (!auctioneer.AuctioneerEntry.Auctions.TryGetAuction(auctionId, out auction))
            {
                AuctionHandler.SendAuctionCommandResult(chr.Client, null, AuctionAction.PlaceBid, AuctionError.InternalError);
                return;
            }

            var msg = AuctionBidChecks(auction, chr, bid);

            if (msg != AuctionError.Ok)
            {
                AuctionHandler.SendAuctionCommandResult(chr.Client, auction, AuctionAction.PlaceBid, msg);
                return;
            }

            if (bid < auction.BuyoutPrice || (auction.BuyoutPrice == 0))
            {
                if (auction.BidderLowId == chr.EntityId)
                {
                    chr.Money -= (bid - auction.CurrentBid);
                }
                else
                {
                    chr.Money -= bid;

                    // Send a mail to the outbid character with their bid money
                    SendOutbidMail(auction, bid);
                }

                auction.BidderLowId = chr.EntityId.Low;
                auction.CurrentBid  = bid;

                AuctionHandler.SendAuctionCommandResult(chr.Client, auction, AuctionAction.PlaceBid, AuctionError.Ok);
            }
            else
            {
                // This is a buyout
                if (auction.BidderLowId == chr.EntityId)
                {
                    chr.Money -= (auction.BuyoutPrice - auction.CurrentBid);
                }
                else
                {
                    chr.Money -= auction.BuyoutPrice;
                    if (auction.BidderLowId != auction.OwnerLowId)
                    {
                        // Someone had already bid on this item, send them a rejection letter
                        SendOutbidMail(auction, auction.BuyoutPrice);
                    }
                }
                auction.BidderLowId = chr.EntityId.Low;
                auction.CurrentBid  = auction.BuyoutPrice;

                SendAuctionSuccessfullMail(auction);
                SendAuctionWonMail(auction);

                AuctionHandler.SendAuctionCommandResult(chr.Client, auction, AuctionAction.PlaceBid, AuctionError.Ok);

                auctioneer.AuctioneerEntry.Auctions.RemoveAuction(auction);
            }
        }
Exemplo n.º 28
0
        public void CancelAuction(Character chr, NPC auctioneer, uint auctionId)
        {
            if (!DoAuctioneerInteraction(chr, auctioneer))
            {
                return;
            }

            Auction auction;

            if (auctioneer.AuctioneerEntry.Auctions.TryGetAuction(auctionId, out auction))
            {
                if (auction.OwnerLowId == chr.EntityId.Low)
                {
                    var itemRecord = ItemRecord.GetRecordByID(auction.ItemLowId);
                    if (itemRecord != null)
                    {
                        if (auction.BidderLowId != auction.OwnerLowId)
                        {
                            // someone has bid on the item already, his money must be returned
                            // and the cancelling player must be charged the auctionhouse's cut
                            var auctionhouseCut = CalcAuctionCut(auction.HouseFaction, auction.CurrentBid);
                            if (chr.Money < auctionhouseCut)
                            {
                                // the player is no-good for the money, the auction cannot be cancelled
                                AuctionHandler.SendAuctionCommandResult(chr.Client, auction, AuctionAction.CancelAuction, AuctionError.NotEnoughMoney);
                                return;
                            }

                            //var bidder = WorldMgr.GetCharacter(auction.BidderLowId);
                            //if (bidder != null)
                            //{
                            // send bidder a notification?
                            //}
                            auction.SendMail(MailAuctionAnswers.CancelledToBidder, auction.CurrentBid);
                            chr.Money -= auctionhouseCut;
                        }

                        // return the item to the seller via mail
                        auction.SendMail(MailAuctionAnswers.Cancelled, itemRecord);
                        auctioneer.AuctioneerEntry.Auctions.RemoveAuction(auction);
                    }
                    else
                    {
                        // auction contains a non-existant item
                        AuctionHandler.SendAuctionCommandResult(chr.Client, auction, AuctionAction.CancelAuction, AuctionError.ItemNotFound);
                        return;
                    }
                }
                else
                {
                    // trying to cancel someone else's auction -- CHEATER!
                    AuctionHandler.SendAuctionCommandResult(chr.Client, auction, AuctionAction.CancelAuction, AuctionError.ItemNotFound);
                    return;
                }
            }
            else
            {
                // auction not found -- CHEATER?
                AuctionHandler.SendAuctionCommandResult(chr.Client, auction, AuctionAction.CancelAuction, AuctionError.ItemNotFound);
                return;
            }

            AuctionHandler.SendAuctionCommandResult(chr.Client, auction, AuctionAction.CancelAuction, AuctionError.Ok);
            auctioneer.AuctioneerEntry.Auctions.RemoveAuction(auction);
        }
Exemplo n.º 29
0
    private void prepareAuctionPanel(AuctionHandler auction)
    {
        increaseBid.enabled = true;
        decreaseBid.enabled = true;
        App             app         = UnityEngine.Object.FindObjectOfType <App>();
        int             playerIndex = app.GetHumanIndex();
        Nation          player      = State.getNations()[playerIndex];
        TextMeshProUGUI title       = AuctionPanelTitleText.GetComponent <TextMeshProUGUI>();
        Nation          item        = State.getNations()[0];

        // Colony Auction
        backGroudImage.sprite = Resources.Load("Sprites/BackGrounds/imperialism_cartoon", typeof(Sprite)) as Sprite;
        title.text            = "Colony Bids";
        pointTypeText.text    = "Colonial Points";
        // PointTypeImage.sprite = Resources.Load("Sprites/GUI/eagle", typeof(Sprite)) as Sprite;

        item = State.getNations()[auction.getIndexOfCurrentItem()];

        // GameObject mapPrefab = Instantiate(Resources.Load<GameObject>("RPG100set/512/Prop/06_letter" + item.getNationName()));
        currentNumberOfBiddingPoints.text = player.GetColonialPoints().ToString();
        if (player.GetColonialPoints() < State.CurrentColonyAuctionBid || player.RecognizingTheseClaims.Contains(item.getIndex()) || player.landForces.Strength < 2)
        {
            increaseBid.interactable = false;
        }
        else
        {
            increaseBid.interactable = true;
        }

        TextMeshProUGUI itemName = ItemNameText.GetComponent <TextMeshProUGUI>();

        itemName.text = item.getNationName();

        GameObject itemFlag = Instantiate(Resources.Load <GameObject>("Flags/Prefabs/" + item.getNationName()));

        itemFlag1.ObjectPrefab = itemFlag.transform;

        // TextMeshProUGUI currentPlayerBid = currentBidAmount.GetComponent<TextMeshProUGUI>();
        currentBidAmount.text = "00";
        int firstProvIndex  = -1;
        int secondProvIndex = -1;

        foreach (int provIndex in item.getProvinces())
        {
            if (firstProvIndex == -1)
            {
                firstProvIndex = provIndex;
            }
            else
            {
                secondProvIndex = provIndex;
            }
        }

        assemblyCsharp.Province firstProvince = State.getProvince(firstProvIndex);
        itemProvinces.Rows[1].Cells[0].GetComponentInChildren <Text>().text = firstProvince.getProvName();
        //  itemProvinces.Rows[1].Cells[1].GetComponentInChildren<Image>().sprite =
        Transform P1Res      = itemProvinces.Rows[1].Cells[1].transform.GetChild(0);
        Image     P1ResImage = P1Res.GetComponent <Image>();

        // Image provOneRes = itemProvinces.Rows[1].Cells[1].GetComponentInChildren<Image>() as Image;
        //resImg.sprite = Resources.Load("Resource/" + imp.getResourceType().ToString(), typeof(Sprite)) as Sprite;
        //  Debug.Log("First Resource is: " + firstProvince.getResource());
        P1ResImage.sprite = Resources.Load("Resource/" + firstProvince.getResource().ToString(), typeof(Sprite)) as Sprite;
        itemProvinces.Rows[1].Cells[2].GetComponentInChildren <Text>().text = firstProvince.getDevelopmentLevel().ToString();
        Toggle provOneRail = itemProvinces.Rows[1].Cells[3].GetComponentInChildren <Toggle>();

        if (firstProvince.getRail())
        {
            provOneRail.isOn = true;
        }
        else
        {
            provOneRail.isOn = false;
        }

        assemblyCsharp.Province secondProvince = State.getProvince(secondProvIndex);
        itemProvinces.Rows[2].Cells[0].GetComponentInChildren <Text>().text = secondProvince.getProvName();
        //  itemProvinces.Rows[1].Cells[1].GetComponentInChildren<Image>().sprite =
        // Image provTwoRes = itemProvinces.Rows[2].Cells[1].GetComponentInChildren<Image>() as Image;
        // Debug.Log("Second Resource is: " + secondProvince.getResource());
        Transform P2Res      = itemProvinces.Rows[2].Cells[1].transform.GetChild(0);
        Image     P2ResImage = P2Res.GetComponent <Image>();

        P2ResImage.sprite = Resources.Load("Resource/" + secondProvince.getResource().ToString(), typeof(Sprite)) as Sprite;
        itemProvinces.Rows[2].Cells[2].GetComponentInChildren <Text>().text = secondProvince.getDevelopmentLevel().ToString();
        Toggle provTwoRail = itemProvinces.Rows[2].Cells[3].GetComponentInChildren <Toggle>();

        if (secondProvince.getRail())
        {
            provTwoRail.isOn = true;
        }
        else
        {
            provTwoRail.isOn = false;
        }
        if (item.IsColonyOf() != -1)
        {
            Nation currentOwner = State.getNations()[item.IsColonyOf()];
            currentOwnerName.text         = currentOwner.getNationName();
            relationWithCurrentOwner.text = player.Relations[currentOwner.getIndex()].ToString();
        }
        else
        {
            currentOwnerName.text = "None";
        }

        if (player.RecognizingTheseClaims.Contains(item.getIndex()))
        {
            isRecognizing.isOn = true;
        }
        else
        {
            isRecognizing.isOn = false;
        }
    }
Exemplo n.º 30
0
    private void updateAuctionPanel()
    {
        Debug.Log("Update Auction Panel ___________________________");
        App            app         = UnityEngine.Object.FindObjectOfType <App>();
        int            playerIndex = app.GetHumanIndex();
        Nation         player      = State.getNations()[playerIndex];
        AuctionHandler auction     = State.getAuctionHandler();
        Nation         item        = State.getNations()[auction.getIndexOfCurrentItem()];

        // Debug.Log(playerIndex);
        //TextMeshProUGUI currentPlayerBid = currentBidAmount.GetComponent<TextMeshProUGUI>();
        currentBidAmount.text = auction.getPlayerBid(playerIndex).ToString();
        if (auction.getPlayerBid(playerIndex) > 0 && !auction.getIfPlayerPass(playerIndex))
        {
            decreaseBid.interactable = true;
        }
        else
        {
            decreaseBid.interactable = false;
        }

        if (player.ColonialPoints <= State.CurrentColonyAuctionBid || player.RecognizingTheseClaims.Contains(item.getIndex()) ||
            auction.getIfPlayerPass(playerIndex) || player.landForces.Strength < 2)
        {
            increaseBid.interactable = false;
        }
        else
        {
            increaseBid.interactable = true;
        }

        biddingTable.ClearRows();
        for (int i = 0; i < auction.getBiddingOrder().Count; i++)
        {
            int    currNationIndex = auction.getBiddingOrder()[i];
            Nation currNat         = State.getNations()[currNationIndex];

            TableRow newRow = Instantiate <TableRow>(biddingRow);
            newRow.gameObject.SetActive(true);
            newRow.preferredHeight = 30;
            newRow.name            = currNat.getIndex().ToString();
            biddingTable.AddRow(newRow);
            biddingConnector.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, (biddingTable.transform as RectTransform).rect.height);

            int currNatIndex = currNat.getIndex();
            //   Debug.Log("Current Nation: " + currNatIndex);
            int currentNatBid = auction.getPlayerBid(currNatIndex);

            newRow.Cells[0].GetComponentInChildren <Text>().text = currentNatBid.ToString();
            newRow.Cells[1].GetComponentInChildren <Text>().text = currNat.getNationName().ToString();
            // Transform res = newRow.Cells[2].transform.GetChild(0);

            UIObject3D flagImage = newRow.Cells[2].GetComponentInChildren <UIObject3D>();
            // flagImage.sprite = Resources.Load("Flags/" + currNat.getNationName().ToString(), typeof(Sprite)) as Sprite;
            GameObject flagPrefab = Instantiate(Resources.Load <GameObject>("Flags/Prefabs/" + currNat.getNationName()));
            flagImage.ObjectPrefab   = flagPrefab.transform;
            flagImage.RenderScale    = 0;
            flagImage.LightIntensity = 1;
            Transform statusTransform = newRow.Cells[3].transform.GetChild(0);
            Image     statusImage     = statusTransform.GetComponent <Image>();
            if (auction.getIfPlayerPass(currNatIndex) == true)
            {
                statusImage.sprite = Resources.Load("Sprites/GUI/Dark_Red_x", typeof(Sprite)) as Sprite;
            }
            else
            {
                statusImage.sprite = Resources.Load("Sprites/GUI/AuctionHammer", typeof(Sprite)) as Sprite;
            }
        }
        if (auction.getPlayerBid(playerIndex) > State.CurrentColonyAuctionBid)
        {
            bid.interactable = true;
        }
        else
        {
            bid.interactable = false;
        }
        TextMeshProUGUI passButtonText = pass.GetComponentInChildren <TextMeshProUGUI>();

        if (auction.getIfPlayerPass(playerIndex) || auction.getHighestBidderSoFar() == playerIndex)
        {
            passButtonText.SetText("Continue");
        }
        else
        {
            passButtonText.SetText("Pass");
        }
    }