示例#1
0
        public async Task <bool> Create(AuctionHouseCreateInputModel inputModel)
        {
            City cityFromDb =
                context
                .Cities
                .FirstOrDefault(city => city.Name == inputModel.City);

            if (cityFromDb == null)
            {
                throw new ArgumentNullException(nameof(cityFromDb));
            }

            AuctionHouse auctionHouse = new AuctionHouse
            {
                Name        = inputModel.Name,
                Address     = inputModel.Address,
                Description = inputModel.Description,
            };

            auctionHouse.City = cityFromDb;

            context.AuctionHouses.Add(auctionHouse);
            int result = await context
                         .SaveChangesAsync();

            return(result > 0);
        }
        public ActionResult CreateBuyer( AuctionHouse.Models.RegisterAHBuyerModel _oNewBuyer )
        {
            if (ModelState.IsValid)
            {
                try
                {
                    ActionHouseClient.Context oAHContext = new ActionHouseClient.Context(System.Configuration.ConfigurationManager.AppSettings["AHServiceAddress"]);

                    AuctionHouseModels.Buyer oAHBuyer = new AuctionHouseModels.Buyer() { Username = _oNewBuyer.UserName, Password = _oNewBuyer.Password, ContactInfo = _oNewBuyer.ContactInfo };

                    AuctionHouseModels.ResultCode oRes = oAHContext.AddBuyer(oAHBuyer);

                    // TODO encode the error
                    if (oRes.Code != 0)
                    {
                        ModelState.AddModelError(String.Empty, "Register user failed: " + oRes.Message);

                        return View();
                    }

                    // register in session
                    Session["BuyerID"] = oRes.ContextID;

                    FormsAuthentication.SetAuthCookie( _oNewBuyer.UserName, false );

                    return RedirectToAction( "Index", "Home" );
                }
                catch (Exception exc)
                {
                    ModelState.AddModelError( String.Empty, "An error occurs during the registration: " + exc.Message );
                }
            }

            return View();
        }
示例#3
0
        private static AuctionHouse CreateAuctionHouse(List <Card> cards, IEnumerable <string> playerNames)
        {
            var auctionHouse = new AuctionHouse();

            auctionHouse.Prepare(cards.Where(x => x.MinimumBid <= 15), cards.Where(x => x.MinimumBid > 15), true, playerNames.Count());
            return(auctionHouse);
        }
示例#4
0
        public ActionResult Login( AuctionHouse.Models.AHBuyer _oBuyer )
        {
            if (ModelState.IsValid)
            {
                ActionHouseClient.Context oAHContext = new ActionHouseClient.Context( System.Configuration.ConfigurationManager.AppSettings["AHServiceAddress"] );

                AuctionHouseModels.Buyer oVerifiedBuyer = oAHContext.VerifyBuyer(_oBuyer.UserName, _oBuyer.Password);

                if (oVerifiedBuyer != null)
                {
                    // register in session
                    Session["BuyerID"] = oVerifiedBuyer.ID;

                    FormsAuthentication.SetAuthCookie( _oBuyer.UserName, false );

                    return RedirectToAction( "Index", "Home" );
                }
                else
                {
                    ModelState.AddModelError( String.Empty, "Incorrect login data" );
                }
            }

            return View();
        }
示例#5
0
        private void UpdatePowerPlantMarket()
        {
            var x = AuctionHouse.FutureMarket.Last();

            AuctionHouse.ThirdStepPowerStations.Enqueue(x);
            AuctionHouse.FutureMarket.Remove(x);
            AuctionHouse.DrawPowerPlant();
        }
示例#6
0
        public static void F_AUCTION_SEARCH_QUERY(BaseClient client, PacketIn packet)
        {
            GameClient cclient = (GameClient)client;

            if (!cclient.IsPlaying() || !cclient.Plr.IsInWorld())
            {
                return;
            }

            Player plr = cclient.Plr;

            packet.Skip(3);
            byte NumOfSearches = packet.GetUint8(); // Why?

            packet.Skip(12);
            // Item Level
            byte MinLevel = packet.GetUint8();
            byte MaxLevel = packet.GetUint8();
            byte Rarity   = packet.GetUint8();
            byte career   = packet.GetUint8();

            packet.Skip(6);

            byte        NumTypes = packet.GetUint8();
            List <byte> Types    = new List <byte>();

            for (byte i = 0; i < NumTypes; i++)
            {
                Types.Add(packet.GetUint8());
            }

            byte        NumSlots = packet.GetUint8();
            List <byte> Slots    = new List <byte>();

            for (byte i = 0; i < NumSlots; i++)
            {
                Slots.Add(packet.GetUint8());
            }

            bool IsStatistic = packet.GetUint8() == 1;
            byte Stat        = 0;

            if (IsStatistic)
            {
                Stat = packet.GetUint8();
            }

            string SearchTerm = packet.GetPascalString();
            string Character  = packet.GetPascalString().Replace("^M", string.Empty).Replace("^F", string.Empty);

            AuctionHouse.SendAuctions(plr, SearchTerm, Character, MinLevel, MaxLevel, Rarity, career, Types, Slots, Stat);

            cclient.IsPlaying();
        }
