Skip to content

Commit

Permalink
move attackSpeed out of EquipmentStats
Browse files Browse the repository at this point in the history
  • Loading branch information
LlemonDuck committed Nov 26, 2024
1 parent 1a351cb commit 8ce9815
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/app/components/player/bonuses/OtherBonuses.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ const OtherBonuses: React.FC<{ computedStats: EquipmentBonuses }> = observer(({
disabled={!prefs.manualMode}
name="Attack Speed"
image={attackSpeed}
value={player.bonuses.attack_speed}
className={`${(player.bonuses.attack_speed !== computedStats.bonuses.attack_speed) ? 'bg-yellow-200 dark:bg-yellow-500' : ''}`}
onChange={(v) => store.updatePlayer({ bonuses: { attack_speed: v } })}
value={player.attackSpeed}
className={`${(player.attackSpeed !== computedStats.attackSpeed) ? 'bg-yellow-200 dark:bg-yellow-500' : ''}`}
onChange={(v) => store.updatePlayer({ attackSpeed: v })}
min={1}
/>
</div>
Expand Down
6 changes: 3 additions & 3 deletions src/lib/Equipment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { sum } from 'd3-array';
import equipment from '../../cdn/json/equipment.json';
import generatedEquipmentAliases from './EquipmentAliases';

export type EquipmentBonuses = Pick<Player, 'bonuses' | 'offensive' | 'defensive'>;
export type EquipmentBonuses = Pick<Player, 'bonuses' | 'offensive' | 'defensive' | 'attackSpeed'>;

/**
* All available equipment that a player can equip.
Expand Down Expand Up @@ -287,7 +287,6 @@ export const calculateEquipmentBonusesFromGear = (player: Player, monster: Monst
magic_str: 0,
ranged_str: 0,
prayer: 0,
attack_speed: DEFAULT_ATTACK_SPEED,
},
offensive: {
slash: 0,
Expand All @@ -303,6 +302,7 @@ export const calculateEquipmentBonusesFromGear = (player: Player, monster: Monst
ranged: 0,
magic: 0,
},
attackSpeed: DEFAULT_ATTACK_SPEED,
};

// canonicalize all items first, otherwise ammoApplicability etc calls may return incorrect results later
Expand Down Expand Up @@ -380,7 +380,7 @@ export const calculateEquipmentBonusesFromGear = (player: Player, monster: Monst
totals.bonuses.ranged_str += 1;
}

totals.bonuses.attack_speed = calculateAttackSpeed(player, monster);
totals.attackSpeed = calculateAttackSpeed(player, monster);

return totals;
};
Expand Down
2 changes: 1 addition & 1 deletion src/lib/PlayerVsNPCCalc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1864,7 +1864,7 @@ export default class PlayerVsNPCCalc extends BaseCalc {
* Returns the player's attack speed.
*/
public getAttackSpeed(): number {
return this.player.bonuses.attack_speed
return this.player.attackSpeed
?? calculateAttackSpeed(this.player, this.monster);
}

Expand Down
2 changes: 1 addition & 1 deletion src/state.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@ export const generateEmptyPlayer = (name?: string): Player => ({
herblore: 0,
},
equipment: generateInitialEquipment(),
attackSpeed: DEFAULT_ATTACK_SPEED,
prayers: [],
bonuses: {
str: 0,
ranged_str: 0,
magic_str: 0,
prayer: 0,
attack_speed: DEFAULT_ATTACK_SPEED,
},
defensive: {
stab: 0,
Expand Down
2 changes: 1 addition & 1 deletion src/types/Player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ export interface PlayerBonuses {
ranged_str: number;
magic_str: number;
prayer: number;
attack_speed: number;
}

export interface PlayerDefensive {
Expand Down Expand Up @@ -94,6 +93,7 @@ export interface Player extends EquipmentStats {
*/
boosts: PlayerSkills;
equipment: PlayerEquipment;
attackSpeed: number;
prayers: Prayer[];
buffs: {
/**
Expand Down

0 comments on commit 8ce9815

Please sign in to comment.