import '../enums.dart';

class StatusEffect {
  final StatusEffectType type;
  int duration; // Turns remaining
  int value; // Intensity (e.g., bleed damage amount, now mutable for stacking)
  int stacks; // Number of stacks

  StatusEffect({required this.type, required this.duration, this.value = 0, this.stacks = 1});

  Map<String, dynamic> toJson() {
    return {
      'type': type.name,
      'duration': duration,
      'value': value,
      'stacks': stacks,
    };
  }

  factory StatusEffect.fromJson(Map<String, dynamic> json) {
    return StatusEffect(
      type: StatusEffectType.values.firstWhere((e) => e.name == json['type']),
      duration: json['duration'],
      value: json['value'],
      stacks: json['stacks'] ?? 1,
    );
  }
}
