diff --git a/app/core/abilities/abilities.ts b/app/core/abilities/abilities.ts index bf0bb8e030..5dfa7d0718 100644 --- a/app/core/abilities/abilities.ts +++ b/app/core/abilities/abilities.ts @@ -46,7 +46,7 @@ import { } from "../../types/Config" import Board from "../board" -import PokemonEntity from "../pokemon-entity" +import { PokemonEntity } from "../pokemon-entity" import PokemonState from "../pokemon-state" import PokemonFactory from "../../models/pokemon-factory" diff --git a/app/core/abilities/ability-strategy.ts b/app/core/abilities/ability-strategy.ts index 09843914f7..48dda1e03b 100644 --- a/app/core/abilities/ability-strategy.ts +++ b/app/core/abilities/ability-strategy.ts @@ -5,7 +5,7 @@ import { Item } from "../../types/enum/Item" import { Passive } from "../../types/enum/Passive" import { Synergy } from "../../types/enum/Synergy" import Board from "../board" -import PokemonEntity from "../pokemon-entity" +import { PokemonEntity } from "../pokemon-entity" import PokemonState from "../pokemon-state" export class AbilityStrategy { diff --git a/app/core/abilities/hidden-power.ts b/app/core/abilities/hidden-power.ts index 46b20c11fe..16144f389a 100644 --- a/app/core/abilities/hidden-power.ts +++ b/app/core/abilities/hidden-power.ts @@ -6,7 +6,7 @@ import { getUnownsPoolPerStage, Pkm } from "../../types/enum/Pokemon" import { Synergy } from "../../types/enum/Synergy" import { pickNRandomIn, pickRandomIn } from "../../utils/random" import Board from "../board" -import PokemonEntity from "../pokemon-entity" +import { PokemonEntity } from "../pokemon-entity" import PokemonState from "../pokemon-state" import { PRECOMPUTED_POKEMONS_PER_TYPE_AND_CATEGORY } from "../../models/precomputed" import { AbilityStrategies } from "./abilities" diff --git a/app/core/attacking-state.ts b/app/core/attacking-state.ts index 1d72b66dcc..65610138ed 100644 --- a/app/core/attacking-state.ts +++ b/app/core/attacking-state.ts @@ -2,7 +2,7 @@ import { Item } from "../types/enum/Item" import { AttackType } from "../types/enum/Game" import { Effect } from "../types/enum/Effect" import Board from "./board" -import PokemonEntity from "./pokemon-entity" +import { PokemonEntity } from "./pokemon-entity" import PokemonState from "./pokemon-state" import { PokemonActionState } from "../types/enum/Game" import { chance } from "../utils/random" diff --git a/app/core/board.ts b/app/core/board.ts index b426887b87..3a80017162 100644 --- a/app/core/board.ts +++ b/app/core/board.ts @@ -7,7 +7,7 @@ import { distanceC } from "../utils/distance" import { logger } from "../utils/logger" import { OrientationArray, OrientationVector } from "../utils/orientation" import { pickRandomIn } from "../utils/random" -import PokemonEntity from "./pokemon-entity" +import { PokemonEntity, getStrongestUnit } from "./pokemon-entity" export type Cell = { x: number @@ -326,27 +326,9 @@ export default class Board { } getStrongestUnitOnBoard(team?: number): PokemonEntity | undefined { - /* - strongest is defined as: - 1) number of items - 2) stars level - 3) rarity cost - */ - let strongest, - bestScore = 0 - this.forEach((x, y, pokemon) => { - if (pokemon && (pokemon.team === team || team === undefined)) { - let score = 0 - score += 100 * pokemon.items.size - score += 10 * pokemon.stars - score += PokemonFactory.getSellPrice(pokemon.name) - - if (score > bestScore) { - bestScore = score - strongest = pokemon - } - } - }) - return strongest + const candidates = this.cells.filter( + (cell) => cell && (cell.team === team || team === undefined) + ) as PokemonEntity[] + return getStrongestUnit(candidates) } } diff --git a/app/core/idle-state.ts b/app/core/idle-state.ts index af49895dcb..5e5b98a332 100644 --- a/app/core/idle-state.ts +++ b/app/core/idle-state.ts @@ -1,7 +1,7 @@ import { PokemonActionState } from "../types/enum/Game" import { Passive } from "../types/enum/Passive" import Board from "./board" -import PokemonEntity from "./pokemon-entity" +import { PokemonEntity } from "./pokemon-entity" import PokemonState from "./pokemon-state" export class IdleState extends PokemonState { diff --git a/app/core/moving-state.ts b/app/core/moving-state.ts index 5ae9ea2c53..1769a21f1f 100644 --- a/app/core/moving-state.ts +++ b/app/core/moving-state.ts @@ -1,5 +1,5 @@ import Board from "./board" -import PokemonEntity from "./pokemon-entity" +import { PokemonEntity } from "./pokemon-entity" import PokemonState from "./pokemon-state" import { BoardEvent, PokemonActionState } from "../types/enum/Game" import { Synergy } from "../types/enum/Synergy" diff --git a/app/core/pokemon-entity.ts b/app/core/pokemon-entity.ts index 468842af1d..25f3b54dfe 100644 --- a/app/core/pokemon-entity.ts +++ b/app/core/pokemon-entity.ts @@ -45,7 +45,7 @@ import Player from "../models/colyseus-models/player" import { values } from "../utils/schemas" import { AbilityStrategies } from "./abilities/abilities" -export default class PokemonEntity extends Schema implements IPokemonEntity { +export class PokemonEntity extends Schema implements IPokemonEntity { @type("boolean") shiny: boolean @type("uint8") positionX: number @type("uint8") positionY: number @@ -1201,3 +1201,30 @@ export default class PokemonEntity extends Schema implements IPokemonEntity { } } } + +export function getStrongestUnit(pokemons: PokemonEntity[]): PokemonEntity { + /* + strongest is defined as: + 1) number of items + 2) stars level + 3) rarity cost + */ + let strongest, + bestScore = 0 + pokemons.forEach((pokemon) => { + const score = getUnitScore(pokemon) + if (score > bestScore) { + bestScore = score + strongest = pokemon + } + }) + return strongest +} + +export function getUnitScore(pokemon: PokemonEntity | IPokemon) { + let score = 0 + score += 100 * pokemon.items.size + score += 10 * pokemon.stars + score += PokemonFactory.getSellPrice(pokemon.name) + return score +} diff --git a/app/core/pokemon-state.ts b/app/core/pokemon-state.ts index 31d3cb3f7d..f2b62880b7 100644 --- a/app/core/pokemon-state.ts +++ b/app/core/pokemon-state.ts @@ -8,7 +8,7 @@ import { Team } from "../types/enum/Game" import Board from "./board" -import PokemonEntity from "./pokemon-entity" +import { PokemonEntity } from "./pokemon-entity" import { IPokemonEntity, Transfer } from "../types" import { Synergy, SynergyEffects } from "../types/enum/Synergy" import { pickRandomIn } from "../utils/random" @@ -16,7 +16,7 @@ import { logger } from "../utils/logger" import { Passive } from "../types/enum/Passive" import { Weather } from "../types/enum/Weather" import { max, min } from "../utils/number" -import { distanceC, distanceM } from "../utils/distance" +import { distanceM } from "../utils/distance" import { FIGHTING_PHASE_DURATION } from "../types/Config" export default class PokemonState { diff --git a/app/core/simulation.ts b/app/core/simulation.ts index d4f690ebb7..ffe008b89c 100644 --- a/app/core/simulation.ts +++ b/app/core/simulation.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/no-extra-semi */ import Board from "./board" import { Schema, MapSchema, type, SetSchema } from "@colyseus/schema" -import PokemonEntity from "./pokemon-entity" +import { getUnitScore, PokemonEntity } from "./pokemon-entity" import PokemonFactory from "../models/pokemon-factory" import { Pokemon } from "../models/colyseus-models/pokemon" import { Berries, CompletedItems, Item } from "../types/enum/Item" @@ -152,7 +152,7 @@ export default class Simulation extends Schema implements ISimulation { bugTeam.push(pkm) } }) - bugTeam.sort((a, b) => b.hp - a.hp) + bugTeam.sort((a, b) => getUnitScore(b) - getUnitScore(a)) let numberToSpawn = 0 if (effects.has(Effect.COCOON)) { diff --git a/app/models/colyseus-models/pokemon.ts b/app/models/colyseus-models/pokemon.ts index 7239edecb0..658f706233 100644 --- a/app/models/colyseus-models/pokemon.ts +++ b/app/models/colyseus-models/pokemon.ts @@ -41,7 +41,7 @@ import PokemonFactory from "../pokemon-factory" import { distanceM } from "../../utils/distance" import Simulation from "../../core/simulation" import { AbilityStrategies } from "../../core/abilities/abilities" -import PokemonEntity from "../../core/pokemon-entity" +import { PokemonEntity } from "../../core/pokemon-entity" export class Pokemon extends Schema implements IPokemon { @type("string") id: string diff --git a/app/models/colyseus-models/status.ts b/app/models/colyseus-models/status.ts index 462d2a652b..8ce60653f6 100644 --- a/app/models/colyseus-models/status.ts +++ b/app/models/colyseus-models/status.ts @@ -1,6 +1,6 @@ import { Schema, type } from "@colyseus/schema" import Board from "../../core/board" -import PokemonEntity from "../../core/pokemon-entity" +import { PokemonEntity } from "../../core/pokemon-entity" import { IPokemonEntity, IStatus, Transfer } from "../../types" import { Effect } from "../../types/enum/Effect" import { AttackType } from "../../types/enum/Game" diff --git a/app/public/dist/client/changelog/patch-4.5.md b/app/public/dist/client/changelog/patch-4.5.md index 05ccd29281..c5daf6066d 100644 --- a/app/public/dist/client/changelog/patch-4.5.md +++ b/app/public/dist/client/changelog/patch-4.5.md @@ -67,6 +67,7 @@ To begin with, Great Ball tier (ELO > 1100) ranked matches will start every 4 ho - increased Flinch duration to 3 seconds - add AP scaling on kill - increase Monster 6 bonuses: when knocking down its target, gain 10 Attack, 30% AP and 100 max HP +- Bug: Your ~~most HP~~ strongest units are cloned. Strongest is defined by 1) number of items 2) unit tier 3) unit rarity # Changes to Items diff --git a/app/public/dist/client/locales/bg/translation.json b/app/public/dist/client/locales/bg/translation.json index 9076b9e5bf..cfd9660529 100644 --- a/app/public/dist/client/locales/bg/translation.json +++ b/app/public/dist/client/locales/bg/translation.json @@ -1515,7 +1515,7 @@ "MONSTER": "MONSTER покемоните могат да FLINCH своите опоненти. Всеки път, когато получат нокаут, те получават ATK, лекуват и увеличават максималния си HP и нарастват по размер.", "HUMAN": "Целият ви екип лекува за процент от щетите, които нанасят с атаки и способности", "AQUATIC": "Водните покемони имат шанс да откраднат PP от целта си при всяка основна атака", - "BUG": "В началото на битката покемоните с бъгове с най-много HP се дублират", + "BUG": "В началото на битката вашите най-силни BUG покемони се клонират", "FLYING": "Летящите покемони отлитат, когато паднат под определено количество HP", "FLORA": "Когато първият флорален покемон е мъртъв, цвете ще възкръсне от гроба му...", "ROCK": "Рок покемоните получават DEF и по-добре се съпротивляват на критични щети", diff --git a/app/public/dist/client/locales/de/translation.json b/app/public/dist/client/locales/de/translation.json index f4dbe5852c..867a13494a 100644 --- a/app/public/dist/client/locales/de/translation.json +++ b/app/public/dist/client/locales/de/translation.json @@ -1514,7 +1514,7 @@ "MONSTER": "MONSTER Pokémons können ihre Gegner FLINCH. Jedes Mal, wenn sie einen KO erleiden, erhalten sie ATK, heilen sich, erhöhen ihre maximalen HP und werden größer.", "HUMAN": "Ihr gesamtes Team heilt sich um einen Prozentsatz des Schadens, den es durch Angriffe und Fähigkeiten verursacht", "AQUATIC": "Wasserpokémons haben bei jedem Basisangriff die Chance, ihrem Ziel PP zu stehlen", - "BUG": "Zu Beginn des Kampfes werden die Käfer-Pokémon mit den meisten HP dupliziert", + "BUG": "Zu Beginn des Kampfes werden Ihre stärksten BUG Pokémon geklont", "FLYING": "Flugpokémons fliegen weg, wenn sie unter eine bestimmte Menge an HP fallen", "FLORA": "Wenn das erste Flora-Pokémon tot ist, erhebt sich eine Blume aus seinem Grab ...", "ROCK": "Felspokémons erhalten DEF und widerstehen kritischem Schaden besser", diff --git a/app/public/dist/client/locales/en/translation.json b/app/public/dist/client/locales/en/translation.json index 38003ed206..3889ef26c7 100644 --- a/app/public/dist/client/locales/en/translation.json +++ b/app/public/dist/client/locales/en/translation.json @@ -1756,7 +1756,7 @@ "MONSTER": "MONSTER pokemons can FLINCH their opponents. Every time they get a KO, they gain ATK, heal and increase their max HP, and grow in size.", "HUMAN": "All your team heals for a percentage of the damage they deal with attacks and abilities", "AQUATIC": "AQUATIC pokemons have a chance to steal PP from their target at every basic attack", - "BUG": "At the start of the combat, the BUG pokemons with the most HP are duplicated", + "BUG": "At the start of the combat, your strongest BUG pokemons are cloned", "FLYING": "FLYING pokemons fly away when they fell under a certain amount of HP", "FLORA": "When the first FLORA pokemon is dead, a flower will rise from its grave...", "ROCK": "ROCK pokemons gain DEF and better resist to critical damage", diff --git a/app/public/dist/client/locales/es/translation.json b/app/public/dist/client/locales/es/translation.json index 50b7550b50..dc9bab7e06 100644 --- a/app/public/dist/client/locales/es/translation.json +++ b/app/public/dist/client/locales/es/translation.json @@ -1699,7 +1699,7 @@ "MONSTER": "Los pokemon MONSTER pueden dejar FLINCH a sus oponentes durante 2s. Cada vez que obtienen un KO, ganan ATK, se curan y aumentan su HP máximo, y crecen en tamaño.", "HUMAN": "Todo tu equipo se cura por un porcentaje del daño que infligen con ataques y habilidades", "AQUATIC": "Los Pokémon acuáticos tienen la posibilidad de robar PP de su objetivo en cada ataque básico.", - "BUG": "Al inicio del combate se duplican los pokemon bicho con más HP", + "BUG": "Al comienzo del combate, se clonan tus Pokémon BUG más fuertes.", "FLYING": "Los Pokémon voladores se van volando cuando caen por debajo de una cierta cantidad de HP.", "FLORA": "Cuando el primer pokemon flora muera, una flor se levantará de su tumba...", "ROCK": "Los Pokémon Roca ganan DEF y resisten mejor el daño crítico.", diff --git a/app/public/dist/client/locales/fr/translation.json b/app/public/dist/client/locales/fr/translation.json index 89c1d0014b..bab6f35038 100644 --- a/app/public/dist/client/locales/fr/translation.json +++ b/app/public/dist/client/locales/fr/translation.json @@ -1756,7 +1756,7 @@ "MONSTER": "Les pokémons MONSTER ont une chance de causer FLINCH sur leur cible. Chaque fois qu'ils mettent KO une unité adverse, ils gagnent en ATK, se soignent et augmentent leurs HP max, et grossissent en taille.", "HUMAN": "Toute votre équipe guérit d'un pourcentage des dégâts qu'elle inflige avec les attaques et capacités", "AQUATIC": "Les pokémons AQUATIC ont une chance de voler des PP à leur cible à chaque attaque de base", - "BUG": "Au début du combat, les pokemons BUG avec le plus de HP sont dupliqués", + "BUG": "Au début du combat, vos pokemons BUG les plus forts sont clonés", "FLYING": "Les pokémons FLYING s'envolent lorsqu'ils tombent sous une certaine quantité de HP", "FLORA": "Quand le premier pokémon FLORA est mort, une fleur sort de sa tombe...", "ROCK": "Les pokémons ROCK gagnent en DEF et résistent mieux aux dégâts critiques", diff --git a/app/public/dist/client/locales/it/translation.json b/app/public/dist/client/locales/it/translation.json index f130a928b9..40fa4dff49 100644 --- a/app/public/dist/client/locales/it/translation.json +++ b/app/public/dist/client/locales/it/translation.json @@ -1515,7 +1515,7 @@ "MONSTER": "I Pokemon MONSTER possono FLINCH i loro avversari. Ogni volta che ottengono un KO, guadagnano ATK, guariscono e aumentano i loro HP massimi e crescono di dimensioni.", "HUMAN": "Tutta la tua squadra guarisce per una percentuale del danno che infligge con attacchi e abilità", "AQUATIC": "I pokemon acquatici hanno la possibilità di rubare PP al loro bersaglio ad ogni attacco base", - "BUG": "All'inizio del combattimento, i Pokémon coleottero con più HP vengono duplicati", + "BUG": "All'inizio del combattimento, i tuoi Pokemon BUG più forti verranno duplicati", "FLYING": "I pokemon volanti volano via quando cadono sotto una certa quantità di HP", "FLORA": "Quando il primo pokemon flora sarà morto, un fiore risorgerà dalla sua tomba...", "ROCK": "I pokemon roccia guadagnano DEF e resistono meglio ai danni critici", diff --git a/app/public/dist/client/locales/ja/translation.json b/app/public/dist/client/locales/ja/translation.json index 081e34e488..eabade5ad8 100644 --- a/app/public/dist/client/locales/ja/translation.json +++ b/app/public/dist/client/locales/ja/translation.json @@ -1495,7 +1495,7 @@ "MONSTER": "MONSTER ポケモンは対戦相手を_ひるませることができます。 KO を受けるたびに、ATK が増加し、回復して最大 HP が増加し、サイズが大きくなります。", "HUMAN": "チーム全員が攻撃や能力で与えたダメージの一定割合を回復します", "AQUATIC": "水生ポケモンは、基本攻撃ごとにターゲットから PP を盗むチャンスがあります。", - "BUG": "戦闘開始時にHPが最も多いむしポケモンが複製される", + "BUG": "戦闘の開始時に、あなたの最強の BUG ポケモンが複製されます", "FLYING": "飛行ポケモンはHPが一定以下になると飛んでいきます。", "FLORA": "最初のフローラポケモンが死ぬと、墓から花が現れます...", "ROCK": "いわポケモンはDEFを獲得し、クリティカルダメージに対する耐性が向上します", diff --git a/app/public/dist/client/locales/nl/translation.json b/app/public/dist/client/locales/nl/translation.json index f8ace699db..8d97383502 100644 --- a/app/public/dist/client/locales/nl/translation.json +++ b/app/public/dist/client/locales/nl/translation.json @@ -1496,7 +1496,7 @@ "MONSTER": "MONSTER Pokémon kunnen hun tegenstanders FLINCH. Elke keer dat ze een KO krijgen, krijgen ze ATK, genezen ze en verhogen ze hun maximale HP, en worden ze groter.", "HUMAN": "Je hele team geneest voor een percentage van de schade die ze aanrichten met aanvallen en vaardigheden", "AQUATIC": "Aquatische pokemons hebben bij elke basisaanval de kans om PP van hun doelwit te stelen", - "BUG": "Aan het begin van het gevecht worden de bug-pokemons met de meeste HP gedupliceerd", + "BUG": "Aan het begin van het gevecht worden je sterkste BUG Pokémon gekloond", "FLYING": "Vliegende pokemons vliegen weg als ze onder een bepaalde hoeveelheid HP vallen", "FLORA": "Als de eerste flora-pokemon dood is, zal er een bloem uit zijn graf opstaan...", "ROCK": "Rock-pokemons krijgen DEF en zijn beter bestand tegen kritieke schade", diff --git a/app/public/dist/client/locales/pt/translation.json b/app/public/dist/client/locales/pt/translation.json index 858ff36266..8dfe867a4e 100644 --- a/app/public/dist/client/locales/pt/translation.json +++ b/app/public/dist/client/locales/pt/translation.json @@ -1492,7 +1492,7 @@ "MONSTER": "Pokémon MONSTER podem FLINCH seus oponentes. Cada vez que são nocauteados, eles ganham ATK, curam e aumentam seu HP máximo e aumentam de tamanho.", "HUMAN": "Toda a sua equipe cura uma porcentagem do dano causado com ataques e habilidades", "AQUATIC": "Pokémon aquáticos têm chance de roubar PP de seu alvo a cada ataque básico", - "BUG": "No início do combate, os pokémons bug com mais HP são duplicados", + "BUG": "No início do combate, seus pokémons BUG mais fortes são duplicados", "FLYING": "Os pokémons voadores voam para longe quando caem abaixo de uma certa quantidade de HP", "FLORA": "Quando o primeiro pokémon da flora estiver morto, uma flor surgirá de seu túmulo...", "ROCK": "Pokémons de pedra ganham DEF e resistem melhor a danos críticos", diff --git a/app/public/src/game/game-container.ts b/app/public/src/game/game-container.ts index 02ea5c1f2c..7381bc2767 100644 --- a/app/public/src/game/game-container.ts +++ b/app/public/src/game/game-container.ts @@ -16,7 +16,7 @@ import { NonFunctionPropNames, ISimplePlayer } from "../../../types" -import PokemonEntity from "../../../core/pokemon-entity" +import { PokemonEntity } from "../../../core/pokemon-entity" import { DesignTiled } from "../../../core/design" import { toast } from "react-toastify" import React from "react" diff --git a/app/utils/orientation.ts b/app/utils/orientation.ts index 36e2d18ca2..a0522835f4 100644 --- a/app/utils/orientation.ts +++ b/app/utils/orientation.ts @@ -1,5 +1,5 @@ import { Orientation } from "../types/enum/Game" -import PokemonEntity from "../core/pokemon-entity" +import { PokemonEntity } from "../core/pokemon-entity" import Board from "../core/board" export const OrientationVector: Record = {