public void SetPlayerStats(StatsValue type, float value) { IntPtr cache = GetCache(Context.Game, (int)GameContext.Player); List <IntPtr> players = GroupComponents(cache); int count = players.Count; for (int i = 0; i < count; i++) { IntPtr entity = players[i]; IntPtr stats = Program.Read <IntPtr>(entity, 0x10 + ((int)GameContext.Stats * 0x4)); if (stats == IntPtr.Zero) { continue; } switch (type) { case StatsValue.Attack: case StatsValue.AttackSpeed: case StatsValue.Defence: case StatsValue.Health: case StatsValue.IncreasedAttackSpeed: case StatsValue.Magic: case StatsValue.MagicBuff: case StatsValue.Mana: case StatsValue.PhysicalBuff: Program.Write <int>(stats, (int)value, (int)type, 0xc); break; case StatsValue.MoveSpeed: case StatsValue.RollDistance: Program.Write <float>(stats, value, (int)type, 0xc); break; } } }
private void CreateSavingThrowLabels(StatsUiParams uiParams) { void AddWidgets(Stat stat, string helpTopic, Rectangle labelRect, Rectangle valueRect) { Container.Add(new StatsLabel(stat, helpTopic, labelRect, StatsUiTexture.ButtonFORTClick, StatsUiTexture.ButtonFORTHover, uiParams )); var valueWidget = new StatsValue( obj => GetStatModifierText(obj, stat), valueRect, StatsUiTexture.ButtonFORTOutputClick, StatsUiTexture.ButtonFORTOutputHover, uiParams ); valueWidget.SetClickHandler(() => ShowSavingThrowHelp(stat)); Container.Add(valueWidget); } AddWidgets(Stat.save_fortitude, "TAG_FORTITUDE", uiParams.FortLabel, uiParams.FortValue); AddWidgets(Stat.save_reflexes, "TAG_REFLEX", uiParams.RefLabel, uiParams.RefValue); AddWidgets(Stat.save_willpower, "TAG_WILL", uiParams.WillLabel, uiParams.WillValue); }
public void Calculates_total_correctly() { // setup var stats = new StatsValue {CacheHit = 100, CacheMiss = 50}; // validate stats.TotalRequests.Should().Be(150); }
public void Calculates_miss_percent_correctly(long hits, long misses, double percent) { // setup var stats = new StatsValue { CacheHit = hits, CacheMiss = misses }; // validate stats.CacheMissPercent.Should().Be(percent); }
public void Calculates_total_correctly() { // setup var stats = new StatsValue { CacheHit = 100, CacheMiss = 50 }; // validate stats.TotalRequests.Should().Be(150); }
public void BuildStatsValue() { var value = new StatsValue(new List <decimal>() { 1, 2, 3, 4 }); Assert.Equal(4, value.Max); Assert.Equal(1, value.Min); Assert.Equal(4, value.Count); Assert.Equal(2.5m, value.Mean); }
public T PlayerStat <T>(StatsValue type) where T : unmanaged { IntPtr cache = GetCache(Context.Game, (int)GameContext.Player); List <IntPtr> players = GroupComponents(cache); if (players == null || players.Count == 0) { return(default(T)); } IntPtr entity = players[0]; IntPtr stats = Program.Read <IntPtr>(entity, 0x10 + ((int)GameContext.Stats * 0x4)); if (stats == IntPtr.Zero) { return(default(T)); } return(Program.Read <T>(stats, (int)type, 0xc)); }
private void CreateDefensiveLabels(StatsUiParams uiParams) { Container.Add(new StatsLabel(Stat.hp_current, "TAG_HIT_POINTS", uiParams.HpLabel, StatsUiTexture.ButtonHPClick, StatsUiTexture.ButtonHPHover, uiParams )); var hpValue = new StatsValue( GetHitPointsText, uiParams.HpValue, StatsUiTexture.ButtonHPOutputClick, StatsUiTexture.ButtonHPOutputHover, uiParams ); hpValue.SetClickHandler(() => GameSystems.Help.ShowTopic("TAG_HIT_POINTS")); hpValue.TooltipText = null; Container.Add(hpValue); Container.Add(new StatsLabel(Stat.ac, "TAG_ARMOR_CLASS", uiParams.AcLabel, StatsUiTexture.ButtonHPClick, StatsUiTexture.ButtonHPHover, uiParams )); var acValue = new StatsValue( obj => GetStatValue(obj, Stat.ac), uiParams.AcValue, StatsUiTexture.ButtonHPOutputClick, StatsUiTexture.ButtonHPOutputHover, uiParams ); acValue.SetClickHandler(ShowArmorClassHelp); Container.Add(acValue); }
private void CreatePhysicalAppearanceLabels(StatsUiParams uiParams) { Container.Add(new StatsLabel(Stat.height, null, uiParams.HeightLabel, StatsUiTexture.ButtonHTClick, StatsUiTexture.ButtonHTHover, uiParams )); var heightValue = new StatsValue( GetHeightText, uiParams.HeightValue, StatsUiTexture.ButtonHTOutputClick, StatsUiTexture.ButtonHTOutputHover, uiParams ); heightValue.TooltipText = null; Container.Add(heightValue); Container.Add(new StatsLabel(Stat.weight, null, uiParams.WeightLabel, StatsUiTexture.ButtonHTClick, StatsUiTexture.ButtonHTHover, uiParams )); var weightValue = new StatsValue( obj => GetStatValue(obj, Stat.weight), uiParams.WeightValue, StatsUiTexture.ButtonHTOutputClick, StatsUiTexture.ButtonHTOutputHover, uiParams ); weightValue.TooltipText = null; Container.Add(weightValue); }
private void CreateAbilityScoreLabels(StatsUiParams uiParams) { void AddLabel(Stat stat, string helpTopic, Rectangle rectangle) { Container.Add(new StatsLabel(stat, helpTopic, rectangle, StatsUiTexture.ButtonSTRClick, StatsUiTexture.ButtonSTRHover, uiParams )); } void AddScore(Stat stat, Rectangle rectangle) { var widget = new StatsValue( obj => GetAbilityScoreValue(obj, stat), rectangle, StatsUiTexture.ButtonLevelOutputClick, StatsUiTexture.ButtonLevelOutputHover, uiParams ); widget.SetClickHandler(() => ShowAbilityScoreHelp(stat)); Container.Add(widget); } void AddModifier(Stat stat, Rectangle rectangle) { var widget = new StatsValue( obj => GetStatModifierText(obj, stat), rectangle, StatsUiTexture.ButtonLevelOutputClick, StatsUiTexture.ButtonLevelOutputHover, uiParams ); widget.TooltipText = null; widget.SetClickHandler(() => { GameSystems.Help.ShowTopic("TAG_ABILITY_MODIFIERS"); }); Container.Add(widget); } AddLabel(Stat.strength, "TAG_STRENGTH", uiParams.StrLabel); AddScore(Stat.strength, uiParams.StrValue); AddModifier(Stat.str_mod, uiParams.StrBonusValue); AddLabel(Stat.dexterity, "TAG_DEXTERITY", uiParams.DexLabel); AddScore(Stat.dexterity, uiParams.DexValue); AddModifier(Stat.dex_mod, uiParams.DexBonusValue); AddLabel(Stat.constitution, "TAG_CONSTITUTION", uiParams.ConLabel); AddScore(Stat.constitution, uiParams.ConValue); AddModifier(Stat.con_mod, uiParams.ConBonusValue); AddLabel(Stat.intelligence, "TAG_INTELLIGENCE", uiParams.IntLabel); AddScore(Stat.intelligence, uiParams.IntValue); AddModifier(Stat.int_mod, uiParams.IntBonusValue); AddLabel(Stat.wisdom, "TAG_WISDOM", uiParams.WisLabel); AddScore(Stat.wisdom, uiParams.WisValue); AddModifier(Stat.wis_mod, uiParams.WisBonusValue); AddLabel(Stat.charisma, "TAG_CHARISMA", uiParams.ChaLabel); AddScore(Stat.charisma, uiParams.ChaValue); AddModifier(Stat.cha_mod, uiParams.ChaBonusValue); }
private void CreateCombatLabels(StatsUiParams uiParams) { Container.Add(new StatsLabel(Stat.initiative_bonus, "TAG_INITIATIVE", uiParams.InitLabel, StatsUiTexture.ButtonInitiativeClick, StatsUiTexture.ButtonInitiativeHover, uiParams )); var initValue = new StatsValue( obj => GetStatModifierText(obj, Stat.initiative_bonus), uiParams.InitValue, StatsUiTexture.ButtonInitiativeOutputClick, StatsUiTexture.ButtonInitiativeOutputHover, uiParams ); initValue.SetClickHandler(ShowInitiativeBonusHelp); Container.Add(initValue); Container.Add(new StatsLabel(Stat.movement_speed, "TAG_MOVEMENT_RATE", uiParams.SpeedLabel, StatsUiTexture.ButtonInitiativeClick, StatsUiTexture.ButtonInitiativeHover, uiParams )); var speedValue = new StatsValue( GetMovementSpeedText, uiParams.SpeedValue, StatsUiTexture.ButtonInitiativeOutputClick, StatsUiTexture.ButtonInitiativeOutputHover, uiParams ); speedValue.SetClickHandler(() => GameSystems.Help.ShowTopic("TAG_MOVEMENT_RATE")); speedValue.TooltipText = null; Container.Add(speedValue); // Primary Weapon Attack Bonus Container.Add(new StatsLabel(Stat.melee_attack_bonus, "TAG_COMBAT", uiParams.PrimaryAtkLabel, StatsUiTexture.ButtonInitiativeClick, StatsUiTexture.ButtonInitiativeHover, uiParams )); var primaryAtkValue = new StatsValue( GetPrimaryWeaponAttackBonus, uiParams.PrimaryAtkValue, StatsUiTexture.ButtonInitiativeOutputClick, StatsUiTexture.ButtonInitiativeOutputHover, uiParams ); primaryAtkValue.SetClickHandler(ShowPrimaryWeaponAttackBonusHelp); Container.Add(primaryAtkValue); // Secondary Weapon Attack Bonus Container.Add(new StatsLabel(Stat.ranged_attack_bonus, "TAG_COMBAT", uiParams.SecondaryAtkLabel, StatsUiTexture.ButtonInitiativeClick, StatsUiTexture.ButtonInitiativeHover, uiParams )); var secondaryAtkValue = new StatsValue( GetSecondaryWeaponAttackBonus, uiParams.SecondaryAtkValue, StatsUiTexture.ButtonInitiativeOutputClick, StatsUiTexture.ButtonInitiativeOutputHover, uiParams ); secondaryAtkValue.SetClickHandler(ShowSecondaryWeaponAttackBonusHelp); Container.Add(secondaryAtkValue); }