You and three of your friends are amateur Dota 2 gamers. After watching The International of 2017 where the winning team won just shy of $11 million USD, you've decided to enter the professional scene. The problem is that you only have four players and a team requires five, so you'll have to seek one out. In the meantime, you'll practice with a bot of your own design.
Your bot will play the hero Pudge. In this kata, your goal is to create a constructor function and method that will handle his signature ability, the Meat Hook.
The Meat Hook is a bloody hook that Pudge launches toward a unit or location. The hook will snag the first unit it encounters, dragging the unit back to Pudge and dealing damage if it is an enemy.
MEAT HOOK STATS:
(distance measured in unit value "dst")
Speed: 1450 dst/second
Max Distance @ Level:
Level 1: 1100
Level 2: 1200
Level 3: 1300
Level 4: 1400
The name of your method will be meatHook
(JavaScript) or meat_hook
(Python). It will receive an object representing an enemy hero which will include the following properties:
- speed: enemy's movement speed in
dst / second
- start: initial position given by
x
andy
Cartesian coordinates - end: "estimated" destination given by
x
andy
values
Note: the property end
is stated as "estimated" because it is not to be treated as a line segment ending at end
, but as a ray with the origin at start
. In other words, assume that the enemy's path continues beyond the end
point, indefinitely.
An array/list of length 2
comprised of:
- contact point (
[x,y]
) of the hookshot if the enemy can be hooked (rounded to nearest integers) - hook launch time rounded to the nearest millisecond
If the enemy cannot be hooked, return null
(JavaScript) or None
(Python).
At level 1, the enemy is out of range. At level 4, the enemy can be hooked at any point along the green line segment in the shaded sector.
- Pudge's
[x,y]
position is fixed at[0,0]
- Your function should hook at the earliest possible point when the enemy unit comes into range
In the image above, Pudge should hook as close to point A as possible - Enemy's
speed
will always fall in the range:550 >= speed >= 270
- Enemy's
start
position will always be outside Pudge's hook range - Enemy's path (with indeterminate destination) will always cross at least one axis
- After every 10 successful hookshots, Pudge levels up; each level-up increases his hook range (refer to
MEAT HOOK STATS
above) - Pudge begins at level
1
- Inputs will always be valid
let pudge = new Pudge();
let test = {speed: 325, start: [1800,240], end: [200,-1025]};
pudge.meatHook(test); // [[1039, -362], 2227]
pudge = Pudge()
test = {speed: 325, start: [1800,240], end: [200,-1025]}
pudge.meat_hook(test) # [[1039, -362], 2227]
If you enjoyed this kata, be sure to check out my other katas.