Skip to content

Commit

Permalink
Merge pull request #2635 from sylvainpolletvillard/remove-mega
Browse files Browse the repository at this point in the history
remove mega from ultra category
  • Loading branch information
sylvainpolletvillard authored Jan 5, 2025
2 parents 35d36d3 + ff4d696 commit 3371794
Show file tree
Hide file tree
Showing 28 changed files with 409 additions and 296 deletions.
111 changes: 87 additions & 24 deletions app/core/abilities/abilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,13 @@ import { getFirstAvailablePositionInBench, isOnBench } from "../../utils/board"
import { distanceC, distanceE, distanceM } from "../../utils/distance"
import { repeat } from "../../utils/function"
import { logger } from "../../utils/logger"
import { calcAngleDegrees, clamp, max, min } from "../../utils/number"
import {
calcAngleDegrees,
clamp,
isBetween,
max,
min
} from "../../utils/number"
import { OrientationArray, effectInLine } from "../../utils/orientation"
import {
chance,
Expand Down Expand Up @@ -1617,15 +1623,31 @@ export class HighJumpKickStrategy extends AbilityStrategy {
crit: boolean
) {
super.process(pokemon, state, board, target, crit)
const damage = [50, 100, 200][pokemon.stars - 1] ?? 200
const ppStolen = max(70)(target.pp)
const damage = [15, 30, 60][pokemon.stars - 1] ?? 60
const ppStolen = max(50)(target.pp)
pokemon.addPP(ppStolen, pokemon, 0, false)
target.addPP(-ppStolen, pokemon, 0, false)
target.count.manaBurnCount++
target.handleSpecialDamage(damage, board, AttackType.SPECIAL, pokemon, crit)
}
}

export class TropKickStrategy extends AbilityStrategy {
process(
pokemon: PokemonEntity,
state: PokemonState,
board: Board,
target: PokemonEntity,
crit: boolean
) {
super.process(pokemon, state, board, target, crit)
const damage = [50, 100, 200][pokemon.stars - 1] ?? 200
const atkDebuff = [3, 5, 7][pokemon.stars - 1] ?? 7
target.addAttack(-atkDebuff, pokemon, 1, crit)
target.handleSpecialDamage(damage, board, AttackType.SPECIAL, pokemon, crit)
}
}

