Пример #1
0
 private bool CheckToTip(BuyResponse buy, SellResponse sell)
 {
     if (null != buy)
     {
         return(buy.Success);
     }
     if (null != sell)
     {
         return(sell.Success);
     }
     return(false);
 }
Пример #2
0
    public void OnSellResponse(SellResponse resp)
    {
        m_iSaleId = resp.SaleId;

        WindowManager.Instance.OpenWindow(WindowID.MsgTreeSell);
        if (CheckToTip(null, resp))
        {
            ChangeMTStatus(MTStatus.Sell);
        }
        else
        {
            // show tip
            TipManager.Instance.Alert("当前图纸不可出售");
        }
    }
Пример #3
0
        public static SellResponse BuildSellResponse(byte[] source)
        {
            var sourceString = Encoding.Default.GetString(source);

            var retVal = new SellResponse();

            retVal.HostCode = sourceString.Substring(5, 3);
            if (retVal.HostCode == "000")
            {
                retVal.ResponseCode    = sourceString.Substring(10, 2);
                retVal.ResponseMessage = sourceString.Substring(12, 32);
                if (retVal.ResponseCode == "00")
                {
                    retVal.AuthCode = int.Parse(sourceString.Substring(44, 6));
                }

                retVal.VoucherCode  = int.Parse(sourceString.Substring(50, 7));
                retVal.BatchNumber  = int.Parse(sourceString.Substring(57, 3));
                retVal.CustomerName = sourceString.Substring(60, 26).Trim();
                retVal.CardLast4    = int.Parse(sourceString.Substring(86, 4));
                retVal.CardFirst6   = int.Parse(sourceString.Substring(90, 6));

                var dateString = sourceString.Substring(96, 10);
                var timeString = sourceString.Substring(106, 8);

                retVal.TransactionDate = new DateTime(
                    int.Parse(dateString.Substring(6, 4)),
                    int.Parse(dateString.Substring(3, 2)),
                    int.Parse(dateString.Substring(0, 2)),
                    int.Parse(timeString.Substring(0, 2)),
                    int.Parse(timeString.Substring(3, 2)),
                    int.Parse(timeString.Substring(6, 2))
                    );
                retVal.TerminalId = int.Parse(sourceString.Substring(114, 8));
            }
            return(retVal);
        }
