Skip to content

Commit

Permalink
address #237, #239, #240, #90/#160, change Confederated to Allied, im…
Browse files Browse the repository at this point in the history
…prove ally/allied marker, small fixes + improvements
  • Loading branch information
Lurkars committed Apr 18, 2023
1 parent 79817d2 commit e43fa37
Show file tree
Hide file tree
Showing 48 changed files with 305 additions and 135 deletions.
2 changes: 1 addition & 1 deletion data/fh/scenarios/028.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"algox-icespeaker",
"algox-snowspeaker"
],
"confederates": [
"allied": [
"algox-archer",
"algox-icespeaker"
],
Expand Down
14 changes: 8 additions & 6 deletions data/fh/scenarios/061.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@
},
{
"type": "attack",
"value": "L+1"
},
{
"type": "custom",
"small": true,
"value": "Attacks are unaffected by %game.action.retaliate%"
"value": "L+1",
"subActions": [
{
"type": "custom",
"small": true,
"value": "Attacks are unaffected by %game.action.retaliate%"
}
]
}
]
}
Expand Down
11 changes: 7 additions & 4 deletions data/fh/scenarios/062.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,13 @@
"actions": [
{
"type": "move",
"value": 3
},
{
"type": "jump"
"value": 3,
"subActions": [
{
"type": "jump",
"small": true
}
]
}
]
}
Expand Down
12 changes: 7 additions & 5 deletions data/fh/scenarios/086.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
"actions": [
{
"type": "custom",
"value": "When suffering damage but not destroyed:"
},
{
"type": "summon",
"value": "black-imp:normal"
"value": "When suffering damage but not destroyed:",
"subActions": [
{
"type": "summon",
"value": "black-imp:normal"
}
]
}
]
}
Expand Down
8 changes: 5 additions & 3 deletions data/fh/scenarios/114.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
"index": "114",
"name": "Work Freeze",
"edition": "fh",
"unlocks": [
"115"
],
"rewards": {
"calenderSection": [
"86.1-4"
]
},
"monsters": [
"hound",
"polar-bear",
Expand Down
12 changes: 7 additions & 5 deletions data/fh/scenarios/116.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@
"actions": [
{
"type": "move",
"value": "3"
},
{
"type": "custom",
"value": "Focus on moving towards %game.mapMarker.b%"
"value": "3",
"subActions": [
{
"type": "custom",
"value": "Focus on moving towards %game.mapMarker.b%"
}
]
}
]
}
Expand Down
12 changes: 7 additions & 5 deletions data/fh/sections/105-1.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@
},
{
"type": "attack",
"value": "L+2"
},
{
"type": "custom",
"value": "Attacks are unaffected by %game.action.retaliate%"
"value": "L+2",
"subActions": [
{
"type": "custom",
"value": "Attacks are unaffected by %game.action.retaliate%"
}
]
}
]
}
Expand Down
36 changes: 26 additions & 10 deletions data/fh/sections/146-3.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,32 @@
},
{
"type": "attack",
"value": "3+L"
},
{
"type": "condition",
"value": "brittle"
},
{
"type": "custom",
"value": "When this attack is performed, on the next round at initiative 99 instead perform: %game.action.heal%2 self",
"small": true
"value": "3+L",
"subActions": [
{
"type": "condition",
"value": "brittle",
"small": true
},
{
"type": "custom",
"value": "When this attack is performed, on the next round at initiative 99 instead perform:",
"small": true,
"subActions": [
{
"type": "heal",
"value": 2,
"subActions": [
{
"type": "specialTarget",
"value": "self",
"small": true
}
]
}
]
}
]
}
]
}
Expand Down
9 changes: 9 additions & 0 deletions data/fh/sections/86-1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"index": "86.1",
"name": "Protect the Pass",
"edition": "fh",
"conclusion": true,
"unlocks": [
"115"
]
}
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gloomhavensecretariat",
"version": "0.60.0",
"version": "0.60.1",
"license": "AGPL3",
"description": "Gloomhaven Secretariat is a Gloomhaven Companion app.",
"homepage": "https://gloomhaven-secretariat.de",
Expand Down
2 changes: 1 addition & 1 deletion scripts/sort/sorter/scenario.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@ export const sortScenario = function (scenario) {
scenario.requiredAchievements = scenario.requiredAchievements.map((requiredAchievements) => sortObjectKeys(requiredAchievements, 'global', 'party'));
}

