Skip to content

Commit

Permalink
improve retirement (#636)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lurkars committed Dec 16, 2024
1 parent aaecccd commit 70c4b1f
Show file tree
Hide file tree
Showing 4 changed files with 241 additions and 16 deletions.
77 changes: 73 additions & 4 deletions src/app/ui/figures/character/sheet/retirement-dialog.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</div>

<div class="event text-white" *ngIf="character.retireEvent" [ghs-label]="'character.progress.retirement.events'"
[ghs-label-args]="[character.retireEvent]">
[ghs-label-args]="[character.retireEvent]" [ngClass]="{'already-unlocked': alreadyRetired}">
</div>

<div class="conclusion" *ngIf="conclusion">
Expand All @@ -23,19 +23,55 @@

<div class="personal-quest" *ngIf="personalQuest">
<div class="text-white" *ngIf="personalQuest.unlockCharacter"
[ngClass]="{'already-unlocked': characterAlreadyUnlocked}"
[ghs-label]="'character.progress.personalQuest.unlockCharacter'"
[ghs-label-args]="[personalQuest.unlockCharacter]">
</div>

<div class="text-white" *ngIf="characterScenario"
[ghs-label]="'character.progress.personalQuest.unlockCharacter.randomScenario'"
[ghs-label-args]="[characterScenario.index, characterScenario.name]">
</div>

<div class="text-white link" *ngIf="characterItemDesign" (click)="itemDialog(characterItemDesign)"
[ghs-label]="'character.progress.personalQuest.unlockCharacter.itemDesign'"
[ghs-label-args]="[characterItemDesign.id, characterItemDesign.edition]">
</div>

<div class="event text-white" *ngIf="unlockEvent" [ghs-label]="'character.progress.retirement.events'"
[ghs-label-args]="[unlockEvent]">
</div>

<div class="envelope" *ngIf="personalQuest.openEnvelope">
<span class="text-white"
[ghs-label]="'character.progress.personalQuest.openEnvelope' + (personalQuest.openEnvelope.split(':').length > 1 ? '.alt' : '')"
[ghs-label-args]="personalQuest.openEnvelope.split(':')"></span>
[ghs-label-args]="personalQuest.openEnvelope.split(':')"
[ngClass]="{'already-unlocked': envelopeAlreadyUnlocked}"></span>

<span class="building" *ngIf="personalQuestBuilding"
[ghs-label]="'character.progress.personalQuest.openEnvelope.building'"
[ghs-label-args]="[personalQuestBuilding.id, personalQuestBuilding.name]"></span>
</div>

<div class="text-white" *ngIf="envelopeSection"
[ghs-label]="'character.progress.personalQuest.openEnvelope.randomScenario'"
[ghs-label-args]="[envelopeSection.index, envelopeSection.unlocks && envelopeSection.unlocks[0]]">
</div>

<div class="text-white" *ngIf="envelopeAlreadyUnlocked && !envelopeSection"
[ghs-label]="'character.progress.personalQuest.openEnvelope.inspiration'">
</div>

<div class="text-white link" *ngIf="envelopeItemBlueprint" (click)="itemDialog(envelopeItemBlueprint)"
[ghs-label]="'character.progress.personalQuest.openEnvelope.itemBlueprint'"
[ghs-label-args]="[envelopeItemBlueprint.id, envelopeItemBlueprint.edition]">
</div>

<div class="text-white" *ngIf="envelopeAlreadyUnlocked && !envelopeItemBlueprint"
[ghs-label]="'character.progress.personalQuest.openEnvelope.inspiration'">
</div>


<div class="errata text-white" *ngIf="settingsManager.settings.errata && personalQuest.errata">
<span [ghs-label]="'errata'"></span>:&nbsp;<span class="text"
[ghs-label]="'data.custom.' + personalQuest.edition + '.errata.' + personalQuest.errata"></span>
Expand Down Expand Up @@ -67,18 +103,51 @@

<div class="text-white" *ngIf="additionalPQ && additionalPQ.unlockCharacter"
[ghs-label]="'character.progress.personalQuest.unlockCharacter'"
[ghs-label-args]="[additionalPQ.unlockCharacter]">
[ghs-label-args]="[additionalPQ.unlockCharacter]"
[ngClass]="{'already-unlocked': additionalCharacterAlreadyUnlocked}">
</div>

<div class="text-white" *ngIf="additionalCharacterScenario"
[ghs-label]="'character.progress.personalQuest.unlockCharacter.randomScenario'"
[ghs-label-args]="[additionalCharacterScenario.index, additionalCharacterScenario.name]">
</div>

<div class="text-white link" *ngIf="additionalCharacterItemDesign"
(click)="itemDialog(additionalCharacterItemDesign)"
[ghs-label]="'character.progress.personalQuest.unlockCharacter.itemDesign'"
[ghs-label-args]="[additionalCharacterItemDesign.id, additionalCharacterItemDesign.edition]">
</div>

<div class="envelope" *ngIf="additionalPQ && additionalPQ.openEnvelope">
<span class="text-white"
[ghs-label]="'character.progress.personalQuest.openEnvelope' + (additionalPQ.openEnvelope.split(':').length > 1 ? '.alt' : '')"
[ghs-label-args]="additionalPQ.openEnvelope.split(':')"></span>
[ghs-label-args]="additionalPQ.openEnvelope.split(':')"
[ngClass]="{'already-unlocked': additionalEnvelopeAlreadyUnlocked}"></span>

<span class="building" *ngIf="additionalPQBuilding"
[ghs-label]="'character.progress.personalQuest.openEnvelope.building'"
[ghs-label-args]="[additionalPQBuilding.id, additionalPQBuilding.name]"></span>
</div>

<div class="text-white" *ngIf="additionalEnvelopeSection"
[ghs-label]="'character.progress.personalQuest.openEnvelope.randomScenario'"
[ghs-label-args]="[additionalEnvelopeSection.index, additionalEnvelopeSection.unlocks && additionalEnvelopeSection.unlocks[0]]">
</div>

<div class="text-white" *ngIf="additionalEnvelopeAlreadyUnlocked && !additionalEnvelopeSection"
[ghs-label]="'character.progress.personalQuest.openEnvelope.inspiration'">
</div>

<div class="text-white link" *ngIf="additionalEnvelopeItemBlueprint"
(click)="itemDialog(additionalEnvelopeItemBlueprint)"
[ghs-label]="'character.progress.personalQuest.openEnvelope.itemBlueprint'"
[ghs-label-args]="[additionalEnvelopeItemBlueprint.id, additionalEnvelopeItemBlueprint.edition]">
</div>

<div class="text-white" *ngIf="additionalEnvelopeAlreadyUnlocked && !additionalEnvelopeItemBlueprint"
[ghs-label]="'character.progress.personalQuest.openEnvelope.inspiration'">
</div>

<div class="errata text-white" *ngIf="settingsManager.settings.errata && additionalPQ && additionalPQ.errata">
<span [ghs-label]="'errata'"></span>:&nbsp;<span class="text"
[ghs-label]="'data.custom.' + additionalPQ.edition + '.errata.' + additionalPQ.errata"></span>
Expand Down
14 changes: 13 additions & 1 deletion src/app/ui/figures/character/sheet/retirement-dialog.scss
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
flex-direction: column;
justify-content: center;
align-items: center;
font-size: 1.5em;
font-size: calc(var(--ghs-unit) * 2.6 * var(--ghs-dialog-factor));
}