示例#7
0
        public static void F_AUCTION_POST_ITEM(BaseClient client, PacketIn packet)
        {
            GameClient cclient = (GameClient)client;

            if (!cclient.IsPlaying() || !cclient.Plr.IsInWorld())
            {
                return;
            }

            Player plr = cclient.Plr;

            if (AuctionHouse.PlayerAuctionCount(plr.CharacterId) >= AuctionHouse.MAX_AUCTIONS_PER_CHAR)
            {
                plr.SendMessage("You have reached the maximum of " + AuctionHouse.MAX_AUCTIONS_PER_CHAR + " auctions.", ChatLogFilters.CHATLOGFILTERS_USER_ERROR);
                return;
            }

            ushort slot = packet.GetUint16();

            packet.Skip(2);
            uint price = packet.GetUint32();

            if (plr.ItmInterface.GetItemInSlot(slot) == null)
            {
                return;
            }

            if (plr.ItmInterface.GetItemInSlot(slot).BoundtoPlayer || plr.ItmInterface.GetItemInSlot(slot).Info.Bind == 1)
            {
                plr.SendLocalizeString(plr.ItmInterface.GetItemInSlot(slot).Info.Name, ChatLogFilters.CHATLOGFILTERS_USER_ERROR, GameData.Localized_text.TEXT_AUCTION_ITEM_IS_BOUND);
                return;
            }

            Auction auction = new Auction
            {
                Item         = plr.ItmInterface.GetItemInSlot(slot).Info,
                ItemId       = plr.ItmInterface.GetItemInSlot(slot).Info.Entry,
                _Talismans   = plr.ItmInterface.GetItemInSlot(slot).GetTalismans(),
                PrimaryDye   = plr.ItmInterface.GetItemInSlot(slot).GetPrimaryDye(),
                SecondaryDye = plr.ItmInterface.GetItemInSlot(slot).GetSecondaryDye(),
                Count        = plr.ItmInterface.GetItemInSlot(slot).Count,
                Seller       = plr.Info,
                SellerId     = plr.CharacterId,
                SellPrice    = price,
                StartTime    = (uint)TCPManager.GetTimeStamp(),
                Realm        = plr.Info.Realm,
                AuctionId    = (uint)AuctionHouse.GenerateAuctionGUID()
            };

            AuctionHouse.AddAuction(auction);
            plr.ItmInterface.DeleteItem(slot);
        }
示例#8
0
        public GameObject(int numberOfPlayers, Location location)
        {
            Round   = 2;
            Players = new List <Player>(numberOfPlayers);
            for (int i = 0; i < numberOfPlayers; i++)
            {
                var player = new Player($"Player {i}", 3);
                player.CanBuy = true;
                Players.Add(player);
            }

            AuctionHouse   = new AuctionHouse(location, numberOfPlayers);
            ResourceMarket = new ResourceMarket(location, numberOfPlayers);
            CurrentStep    = Steps.Step1;
            CurrentPhase   = Phase.AuctionPowerPlants;
        }
示例#9
0
        public static void F_AUCTION_BID_ITEM(BaseClient client, PacketIn packet)
        {
            GameClient cclient = (GameClient)client;

            if (!cclient.IsPlaying() || !cclient.Plr.IsInWorld())
            {
                return;
            }

            uint price = packet.GetUint32();

            packet.GetUint32(); // unk

            // item id
            // 10 bytes which are sent along with the item list, might be a very long number however lets take the first 8
            ulong Id = packet.GetUint64();

            packet.Skip(2);     // last byte ranges from 01 - 03? a flag?

            packet.GetUint32(); // unk

            AuctionHouse.BuyOutAuction(cclient.Plr, Id, price);
        }
示例#10
0
 private static Boolean KawigiEdit_RunTest(int testNum, string[] p0, Boolean hasAnswer, string[] p1)
 {
     Console.Write("Test " + testNum + ": [" + "{");
     for (int i = 0; p0.Length > i; ++i) {
         if (i > 0) {
             Console.Write(",");
         }
         Console.Write("\"" + p0[i] + "\"");
     }
     Console.Write("}");
     Console.WriteLine("]");
     AuctionHouse obj;
     string[] answer;
     obj = new AuctionHouse();
     DateTime startTime = DateTime.Now;
     answer = obj.getList(p0);
     DateTime endTime = DateTime.Now;
     Boolean res;
     res = true;
     Console.WriteLine("Time: " + (endTime - startTime).TotalSeconds + " seconds");
     if (hasAnswer) {
         Console.WriteLine("Desired answer:");
         Console.Write("\t" + "{");
         for (int i = 0; p1.Length > i; ++i) {
             if (i > 0) {
                 Console.Write(",");
             }
             Console.Write("\"" + p1[i] + "\"");
         }
         Console.WriteLine("}");
     }
     Console.WriteLine("Your answer:");
     Console.Write("\t" + "{");
     for (int i = 0; answer.Length > i; ++i) {
         if (i > 0) {
             Console.Write(",");
         }
         Console.Write("\"" + answer[i] + "\"");
     }
     Console.WriteLine("}");
     if (hasAnswer) {
         if (answer.Length != p1.Length) {
             res = false;
         } else {
             for (int i = 0; answer.Length > i; ++i) {
                 if (answer[i] != p1[i]) {
                     res = false;
                 }
             }
         }
     }
     if (!res) {
         Console.WriteLine("DOESN'T MATCH!!!!");
     } else if ((endTime - startTime).TotalSeconds >= 2) {
         Console.WriteLine("FAIL the timeout");
         res = false;
     } else if (hasAnswer) {
         Console.WriteLine("Match :-)");
     } else {
         Console.WriteLine("OK, but is it right?");
     }
     Console.WriteLine("");
     return res;
 }