Skip to content

Commit

Permalink
address #242, #520, improve game clock, fix and improve standalone de…
Browse files Browse the repository at this point in the history
…cks, add support for character standalone deck
  • Loading branch information
Lurkars committed Feb 28, 2024
1 parent a7628bb commit 0ec6e20
Show file tree
Hide file tree
Showing 26 changed files with 258 additions and 79 deletions.
2 changes: 1 addition & 1 deletion data/fh/label-spoiler/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1005,7 +1005,7 @@
".": "Orchid Wand"
},
"fh-233": {
"1": "During you ally's ranged attack ability, add %game.condition.muddle% %game.condition.curse% one attack.",
"1": "During an ally's ranged attack ability, add %game.condition.muddle% and %game.condition.curse% one attack.",
".": "Dead Raven"
},
"fh-234": {
Expand Down
4 changes: 3 additions & 1 deletion src/app/game/model/Game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,9 @@ export class Game {

this.server = model.server;
this.finish = model.finish;
this.gameClock = gameManager.mergeGameClocks(this.gameClock, model.gameClock);
if (settingsManager.settings.gameClockMerge) {
this.gameClock = gameManager.mergeGameClocks(this.gameClock, model.gameClock);
}
}
}

Expand Down
4 changes: 3 additions & 1 deletion src/app/game/model/Settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export class Settings {
autoBackupUrl: { url: string, method: string, fileUpload: boolean, username: string | undefined, password: string | undefined, authorization: string | undefined } | undefined;
automaticAttackModifierFullscreen: boolean = true;
automaticGameClock: boolean = true;
automaticGameClockFocus: boolean = false;
automaticPassTime: boolean = true;
automaticStandees: boolean = true;
automaticStandeesDialog: boolean = false;
Expand All @@ -50,7 +51,7 @@ export class Settings {
calculate: boolean = true;
calculateStats: boolean = true;
calculateShieldStats: boolean = true;
calendarLocked: boolean = false;
calendarLocked: boolean | 'permissive' = false;
characterAttackModifierAnimate: boolean = true;
characterAttackModifierDeck: boolean = true;
characterAttackModifierDeckPermanent: boolean = false;
Expand Down Expand Up @@ -95,6 +96,7 @@ export class Settings {
fhStyle: boolean = false;
fontsize: number = 1;
gameClock: boolean = false;
gameClockMerge: boolean = true;
globalFontsize: number = 1;
fullscreen: boolean = false;
hideAbsent: boolean = false;
Expand Down
24 changes: 17 additions & 7 deletions src/app/ui/figures/attackmodifier/attackmodifierdeck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class AttackModiferDeckChange {
export class AttackModifierDeckComponent implements OnInit, OnDestroy, OnChanges {

@Input('deck') deck!: AttackModifierDeck;
@Input('character') character!: Character;
@Input('character') character: Character | undefined;
@Input() ally: boolean = false;
@Input('numeration') numeration: string = "";
@Input('bottom') bottom: boolean = false;
Expand Down Expand Up @@ -144,6 +144,14 @@ export class AttackModifierDeckComponent implements OnInit, OnDestroy, OnChanges
}

update(fromServer: boolean = false) {
if (this.character) {
this.deck = this.character.attackModifierDeck;
this.edition = this.character.edition;
this.numeration = "" + this.character.number;
this.characterIcon = this.character.iconUrl;
} else {
this.battleGoals = false;
}
this.disabled = !this.standalone && (!this.townGuard && gameManager.game.state == GameState.draw || this.townGuard && gameManager.game.scenario != undefined);

if (this.character && this.deck != this.character.attackModifierDeck) {
Expand Down Expand Up @@ -263,12 +271,14 @@ export class AttackModifierDeckComponent implements OnInit, OnDestroy, OnChanges
}

openBattleGoals(event: any): void {
this.dialog.open(CharacterBattleGoalsDialog, {
panelClass: ['dialog'],
data: { character: this.character, draw: !this.character.battleGoals || this.character.battleGoals.length == 0 }
});
event.preventDefault();
event.stopPropagation();
if (this.character) {
this.dialog.open(CharacterBattleGoalsDialog, {
panelClass: ['dialog'],
data: { character: this.character, draw: !this.character.battleGoals || this.character.battleGoals.length == 0 }
});
event.preventDefault();
event.stopPropagation();
}
}

calcRolling() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="light character-sheet-dialog">
<div class="scroll-container">
<ghs-character-sheet #characterSheet [character]="data.character" [editable]="!data.viewOnly"
<ghs-character-sheet #characterSheet [character]="data.character" [editable]="!data.viewOnly" [forceEdit]="data.forceEdit"
[dialogRef]="dialogRef"></ghs-character-sheet>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class CharacterSheetDialog {

@ViewChild('characterSheet') characterSheet!: CharacterSheetComponent;

constructor(@Inject(DIALOG_DATA) public data: { character: Character, viewOnly: boolean }, public dialogRef: DialogRef) {
constructor(@Inject(DIALOG_DATA) public data: { character: Character, viewOnly: boolean, forceEdit: boolean }, public dialogRef: DialogRef) {

this.dialogRef.closed.subscribe({
next: () => {
Expand Down
4 changes: 2 additions & 2 deletions src/app/ui/figures/character/sheet/character-sheet.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="light character-sheet" [style.--ghs-character-color]="character.color"
[ngClass]="{'cs-sheet' : csSheet, 'fh-sheet' : fhSheet, 'compact': settingsManager.settings.characterSheetCompact}">
<div class="container"
[ngClass]="{'denied' : !editable || !gameManager.stateManager.characterPermissions[character.name + '|' + character.edition], 'view-only' : !editable}">
[ngClass]="{'denied' : !forceEdit && (!editable || !gameManager.stateManager.characterPermissions[character.name + '|' + character.edition]), 'view-only' : !forceEdit && !editable}">
<div class="columns">
<div class="column column-left">
<div class="row title">
Expand Down Expand Up @@ -185,7 +185,7 @@
<div class="perk" *ngFor="let perk of character.perks; let i = index;">
<div class="checkboxes" [ngClass]="{'combined' : perk.combined}">
<span class="checkbox" *ngFor="let count of []|ghsRange:perk.count"
[ngClass]="{'checked' : character.progress.perks[i] && character.progress.perks[i] > count, 'disabled' : gameManager.game.state != GameState.draw || gameManager.game.round > 0 || character.progress.perks[i] <= count && availablePerks < count - character.progress.perks[i] + 1}"
[ngClass]="{'checked' : character.progress.perks[i] && character.progress.perks[i] > count, 'disabled' : !forceEdit && (gameManager.game.state != GameState.draw || gameManager.game.round > 0) || character.progress.perks[i] <= count && availablePerks < count - character.progress.perks[i] + 1}"
ghs-pointer-input (singleClick)="addPerk(i, count+1)"
(doubleClick)="addPerk(i, count+1, true)"></span>
</div>
Expand Down
3 changes: 2 additions & 1 deletion src/app/ui/figures/character/sheet/character-sheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export class CharacterSheetComponent implements OnInit, AfterViewInit {

@Input() character!: Character;
@Input() editable: boolean = true;
@Input() forceEdit: boolean = false;
@Input() standalone: boolean = false;
@Input() dialogRef: DialogRef | undefined;

Expand Down Expand Up @@ -409,7 +410,7 @@ export class CharacterSheetComponent implements OnInit, AfterViewInit {
}

addPerk(index: number, value: number, force: boolean = false) {
const disabled: boolean = gameManager.game.state != GameState.draw || gameManager.game.round > 0 || this.character.progress.perks[index] < value && this.availablePerks < value - this.character.progress.perks[index];
const disabled: boolean = !this.forceEdit && (gameManager.game.state != GameState.draw || gameManager.game.round > 0) || this.character.progress.perks[index] < value && this.availablePerks < value - this.character.progress.perks[index];

if (!disabled || force) {
gameManager.stateManager.before("setPerk", gameManager.characterManager.characterName(this.character), "" + index, "" + value);
Expand Down
2 changes: 0 additions & 2 deletions src/app/ui/figures/entity-menu/entity-menu-dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -958,8 +958,6 @@ export class EntityMenuDialogComponent {
this.data.entity.immunities = gameManager.conditionsForTypes('character', 'negative').map((condition) => condition.name);
}

console.log(this.data.entity.name, this.data.entity.edition, specialTagsToAdd, gameManager.conditionsForTypes('character', 'negative'));

gameManager.stateManager.after();
}

Expand Down
3 changes: 1 addition & 2 deletions src/app/ui/figures/loot/loot-deck-dialog.scss
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@

.config {
margin-bottom: 5%;
padding: 2em;
min-height: 500px;

.title {
Expand All @@ -98,7 +97,7 @@

display: grid;
grid-template-columns: auto auto auto auto;
font-size: 2em;
font-size: 1.5em;

label {
color: var(--ghs-color-white);
Expand Down
2 changes: 1 addition & 1 deletion src/app/ui/figures/loot/loot-deck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export class LootDeckComponent implements OnInit, OnDestroy, OnChanges {
this.initServer = false;
}

if (!this.deck.active) {
if (!this.deck.active && !this.standalone) {
if (this.queueTimeout) {
clearTimeout(this.queueTimeout);
this.queueTimeout = null;
Expand Down
11 changes: 7 additions & 4 deletions src/app/ui/figures/party/party-sheet-dialog.html
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,10 @@
[ghs-label]="'party.campaign.sheet.winter'"></span><img src="./assets/images/fh/party/winter.svg"></label>
</div>

<div class="calendar-lock-toggle">
<a (click)="settingsManager.toggle('calendarLocked')">
<div class="calendar-lock-toggle" [ghs-tooltip]="'party.campaign.sheet.weekSections.lock'"
[ngClass]="{'permissive': settingsManager.settings.calendarLocked == 'permissive'}">
<a ghs-pointer-input (singleClick)="settingsManager.toggle('calendarLocked')"
(doubleClick)="settingsManager.set('calendarLocked', settingsManager.settings.calendarLocked != 'permissive' ? 'permissive': true)">
<img [src]="'./assets/images/lock' + (settingsManager.settings.calendarLocked ? '' : '-open') + '.svg'">
</a>
</div>
Expand All @@ -150,7 +152,7 @@
<div class="week" *ngFor="let week of [] | ghsRange:80; let index = index" ghs-pointer-input
[ghs-tooltip]="'party.campaign.sheet.weekSections.hint'" (singleClick)="setWeek(index+1 + 80*calendarSheet)"
(doubleClick)="setWeekSection(index+1+ 80*calendarSheet)"
[ngClass]="{'checked': party.weeks > index + 80*calendarSheet, 'section': sectionsForWeekFixed(week+ 80*calendarSheet).length > 0 || sectionsForWeek(week+ 80*calendarSheet).length > 0, 'locked': settingsManager.settings.calendarLocked}">
[ngClass]="{'checked': party.weeks > index + 80*calendarSheet, 'section': sectionsForWeekFixed(week+ 80*calendarSheet).length > 0 || sectionsForWeek(week+ 80*calendarSheet).length > 0, 'locked': settingsManager.settings.calendarLocked && (settingsManager.settings.calendarLocked != 'permissive' || party.weeks != index + 80*calendarSheet && party.weeks != index + 80*calendarSheet + 1)}">
<div class="section" *ngFor="let section of sectionsForWeekFixed(week+ 80*calendarSheet)">
<img
[src]="'./assets/images/' + (hasConclusions(section) ? 'hint.svg' : (isConclusion(section) ? 'scenario/conclusion.svg' : 'fh/party/section.svg'))">
Expand Down Expand Up @@ -806,7 +808,8 @@
</div>

<div class="row time">
<span [ghs-label]="'party.campaign.totalTime'" [ghs-label-args]="[(gameManager.game.totalSeconds| ghsDurationLabel:true)]"></span>
<span [ghs-label]="'party.campaign.totalTime'"
[ghs-label-args]="[(gameManager.game.totalSeconds| ghsDurationLabel:true)]"></span>
</div>
</div>
</div>
Expand Down
13 changes: 13 additions & 0 deletions src/app/ui/figures/party/party-sheet-dialog.scss
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,15 @@
&.disabled {
pointer-events: none;
}

&.checked:hover::before {
opacity: 0.6;
}

&:not(.checked):hover::before {
transform: scale(1) translate(-50%, -50%);
opacity: 0.6;
}
}

input[type="text"] {
Expand Down Expand Up @@ -582,6 +591,10 @@
}
}

&.permissive {
opacity: 0.6;
}

z-index: 2;
}

Expand Down
2 changes: 1 addition & 1 deletion src/app/ui/figures/party/party-sheet-dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,7 @@ export class PartySheetDialogComponent implements OnInit, OnDestroy {
}

setWeek(value: number) {
if (settingsManager.settings.calendarLocked) {
if (settingsManager.settings.calendarLocked && settingsManager.settings.calendarLocked != 'permissive' || this.party.weeks != value - 1 && this.party.weeks != value) {
return;
}

Expand Down
4 changes: 2 additions & 2 deletions src/app/ui/header/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@
</ng-container>
</div>
<span class="spacer"></span>
<div class="event-effects" (click)="openEventEffects()"
*ngIf="gameManager.game.scenario && gameManager.characterManager.characterCount() > 0">
<div *ngIf="gameManager.game.scenario && gameManager.characterManager.characterCount() > 0" class="event-effects"
(click)="openEventEffects()">
<img class="ghs-svg"
[src]="'./assets/images/event' + (gameManager.game.round > 0 || gameManager.game.state == GameState.next ? '-effects' : '') + '.svg'">
</div>
Expand Down
1 change: 1 addition & 0 deletions src/app/ui/header/menu/datamanagement/datamanagement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ export class DatamanagementMenuComponent implements OnInit {
try {
console.warn("clear storage");
await storageManager.clear();
gameManager.stateManager.storageBlocked = true;
console.info("Reload...");
window.location.reload();
} catch {
Expand Down
21 changes: 9 additions & 12 deletions src/app/ui/header/menu/menu.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,9 @@
<div class="line">
<a tabclick (click)="setActive(SubMenu.settings)"><span [ghs-label]="'settings'"></span></a>
</div>
<ng-container *ngIf="!standalone">
<div class="line">
<a tabclick (click)="setActive(SubMenu.datamanagement)"><span [ghs-label]="'datamanagement'"></span></a>
</div>
</ng-container>
<div class="line">
<a tabclick (click)="setActive(SubMenu.datamanagement)"><span [ghs-label]="'datamanagement'"></span></a>
</div>

<div class="separator"></div>
<div class="line">
Expand All @@ -102,13 +100,6 @@

<div class="separator"></div>

<div class="line" *ngIf="standalone">

<a tabclick [routerLink]="'/'" (click)="close()"><img class="ghs-svg" src="./assets/images/left.svg">&nbsp;
<span [ghs-label]="'tools.backToGhs'"></span>
</a>
</div>

<div class="line" *ngIf="gameManager.stateManager.installPrompt">
<a class="install" (click)="gameManager.stateManager.install()"> <img class="ghs-svg"
src="./assets/images/install.svg"> <span [ghs-label]="'app.install'"></span></a>
Expand All @@ -126,6 +117,12 @@
</a>
</div>

<div class="line" *ngIf="standalone">
<a tabclick [routerLink]="'/'" (click)="close()"><img class="ghs-svg" src="./assets/images/left.svg">&nbsp;
<span [ghs-label]="'tools.backToGhs'"></span>
</a>
</div>

<div class="line separator" *ngIf="isUpdateAvailable()">
<a tabclick (click)="update()">&lt;<span [ghs-label]="'update'"></span>(!)&gt;</a>
</div>
Expand Down
15 changes: 13 additions & 2 deletions src/app/ui/header/menu/settings/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,19 @@

<div class="separator"></div>

<!-- Game clock-->
<div class="column">
<div class="line" ghs-setting-menu="gameClock"></div>
<div class="line" ghs-setting-menu="gameClockMerge" [disabled]="!settingsManager.settings.gameClock"></div>
</div>

<div class="column">
<div class="line" ghs-setting-menu="automaticGameClock" [disabled]="!settingsManager.settings.gameClock"></div>
<div class="line" ghs-setting-menu="automaticGameClockFocus" [disabled]="!settingsManager.settings.gameClock || !settingsManager.settings.automaticGameClock"></div>
</div>

<div class="separator"></div>

<div class="column">
<div class="line ">
<a ghs-pointer-input (singleClick)="zoomOut()" (doubleClick)="zoomOut(true)">
Expand Down Expand Up @@ -282,8 +295,6 @@
<div class="line" ghs-setting-menu="tooltips"></div>
<div class="line" ghs-setting-menu="backupHint"></div>
<div class="line" ghs-setting-menu="errata"></div>
<div class="line" ghs-setting-menu="gameClock"></div>
<div class="line" ghs-setting-menu="automaticGameClock" [disabled]="!settingsManager.settings.gameClock"></div>
<div class="line" ghs-setting-menu="columns"></div>
<div class="line" ghs-setting-menu="columnsForce" [disabled]="!settingsManager.settings.columns"></div>
<div class="line" ghs-setting-menu="artwork"></div>
Expand Down
9 changes: 6 additions & 3 deletions src/app/ui/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -198,13 +198,16 @@ main {

.editions {
display: flex;
flex-direction: column;
justify-content: flex-start;
flex-wrap: wrap;
justify-content: center;
align-items: center;
max-width: calc(var(--ghs-unit) * 70 * var(--ghs-text-factor));

.edition {
cursor: pointer;
margin: calc(var(--ghs-unit) * 0.5 * var(--ghs-text-factor));
min-width: calc(var(--ghs-unit) * 30 * var(--ghs-text-factor));
margin: calc(var(--ghs-unit) * 0.5 * var(--ghs-text-factor)) calc(var(--ghs-unit) * 2.5 * var(--ghs-text-factor));
text-align: center;

.text {
font-family: var(--ghs-font-title);
Expand Down
Loading

0 comments on commit 0ec6e20

Please sign in to comment.