import { RoleType } from '@/domain/enums'
import { DomainError } from '@/shared/exceptions'

export class BenefitAmount {
  constructor(
    public readonly usdtPerTree: number,
    public readonly computingPowerPercentage: number,
  ) {}

  static forCommunity(): BenefitAmount {
    return new BenefitAmount(80, 0)
  }

  static forAuthProvince(): BenefitAmount {
    return new BenefitAmount(20, 0)
  }

  static forProvince(): BenefitAmount {
    return new BenefitAmount(15, 1)
  }

  static forAuthCity(): BenefitAmount {
    return new BenefitAmount(40, 0)
  }

  static forCity(): BenefitAmount {
    return new BenefitAmount(35, 2)
  }

  static forRoleType(roleType: RoleType): BenefitAmount {
    switch (roleType) {
      case RoleType.COMMUNITY:
        return this.forCommunity()
      case RoleType.AUTH_PROVINCE_COMPANY:
        return this.forAuthProvince()
      case RoleType.PROVINCE_COMPANY:
        return this.forProvince()
      case RoleType.AUTH_CITY_COMPANY:
        return this.forAuthCity()
      case RoleType.CITY_COMPANY:
        return this.forCity()
      default:
        throw new DomainError(`未知角色类型: ${roleType}`)
    }
  }
}
