public static void SavePcoID(Lookup pcoAccount, Person person, int pcoID, string userId) { PersonAttribute pa = GetPcoIDAttribute(pcoAccount, person); pa.IntValue = pcoID; pa.Save(person.OrganizationID, userId); }
public static PersonAttributeType GetAttrType(this PersonAttribute attr) { switch (attr) { case PersonAttribute.FARMER: case PersonAttribute.WARRIOR: case PersonAttribute.CIVILIAN: case PersonAttribute.SCRIBE: case PersonAttribute.WITCH_DOCTOR: return(PersonAttributeType.PROFESSION); case PersonAttribute.TALL: case PersonAttribute.SHORT: return(PersonAttributeType.HEIGHT); case PersonAttribute.BLUE_EYES: case PersonAttribute.GREEN_EYES: case PersonAttribute.BROWN_EYES: return(PersonAttributeType.EYE_COLOR); case PersonAttribute.STRONG: case PersonAttribute.WEAK: return(PersonAttributeType.STRENGTH); case PersonAttribute.SMART: case PersonAttribute.CARING: case PersonAttribute.STUPID: return(PersonAttributeType.PERSONALITY); default: return(PersonAttributeType.NONE); } }
public static PersonAttribute[] RandomAttributes(int howMany, bool alsoRandomProfession = true) { PersonAttributeType[] attrTypes = { PersonAttributeType.PERSONALITY, PersonAttributeType.HEIGHT, PersonAttributeType.STRENGTH, // PersonAttributeType.EYE_COLOR, }; howMany = Mathf.Min(attrTypes.Length, howMany); PersonAttributeType[] randomAttributes = Utilities.RandomSubset(attrTypes, howMany); PersonAttribute[] attributes = new PersonAttribute[howMany + (alsoRandomProfession ? 1 : 0)]; if (alsoRandomProfession) { attributes[howMany] = PersonAttributeType.PROFESSION.GetRandomValue(); } for (int i = 0; i < howMany; ++i) { attributes[i] = randomAttributes[i].GetRandomValue(); } return(attributes); }
/// <summary> /// Gets a formatted ID for a person attribute control based on the attribute's type. The control corresponding to the ID /// should be created with the CreateControl() method. /// </summary> /// <param name="attribute">Arena.Core.PersonAttribute</param> /// <returns>Formatted string representing a control ID of the given PersonAttribute</returns> public static string GetControlID(PersonAttribute attribute) { string prefix; switch (attribute.AttributeType) { case DataType.DateTime: prefix = "dtb"; break; case DataType.Lookup: prefix = "ddl"; break; case DataType.YesNo: prefix = "cb"; break; case DataType.Document: prefix = "dp"; break; default: prefix = "tb"; break; } return(string.Format("{0}_{1}", prefix, attribute.AttributeId)); }
/// <summary> /// Writes the person attributes. /// </summary> public static void WritePersonAttributes() { foreach (var attrib in PersonAttributes) { var attribute = new PersonAttribute(); // strip out "Ind" from the attribute name and add spaces between words attribute.Name = ExtensionMethods.SplitCase(attrib.Key.Replace("Ind", "")); attribute.Key = attrib.Key; attribute.Category = "Imported Attributes"; switch (attrib.Value) { case "String": attribute.FieldType = "Rock.Field.Types.TextFieldType"; break; case "DateTime": attribute.FieldType = "Rock.Field.Types.DateTimeFieldType"; break; default: attribute.FieldType = "Rock.Field.Types.TextFieldType"; break; } ImportPackage.WriteToPackage(attribute); } }
public static void SavePcoPassword(Lookup pcoAccount, Person person, string password, string userId) { PersonAttribute pa = GetPcoPasswordAttribute(pcoAccount, person); pa.StringValue = password; pa.Save(person.OrganizationID, userId); }
// TODO: use profession.GetColor() to color profession in GodDemand description/cost, and Person public static Color32 GetColor(this PersonAttribute attr) { switch (attr) { case PersonAttribute.FARMER: return(new Color32(60, 99, 60, 255)); case PersonAttribute.WARRIOR: return(new Color32(225, 0, 0, 255)); case PersonAttribute.CIVILIAN: return(new Color32(23, 19, 102, 255)); case PersonAttribute.SCRIBE: return(new Color32(166, 0, 226, 255)); case PersonAttribute.WITCH_DOCTOR: return(new Color32(239, 96, 13, 255)); case PersonAttribute.NONE: return(new Color32(29, 29, 29, 255)); default: Debug.Log("WARNING: " + attr.ToString() + " has no associated color"); return(Color.white); } }
public static string CapitalizedString(this PersonAttribute attr) { string[] words = attr.ToString().Split(new [] { '-', '_' }, System.StringSplitOptions.RemoveEmptyEntries); var capitalizedWords = words.Select(word => char.ToUpper(word[0]) + word.Substring(1).ToLower()).ToArray(); return(System.String.Join(" ", capitalizedWords)); }
private void LoadAttributes() { if (!string.IsNullOrEmpty(this.AttributesSetting)) { string[] array = this.AttributesSetting.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); string[] array2 = array; for (int i = 0; i < array2.Length; i++) { string s = array2[i]; int num = -1; if (int.TryParse(s, out num) && num != -1) { Arena.Core.Attribute attribute = new Arena.Core.Attribute(num); PersonAttribute personAttribute = (PersonAttribute)this.person.Attributes.FindByID(attribute.AttributeId); if (personAttribute == null) { personAttribute = new PersonAttribute(this.person.PersonID, num); } this.AddAttributeEdit(attribute, personAttribute, !this.Page.IsPostBack); } } } }
public static void SavePcoLastSyncArena(Lookup pcoAccount, Person person, XDocument details, string userId) { PersonAttribute pa = GetPcoLastSyncArenaAttribute(pcoAccount, person); Arena.Document.PersonDocument personDocument = new Arena.Document.PersonDocument(person.PersonID, pa.IntValue); personDocument.PersonID = person.PersonID; using (MemoryStream stream = new MemoryStream()) { XmlWriterSettings settings = new XmlWriterSettings(); using (XmlWriter writer = XmlWriter.Create(stream, settings)) { details.Save(writer); } personDocument.ByteArray = stream.ToArray(); } personDocument.OriginalFileName = "ArenaPerson.xml"; personDocument.FileExtension = "xml"; personDocument.MimeType = "application/xml"; personDocument.Title = "Last PCO Sync Arena Data"; personDocument.Description = string.Format("Arena Attributes for {0}({1})", person.FullName, person.PersonGUID.ToString()); personDocument.Save(userId); pa.IntValue = personDocument.DocumentID; pa.Save(person.OrganizationID, userId); }
/// <summary> /// This method will set the label's flags and health notes for the given person. /// </summary> /// <param name="attendee"></param> private void SetLabelFlags(Person attendee) { PersonAttribute selfCheckOut = new PersonAttribute(attendee.PersonID, int.Parse(organization.Settings["Cccev.SelfCheckOutAttributeID"])); PersonAttribute legalNotes = new PersonAttribute(attendee.PersonID, int.Parse(organization.Settings["Cccev.LegalNotesAttributeID"])); PersonAttribute healthNotes = new PersonAttribute(attendee.PersonID, int.Parse(organization.Settings["Cccev.HealthNotesAttributeID"])); label.SelfCheckOutFlag = (selfCheckOut.IntValue.Equals(1)); label.LegalNoteFlag = (!legalNotes.StringValue.Equals(string.Empty)); if (!healthNotes.StringValue.Equals(string.Empty)) { label.HealthNoteFlag = true; // This was removed after speaking with Laurie (NA 1/26/2009) // Don't print health notes if child greater than 1st grade. //if ( !( attendee.GraduationDate > DateTime.Parse( "1/1/1900" ) // && Person.CalculateGradeLevel( attendee.GraduationDate, organization.GradePromotionDate ) >= 1 ) ) //{ label.HealthNotes = healthNotes.StringValue; //} } else { label.HealthNoteFlag = false; } }
/// <summary> /// Verifies that a valid Tag and Attribute were selected, then loops through the ProfileMembers of the selected Tag /// and calls the SaveAttributeValue method for each ProfileMember /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnCreate_Click(object sender, EventArgs e) { if (ppTag.ProfileID == -1 || drpAttribute.SelectedValue == "-1") return; Profile p = new Profile(ppTag.ProfileID); Arena.Core.Attribute attr = new Arena.Core.Attribute(int.Parse(drpAttribute.SelectedValue)); if (p.ProfileID == -1 && attr.AttributeId != -1) return; int memberCount = 0; try { foreach (ProfileMember member in p.Members) { PersonAttribute pa = new PersonAttribute(member.PersonID, attr.AttributeId); if (pa.PersonID == -1) pa.PersonID = member.PersonID; if (SaveAttributeValue(pa, member, cbOverwrite.Checked)) memberCount++; } lcResult.Text = string.Format("{0} Member(s) updated", memberCount.ToString()); } catch (Exception ex) { lcMessage.Text = "The following errors have occurred:<br />" + ex.Message; pnlError.Visible = true; lcResult.Text = string.Format("{0} Member(s) updated", memberCount.ToString()); } }
void Update() { List <Person> people = Utilities.GetPersonManager().People; List <Person> peopleNotMaxLevel = people.FindAll(p => p.Level < GameState.GetLevelCap(p.Profession)); // Scribes produce XP and distribute it evenly among all people that are not max level float scribeBonus = people.FindAll(p => p.Profession == PersonAttribute.SCRIBE).Sum(p => p.Efficiency) / Mathf.Max(1, peopleNotMaxLevel.Count); foreach (Person person in peopleNotMaxLevel) { PersonAttribute prof = person.Profession; float xpGain = 1; xpGain = GameState.GetBuffedXp(prof, xpGain); if (GameState.HasBoon(BoonType.SAME_PROFESSION_XP_BONUS)) { List <Person> sameProfession = Utilities.GetPersonManager().FindPeople(PersonAttributeType.PROFESSION, prof); if (sameProfession.Count >= GameState.GetBoonValue(BoonType.SAME_PROFESSION_XP_REQ)) { xpGain += GameState.GetBoonValue(BoonType.SAME_PROFESSION_XP_BONUS); } } int bonusXpHealthThreshold = GameState.GetBoonValue(BoonType.HEALTHY_BONUS_XP_THRESHOLD); if (bonusXpHealthThreshold > 0 && person.Health >= bonusXpHealthThreshold) { xpGain += GameState.GetBoonValue(BoonType.HEALTHY_BONUS_XP); } int bonusXpUnhealthyThreshold = GameState.GetBoonValue(BoonType.UNHEALTHY_BONUS_XP_THRESHOLD); if (bonusXpUnhealthyThreshold > 0 && person.Health <= bonusXpUnhealthyThreshold) { xpGain += GameState.GetBoonValue(BoonType.UNHEALTHY_BONUS_XP); } xpGain += scribeBonus; person.AddXp(xpGain * GameState.GameDeltaTime); } }
private void btnSubmit_Click(object sender, EventArgs e) { PersonAttribute attribute; int i; for (i = 0; i < phAttributes.Controls.Count; i++) { // // Load the person attribute if the ID is not -1. // if (phAttributes.Controls[i].ID == "-1") { continue; } attribute = new PersonAttribute(CurrentPerson.PersonID, Convert.ToInt32(phAttributes.Controls[i].ID)); if (phAttributes.Controls[i].GetType() == typeof(CheckBox)) { CheckBox cbox = (CheckBox)phAttributes.Controls[i]; attribute.IntValue = Convert.ToInt32(cbox.Checked); attribute.Save(CurrentOrganization.OrganizationID, CurrentUser.Identity.Name); } else if (phAttributes.Controls[i].GetType() == typeof(TextBox)) { TextBox tb = (TextBox)phAttributes.Controls[i]; attribute.StringValue = HttpUtility.HtmlEncode(tb.Text); attribute.Save(CurrentOrganization.OrganizationID, CurrentUser.Identity.Name); } } // // Redirect browser back to originating page. // Response.Redirect(iRedirect.Value); }
protected IEnumerable <Lookup> GetTopicPreferences() { IEnumerable <int> lookupIDs = null; if (Request.IsAuthenticated) { var attribute = new Arena.Core.Attribute(SystemGuids.WEB_PREFS_NEWS_TOPICS_ATTRIBUTE); var pa = new PersonAttribute(CurrentPerson.PersonID, attribute.AttributeId); if (!string.IsNullOrEmpty(pa.StringValue)) { lookupIDs = pa.StringValue.SplitAndConvertTo <int>(new[] { ',' }, Convert.ToInt32); } } else { var cookie = Request.Cookies["Cccev.Web.Settings"] != null ? Request.Cookies["Cccev.Web.Settings"].Value : Constants.NULL_STRING; var array = Server.UrlDecode(cookie).Split(new[] { "|||" }, StringSplitOptions.None); if (!string.IsNullOrEmpty(array.Last().Trim())) { lookupIDs = array.Last().SplitAndConvertTo <int>(new[] { ',' }, Convert.ToInt32); } } return(lookupIDs != null ? (from s in lookupIDs select new Lookup(s)).ToList() : new List <Lookup>()); }
public ActionResult DeleteConfirmed(int id) { PersonAttribute personAttribute = _personAttributeRepository.GetById(id); _personAttributeRepository.Delete(personAttribute); _personAttributeRepository.SaveChanges(); return(RedirectToAction("Index")); }
// TODO: add an option to choose between 16px and 32px variants public Sprite GetSprite(PersonAttribute attribute) { if (attribute == PersonAttribute.NONE) { return(null); } return(GetSprite(attribute.ToString())); }
public ModifyResult Update(int personId, PersonAttribute attribute) { Arena.Core.Person person = new Arena.Core.Person(personId); var modifyResult = new ModifyResult(); try { Core.Attribute coreAttribute = null; if (attribute.AttributeID > 0) { coreAttribute = person.Attributes.FindByID(attribute.AttributeID); if (coreAttribute == null) { coreAttribute = new Core.PersonAttribute(attribute.AttributeID); person.Attributes.Add(coreAttribute); } } else { modifyResult.Successful = "False"; modifyResult.ErrorMessage = "Attribute ID is required."; return(modifyResult); } if (!coreAttribute.Allowed(Security.OperationType.Edit, Arena.Core.ArenaContext.Current.User, person)) { modifyResult.Successful = "False"; modifyResult.ErrorMessage = "Permission denied to edit attribute."; return(modifyResult); } coreAttribute.AttributeName = attribute.AttributeName; if (coreAttribute.AttributeType == Enums.DataType.String) { coreAttribute.StringValue = attribute.StringValue; } if (coreAttribute.AttributeType == Enums.DataType.DateTime) { coreAttribute.DateValue = attribute.DateValue.GetValueOrDefault(); } if (coreAttribute.AttributeType == Enums.DataType.Decimal) { coreAttribute.DecimalValue = attribute.DecimalValue.GetValueOrDefault(); } if (coreAttribute.AttributeType == Enums.DataType.Int) { coreAttribute.IntValue = attribute.IntValue.GetValueOrDefault(); } person.SaveAttributes(Arena.Core.ArenaContext.Current.Organization.OrganizationID, Arena.Core.ArenaContext.Current.User.Identity.Name); modifyResult.Successful = "True"; } catch (Exception e) { modifyResult.Successful = "False"; modifyResult.ErrorMessage = e.Message; } return(modifyResult); }
public XpBuff(PersonAttribute profession) : base("", "") { mProfession = profession; string professionString = profession.CapitalizedString(); mName = string.Format("Level {0} {1}s", GameState.GetLevelCap(mProfession) + 1, professionString); mDescription = professionString + "s gain +1 xp/s. +1 max level."; mIcon = profession.ToString(); }
public static float GetBuffedXp(PersonAttribute profession, float baseValue) { if (!sGameState.mXpBuffs.ContainsKey(profession)) { return(baseValue); } return(baseValue * sGameState.mXpBuffs[profession]); }
// Returns a list of attributes. Corresponding icons will be used in the demand info rows. // TODO: support images other than profession icons public PersonAttribute[] GetUIDescriptionIcons() { PersonAttribute[] attributes = new PersonAttribute[mCriteria.Count]; for (int i = 0; i < mCriteria.Count; i++) { attributes[i] = mCriteria[i].GetProfession(); } return(attributes); }
public static void IncreaseLevelCap(PersonAttribute profession) { if (!sGameState.mLevelCapIncreases.ContainsKey(profession)) { sGameState.mLevelCapIncreases.Add(profession, 0); } sGameState.mLevelCapIncreases[profession]++; }
// Called when a GameObject is dropped on a profession area // Returns false if the dropped object is not a person. public bool OnChangeProfession(GameObject uiObject, PersonAttribute newProfession) { if (!mUiPeopleMap.ContainsValue(uiObject)) { return(false); } mUiPeopleMap.GetKey(uiObject).ChangeProfession(newProfession); return(true); }
public ModifyResult Update(int personId, PersonAttribute attribute) { Arena.Core.Person person = new Arena.Core.Person(personId); var modifyResult = new ModifyResult(); try { Core.Attribute coreAttribute = null; if (attribute.AttributeID > 0) { coreAttribute = person.Attributes.FindByID(attribute.AttributeID); if (coreAttribute == null) { coreAttribute = new Core.PersonAttribute(attribute.AttributeID); person.Attributes.Add(coreAttribute); } } else { modifyResult.Successful = "False"; modifyResult.ErrorMessage = "Attribute ID is required."; return modifyResult; } if (!coreAttribute.Allowed(Security.OperationType.Edit, Arena.Core.ArenaContext.Current.User, person)) { modifyResult.Successful = "False"; modifyResult.ErrorMessage = "Permission denied to edit attribute."; return modifyResult; } coreAttribute.AttributeName = attribute.AttributeName; if (coreAttribute.AttributeType == Enums.DataType.String) { coreAttribute.StringValue = attribute.StringValue; } if (coreAttribute.AttributeType == Enums.DataType.DateTime) { coreAttribute.DateValue = attribute.DateValue.GetValueOrDefault(); } if (coreAttribute.AttributeType == Enums.DataType.Decimal) { coreAttribute.DecimalValue = attribute.DecimalValue.GetValueOrDefault(); } if (coreAttribute.AttributeType == Enums.DataType.Int) { coreAttribute.IntValue = attribute.IntValue.GetValueOrDefault(); } person.SaveAttributes(Arena.Core.ArenaContext.Current.Organization.OrganizationID, Arena.Core.ArenaContext.Current.User.Identity.Name); modifyResult.Successful = "True"; } catch (Exception e) { modifyResult.Successful = "False"; modifyResult.ErrorMessage = e.Message; } return modifyResult; }
public static void AddXpBuff(PersonAttribute profession, int xpMultiplierIncrease) { if (!sGameState.mXpBuffs.ContainsKey(profession)) { sGameState.mXpBuffs.Add(profession, 1 + xpMultiplierIncrease); } else { sGameState.mXpBuffs[profession] = sGameState.mXpBuffs[profession] + xpMultiplierIncrease; } }
public bool IsRelevantAttribute(PersonAttribute attribute) { foreach (Criterion c in mCriteria) { if (c.IsRelevantAttribute(attribute)) { return(true); } } return(false); }
public ActionResult Edit([Bind(Include = "PersonAttributeId,Personality,StrongSides,TouchNeedingSides,Interrest,PersonId")] PersonAttribute personAttribute) { if (ModelState.IsValid) { _personAttributeRepository.Update(personAttribute); _personAttributeRepository.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.PersonId = new SelectList(_personRepository.All, "PersonId", "Firstname", personAttribute.PersonId); return(View(personAttribute)); }
public static PersonAttribute CreatePersonAttribute(Person person) { PersonAttribute attribute = new PersonAttribute { IntValue = 1, PersonID = person.PersonID }; person.Attributes.Add(attribute); return(attribute); }
// This should be called after the person has already been created and Awake completed. public void OverrideRandomValues(PersonAttribute newProfession = PersonAttribute.NONE, int level = -1) { if (newProfession != PersonAttribute.NONE) { mAttributes[PersonAttributeType.PROFESSION] = newProfession; } if (level != -1) { mLevel = level; mXp = GetTotalXpForLevel(level); } }
private static void SavePersonAttribute(Person person, string facebookID, int orgID) { var attribute = new Arena.Core.Attribute(SystemGuids.FACEBOOK_USER_ID_ATTRIBUTE); var facebookSetting = new PersonAttribute { PersonID = person.PersonID, AttributeId = attribute.AttributeId, StringValue = facebookID }; facebookSetting.Save(orgID, CREATED_BY); }
private static void CreateValidator(PersonAttribute attribute, string cssClass, Control parentContainer) { RequiredFieldValidator rfv = new RequiredFieldValidator(); parentContainer.Controls.Add(rfv); rfv.CssClass = cssClass + "_validator"; rfv.ControlToValidate = GetControlID(attribute); rfv.ErrorMessage = string.Format("{0} is required.", attribute.AttributeName); rfv.SetFocusOnError = true; rfv.Text = " *"; rfv.Display = ValidatorDisplay.Dynamic; }
public List <Person> FindPeople(PersonAttributeType attrType, PersonAttribute attrValue) { List <Person> results = new List <Person>(); foreach (Person p in mPeople) { if (p.GetAttribute(attrType) == attrValue) { results.Add(p); } } return(results); }
private void LoadFbAttributes() { const string OPT_OUT_KEY = "CentralAZ.Web.FacebookAuth.OptOut"; const string CONNECT_KEY = "CentralAZ.Web.FacebookAuth.AccountIsConnected"; //if (Session[OPT_OUT_KEY] != null || Session[CONNECT_KEY] != null) //{ // hasOptedOut = Convert.ToBoolean(Session[OPT_OUT_KEY]); // connectedToFacebook = Convert.ToBoolean(Session[CONNECT_KEY]); // return; //} var optOutAttribute = new Arena.Core.Attribute(SystemGuids.FACEBOOK_OPT_OUT_ATTRIBUTE); var optedOut = new PersonAttribute(CurrentPerson.PersonID, optOutAttribute.AttributeId); hasOptedOut = Convert.ToBoolean(optedOut.IntValue); //Session[OPT_OUT_KEY] = hasOptedOut; var facebookIdAttribute = new Arena.Core.Attribute(SystemGuids.FACEBOOK_USER_ID_ATTRIBUTE); var facebookID = new PersonAttribute(CurrentPerson.PersonID, facebookIdAttribute.AttributeId); connectedToFacebook = !string.IsNullOrEmpty(facebookID.StringValue); //Session[CONNECT_KEY] = connectedToFacebook; }
/// <summary> /// Saves the correct value from ProfileMember into the passed in PersonAttribute. /// If the Attribute is a YesNo attribute, then the Attribute for the ProfileMember will be marked as yes. /// If the Attribute is a DateTime attribute, then the value will be the DateActive value of the ProfileMember. /// If the Attribute is a Lookup, then the value will be the Lookup ID that has a matching Value to the MemberNotes property of the ProfileMember. /// If the Attribute is any other type, the value will be the MemberNotes. /// </summary> /// <param name="personAttribute"></param> /// <param name="member"></param> private bool SaveAttributeValue(PersonAttribute personAttribute, ProfileMember member, bool overwrite) { bool updated = false; try { switch (personAttribute.AttributeType) { case DataType.YesNo: if (overwrite || !personAttribute.HasIntValue) { personAttribute.IntValue = 1; updated = true; } break; case DataType.DateTime: if (overwrite || !personAttribute.HasDateValue) { personAttribute.DateValue = member.DateActive; updated = true; } break; case DataType.Lookup: if (!string.IsNullOrEmpty(member.MemberNotes.Trim()) && (overwrite || !personAttribute.HasIntValue)) { LookupType lt = new LookupType(int.Parse(personAttribute.TypeQualifier)); Lookup lookup = lt.Values.SingleOrDefault(l => l.Value.ToUpper() == member.MemberNotes.Trim().ToUpper()); if (lookup != null) { personAttribute.IntValue = lookup.LookupID; updated = true; } } break; default: if (overwrite || !personAttribute.HasStringValue) { personAttribute.StringValue = member.MemberNotes.Trim(); updated = true; } break; } if (updated) { personAttribute.Save(CurrentOrganization.OrganizationID, "TagsToAttributes"); // we must save the relationship between the document and the person if (personAttribute.AttributeType == DataType.Document) { if (personAttribute.IntValue != -1) { PersonDocument newDocument = new PersonDocument(personAttribute.PersonID, personAttribute.IntValue); newDocument.PersonID = personAttribute.PersonID; newDocument.DocumentID = personAttribute.IntValue; newDocument.SaveRelationship("TagsToAttributes"); } } } return updated; } catch { throw; } }
public ModifyResult Create(int personId, PersonAttribute attribute) { return Update(personId, attribute); }