generated from UnBParadigmas2021-2/RepositorioTemplate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
menus.pl
138 lines (126 loc) · 4.29 KB
/
menus.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
:- [facts].
:- [utils].
game_recommendation :-
clear,
write('\n========== Menu de Indicação de jogos ======='),nl,
write('[1] - Recomendação por preferencias'),nl,
write('[2] - Recomendação aleatória'),nl,
write('[0] - Voltar ao Menu Inicial'),nl,
read_string(user, "\n", "\r", _, Option),
switch(
Option,
[
"1" : preferences,
"2" : random_recommendation,
"3" : exit,
"0" : main_menu
],
game_recommendation
).
game_list :-
clear,
write('\n========== Menu de Listagem de jogos ======='),nl,
write('[1] - Listar por desenvolvedor'),nl,
write('[2] - Listar todos os games'),nl,
write('[3] - Listar por Genero'),nl,
write('[0] - Voltar ao Menu Inicial'),nl,
read_string(user, "\n", "\r", _, Option),
switch(
Option,
[
"1" : by_developer,
"2" : list_all_games,
"3" : by_genre,
"0" : main_menu
],
game_list
).
main_menu:-
clear,
write('=========== Bem vindo ao Steam Seeker ========='),nl,
write('[1] - Me indique um jogo'),nl,
write('[2] - Liste jogos'),nl,
write('[0] - Encerrar programa'),nl,
read_string(user, "\n", "\r", _, Option),
switch(
Option,
[
"1" : game_recommendation,
"2" : game_list,
"0" : exit
],
main_menu
).
menu_category:-
clear,
write('Selecione a categoria'),nl,
setof(CategoryName, category(CategoryName), CategoryList),
(display(CategoryList, 0) ; true),
write('--------------------------------------'),nl,
write('Digite o numero da categoria'),nl,
read_string(user, "\n", "\r", _, Option),
number_string(ConvertedOption, Option),
checkinput(ConvertedOption,CategoryList),
nb_getval(checkresult, SelectedCategory),
save_preference(user_category, CategoryList, SelectedCategory),
clear.
menu_genre:-
clear,
write('Selecione o genero'),nl,
setof(GenreName, genre(GenreName), GenreList),
(display(GenreList, 0) ; true),
write('--------------------------------------'),nl,
write('Digite o numero do genero'),nl,
read_string(user, "\n", "\r", _, Option),
number_string(ConvertedOption, Option),
checkinput(ConvertedOption, GenreList),
nb_getval(checkresult, SelectedGenre),
save_preference(user_genre, GenreList, SelectedGenre),
clear.
menu_publisher:-
clear,
write('Selecione o Editora'),nl,
setof(PublisherName, publisher(PublisherName), PublisherList),
(display(PublisherList, 0) ; true),
write('0 - Nao especificar'), nl,
write('--------------------------------------'),nl,
write('Digite o numero da editora'),nl,
read_string(user, "\n", "\r", _, Option),
number_string(ConvertedOption, Option),
checkinput(ConvertedOption, PublisherList),
nb_getval(checkresult, SelectedPublisher),
save_preference(user_publisher, PublisherList, SelectedPublisher),
clear.
menu_developer:-
clear,
write('Selecione o desenvolvedor'),nl,
setof(DeveloperName, developer(DeveloperName), DeveloperList),
(display(DeveloperList, 0) ; true),
write('0 - Nao especificar'),nl,
write('--------------------------------------'),nl,
write('Digite o numero referente ao desenvolvedor'),nl,
read_string(user, "\n", "\r", _, Option),
number_string(ConvertedOption, Option),
checkinput(ConvertedOption,DeveloperList),
nb_getval(checkresult, SelectedDeveloper),
save_preference(user_developer,DeveloperList, SelectedDeveloper),
clear.
game_details(GameID) :-
game(GameID, Name, _, _, _, _, _, _, _, Description),
clear,
write("========== JOGO RECOMENDADO =========="),nl,
write("Nome:"),nl,
write(Name),nl,
write("Descrição:"),nl,
write(Description), nl,
nl, write("Pressione ENTER para retornar ao menu..."), nl,
get_char(_).
show_game_as_list_item(GameID) :-
game(GameID, Name, _, _, _, Cat, Gen, _, _, _),
format('Nome: ~w', Name), nl,
format('Gênero (s): ~w', [Gen]), nl,
format('Categoria (s): ~w', [Cat]), nl, nl, nl.
show_error :-
write("Não foi encontrado nenhum jogo com os filtros selecionados."),nl,nl,
write("Pressione ENTER para retornar ao menu..."), nl,
get_char(_).