Пример #4
0
        public void TestItemsSellXmlGetAttributes()
        {
            string xml =
                @"<roar tick=""135572003492"">
				<items>
					<sell status=""ok"">
						<effect>
							<costs/>
							<modifiers>
								<modifier type=""removed_items"" ikey=""talisman"" count=""34""/>
								<modifier type=""stat_change"" ikey=""premium_currency"" value=""67""/>
								<modifier type=""stat_change"" ikey=""aud"" value=""9""/>
								<modifier type=""add_xp"" value=""876""/>
								<modifier type=""add_xp"" value=""6""/>
								<modifier type=""add_item"" ikey=""talisman"" item_id=""1458454945""/>
								<modifier type=""stat_change"" ikey=""premium_currency"" value=""88""/>
								<modifier type=""add_xp"" value=""66""/>
								<modifier type=""add_xp"" value=""77""/>
							</modifiers>
						</effect>
						<item id=""275012935"" ikey=""ring"" count=""1"" label=""Ring"" type=""item"" description=""Magic ring for protection and strength"" consumable=""true"" sellable=""true"">
							<stats>
								<equip_attribute ikey=""premium_currency"" value=""67""/>
								<collect_stat ikey=""premium_currency"" value=""45"" every=""600000"" window=""234"" collect_at=""0""/>
								<regen_stat_limited ikey=""premium_currency"" value=""345"" repeat=""12"" times_used=""0""/>
								<regen_stat ikey=""premium_currency"" value=""44"" every=""600000""/>
								<grant_stat ikey=""premium_currency"" value=""566""/>
							</stats>
							<properties>
								<property ikey=""sonda"" value=""extra""/>
								<property ikey=""mariner"" value=""505""/>
							</properties>
							<tags>
								<tag value=""magic""/>
								<tag value=""magicitem""/>
								<tag value=""protection""/>
							</tags>
							<price>
								<remove_items/>
								<grant_stat type=""currency"" ikey=""premium_currency"" value=""67""/>
								<grant_stat_range type=""currency"" ikey=""premium_currency"" min=""8"" max=""9""/>
								<grant_xp value=""876""/>
								<grant_xp_range min=""6"" max=""7""/>
								<grant_item ikey=""talisman""/>
								<random_choice>
									<choice weight=""67"">
										<modifier>
											<grant_stat type=""currency"" ikey=""premium_currency"" value=""88""/>
										</modifier>
										<requirement>
											<true_requirement ok=""true""/>
										</requirement>
									</choice>
								</random_choice>
								<grant_xp value=""66""/>
								<if_then_else>
									<if>
										<true_requirement ok=""true""/>
									</if>
									<then>
										<grant_xp value=""77""/>
									</then>
									<else>
										<grant_xp value=""88""/>
									</else>
								</if_then_else>
							</price>
						</item>
					</sell>
				</items>
				<server>
					<item_lose item_id=""180846839"" item_ikey=""talisman""/>
					<item_add item_id=""1458454945"" item_ikey=""talisman""/>
					<item_lose item_id=""275012935"" item_ikey=""ring""/>
					<update type=""currency"" ikey=""premium_currency"" value=""32987""/>
					<update type=""xp"" ikey=""xp"" value=""16807""/>
					<inventory_changed/>
				</server>
			</roar>"            ;

            System.Xml.XmlElement nn = RoarExtensions.CreateXmlElement(xml);
            Roar.DataConversion.Responses.Items.Sell sell_parser = new Roar.DataConversion.Responses.Items.Sell();

            SellResponse response = sell_parser.Build(nn);

            Assert.IsNotNull(response.item);
            Assert.AreEqual(response.item.id, "275012935");
            Assert.AreEqual(response.item.ikey, "ring");
            Assert.AreEqual(response.item.count, 1);
            Assert.AreEqual(response.item.label, "Ring");
            Assert.AreEqual(response.item.type, "item");
            Assert.AreEqual(response.item.description, "Magic ring for protection and strength");
            Assert.IsTrue(response.item.consumable);
            Assert.IsTrue(response.item.sellable);
            Assert.AreEqual(response.item.stats.Count, 5);
            Assert.AreEqual(response.item.price.Count, 9);
            Assert.AreEqual(response.item.tags.Count, 3);

            Assert.IsNotNull(response.effect);
            Assert.AreEqual(response.effect.add_xp, 1025);
            Assert.AreEqual(response.effect.stat_change.Count, 2);
            Assert.AreEqual(response.effect.stat_change["premium_currency"], 155);
            Assert.AreEqual(response.effect.stat_change["aud"], 9);
            Assert.AreEqual(response.effect.removed_items.Count, 1);
            Assert.AreEqual(response.effect.removed_items["talisman"], 34);
            Assert.AreEqual(response.effect.add_item.Count, 1);
            Assert.AreEqual(response.effect.add_item["talisman"][0], "1458454945");
            Assert.AreEqual(response.effect.tags.Count, 0);
        }
