import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { CharacterResponse, CurrentLocationResponse, CurrentTravel } from './game-api.models';

@Injectable({ providedIn: 'root' })
export class GameApiService {
  constructor(private readonly http: HttpClient) {}

  getCharacter(): Observable<CharacterResponse> {
    return this.http.get<CharacterResponse>('/api/characters/me');
  }

  getCurrentLocation(): Observable<CurrentLocationResponse> {
    return this.http.get<CurrentLocationResponse>('/api/world/current-location');
  }

  startTravel(targetLocationId: string): Observable<CurrentTravel> {
    return this.http.post<CurrentTravel>('/api/travel', { targetLocationId });
  }

  getCurrentTravel(): Observable<CurrentTravel> {
    return this.http.get<CurrentTravel>('/api/travel/current');
  }
}
