public IHttpActionResult PutInjury(int id, Injury injury) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != injury.Id) { return(BadRequest()); } db.Entry(injury).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!InjuryExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
private void Display(Injury injury) { DisplayCurrentData(injury); Console.WriteLine($"Location: {injury.Location}"); Console.WriteLine($"Type: {injury.Type}"); Console.WriteLine($"Cause: {injury.Cause}"); }
public void Load() { this.ResetInjuries(); int num = SaveGame.LoadIVal("InjuriesCount"); for (int i = 0; i < num; i++) { InjuryType injuryType = (InjuryType)SaveGame.LoadIVal("InjuryType" + i); InjuryPlace place = (InjuryPlace)SaveGame.LoadIVal("InjuryPlace" + i); InjuryState injuryState = (InjuryState)SaveGame.LoadIVal("InjuryState" + i); if (injuryType != InjuryType.WormHole || injuryState != InjuryState.WormInside) { BIWoundSlot woundSlot = BodyInspectionController.Get().GetWoundSlot(place, SaveGame.LoadSVal("InjurySlot" + i)); int poison_level = SaveGame.LoadIVal("InjuryPoisonLevel" + i); Injury injury = this.AddInjury(injuryType, place, woundSlot, injuryState, poison_level, null, null); if (injury != null) { if (injuryState == InjuryState.Infected) { injury.Infect(); } else if (injuryState == InjuryState.Closed) { injury.CloseWound(); } injury.Load(i); } } } }
void Update() { if (Input.anyKey) { if (treatments.ContainsKey(Input.inputString) && activeInjury != null) { activeInjury.appliedTreatment.Add(treatments[Input.inputString]); Debug.Log("Treatment used: " + treatments[Input.inputString].Name); UpdateProcedure(); } else if (activeInjuryDict.ContainsKey(Input.inputString)) { activeInjury = activeInjuryDict[Input.inputString]; lastKey = Input.inputString; select.transform.position = activeInjury.slot.pos + new Vector2(human.transform.position.x, human.transform.position.y); currentInjury.text = activeInjury.Name; Debug.Log("Active injury is set to " + activeInjury.Name); UpdateProcedure(); } } if (Input.GetKeyDown(KeyCode.Return) && activeInjury != null && activeInjuryDict.Count > 0) { fullReport.Add(new Report(activeInjury)); activeInjury.Reset(); activeInjuryDict.Remove(lastKey); RefreshInjuries(); } else if (Input.GetKeyDown(KeyCode.Return) && activeInjuryDict.Count == 0) { GenerateInjuries(); } }
private IEnumerable <Injury> GetAllInjuriesFromDatabase() { using (var connection = new SqlConnection(_connectionString)) using (var command = new SqlCommand("Injuries_GetAll", connection)) { command.CommandType = CommandType.StoredProcedure; connection.Open(); using (var reader = command.ExecuteReader()) { var injuries = new List <Injury>(); while (reader.Read()) { var injury = new Injury(); var value = reader.GetOrdinal("injuryId"); injury.InjuryId = (InjuryEnum)reader.GetInt32(value); value = reader.GetOrdinal("injuryName"); injury.Name = reader.GetString(value); value = reader.GetOrdinal("description"); injury.Description = reader.GetString(value); injuries.Add(injury); } return(injuries); } } }
public void ScenarioAddInjury(string type, string place, string state) { InjuryType injuryType = (InjuryType)Enum.Parse(typeof(InjuryType), type); InjuryPlace place2 = (InjuryPlace)Enum.Parse(typeof(InjuryPlace), place); InjuryState injuryState = (InjuryState)Enum.Parse(typeof(InjuryState), state); BIWoundSlot freeWoundSlot = this.m_BodyInspectionController.GetFreeWoundSlot(place2, injuryType); Injury injury = null; if (freeWoundSlot != null) { injury = this.AddInjury(injuryType, place2, freeWoundSlot, injuryState, 0, null); } if (injuryState != InjuryState.Open) { if (injuryState != InjuryState.Infected) { if (injuryState == InjuryState.Closed) { injury.CloseWound(); } } else { injury.Infect(); } } else { injury.OpenWound(); } }
public void RestoreState(IStateSnippet savedState) { var state = (ActiveInjurySnippet)savedState; Injury = (InjuryBase)Activator.CreateInstance(state.InjuryType); _injuryTriggerTimeInitial = state.InjuryTriggerTime; InjuryTriggerTime = state.InjuryTriggerTime; IsDiseaseProbabilityChecked = state.IsDiseaseProbabilityChecked; BodyPart = state.BodyPart; IsTreated = state.IsTreated; SetUpActiveStage(state.InjuryTriggerTime); Injury.RestoreState(state.ChildStates["Treatments"]); if (state.TreatedStageLevel.HasValue) { Invert(); } else { TreatedStage = null; } _isChainInverted = state.IsChainInverted; _isInjuryActivated = state.IsInjuryActivated; }
protected override void Add() { Injury _injury = new Injury(); PopulateEventData(_injury, "Name of injury (dog bite, broken arm, sprained ankle, etc): "); Console.Write("Where did the injury occur: "); _injury.Location = Console.ReadLine(); bool typeFound = false; do { Console.Write("What type of injury (must be Bite, Break, Bruise, Burn, Dislocation, Electrical, Fracture, Sprain, or Strain: "); _injury.Type = Console.ReadLine(); foreach (string item in Enum.GetNames(typeof(InjuryType))) { if (_injury.Type.ToLower().Equals(item.ToLower())) { typeFound = true; break; } } } while (!typeFound); Console.Write("What caused the injury (fall, vehicle accident, playing sports, etc): "); _injury.Cause = Console.ReadLine(); _ir.Add(_injury); Console.WriteLine("\nAdded new injury."); }
public void ScenarioAddInjury(string type, string place, string state) { InjuryType injuryType = (InjuryType)Enum.Parse(typeof(InjuryType), type); InjuryPlace place2 = (InjuryPlace)Enum.Parse(typeof(InjuryPlace), place); InjuryState state2 = (InjuryState)Enum.Parse(typeof(InjuryState), state); BIWoundSlot freeWoundSlot = this.m_BodyInspectionController.GetFreeWoundSlot(place2, injuryType, true); Injury injury = null; if (freeWoundSlot != null) { injury = this.AddInjury(injuryType, place2, freeWoundSlot, state2, 0, null, null); } if (injury != null) { switch (state2) { case InjuryState.Open: injury.OpenWound(); return; case InjuryState.Infected: injury.Infect(); return; case InjuryState.Closed: injury.CloseWound(); break; default: return; } } }
public ActionResult Create([Bind(Include = "InjuryID,UserID,MuscleID,JointID,InjuryDescription,BoneID")] Injury injury) { if (ModelState.IsValid) { //If user still hasn't filled up his personal info string myUserID = User.Identity.GetUserId(); if (db.EWPUsers.Where(p => p.UserID == myUserID).Count() == 0) { ViewBag.Color = "Red"; ViewBag.Message = "Please fill the User Info page first."; return(View()); } injury.UserID = User.Identity.GetUserId(); db.Injuries.Add(injury); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.BoneID = new SelectList(db.Bones, "BoneID", "Name", injury.BoneID); ViewBag.UserID = new SelectList(db.EWPUsers, "UserID", "FirstName", injury.UserID); ViewBag.JointID = new SelectList(db.Joints, "JointID", "Name", injury.JointID); ViewBag.MuscleID = new SelectList(db.Muscles, "MuscleID", "Name", injury.MuscleID); return(View(injury)); }
void GenerateInjuries() { int index = 0; if (activeInjuryDict == null) { activeInjuryDict = new Dictionary <string, Injury>(); } else { activeInjuryDict.Clear(); } foreach (Slot s in Manager.slots.Values) { int j = Random.Range(0, s.possibleInjuries.Count); Debug.Log(j + " / " + (s.possibleInjuries.Count)); Injury i = new Injury(s.possibleInjuries[j]); i.slot = s; activeInjuryDict.Add(System.Convert.ToChar(index + 110).ToString(), i); index++; } RefreshInjuries(); report.SetActive(false); }
public void Add(Object entity) { Injury record = (Injury)entity; record.Id = GetId(RecordType.Injury); _dataMgr.Add(record); }
public ActionResult DeleteConfirmed(int id) { Injury injury = db.Injuries.Find(id); db.Injuries.Remove(injury); db.SaveChanges(); return(RedirectToAction("Index")); }
protected override void Delete() { int _count = List(); int _option = GetOption("Please enter your selection: ", _count); string _id = List(_option); Injury _injury = (Injury)_ir.GetOne(_id); _ir.Remove(_injury); }
public Object GetOne(string id) { List <Injury> _list = _dataMgr.GetInjuries(); Injury _injury = (from e in _list where e.Id == id select e).Single(); return((Object)_injury); }
public ActionResult Edit([Bind(Include = "InjuryID,InjuryDescription")] Injury injury) { if (ModelState.IsValid) { db.Entry(injury).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(injury)); }
public void OpenChildrenInjuries(Injury injury) { for (int i = 0; i < this.m_Injuries.Count; i++) { if (this.m_Injuries[i].m_ParentInjury == injury) { this.m_Injuries[i].OpenWound(); } } }
public Injury(Injury i) { treatment = i.treatment; appliedTreatment = i.appliedTreatment; Name = i.Name; Id = i.Id; visual = i.visual; slot = i.slot; key = i.key; }
public IHttpActionResult GetInjury(int id) { Injury injury = db.Injuries.Find(id); if (injury == null) { return(NotFound()); } return(Ok(injury)); }
public ActionResult Create([Bind(Include = "InjuryID,InjuryDescription")] Injury injury) { if (ModelState.IsValid) { db.Injuries.Add(injury); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(injury)); }
public void Setup() { ctx = new SqlContext(); engine = new InjuryEngine(ctx); injury = new Injury() { Id = 1, PlayerId = 1, ScratchDate = new DateTime(2020, 1, 18) }; }
public void TestSaveInjuryUpdateNoId() { engine.Save(injury); Injury injury2 = new Injury() { Id = 0, PlayerId = 1, ScratchDate = new DateTime(2020, 1, 18) }; Assert.IsNull(ctx.Injuries.Where(c => c.Id == 0).FirstOrDefault()); }
public void Given_injury_is_in_list_when_AddInjury_then_Injury_is_not_duplicated() { //given var injury = new Injury() { Id = 3425, Description = "Anterior cruciate ligament" }; var target = new AccidentRecord(); target.AddInjury(injury, null); target.AddInjury(injury, null); Assert.AreEqual(1, target.AccidentRecordInjuries.Count); }
public IHttpActionResult PostInjury(Injury injury) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Injuries.Add(injury); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = injury.Id }, injury)); }
public void TestInsertInjury() { Injury injury = new Injury() { Id = 1, PlayerId = 1, ScratchDate = DateTime.Now }; repo.Insert(injury); Assert.IsTrue(ctx.Injuries.Any(c => c.Id == 1)); }
public void TestExists() { engine.Save(injury); Injury injury2 = new Injury() { Id = 0, PlayerId = 1, ScratchDate = new DateTime(2020, 1, 18) }; Assert.IsTrue(engine.Exists(injury2)); }
public IHttpActionResult AddInjury([FromBody] Injury Injury) { //Will Validate according to data annotations specified on model if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Injuries.Add(Injury); db.SaveChanges(); return(Ok(Injury.InjuryID)); }
public void TestInjuryExits() { Injury injury = new Injury() { Id = 1, PlayerId = 1, ScratchDate = new DateTime(2020, 1, 17) }; repo.Insert(injury); Assert.IsTrue(repo.Exists(injury)); }
public void Given_injury_list_is_empty_when_AddInjury_then_Injury_appears_in_list() { //given var injury = new Injury() {Id = 3425, Description = "Anterior cruciate ligament"}; var target = new AccidentRecord(); target.AddInjury(injury,null); Assert.IsTrue(target.AccidentRecordInjuries.Any(x => x.Injury.Id == injury.Id)); Assert.AreEqual(target, target.AccidentRecordInjuries.First(x => x.Injury.Id == injury.Id)); }
public IHttpActionResult DeleteInjury(int id) { Injury injury = db.Injuries.Find(id); if (injury == null) { return(NotFound()); } db.Injuries.Remove(injury); db.SaveChanges(); return(Ok(injury)); }
private void onInjurySelected(object sender, SelectedItemChangedEventArgs e) { // Ensure SelectedItem is not null. This is to make sure no action is taken when it is deselected. if (e.SelectedItem == null) { return; } // Get the selected item and cast it to injury so we can pull the id. Injury injury = (Injury)e.SelectedItem; // Switch to the Display view and pass the current injury id. Navigation.PushAsync(new Display(injury.TreatmentId)); }
// GET: Injuries/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Injury injury = db.Injuries.Find(id); if (injury == null) { return(HttpNotFound()); } return(View(injury)); }
public void Given_injury_is_in_list_when_RemoveInjury_then_Injury_removed_from_list() { //given var injury = new Injury() { Id = 3425, Description = "Anterior cruciate ligament", Deleted = false}; var injury2 = new Injury() { Id = 123124, Description = "Hip flexior", Deleted = false }; var target = new AccidentRecord(); target.AddInjury(injury, null); target.AddInjury(injury2, null); //when target.RemoveInjury(injury2, null); Assert.AreEqual(1, target.AccidentRecordInjuries.Count); Assert.IsTrue(target.AccidentRecordInjuries.All(x => x.Injury.Id != injury2.Id)); }
public void Given_injury_is_not_in_list_when_RemoveInjury_then_Injury_list_remains_the_same() { //given var injury = new Injury() { Id = 3425, Description = "Anterior cruciate ligament" }; var injury2 = new Injury() { Id = 123124, Description = "Hip flexior" }; var target = new AccidentRecord(); target.AddInjury(injury, null); target.AddInjury(injury2, null); //when target.RemoveInjury(new Injury() {Id = 124314, Description = "Test"},null); Assert.AreEqual(2, target.AccidentRecordInjuries.Count); }
public SewTarget(Mobile injured, Injury injury, HealInfo info, HealTimer timer) : base(1, true, TargetFlags.None) { m_Injured = injured; m_Injury = injury; m_Info = info; m_Timer = timer; }
public GiveInjuryTarget(Injury i) : base(20, true, TargetFlags.None) { m_Inj = i; }
public static bool MeetsRequirements(PlayerMobile healer, Mobile injured, HealInfo info, Injury injury) { HealInjuryRequirements req = HealInjuryRequirements.GetRequirements(injury); int MOE = (healer.Feats.GetFeatLevel(FeatList.Surgery) > 2 ? 1 : 0); // Margin of error from having max Surgery. if (!(info.Cut >= req.Cut - MOE && info.Cut <= req.Cut + MOE)) return false; if (!(info.Sew >= req.Sew - MOE && info.Sew <= req.Sew + MOE)) return false; if (!(info.Heat >= req.Heat - MOE && info.Heat <= req.Heat + MOE)) return false; if (!(info.Cool >= req.Cool - MOE && info.Cool <= req.Cool + MOE)) return false; if (!(info.Bleed >= req.Bleed - MOE && info.Bleed <= req.Bleed + MOE)) return false; return true; }
public HealTimer(PlayerMobile healer, Mobile injured, Injury injury, HealInfo info) : base(TimeSpan.Zero, TimeSpan.FromSeconds(1)) { m_Healer = healer; m_Injured = injured; m_Injury = injury; m_HealInfo = info; int medVal = 15; if (healer != null && !healer.Deleted & healer.Alive) { medVal += (healer.Feats.GetFeatLevel(FeatList.Medicine) * 5); medVal += (healer.Feats.GetFeatLevel(FeatList.Surgery) * 10); } if(injured != null && !injured.Deleted && injured.Alive) medVal += injured.Stam / 10; m_StartTime = DateTime.Now; m_Expiration = DateTime.Now.AddSeconds(medVal); }
public TryHealInjuryGump(PlayerMobile viewer, Mobile injured, Injury injury, HealInfo info, HealTimer timer) : base(0, 0) { m_Viewer = viewer; m_Injured = injured; m_Injury = injury; m_Info = info; m_Timer = timer; if (!m_Timer.Running) m_Timer.Start(); InitialSetup(); }
public static HealInjuryRequirements GetRequirements(Injury i) { HealInjuryRequirements reqs = new HealInjuryRequirements(); reqs.Cut = 0; reqs.Sew = 0; reqs.Cool = 0; reqs.Heat = 0; reqs.Bleed = 0; switch (i) { case Injury.Bloodied: { reqs.Cut = (int)Severity.None; reqs.Sew = (int)Severity.Minor; reqs.Cool = (int)Severity.Minor; reqs.Heat = (int)Severity.None; reqs.Bleed = (int)Severity.None; break; } case Injury.BrokenBack: { reqs.Cut = (int)Severity.Severe; reqs.Sew = (int)Severity.Critical; reqs.Cool = (int)Severity.None; reqs.Heat = (int)Severity.Moderate; reqs.Bleed = (int)Severity.Moderate; break; } case Injury.BrokenJaw: { reqs.Cut = (int)Severity.Severe; reqs.Sew = (int)Severity.Moderate; reqs.Cool = (int)Severity.None; reqs.Heat = (int)Severity.Moderate; reqs.Bleed = (int)Severity.Moderate; break; } case Injury.BrokenLeftArm: { reqs.Cut = (int)Severity.None; reqs.Sew = (int)Severity.None; reqs.Cool = (int)Severity.Moderate; reqs.Heat = (int)Severity.Moderate; reqs.Bleed = (int)Severity.Moderate; break; } case Injury.BrokenLeftLeg: { reqs.Cut = (int)Severity.None; reqs.Sew = (int)Severity.Minor; reqs.Cool = (int)Severity.Moderate; reqs.Heat = (int)Severity.Moderate; reqs.Bleed = (int)Severity.Moderate; break; } case Injury.BrokenNeck: { reqs.Cut = (int)Severity.Moderate; reqs.Sew = (int)Severity.Moderate; reqs.Cool = (int)Severity.None; reqs.Heat = (int)Severity.Moderate; reqs.Bleed = (int)Severity.Severe; break; } case Injury.BrokenRightArm: { reqs.Cut = (int)Severity.None; reqs.Sew = (int)Severity.None; reqs.Cool = (int)Severity.Moderate; reqs.Heat = (int)Severity.Moderate; reqs.Bleed = (int)Severity.Moderate; break; } case Injury.BrokenRightLeg: { reqs.Cut = (int)Severity.None; reqs.Sew = (int)Severity.Minor; reqs.Cool = (int)Severity.Moderate; reqs.Heat = (int)Severity.Moderate; reqs.Bleed = (int)Severity.Moderate; break; } case Injury.Bruised: { reqs.Cut = (int)Severity.None; reqs.Sew = (int)Severity.None; reqs.Cool = (int)Severity.Minor; reqs.Heat = (int)Severity.None; reqs.Bleed = (int)Severity.None; break; } case Injury.DeepCut: { reqs.Cut = (int)Severity.None; reqs.Sew = (int)Severity.Moderate; reqs.Cool = (int)Severity.None; reqs.Heat = (int)Severity.Minor; reqs.Bleed = (int)Severity.None; break; } case Injury.Exhausted: { reqs.Cut = (int)Severity.None; reqs.Sew = (int)Severity.None; reqs.Cool = (int)Severity.Moderate; reqs.Heat = (int)Severity.None; reqs.Bleed = (int)Severity.None; break; } case Injury.FracturedLeftArm: { reqs.Cut = (int)Severity.Minor; reqs.Sew = (int)Severity.Minor; reqs.Cool = (int)Severity.Minor; reqs.Heat = (int)Severity.Minor; reqs.Bleed = (int)Severity.None; break; } case Injury.FracturedLeftLeg: { reqs.Cut = (int)Severity.Minor; reqs.Sew = (int)Severity.Minor; reqs.Cool = (int)Severity.Minor; reqs.Heat = (int)Severity.Minor; reqs.Bleed = (int)Severity.Minor; break; } case Injury.FracturedRibs: { reqs.Cut = (int)Severity.Moderate; reqs.Sew = (int)Severity.Moderate; reqs.Cool = (int)Severity.None; reqs.Heat = (int)Severity.Moderate; reqs.Bleed = (int)Severity.None; break; } case Injury.FracturedRightArm: { reqs.Cut = (int)Severity.Minor; reqs.Sew = (int)Severity.Minor; reqs.Cool = (int)Severity.Minor; reqs.Heat = (int)Severity.Minor; reqs.Bleed = (int)Severity.None; break; } case Injury.FracturedRightLeg: { reqs.Cut = (int)Severity.Minor; reqs.Sew = (int)Severity.Minor; reqs.Cool = (int)Severity.Minor; reqs.Heat = (int)Severity.Minor; reqs.Bleed = (int)Severity.Minor; break; } case Injury.FracturedSkull: { reqs.Cut = (int)Severity.Moderate; reqs.Sew = (int)Severity.Minor; reqs.Cool = (int)Severity.None; reqs.Heat = (int)Severity.None; reqs.Bleed = (int)Severity.Moderate; break; } case Injury.InternalBleeding: { reqs.Cut = (int)Severity.Minor; reqs.Sew = (int)Severity.Moderate; reqs.Cool = (int)Severity.None; reqs.Heat = (int)Severity.None; reqs.Bleed = (int)Severity.Severe; break; } case Injury.LaceratedTorso: { reqs.Cut = (int)Severity.Minor; reqs.Sew = (int)Severity.Moderate; reqs.Cool = (int)Severity.Minor; reqs.Heat = (int)Severity.Moderate; reqs.Bleed = (int)Severity.None; break; } case Injury.MajorConcussion: { reqs.Cut = (int)Severity.None; reqs.Sew = (int)Severity.None; reqs.Cool = (int)Severity.Moderate; reqs.Heat = (int)Severity.None; reqs.Bleed = (int)Severity.Critical; break; } case Injury.MassiveBleeding: { reqs.Cut = (int)Severity.Moderate; reqs.Sew = (int)Severity.Severe; reqs.Cool = (int)Severity.None; reqs.Heat = (int)Severity.Minor; reqs.Bleed = (int)Severity.Deadly; break; } case Injury.MinorConcussion: { reqs.Cut = (int)Severity.None; reqs.Sew = (int)Severity.None; reqs.Cool = (int)Severity.Minor; reqs.Heat = (int)Severity.None; reqs.Bleed = (int)Severity.Severe; break; } case Injury.MinorCut: { reqs.Cut = (int)Severity.None; reqs.Sew = (int)Severity.Minor; reqs.Cool = (int)Severity.None; reqs.Heat = (int)Severity.Minor; reqs.Bleed = (int)Severity.None; break; } case Injury.BrokenSkull: { reqs.Cut = (int)Severity.Severe; reqs.Sew = (int)Severity.Moderate; reqs.Cool = (int)Severity.None; reqs.Heat = (int)Severity.Minor; reqs.Bleed = (int)Severity.Deadly; break; } case Injury.Winded: { reqs.Cut = (int)Severity.None; reqs.Sew = (int)Severity.None; reqs.Cool = (int)Severity.Minor; reqs.Heat = (int)Severity.None; reqs.Bleed = (int)Severity.None; break; } } return reqs; }
public static void TryHealInjury(PlayerMobile from, Mobile targ, Injury inj, TryHealInjuryGump.HealInfo info) { if (from == null || from.Deleted || !from.Alive) return; if (targ == null || targ.Deleted || !targ.Alive || targ.IsDeadBondedPet) return; if (info == null) return; if (HasHealthAttachment(targ)) { if (HealthAttachment.GetHA(targ).HasInjury(inj)) { if (TryHealInjuryGump.HealInjuryRequirements.MeetsRequirements(from, targ, info, inj)) { from.SendMessage("You succcessfully heal " + targ.Name + "'s " + GetName(inj)); targ.SendMessage(from.Name + " has successfully healed your " + GetName(inj)); Misc.LevelSystem.AwardCraftXP(from, true); InjuryTimer removeTimer = null; foreach (InjuryTimer iT in HealthAttachment.GetHA(targ).CurrentInjuries) { if (iT.Injury == inj) { removeTimer = iT; continue; } } if (removeTimer != null && HealthAttachment.GetHA(targ).CurrentInjuries.Contains(removeTimer)) { removeTimer.Stop(); HealthAttachment.GetHA(targ).CurrentInjuries.Remove(removeTimer); } } else { from.SendMessage("You have failed to treat the wound properly!"); targ.SendMessage("You feel an intense pain!"); TryHealInjuryGump.FailToHeal(from, targ); Misc.LevelSystem.AwardCraftXP(from, false); } } else from.SendMessage(targ.Name + " no longer has that injury."); } else { from.SendMessage("ERROR: Target has no Health Attachment."); return; } }
public TryHealInjuryGump(PlayerMobile viewer, Mobile injured, Injury injury, HealInfo info) : this(viewer, injured, injury, info, new HealTimer(viewer, injured, injury, info)) { }
public TryHealInjuryGump(PlayerMobile viewer, Mobile injured, Injury injury) : this(viewer, injured, injury, new HealInfo()) { }
public void DoInjury(Injury inj) { if (m_Player == null || m_Player.Deleted) { Delete(); return; } if (m_Player is PlayerMobile && (m_Player as PlayerMobile).RessSick) return; bool hasInjury = false; foreach (InjuryTimer iT in CurrentInjuries) { if (iT.Injury == inj) { hasInjury = true; continue; } } if (!hasInjury) return; switch (inj) { case Injury.Bloodied: { int dmg = Utility.RandomMinMax(1, 5); if (m_Player.Hits - dmg < 1) dmg = m_Player.Hits - (m_Player.Hits - 1); m_Player.Damage(dmg); Blood newBlood = new Blood(); newBlood.MoveToWorld(m_Player.Location, m_Player.Map); m_Player.SendMessage(37, "You're bleeding."); break; } case Injury.BrokenBack: { int pMin = 120 - m_Player.StamMax - m_Player.ManaMax; if (pMin < 15) pMin = 15; XmlParalyze newParalysis = new XmlParalyze(pMin); newParalysis.Name = "Injury Paralysis"; XmlAttach.AttachTo(m_Player, newParalysis); m_Player.SendMessage(37, "You are wracked with paralytic back spasms and cannot move!"); m_Player.Emote("*spasms!*"); break; } case Injury.BrokenJaw: { ArrayList muteAtt = XmlAttach.FindAttachments(m_Player, typeof(XmlBackground)); bool attached = false; foreach (XmlBackground att in muteAtt) { if (att.Background == BackgroundList.Mute) attached = true; } if (!attached) { int muteTime = 180 - m_Player.StamMax - m_Player.ManaMax; if (muteTime < 20) muteTime = 20; XmlBackground newMute = new XmlBackground(BackgroundList.Mute, 1, muteTime); newMute.Name = "Injury Mute"; XmlAttach.AttachTo(m_Player, newMute); m_Player.SendMessage(37, "Your jaw is broken, causing you great pain and rendering you unable to speak."); } break; } case Injury.BrokenLeftArm: { Item LeftArmItem = m_Player.FindItemOnLayer(Layer.TwoHanded); if (LeftArmItem != null && !LeftArmItem.Deleted && m_Player.Alive) { LeftArmItem.MoveToWorld(m_Player.Location, m_Player.Map); m_Player.PlaySound(LeftArmItem.GetDropSound()); if (LeftArmItem.Name != null && LeftArmItem.Name != "") m_Player.Emote("*drops " + LeftArmItem.Name + " due to " + (m_Player.Female ? "her" : "his") + " wounds*"); } //Remainder is handled in PlayerMobile.cs break; } case Injury.BrokenLeftLeg: { ArrayList lameAtts = XmlAttach.FindAttachments(m_Player, typeof(XmlBackground)); bool attached = false; foreach (XmlBackground att in lameAtts) { if (att.Background == BackgroundList.Lame) attached = true; } if (!attached) { int lameTime = 100 - m_Player.StamMax - m_Player.ManaMax; if (lameTime < 5) lameTime = 5; XmlBackground lameAtt = new XmlBackground(BackgroundList.Lame, 1, lameTime); lameAtt.Name = "Injury Left Lame"; XmlAttach.AttachTo(m_Player, lameAtt); m_Player.SendMessage(37, "Your left leg is broken, hindering your movement."); } break; } case Injury.BrokenNeck: { if (Utility.RandomMinMax(1, 100) > Utility.RandomMinMax(1 + (m_Player.ManaMax / 2), 100 + m_Player.ManaMax)) { int pMin = 120 - m_Player.StamMax - m_Player.ManaMax; if (pMin < 15) pMin = 15; XmlParalyze parAtt = new XmlParalyze(pMin); parAtt.Name = "Injury Paralysis Neck"; XmlAttach.AttachTo(m_Player, parAtt); m_Player.SendMessage(37, "Your neck is broken, and your body is paralyzed with pain!"); m_Player.Emote("*spasms!*"); } break; } case Injury.BrokenRightArm: { Item RightArmItem = m_Player.FindItemOnLayer(Layer.OneHanded); if (RightArmItem == null || RightArmItem.Deleted) RightArmItem = m_Player.FindItemOnLayer(Layer.FirstValid); if ((RightArmItem == null || RightArmItem.Deleted) && m_Player.FindItemOnLayer(Layer.TwoHanded) is BaseWeapon) RightArmItem = m_Player.FindItemOnLayer(Layer.TwoHanded); if (RightArmItem != null && !RightArmItem.Deleted && m_Player.Alive) { RightArmItem.MoveToWorld(m_Player.Location, m_Player.Map); m_Player.PlaySound(RightArmItem.GetDropSound()); if (RightArmItem.Name != null && RightArmItem.Name != "") m_Player.Emote("*drops " + RightArmItem.Name + " due to " + (m_Player.Female ? "her" : "his") + " wounds*"); } //Remainder is handled in PlayerMobile.cs break; } case Injury.BrokenRightLeg: { ArrayList lameAtts = XmlAttach.FindAttachments(m_Player, typeof(XmlBackground)); bool attached = false; foreach (XmlBackground att in lameAtts) { if (att.Background == BackgroundList.Lame) attached = true; } if (!attached) { int lameTime = 100 - m_Player.StamMax - m_Player.ManaMax; if (lameTime < 5) lameTime = 5; XmlBackground lameAtt = new XmlBackground(BackgroundList.Lame, 1, lameTime); lameAtt.Name = "Injury Right Lame"; XmlAttach.AttachTo(m_Player, lameAtt); m_Player.SendMessage(37, "Your right leg is broken, hindering your movement."); } break; } case Injury.Bruised: { bool alreadyBruised = false; foreach (StatMod mod in m_Player.StatMods) { if (mod.Name.ToLower().Contains("bruise")) { alreadyBruised = true; continue; } } if (!alreadyBruised) { int bruiseTime = 180 - m_Player.StamMax - m_Player.ManaMax; if (bruiseTime < 20) bruiseTime = 20; XmlHits bruising = new XmlHits(Utility.RandomMinMax(1, 10) * -1, bruiseTime); bruising.Name = "Bruise"; XmlAttach.AttachTo(m_Player, bruising); m_Player.SendMessage("You are badly bruised."); } break; } case Injury.DeepCut: { int HPLoss = m_Player.HitsMax / Utility.RandomMinMax(10, 20); if (m_Player.Hits - HPLoss <= 0) break; else if ( m_Player.Hits - HPLoss > 0 ) { m_Player.Damage(HPLoss); m_Player.SendMessage(37, "You have been cut deeply, and continue to bleed."); Blood newBlood = new Blood(); newBlood.MoveToWorld(m_Player.Location, m_Player.Map); m_Player.PlaySound(0x050); } break; } case Injury.Exhausted: { int StamLoss = 0; if (m_Player is PlayerMobile) { double numerator = m_Player.StamMax; StamLoss = (int)(numerator / (m_Player as PlayerMobile).Level); } else StamLoss = Utility.Random(1, 10); if (m_Player.StamMax - StamLoss < 1) StamLoss = m_Player.Stam - 1; m_Player.Stam -= StamLoss; if(Utility.RandomMinMax(1,100) > 90) m_Player.SendMessage(37, "You are exhausted, drained of " + StamLoss.ToString() + " stamina."); break; } case Injury.FracturedLeftArm: { //Handled in BaseWeapon and BaseShield.cs break; } case Injury.FracturedLeftLeg: { if (Utility.RandomBool() && m_Player.Stam - 1 > 0) m_Player.Stam--; //Handled in PlayerMobile.cs break; } case Injury.FracturedRibs: { int damage = Utility.RandomMinMax(1, 10); if (m_Player.Hits - damage > 0) { m_Player.Damage(damage); if(Utility.RandomMinMax(1,100) < 25) m_Player.SendMessage(37, "Your ribs are fractured, making movement painful and even debilitating!"); } break; } case Injury.FracturedRightArm: { //Handled in BaseWeapon.cs break; } case Injury.FracturedRightLeg: { if (Utility.RandomBool() && m_Player.Stam - 1 > 0) m_Player.Stam--; //Handled in PlayerMobile.cs break; } case Injury.FracturedSkull: { m_Player.Mana = 0; int intLoss = (-1 * (m_Player.RawInt - m_Player.ManaMax)) / 10; if(intLoss > 0) intLoss = 0; XmlAttach.AttachTo(m_Player, new XmlInt(intLoss, InjuryLevel * 100)); m_Player.SendMessage(37, "Your skull is fractured, causing you to feel dizzy and confused!"); break; } case Injury.InternalBleeding: { int HPLoss = m_Player.HitsMax / Utility.RandomMinMax(10, 20); if (m_Player.Hits - HPLoss > 0) { m_Player.Damage(HPLoss); } m_Player.SendMessage(37, "You are bleeding internally!"); m_Player.PlaySound(m_Player.Female ? 813 : 1087); m_Player.Say("*pukes*"); if (!m_Player.Mounted) m_Player.Animate(32, 5, 1, true, false, 0); Point3D p = new Point3D(m_Player.Location); switch (m_Player.Direction) { case Direction.North: p.Y--; break; case Direction.South: p.Y++; break; case Direction.East: p.X++; break; case Direction.West: p.X--; break; case Direction.Right: p.X++; p.Y--; break; case Direction.Down: p.X++; p.Y++; break; case Direction.Left: p.X--; p.Y++; break; case Direction.Up: p.X--; p.Y--; break; default: break; } p.Z = m_Player.Map.GetAverageZ(p.X, p.Y); bool canFit = Server.Spells.SpellHelper.AdjustField(ref p, m_Player.Map, 12, false); if (canFit) { Puke puke = new Puke(); puke.Name = "blood"; puke.Hue = Utility.RandomList(1157, 1609, 2206, 2778, 2795); puke.Map = m_Player.Map; puke.Location = p; } if (CombatSystemAttachment.GetCSA(m_Player).CruiseControl) { CombatSystemAttachment.GetCSA(m_Player).DisableAutoCombat(); m_Player.SendMessage("It is difficult for you focus on combat right now."); } break; } case Injury.LaceratedTorso: { int HPLoss = m_Player.HitsMax / Utility.RandomMinMax(10, 20); if (m_Player.Hits - HPLoss > 0) { m_Player.Damage(HPLoss); m_Player.SendMessage(37, "You are severely injured!"); } break; } case Injury.MajorConcussion: { m_Player.Mana = 0; if (m_Player.Warmode) m_Player.Warmode = false; if (m_Player.Mount != null && !(m_Player.Mount as BaseCreature).Deleted && Utility.RandomMinMax(1, 100) > ( 50 - ( m_Player.HitsMax - m_Player.Hits))) { IMount mount = m_Player.Mount; mount.Rider = null; if (m_Player is PlayerMobile) { PlayerMobile pm = m_Player as PlayerMobile; if (pm.DismountedTimer != null) pm.DismountedTimer.Stop(); pm.DismountedTimer = new Misc.Dismount.DismountTimer(pm, 1); pm.DismountedTimer.Start(); Spells.SpellHelper.Damage(TimeSpan.FromTicks(1), pm, pm, Utility.RandomMinMax(1, 6)); pm.Emote("*falls from {0} mount*", pm.Female == true ? "her" : "his"); } else { m_Player.Emote("*falls off " + (m_Player.Female == true ? "her" : "his") + " mount!*"); if (m_Player is Soldier) (mount as BaseCreature).Kill(); } } if (Utility.RandomMinMax(1, 100) > 95) { CombatSystemAttachment csa = CombatSystemAttachment.GetCSA(m_Player); csa.DoTrip(1); } if (Utility.RandomMinMax(1, 100) > 25) XmlAttach.AttachTo(m_Player, new XmlBackground(BackgroundList.Deaf, 1, 5)); if(Utility.RandomMinMax(1,100) > 95) m_Player.SendMessage(37, "You are severely concussed!"); break; } case Injury.MassiveBleeding: { foreach (Item item in m_Player.Items) { if (Utility.RandomMinMax(1, 100) > 75) { XmlAttach.AttachTo(item, new XmlHue(1157, 30)); continue; } } XmlAttach.AttachTo(m_Player, new XmlHue(2419, 30)); XmlAttach.AttachTo(m_Player, new XmlHits(-1 * Utility.RandomMinMax(1, InjuryLevel), InjuryLevel * 100)); Blood newBlood = new Blood(); newBlood.MoveToWorld(m_Player.Location, m_Player.Map); m_Player.Mana = 0; break; } case Injury.MinorConcussion: { m_Player.Mana = 0; switch(Utility.RandomMinMax(1,3)) { case 1: if (m_Player.Warmode) { m_Player.Warmode = false; if(Utility.RandomMinMax(1,100) > 90) m_Player.SendMessage(37, "You are concussed!"); } break; case 2: { if (m_Player.Mount != null && !(m_Player.Mount as BaseCreature).Deleted && Utility.RandomMinMax(1, 100) > ( 50 - ( m_Player.HitsMax - m_Player.Hits))) { IMount mount = m_Player.Mount; mount.Rider = null; if (m_Player is PlayerMobile) { PlayerMobile pm = m_Player as PlayerMobile; if (pm.DismountedTimer != null) pm.DismountedTimer.Stop(); pm.DismountedTimer = new Misc.Dismount.DismountTimer(pm, 1); pm.DismountedTimer.Start(); Spells.SpellHelper.Damage(TimeSpan.FromTicks(1), pm, pm, Utility.RandomMinMax(1, 6)); pm.Emote("*falls from {0} mount*", pm.Female == true ? "her" : "his"); } else { m_Player.Emote("*falls off " + (m_Player.Female == true ? "her" : "his") + " mount!*"); if (m_Player is Soldier) (mount as BaseCreature).Kill(); } } break; } case 3: { if (Utility.RandomMinMax(1, 100) > 95) { CombatSystemAttachment csa = CombatSystemAttachment.GetCSA(m_Player); csa.DoTrip(1); m_Player.SendMessage(37, "You are concussed!"); } break; } } break; } case Injury.MinorCut: { int dmg = Utility.RandomMinMax(1, 3); if (m_Player.Hits - dmg > 0) { m_Player.Damage(dmg); m_Player.SendMessage(37, "You have been cut, and are still bleeding."); } break; } case Injury.BrokenSkull: { m_Player.Mana = 0; int intLoss = (-1 * (m_Player.RawInt - m_Player.ManaMax)) / 10; if (intLoss > 0) intLoss = 0; XmlAttach.AttachTo(m_Player, new XmlInt(intLoss, InjuryLevel * 100)); new EyeRaking.EyeRakingTimer(m_Player, 10); m_Player.SendMessage("You have been blinded!"); m_Player.SendMessage(37, "Your skull is broken, causing your perception to fade in and out!"); break; } case Injury.Winded: { m_Player.Mana -= Utility.RandomMinMax(1, 10); int stamDmg = Utility.RandomMinMax(1, 5); if (m_Player.Stam - stamDmg > 0) m_Player.Stam -= stamDmg; else m_Player.Stam = 1; m_Player.SendMessage(37, "You're winded."); break; } default: break; } }
public bool HasInjury(Injury inj) { bool hasInjury = false; foreach (InjuryTimer i in m_CurrentInjuries) { if (i.Injury == inj) { hasInjury = true; continue; } } return hasInjury; }
private void AddInjury(Injury inj) { InjuryTimer addInjury = new InjuryTimer(inj, this); m_CurrentInjuries.Add(addInjury); addInjury.Start(); m_LastInjury = DateTime.Now; if (m_Player is PlayerMobile && ((PlayerMobile)m_Player).Feats.GetFeatLevel(FeatList.Justice) > 0) { if (((PlayerMobile)m_Player).LastDeath + TimeSpan.FromSeconds(90) > DateTime.Now) { if (m_Player.LastKiller != null && !m_Player.LastKiller.Deleted && m_Player.LastKiller.Alive) { HealthAttachment.GetHA(m_Player.LastKiller).TryInjure(m_Player); } } } switch (inj) { case Injury.Bloodied: m_Player.SendMessage(37, "You have been bloodied!"); break; case Injury.BrokenBack: m_Player.SendMessage(37, "Your back is broken!"); break; case Injury.BrokenJaw: m_Player.SendMessage(37, "Your jaw is broken!"); break; case Injury.BrokenLeftArm: m_Player.SendMessage(37, "Your left arm is broken!"); break; case Injury.BrokenLeftLeg: m_Player.SendMessage(37, "Your left leg is broken!"); break; case Injury.BrokenNeck: m_Player.SendMessage(37, "Your neck is broken!"); break; case Injury.BrokenRightArm: m_Player.SendMessage(37, "Your right arm is broken!"); break; case Injury.BrokenRightLeg: m_Player.SendMessage(37, "Your right leg is broken!"); break; case Injury.Bruised: m_Player.SendMessage(37, "You are bruised!"); break; case Injury.DeepCut: m_Player.SendMessage(37, "You have been deeply cut!"); break; case Injury.Exhausted: m_Player.SendMessage(37, "You are exhausted!"); break; case Injury.FracturedLeftArm: m_Player.SendMessage(37, "Your left arm is fractured!"); break; case Injury.FracturedLeftLeg: m_Player.SendMessage(37, "Your left leg is fractured!"); break; case Injury.FracturedRibs: m_Player.SendMessage(37, "Your ribs are fractured!"); break; case Injury.FracturedRightArm: m_Player.SendMessage(37, "Your right arm is fractured!"); break; case Injury.FracturedRightLeg: m_Player.SendMessage(37, "Your right leg is fractured!"); break; case Injury.FracturedSkull: m_Player.SendMessage(37, "Your skull is fractured!"); break; case Injury.InternalBleeding: m_Player.SendMessage(37, "You're bleeding internally!"); break; case Injury.LaceratedTorso: m_Player.SendMessage(37, "Your torso is lacerated!"); break; case Injury.MajorConcussion: m_Player.SendMessage(37, "You are majorly concussed!"); break; case Injury.MassiveBleeding: m_Player.SendMessage(37, "You are experiencing massive bleeding!"); break; case Injury.MinorConcussion: m_Player.SendMessage(37, "You have a minor concussion!"); break; case Injury.MinorCut: m_Player.SendMessage(37, "You have a few minor cuts!"); break; case Injury.BrokenSkull: m_Player.SendMessage(37, "Your skull is broken!"); break; case Injury.Winded: m_Player.SendMessage(37, "You are winded!"); break; default: break; } }
public static string GetName(Injury inj) { switch (inj) { case Injury.Bloodied: return "Bloodied"; case Injury.BrokenBack: return "Broken Back"; case Injury.BrokenJaw: return "Broken Jaw"; case Injury.BrokenLeftArm: return "Broken Left Arm"; case Injury.BrokenLeftLeg: return "Broken Left Leg"; case Injury.BrokenNeck: return "Broken Neck"; case Injury.BrokenRightArm: return "Broken Right Arm"; case Injury.BrokenRightLeg: return "Broken Right Leg"; case Injury.Bruised: return "Bruising"; case Injury.DeepCut: return "A Deep Cut"; case Injury.Exhausted: return "Exhaustion"; case Injury.FracturedLeftArm: return "Fractured Left Arm"; case Injury.FracturedLeftLeg: return "Fractured Left Leg"; case Injury.FracturedRibs: return "Fractured Ribs"; case Injury.FracturedRightArm: return "Fractured Right Arm"; case Injury.FracturedRightLeg: return "Fractured Right Leg"; case Injury.FracturedSkull: return "A Skull Fracture"; case Injury.InternalBleeding: return "Internal Bleeding"; case Injury.LaceratedTorso: return "Torso Lacerations"; case Injury.MajorConcussion: return "A Major Concussion"; case Injury.MassiveBleeding: return "Massive Bleeding"; case Injury.MinorConcussion: return "A Minor Concussion"; case Injury.MinorCut: return "A Minor Cut"; case Injury.BrokenSkull: return "Broken Skull"; case Injury.Winded: return "Winded"; default: return "An Injury"; } }
public InjuryTimer(Injury i, HealthAttachment ha) : base(TimeSpan.FromSeconds(Utility.Random(300)), TimeSpan.FromMinutes(1)) { m_Injury = i; m_HA = ha; m_RecoveryTime = m_HA.RecoveryTime; Priority = TimerPriority.OneMinute; m_StartTime = DateTime.Now; }
public MedicalTreatmentConfirmGump(PlayerMobile from, PlayerMobile target, Injury injury) : base(0, 0) { m_Healer = from; m_Target = target; m_Injury = injury; InitialSetup(); }