Пример #5
0
        public void TestItemsSellXmlParseMechanics()
        {
            string xml =
                @"<roar tick=""135572003492"">
				<items>
					<sell status=""ok"">
						<effect>
							<costs/>
							<modifiers>
								<modifier type=""removed_items"" ikey=""talisman"" count=""34""/>
								<modifier type=""stat_change"" ikey=""premium_currency"" value=""67""/>
								<modifier type=""stat_change"" ikey=""premium_currency"" value=""9""/>
								<modifier type=""add_xp"" value=""876""/>
								<modifier type=""add_xp"" value=""6""/>
								<modifier type=""add_item"" ikey=""talisman"" item_id=""1458454945""/>
								<modifier type=""stat_change"" ikey=""premium_currency"" value=""88""/>
								<modifier type=""add_xp"" value=""66""/>
								<modifier type=""add_xp"" value=""77""/>
							</modifiers>
						</effect>
						<item id=""275012935"" ikey=""ring"" count=""1"" label=""Ring"" type=""item"" description=""Magic ring for protection and strength"" consumable=""true"" sellable=""true"">
							<stats>
								<equip_attribute ikey=""premium_currency"" value=""67""/>
								<collect_stat ikey=""premium_currency"" value=""45"" every=""600000"" window=""234"" collect_at=""0""/>
								<regen_stat_limited ikey=""premium_currency"" value=""345"" repeat=""12"" times_used=""0""/>
								<regen_stat ikey=""premium_currency"" value=""44"" every=""600000""/>
								<grant_stat ikey=""premium_currency"" value=""566""/>
							</stats>
							<properties>
								<property ikey=""sonda"" value=""extra""/>
								<property ikey=""mariner"" value=""505""/>
							</properties>
							<tags>
								<tag value=""magic""/>
								<tag value=""magicitem""/>
								<tag value=""protection""/>
							</tags>
							<price>
								<remove_items/>
								<grant_stat type=""currency"" ikey=""premium_currency"" value=""67""/>
								<grant_stat_range type=""currency"" ikey=""premium_currency"" min=""8"" max=""9""/>
								<grant_xp value=""876""/>
								<grant_xp_range min=""6"" max=""7""/>
								<grant_item ikey=""talisman""/>
								<random_choice>
									<choice weight=""67"">
										<modifier>
											<grant_stat type=""currency"" ikey=""premium_currency"" value=""88""/>
										</modifier>
										<requirement>
											<true_requirement ok=""true""/>
										</requirement>
									</choice>
								</random_choice>
								<grant_xp value=""66""/>
								<if_then_else>
									<if>
										<true_requirement ok=""true""/>
									</if>
									<then>
										<grant_xp value=""77""/>
									</then>
									<else>
										<grant_xp value=""88""/>
									</else>
								</if_then_else>
							</price>
						</item>
					</sell>
				</items>
				<server>
					<item_lose item_id=""180846839"" item_ikey=""talisman""/>
					<item_add item_id=""1458454945"" item_ikey=""talisman""/>
					<item_lose item_id=""275012935"" item_ikey=""ring""/>
					<update type=""currency"" ikey=""premium_currency"" value=""32987""/>
					<update type=""xp"" ikey=""xp"" value=""16807""/>
					<inventory_changed/>
				</server>
			</roar>"            ;

            Mockery mockery = new Mockery();

            Roar.DataConversion.IXCRMParser  ixcrm_parser = mockery.NewMock <Roar.DataConversion.IXCRMParser>();
            Roar.DomainObjects.InventoryItem item_data    = new Roar.DomainObjects.InventoryItem();

            System.Xml.XmlElement nn = RoarExtensions.CreateXmlElement(xml);
            Roar.DataConversion.Responses.Items.Sell sell_parser = new Roar.DataConversion.Responses.Items.Sell();
            sell_parser.ixcrm_parser = ixcrm_parser;

            Expect.Once.On(ixcrm_parser).Method("ParseItemStatList").With(nn.SelectSingleNode("./items/sell/item/stats")).Will(Return.Value(item_data.stats));
            Expect.Once.On(ixcrm_parser).Method("ParseModifierList").With(nn.SelectSingleNode("./items/sell/item/price")).Will(Return.Value(item_data.price));
            Expect.Once.On(ixcrm_parser).Method("ParseTagList").With(nn.SelectSingleNode("./items/sell/item/tags")).Will(Return.Value(item_data.tags));

            SellResponse response = sell_parser.Build(nn);

            mockery.VerifyAllExpectationsHaveBeenMet();

            Assert.IsNotNull(response.item);
            Assert.AreEqual(response.item.id, "275012935");
            Assert.AreEqual(response.item.ikey, "ring");
            Assert.AreEqual(response.item.count, 1);
            Assert.AreEqual(response.item.label, "Ring");
            Assert.AreEqual(response.item.type, "item");
            Assert.AreEqual(response.item.description, "Magic ring for protection and strength");
            Assert.IsTrue(response.item.consumable);
            Assert.IsTrue(response.item.sellable);
            Assert.AreEqual(response.item.stats, item_data.stats);
            Assert.AreEqual(response.item.price, item_data.price);
            Assert.AreEqual(response.item.tags, item_data.tags);
        }