Skip to content

Commit

Permalink
update for 25.2
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastientromp committed Jan 21, 2023
1 parent 705a884 commit 174c092
Show file tree
Hide file tree
Showing 19 changed files with 14,798 additions and 2,145 deletions.
12,933 changes: 12,912 additions & 21 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@firestone-hs/simulate-bgs-battle",
"version": "1.1.222",
"version": "1.1.231",
"description": "",
"scripts": {
"lint": "eslint --color --fix --ext .ts .",
Expand Down Expand Up @@ -28,7 +28,7 @@
],
"dependencies": {
"@firestone-hs/hs-replay-xml-parser": "0.0.46",
"@firestone-hs/reference-data": "^1.0.52",
"@firestone-hs/reference-data": "^1.0.54",
"cross-fetch": "^3.1.5",
"lodash.clonedeep": "^4.5.0",
"node-fetch": "^2.6.7"
Expand Down
6 changes: 6 additions & 0 deletions src/bgs-player-entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ export interface BgsPlayerEntity {
cardsInHand?: number;
avengeCurrent?: number;
avengeDefault?: number;
globalInfo?: BgsPlayerGlobalInfo;

deadEyeDamageDone?: number;
}

export interface BgsPlayerGlobalInfo {
EternalKnightsDeadThisGame: number;
UndeadAttackBonus: number;
}
5 changes: 4 additions & 1 deletion src/board-entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ export interface BoardEntity {
windfury?: boolean;
megaWindfury?: boolean;
stealth?: boolean;
enchantments?: { cardId: string; originEntityId?: number; timing: number; repeats?: number }[];
enchantments?: { cardId: string; originEntityId?: number; timing: number; repeats?: number; value?: number }[];
// For Build-An-Undead
additionalCards?: readonly string[];

// We only store the card id, because we want all the attack and other data to be computed at runtime, based on the
// current stats of the Fish
rememberedDeathrattles?: { cardId: string; timing: number; repeats: number }[];
Expand Down
50 changes: 13 additions & 37 deletions src/cards/cards-data.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,7 @@
import { AllCardsService, CardIds, GameTag, isBattlegroundsCard, Race, ReferenceCard } from '@firestone-hs/reference-data';
import { groupByFunction, pickRandom } from '../services/utils';
import { getRaceEnum, hasMechanic } from '../utils';
import { getRaceEnum, hasMechanic, isCorrectTribe } from '../utils';

export const AURA_ENCHANTMENTS: readonly string[][] = [
[CardIds.Kathranatir_BG21_039, CardIds.Kathranatir_GraspOfKathranatirEnchantment_BG21_039e],
[CardIds.KathranatirBattlegrounds, CardIds.Kathranatir_GraspOfKathranatirEnchantment_BG21_039_Ge],
[CardIds.MurlocWarleaderLegacy_BG_EX1_507, CardIds.MurlocWarleader_MrgglaarglLegacyEnchantment],
[CardIds.MurlocWarleaderLegacyBattlegrounds, CardIds.MurlocWarleader_MrgglaarglEnchantmentBattlegrounds],
[CardIds.SouthseaCaptainLegacy_BG_NEW1_027, CardIds.SouthseaCaptain_YarrrLegacyEnchantment],
[CardIds.SouthseaCaptainLegacyBattlegrounds, CardIds.SouthseaCaptain_YarrrEnchantmentBattlegrounds],
[
CardIds.LadySinestraBattlegrounds_TB_BaconShop_HERO_52_Buddy,
CardIds.DraconicBlessingEnchantmentBattlegrounds_TB_BaconShop_HERO_52_Buddy_e,
],
[
CardIds.LadySinestraBattlegrounds_TB_BaconShop_HERO_52_Buddy_G,
CardIds.DraconicBlessingEnchantmentBattlegrounds_TB_BaconShop_HERO_52_Buddy_G_e,
],
[CardIds.RotHideGnoll, CardIds.RotHideGnollEnchantment],
[CardIds.RotHideGnoll_G, CardIds.RotHideGnollEnchantment_G],
[CardIds.CyborgDrake, CardIds.CyborgDrake_Enchantment],
[CardIds.CyborgDrakeBattlegrounds, CardIds.CardIds.CyborgDrake_Enchantment_G],
];
// Auras are effects that are permanent (unlike deathrattles or "whenever" effects)
// and that stop once the origin entity leaves play (so it doesn't include buffs)
export const AURA_ORIGINS: readonly string[] = AURA_ENCHANTMENTS.map((pair) => pair[0]);
export const START_OF_COMBAT_CARD_IDS = [
CardIds.CorruptedMyrmidon,
CardIds.CorruptedMyrmidonBattlegrounds,
Expand All @@ -38,8 +15,8 @@ export const START_OF_COMBAT_CARD_IDS = [
CardIds.RedWhelpBattlegrounds,
CardIds.AmberGuardian,
CardIds.AmberGuardianBattlegrounds,
CardIds.InterrogatorWhitemane,
CardIds.InterrogatorWhitemaneBattlegrounds,
CardIds.InterrogatorWhitemane_BG24_704,
CardIds.InterrogatorWhitemane_BG24_704_G,
CardIds.Soulsplitter,
CardIds.SoulsplitterBattlegrounds,
];
Expand All @@ -56,7 +33,6 @@ export class CardsData {
// public sneedsSpawns: readonly string[];
// public treasureChestSpawns: readonly string[];
public pirateSpawns: readonly string[];
public auraOrigins: readonly string[];

private minionsForTier: { [key: string]: readonly ReferenceCard[] };

Expand Down Expand Up @@ -127,28 +103,28 @@ export class CardsData {
return 1;
case CardIds.FrostwolfLieutenant:
case CardIds.FrostwolfLieutenantBattlegrounds:
case CardIds.MechanoTank:
case CardIds.MechanoTankBattlegrounds:
case CardIds.PalescaleCrocolisk:
case CardIds.PalescaleCrocoliskBattlegrounds:
case CardIds.MechanoTank_BG21_023:
case CardIds.MechanoTank_BG21_023_G:
case CardIds.PalescaleCrocolisk_BG21_001:
case CardIds.PalescaleCrocolisk_BG21_001_G:
case CardIds.StormpikeLieutenant:
case CardIds.StormpikeLieutenantBattlegrounds:
case CardIds.VanndarStormpike_LeadTheStormpikes:
return 2;
case CardIds.BuddingGreenthumb_BG21_030:
case CardIds.BuddingGreenthumb_BG21_030_G:
case CardIds.BuddingGreenthumb:
case CardIds.BuddingGreenthumbBattlegrounds:
case CardIds.PashmarTheVengeful:
case CardIds.PashmarTheVengefulBattlegrounds:
case CardIds.WitchwingNestmatron_BG21_038:
case CardIds.WitchwingNestmatron_BG21_038_G:
case CardIds.WitchwingNestmatron:
case CardIds.WitchwingNestmatronBattlegrounds:
case CardIds.Drekthar_LeadTheFrostwolves:
return 3;
case CardIds.ImpatientDoomsayer:
case CardIds.ImpatientDoomsayerBattlegrounds:
case CardIds.Sisefin_BG21_009:
case CardIds.Sisefin_BG21_009_G:
case CardIds.TonyTwoTusk:
case CardIds.TonyTwoTuskBattlegrounds:
case CardIds.TonyTwoTusk_BG21_031:
case CardIds.TonyTwoTusk_BG21_031_G:
case CardIds.Onyxia_Broodmother:
return 4;
}
Expand Down
14 changes: 8 additions & 6 deletions src/simulate-bgs-battle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { BgsBattleInfo } from './bgs-battle-info';
import { BoardEntity } from './board-entity';
import { CardsData } from './cards/cards-data';
import { SimulationResult } from './simulation-result';
import { removeAuras, setImplicitData, setImplicitDataHero } from './simulation/auras';
import { setImplicitData, setImplicitDataHero, setMissingAuras } from './simulation/auras';
import { Simulator } from './simulation/simulator';
import { Spectator } from './simulation/spectator/spectator';
import { addImpliedMechanics } from './utils';
Expand Down Expand Up @@ -57,12 +57,14 @@ export const simulateBattle = (battleInput: BgsBattleInfo, cards: AllCardsServic

const playerBoard = playerInfo.board.map((entity) => ({ ...addImpliedMechanics(entity), friendly: true } as BoardEntity));
const opponentBoard = opponentInfo.board.map((entity) => ({ ...addImpliedMechanics(entity), friendly: false } as BoardEntity));
removeAuras(playerBoard, cardsData);
removeAuras(opponentBoard, cardsData);
setImplicitData(playerBoard, cardsData); // Avenge, maxHealth, etc.
setImplicitData(opponentBoard, cardsData); // Avenge, maxHealth, etc.
// When using the simulator, the aura is not applied when receiving the board state. When
setMissingAuras(playerBoard, playerInfo.player, opponentInfo.player);
setMissingAuras(opponentBoard, opponentInfo.player, playerInfo.player);
// Avenge, maxHealth, etc.
setImplicitData(playerBoard, cardsData);
setImplicitData(opponentBoard, cardsData);
// Avenge, globalInfo
setImplicitDataHero(playerInfo.player, cardsData, true);
// console.log('after implicit data', playerInfo.player.avengeCurrent, playerInfo.player.avengeDefault);
setImplicitDataHero(opponentInfo.player, cardsData, false);

// We do this so that we can have mutated objects inside the simulation and still
Expand Down
Loading

0 comments on commit 174c092

Please sign in to comment.