import {
  ChangeDetectionStrategy,
  Component,
  computed,
  input,
  output,
} from '@angular/core';
import { MissionStateResponse } from '@fog-explorer/api-interfaces';

const OUTCOME: Record<string, { glyph: string; heading: string; glyphClass: string }> = {
  success:   { glyph: '◆', heading: 'Expedition complete', glyphClass: 'success' },
  sacrifice: { glyph: '✕', heading: 'Taken by the fog',    glyphClass: 'sacrifice' },
};

@Component({
  selector: 'app-summary-panel',
  standalone: true,
  changeDetection: ChangeDetectionStrategy.OnPush,
  templateUrl: './summary-panel.component.html',
  styleUrl: './summary-panel.component.css',
})
export class SummaryPanelComponent {
  missionState = input.required<NonNullable<MissionStateResponse>>();
  continueExpedition = output<void>();

  protected outcome = computed(() => {
    const status = this.missionState().mission.status;
    return OUTCOME[status] ?? { glyph: '○', heading: 'Expedition ended', glyphClass: '' };
  });

  protected ticks = computed(() => this.missionState().mission.tickIndex);
}