.conclusion {
Expand All @@ -92,6 +92,18 @@
}
}

.already-unlocked {
filter: brightness(0) var(--ghs-filter-darkgray);
}

.link {
cursor: pointer;

&:hover {
opacity: 0.7;
}
}

.personal-quest {
font-family: var(--ghs-font-text);
font-size: calc(var(--ghs-unit) * 2.5 * var(--ghs-dialog-factor));
Expand Down
155 changes: 146 additions & 9 deletions src/app/ui/figures/character/sheet/retirement-dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,19 @@ import { SettingsManager, settingsManager } from "src/app/game/businesslogic/Set
import { BuildingModel } from "src/app/game/model/Building";
import { Character } from "src/app/game/model/Character";
import { BuildingData } from "src/app/game/model/data/BuildingData";
import { CountIdentifier } from "src/app/game/model/data/Identifier";
import { ItemData } from "src/app/game/model/data/ItemData";
import { LootType, resourceLootTypes } from "src/app/game/model/data/Loot";
import { PersonalQuest } from "src/app/game/model/data/PersonalQuest";
import { ScenarioData } from "src/app/game/model/data/ScenarioData";
import { GameScenarioModel } from "src/app/game/model/Scenario";
import { ScenarioSummaryComponent } from "src/app/ui/footer/scenario/summary/scenario-summary";
import { ghsDialogClosingHelper } from "src/app/ui/helper/Static";
import { CharacterMoveResourcesDialog } from "./move-resources";
import { LootType, resourceLootTypes } from "src/app/game/model/data/Loot";
import { ItemDialogComponent } from "../../items/dialog/item-dialog";

@Component({
standalone: false,
standalone: false,
selector: 'ghs-character-retirement-dialog',
templateUrl: 'retirement-dialog.html',
styleUrls: ['./retirement-dialog.scss']
Expand All @@ -26,9 +30,25 @@ export class CharacterRetirementDialog {
conclusion: ScenarioData | undefined;
personalQuest: PersonalQuest | undefined;
personalQuestBuilding: BuildingData | undefined;
unlockEvent: string = '';
alreadyRetired: boolean = false;
characterAlreadyUnlocked: boolean = false;
characterScenario: ScenarioData | undefined;
characterItemDesign: ItemData | undefined;
envelopeAlreadyUnlocked: boolean = false;
envelopeSection: ScenarioData | undefined;
envelopeItemBlueprint: ItemData | undefined;

additional: boolean = false;
additionalPQ: PersonalQuest | undefined;
additionalPQBuilding: BuildingData | undefined;
additionalUnlockEvent: string = '';
additionalCharacterAlreadyUnlocked: boolean = false;
additionalCharacterScenario: ScenarioData | undefined;
additionalCharacterItemDesign: ItemData | undefined;
additionalEnvelopeAlreadyUnlocked: boolean = false;
additionalEnvelopeSection: ScenarioData | undefined;
additionalEnvelopeItemBlueprint: ItemData | undefined;

hasResources: boolean = false;

Expand All @@ -42,12 +62,35 @@ export class CharacterRetirementDialog {
}
}

for(let key of Object.keys(this.character.progress.loot)) {
const loot : LootType = key as LootType;
if (resourceLootTypes.indexOf(loot) != -1 && this.character.progress.loot[loot]) {
for (let key of Object.keys(this.character.progress.loot)) {
const loot: LootType = key as LootType;
if (resourceLootTypes.indexOf(loot) != -1 && this.character.progress.loot[loot]) {
this.hasResources = true;
}
}

if (this.personalQuest) {
if (this.personalQuest.unlockCharacter) {
this.characterAlreadyUnlocked = gameManager.game.unlockedCharacters.indexOf(this.personalQuest.unlockCharacter) != -1;
if (!this.characterAlreadyUnlocked) {
const unlockCharacter = gameManager.charactersData(this.personalQuest.edition).find((characterData) => this.personalQuest && characterData.edition == this.personalQuest.edition && characterData.name == this.personalQuest.unlockCharacter);
this.unlockEvent = unlockCharacter && unlockCharacter.unlockEvent || '';
} else {
this.characterScenario = gameManager.scenarioManager.drawRandomScenario(gameManager.currentEdition());
this.characterItemDesign = gameManager.itemManager.drawRandomItem(gameManager.currentEdition());
}
}

if (this.personalQuest.openEnvelope && gameManager.fhRules()) {
this.envelopeAlreadyUnlocked = !this.buildingsEnvelopeHelper(this.personalQuest.openEnvelope, false) && !this.buildingsEnvelopeHelper(this.personalQuest.openEnvelope);
if (this.envelopeAlreadyUnlocked) {
this.envelopeSection = gameManager.scenarioManager.drawRandomScenarioSection(gameManager.currentEdition());
this.envelopeItemBlueprint = gameManager.itemManager.drawRandomItem(gameManager.currentEdition(), true);
}
}
}

this.alreadyRetired = gameManager.game.party.retirements.find((retired) => retired.edition == this.character.edition && retired.name == this.character.name) != undefined;
}

openConclusion() {
Expand Down Expand Up @@ -82,6 +125,70 @@ export class CharacterRetirementDialog {
gameManager.game.unlockedCharacters.push(this.personalQuest.unlockCharacter);
}

if (this.characterAlreadyUnlocked) {
if (this.characterScenario) {
gameManager.game.party.manualScenarios.push(new GameScenarioModel(this.characterScenario.index, this.characterScenario.edition, this.characterScenario.group));
}

if (this.characterItemDesign) {
gameManager.game.party.unlockedItems.push(new CountIdentifier('' + this.characterItemDesign.id, this.characterItemDesign.edition));

}
}

if (this.additionalCharacterAlreadyUnlocked) {
if (this.additionalCharacterScenario) {
gameManager.game.party.manualScenarios.push(new GameScenarioModel(this.additionalCharacterScenario.index, this.additionalCharacterScenario.edition, this.additionalCharacterScenario.group));
}

if (this.additionalCharacterItemDesign) {
gameManager.game.party.unlockedItems.push(new CountIdentifier('' + this.additionalCharacterItemDesign.id, this.additionalCharacterItemDesign.edition));

}
}

if (this.envelopeAlreadyUnlocked) {
if (this.envelopeSection) {
gameManager.game.party.conclusions.push(new GameScenarioModel('' + this.envelopeSection.index, this.envelopeSection.edition, this.envelopeSection.group));
if (this.envelopeSection.unlocks) {
this.envelopeSection.unlocks.forEach((unlock) => {
if (this.envelopeSection) {
gameManager.game.party.manualScenarios.push(new GameScenarioModel(unlock, this.envelopeSection.edition));
}
})
}
} else {
gameManager.game.party.inspiration += 1;
}

if (this.envelopeItemBlueprint) {
gameManager.game.party.unlockedItems.push(new CountIdentifier('' + this.envelopeItemBlueprint.id, this.envelopeItemBlueprint.edition));
} else {
gameManager.game.party.inspiration += 1;
}
}

if (this.additionalEnvelopeAlreadyUnlocked) {
if (this.additionalEnvelopeSection) {
gameManager.game.party.conclusions.push(new GameScenarioModel('' + this.additionalEnvelopeSection.index, this.additionalEnvelopeSection.edition, this.additionalEnvelopeSection.group));
if (this.additionalEnvelopeSection.unlocks) {
this.additionalEnvelopeSection.unlocks.forEach((unlock) => {
if (this.envelopeSection) {
gameManager.game.party.manualScenarios.push(new GameScenarioModel(unlock, this.envelopeSection.edition));
}
})
}
} else {
gameManager.game.party.inspiration += 1;
}

if (this.additionalEnvelopeItemBlueprint) {
gameManager.game.party.unlockedItems.push(new CountIdentifier('' + this.additionalEnvelopeItemBlueprint.id, this.additionalEnvelopeItemBlueprint.edition));
} else {
gameManager.game.party.inspiration += 1;
}
}

if (this.additional) {
gameManager.game.party.inspiration -= 15;
gameManager.game.party.prosperity += 2;
Expand All @@ -106,13 +213,13 @@ export class CharacterRetirementDialog {
}
}

buildingsEnvelopeHelper(envelope: string): BuildingData | undefined {
buildingsEnvelopeHelper(envelope: string, both: boolean = true): BuildingData | undefined {
const buildingData = gameManager.campaignData().buildings;
const buildings = envelope.split(':').map((id) => buildingData.find((buildingData) => buildingData.id === id)).filter((buildingData) => buildingData).map((buildingData) => buildingData as BuildingData);
if (buildings.length > 0) {
if (!gameManager.game.party.buildings.find((buildingModel) => buildingModel.name == buildings[0].name) && (!this.personalQuestBuilding || this.personalQuestBuilding != buildings[0])) {
return buildings[0];
} else if (buildings.length > 1 && !gameManager.game.party.buildings.find((buildingModel) => buildingModel.name == buildings[1].name)) {
} else if (both && buildings.length > 1 && !gameManager.game.party.buildings.find((buildingModel) => buildingModel.name == buildings[1].name)) {
return buildings[1];
}
}
Expand All @@ -123,11 +230,41 @@ export class CharacterRetirementDialog {
changeAdditionalPQ(event: any) {
this.additionalPQ = gameManager.characterManager.personalQuestByCard(gameManager.currentEdition(), event.target.value);

if (settingsManager.settings.unlockEnvelopeBuildings && this.additionalPQ && this.additionalPQ.openEnvelope) {
this.additionalPQBuilding = this.buildingsEnvelopeHelper(this.additionalPQ.openEnvelope);
if (this.additionalPQ) {
if (settingsManager.settings.unlockEnvelopeBuildings && this.additionalPQ.openEnvelope) {
this.additionalPQBuilding = this.buildingsEnvelopeHelper(this.additionalPQ.openEnvelope);
}

if (this.additionalPQ.unlockCharacter) {
this.additionalCharacterAlreadyUnlocked = gameManager.game.unlockedCharacters.indexOf(this.additionalPQ.unlockCharacter) != -1;
if (!this.characterAlreadyUnlocked) {
const unlockCharacter = gameManager.charactersData(this.additionalPQ.edition).find((characterData) => this.additionalPQ && characterData.edition == this.additionalPQ.edition && characterData.name == this.additionalPQ.unlockCharacter);
this.additionalUnlockEvent = unlockCharacter && unlockCharacter.unlockEvent || '';
} else {
this.additionalCharacterScenario = gameManager.scenarioManager.drawRandomScenario(gameManager.currentEdition());
this.additionalCharacterItemDesign = gameManager.itemManager.drawRandomItem(gameManager.currentEdition());
}
}

if (this.additionalPQ.openEnvelope && gameManager.fhRules()) {
this.additionalEnvelopeAlreadyUnlocked = !this.buildingsEnvelopeHelper(this.additionalPQ.openEnvelope, false) && !this.buildingsEnvelopeHelper(this.additionalPQ.openEnvelope);

if (this.additionalEnvelopeAlreadyUnlocked) {
this.additionalEnvelopeSection = gameManager.scenarioManager.drawRandomScenarioSection(gameManager.currentEdition());
this.additionalEnvelopeItemBlueprint = gameManager.itemManager.drawRandomItem(gameManager.currentEdition(), true);
}
}
}
}

itemDialog(item: ItemData) {
this.dialog.open(ItemDialogComponent, {
panelClass: ['fullscreen-panel'],
disableClose: true,
data: { item: item }
});
}

close() {
ghsDialogClosingHelper(this.dialogRef);
}
Expand Down
Loading

0 comments on commit 70c4b1f

Please sign in to comment.