#[Copyright 2025 ITwrx.
This file is part of Forget-Me-Not.
Forget-Me-Not is released under the GNU Affero General Public License 3.0.
See COPYING or <https://www.gnu.org/licenses/> for details.]#

#TODO: Use a human checker in login form or remove from project.

import std/random

type
  HumanChecker* = object
    question*: string
    id*, answer*: int
    
var humanCheckers: seq[HumanChecker]
humanCheckers = @[
  HumanChecker(id: 1, question: "26 + four, minus 10", answer: 20),
  HumanChecker(id: 2, question: "10 minus 2, + 14", answer: 22),
  HumanChecker(id: 3, question: "15 + five, minus 3", answer: 17),
  HumanChecker(id: 4, question: "9 + nine, minus 6", answer: 12),
  HumanChecker(id: 5, question: "13 - three, plus 5", answer: 15),
  HumanChecker(id: 6, question: "7 + six, plus one", answer: 14),
  HumanChecker(id: 7, question: "22 + 8, - 2", answer: 28),
  HumanChecker(id: 8, question: "4 - four, + ten", answer: 10),
  HumanChecker(id: 9, question: "16 + four, minus three", answer: 17),
  HumanChecker(id: 10, question: "twelve minus four, plus 8", answer: 16)
  ]

proc getHumanChecker*(): HumanChecker =  
  {.gcsafe.}:
    randomize()    
    return sample(humancheckers)
  
proc getHCById*(id: int): HumanChecker =
  {.gcsafe.}:
    for hc in humanCheckers:
      if hc.id == id:
        return hc
