public static string WillChangeNotification(StatTypes type) { if (!_willChangeNotifications.ContainsKey (type)) _willChangeNotifications.Add (type, string.Format ("Stats.{0}WillChange", type.ToString ())); return _willChangeNotifications[type]; }
public void SetValue(StatTypes type, int value, bool allowExceptions) { int oldValue = this[type]; if (oldValue == value) return; if (allowExceptions) { // Allow exceptions to the rule here ValueChangeException exc = new ValueChangeException( oldValue, value ); // The notification is unique per stat type this.PostNotification(WillChangeNotification(type), exc); // Did anything modify the value? value = Mathf.FloorToInt(exc.GetModifiedValue()); // Did something nullify the change? if (exc.toggle == false || value == oldValue) return; } _data[(int)type] = value; this.PostNotification(DidChangeNotification(type), oldValue); }
public ServerCharacterStatChange(StatTypes stat, long currentValue, long maximumValue, long characterId) { Stat = stat; CurrentValue = currentValue; MaximumValue = maximumValue; CharacterId = characterId; }
public void Init(StatTypes type, int value, Func<bool> condition) { this.type = type; this.value = value; this.condition = condition; this.AddObserver(OnStatChanged, Stats.WillChangeNotification(type), stats); }
public NatureData(DataRow row) { this.id = (byte)(long)row["ID"]; this.name = row["Name"] as string; this.raisedStat = GetStatTypeFromString(row["RaisedStat"] as string); this.loweredStat = GetStatTypeFromString(row["LoweredStat"] as string); }
public static string WillChangeNotification(StatTypes s) { if (!_willChangeNotifications.ContainsKey(s)) { _willChangeNotifications.Add(s, string.Format("Stats.{0}WillChange", s.ToString())); } return _willChangeNotifications[s]; }
public int this[StatTypes s] { get { return _data[(int)s]; } set { SetValue(s, value, true); } }
static StatModifierFeature GetFeature(GameObject obj, StatTypes type) { StatModifierFeature[] smf = obj.GetComponents<StatModifierFeature> (); for (int i = 0; i < smf.Length; i++) if (smf [i].type == type) return smf [i]; StatModifierFeature feature = obj.AddComponent<StatModifierFeature> (); feature.type = type; return feature; }
public CharacterStat this[StatTypes i] { get { // This indexer is very simple, and just returns or sets // the corresponding element from the internal array. return _stats[(int)i]; } set { _stats[(int)i] = value; } }
private void CharacterStatsOnCurrentValueChanged(long oldValue, long newValue, StatTypes statType, Character tracking) { var player = tracking as Player; Logger.Instance.Debug("{0} has {1} changed to {2}", player.Name, statType, newValue); //TODO: Revaluate this, right now we only broadcast hitpoint changes if (statType == StatTypes.Hitpoints) { var zone = player.Zone; var updatePacket = new ServerCharacterStatChange(statType, newValue, player.CharacterStats[statType].MaximumValue, (long)player.Id); // Broadcast to interested parties zone.SendToEveryone(updatePacket); } }
public void SetValue(StatTypes type, int value, bool allowExceptions) { int oldVlaue = this [type]; if (oldVlaue == value) return; if (allowExceptions) { ValueChangeException exc = new ValueChangeException(oldVlaue, value); this.PostNotification (WillChangeNotification(type), exc); value = Mathf.FloorToInt (exc.GetModifiedValue()); if(exc.toggle == false || value == oldVlaue) return; } _data [(int)type] = value; this.PostNotification (DidChangeNotification (type), oldVlaue); }
public int CalculateStat(int statVal, StatTypes statType, int lvl) { //float modifier; if (statType == StatTypes.STRENGTH) { //modifier = strMod; return (statVal + (int)(statVal * strMod * lvl)); } else if (statType == StatTypes.CONSTITUTION) { //modifier = conMod; return (statVal + (int)(statVal * conMod * lvl)); } else if (statType == StatTypes.DEXTERITY) { //modifier = dexMod; return (statVal + (int)(statVal * dexMod * lvl)); } else if (statType == StatTypes.INTELLIGENCE) { //modifier = intMod; return (statVal + (int)(statVal * intMod * lvl)); } else if (statType == StatTypes.WISDOM) { //modifier = wisMod; return (statVal + (int)(statVal * wisMod * lvl)); } else if (statType == StatTypes.CHARISMA) { //modifier = chaMod; return (statVal + (int)(statVal * chaMod * lvl)); } else if (statType == StatTypes.ARMOR_CLASS) { //modifier = acMod; return (statVal + (int)(statVal + acMod * lvl)); } else return 0; }
public void SetValue(StatTypes s, float value, bool allowExceptions) { float oldValue = this[s]; if (oldValue == value) { return; } if (allowExceptions) { ValueChangeException ve = new ValueChangeException(oldValue, value); this.PostNotification(WillChangeNotification(s), ve); value = Mathf.FloorToInt(ve.GetModifiedValue()); if (ve.toggle == false || oldValue == value) { return; } } _data[(int)s] = value; this.PostNotification(DidChangeNotification(s), oldValue); }
public float SetValue(StatTypes type, float value, bool allowExceptions) { float oldValue = this[type]; if (allowExceptions) { // Allow exceptions to the rule here ValueChangeException exc = new ValueChangeException(oldValue, value); // The notification is unique per stat type this.PostNotification(WillChangeNotification(type), exc); // Did anything modify the value? value = Mathf.FloorToInt(exc.GetModifiedValue()); // Did something nullify the change? if (exc.toggle == false || value == oldValue) { return(oldValue); } } if (oldValue == value) { return(oldValue); } // Modify value for special cases (ie Health/Mana will not go lower than 0, or higher than MHP/MMP) switch (type) { case StatTypes.HP: value = Mathf.Clamp(value, 0, this[StatTypes.MHP]); break; case StatTypes.MP: value = Mathf.Clamp(value, 0, this[StatTypes.MMP]); break; } // Set Value _data[(int)type] = value; // Wrap up other stat changes affected by value, and send completed notifications if (type == StatTypes.DEX) { if (_data[(int)type] <= 0) { _data[(int)StatTypes.SPD] = 0; } else { _data[(int)StatTypes.SPD] = 1 / _data[(int)type] / 2; } } this.PostNotification(DidChangeNotification(type), oldValue); this.PostNotification(UnitUpdateNotification, GetComponent <Unit>()); return(value); }
public void AddValue(StatTypes type, float value, bool allowExceptions) { float oldValue = this[type]; SetValue(type, Mathf.Clamp(oldValue + value, 0, int.MaxValue), allowExceptions); }
private float GetTraitMultiplier(StatTypes statType, int originalStat) { List <Trait> tempTraits = new List <Trait>(); #region adding character traits //job trait switch (mb.jobTraitIndex) { case 0: tempTraits.Add(home.tl.traits[0]); break; case 1: tempTraits.Add(home.tl.traits[1]); break; case 2: tempTraits.Add(home.tl.traits[2]); break; case 3: tempTraits.Add(home.tl.traits[6]); break; } //race trait switch (mb.raceTraitIndex) { case 0: tempTraits.Add(home.tl.traits[3]); break; case 1: tempTraits.Add(home.tl.traits[4]); break; case 2: tempTraits.Add(home.tl.traits[5]); break; } #endregion float oStat = originalStat; float cumultiveMultiplier = 0; foreach (Trait trait in tempTraits) { foreach (StatAffector sa in trait.affectedStats) { if (sa.stat == statType) { cumultiveMultiplier += sa.multiplier; } } } if (cumultiveMultiplier == 0) { return(oStat); } else { return(oStat * cumultiveMultiplier); } }
public ColumnStats GetDomainValueBarChart(int domainColumn, int dataColumn, int denominatorColumn, StatTypes statType) { CheckState(); var stats = new ColumnStats(); stats.Computed = true; var domainIdList = new Dictionary<string, int>(); stats.DomainValues = GetDomainValues(domainColumn); stats.Buckets = stats.DomainValues.Length; stats.Histogram = new double[stats.Buckets]; stats.TargetColumn = dataColumn; stats.DomainColumn = domainColumn; stats.DomainStatType = statType; stats.DemoninatorColumn = denominatorColumn; var sortLists = new List<double>[stats.Buckets]; var min = new double[stats.Buckets]; var max = new double[stats.Buckets]; var sum = new double[stats.Buckets]; var denominatorSum = new double[stats.Buckets]; stats.Selected = new bool[stats.Buckets]; for (var i = 0; i < stats.Buckets; i++) { domainIdList.Add(stats.DomainValues[i], i); max[i] = double.MinValue; min[i] = double.MaxValue; sortLists[i] = new List<double>(); stats.Selected[i] = false; } table.Lock(); // First Pass - Basic statistics.. foreach (var row in table.Rows) { var selected = Filters.Count == 0; var firstFilter = true; foreach (var fgt in Filters) { var filter = fgt.Stats; if (filter.Computed && (selected || firstFilter)) { if (filter.IsSelected(row)) { selected = true; } else { selected = false; } firstFilter = false; } } if (selected) { try { if (dataColumn > -1) { var domainID = domainIdList[row[domainColumn]]; var sucsess = false; double val = 0; sucsess = double.TryParse(row[dataColumn], out val); if (sucsess) { if (val > max[domainID]) { max[domainID] = val; } if (val < min[domainID]) { min[domainID] = val; } stats.Count++; stats.Sum += val; sum[domainID] += val; sortLists[domainID].Add(val); } else if (statType == StatTypes.Count) // && domainColumn == dataColumn) { sortLists[domainID].Add(0); } if (statType == StatTypes.Ratio && denominatorColumn != -1) { sucsess = double.TryParse(row[denominatorColumn], out val); if (sucsess) { denominatorSum[domainID] += val; } } } } catch { } } } table.Unlock(); //2nd pass does not use the table anymore. working from sortList for (var i = 0; i < stats.Buckets; i++) { if (sortLists[i].Count > 0) { var average = sum[i] / sortLists[i].Count; double median = 0; sortLists[i].Sort(); var midPoint = Math.Max(0, (sortLists[i].Count / 2) - 1); try { if (sortLists[i].Count % 2 == 0) { median = (sortLists[i][midPoint] + sortLists[i][midPoint + 1]) / 2; } else { median = (sortLists[i][midPoint]); } } catch { } switch (stats.DomainStatType) { case StatTypes.Count: stats.Histogram[i] = sortLists[i].Count; break; case StatTypes.Average: stats.Histogram[i] = average; break; case StatTypes.Median: stats.Histogram[i] = median; break; case StatTypes.Sum: stats.Histogram[i] = sum[i]; break; case StatTypes.Min: stats.Histogram[i] = min[i]; break; case StatTypes.Max: stats.Histogram[i] = max[i]; break; case StatTypes.Ratio: stats.Histogram[i] = sum[i] / denominatorSum[i]; break; default: break; } } } foreach (var j in stats.Histogram) { if (stats.HistogramMax < j) { stats.HistogramMax = j; } } return stats; }
protected virtual void OnCurrentValueChanged(long oldvalue, long newvalue, StatTypes stattype) { StatValueChanged handler = CurrentValueChanged; if (handler != null) handler(oldvalue, newvalue, stattype); }
public int CalculateStat(int baseStat, int level, int iv, int ev, Pokemon.Natures nature, StatTypes statType) { SetModifier(nature, statType); return((int)(((((iv + (2 * baseStat) + (ev / 4)) * level) / 100) + 5) * statModifier)); }
public Stat(StatTypes statType) { this.statType = statType; }
private void SetModifier(Pokemon.Natures nature, StatTypes statType) { if (nature == Pokemon.Natures.LONELY && statType == StatTypes.ATTACK) { statModifier = natureIncreaseModifier; } else { statModifier = natureNeutralModifier; } if (nature == Pokemon.Natures.LONELY && statType == StatTypes.DEFENSE) { statModifier = natureDecreaseModifier; } else { statModifier = natureNeutralModifier; } if (nature == Pokemon.Natures.BRAVE && statType == StatTypes.ATTACK) { statModifier = natureIncreaseModifier; } else { statModifier = natureNeutralModifier; } if (nature == Pokemon.Natures.BRAVE && statType == StatTypes.SPEED) { statModifier = natureDecreaseModifier; } else { statModifier = natureNeutralModifier; } if (nature == Pokemon.Natures.ADAMANT && statType == StatTypes.ATTACK) { statModifier = natureIncreaseModifier; } else { statModifier = natureNeutralModifier; } if (nature == Pokemon.Natures.ADAMANT && statType == StatTypes.SPECIALATTACK) { statModifier = natureDecreaseModifier; } else { statModifier = natureNeutralModifier; } if (nature == Pokemon.Natures.NAUGHTY && statType == StatTypes.ATTACK) { statModifier = natureIncreaseModifier; } else { statModifier = natureNeutralModifier; } if (nature == Pokemon.Natures.NAUGHTY && statType == StatTypes.SPECIALDEFENSE) { statModifier = natureDecreaseModifier; } else { statModifier = natureNeutralModifier; } if (nature == Pokemon.Natures.BOLD && statType == StatTypes.DEFENSE) { statModifier = natureIncreaseModifier; } else { statModifier = natureNeutralModifier; } if (nature == Pokemon.Natures.BOLD && statType == StatTypes.ATTACK) { statModifier = natureDecreaseModifier; } else { statModifier = natureNeutralModifier; } if (nature == Pokemon.Natures.RELAXED && statType == StatTypes.DEFENSE) { statModifier = natureIncreaseModifier; } else { statModifier = natureNeutralModifier; } if (nature == Pokemon.Natures.RELAXED && statType == StatTypes.SPEED) { statModifier = natureDecreaseModifier; } else { statModifier = natureNeutralModifier; } if (nature == Pokemon.Natures.IMPISH && statType == StatTypes.DEFENSE) { statModifier = natureIncreaseModifier; } else { statModifier = natureNeutralModifier; } if (nature == Pokemon.Natures.IMPISH && statType == StatTypes.SPECIALATTACK) { statModifier = natureDecreaseModifier; } else { statModifier = natureNeutralModifier; } if (nature == Pokemon.Natures.LAX && statType == StatTypes.DEFENSE) { statModifier = natureIncreaseModifier; } else { statModifier = natureNeutralModifier; } if (nature == Pokemon.Natures.LAX && statType == StatTypes.SPECIALDEFENSE) { statModifier = natureDecreaseModifier; } else { statModifier = natureNeutralModifier; } if (nature == Pokemon.Natures.TIMID && statType == StatTypes.SPEED) { statModifier = natureIncreaseModifier; } else { statModifier = natureNeutralModifier; } if (nature == Pokemon.Natures.TIMID && statType == StatTypes.ATTACK) { statModifier = natureDecreaseModifier; } else { statModifier = natureNeutralModifier; } if (nature == Pokemon.Natures.HASTY && statType == StatTypes.SPEED) { statModifier = natureIncreaseModifier; } else { statModifier = natureNeutralModifier; } if (nature == Pokemon.Natures.HASTY && statType == StatTypes.DEFENSE) { statModifier = natureDecreaseModifier; } else { statModifier = natureNeutralModifier; } if (nature == Pokemon.Natures.JOLLY && statType == StatTypes.SPEED) { statModifier = natureIncreaseModifier; } else { statModifier = natureNeutralModifier; } if (nature == Pokemon.Natures.JOLLY && statType == StatTypes.SPECIALATTACK) { statModifier = natureDecreaseModifier; } else { statModifier = natureNeutralModifier; } if (nature == Pokemon.Natures.NAIVE && statType == StatTypes.SPEED) { statModifier = natureIncreaseModifier; } else { statModifier = natureNeutralModifier; } if (nature == Pokemon.Natures.NAIVE && statType == StatTypes.SPECIALDEFENSE) { statModifier = natureDecreaseModifier; } else { statModifier = natureNeutralModifier; } if (nature == Pokemon.Natures.MODEST && statType == StatTypes.SPECIALATTACK) { statModifier = natureIncreaseModifier; } else { statModifier = natureNeutralModifier; } if (nature == Pokemon.Natures.MODEST && statType == StatTypes.ATTACK) { statModifier = natureDecreaseModifier; } else { statModifier = natureNeutralModifier; } if (nature == Pokemon.Natures.MILD && statType == StatTypes.SPECIALATTACK) { statModifier = natureIncreaseModifier; } else { statModifier = natureNeutralModifier; } if (nature == Pokemon.Natures.MILD && statType == StatTypes.DEFENSE) { statModifier = natureDecreaseModifier; } else { statModifier = natureNeutralModifier; } if (nature == Pokemon.Natures.QUIET && statType == StatTypes.SPECIALATTACK) { statModifier = natureIncreaseModifier; } else { statModifier = natureNeutralModifier; } if (nature == Pokemon.Natures.QUIET && statType == StatTypes.SPEED) { statModifier = natureDecreaseModifier; } else { statModifier = natureNeutralModifier; } if (nature == Pokemon.Natures.RASH && statType == StatTypes.SPECIALATTACK) { statModifier = natureIncreaseModifier; } else { statModifier = natureNeutralModifier; } if (nature == Pokemon.Natures.RASH && statType == StatTypes.SPECIALDEFENSE) { statModifier = natureDecreaseModifier; } else { statModifier = natureNeutralModifier; } if (nature == Pokemon.Natures.CALM && statType == StatTypes.SPECIALDEFENSE) { statModifier = natureIncreaseModifier; } else { statModifier = natureNeutralModifier; } if (nature == Pokemon.Natures.CALM && statType == StatTypes.ATTACK) { statModifier = natureDecreaseModifier; } else { statModifier = natureNeutralModifier; } if (nature == Pokemon.Natures.GENTLE && statType == StatTypes.SPECIALDEFENSE) { statModifier = natureIncreaseModifier; } else { statModifier = natureNeutralModifier; } if (nature == Pokemon.Natures.GENTLE && statType == StatTypes.DEFENSE) { statModifier = natureDecreaseModifier; } else { statModifier = natureNeutralModifier; } if (nature == Pokemon.Natures.SASSY && statType == StatTypes.SPECIALDEFENSE) { statModifier = natureIncreaseModifier; } else { statModifier = natureNeutralModifier; } if (nature == Pokemon.Natures.SASSY && statType == StatTypes.SPEED) { statModifier = natureDecreaseModifier; } else { statModifier = natureNeutralModifier; } if (nature == Pokemon.Natures.CAREFUL && statType == StatTypes.SPECIALDEFENSE) { statModifier = natureIncreaseModifier; } else { statModifier = natureNeutralModifier; } if (nature == Pokemon.Natures.CAREFUL && statType == StatTypes.SPECIALATTACK) { statModifier = natureDecreaseModifier; } else { statModifier = natureNeutralModifier; } if (nature == Pokemon.Natures.BASHFUL || nature == Pokemon.Natures.DOCILE || nature == Pokemon.Natures.HARDY || nature == Pokemon.Natures.QUIRKY || nature == Pokemon.Natures.SERIOUS) { statModifier = natureNeutralModifier; } }
protected virtual void OnMaximumValueChanged(long oldvalue, long newvalue, StatTypes stattype) { StatValueChanged handler = MaximumValueChanged; if (handler != null) handler(oldvalue, newvalue, stattype, _tracking); }
public void AddToStat(int playerId, StatTypes s) { Players[playerId].Properties.Stats[s]++; }
public int this[StatTypes s] { get { return(_data[(int)s]); } set { SetValue(s, value, true); } }
public int this[StatTypes type] { get => _data[(int)type];
public CharacterStat(long maximumValue, long currentValue, StatTypes statType) { _maximumValue = maximumValue; _currentValue = currentValue; StatType = statType; }
public static int Mask(this StatTypes stats) { return((int)Math.Pow(2, (double)stats)); }
private void OnHitpointsChanged(long oldValue, long newValue, StatTypes statType) { if (newValue <= 0) OnKilled(_lastCharacterToHitMe, this); }
public HealthStats(StatTypes statType, uint @value) : this(statType) { this.@value = @value; }
public int this[StatTypes s] { get => _data[(int)s];
public int this[StatTypes type] { get { return stats[(int)type]; } set { stats[(int)type] = value; } }
public void ModifyStat(StatTypes type, int modifier) { this[type] = this[type] + modifier; }
// The order for adding mdos will go: // Mod type (e.g. flat or percentage), // Affected stat (e.g. ATK, DEF, HP), then // Value of the mod being added (e.g. 3f, 0.12f) public ModApplication(StatModType modType, StatTypes statType, float value) { mType = modType; sType = statType; Value = value; }
public Stat(StatTypes statType, uint @value) : this(statType) { this.@value = @value; }
public AssingTempStatMod(TempStatMod tempStatMod, StatTypes statTypes) { this.tempStatMod = tempStatMod; this.statTypes = statTypes; }
public HealthStats(StatTypes statType) { this.statType = statType; }
public StatMultiplier(StatTypes stat, float multiplier) { this.stat = stat; this.multiplier = multiplier; }