export class GrassWhistleStrategy extends AbilityStrategy {
process(
pokemon: PokemonEntity,
Expand Down Expand Up @@ -1810,13 +1832,15 @@ export class HyperVoiceStrategy extends AbilityStrategy {
) {
super.process(pokemon, state, board, target, crit)

const damage = [30, 60, 150][pokemon.stars - 1] ?? 200
const damage = [25, 50, 100][pokemon.stars - 1] ?? 200
const confusionDuration = [1000, 2000, 3000][pokemon.stars - 1] ?? 3

board.forEach((x: number, y: number, tg: PokemonEntity | undefined) => {
if (tg && pokemon.team != tg.team && target.positionY == y) {
tg.handleSpecialDamage(damage, board, AttackType.SPECIAL, pokemon, crit)
tg.status.triggerConfusion(confusionDuration, tg, pokemon)
if (chance(0.3, pokemon)) {
tg.status.triggerConfusion(confusionDuration, tg, pokemon)
}
}
})
}
Expand Down Expand Up @@ -1866,7 +1890,7 @@ export class VoltSwitchStrategy extends AbilityStrategy {
crit: boolean
) {
super.process(pokemon, state, board, target, crit)
const damage = [30, 60, 120][pokemon.stars - 1] ?? 120
const damage = [25, 50, 100][pokemon.stars - 1] ?? 100
const farthestCoordinate =
board.getFarthestTargetCoordinateAvailablePlace(pokemon)

Expand Down Expand Up @@ -3790,6 +3814,26 @@ export class StompStrategy extends AbilityStrategy {
}
}

export class HornDrillStrategy extends AbilityStrategy {
process(
pokemon: PokemonEntity,
state: PokemonState,
board: Board,
target: PokemonEntity,
crit: boolean
) {
super.process(pokemon, state, board, target, crit)
const damageFactor = [3, 4, 5][pokemon.stars - 1] ?? 5
let damage = pokemon.atk * damageFactor
const executeChance =
0.3 * (1 + min(0)((pokemon.atk - target.atk) / target.atk))
if (chance(executeChance, pokemon)) {
damage = 9999
}
target.handleSpecialDamage(damage, board, AttackType.SPECIAL, pokemon, crit)
}
}

export class PaybackStrategy extends AbilityStrategy {
process(
pokemon: PokemonEntity,
Expand Down Expand Up @@ -8411,11 +8455,9 @@ export class SheerColdStrategy extends AbilityStrategy {
crit: boolean
) {
super.process(pokemon, state, board, target, crit)
let executeChance = clamp(
0.3 + min(0)((pokemon.life - target.life) / target.life),
0,
1
)
let executeChance =
([0.1, 0.2, 0.3][pokemon.stars - 1] ?? 0.3) *
(1 + min(0)((pokemon.life - target.life) / target.life))
if (target.types.has(Synergy.ICE)) executeChance = 0
else if (target.status.freeze) executeChance = 1

Expand Down Expand Up @@ -9801,7 +9843,7 @@ export class GlaiveRushStrategy extends AbilityStrategy {
crit: boolean
) {
super.process(pokemon, state, board, target, crit, true)
const damage = pokemon.stars === 3 ? 150 : pokemon.stars === 2 ? 80 : 40
const damage = [50, 100, 200][pokemon.stars - 1] ?? 200
pokemon.status.triggerArmorReduction(6000, pokemon)

target.handleSpecialDamage(
Expand All @@ -9812,19 +9854,38 @@ export class GlaiveRushStrategy extends AbilityStrategy {
crit
)

const availablePlacesAroundTarget = board
.getAdjacentCells(target.positionX, target.positionY, false)
.filter((cell) => cell.value === undefined)
.sort(
(a, b) =>
distanceM(b.x, b.y, pokemon.positionX, pokemon.positionY) -
distanceM(a.x, a.y, pokemon.positionX, pokemon.positionY)
const destinationRow =
pokemon.team === Team.RED_TEAM
? pokemon.positionY === 0
? BOARD_HEIGHT - 1
: 0
: pokemon.positionY === BOARD_HEIGHT - 1
? 0
: BOARD_HEIGHT - 1

const enemiesHit = board.cells.filter(
(enemy) =>
enemy &&
enemy.team !== pokemon.team &&
enemy.positionX === pokemon.positionX &&
isBetween(pokemon.positionY, destinationRow)(enemy.positionY)
) as PokemonEntity[]
enemiesHit.forEach((enemy) => {
enemy.handleSpecialDamage(
damage,
board,
AttackType.PHYSICAL,
pokemon,
crit
)
if (availablePlacesAroundTarget.length > 0) {
const behindTargetPlace = availablePlacesAroundTarget[0]
if (behindTargetPlace) {
pokemon.moveTo(behindTargetPlace.x, behindTargetPlace.y, board)
}
})

const destination = board.getClosestAvailablePlace(
pokemon.positionX,
destinationRow
)
if (destination) {
pokemon.moveTo(destination.x, destination.y, board)
}
}
}
Expand Down Expand Up @@ -11231,6 +11292,7 @@ export const AbilityStrategies: { [key in Ability]: AbilityStrategy } = {
[Ability.FAIRY_WIND]: new FairyWindStrategy(),
[Ability.DISARMING_VOICE]: new DisarmingVoiceStrategy(),
[Ability.HIGH_JUMP_KICK]: new HighJumpKickStrategy(),
[Ability.TROP_KICK]: new TropKickStrategy(),
[Ability.GRASS_WHISTLE]: new GrassWhistleStrategy(),
[Ability.TRI_ATTACK]: new TriAttackStrategy(),
[Ability.ECHO]: new EchoStrategy(),
Expand Down Expand Up @@ -11268,6 +11330,7 @@ export const AbilityStrategies: { [key in Ability]: AbilityStrategy } = {
[Ability.ROOT]: new RootStrategy(),
[Ability.TORMENT]: new TormentStrategy(),
[Ability.STOMP]: new StompStrategy(),
[Ability.HORN_DRILL]: new HornDrillStrategy(),
[Ability.PAYBACK]: new PaybackStrategy(),
[Ability.NIGHT_SLASH]: new NightSlashStrategy(),
[Ability.KOWTOW_CLEAVE]: new KowtowCleaveStrategy(),
Expand Down
Loading

0 comments on commit 3371794

Please sign in to comment.