public ActionCharacterPropertySet(Guid guid, List <string> path, CharProperty from, CharProperty to) { if (path is null) { throw new ArgumentNullException(nameof(path)); } if (path.Count <= 0) { throw new ArgumentOutOfRangeException(nameof(path)); } if ((from is null) && (to is null)) { throw new ArgumentNullException(nameof(to)); } if (from is not null) { from = from.copy(); } if (to is not null) { to = to.copy(); } this.guid = guid; this.path = new List <string>(path); this.from = from; this.to = to; }
public SimpleCharacterWindow(CampaignState state, Guid?guid = null) { this.valid = false; this.state = state.copy(); this.actions = new List <EntryAction>(); if (guid is null) { ActionCharacterSet add_action = new ActionCharacterSet(Guid.NewGuid(), null, new Character("")); this.actions.Add(add_action); this.character = add_action.to; } else { this.character = this.state.characters.characters[guid.Value]; } this.guid = guid; this.property_rows = new ObservableCollection <PropertyRow>(); this.populate_property_rows(this.property_rows, new List <string>(), this.character.properties); this.selected_path = null; this.selected_prop = null; this.selected_member = null; InitializeComponent(); this.name_box.Text = this.character.name; this.properties_list.ItemsSource = this.property_rows; }
public override int GetHashCode() { unchecked { // Choose large primes to avoid hashing collisions const int HashingBase = (int)2166136261; const int HashingMultiplier = 16777619; int hash = HashingBase; hash = (hash * HashingMultiplier) ^ ByteProperty.GetHashCode(); hash = (hash * HashingMultiplier) ^ ShortByteProperty.GetHashCode(); hash = (hash * HashingMultiplier) ^ IntProperty.GetHashCode(); hash = (hash * HashingMultiplier) ^ UIntProperty.GetHashCode(); hash = (hash * HashingMultiplier) ^ ShortProperty.GetHashCode(); hash = (hash * HashingMultiplier) ^ UShortProperty.GetHashCode(); hash = (hash * HashingMultiplier) ^ LongProperty.GetHashCode(); hash = (hash * HashingMultiplier) ^ ULongProperty.GetHashCode(); hash = (hash * HashingMultiplier) ^ FloatPropertyOne.GetHashCode(); hash = (hash * HashingMultiplier) ^ FloatPropertyTwo.GetHashCode(); hash = (hash * HashingMultiplier) ^ DoublePropertyOne.GetHashCode(); hash = (hash * HashingMultiplier) ^ DoublePropertyTwo.GetHashCode(); hash = (hash * HashingMultiplier) ^ CharProperty.GetHashCode(); hash = (hash * HashingMultiplier) ^ BoolProperty.GetHashCode(); hash = (hash * HashingMultiplier) ^ DecimalProperty.GetHashCode(); return(hash); } }
/// <summary> /// Update final property calculated by equipments and labels /// </summary> public void UpdateFinalProperty(bool isFirstUpdate = false) { // Calculate property by equipments and labels // 1. Equipments CharProperty newProperty = originalProperty; newProperty.hpMax += armor.health + accessory.health; newProperty.pDamage += weapon.pAtk; newProperty.mDamage += weapon.mAtk; newProperty.strength += armor.strength + accessory.strength; newProperty.agility += armor.agility + accessory.agility; newProperty.intellect += armor.intellect + accessory.intellect; newProperty.pResist += armor.pDefense + accessory.pDefense; newProperty.mResist += armor.mDefense + accessory.mDefense; // Calculate 2-level property by 1-level property newProperty.dodge += newProperty.agility * 1f; newProperty.pResist += newProperty.strength * 1f; newProperty.mResist += newProperty.intellect * 1f; // Keep hp and hunger newProperty.hp = finalProperty.hp; newProperty.hunger = finalProperty.hunger; // 2. Labels foreach (Label label in labels) { newProperty = InequalityParse.EffectParse(label.effect, newProperty); } finalProperty = newProperty; }
// Use this for initialization void Start() { string str = "E3+10|E4-10.1"; CharProperty cp = CharProperty.standard; cp = InequalityParse.EffectParse(str, cp); Debug.Log("strength: " + cp.strength); Debug.Log("agility: " + cp.agility); }
public override void rebase(CampaignState state) { if (!state.characters.characters.ContainsKey(this.guid)) { throw new ArgumentOutOfRangeException(); } try { CharProperty prop = state.characters.characters[this.guid].get_property(this.path); this.from = prop.copy(); } catch (ArgumentOutOfRangeException) { this.from = null; } }
private void properties_list_sel_changed(object sender, RoutedEventArgs e) { List <string> path = this.properties_list.SelectedValue as List <string>; this.selected_path = null; this.selected_prop = null; this.selected_member = null; if (path is not null) { try { this.selected_prop = this.character.get_property(path); } catch (ArgumentException) { if (path.Count > 1) { this.selected_member = path[^ 1];
public void test_set_property_new() { Character c = this.get_test_character(); CharNumProperty new_prop = new CharNumProperty(42); CharProperty old_prop = c.set_property(new List <string>() { "Skills", "Fury" }, new_prop); Assert.IsTrue(old_prop is null); CharNumProperty prop = c.get_property(new List <string>() { "Skills", "Fury" }) as CharNumProperty; Assert.IsFalse(prop is null); Assert.AreEqual(prop.value, new_prop.value); }
public static CharProperty EffectParse(string str, CharProperty cp) { string pattern = @"E(\d+)([\+\-\*/])([0-9]*(?:\.[0-9]*)?)"; foreach (Match m in Regex.Matches(str, pattern)) { int effectType = int.Parse(m.Groups[1].Value); string operStr = m.Groups[2].Value; float effectValue = float.Parse(m.Groups[3].Value); switch (effectType) { case 1: cp.technology = BaseEParse(operStr, cp.technology, effectValue); break; case 2: cp.intellect = BaseEParse(operStr, cp.intellect, effectValue); break; case 3: cp.strength = BaseEParse(operStr, cp.strength, effectValue); break; case 4: cp.agility = BaseEParse(operStr, cp.agility, effectValue); break; case 5: cp.pResist = BaseEParse(operStr, cp.pResist, effectValue); break; case 6: cp.mResist = BaseEParse(operStr, cp.mResist, effectValue); break; } } return(cp); }
// ------ Shared Variables ------ // ------ Private Variables ------ // ------ Required Components ------ // ------ Public Functions ------ /// <summary> /// Initialize a character /// </summary> /// <param name="n">Name</param> /// <param name="ip">Is player</param> public Character(string n, bool ip = false) { name = n; isPlayer = ip; // Initialization // Equipments weapon = Weapon.Default; armor = Armor.Default; accessory = Accessory.Default; // Weight And Money maxWeight = 20f; currentWeight = 0f; money = 200f; // Property originalProperty = CharProperty.standard; finalProperty = originalProperty; UpdateFinalProperty(true); // Label labels = new List <Label>(); // Inventory inventories = new Dictionary <Inventory, int>(); // Pool for test // Now pool is the same as global pool // foreach(Attack atk in Data.AllAttacks.Values){ // attackPool.Add(atk); // } foreach (ActionType type in System.Enum.GetValues(typeof(ActionType))) { defendPool.Add(type, new List <Defend>()); foreach (int defendID in Data.AllDefendsByType[type]) { defendPool[type].Add(Data.AllDefends[defendID]); } } }
private static CharProperty setDifference(CharProperty lhs, CharProperty rhs) { return new CharProperty((int ch)=> { return ! rhs.isSatisfiedBy(ch) && lhs.isSatisfiedBy(ch); }); }
private static CharProperty intersection(CharProperty lhs, CharProperty rhs) { return new CharProperty((int ch)=> { return lhs.isSatisfiedBy(ch) && rhs.isSatisfiedBy(ch); }); }
private static CharProperty union(CharProperty lhs, CharProperty rhs) { return new CharProperty((int ch)=> { return lhs.isSatisfiedBy(ch) || rhs.isSatisfiedBy(ch); }); }