Skip to content

Commit

Permalink
restrict random picker (polar-bear 1rst printing vs 2nd)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lurkars committed Aug 21, 2024
1 parent a711b01 commit f6dafa4
Show file tree
Hide file tree
Showing 8 changed files with 103 additions and 86 deletions.
1 change: 1 addition & 0 deletions data/fh/monster/polar-bear.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "polar-bear",
"edition": "fh",
"count": 6,
"randomCount": 4,
"baseStat": {
"type": "normal",
"immunities": [
Expand Down
134 changes: 67 additions & 67 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gloomhavensecretariat",
"version": "0.99.23",
"version": "0.99.24",
"license": "AGPL3",
"description": "Gloomhaven Secretariat is a Gloomhaven/Frosthaven Companion app.",
"homepage": "https://gloomhaven-secretariat.de",
Expand Down Expand Up @@ -95,16 +95,16 @@
"zone.js": "~0.14.10"
},
"devDependencies": {
"@angular-devkit/build-angular": "^18.2.0",
"@angular/cli": "^18.2.0",
"@angular-devkit/build-angular": "^18.2.1",
"@angular/cli": "^18.2.1",
"@angular/compiler-cli": "^18.2.0",
"@types/d3": "^7.4.3",
"@types/dom-screen-wake-lock": "1.0.3",
"@types/dompurify": "^3.0.5",
"@types/jasmine": "~5.1.4",
"@types/leaflet": "^1.9.12",
"@types/uuid": "^10.0.0",
"electron": "^32.0.0",
"electron": "^32.0.1",
"electron-builder": "^24.13.3",
"http-server": "^14.1.1",
"husky": "^9.1.5",
Expand Down
2 changes: 1 addition & 1 deletion scripts/sort/sorter/monster.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ export const sortMonster = function (monster) {
});
}

return sortObjectKeys(monster, 'name', 'thumbnail', 'thumbnailUrl', 'noThumbnail', 'noArtwork', 'edition', 'deck', 'boss', 'bb', 'flying', 'immortal', 'catching', 'hidden', 'count', 'standeeCount', 'standeeShare', 'standeeShareEdition', 'baseStat', 'stats');
return sortObjectKeys(monster, 'name', 'thumbnail', 'thumbnailUrl', 'noThumbnail', 'noArtwork', 'edition', 'deck', 'boss', 'bb', 'flying', 'immortal', 'catching', 'hidden', 'count', 'randomCount', 'standeeCount', 'standeeShare', 'standeeShareEdition', 'baseStat', 'stats');
}
29 changes: 25 additions & 4 deletions src/app/game/businesslogic/MonsterManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,30 @@ export class MonsterManager {
return max;
}

monsterRandomStandee(monster: Monster): number {
let number = -1;
const monsterCount = this.monsterStandeeMax(monster);

if ([...Array(monsterCount).keys()].every((n) => gameManager.monsterManager.monsterStandeeUsed(monster, n + 1))) {
console.error("This should not happen: monsterRandomStandee called with all standees used already!");
return number;
}

const randomCount = monster.randomCount ? EntityValueFunction(monster.randomCount) : 0;
if (randomCount && randomCount < monsterCount && [...Array(randomCount).keys()].some((n) => !gameManager.monsterManager.monsterStandeeUsed(monster, n + 1))) {
number = Math.floor(Math.random() * randomCount) + 1;
while (gameManager.monsterManager.monsterStandeeUsed(monster, number)) {
number = Math.floor(Math.random() * randomCount) + 1;
}
} else {
number = Math.floor(Math.random() * monsterCount) + 1;
while (gameManager.monsterManager.monsterStandeeUsed(monster, number)) {
number = Math.floor(Math.random() * monsterCount) + 1;
}
}
return number;
}

addMonsterEntity(monster: Monster, number: number, type: MonsterType, summon: boolean = false): MonsterEntity | undefined {
if (monster.bb && !monster.baseStat || !monster.bb && !monster.stats.some((monsterStat) => {
return monsterStat.type == type;
Expand Down Expand Up @@ -479,10 +503,7 @@ export class MonsterManager {
}

if (settingsManager.settings.randomStandees) {
number = Math.floor(Math.random() * monsterCount) + 1;
while (gameManager.monsterManager.monsterStandeeUsed(monster, number)) {
number = Math.floor(Math.random() * monsterCount) + 1;
}
number = this.monsterRandomStandee(monster);
} else if (this.monsterStandeeCount(monster, false) == monsterCount - 1) {
number = 1;
while (gameManager.monsterManager.monsterStandeeUsed(monster, number)) {
Expand Down
Loading

0 comments on commit f6dafa4

Please sign in to comment.