return sortObjectKeys(scenario, 'index', 'group', 'name', 'gridLocation', 'edition', 'parent', 'parentSections', 'conclusion', 'blockedSections', 'marker', 'spoiler', 'initial', 'random', 'solo', 'allyDeck', 'resetRound', 'unlocks', 'requires', 'requiredAchievements', 'blocks', 'links', "forcedLinks", "rewards", 'monsters', 'allies', 'confederates', 'drawExtra', 'objectives', 'lootDeckConfig', 'rules', 'rooms');
return sortObjectKeys(scenario, 'index', 'group', 'name', 'gridLocation', 'edition', 'parent', 'parentSections', 'conclusion', 'blockedSections', 'marker', 'spoiler', 'initial', 'random', 'solo', 'allyDeck', 'resetRound', 'unlocks', 'requires', 'requiredAchievements', 'blocks', 'links', "forcedLinks", "rewards", 'monsters', 'allies', 'allied', 'drawExtra', 'objectives', 'lootDeckConfig', 'rules', 'rooms');
}
8 changes: 4 additions & 4 deletions src/app/game/businesslogic/AttackModifierManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ export class AttackModifierManager {
if (figure instanceof Character) {
return figure.attackModifierDeck;
} else if (figure instanceof Monster) {
return (settingsManager.settings.alwaysAllyAttackModifierDeck || gameManager.fhRules()) && (figure.isAlly || figure.isConfederated) ? this.game.allyAttackModifierDeck : this.game.monsterAttackModifierDeck;
return (settingsManager.settings.alwaysAllyAttackModifierDeck || gameManager.fhRules()) && (figure.isAlly || figure.isAllied) ? this.game.allyAttackModifierDeck : this.game.monsterAttackModifierDeck;
}

return new AttackModifierDeck();
}

