public async Task Update(string id, Craftsman craftsman) { var content = new StringContent(JsonConvert.SerializeObject(craftsman), Encoding.UTF8, "application/json"); var response = await _client.PutAsync("", content); response.EnsureSuccessStatusCode(); }
public async Task <IActionResult> PutCraftsman(long id, Craftsman craftsman) { if (id != craftsman.Id) { return(BadRequest()); } _context.Entry(craftsman).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CraftsmanExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public void Setup() { craftsman = new Craftsman(); npc = new Mock <INonPlayerCharacter>(); pc = new Mock <IPlayerCharacter>(); Mock <IDefaultValues> defaultValues = new Mock <IDefaultValues>(); Mock <IMoneyToCoins> moneyToCoins = new Mock <IMoneyToCoins>(); Mock <ITagWrapper> tagWrapper = new Mock <ITagWrapper>(); craftsmanObjects = new List <ICraftsmanObject>(); gameDateTime = new Mock <IGameDateTime>(); defaultValues.Setup(e => e.MoneyForNpcLevel(10)).Returns(1000); defaultValues.Setup(e => e.DiceForWeaponLevel(1)).Returns(new Dice(1, 2)); pc.Setup(e => e.CharismaEffective).Returns(1); pc.Setup(e => e.KeyWords).Returns(new List <string>() { "pc" }); npc.Setup(e => e.CharismaEffective).Returns(2); npc.Setup(e => e.Zone).Returns(1); npc.Setup(e => e.Id).Returns(2); pc.Setup(e => e.Money).Returns(1000); pc.Setup(e => e.CraftsmanObjects).Returns(craftsmanObjects); moneyToCoins.Setup(e => e.FormatedAsCoins(20000)).Returns("2 gold"); tagWrapper.Setup(e => e.WrapInTag("You need 2 gold to have the item made for you.", TagType.Info)).Returns("not enough money"); tagWrapper.Setup(e => e.WrapInTag("", TagType.Info)).Returns(""); gameDateTime.Setup(e => e.BuildFormatedDateTime(It.IsAny <DateTime>())).Returns("future date"); GlobalReference.GlobalValues.DefaultValues = defaultValues.Object; GlobalReference.GlobalValues.MoneyToCoins = moneyToCoins.Object; GlobalReference.GlobalValues.TagWrapper = tagWrapper.Object; GlobalReference.GlobalValues.GameDateTime = gameDateTime.Object; }
public void Setup() { GlobalReference.GlobalValues = new GlobalValues(); craftsman = new Craftsman(); npc = new Mock <INonPlayerCharacter>(); pc = new Mock <IPlayerCharacter>(); Mock <IDefaultValues> defaultValues = new Mock <IDefaultValues>(); Mock <IMoneyToCoins> moneyToCoins = new Mock <IMoneyToCoins>(); Mock <ITagWrapper> tagWrapper = new Mock <ITagWrapper>(); craftsmanObjects = new List <ICraftsmanObject>(); inGameDateTime = new Mock <IInGameDateTime>(); defaultValues.Setup(e => e.MoneyForNpcLevel(10)).Returns(1000); defaultValues.Setup(e => e.DiceForWeaponLevel(1)).Returns(new Dice(1, 2)); pc.Setup(e => e.CharismaEffective).Returns(1); pc.Setup(e => e.KeyWords).Returns(new List <string>() { "pc" }); npc.Setup(e => e.CharismaEffective).Returns(2); npc.Setup(e => e.Zone).Returns(1); npc.Setup(e => e.Id).Returns(2); pc.Setup(e => e.Money).Returns(1000); pc.Setup(e => e.CraftsmanObjects).Returns(craftsmanObjects); moneyToCoins.Setup(e => e.FormatedAsCoins(20000)).Returns("2 gold"); tagWrapper.Setup(e => e.WrapInTag(It.IsAny <string>(), TagType.Info)).Returns((string x, TagType y) => (x)); GlobalReference.GlobalValues.DefaultValues = defaultValues.Object; GlobalReference.GlobalValues.MoneyToCoins = moneyToCoins.Object; GlobalReference.GlobalValues.TagWrapper = tagWrapper.Object; GlobalReference.GlobalValues.GameDateTime = inGameDateTime.Object; }
public async Task <ActionResult <Craftsman> > PostCraftsman([FromBody] Craftsman craftsman) { context.Add(craftsman); await context.SaveChangesAsync(); return(CreatedAtAction(nameof(PostCraftsman), new { id = craftsman.Id }, craftsman)); }
private void initBehaviourModel(string prof) { switch (prof) { case "craftsman": Behaviour = new Craftsman(this, ProfLevels[prof]); break; case "farmer": Behaviour = new Farmer(this, ProfLevels[prof]); break; case "guardian": Behaviour = new Guardian(this, ProfLevels[prof]); break; case "thief": Behaviour = new Thief(this, ProfLevels[prof]); break; case "trader": Behaviour = new Trader(this, ProfLevels[prof]); break; default: throw new Exception("Wrong proffession"); } Log.Add("citizens:Human " + Name + " behaviour: " + prof); }
public async Task <ActionResult <Craftsman> > PostCraftsman(Craftsman craftsman) { _context.Craftsmen.Add(craftsman); await _context.SaveChangesAsync(); return(CreatedAtAction("GetCraftsman", new { id = craftsman.Id }, craftsman)); }
public ActionResult DeleteConfirmed(int id) { Craftsman craftsman = db.Craftsmen.Find(id); db.Craftsmen.Remove(craftsman); db.SaveChanges(); return(RedirectToAction("Index")); }
public virtual bool Scissor(Mobile from, Scissors scissors) { if (!IsChildOf(from.Backpack)) { from.SendLocalizedMessage(502437); // Items you wish to cut must be in your backpack. return(false); } CraftSystem system = DefTailoring.CraftSystem; CraftItem item = system.CraftItems.SearchFor(GetType()); if (item != null && item.Resources.Count == 1 && item.Resources.GetAt(0).Amount >= 2) { try { Type resourceType = null; CraftResourceInfo info = CraftResources.GetInfo(m_Resource); if (info != null && info.ResourceTypes.Length > 0) { resourceType = info.ResourceTypes[0]; } if (resourceType == null) { resourceType = item.Resources.GetAt(0).ItemType; } Item res = (Item)Activator.CreateInstance(resourceType); int x = m_PlayerConstructed ? (item.Resources.GetAt(0).Amount / 2) : 1; if (from is Player) { Craftsman cm = Perk.GetByType <Craftsman>(from as Player); if (cm != null && cm.Savvy()) { x += Utility.RandomMinMax(1, 2); } } ScissorHelper(from, res, x); res.LootType = LootType.Regular; return(true); } catch { } } from.SendLocalizedMessage(502440); // Scissors can not be used on that to produce anything. return(false); }
public async Task Insert(Craftsman craftsman) { var request = new HttpRequestMessage(HttpMethod.Post, ""); var content = new StringContent(JsonConvert.SerializeObject(craftsman), Encoding.UTF8, "application/json"); request.Content = content; var response = await _client.SendAsync(request); response.EnsureSuccessStatusCode(); }
public ActionResult Create([Bind(Include = "id,Name,Surname,Description,Address")] Craftsman craftsman) { if (ModelState.IsValid) { db.Craftsmen.Add(craftsman); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(craftsman)); }
public async Task <Craftsman> Create(Craftsman value) { var craftsman = await _craftsmenCollection.FindAsync(cm => cm.CraftsmanId == value.CraftsmanId).Result.FirstOrDefaultAsync(); if (craftsman != null) { throw new Exception("Craftsman already exists"); } await _craftsmenCollection.InsertOneAsync(value); return(value); }
public async Task <Craftsman> Post([FromBody] Craftsman craftsman) { try { return(await _craftsmanService.Create(craftsman)); } catch (Exception ex) { Console.WriteLine(ex.Message); } return(craftsman); }
public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Craftsman craftsman = db.Craftsmen.Find(id); if (craftsman == null) { return(HttpNotFound()); } return(View(craftsman)); }
public async Task <IActionResult> OnGetAsync(string id) { if (id == null) { return(NotFound()); } Craftsman = await _client.Get(id); if (Craftsman == null) { return(NotFound()); } return(Page()); }
public async Task <IActionResult> OnPostAsync(string id) { if (id == null) { return(NotFound()); } Craftsman = await _client.Get(id); if (Craftsman != null) { await _client.Delete(id); } return(RedirectToPage("./Index")); }
public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Craftsman craftsman = db.Craftsmen.Find(id); if (craftsman == null) { return(HttpNotFound()); } var result = from g in db.Guitars select new { g.id, g.Name, Checked = ((from gTOc in db.GuitarToCraftsmen where (gTOc.CraftsmanID == id) && (gTOc.GuitarID == g.id) select gTOc).Count() > 0 ) }; var myViewModel = new CraftsmenViewModel(); myViewModel.CrafrsmanID = id.Value; myViewModel.Name = craftsman.Name; myViewModel.Surname = craftsman.Surname; myViewModel.Description = craftsman.Description; myViewModel.Address = craftsman.Address; var CheckBoxList = new List <CheckboxViewModel>(); foreach (var item in result) { CheckBoxList.Add(new CheckboxViewModel { id = item.id, Name = item.Name, Checked = item.Checked }); } myViewModel.Guitars = CheckBoxList; return(View(myViewModel)); }
public BuyForm() { InitializeComponent(); log = new NoOpLogger(); touch = new Touch(log); captureScreen = new CaptureScreen(new NoOpLogger(), touch); resourceReader = new CommerceResourceReader(log, touch); buildingSelector = new BuildingSelector(log, touch); tradeWindow = new TradeWindow(captureScreen, log); tradePanelCapture = new TradePanelCapture(tradeWindow); navigateToBuilding = new NavigateToBuilding(log, touch, buildingSelector, tradeWindow); buildItemList = CommerceItemBuild.CreateResourceList(); tradeWindow.PictureBox = this.pictureBox1; var pictureBoxes = new List <PictureBox>(); var textBoxes = new List <TextBox>(); pictureBoxes.Add(this.pb1); pictureBoxes.Add(this.pb2); pictureBoxes.Add(this.pb3); pictureBoxes.Add(this.pb4); pictureBoxes.Add(this.pb5); pictureBoxes.Add(this.pb6); pictureBoxes.Add(this.pb7); pictureBoxes.Add(this.pb8); textBoxes.Add(this.tb1); textBoxes.Add(this.tb2); textBoxes.Add(this.tb3); textBoxes.Add(this.tb4); textBoxes.Add(this.tb5); textBoxes.Add(this.tb6); textBoxes.Add(this.tb7); textBoxes.Add(this.tb8); itemHashes = new ItemHashes(pictureBoxes, textBoxes); LoadShoppingLists(); salesman = new Salesman(touch, tradeWindow, tradePanelCapture, itemHashes, navigateToBuilding, log); craftsman = new Craftsman(log, buildingSelector, navigateToBuilding, touch, resourceReader, buildItemList); }
public bool CheckSkills(Mobile from, Type typeRes, CraftSystem craftSystem, ref int quality, ref bool allRequiredSkills, bool gainSkills) { double chance = GetSuccessChance(from, typeRes, craftSystem, gainSkills, ref allRequiredSkills); if (GetExceptionalChance(craftSystem, chance, from) > Utility.RandomDouble()) { quality = 2; } if (from is Player) { Craftsman cm = Perk.GetByType <Craftsman>(from as Player); if (cm != null && cm.Master() && Utility.RandomDouble() < 0.02) { quality = 3; } } return(chance > Utility.RandomDouble()); }
public BotForm() { InitializeComponent(); log = new LogToText(this.txtLog, this); touch = new Touch(log); buildingSelector = new BuildingSelector(log, touch); captureScreen = new CaptureScreen(log); tradeWindow = new TradeWindow(captureScreen, log); navigateToBuilding = new NavigateToBuilding(log, touch, buildingSelector, tradeWindow); resourceReader = new CommerceResourceReader(log, touch); buildItemList = CommerceItemBuild.CreateResourceList(); tradePanelCapture = new TradePanelCapture(tradeWindow); itemHashes = new ItemHashes(new List <PictureBox>(), new List <TextBox>()); itemHashes.ReadHashes(); salesman = new Salesman(touch, tradeWindow, tradePanelCapture, itemHashes, navigateToBuilding, log); craftsman = new Craftsman(log, buildingSelector, navigateToBuilding, touch, resourceReader, buildItemList); }
public async Task <IActionResult> PutCraftsman(int id, [FromBody] Craftsman craftsman) { var dbCraftsman = await context.Craftsmen.FindAsync(id); if (dbCraftsman == null) { return(NotFound()); } context.Attach(dbCraftsman); dbCraftsman.FirstName = craftsman.FirstName ?? dbCraftsman.FirstName; dbCraftsman.LastName = craftsman.LastName ?? dbCraftsman.LastName; dbCraftsman.Toolboxes = craftsman.Toolboxes ?? dbCraftsman.Toolboxes; dbCraftsman.WorkField = craftsman.WorkField ?? dbCraftsman.WorkField; dbCraftsman.EmploymentDate = craftsman.EmploymentDate != null ? craftsman.EmploymentDate : dbCraftsman.EmploymentDate; await context.SaveChangesAsync(); return(NoContent()); }
public MainWindow() { Craftsman = new Craftsman() { Age = 10, Name = "Woody", LastName = "Woodpecker", PicturePath = "Images/Woody.jfif" }; Craftsmen = new ObservableCollection <Craftsman>() { new Craftsman() { Age = 10, LastName = "Woodpecker", Name = "Woody", PicturePath = "Images/Woody.jfif" }, new Craftsman() { Age = 12, LastName = "Woodpecker2", Name = "Woody2", PicturePath = "Images/Woody2.jiff" }, }; InitializeComponent(); }
public DataSeeder(string connectionString) { _connectionstring = connectionString; _client = new MongoClient(_connectionstring); _db = _client.GetDatabase("CraftsmanDb"); _db.DropCollectionAsync("Craftsmen"); _db.DropCollectionAsync("Toolboxes"); _db.DropCollectionAsync("Tools"); _db.CreateCollectionAsync("Craftsmen"); _db.CreateCollectionAsync("ToolBoxes"); _db.CreateCollectionAsync("Tools"); _craftsmanCollection = _db.GetCollection <Craftsman>("Craftsmen"); _toolboxCollection = _db.GetCollection <Toolbox>("Toolboxes"); _toolCollection = _db.GetCollection <Tool>("Tools"); // Dataseeding var hammer = new Tool() { ToolId = "5cdd705eace4a36e8c3ca1C1", Purchased = DateTime.Today, Color = "Black", Brand = "M.C.", Model = "Hammer", SerialNumber = "4CE0460D0F", ToolBoxId = "5cdd705eace4a36e8c3ca1B1", OwnerId = "5cdd705eace4a36e8c3ca1A1" }; var screwdriver = new Tool() { ToolId = "5cdd705eace4a36e8c3ca1C2", Purchased = DateTime.Today, Brand = "Tools 'r' us", Color = "White", Model = "Flathead screwdriver", SerialNumber = "4CE0460D0M", ToolBoxId = "5cdd705eace4a36e8c3ca1B1", OwnerId = "5cdd705eace4a36e8c3ca1A1" }; var toolbox1 = new Toolbox() { ToolboxId = "5cdd705eace4a36e8c3ca1B1", Purchased = DateTime.Today, Brand = "Black & Decker", Model = "Deluxe", SerialNumber = "4CE0460D0H", Type = "Ze best", Tools = new List <Tool> { hammer, screwdriver }, OwnerId = "5cdd705eace4a36e8c3ca1A1" }; var henry = new Craftsman() { CraftsmanId = "5cdd705eace4a36e8c3ca1A1", Firstname = "Henry", Surname = "Jensen", EmploymentDate = DateTime.Today, SubjectArea = "Carpenter", ToolBoxes = new List <Toolbox> { toolbox1 } }; _toolboxCollection.InsertOneAsync(toolbox1); _craftsmanCollection.InsertOneAsync(henry); _toolCollection.InsertMany(new [] { hammer, screwdriver }); }
private SmeltResult Resmelt(Mobile from, Item item, CraftResource resource) { try { if (CraftResources.GetType(resource) != CraftResourceType.Metal) { return(SmeltResult.Invalid); } CraftResourceInfo info = CraftResources.GetInfo(resource); if (info == null || info.ResourceTypes.Length == 0) { return(SmeltResult.Invalid); } CraftItem craftItem = m_CraftSystem.CraftItems.SearchFor(item.GetType()); if (craftItem == null || craftItem.Resources.Count == 0) { return(SmeltResult.Invalid); } CraftRes craftResource = craftItem.Resources.GetAt(0); if (craftResource.Amount < 2) { return(SmeltResult.Invalid); // Not enough metal to resmelt } double difficulty = 0.0; switch (resource) { case CraftResource.DullCopper: difficulty = 65.0; break; case CraftResource.ShadowIron: difficulty = 70.0; break; case CraftResource.Copper: difficulty = 75.0; break; case CraftResource.Bronze: difficulty = 80.0; break; case CraftResource.Gold: difficulty = 85.0; break; case CraftResource.Agapite: difficulty = 90.0; break; case CraftResource.Verite: difficulty = 95.0; break; case CraftResource.Valorite: difficulty = 99.0; break; } if (difficulty > from.Skills[SkillName.Mining].Value) { return(SmeltResult.NoSkill); } Type resourceType = info.ResourceTypes[0]; Item ingot = (Item)Activator.CreateInstance(resourceType); if (item is DragonBardingDeed || (item is BaseArmor && ((BaseArmor)item).PlayerConstructed) || (item is BaseWeapon && ((BaseWeapon)item).PlayerConstructed) || (item is BaseClothing && ((BaseClothing)item).PlayerConstructed)) { ingot.Amount = craftResource.Amount / 2; } else { ingot.Amount = 1; } item.Delete(); if (from is Player) { Craftsman cm = Perk.GetByType <Craftsman>(from as Player); if (cm != null && cm.Savvy()) { ingot.Amount += Utility.RandomMinMax(1, 2); } } from.AddToBackpack(ingot); from.PlaySound(0x2A); from.PlaySound(0x240); return(SmeltResult.Success); } catch { } return(SmeltResult.Invalid); }
public static void ConstructorHook(Action <Craftsman, Projectile, SpeculativeRigidbody> orig, Craftsman self, Projectile proj, SpeculativeRigidbody enemy) { orig(self, proj, enemy); bool hasSynergy = false; List <int> OptionalItemIDs = new List <int> { 66, 201, 644 }; foreach (PlayerItem active in (self.GetComponent <Gun>().CurrentOwner as PlayerController).activeItems) { if (OptionalItemIDs.Contains(active.PickupObjectId)) { hasSynergy = true; } } if (hasSynergy) { orig(self, proj, enemy); if (UnityEngine.Random.value < 0.05) { orig(self, proj, enemy); } } }
public async Task <Craftsman> Get(string id) { Craftsman cm = await _craftsmanService.Get(id); return(cm); }
public bool ConsumeRes(Mobile from, Type typeRes, CraftSystem craftSystem, ref int resHue, ref int maxAmount, ConsumeType consumeType, ref object message, bool isFailure) { Container ourPack = from.Backpack; if (ourPack == null) { return(false); } if (m_NeedHeat && !Find(from, m_HeatSources)) { message = 1044487; // You must be near a fire source to cook. return(false); } if (m_NeedOven && !Find(from, m_Ovens)) { message = 1044493; // You must be near an oven to bake that. return(false); } if (m_NeedMill && !Find(from, m_Mills)) { message = 1044491; // You must be near a flour mill to do that. return(false); } Type[][] types = new Type[m_arCraftRes.Count][]; int[] amounts = new int[m_arCraftRes.Count]; maxAmount = int.MaxValue; CraftSubResCol resCol = (m_UseSubRes2 ? craftSystem.CraftSubRes2 : craftSystem.CraftSubRes); for (int i = 0; i < types.Length; ++i) { CraftRes craftRes = m_arCraftRes.GetAt(i); Type baseType = craftRes.ItemType; // Resource Mutation if ((baseType == resCol.ResType) && (typeRes != null)) { baseType = typeRes; CraftSubRes subResource = resCol.SearchFor(baseType); if (subResource != null && from.Skills[craftSystem.MainSkill].Base < subResource.RequiredSkill) { message = subResource.Message; return(false); } } // ****************** for (int j = 0; types[i] == null && j < m_TypesTable.Length; ++j) { if (m_TypesTable[j][0] == baseType) { types[i] = m_TypesTable[j]; } } if (types[i] == null) { types[i] = new Type[] { baseType } } ; amounts[i] = craftRes.Amount; // For stackable items that can ben crafted more than one at a time if (UseAllRes) { int tempAmount = ourPack.GetAmount(types[i]); tempAmount /= amounts[i]; if (tempAmount < maxAmount) { maxAmount = tempAmount; if (maxAmount == 0) { CraftRes res = m_arCraftRes.GetAt(i); if (res.MessageNumber > 0) { message = res.MessageNumber; } else if (!String.IsNullOrEmpty(res.MessageString)) { message = res.MessageString; } else { message = 502925; // You don't have the resources required to make that item. } return(false); } } } // **************************** if (isFailure && !craftSystem.ConsumeOnFailure(from, types[i][0], this)) { amounts[i] = 0; } } // We adjust the amount of each resource to consume the max posible if (UseAllRes) { for (int i = 0; i < amounts.Length; ++i) { amounts[i] *= maxAmount; } } else { maxAmount = -1; } Item consumeExtra = null; if (m_NameNumber == 1041267) { // Runebooks are a special case, they need a blank recall rune List <RecallRune> runes = ourPack.FindItemsByType <RecallRune>(); for (int i = 0; i < runes.Count; ++i) { RecallRune rune = runes[i]; if (rune != null && !rune.Marked) { consumeExtra = rune; break; } } if (consumeExtra == null) { message = 1044253; // You don't have the components needed to make that. return(false); } } int index = 0; // Consume ALL if (consumeType == ConsumeType.All) { m_ResHue = 0; m_ResAmount = 0; m_System = craftSystem; if (from is Player) { Craftsman cm = Perk.GetByType <Craftsman>(from as Player); if (cm != null && cm.Efficient()) { for (int i = 0; i < amounts.Length; i++) { //Reduce all resources used by one if result is greater than one. if (amounts[i] - 1 > 1) { amounts[i]--; } } } } if (IsQuantityType(types)) { index = ConsumeQuantity(ourPack, types, amounts); } else { index = ourPack.ConsumeTotalGrouped (types, amounts, true, new OnItemConsumed(OnResourceConsumed), new CheckItemGroup(CheckHueGrouping)); } resHue = m_ResHue; } // Consume Half ( for use all resource craft type ) else if (consumeType == ConsumeType.Half) { for (int i = 0; i < amounts.Length; i++) { amounts[i] /= 2; if (amounts[i] < 1) { amounts[i] = 1; } } m_ResHue = 0; m_ResAmount = 0; m_System = craftSystem; if (IsQuantityType(types)) { index = ConsumeQuantity(ourPack, types, amounts); } else { index = ourPack.ConsumeTotalGrouped (types, amounts, true, new OnItemConsumed(OnResourceConsumed), new CheckItemGroup(CheckHueGrouping)); } resHue = m_ResHue; } else // ConstumeType.None ( it's basicaly used to know if the crafter has enough resource before starting the process ) { index = -1; if (IsQuantityType(types)) { for (int i = 0; i < types.Length; i++) { if (GetQuantity(ourPack, types[i]) < amounts[i]) { index = i; break; } } } else { for (int i = 0; i < types.Length; i++) { if (ourPack.GetBestGroupAmount(types[i], true, new CheckItemGroup(CheckHueGrouping)) < amounts[i]) { index = i; break; } } } } if (index == -1) { if (consumeType != ConsumeType.None) { if (consumeExtra != null) { consumeExtra.Delete(); } } return(true); } else { CraftRes res = m_arCraftRes.GetAt(index); if (res.MessageNumber > 0) { message = res.MessageNumber; } else if (res.MessageString != null && res.MessageString != String.Empty) { message = res.MessageString; } else { message = 502925; // You don't have the resources required to make that item. } return(false); } }
public void CompleteCraft(int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool, CustomCraft customCraft) { int badCraft = craftSystem.CanCraft(from, tool, m_Type); if (badCraft > 0) { if (tool != null && !tool.Deleted && tool.UsesRemaining > 0) { from.SendGump(new CraftGump(from, craftSystem, tool, badCraft)); } else { from.SendLocalizedMessage(badCraft); } return; } int checkResHue = 0, checkMaxAmount = 0; object checkMessage = null; // Not enough resource to craft it if (!ConsumeRes(from, typeRes, craftSystem, ref checkResHue, ref checkMaxAmount, ConsumeType.None, ref checkMessage)) { if (tool != null && !tool.Deleted && tool.UsesRemaining > 0) { from.SendGump(new CraftGump(from, craftSystem, tool, checkMessage)); } else if (checkMessage is int && (int)checkMessage > 0) { from.SendLocalizedMessage((int)checkMessage); } else if (checkMessage is string) { from.SendMessage((string)checkMessage); } return; } else if (!ConsumeAttributes(from, ref checkMessage, false)) { if (tool != null && !tool.Deleted && tool.UsesRemaining > 0) { from.SendGump(new CraftGump(from, craftSystem, tool, checkMessage)); } else if (checkMessage is int && (int)checkMessage > 0) { from.SendLocalizedMessage((int)checkMessage); } else if (checkMessage is string) { from.SendMessage((string)checkMessage); } return; } bool toolBroken = false; int ignored = 1; int endquality = 1; bool allRequiredSkills = true; if (CheckSkills(from, typeRes, craftSystem, ref ignored, ref allRequiredSkills)) { // Resource int resHue = 0; int maxAmount = 0; object message = null; // Not enough resource to craft it if (!ConsumeRes(from, typeRes, craftSystem, ref resHue, ref maxAmount, ConsumeType.All, ref message)) { if (tool != null && !tool.Deleted && tool.UsesRemaining > 0) { from.SendGump(new CraftGump(from, craftSystem, tool, message)); } else if (message is int && (int)message > 0) { from.SendLocalizedMessage((int)message); } else if (message is string) { from.SendMessage((string)message); } return; } else if (!ConsumeAttributes(from, ref message, true)) { if (tool != null && !tool.Deleted && tool.UsesRemaining > 0) { from.SendGump(new CraftGump(from, craftSystem, tool, message)); } else if (message is int && (int)message > 0) { from.SendLocalizedMessage((int)message); } else if (message is string) { from.SendMessage((string)message); } return; } tool.UsesRemaining--; if (craftSystem is DefBlacksmithy) { AncientSmithyHammer hammer = from.FindItemOnLayer(Layer.OneHanded) as AncientSmithyHammer; if (hammer != null && hammer != tool) { hammer.UsesRemaining--; if (hammer.UsesRemaining < 1) { hammer.Delete(); } } } if (tool.UsesRemaining < 1 && tool.BreakOnDepletion) { toolBroken = true; } if (toolBroken) { tool.Delete(); } int num = 0; Item item; if (customCraft != null) { item = customCraft.CompleteCraft(out num); } else if (typeof(MapItem).IsAssignableFrom(ItemType) && from.Map != Map.Felucca) { item = new IndecipherableMap(); from.SendLocalizedMessage(1070800); // The map you create becomes mysteriously indecipherable. } else { item = Activator.CreateInstance(ItemType) as Item; } if (item != null) { if (item is ICraftable) { endquality = ((ICraftable)item).OnCraft(quality, makersMark, from, craftSystem, typeRes, tool, this, resHue); } else if (item.Hue == 0) { item.Hue = resHue; } if (maxAmount > 0) { if (!item.Stackable && item is IUsesRemaining) { ((IUsesRemaining)item).UsesRemaining *= maxAmount; } else { item.Amount = maxAmount; } } if (from is Player) { Player p = from as Player; Craftsman cm = Perk.GetByType <Craftsman>(p); if (cm != null && cm.Craftsmanship()) { if (item is BaseArmor) { ((BaseArmor)item).MaxHitPoints += Utility.RandomMinMax(25, 30); ((BaseArmor)item).HitPoints = ((BaseWeapon)item).MaxHitPoints; } if (item is BaseWeapon) { ((BaseWeapon)item).MaxHitPoints += Utility.RandomMinMax(25, 30); ((BaseWeapon)item).HitPoints = ((BaseWeapon)item).MaxHitPoints; } if (item is BaseClothing) { ((BaseClothing)item).MaxHitPoints += Utility.RandomMinMax(25, 30); ((BaseClothing)item).HitPoints = ((BaseClothing)item).MaxHitPoints; } } } from.AddToBackpack(item); if (from.AccessLevel > AccessLevel.Player) { Commands.CommandLogging.WriteLine(from, "Crafting {0} with craft system {1}", Commands.CommandLogging.Format(item), craftSystem.GetType().Name); } from.PlaySound(0x57); } if (num == 0) { num = craftSystem.PlayEndingEffect(from, false, true, toolBroken, endquality, makersMark, this); } if (tool != null && !tool.Deleted && tool.UsesRemaining > 0) { from.SendGump(new CraftGump(from, craftSystem, tool, num)); } else if (num > 0) { from.SendLocalizedMessage(num); } EventDispatcher.InvokeItemCraft(new ItemCraftEventArgs((Player)from, true, this, craftSystem)); } else if (!allRequiredSkills) { if (tool != null && !tool.Deleted && tool.UsesRemaining > 0) { from.SendGump(new CraftGump(from, craftSystem, tool, 1044153)); } else { from.SendLocalizedMessage(1044153); // You don't have the required skills to attempt this item. } } else { ConsumeType consumeType = (UseAllRes ? ConsumeType.Half : ConsumeType.All); int resHue = 0; int maxAmount = 0; object message = null; // Not enough resource to craft it if (!ConsumeRes(from, typeRes, craftSystem, ref resHue, ref maxAmount, consumeType, ref message, true)) { if (tool != null && !tool.Deleted && tool.UsesRemaining > 0) { from.SendGump(new CraftGump(from, craftSystem, tool, message)); } else if (message is int && (int)message > 0) { from.SendLocalizedMessage((int)message); } else if (message is string) { from.SendMessage((string)message); } return; } tool.UsesRemaining--; if (tool.UsesRemaining < 1 && tool.BreakOnDepletion) { toolBroken = true; } if (toolBroken) { tool.Delete(); } // SkillCheck failed. int num = craftSystem.PlayEndingEffect(from, true, true, toolBroken, endquality, false, this); if (tool != null && !tool.Deleted && tool.UsesRemaining > 0) { from.SendGump(new CraftGump(from, craftSystem, tool, num)); } else if (num > 0) { from.SendLocalizedMessage(num); } EventDispatcher.InvokeItemCraft(new ItemCraftEventArgs((Player)from, false, this, craftSystem)); } }
public async Task <Craftsman> Put([FromBody] Craftsman craftsman) { return(await _craftsmanService.Update(craftsman)); }
public async Task <Craftsman> Update(Craftsman craftsman) { return(await _craftsmenCollection.FindOneAndReplaceAsync(cm => cm.CraftsmanId == craftsman.CraftsmanId, craftsman)); }