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)) { Pineapple fruit = new Pineapple(Utility.Random(m_yield + 2)); from.AddToBackpack(fruit); if (Utility.RandomDouble() <= .1) { Log logs = new Log(Utility.Random(5) + 1); from.AddToBackpack(logs); } } this.Delete(); from.SendMessage("You chop the plant up"); } else { from.SendMessage("You do not own this plant !!!"); } } else { from.SendLocalizedMessage(500446); } }
public async Task <ActionResult <IEnumerable <string> > > GetAsync() { var name = _contextAccessor.HttpContext.User.Claims.First(c => c.Type == "user_id").Value; var newPine = new Pineapple(); newPine.name = "my new pineapple"; db.Pineapples.Add(newPine); db.SaveChanges(); var role = "admin"; if (!await _roleManager.RoleExistsAsync(role)) { var create = await _roleManager.CreateAsync(new IdentityRole(role)); if (!create.Succeeded) { throw new Exception("Failed to create role"); } } ApplicationUser user = await _userManager.FindByNameAsync(name); // await _signInManager.SignInAsync(user,true); return(new string[] { user.Email, "value1", "value2" }); }
public void Test_Pineapple() { //arrange var sut = new Pineapple(); //act //assert Assert.True(sut.name.Equals("Pineapple")); }
public void Test_PineappleName() { // arrange var sut = new Pineapple(); // act var actual = sut.Name; // assert Assert.Equal("Pineapple (the best toping)", actual); }
/// <summary> /// Map DBTopping => Topping /// Uses enum to determine which topping class to return. /// </summary> /// <param name="entity"></param> /// <returns></returns> public ATopping Map(DBTopping entity) { ATopping topping = null; switch (entity.TOPPING) { case TOPPINGS.BACON: topping = new Bacon(); break; case TOPPINGS.CHICKEN: topping = new Chicken(); break; case TOPPINGS.EXTRACHEESE: topping = new ExtraCheese(); break; case TOPPINGS.GREENPEPPER: topping = new GreenPepper(); break; case TOPPINGS.HAM: topping = new Ham(); break; case TOPPINGS.NOCHEESE: topping = new NoCheese(); break; case TOPPINGS.PINEAPPLE: topping = new Pineapple(); break; case TOPPINGS.REDPEPPER: topping = new RedPepper(); break; case TOPPINGS.SAUSAGE: topping = new Sausage(); break; default: throw new ArgumentException("Topping not recognized. Topping could not be mapped properly"); } topping.ID = entity.ID; return(topping); }
public void Chop(Mobile from) { if (from.InRange(this.GetWorldLocation(), 1)) { if ((chopTimer == null) || (!chopTimer.Running)) { if ((TreeHelper.TreeOrdinance) && (from.AccessLevel == AccessLevel.Player)) { if (from.Region is Regions.GuardedRegion) { from.CriminalAction(true); } } chopTimer = new TreeHelper.ChopAction(from); Point3D pnt = this.Location; Map map = this.Map; from.Direction = from.GetDirectionTo(this); chopTimer.Start(); double lumberValue = from.Skills[SkillName.Lumberjacking].Value / 100; if ((lumberValue > .5) && (Utility.RandomDouble() <= lumberValue)) { Pineapple fruit = new Pineapple((int)Utility.Random(5) + m_yield); from.AddToBackpack(fruit); int cnt = Utility.Random((int)(lumberValue * 10) + 1); Log logs = new Log(cnt); // Fruitwood Logs ?? from.AddToBackpack(logs); FruitTreeStump i_stump = new FruitTreeStump(typeof(PineappleTree)); Timer poof = new StumpTimer(this, i_stump, from); poof.Start(); } else { from.SendLocalizedMessage(500495); // You hack at the tree for a while, but fail to produce any useable wood. } //PublicOverheadMessage( MessageType.Regular, 0x3BD, false, string.Format( "{0}", lumberValue )); } } else { from.SendLocalizedMessage(500446); // That is too far away. } }
static void Main(string[] args) { Pizza pizza = new LargePizza(); pizza = new Cheese(pizza); pizza = new Pineapple(pizza); Pizza pizza2 = new LargePizza().WithCheese().WithPineapple(); Console.WriteLine(pizza.GetDescription()); Console.WriteLine(pizza.GetPrice()); Console.WriteLine(pizza2.GetDescription()); Console.WriteLine(pizza2.GetPrice()); Console.ReadLine(); }
public override ILarge GetLarge(LargeType largeType) { switch (largeType) { case LargeType.Cabbage: ILarge cabbage = new Cabbage(); return(cabbage); case LargeType.Pineapple: ILarge pineapple = new Pineapple(); return(pineapple); case LargeType.Pumpkin: ILarge pumpkin = new Pumpkin(); return(pumpkin); } return(null); }
public void Setup() { _apple = new Apple(_symbolSettingsOptions.Value.Apple); _pineapple = new Pineapple(_symbolSettingsOptions.Value.Pineapple); _banana = new Banana(_symbolSettingsOptions.Value.Banana); _wildCard = new Wildcard(_symbolSettingsOptions.Value.WildCard); _randomSymbolGenerator = Substitute.For <IRandomSymbolGenerator>(); var slotMachineOptions = Substitute.For <IOptions <SlotMachineSettings> >(); slotMachineOptions.Value.Returns(new SlotMachineSettings() { ReelSymbolsCount = 4, ReelsCount = 3, }); var symbolsProvider = Substitute.For <ISymbolsProvider>(); _slotMachine = new SlotMachine(_randomSymbolGenerator, slotMachineOptions, symbolsProvider); }
public ActionResult AddMorePizza(string size, string name, bool?bacon, bool?bbq, bool?cheese, bool?mushroom, bool?onion, bool?pepperoni, bool?pepper, bool?pineapple, bool?sausage, bool?shrimp, int amt) { if (!string.IsNullOrEmpty(size)) { double totalCost; Pizza aPizza = null; //Switch statement for the size of the pizza switch (size) { case "Small": aPizza = new Small(); break; case "Medium": aPizza = new Medium(); break; case "Large": aPizza = new Large(); break; } //If the topping was selected then it is added to the pizza if (bacon == true) { aPizza = new Bacon(aPizza); } if (bbq == true) { aPizza = new BBQ(aPizza); } if (cheese == true) { aPizza = new ExCheese(aPizza); } if (mushroom == true) { aPizza = new Mushroom(aPizza); } if (onion == true) { aPizza = new Onion(aPizza); } if (pepperoni == true) { aPizza = new Pepperoni(aPizza); } if (pepper == true) { aPizza = new Peppers(aPizza); } if (pineapple == true) { aPizza = new Pineapple(aPizza); } if (sausage == true) { aPizza = new Sausage(aPizza); } if (shrimp == true) { aPizza = new Shrimp(aPizza); } //Created a variable to contain and manipulate the cost totalCost = aPizza.GetCost(); if (Session["cart"] == null) { List <CartItem> cart = new List <CartItem> { new CartItem { ID = 1, Pizza = aPizza, Quant = amt, ViewModel = (InfoViewModel)Session["info"] } }; Session["cart"] = cart; Session["Total"] = cart.Sum(item => item.Pizza.GetCost() * item.Quant); } else { List <CartItem> cart = (List <CartItem>)Session["cart"]; int index = IsExist(aPizza); if (index != -1) { cart[index].Quant++; } else { int currentID = cart.Count(); cart.Add(new CartItem { ID = currentID, Pizza = aPizza, Quant = amt, ViewModel = (InfoViewModel)Session["info"] }); } Session["cart"] = cart; Session["Total"] = cart.Sum(item => item.Pizza.GetCost() * item.Quant); } return(RedirectToAction("DisplayCart")); } else { if (string.IsNullOrEmpty(size)) { TempData["Amt"] = "The amount must be a number"; TempData["Size"] = "A size must be selected"; } return(View("AddMorePizzaForm")); } }
/* * public override void OnAfterDelete() * { * if (( i_trunk != null ) && ( !i_trunk.Deleted )) * i_trunk.Delete(); * * base.OnAfterDelete(); * } */ public override void OnDoubleClick(Mobile from) { if (from.Mounted && !TreeHelper.CanPickMounted) { from.SendMessage("You cannot pick fruit while mounted."); return; } /* To Kill Tree * if ( Utility.RandomDouble() <= .05 ) //.5 is 5% Chance * { * from.SendMessage( "The crop withers away." ); * if ( regrowTimer.Running ) * regrowTimer.Stop(); * * this.Delete(); * } */ if (DateTime.Now > lastpicked.AddSeconds(3)) // 3 seconds between picking { lastpicked = DateTime.Now; int lumberValue = (int)from.Skills[SkillName.Lumberjacking].Value / 20; if (from.Mounted) { ++lumberValue; } if (lumberValue < 0) //Changed lumberValue == 0 to lv < 0 { from.SendMessage("You have no idea how to pick this fruit."); return; } if (from.InRange(this.GetWorldLocation(), 2)) { if (m_yield < 1) { from.SendMessage("There is nothing here to harvest."); } else //check skill { from.Direction = from.GetDirectionTo(this); from.Animate(from.Mounted ? 26:17, 7, 1, true, false, 0); if (lumberValue < m_yield) //Changed lumberValue > to lv < 0 { lumberValue = m_yield + 1; } int pick = Utility.Random(lumberValue); if (pick == 0) { from.SendMessage("You do not manage to gather any fruit."); return; } m_yield -= pick; from.SendMessage("You pick {0} Pineapple{1}!", pick, (pick == 1 ? "" : "s")); //PublicOverheadMessage( MessageType.Regular, 0x3BD, false, string.Format( "{0}", m_yield )); Pineapple crop = new Pineapple(pick); from.AddToBackpack(crop); if (!regrowTimer.Running) { regrowTimer.Start(); } } } else { from.SendLocalizedMessage(500446); // That is too far away. } } }
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; } Pineapple crop = new Pineapple(pick); from.AddToBackpack(crop); if (!regrowTimer.Running) { regrowTimer.Start(); } } } else { from.SendMessage("You are too far away to harvest anything."); } } }
public void Idaho(Pineapple.Fargo f) { writer.WriteLine(f); writer.Close(); }
public Info(Pineapple p) { this.Info1 = p.State; this.Info2 = p.Ripe; }
public ActionResult CreatePizza(string size, string name, bool?bacon, bool?bbq, bool?cheese, bool?mushroom, bool?onion, bool?pepperoni, bool?pepper, bool?pineapple, bool?sausage, bool?shrimp, int amt, bool?deliver, InfoViewModel infoView) { bool isNum = IsNumber(amt); if (ModelState.IsValid && !string.IsNullOrEmpty(size) && isNum) { double totalCost; Pizza aPizza = null; //Switch statement for the size of the pizza switch (size) { case "Small": aPizza = new Small(); break; case "Medium": aPizza = new Medium(); break; case "Large": aPizza = new Large(); break; } //If the topping was selected then it is added to the pizza if (bacon == true) { aPizza = new Bacon(aPizza); } if (bbq == true) { aPizza = new BBQ(aPizza); } if (cheese == true) { aPizza = new ExCheese(aPizza); } if (mushroom == true) { aPizza = new Mushroom(aPizza); } if (onion == true) { aPizza = new Onion(aPizza); } if (pepperoni == true) { aPizza = new Pepperoni(aPizza); } if (pepper == true) { aPizza = new Peppers(aPizza); } if (pineapple == true) { aPizza = new Pineapple(aPizza); } if (sausage == true) { aPizza = new Sausage(aPizza); } if (shrimp == true) { aPizza = new Shrimp(aPizza); } //Created a variable to contain and manipulate the cost totalCost = aPizza.GetCost(); infoView.Delivery = deliver; if (Session["cart"] == null) { List <CartItem> cart = new List <CartItem> { new CartItem { ID = 1, Pizza = aPizza, Quant = amt, ViewModel = infoView } }; Session["info"] = infoView; Session["cart"] = cart; Session["Total"] = cart.Sum(item => item.Pizza.GetCost() * item.Quant); } else { List <CartItem> cart = (List <CartItem>)Session["cart"]; int index = IsExist(aPizza); if (index != -1) { cart[index].Quant++; } else { int currentID = cart.Count(); cart.Add(new CartItem { ID = currentID, Pizza = aPizza, Quant = amt, ViewModel = infoView }); } Session["info"] = infoView; Session["cart"] = cart; Session["Total"] = cart.Sum(item => item.Pizza.GetCost() * item.Quant); } //Method sends order to database //aConnection.InsertPizzaOrder(aPizza, totalCost, name, amt, deliver, addy, city, zip, time); //Adds everything to a ViewBag to send to confirmation page //ViewBag.APizza = aPizza; //ViewBag.Total = totalCost; //ViewBag.Name = name; //ViewBag.Amt = amt; //ViewBag.Deliver = deliver; //ViewBag.Addy = addy; //ViewBag.City = city; //ViewBag.Zip = zip; //ViewBag.Time = time; return(RedirectToAction("DisplayCart")); } else { if (string.IsNullOrEmpty(size)) { TempData["Amt"] = "The amount must be a number"; TempData["Size"] = "A size must be selected"; } return(View("CreatePizzaForm", infoView)); } }
static void Main(string[] args) { // now it works Pineapple pineapple = new Pineapple(); var pineappleClone = pineapple.Given(new ActionElement <Button>(new Button())); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddDbContext <ApplicationDbContext>(options => options.UseSqlServer( Configuration.GetConnectionString("DefaultConnection"))); // this is for DI purposes services.TryAddSingleton <IHttpContextAccessor, HttpContextAccessor>(); services // .AddAuthentication(JwtBearerDefaults.AuthenticationScheme) .AddAuthentication(cfg => { cfg.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; cfg.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; }) .AddJwtBearer(options => { options.Authority = "https://securetoken.google.com/abtestinghost"; options.TokenValidationParameters = new TokenValidationParameters { ValidateIssuer = true, ValidIssuer = "https://securetoken.google.com/abtestinghost", ValidateAudience = true, ValidAudience = "abtestinghost", ValidateLifetime = true }; options.Events = new JwtBearerEvents { OnTokenValidated = async ctx => { // grabs the unique id from firebase var name = ctx.Principal.Claims.First(c => c.Type == "user_id").Value; //Get userManager out of DI var _userManager = ctx.HttpContext.RequestServices.GetRequiredService <UserManager <ApplicationUser> >(); // retrieves the roles that the user has ApplicationUser user = await _userManager.FindByNameAsync(name); if (user == null) { user = new ApplicationUser(name); user.Email = "*****@*****.**"; user.customField = "haha"; var newPineapple = new Pineapple() { name = "random name of things " + name }; user.Pineapples = new List <Pineapple>(); user.Pineapples.Add(newPineapple); var result = await _userManager.CreateAsync(user); var roleResult = await _userManager.AddToRoleAsync(user, "admin"); } var userRoles = await _userManager.GetRolesAsync(user); // adds the role as a new claim ClaimsIdentity identity = ctx.Principal.Identity as ClaimsIdentity; if (identity != null) { foreach (var role in userRoles) { identity.AddClaim(new System.Security.Claims.Claim(ClaimTypes.Role, role)); } } } }; }); services.AddIdentityCore <ApplicationUser>() .AddRoles <IdentityRole>() .AddEntityFrameworkStores <ApplicationDbContext>(); services.TryAddScoped <SignInManager <ApplicationUser> >(); services.AddSingleton <IDocumentExecuter, DocumentExecuter>(); services.AddSingleton <BaseGraphQLQuery>(); services.AddSingleton <GraphQLQuery>(); services.AddSingleton <GraphQLSchema>(); services.AddSingleton <GraphQLMutation>(); services.AddSingleton <PineappleType>(); services.AddSingleton <PineappleInputType>(); services.AddSingleton <ApplicationUserType>(); var sp = services.BuildServiceProvider(); services.AddSingleton <ISchema>(new GraphQLSchema(new FuncDependencyResolver(type => sp.GetService(type)))); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); services.AddCors(options => options.AddPolicy("AllowAll", p => p.AllowAnyOrigin() .AllowAnyMethod() .AllowAnyHeader())); }