package com.example.courseworkkotlin

import android.content.Intent
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.example.courseworkkotlin.databinding.ActivityMbtiResultBinding

class MBTIResult : AppCompatActivity() {
    private lateinit var binding: ActivityMbtiResultBinding

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding = ActivityMbtiResultBinding.inflate(layoutInflater)
        setContentView(binding.root)

        displayResult()

        binding.home.setOnClickListener { startActivity(Intent(this, HomeScreen::class.java)) }
    }

    private fun displayResult() {
        val answer = intent.getStringExtra("answer")
        binding.Result.text = answer

        when (answer) {
            "ESTJ" -> binding.Explanation.text = resources.getText(R.string.ESTJ)
            "ISTJ" -> binding.Explanation.text = resources.getText(R.string.ISTJ)
            "ESTP" -> binding.Explanation.text = resources.getText(R.string.ESTP)
            "ISTP" -> binding.Explanation.text = resources.getText(R.string.ISTP)
            "ENTJ" -> binding.Explanation.text = resources.getText(R.string.ENTJ)
            "INTJ" -> binding.Explanation.text = resources.getText(R.string.INTJ)
            "ENTP" -> binding.Explanation.text = resources.getText(R.string.ENTP)
            "INTP" -> binding.Explanation.text = resources.getText(R.string.INTP)
            "ESFJ" -> binding.Explanation.text = resources.getText(R.string.ESFJ)
            "ISFJ" -> binding.Explanation.text = resources.getText(R.string.ISFJ)
            "ESFP" -> binding.Explanation.text = resources.getText(R.string.ESFP)
            "ISFP" -> binding.Explanation.text = resources.getText(R.string.ISFP)
            "ENFJ" -> binding.Explanation.text = resources.getText(R.string.ENFJ)
            "INFJ" -> binding.Explanation.text = resources.getText(R.string.INFJ)
            "ENFP" -> binding.Explanation.text = resources.getText(R.string.ENFP)
            "INFP" -> binding.Explanation.text = resources.getText(R.string.INFP)
            else -> binding.Explanation.text = "That's not supposed to happen."
        }

    }
}