public void Chop(Mobile from) { if (from.InRange(this.GetWorldLocation(), 1)) { if (from == m_sower) { from.Direction = from.GetDirectionTo(this); double lumberValue = from.Skills[SkillName.Lumberjacking].Value / 100; if ((lumberValue > .5) && (Utility.RandomDouble() <= lumberValue)) { Garlic fruit = new Garlic(Utility.Random(m_yield + 2)); from.AddToBackpack(fruit); } this.Delete(); from.SendMessage("You chop the plant up"); } else { from.SendMessage("You do not own this plant !!!"); } } else { from.SendLocalizedMessage(500446); } }
public InternalBuyInfo() { Add(new GenericBuyInfo("Bottle", typeof(Bottle), Bottle.GetSBPurchaseValue(), 200, 0xF0E, 0)); Add(new GenericBuyInfo("Mortar and Pestle", typeof(MortarPestle), MortarPestle.GetSBPurchaseValue(), 10, 0xE9B, 0)); Add(new GenericBuyInfo("Black Pearl", typeof(BlackPearl), BlackPearl.GetSBPurchaseValue(), 500, 0xF7A, 0)); Add(new GenericBuyInfo("Bloodmoss", typeof(Bloodmoss), Bloodmoss.GetSBPurchaseValue(), 500, 0xF7B, 0)); Add(new GenericBuyInfo("Mandrake Root", typeof(MandrakeRoot), MandrakeRoot.GetSBPurchaseValue(), 500, 0xF86, 0)); Add(new GenericBuyInfo("Garlic", typeof(Garlic), Garlic.GetSBPurchaseValue(), 500, 0xF84, 0)); Add(new GenericBuyInfo("Ginseng", typeof(Ginseng), Ginseng.GetSBPurchaseValue(), 500, 0xF85, 0)); Add(new GenericBuyInfo("Nightshade", typeof(Nightshade), Nightshade.GetSBPurchaseValue(), 500, 0xF88, 0)); Add(new GenericBuyInfo("Spider Silk", typeof(SpidersSilk), SpidersSilk.GetSBPurchaseValue(), 500, 0xF8D, 0)); Add(new GenericBuyInfo("Sulfurous Ash", typeof(SulfurousAsh), SulfurousAsh.GetSBPurchaseValue(), 500, 0xF8C, 0)); Add(new GenericBuyInfo("Lesser Heal Potion", typeof(LesserHealPotion), LesserHealPotion.GetSBPurchaseValue(), 50, 0xF0C, 0)); Add(new GenericBuyInfo("Lesser Cure Potion", typeof(LesserCurePotion), LesserCurePotion.GetSBPurchaseValue(), 50, 0xF07, 0)); Add(new GenericBuyInfo("Refresh Potion", typeof(RefreshPotion), RefreshPotion.GetSBPurchaseValue(), 50, 0xF0B, 0)); Add(new GenericBuyInfo("Agility Potion", typeof(AgilityPotion), AgilityPotion.GetSBPurchaseValue(), 50, 0xF08, 0)); Add(new GenericBuyInfo("Strength Potion", typeof(StrengthPotion), StrengthPotion.GetSBPurchaseValue(), 50, 0xF09, 0)); Add(new GenericBuyInfo("Lesser Magic Resist Potion", typeof(LesserMagicResistPotion), LesserMagicResistPotion.GetSBPurchaseValue(), 10, 0xF06, 0)); Add(new GenericBuyInfo("Lesser Poison Potion", typeof(LesserPoisonPotion), LesserPoisonPotion.GetSBPurchaseValue(), 50, 0xF0A, 0)); Add(new GenericBuyInfo("Lesser Explosion Potion", typeof(LesserExplosionPotion), LesserExplosionPotion.GetSBPurchaseValue(), 50, 0xF0D, 0)); Add(new GenericBuyInfo("Hair Dye", typeof(HairDye), HairDye.GetSBPurchaseValue(), 10, 0xEFF, 0)); }
public InternalSellInfo() { Add(typeof(Bottle), Bottle.GetSBSellValue()); Add(typeof(MortarPestle), MortarPestle.GetSBSellValue()); Add(typeof(BlackPearl), BlackPearl.GetSBSellValue()); Add(typeof(Bloodmoss), Bloodmoss.GetSBSellValue()); Add(typeof(MandrakeRoot), MandrakeRoot.GetSBSellValue()); Add(typeof(Garlic), Garlic.GetSBSellValue()); Add(typeof(Ginseng), Ginseng.GetSBSellValue()); Add(typeof(Nightshade), Nightshade.GetSBSellValue()); Add(typeof(SpidersSilk), SpidersSilk.GetSBSellValue()); Add(typeof(SulfurousAsh), SulfurousAsh.GetSBSellValue()); Add(typeof(LesserMagicResistPotion), LesserMagicResistPotion.GetSBSellValue()); Add(typeof(AgilityPotion), AgilityPotion.GetSBSellValue()); Add(typeof(StrengthPotion), StrengthPotion.GetSBSellValue()); Add(typeof(RefreshPotion), RefreshPotion.GetSBSellValue()); Add(typeof(LesserCurePotion), LesserCurePotion.GetSBSellValue()); Add(typeof(LesserHealPotion), LesserHealPotion.GetSBSellValue()); Add(typeof(LesserPoisonPotion), LesserPoisonPotion.GetSBSellValue()); Add(typeof(LesserExplosionPotion), LesserExplosionPotion.GetSBSellValue()); Add(typeof(HairDye), HairDye.GetSBSellValue()); }
GarlicCreationInfo UseExistingSessionTags(bool explack, uint trackingid, GarlicCloveDelivery[] cloves) { Garlic msg; DeliveryStatusMessage ackmsg = null; if (explack) { msg = AddExplAck(cloves, out ackmsg); } else { var exp = new I2PDate(DateTime.UtcNow.AddMinutes(5)); msg = new Garlic(cloves.Select(d => new GarlicClove(d, exp)).ToArray()); } #if LOG_ALL_TUNNEL_TRANSFER Logging.LogDebug(() => string.Format( "DestinationSession: Garlic generated with {0} cloves. {1} tags available.", msg.Cloves.Count, SessionTags.Count)); #endif var payload = msg.ToByteArray(); var dest = new BufLen(new byte[61000]); var writer = new BufRefLen(dest, 4); // Reserve 4 bytes for GarlicMessageLength I2PSessionTag tag; lock ( SessionTags ) { var ix = BufUtils.RandomInt(SessionTags.Count); tag = SessionTags[ix]; SessionTags.RemoveAt(ix); } // Tag as header writer.Write(tag.Value); // AES block var aesstart = new BufLen(writer); var aesblock = new GarlicAESBlock(writer, null, null, new BufRefLen(payload)); var pivh = I2PHashSHA256.GetHash(tag.Value); Cipher.Init(true, SessionKey.Key.ToParametersWithIV(new BufLen(pivh, 0, 16))); Cipher.ProcessBytes(aesblock.DataBuf); var length = writer - dest; dest.PokeFlip32((uint)(length - 4), 0); return(new GarlicCreationInfo( Destination.IdentHash, cloves, new EGGarlic(new BufRefLen(dest, 0, length)), GarlicCreationInfo.KeyUsed.Aes, SessionTags.Count(), trackingid, explack ? (uint?)ackmsg.MessageId : null, LatestEGAckMessageId)); }
public Veggies[] CreateVaggies() { Veggies garlic = new Garlic(); Veggies mashroom = new Mashroom(); Veggies peeper = new RedPepper(); Veggies[] veggies = { garlic, mashroom, peeper }; return(veggies); }
public void DefaultOrganicIngredients() { //Arrange Ingredient garlic = new Garlic(null, DEFAULT_UNIT_SIZE); Ingredient oliveOil = new OliveOil(null, DEFAULT_UNIT_SIZE); //Assert Assert.IsTrue(garlic.IsOrganic); Assert.IsTrue(oliveOil.IsOrganic); }
public InternalSellInfo() { //TEST: FIX THIS !!!!! //TEST: DETERMINE SPELL SCROLL PRICES /* * Type[] types = Loot.RegularScrollTypes; * * for (int i = 0; i < types.Length; ++i) * { * Type type = types[i]; * * var ci = Server.Engines.Craft.DefInscription.CraftSystem.CraftItems.SearchFor(type); * * if (ci == null) * continue; * * var res = ci.Resources; * * int cost = 0; * * foreach (CraftRes c in ci.Resources) * cost += CostOfResource(c.ItemType); * * int level = ((i + 1) / 8) / 2; * * cost += LevelBonusFor(level); * * cost *= 3; * * int count = res.Count; * * //TEST: DETERMINE SCROLL SELL PRICES * Add(type, Math.Min(6 + ((i / 8) * 5), cost)); * } */ Add(typeof(BlackPearl), BlackPearl.GetSBSellValue()); Add(typeof(Bloodmoss), Bloodmoss.GetSBSellValue()); Add(typeof(MandrakeRoot), MandrakeRoot.GetSBSellValue()); Add(typeof(Garlic), Garlic.GetSBSellValue()); Add(typeof(Ginseng), Ginseng.GetSBSellValue()); Add(typeof(Nightshade), Nightshade.GetSBSellValue()); Add(typeof(SpidersSilk), SpidersSilk.GetSBSellValue()); Add(typeof(SulfurousAsh), SulfurousAsh.GetSBSellValue()); Add(typeof(RecallRune), RecallRune.GetSBSellValue()); Add(typeof(BlankScroll), BlankScroll.GetSBSellValue()); Add(typeof(Spellbook), Spellbook.GetSBSellValue()); Add(typeof(ScribesPen), ScribesPen.GetSBSellValue()); Add(typeof(MagicWizardsHat), MagicWizardsHat.GetSBSellValue()); }
private static void HandleGarlic(GarlicMessage garlicmsg) { try { // No sessions, just accept EG var(aesblock, sessionkey) = Garlic.EGDecryptGarlic( garlicmsg, RouterContext.Inst.PrivateKey); if (aesblock == null) { Logging.LogWarning($"Router: HandleGarlic: Failed to decrypt."); return; } var garlic = new Garlic((BufRefLen)aesblock.Payload); #if LOG_ALL_LEASE_MGMT Logging.LogDebug($"Router: HandleGarlic: {garlic}"); #endif foreach (var clove in garlic.Cloves) { try { // Only accept Local to not turn into a bot net. switch (clove.Delivery.Delivery) { case GarlicCloveDelivery.DeliveryMethod.Local: #if LOG_ALL_LEASE_MGMT Logging.LogDebug( $"Router: HandleGarlic: Delivered Local: {clove.Message}"); #endif TunnelProvider.Inst.DistributeIncomingMessage(null, clove.Message.CreateHeader16); break; default: Logging.LogDebug($"Router HandleGarlic: Dropped clove ({clove})"); break; } } catch (Exception ex) { Logging.Log("Router: HandleGarlic switch", ex); } } } catch (Exception ex) { Logging.Log("Router: HandleGarlic", ex); } }
public InternalSellInfo() { Add(typeof(Bottle), Bottle.GetSBSellValue()); Add(typeof(MortarPestle), MortarPestle.GetSBSellValue()); Add(typeof(BlackPearl), BlackPearl.GetSBSellValue()); Add(typeof(Bloodmoss), Bloodmoss.GetSBSellValue()); Add(typeof(MandrakeRoot), MandrakeRoot.GetSBSellValue()); Add(typeof(Garlic), Garlic.GetSBSellValue()); Add(typeof(Ginseng), Ginseng.GetSBSellValue()); Add(typeof(Nightshade), Nightshade.GetSBSellValue()); Add(typeof(SpidersSilk), SpidersSilk.GetSBSellValue()); Add(typeof(SulfurousAsh), SulfurousAsh.GetSBSellValue()); }
public void TestGarlicCreateMessage() { var dsm1 = new DeliveryStatusMessage(0x425c) { MessageId = 2354 }; var dsm2 = new DeliveryStatusMessage(0x425c) { MessageId = 2354 }; dsm2.Timestamp = dsm1.Timestamp; dsm2.Expiration = dsm1.Expiration; var dsm1h = dsm1.CreateHeader16; var dsm2h = dsm2.CreateHeader16; var dsm1hap = dsm1h.HeaderAndPayload; var dsm2hap = dsm2h.HeaderAndPayload; var st11 = FreenetBase64.Encode(dsm1hap); var st12 = FreenetBase64.Encode(dsm2hap); Assert.IsTrue(dsm1hap == dsm2hap); var gcd1 = new GarlicCloveDeliveryDestination( dsm1, Destination.IdentHash); var gcd2 = new GarlicCloveDeliveryDestination( dsm2, Destination.IdentHash); var gcd1ar = gcd1.ToByteArray(); var gcd2ar = gcd2.ToByteArray(); var st1 = FreenetBase64.Encode(new BufLen(gcd1ar)); var st2 = FreenetBase64.Encode(new BufLen(gcd2ar)); Assert.IsTrue(BufUtils.Equal(gcd1ar, gcd2ar)); var msg1 = new GarlicClove(gcd1); var msg2 = new GarlicClove(gcd2); var g1 = new Garlic(msg1, msg2); var g2 = new Garlic(new BufRefLen(g1.ToByteArray()).Clone()); Assert.IsTrue(BufUtils.Equal(g1.ToByteArray(), g2.ToByteArray())); }
public InternalBuyInfo() { Add(new GenericBuyInfo("Bottle", typeof(Bottle), Bottle.GetSBPurchaseValue(), 200, 0xF0E, 0)); Add(new GenericBuyInfo("Mortar and Pestle", typeof(MortarPestle), MortarPestle.GetSBPurchaseValue(), 10, 0xE9B, 0)); Add(new GenericBuyInfo("Black Pearl", typeof(BlackPearl), BlackPearl.GetSBPurchaseValue(), 500, 0xF7A, 0)); Add(new GenericBuyInfo("Bloodmoss", typeof(Bloodmoss), Bloodmoss.GetSBPurchaseValue(), 500, 0xF7B, 0)); Add(new GenericBuyInfo("Mandrake Root", typeof(MandrakeRoot), MandrakeRoot.GetSBPurchaseValue(), 500, 0xF86, 0)); Add(new GenericBuyInfo("Garlic", typeof(Garlic), Garlic.GetSBPurchaseValue(), 500, 0xF84, 0)); Add(new GenericBuyInfo("Ginseng", typeof(Ginseng), Ginseng.GetSBPurchaseValue(), 500, 0xF85, 0)); Add(new GenericBuyInfo("Nightshade", typeof(Nightshade), Nightshade.GetSBPurchaseValue(), 500, 0xF88, 0)); Add(new GenericBuyInfo("Spider Silk", typeof(SpidersSilk), SpidersSilk.GetSBPurchaseValue(), 500, 0xF8D, 0)); Add(new GenericBuyInfo("Sulfurous Ash", typeof(SulfurousAsh), SulfurousAsh.GetSBPurchaseValue(), 500, 0xF8C, 0)); }
public override bool LootItem(Mobile from) { if (Utility.RandomDouble() <= .05) { GarlicSeed item = new GarlicSeed(); from.AddToBackpack(item); from.SendMessage("You manage to gather 1 garlic seed."); } Garlic c = new Garlic(); c.ItemID = 3972; from.AddToBackpack(c); from.SendMessage("You manage to gather 1 garlic."); return(true); }
public void TestGarlicCreate() { var ls = new I2PDate(DateTime.Now + TimeSpan.FromMinutes(5)); var origmessage = new DeliveryStatusMessage(I2NPMessage.GenerateMessageId()); var bigmessage = new DataMessage(new BufLen(BufUtils.RandomBytes(14 * 1024))); var garlic = new Garlic( new GarlicClove( new GarlicCloveDeliveryLocal(origmessage), ls), new GarlicClove( new GarlicCloveDeliveryLocal(bigmessage), ls) ); var egmsg = Garlic.EGEncryptGarlic( garlic, Public, new I2PSessionKey(), null); var origegdata = I2NPMessage.Clone(egmsg); var origegdata2 = I2NPMessage.Clone(egmsg); // Decrypt var(aesblock, sessionkey1) = Garlic.EGDecryptGarlic(origegdata, Private); var newgarlic = new Garlic((BufRefLen)aesblock.Payload); var g1 = new BufLen(garlic.ToByteArray()); var g2 = new BufLen(newgarlic.ToByteArray()); Assert.IsTrue(g1 == g2); // Retrieve var(aesblock2, sessionkey2) = Garlic.RetrieveAESBlock(origegdata2, Private, null); newgarlic = new Garlic((BufRefLen)aesblock2.Payload); g1 = new BufLen(garlic.ToByteArray()); g2 = new BufLen(newgarlic.ToByteArray()); Assert.IsTrue(g1 == g2); Assert.IsTrue(sessionkey1 == sessionkey2); }
public void IsOrganicPropertyIsChangeable() { //Arrange Ingredient control = new Garlic(null, DEFAULT_UNIT_SIZE); Ingredient organic = new Garlic(null, DEFAULT_UNIT_SIZE); //Assert Assert.IsTrue(organic.IsOrganic == true); //Act organic.IsOrganic = false; //Assert Assert.AreNotEqual(control.IsOrganic, organic.IsOrganic); Assert.IsFalse(organic.IsOrganic == true); }
public void AddServingShouldIncreaseUnitSize() { //Arrange Ingredient control = new Garlic(null, DEFAULT_UNIT_SIZE); Ingredient recipe = new Garlic(null, DEFAULT_UNIT_SIZE); //Assert Assert.IsTrue(control.Units == DEFAULT_UNIT_SIZE); Assert.IsTrue(recipe.Units == DEFAULT_UNIT_SIZE); //Act recipe.addServing(DEFAULT_UNIT_SIZE); //Assert Assert.IsTrue(recipe.Units > control.Units); Assert.IsTrue(recipe.Units == (DEFAULT_UNIT_SIZE * 2)); }
public void TestEncodeDecodeAES() { var m1 = new DeliveryStatusMessage(0x4321); var m2 = new DeliveryStatusMessage(0xa3c2); var garlic = new Garlic( new GarlicClove( new GarlicCloveDeliveryDestination( m1, Destination.IdentHash)), new GarlicClove( new GarlicCloveDeliveryDestination( m2, Destination.IdentHash)) ); // No tags var sessionkey = new I2PSessionKey(); var sessiontag = new I2PSessionTag(); var cg = Garlic.AESEncryptGarlic(garlic, sessionkey, sessiontag, null); var egdata = I2NPMessage.Clone(cg); var(aesblock, sk) = Garlic.RetrieveAESBlock(egdata, Private, (t) => sessionkey); var g2 = new Garlic((BufRefLen)aesblock.Payload); Assert.IsTrue(BufUtils.Equal(garlic.ToByteArray(), g2.ToByteArray())); // With tags var tags = new List <I2PSessionTag>(); for (int i = 0; i < 30; ++i) { tags.Add(new I2PSessionTag()); } cg = Garlic.AESEncryptGarlic(garlic, sessionkey, sessiontag, null); egdata = I2NPMessage.Clone(cg); (aesblock, sk) = Garlic.RetrieveAESBlock(egdata, Private, (t) => sessionkey); g2 = new Garlic((BufRefLen)aesblock.Payload); Assert.IsTrue(BufUtils.Equal(garlic.ToByteArray(), g2.ToByteArray())); }
public void WellnessDiscountOrganicOnly() { //Arrange Ingredient organic = new Garlic(null, DEFAULT_UNIT_SIZE); Ingredient inOrganic = new Corn(null, DEFAULT_UNIT_SIZE); //Assert Assert.IsTrue(organic.IsOrganic == true); Assert.IsFalse(inOrganic.IsOrganic == true); //Act double organicDiscount = organic.getWellnessDiscount(); double inOrganicDiscount = inOrganic.getWellnessDiscount(); //Assert Assert.IsTrue(organicDiscount != 0); Assert.IsTrue(inOrganicDiscount == 0); }
private void SendLeaseSetUpdateGarlic( I2PIdentHash ffdest, I2PPublicKey pubkey, I2PLeaseSet ls, uint token) { // If greater than zero, a DeliveryStatusMessage // is requested with the Message ID set to the value of the Reply Token. // A floodfill router is also expected to flood the data to the closest floodfill peers // if the token is greater than zero. // https://geti2p.net/spec/i2np#databasestore var outtunnel = TunnelProvider.Inst.GetEstablishedOutboundTunnel(false); var replytunnel = ls.Leases.Random(); if (outtunnel is null || replytunnel is null) { Logging.LogDebug($"SendLeaseSetUpdateGarlic: " + $"outtunnel: {outtunnel}, replytunnel: {replytunnel?.TunnelGw?.Id32Short}"); return; } var ds = new DatabaseStoreMessage(ls); var delivstatus = new DeliveryStatusMessage(token); // As explained on the network database page, local LeaseSets are sent to floodfill // routers in a Database Store Message wrapped in a Garlic Message so it is not // visible to the tunnel's outbound gateway. var garlic = new Garlic( new GarlicClove( new GarlicCloveDeliveryLocal(ds)), new GarlicClove( new GarlicCloveDeliveryTunnel(delivstatus, replytunnel.TunnelGw, replytunnel.TunnelId)) ); var egmsg = Garlic.EGEncryptGarlic(garlic, pubkey, new I2PSessionKey(), null); outtunnel.Send( new TunnelMessageRouter( egmsg, ffdest)); }
public InternalBuyInfo() { //TEST: FIX THIS!!!! /* * Type[] types = Loot.RegularScrollTypes; * * //for ( int i = 0; i < types.Length; ++i ) * for ( int i = 0; i < 32; ++i ) * * { * int itemID = 0x1F2E + i; * * if ( i == 6 ) * itemID = 0x1F2D; * * else if ( i > 6 ) * --itemID; * * //TEST: DETERMINE SCROLL PRICES * Add( new GenericBuyInfo( types[i], 12 + ((i / 3) * 10), 20, itemID, 0 ) ); * } */ Add(new GenericBuyInfo("Black Pearl", typeof(BlackPearl), BlackPearl.GetSBPurchaseValue(), 500, 0xF7A, 0)); Add(new GenericBuyInfo("Bloodmoss", typeof(Bloodmoss), Bloodmoss.GetSBPurchaseValue(), 500, 0xF7B, 0)); Add(new GenericBuyInfo("Mandrake Root", typeof(MandrakeRoot), MandrakeRoot.GetSBPurchaseValue(), 500, 0xF86, 0)); Add(new GenericBuyInfo("Garlic", typeof(Garlic), Garlic.GetSBPurchaseValue(), 500, 0xF84, 0)); Add(new GenericBuyInfo("Ginseng", typeof(Ginseng), Ginseng.GetSBPurchaseValue(), 500, 0xF85, 0)); Add(new GenericBuyInfo("Nightshade", typeof(Nightshade), Nightshade.GetSBPurchaseValue(), 500, 0xF88, 0)); Add(new GenericBuyInfo("Spider Silk", typeof(SpidersSilk), SpidersSilk.GetSBPurchaseValue(), 500, 0xF8D, 0)); Add(new GenericBuyInfo("Sulfurous Ash", typeof(SulfurousAsh), SulfurousAsh.GetSBPurchaseValue(), 500, 0xF8C, 0)); Add(new GenericBuyInfo("Recall Rune", typeof(RecallRune), RecallRune.GetSBPurchaseValue(), 50, 0x1f14, 0)); Add(new GenericBuyInfo("Spellbook", typeof(Spellbook), Spellbook.GetSBPurchaseValue(), 25, 0xEFA, 0)); Add(new GenericBuyInfo("Blank Scroll", typeof(BlankScroll), BlankScroll.GetSBPurchaseValue(), 500, 0x0E34, 0)); Add(new GenericBuyInfo("Scribe's Pen", typeof(ScribesPen), ScribesPen.GetSBPurchaseValue(), 50, 0xFBF, 0)); Add(new GenericBuyInfo("Magical Wizard's Hat", typeof(MagicWizardsHat), MagicWizardsHat.GetSBPurchaseValue(), 25, 0x1718, 0)); }
private Garlic AddExplAck(GarlicCloveDelivery[] cloves, out DeliveryStatusMessage ackmsg) { var replytunnel = SelInboundTunnel(); if (replytunnel == null) { throw new FailedToConnectException("No inbound tunnels available"); } ackmsg = new DeliveryStatusMessage(I2NPHeader.GenerateMessageId()); var ackclove = new GarlicCloveDeliveryTunnel(ackmsg, replytunnel); var exp = new I2PDate(DateTime.UtcNow.AddMinutes(5)); var msg = new Garlic(cloves.Concat(new GarlicCloveDelivery[] { ackclove }).Select(d => new GarlicClove(d, exp))); #if LOG_ALL_TUNNEL_TRANSFER var ackmsgid = ackmsg.MessageId; Logging.LogDebug(() => string.Format( "DestinationSession: Added ACK message with MessageId: {0} to {1} cloves. Dest: {2}: {3}", ackmsgid, cloves.Length, replytunnel.Destination.Id32Short, replytunnel.ReceiveTunnelId)); #endif return(msg); }
public void SubtractServingCannotMakeSizeNegative() { //Arrange Ingredient aboveZero = new Lemon(null, DEFAULT_UNIT_SIZE); Ingredient atZero = new Garlic(null, DEFAULT_UNIT_SIZE); Ingredient belowZero = new Corn(null, DEFAULT_UNIT_SIZE); //Assert Assert.IsTrue(aboveZero.Units == DEFAULT_UNIT_SIZE); Assert.IsTrue(atZero.Units == DEFAULT_UNIT_SIZE); Assert.IsTrue(belowZero.Units == DEFAULT_UNIT_SIZE); //Act aboveZero.subtractServing(DEFAULT_UNIT_SIZE - 0.1); atZero.subtractServing(DEFAULT_UNIT_SIZE); belowZero.subtractServing(DEFAULT_UNIT_SIZE + 0.1); //Assert Assert.IsTrue(aboveZero.Units > 0.0); Assert.IsTrue(atZero.Units == 0.0); Assert.IsTrue(belowZero.Units >= 0.0); }
public Garlic DecryptMessage(GarlicMessage message) { var egdata = message.EGData; var(aesblock, sessionkey) = Garlic.RetrieveAESBlock( message, PrivateKey, (stag) => { return(SessionTags.TryRemove(stag, out var sessionkeyfound) ? sessionkeyfound : null); }); if (aesblock is null) { Logging.LogDebug($"{Owner} ReceivedSessions: Aes block decrypt failed."); return(null); } #if LOG_ALL_LEASE_MGMT Logging.LogDebug($"{Owner} ReceivedSessions: Working Aes block received. {SessionTags.Count()} tags available."); #endif if (sessionkey != null && aesblock.Tags.Count > 0) { #if LOG_ALL_LEASE_MGMT Logging.LogDebug($"{Owner} ReceivedSessions: {aesblock.Tags.Count} new tags received."); #endif foreach (var onetag in aesblock.Tags) { SessionTags[new I2PSessionTag(new BufRef(onetag))] = sessionkey; } } return(new Garlic((BufRefLen)aesblock.Payload)); }
private void OnTriggerEnter2D(Collider2D other) { if (other.tag == "Player") { //check for each item available and add. //itemtype references the item array found under the inventoryScript //gameobject. //check if full so we can add the items if (InventoryScript.MyInstance.MyEmptySlotCount > 0) { if (itemType == "Leaflet") { Leaflet leaflet = (Leaflet)Instantiate(InventoryScript.MyInstance.items[1]); InventoryScript.MyInstance.AddItem(leaflet); } else if (itemType == "Egg") { Egg egg = (Egg)Instantiate(InventoryScript.MyInstance.items[2]); InventoryScript.MyInstance.AddItem(egg); } else if (itemType == "Sword") { Sword sword = (Sword)Instantiate(InventoryScript.MyInstance.items[3]); InventoryScript.MyInstance.AddItem(sword); } else if (itemType == "Trident") { Trident trident = (Trident)Instantiate(InventoryScript.MyInstance.items[4]); InventoryScript.MyInstance.AddItem(trident); } else if (itemType == "Airpump") { AirPump ap = (AirPump)Instantiate(InventoryScript.MyInstance.items[5]); InventoryScript.MyInstance.AddItem(ap); } else if (itemType == "Bar") { PlatinumBar bar = (PlatinumBar)Instantiate(InventoryScript.MyInstance.items[6]); InventoryScript.MyInstance.AddItem(bar); } else if (itemType == "Knife") { Knife knife = (Knife)Instantiate(InventoryScript.MyInstance.items[7]); InventoryScript.MyInstance.AddItem(knife); } else if (itemType == "Rope") { Rope rope = (Rope)Instantiate(InventoryScript.MyInstance.items[8]); InventoryScript.MyInstance.AddItem(rope); } else if (itemType == "Skull") { Skull skull = (Skull)Instantiate(InventoryScript.MyInstance.items[9]); InventoryScript.MyInstance.AddItem(skull); } else if (itemType == "Sack") { Sack sack = (Sack)Instantiate(InventoryScript.MyInstance.items[10]); InventoryScript.MyInstance.AddItem(sack); } else if (itemType == "Lantern") { Lantern lantern = (Lantern)Instantiate(InventoryScript.MyInstance.items[11]); InventoryScript.MyInstance.AddItem(lantern); } else if (itemType == "Bottle") { Bottle bottle = (Bottle)Instantiate(InventoryScript.MyInstance.items[12]); InventoryScript.MyInstance.AddItem(bottle); } else if (itemType == "Candle") { Candle candle = (Candle)Instantiate(InventoryScript.MyInstance.items[13]); InventoryScript.MyInstance.AddItem(candle); } else if (itemType == "BlackBook") { BlkBook book = (BlkBook)Instantiate(InventoryScript.MyInstance.items[14]); InventoryScript.MyInstance.AddItem(book); } else if (itemType == "PlasticPile") { PlasticPile plastic = (PlasticPile)Instantiate(InventoryScript.MyInstance.items[15]); InventoryScript.MyInstance.AddItem(plastic); } else if (itemType == "Buoy") { Buoy buoy = (Buoy)Instantiate(InventoryScript.MyInstance.items[16]); InventoryScript.MyInstance.AddItem(buoy); } else if (itemType == "Shovel") { Shovel shovel = (Shovel)Instantiate(InventoryScript.MyInstance.items[17]); InventoryScript.MyInstance.AddItem(shovel); } else if (itemType == "Scarab") { Scarab scarab = (Scarab)Instantiate(InventoryScript.MyInstance.items[18]); InventoryScript.MyInstance.AddItem(scarab); } else if (itemType == "PotOfGold") { PotOfGold gold = (PotOfGold)Instantiate(InventoryScript.MyInstance.items[19]); InventoryScript.MyInstance.AddItem(gold); } else if (itemType == "Bracelet") { Bracelet bracelet = (Bracelet)Instantiate(InventoryScript.MyInstance.items[20]); InventoryScript.MyInstance.AddItem(bracelet); } else if (itemType == "Coal") { Coal coal = (Coal)Instantiate(InventoryScript.MyInstance.items[21]); InventoryScript.MyInstance.AddItem(coal); } else if (itemType == "Figurine") { Figurine fig = (Figurine)Instantiate(InventoryScript.MyInstance.items[22]); InventoryScript.MyInstance.AddItem(fig); } else if (itemType == "Diamond") { Diamond diamond = (Diamond)Instantiate(InventoryScript.MyInstance.items[23]); InventoryScript.MyInstance.AddItem(diamond); } else if (itemType == "Torch") { Torch torch = (Torch)Instantiate(InventoryScript.MyInstance.items[24]); InventoryScript.MyInstance.AddItem(torch); } else if (itemType == "Coins") { Coins coins = (Coins)Instantiate(InventoryScript.MyInstance.items[25]); InventoryScript.MyInstance.AddItem(coins); } else if (itemType == "Key") { Key key = (Key)Instantiate(InventoryScript.MyInstance.items[26]); InventoryScript.MyInstance.AddItem(key); } else if (itemType == "Matches") { Matches matches = (Matches)Instantiate(InventoryScript.MyInstance.items[27]); InventoryScript.MyInstance.AddItem(matches); } else if (itemType == "Wrench") { Wrench wrench = (Wrench)Instantiate(InventoryScript.MyInstance.items[28]); InventoryScript.MyInstance.AddItem(wrench); } else if (itemType == "Screwdriver") { Screwdriver sd = (Screwdriver)Instantiate(InventoryScript.MyInstance.items[29]); InventoryScript.MyInstance.AddItem(sd); } else if (itemType == "Jewels") { Jewels jewels = (Jewels)Instantiate(InventoryScript.MyInstance.items[30]); InventoryScript.MyInstance.AddItem(jewels); } else if (itemType == "Coffin") { Coffin coffin = (Coffin)Instantiate(InventoryScript.MyInstance.items[31]); InventoryScript.MyInstance.AddItem(coffin); } else if (itemType == "Chalice") { Chalice chalice = (Chalice)Instantiate(InventoryScript.MyInstance.items[32]); InventoryScript.MyInstance.AddItem(chalice); } //the following items should not be displayed in the world //but going to add just in case we revamp how these items //are obtained. else if(itemType == "Garlic") { Garlic garlic = (Garlic)Instantiate(InventoryScript.MyInstance.items[33]); InventoryScript.MyInstance.AddItem(garlic); } else if(itemType == "Sceptre") { Sceptre sep = (Sceptre)Instantiate(InventoryScript.MyInstance.items[34]); InventoryScript.MyInstance.AddItem(sep); } Destroy(gameObject); } //probably want to utilize CLI popup here else { Debug.Log("Bag full"); } } }
public override void OnDoubleClick(Mobile from) { if (m_sower == null || m_sower.Deleted) { m_sower = from; } if (from.Mounted && !CropHelper.CanWorkMounted) { from.SendMessage("You cannot harvest a crop while mounted."); return; } if (DateTime.Now > lastpicked.AddSeconds(1)) // 3 seconds between picking changed to 1 sec { lastpicked = DateTime.Now; int cookingValue = (int)from.Skills[SkillName.Cooking].Value / 20; //FUTURE add two skill checks... if (cookingValue == 0) { from.SendMessage("You have no idea how to harvest this crop."); return; } if (from.InRange(this.GetWorldLocation(), 1)) { if (m_yield < 1) { from.SendMessage("There is nothing here to harvest."); if (PlayerCanDestroy && !(m_sower.AccessLevel > AccessLevel.Counselor)) { UpRootGump g = new UpRootGump(from, this); from.SendGump(g); } } else //check skill and sower { from.Direction = from.GetDirectionTo(this); from.Animate(from.Mounted ? 29:32, 5, 1, true, false, 0); if (from == m_sower) { cookingValue *= 2; m_lastvisit = DateTime.Now; } if (cookingValue > m_yield) { cookingValue = m_yield + 1; } int pick = Utility.Random(cookingValue); if (pick == 0) { from.SendMessage("You do not manage to harvest any crops."); return; } m_yield -= pick; from.SendMessage("You harvest {0} crop{1}!", pick, (pick == 1 ? "" : "s")); //PublicOverheadMessage( MessageType.Regular, 0x3BD, false, string.Format( "{0}", m_yield )); ((Item)this).ItemID = pickedGraphic; Garlic crop = new Garlic(pick); from.AddToBackpack(crop); if (SowerPickTime != TimeSpan.Zero && m_lastvisit + SowerPickTime < DateTime.Now && !(m_sower.AccessLevel > AccessLevel.Counselor)) { this.UpRoot(from); return; } if (!regrowTimer.Running) { regrowTimer.Start(); } } } else { from.SendMessage("You are too far away to harvest anything."); } } }
public override void OnDoubleClick(Mobile from) { if (m_sower == null || m_sower.Deleted) { m_sower = from; } if (from.Mounted && !CropHelper.CanWorkMounted) { from.SendMessage(AgriTxt.CannotWorkMounted); return; } if (DateTime.Now > lastpicked.AddSeconds(3)) // 3 seconds between picking { lastpicked = DateTime.Now; int lumberValue = (int)from.Skills[SkillName.Lumberjacking].Value / 5; if (lumberValue == 0) { from.SendMessage(AgriTxt.DunnoHowTo); return; } if (from.InRange(this.GetWorldLocation(), 2)) { if (m_yield < 1) { from.SendMessage(AgriTxt.NoCrop); if (PlayerCanDestroy && !(m_sower.AccessLevel > AccessLevel.Counselor)) { UpRootGump g = new UpRootGump(from, this); from.SendGump(g); } } else //check skill and sower { from.Direction = from.GetDirectionTo(this); from.Animate(from.Mounted ? 29 : 32, 5, 1, true, false, 0); if (from == m_sower) { lumberValue *= 2; m_lastvisit = DateTime.Now; } if (lumberValue > m_yield) { lumberValue = m_yield + 1; } int pick = Utility.Random(lumberValue); if (pick == 0) { from.SendMessage(AgriTxt.ZeroPicked); return; } m_yield -= pick; from.SendMessage(AgriTxt.YouPick + " {0} gousse{1} d'ail!", pick, (pick == 1 ? "" : "s")); //PublicOverheadMessage( MessageType.Regular, 0x3BD, false, string.Format( "{0}", m_yield )); ((Item)this).ItemID = pickedGraphic; Garlic crop = new Garlic(pick); from.AddToBackpack(crop); if (SowerPickTime != TimeSpan.Zero && m_lastvisit + SowerPickTime < DateTime.Now && !(m_sower.AccessLevel > AccessLevel.Counselor)) { this.UpRoot(from); return; } if (!regrowTimer.Running) { regrowTimer.Start(); } } } else { from.SendMessage(AgriTxt.TooFar); } } }
public override void OnDoubleClick(Mobile from) { if (m_sower == null || m_sower.Deleted) { m_sower = from; } if (from != m_sower) { from.SendMessage("You do not own this plant !!!"); return; } if (from.Mounted && !CropHelper.CanWorkMounted) { from.SendMessage("You cannot harvest a crop while mounted."); return; } if (DateTime.UtcNow > lastpicked.AddSeconds(3)) { lastpicked = DateTime.UtcNow; int cookValue = (int)from.Skills[SkillName.Cooking].Value / 20; if (cookValue == 0) { from.SendMessage("You have no idea how to harvest this crop."); return; } if (from.InRange(this.GetWorldLocation(), 1)) { if (m_yield < 1) { from.SendMessage("There is nothing here to harvest."); } else { from.Direction = from.GetDirectionTo(this); from.Animate(from.Mounted ? 29:32, 5, 1, true, false, 0); m_lastvisit = DateTime.UtcNow; if (cookValue > m_yield) { cookValue = m_yield + 1; } int pick = Utility.RandomMinMax(cookValue - 4, cookValue); if (pick < 0) { pick = 0; } if (pick == 0) { from.SendMessage("You do not manage to harvest any crops."); return; } m_yield -= pick; from.SendMessage("You harvest {0} crop{1}!", pick, (pick == 1 ? "" : "s")); if (m_yield < 1) { ((Item)this).ItemID = pickedGraphic; } Garlic crop = new Garlic(pick); from.AddToBackpack(crop); if (!regrowTimer.Running) { regrowTimer.Start(); } } } else { from.SendMessage("You are too far away to harvest anything."); } } }
public override void OnDoubleClick(Mobile from) { if (m_sower == null || m_sower.Deleted) { m_sower = from; } if (from.Mounted && !CropHelper.CanWorkMounted) { from.SendMessage("You cannot gather anything while mounted."); return; } if (DateTime.Now > lastpicked.AddSeconds(3)) // 3 seconds between picking { lastpicked = DateTime.Now; int mageValue = (int)from.Skills[SkillName.Magery].Value / 10; //FUTURE add two skill checks... if (mageValue == 0) { from.SendMessage("You have no idea how to pick this."); return; } if (from.InRange(this.GetWorldLocation(), 1)) { if (m_yield < 1) { from.SendMessage("There is nothing here to harvest."); if (PlayerCanDestroy && !(m_sower.AccessLevel > AccessLevel.Counselor)) { UpRootGump g = new UpRootGump(from, this); from.SendGump(g); } } else //check skill and sower { from.Direction = from.GetDirectionTo(this); from.Animate(from.Mounted ? 29:32, 5, 1, true, false, 0); if (from == m_sower) { mageValue *= 2; m_lastvisit = DateTime.Now; } if (mageValue > m_yield) { mageValue = m_yield + 1; } int pick = Utility.Random(mageValue); if (pick == 0) { from.SendMessage("You do not manage to harvest anything."); return; } m_yield -= pick; from.SendMessage("You manage to gather {0} garlic!", pick); double chance = Utility.RandomDouble(); // chance to get a seed is 20% if (0.20 > chance) { from.AddToBackpack(new GarlicSeed(1)); from.SendMessage("You found a seed!"); } //PublicOverheadMessage( MessageType.Regular, 0x3BD, false, string.Format( "{0}", m_yield )); ((Item)this).ItemID = pickedGraphic; Garlic crop = new Garlic(pick); from.AddToBackpack(crop); chance = Utility.RandomDouble(); // chance to pull out plant is 10% if ((0.10 > chance) && !(m_sower.AccessLevel > AccessLevel.Counselor)) { from.SendMessage("You accidently uproot all of the garlic plant."); regrowTimer.Stop(); this.Delete(); return; } if (SowerPickTime != TimeSpan.Zero && m_lastvisit + SowerPickTime < DateTime.Now && !(m_sower.AccessLevel > AccessLevel.Counselor)) { this.UpRoot(from); return; } if (!regrowTimer.Running) { regrowTimer.Start(); } } } else { from.SendMessage("You are too far away to gather anything."); } } }