import 'package:askiineverdie/src/core/engine/game_mutations.dart';
import 'package:askiineverdie/src/core/model/game_state.dart';
import 'package:askiineverdie/src/core/util/pq_logic.dart';

/// Applies quest/act rewards to the GameState using shared RNG.
class RewardService {
  RewardService(this.mutations);

  final GameMutations mutations;

  GameState applyReward(GameState state, RewardKind reward) {
    switch (reward) {
      case RewardKind.spell:
        return mutations.winSpell(state, state.stats.wis, state.traits.level);
      case RewardKind.equip:
        // 원본 Main.pas:797 - Random(Equips.Items.Count) (11개 슬롯)
        final slotIndex = state.rng.nextInt(Equipment.slotCount);
        return mutations.winEquipByIndex(state, state.traits.level, slotIndex);
      case RewardKind.stat:
        return mutations.winStat(state);
      case RewardKind.item:
        return mutations.winItem(state);
    }
  }
}
