import { formatUnits } from "viem";
import { BossLevel, usePlayer } from "../providers/PlayerProvider";
import styles from "../styles/Modal.module.css";
import { bossToReward } from "./BossInfo";

interface BossOutcomeModalProps {
  setIsOpen: (val: boolean) => void,
  outcome: boolean,
  ascended: boolean,
  bossLevel: BossLevel
}

const BossOutcomeModal = ({ setIsOpen, outcome, ascended, bossLevel }: BossOutcomeModalProps) => {
  const text = outcome ? "and you won! 🤩" : "and you lost 😔";
  const rewardAmount = parseFloat(parseFloat(formatUnits(bossToReward[bossLevel], 18).toString()).toFixed(4));
  const rewardText =
    ascended ? <p>You won <strong>{rewardAmount} RGCVII</strong> and <strong>ASCENDED!!!</strong>. This means you beat the bosses and gained a <strong>Prestige level</strong>. Your GELD is now forfeit, but your legend lives on.</p>
      : outcome ? <p>You won <strong>{rewardAmount} RGCVII</strong></p>
        : <p>Your GELD is now forfeit. Try again 💪 we know you can do it!</p>

  return <div className={styles.modal}>
    <h2>You battled a boss</h2>
    <p>{text}</p>
    {rewardText}
    <div>
      <button onClick={() => setIsOpen(false)}>Proceed</button>
    </div>
  </div>
}

export default BossOutcomeModal 
