1+ var GeradorJogosSteam = {
2+
3+ SteamId : null ,
4+
5+ StaticUrl : {
6+ urlSeparatorImage : "https://i.imgur.com/b7NydPU.png" ,
7+ urlMetacriticLogoImage : "https://i.imgur.com/hzTTczo.png" ,
8+ } ,
9+
10+ Data : {
11+ Steam : null
12+ } ,
13+
14+ Validar : function ( ) {
15+
16+ if ( this . SteamId . trim ( ) . length == 0 || this . SteamId == null ) {
17+ bulmaToast . toast ( { message : "O código do jogo na STEAM é obrigatório" , type : "is-danger" , duration : 4000 } ) ;
18+ return false ;
19+ }
20+
21+ this . Data . Steam = this . SteamService ( this . SteamId . trim ( ) ) [ this . SteamId ] ;
22+
23+ if ( this . Data . Steam . success == false ) {
24+ bulmaToast . toast ( { message : "O código do jogo na STEAM informado é inválido!" , type : "is-danger" , duration : 4000 } ) ;
25+ return false ;
26+ }
27+
28+ baseLib . copyToClipboard ( this . GerarBBCode ( ) ) ;
29+ bulmaToast . toast ( { message : "BBCode copiado para a área de transferência!" , type : "is-success" , duration : 4000 } ) ;
30+
31+
32+ } ,
33+
34+ GerarBBCode : function ( ) {
35+ var str = `
36+ ${ this . InserirSeparador ( ) }
37+ ${ this . InserirTitulo ( ) }
38+ ${ this . InserirSeparador ( ) }
39+ ${ this . InserirCapa ( ) }
40+ ${ this . InserirSeparador ( ) }
41+ ${ this . InserirSinopse ( ) }
42+ ${ this . InserirSeparador ( ) }
43+ ${ this . InserirInformacao ( ) }
44+ ${ this . InserirSeparador ( ) }
45+ ${ this . InserirCritica ( ) }
46+ ${ this . InserirSeparador ( ) }
47+ ${ this . InserirScreenshots ( ) }
48+
49+ ` ;
50+
51+ return str ;
52+
53+ } ,
54+
55+ InserirSeparador : function ( ) {
56+ return `[align=center][img]${ this . StaticUrl . urlSeparatorImage } [/img][/align]` ;
57+ } ,
58+
59+ InserirTitulo : function ( ) {
60+ var str = `[b][align=center] ${ this . Data . Steam . data . name } [/align][/b]
61+ [b][align=center] (-- ${ baseLib . getYearFromDDMMMYYYY ( this . Data . Steam . data . release_date . date ) } --) [/align][/b]` ;
62+
63+ return str ;
64+ } ,
65+
66+ InserirCapa : function ( ) {
67+ return `[align=center][img]${ this . Data . Steam . data . header_image } [/img][/align]` ;
68+ } ,
69+
70+ InserirSinopse : function ( ) {
71+ var str = `[b][align=center]SINOPSE[/align][/b]
72+ [align=center]${ this . Data . Steam . data . about_the_game } [/align]` ;
73+
74+
75+ return str ;
76+ } ,
77+
78+ InserirInformacao : function ( ) {
79+ var str = "" ;
80+ str += "\n[b][align=center]INFORMAÇÕES[/align][/b]" ;
81+ str += `\n[align=center]Data de Lançamento: ${ this . Data . Steam . data . release_date . date } [/align]` ;
82+ str += `\n[align=center]Gêneros: ${ this . Data . Steam . data . genres . map ( function ( elem ) { return elem . description ; } ) . join ( ", " ) } [/align]` ;
83+ str += `\n[align=center]Publicadores: ${ this . Data . Steam . data . publishers . join ( ", " ) } [/align]` ;
84+ str += `\n[align=center]Desenvolvedores: ${ this . Data . Steam . data . developers . join ( ", " ) } [/align]` ;
85+ if ( this . Data . Steam . data . price_overview != null ) str += `\n[align=center]Preço (na STEAM): ${ this . Data . Steam . data . price_overview . final_formatted } [/align]` ;
86+ if ( this . Data . Steam . data . website == null ) str += `\n[align=center]Site: [url=${ this . Data . Steam . data . website } ] Clique aqui [/url][/align]` ;
87+
88+ return str ;
89+ } ,
90+
91+ InserirCritica : function ( ) {
92+ var str = "" ;
93+
94+ str += "\n[b][align=center]CRÍTICA[/align][/b]" ;
95+ if ( this . Data . Steam . data . metacritic != null ) {
96+ str += `\n[align=center][img]${ this . StaticUrl . urlMetacriticLogoImage } [/img][/align]` ;
97+ str += `\n[align=center][b][url=${ this . Data . Steam . data . metacritic . url } ]${ this . Data . Steam . data . metacritic . score } /100[/b][/url][/align]`
98+ } else {
99+ str += `\n[align=center][b]###### SEM CRÍTICA ######[/b][/align]`
100+ }
101+
102+ return str ;
103+ } ,
104+
105+ InserirScreenshots : function ( ) {
106+ var str = "" ;
107+ str += "\n[b][align=center]SCREENSHOTS[/align][/b]" ;
108+
109+ this . Data . Steam . data . screenshots . forEach ( element => {
110+ str += `\n[align=center][img] ${ element . path_full . trim ( ) } [/img][/align]`
111+ } ) ;
112+
113+ return str ;
114+ } ,
115+
116+ InserirTrailer : function ( ) {
117+
118+ } ,
119+
120+ InserirAgradecaComente : function ( ) {
121+
122+ } ,
123+
124+
125+ SteamService : function ( ) {
126+ var urlRequest = "https://vindicator.com.br/steam?id=" + this . SteamId ;
127+
128+ var result = null ;
129+
130+ $ . ajax ( {
131+ url : urlRequest ,
132+ async : false ,
133+ success : function ( data ) {
134+ result = data ;
135+ console . log ( result ) ;
136+ }
137+ } ) ;
138+ return result ;
139+ } ,
140+ } ;
0 commit comments