Anri/AdBlockNot
Archived
1
0
Fork 0
This repository has been archived on 2024-01-28. You can view files and clone it, but cannot push or open issues or pull requests.
AdBlockNot/scripts/ads/ads_operation.gd

57 lines
959 B
GDScript3
Raw Normal View History

2024-01-28 18:13:30 +01:00
extends "res://scripts/ads/ads_default.gd"
2024-01-28 19:07:40 +01:00
@onready var question := $Question
@onready var responseA := $Button1
@onready var responseB := $Button2
enum OP {
ADD,
SUB,
MUL,
}
var reponse
2024-01-28 18:13:30 +01:00
func _ready():
2024-01-28 22:30:48 +01:00
new_game()
func new_game():
2024-01-28 19:07:40 +01:00
var a := randi_range(0, 9)
var b := randi_range(0, 9)
var operation = OP.values().pick_random()
var operator := ""
match operation:
OP.ADD:
reponse = a + b
operator = "+"
OP.SUB:
reponse = a - b
operator = "-"
OP.MUL:
reponse = a * b
2024-01-28 22:30:48 +01:00
operator = "x"
2024-01-28 19:07:40 +01:00
question.text = str(str(a), " ", operator, " " , str(b))
var buttons := [responseA, responseB]
buttons.shuffle()
buttons[0].text = str(reponse)
buttons[1].text = str(randi_range(-10, 30))
2024-01-28 18:13:30 +01:00
func exit_condition():
return condition
2024-01-28 19:07:40 +01:00
func _on_button_1_pressed():
2024-01-28 22:30:48 +01:00
check(int(responseA.text))
2024-01-28 19:07:40 +01:00
func _on_button_2_pressed():
2024-01-28 22:30:48 +01:00
check(int(responseB.text))
func check(data):
if data == reponse:
condition = true
else:
new_game()