Add minimum speed requirement for tackle execution
- Players must be moving at least 2 m/s to execute a tackle - Add TACKLE_MIN_SPEED constant (2 m/s) in constants.ts - Add Player.getCurrentSpeed() method to expose current speed - Check tackler speed in executeTackle() before attempting tackle - Log speed in tackle debug output for tuning 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
00d3a0a4ea
commit
549ac400e0
@ -68,3 +68,4 @@ export const TACKLE_SUCCESS_MODIFIER = 1; // Multiplier for tackle succ
|
||||
export const TACKLE_PUCK_LOOSE_CHANCE = 0.6; // Chance puck becomes loose after tackle
|
||||
export const TACKLE_COOLDOWN = 1000; // ms - time between tackles for same player
|
||||
export const TACKLE_FALL_DURATION = 500; // ms - time player stays down after being tackled
|
||||
export const TACKLE_MIN_SPEED = 2; // m/s - minimum speed required to execute tackle
|
||||
|
||||
@ -324,6 +324,13 @@ export class Player extends Phaser.GameObjects.Container {
|
||||
this.body.setVelocity(0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current speed in m/s
|
||||
*/
|
||||
public getCurrentSpeed(): number {
|
||||
return this.currentSpeed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update debug visualizations (target position and path line)
|
||||
*/
|
||||
|
||||
@ -17,7 +17,8 @@ import {
|
||||
PUCK_PICKUP_RADIUS,
|
||||
SHOT_SPEED,
|
||||
TACKLE_SUCCESS_MODIFIER,
|
||||
TACKLE_PUCK_LOOSE_CHANCE
|
||||
TACKLE_PUCK_LOOSE_CHANCE,
|
||||
TACKLE_MIN_SPEED
|
||||
} from '../config/constants';
|
||||
import { Goal } from './Goal';
|
||||
import { Puck } from '../entities/Puck';
|
||||
@ -315,6 +316,16 @@ export class GameScene extends Phaser.Scene {
|
||||
* Execute tackle using tackling skill vs balance skill
|
||||
*/
|
||||
private executeTackle(tackler: Player, tackled: Player) {
|
||||
// Check if tackler has sufficient speed to execute tackle
|
||||
const tacklerSpeed = tackler.getCurrentSpeed();
|
||||
|
||||
if (tacklerSpeed < TACKLE_MIN_SPEED) {
|
||||
console.log(
|
||||
`[Tackle] ${tackler.id} moving too slow (${tacklerSpeed.toFixed(1)} m/s < ${TACKLE_MIN_SPEED} m/s) - tackle impossible`
|
||||
);
|
||||
return; // Tackle cannot occur
|
||||
}
|
||||
|
||||
// Calculate tackle success based on tackling vs balance
|
||||
// Formula: (tackling / (tackling + balance)) * modifier
|
||||
const tacklerSkill = tackler.attributes.tackling;
|
||||
@ -324,7 +335,7 @@ export class GameScene extends Phaser.Scene {
|
||||
const success = Math.random() < successChance;
|
||||
|
||||
console.log(
|
||||
`[Tackle] ${tackler.id} (tackling: ${tacklerSkill}) tackles ${tackled.id} (balance: ${tackledBalance}) - ${success ? 'SUCCESS' : 'FAILED'} (${(successChance * 100).toFixed(1)}%)`
|
||||
`[Tackle] ${tackler.id} (tackling: ${tacklerSkill}, speed: ${tacklerSpeed.toFixed(1)} m/s) tackles ${tackled.id} (balance: ${tackledBalance}) - ${success ? 'SUCCESS' : 'FAILED'} (${(successChance * 100).toFixed(1)}%)`
|
||||
);
|
||||
|
||||
// Mark tackle performed (cooldown starts)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user