countUpcomingBlesses(): number {
let count = 0;
if (settingsManager.settings.alwaysAllyAttackModifierDeck || gameManager.fhRules() && gameManager.game.figures.some((figure) => figure instanceof Monster && (figure.isAlly || figure.isConfederated))) {
if (settingsManager.settings.alwaysAllyAttackModifierDeck || gameManager.fhRules() && gameManager.game.figures.some((figure) => figure instanceof Monster && (figure.isAlly || figure.isAllied))) {
count += gameManager.game.allyAttackModifierDeck.cards.filter((attackModifier, index) => {
return attackModifier.type == AttackModifierType.bless && index > gameManager.game.allyAttackModifierDeck.current;
}).length;
Expand All @@ -55,7 +55,7 @@ export class AttackModifierManager {
}

let count = 0;
if (settingsManager.settings.alwaysAllyAttackModifierDeck || gameManager.fhRules() && gameManager.game.figures.some((figure) => figure instanceof Monster && (figure.isAlly || figure.isConfederated))) {
if (settingsManager.settings.alwaysAllyAttackModifierDeck || gameManager.fhRules() && gameManager.game.figures.some((figure) => figure instanceof Monster && (figure.isAlly || figure.isAllied))) {
count += gameManager.game.allyAttackModifierDeck.cards.filter((attackModifier, index) => {
return attackModifier.type == AttackModifierType.curse && index > gameManager.game.allyAttackModifierDeck.current;
}).length;
Expand All @@ -71,7 +71,7 @@ export class AttackModifierManager {

countExtraMinus1(): number {
let count = 0;
if (settingsManager.settings.alwaysAllyAttackModifierDeck || gameManager.fhRules() && gameManager.game.figures.some((figure) => figure instanceof Monster && (figure.isAlly || figure.isConfederated))) {
if (settingsManager.settings.alwaysAllyAttackModifierDeck || gameManager.fhRules() && gameManager.game.figures.some((figure) => figure instanceof Monster && (figure.isAlly || figure.isAllied))) {
count += gameManager.game.allyAttackModifierDeck.cards.filter((attackModifier) => {
return attackModifier.type == AttackModifierType.minus1extra;
}).length;
Expand Down
4 changes: 2 additions & 2 deletions src/app/game/businesslogic/LootManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,8 @@ export class LootManager {
break;
case TreasureRewardType.calenderSection:
if (reward.value && typeof reward.value === 'string' && reward.value.split('-').length > 1) {
const section = reward.value[0];
const week = gameManager.game.party.weeks + (+reward.value[1]);
const section = reward.value.split('-')[0];
const week = gameManager.game.party.weeks + (+reward.value.split('-')[1]);
if (!gameManager.game.party.weekSections[week]) {
gameManager.game.party.weekSections[week] = [];
}
Expand Down
4 changes: 2 additions & 2 deletions src/app/game/businesslogic/MonsterManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -315,9 +315,9 @@ export class MonsterManager {
return monsterEntity;
}

spawnMonsterEntity(monster: Monster, type: MonsterType, isAlly: boolean = false, isConfederated: boolean = false, drawExtra: boolean = false, summon: boolean = false): MonsterEntity | undefined {
spawnMonsterEntity(monster: Monster, type: MonsterType, isAlly: boolean = false, isAllied: boolean = false, drawExtra: boolean = false, summon: boolean = false): MonsterEntity | undefined {
monster.isAlly = isAlly;
monster.isConfederated = isConfederated;
monster.isAllied = isAllied;
monster.drawExtra = drawExtra;
const monsterCount = this.monsterStandeeMax(monster);
if (settingsManager.settings.automaticStandees && this.monsterStandeeCount(monster) < monsterCount) {
Expand Down
20 changes: 16 additions & 4 deletions src/app/game/businesslogic/ScenarioManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,18 @@ export class ScenarioManager {
}
})
}

if (rewards.calenderSection)
rewards.calenderSection.forEach((calenderSection) => {
if (calenderSection.split('-').length > 1) {
const section = calenderSection.split('-')[0];
const week = gameManager.game.party.weeks + (+calenderSection.split('-')[1]) + ((!casual && scenario && gameManager.fhRules() && !linkedScenario) ? 1 : 0);
if (!gameManager.game.party.weekSections[week]) {
gameManager.game.party.weekSections[week] = [];
}
gameManager.game.party.weekSections[week]?.push(section);
}
})
}

if (conclusionSection) {
Expand Down Expand Up @@ -221,7 +233,7 @@ export class ScenarioManager {
let monster = gameManager.monsterManager.addMonsterByName(name, scenarioData.edition);
if (monster) {
monster.isAlly = scenarioData.allies && scenarioData.allies.indexOf(monsterName) != -1 || section && gameManager.game.scenario && gameManager.game.scenario.allies && gameManager.game.scenario.allies.indexOf(monsterName) != -1 || false;
monster.isConfederated = scenarioData.confederates && scenarioData.confederates.indexOf(monsterName) != -1 || section && gameManager.game.scenario && gameManager.game.scenario.confederates && gameManager.game.scenario.confederates.indexOf(monsterName) != -1 || false;
monster.isAllied = scenarioData.allied && scenarioData.allied.indexOf(monsterName) != -1 || section && gameManager.game.scenario && gameManager.game.scenario.allied && gameManager.game.scenario.allied.indexOf(monsterName) != -1 || false;
monster.drawExtra = scenarioData.drawExtra && scenarioData.drawExtra.indexOf(monsterName) != -1 || section && gameManager.game.scenario && gameManager.game.scenario.drawExtra && gameManager.game.scenario.drawExtra.indexOf(monsterName) != -1 || false;
}
});
Expand Down Expand Up @@ -256,7 +268,7 @@ export class ScenarioManager {
let monster = gameManager.monsterManager.addMonsterByName(name, scenarioData.edition);
if (monster) {
monster.isAlly = scenarioData.allies && scenarioData.allies.indexOf(monsterName) != -1 || section && gameManager.game.scenario && gameManager.game.scenario.allies && gameManager.game.scenario.allies.indexOf(monsterName) != -1 || false;
monster.isConfederated = scenarioData.confederates && scenarioData.confederates.indexOf(monsterName) != -1 || section && gameManager.game.scenario && gameManager.game.scenario.confederates && gameManager.game.scenario.confederates.indexOf(monsterName) != -1 || false;
monster.isAllied = scenarioData.allied && scenarioData.allied.indexOf(monsterName) != -1 || section && gameManager.game.scenario && gameManager.game.scenario.allied && gameManager.game.scenario.allied.indexOf(monsterName) != -1 || false;
monster.drawExtra = scenarioData.drawExtra && scenarioData.drawExtra.indexOf(monsterName) != -1 || section && gameManager.game.scenario && gameManager.game.scenario.drawExtra && gameManager.game.scenario.drawExtra.indexOf(monsterName) != -1 || false;
}
}
Expand Down Expand Up @@ -331,12 +343,12 @@ export class ScenarioManager {
} else {
const monsterName = monsterStandeeData.name.split(':')[0];
const isAlly = scenarioData.allies && scenarioData.allies.indexOf(monsterName) != -1 || section && gameManager.game.scenario && gameManager.game.scenario.allies && gameManager.game.scenario.allies.indexOf(monsterName) != -1 || false;
const isConfederated = scenarioData.confederates && scenarioData.confederates.indexOf(monsterName) != -1 || section && gameManager.game.scenario && gameManager.game.scenario.confederates && gameManager.game.scenario.confederates.indexOf(monsterName) != -1 || false;
const isAllied = scenarioData.allied && scenarioData.allied.indexOf(monsterName) != -1 || section && gameManager.game.scenario && gameManager.game.scenario.allied && gameManager.game.scenario.allied.indexOf(monsterName) != -1 || false;
const drawExtra = scenarioData.drawExtra && scenarioData.drawExtra.indexOf(monsterName) != -1 || section && gameManager.game.scenario && gameManager.game.scenario.drawExtra && gameManager.game.scenario.drawExtra.indexOf(monsterName) != -1 || false;

const monster = gameManager.monsterManager.addMonsterByName(monsterStandeeData.name, scenarioData.edition);
if (monster) {
const entity = gameManager.monsterManager.spawnMonsterEntity(monster, type, isAlly, isConfederated, drawExtra);
const entity = gameManager.monsterManager.spawnMonsterEntity(monster, type, isAlly, isAllied, drawExtra);
if (entity) {
if (monsterStandeeData.marker) {
entity.marker = monsterStandeeData.marker;
Expand Down
22 changes: 18 additions & 4 deletions src/app/game/businesslogic/SettingsManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,19 @@ export class SettingsManager {
}

async loadSettings() {
let loadDefault = false;
try {
const settings = await storageManager.read<Settings>('settings', 'default');
this.setSettings(settings);
let settings = await storageManager.read<Settings>('settings', 'default');
if (settings) {
this.setSettings(settings);
} else {
loadDefault = true;
}
} catch {
loadDefault = true;
}

if (loadDefault) {
try {
await fetch('./ghs-settings-default.json')
.then(response => {
Expand All @@ -47,7 +56,7 @@ export class SettingsManager {
}).then((value: Settings) => {
this.setSettings(Object.assign(new Settings(), value));
});
} catch (error) {
} catch {
this.setSettings(new Settings());
}
}
Expand Down Expand Up @@ -84,7 +93,7 @@ export class SettingsManager {
}

storeSettings(): void {
storageManager.write('settings','default', this.settings);
storageManager.write('settings', 'default', this.settings);
if (this.settings.serverSettings) {
gameManager.stateManager.saveSettings();
}
Expand Down Expand Up @@ -274,6 +283,11 @@ export class SettingsManager {
this.storeSettings();
}

setDisableStatAnimations(disableStatAnimations: boolean) {
this.settings.disableStatAnimations = disableStatAnimations;
this.storeSettings();
}

async setDisableWakeLock(disableWakeLock: boolean) {
this.settings.disableWakeLock = disableWakeLock;
if (disableWakeLock && gameManager.stateManager.wakeLock) {
Expand Down
1 change: 1 addition & 0 deletions src/app/game/businesslogic/StateManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ export class StateManager {
settings.browserNavigation = settingsManager.settings.browserNavigation;
settings.debugRightClick = settingsManager.settings.debugRightClick;
settings.disableAnimations = settingsManager.settings.disableAnimations;
settings.disableStatAnimations = settingsManager.settings.disableStatAnimations;
settings.disableColumns = settingsManager.settings.disableColumns;
settings.disableWakeLock = settingsManager.settings.disableWakeLock;
settings.dragValues = settingsManager.settings.dragValues;
Expand Down
4 changes: 3 additions & 1 deletion src/app/game/businesslogic/StorageManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,9 @@ export class StorageManager {
datadump['undo-infos'] = await this.readAll('undo-infos');
datadump['game-backup'] = await this.readAll('game-backup');
} else {
console.warn("No IndexedDB, fallback to Local Storage");
if (!migrate) {
console.warn("No IndexedDB, fallback to Local Storage");
}
for (let i = 0; i < localStorage.length; i++) {
const key = localStorage.key(i);
if (key) {
Expand Down
Loading

0 comments on commit e43fa37

Please sign in to comment.