package com.red.circle.other.app.dto.clientobject.pet;

import com.red.circle.framework.dto.ClientObject;
import com.red.circle.other.app.dto.clientobject.sys.ActivityPropsGroupCO;
import com.red.circle.other.inner.enums.task.ReceiveStatusEnum;
import com.red.circle.tool.core.collection.CollectionUtils;
import java.io.Serial;
import java.util.List;
import java.util.Objects;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

/**
 * 宠物库-详情.
 *
 * @author pengliang on 2021/10/14
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
public class PetLibraryDetailsCO extends ClientObject {

  @Serial
  private static final long serialVersionUID = 1L;


  /**
   * 宠物池配置信息.
   */
  private PetPoolCO petPool;

  /**
   * 背包.
   */
  private PetBagCO petBag;

  /**
   * 阶段信息.
   */
  private List<PetStageCO> petStages;

  /**
   * 解锁条件.
   */
  private List<PetUnlockConditionCO> conditions;

  /**
   * 奖励.
   */
  private ActivityPropsGroupCO rewards;

  /**
   * 领取状态.
   */
  private ReceiveStatusEnum receiveStatus;

  /**
   * 是否允许激活. true 可以，false 不可以
   */
  public Boolean getComputedActivation() {
    if (CollectionUtils.isEmpty(conditions)) {
      return Boolean.FALSE;
    }

    for (PetUnlockConditionCO condition : conditions) {
      if (!Objects.equals(condition.getSatisfy(), Boolean.TRUE)) {
        return Boolean.FALSE;
      }
    }
    return Boolean.TRUE;
  }
}
