public virtual ActionResult MyBaseForms() { var myMembershipId = User.Identity.GetUserId(); var me = PlayerProcedures.GetPlayerFromMembership(myMembershipId); var customRepo = new EFContributorCustomFormRepository(); var customForms = customRepo.ContributorCustomForms.Where(c => c.OwnerMembershipId == myMembershipId) .Select(c => c.CustomForm).ToList(); var formRepo = new EFDbStaticFormRepository(); var baseForms = formRepo.DbStaticForms.Where(f => f.FriendlyName == "Regular Guy" || f.FriendlyName == "Regular Girl").ToArray(); // Shuffle non-custom base forms so players don't always pick the first one var rand = new Random(); for (var backstop = baseForms.Length; backstop > 1; backstop--) { var dest = backstop - 1; var src = rand.Next(0, backstop); var temp = baseForms[dest]; baseForms[dest] = baseForms[src]; baseForms[src] = temp; } if (me.Mobility == PvPStatics.MobilityFull) { ViewBag.CurrentForm = me.FormSourceId; } ViewBag.CurrentBaseForm = me.OriginalFormSourceId; if (!customForms.Any(f => f.Id == me.OriginalFormSourceId)) { var currentBase = formRepo.DbStaticForms.FirstOrDefault(f => f.Id == me.OriginalFormSourceId); if (currentBase != null) { customForms.Add(currentBase); } } customForms.AddRange(baseForms); return(View(MVC.Settings.Views.MyBaseForms, customForms)); }
/// <summary> /// Allows a player to claim a new base form if they have earned one. /// </summary> /// <returns></returns> public virtual ActionResult SetBaseForm(int baseId) { var myMembershipId = User.Identity.GetUserId(); var me = PlayerProcedures.GetPlayerFromMembership(myMembershipId); if (baseId == me.OriginalFormSourceId) { TempData["Error"] = "You already have this form selected as your base."; return(RedirectToAction(MVC.PvP.Play())); } // Prevent switching to existing form as a means of quickly escaping a TG orb's effects if (baseId == me.FormSourceId && me.Mobility == PvPStatics.MobilityFull) { TempData["Error"] = "You cannot select your current form as your base form."; return(RedirectToAction(MVC.PvP.Play())); } // Look for a match among custom forms IContributorCustomFormRepository repo = new EFContributorCustomFormRepository(); var match = repo.ContributorCustomForms.Where(c => c.OwnerMembershipId == myMembershipId && c.CustomForm.Id == baseId) .Select(c => c.CustomForm).FirstOrDefault(); if (match == null) { // Look for a match among standard starter forms var formRepo = new EFDbStaticFormRepository(); match = formRepo.DbStaticForms.Where(f => f.Id == baseId && (f.FriendlyName == "Regular Guy" || f.FriendlyName == "Regular Girl")).FirstOrDefault(); if (match == null) { TempData["Error"] = "You do not own that custom base form."; return(RedirectToAction(MVC.PvP.Play())); } } var instant = false; // When player is already in their base form change them instantly. if (me.FormSourceId == me.OriginalFormSourceId) { PlayerProcedures.SetCustomBase(me, baseId); me.OriginalFormSourceId = baseId; PlayerProcedures.InstantRestoreToBase(me); instant = true; } else { PlayerProcedures.SetCustomBase(me, baseId); } if (me.Mobility == PvPStatics.MobilityFull) { if (instant) { TempData["Result"] = $"You are suddenly overwhelmed as you spontaneously transform into a {match.FriendlyName}!"; } else { TempData["Result"] = $"Your inner {match.FriendlyName} is begging to be let out, if only you could return yourself to base form..."; } } else { TempData["Result"] = $"Your dreams of becoming a {match.FriendlyName} could come true, if only you could return to animacy..."; } return(RedirectToAction(MVC.PvP.Play())); }