Skip to content

Commit

Permalink
Copy strongest Bug (#1300)
Browse files Browse the repository at this point in the history
* remove obsolete translation key

* copy strongest bugs
  • Loading branch information
sylvainpolletvillard authored Dec 9, 2023
1 parent 64dae19 commit 19d228d
Show file tree
Hide file tree
Showing 24 changed files with 57 additions and 47 deletions.
2 changes: 1 addition & 1 deletion app/core/abilities/abilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
2 changes: 1 addition & 1 deletion app/core/abilities/ability-strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion app/core/abilities/hidden-power.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion app/core/attacking-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
28 changes: 5 additions & 23 deletions app/core/board.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
}
2 changes: 1 addition & 1 deletion app/core/idle-state.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion app/core/moving-state.ts
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
29 changes: 28 additions & 1 deletion app/core/pokemon-entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
4 changes: 2 additions & 2 deletions app/core/pokemon-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ 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"
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 {
Expand Down
4 changes: 2 additions & 2 deletions app/core/simulation.ts
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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)) {
Expand Down
2 changes: 1 addition & 1 deletion app/models/colyseus-models/pokemon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/models/colyseus-models/status.ts
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
1 change: 1 addition & 0 deletions app/public/dist/client/changelog/patch-4.5.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion app/public/dist/client/locales/bg/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -1515,7 +1515,7 @@
"MONSTER": "MONSTER покемоните могат да FLINCH своите опоненти. Всеки път, когато получат нокаут, те получават ATK, лекуват и увеличават максималния си HP и нарастват по размер.",
"HUMAN": "Целият ви екип лекува за процент от щетите, които нанасят с атаки и способности",
"AQUATIC": "Водните покемони имат шанс да откраднат PP от целта си при всяка основна атака",
"BUG": "В началото на битката покемоните с бъгове с най-много HP се дублират",
"BUG": "В началото на битката вашите най-силни BUG покемони се клонират",
"FLYING": "Летящите покемони отлитат, когато паднат под определено количество HP",
"FLORA": "Когато първият флорален покемон е мъртъв, цвете ще възкръсне от гроба му...",
"ROCK": "Рок покемоните получават DEF и по-добре се съпротивляват на критични щети",
Expand Down
2 changes: 1 addition & 1 deletion app/public/dist/client/locales/de/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion app/public/dist/client/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion app/public/dist/client/locales/es/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
2 changes: 1 addition & 1 deletion app/public/dist/client/locales/fr/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion app/public/dist/client/locales/it/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion app/public/dist/client/locales/ja/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -1495,7 +1495,7 @@
"MONSTER": "MONSTER ポケモンは対戦相手を_ひるませることができます。 KO を受けるたびに、ATK が増加し、回復して最大 HP が増加し、サイズが大きくなります。",
"HUMAN": "チーム全員が攻撃や能力で与えたダメージの一定割合を回復します",
"AQUATIC": "水生ポケモンは、基本攻撃ごとにターゲットから PP を盗むチャンスがあります。",
"BUG": "戦闘開始時にHPが最も多いむしポケモンが複製される",
"BUG": "戦闘の開始時に、あなたの最強の BUG ポケモンが複製されます",
"FLYING": "飛行ポケモンはHPが一定以下になると飛んでいきます。",
"FLORA": "最初のフローラポケモンが死ぬと、墓から花が現れます...",
"ROCK": "いわポケモンはDEFを獲得し、クリティカルダメージに対する耐性が向上します",
Expand Down
2 changes: 1 addition & 1 deletion app/public/dist/client/locales/nl/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion app/public/dist/client/locales/pt/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion app/public/src/game/game-container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion app/utils/orientation.ts
Original file line number Diff line number Diff line change
@@ -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<Orientation, [number, number]> = {
Expand Down

0 comments on commit 19d228d

Please sign in to comment.