// game.page.ts
import { Component, ViewChild, ElementRef, AfterViewInit, HostListener , OnInit} from '@angular/core';
import * as PIXI from 'pixi.js';
import { Howl, Howler } from 'howler';
import { Haptics, ImpactStyle } from '@capacitor/haptics';
import { ModalController } from '@ionic/angular';
@Component({
  selector: 'app-game',
  templateUrl: 'game.page.html',
  styleUrls: ['game.page.scss'],
  standalone: false,
})
export class GamePage implements OnInit {

  currentMood = {
    score: 0.6,
    description: "轻度焦虑",
    tags: ["工作压力", "时间紧迫"]
  };

  demoBubbles = Array(8).fill(0);
  unlockedAchievements = {
    bubble: true,
    sand: false,
    raindrop:false,
    constellation:false
  };
  showRecommendation = true;
  recommendedGame = "禅意沙画";
  constructor(private modalCtrl: ModalController) {}
  ngOnInit() {
    // 从服务获取最新情绪数据和游戏解锁状态
  }
  getMoodGradient() {
    const score = this.currentMood.score;
    if (score > 0.7) {
      return 'linear-gradient(135deg, #a8edea 0%, #fed6e3 100%)';
    } else if (score > 0.4) {
      return 'linear-gradient(135deg, #f6f7f9 0%, #e9ecef 100%)';
    } else {
      return 'linear-gradient(135deg, #ff9a9e 0%, #fad0c4 100%)';
    }
  }

  async openGame(gameType: string) {
    let component;
    switch(gameType) {
      case 'bubble':
        //component = BubbleGamePage;
        break;
      case 'sand':
        if (!this.unlockedAchievements.sand) {
          // 显示解锁条件提示
          return;
        }
        //component = SandGamePage;
        break;
      case 'raindrop':
        if (!this.unlockedAchievements.raindrop) {
          // 显示解锁条件提示
          return;
        }
        //component = SandGamePage;
        break;
      case 'constellation':
        if (!this.unlockedAchievements.constellation) {
          // 显示解锁条件提示
          return;
        }
        //component = SandGamePage;
        break;
      default:
        return;
    }
  }
  openAchievements() {
    // 打开成就页面
  }

  dismissRecommendation() {
    this.showRecommendation = false;
  }
}
