Skip to content
This repository was archived by the owner on Dec 18, 2020. It is now read-only.

Commit e98fa69

Browse files
committed
[FIX] Pokepikadora out hasta que funcione la API
1 parent 8dfac2f commit e98fa69

File tree

15 files changed

+600
-15
lines changed

15 files changed

+600
-15
lines changed

client/_index.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44
<meta charset="utf-8">
55
<meta http-equiv="x-ua-compatible" content="ie=edge">
66
<base href="/">
7-
<title>Angular Full-Stack Generator</title>
8-
<meta name="description" content="">
7+
<title>Ranking de Mazos - Clan Elite España de Clash Royale</title>
8+
<meta name="description" content="WebApp del clan Elite España de Clash Royale: Top de Mazos, Torneos, y home del clan">
9+
<meta name="keywords" content="Clash Royale, Supercell, España, Spain, Deck, Mazo, Cards, Cartas, Clan, Elite España">
910
<meta name="viewport" content="width=device-width">
11+
<meta name="google-site-verification" content="Gg7DJttoAb0Tkr5Jec4a-6w4mYKpKYwkUU1rXB97KBE" />
1012
<!-- Place favicon.ico and apple-touch-icon.png in the root directory -->
1113
</head>
1214
<body>

client/app/app.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,11 @@ $fondo-negro-semitrans: rgba(51,51,51,0.75);
104104
@import 'admin/admin';
105105
@import 'main/main';
106106
@import '../components/clan/clan';
107+
@import '../components/cofres/cofres';
107108
@import '../components/footer/footer';
108109
@import '../components/modal/modal';
109110
@import '../components/navbar/navbar';
110111
@import '../components/oauth-buttons/oauth-buttons';
112+
@import '../components/pokesalchichas/pokesalchichas';
111113
@import '../components/rrss/rrss';
112114
/* endinject */

client/components/pokesalchichas/pokesalchichas.jade

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,38 +9,45 @@
99
p La picadora de momento no funciona automáticamente. Estoy esperando a que actualicen la API...de mientras, a mano ;)
1010

1111
h1.page-header Cuenta de PokemonGO:
12-
form.form.pokesalchichasForm(name='form', ng-submit='pokesalchichas.getPokemons()', novalidate='')
12+
form.form.pokesalchichasForm(name='form', ng-submit='$ctrl.getPokemons()', novalidate='')
1313

1414
div.input-group.input-group-lg
1515
span.input-group-addon
1616
span.glyphicon.glyphicon-user
17-
input.form-control(type="text", placeholder="Usuario", aria-describedby="basic-addon1", ng-model='pokesalchichas.user.user')
17+
input.form-control(type="text", placeholder="Usuario", aria-describedby="basic-addon1", ng-model='$ctrl.user.user')
1818

1919
div.input-group.input-group-lg
2020
span.input-group-addon
2121
span.glyphicon.glyphicon-barcode
22-
input.form-control(type="password", placeholder="Contraseña", aria-describedby="basic-addon1", ng-model='pokesalchichas.user.password')
22+
input.form-control(type="password", placeholder="Contraseña", aria-describedby="basic-addon1", ng-model='$ctrl.user.password')
2323

2424
div.btn-group
25-
label.btn.btn-primary(ng-model="pokesalchichas.user.proveedor", uib-btn-radio="'ptc'") PTC
26-
label.btn.btn-primary(ng-model="pokesalchichas.user.proveedor", uib-btn-radio="'google'") Google
25+
label.btn.btn-primary(ng-model="$ctrl.user.proveedor", uib-btn-radio="'ptc'") PTC
26+
label.btn.btn-primary(ng-model="$ctrl.user.proveedor", uib-btn-radio="'google'") Google
2727

2828
div.input-group.input-group-lg
2929
span.input-group-addon
3030
span.glyphicon.glyphicon-globe
31-
input.form-control(type="text", placeholder="Plaza del Sol 1, Madrid, 28013 Spain", aria-describedby="basic-addon1", ng-model='pokesalchichas.user.localization')
31+
input.form-control(type="text", placeholder="Plaza del Sol 1, Madrid, 28013 Spain", aria-describedby="basic-addon1", ng-model='$ctrl.user.localization')
3232

33-
div.alert.alert-danger(ng-show='pokesalchichas.error')
33+
div.alert.alert-danger(ng-show='$ctrl.error')
3434
p Hay algún tipo de error con los datos que has introducido.
3535
p Comprueba que el nombre de usuario y contraseña sean correctos
3636
p Has de seleccionar el proveedor entre "Pokemon Trainer Club" y "Google"
37-
p Es mejor que selecciones una localización cercana a donde estés, por seguridad; Así no parecerá que te has "teleportado" si abres el juego a continuación
37+
38+
div.alert.alert-danger
39+
p Hasta que la API vuelva a funcionar, <strong>esta herramienta no es segura</strong>
40+
p Por lo tanto estará <strong>deshabilitada</strong> hasta que la comunidad de con la tecla
41+
p Si quieres <strong>mas info</strong>, búscala en
42+
a(href='https://www.reddit.com/r/TheSilphRoad') r/TheSilphRoad
43+
| y
44+
a(href='https://www.reddit.com/r/pokemongodev') r/pokemongodev
3845

3946
div
40-
button.btn.btn-success.btn-lg.btn-login(type='submit')
47+
button.btn.btn-success.btn-lg.btn-login.disabled(type='submit')
4148
| Conectarse
4249

43-
ul.nav.nav-tabs.nav-stacked.col-md-2.col-lg-2.col-sm-2.col-xs-4.pokeLista(ng-repeat='pokemon in pokesalchichas.pokeLista')
50+
ul.nav.nav-tabs.nav-stacked.col-md-2.col-lg-2.col-sm-2.col-xs-4.pokeLista(ng-repeat='pokemon in $ctrl.pokeLista')
4451
li
4552
img.text-center.img-responsive.center-block(src='{{ pokemon.info.img }}')
4653
h5.text-center {{ pokemon.info.name }}
@@ -50,7 +57,7 @@
5057
p.text-center(ng-class="(pokemon.indStamina == 15) ? 'bg-success' : ((pokemon.indStamina >= 12) ? 'bg-warning' : '')") STA {{ pokemon.indStamina }}
5158
p.text-center(ng-class="((((pokemon.indAttack+pokemon.indDefense+pokemon.indStamina)*100)/45) == 100) ? 'bg-success' : (((((pokemon.indAttack+pokemon.indDefense+pokemon.indStamina)*100)/45) >= 80) ? 'bg-warning' : (((((pokemon.indAttack+pokemon.indDefense+pokemon.indStamina)*100)/45) <= 60) ? 'bg-danger' : ''))")
5259
strong {{(((pokemon.indAttack+pokemon.indDefense+pokemon.indStamina)*100)/45)| number:0}}%
53-
button.btn.btn-danger.disabled.btn-lg.center-block(type='button', ng-click='pokesalchichas.picaPokemon(pokemon)', ng-show='(((pokemon.indAttack+pokemon.indDefense+pokemon.indStamina)*100)/45) <= 60')
60+
button.btn.btn-danger.disabled.btn-lg.center-block(type='button', ng-click='$ctrl.picaPokemon(pokemon)', ng-show='(((pokemon.indAttack+pokemon.indDefense+pokemon.indStamina)*100)/45) <= 60')
5461
span.glyphicon.glyphicon-erase
5562
| Picadora
5663
div.cubreBoton(ng-show='(((pokemon.indAttack+pokemon.indDefense+pokemon.indStamina)*100)/45) > 60')

client/index.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44
<meta charset="utf-8">
55
<meta http-equiv="x-ua-compatible" content="ie=edge">
66
<base href="/">
7-
<title>Angular Full-Stack Generator</title>
8-
<meta name="description" content="">
7+
<title>Ranking de Mazos - Clan Elite España de Clash Royale</title>
8+
<meta name="description" content="WebApp del clan Elite España de Clash Royale: Top de Mazos, Torneos, y home del clan">
9+
<meta name="keywords" content="Clash Royale, Supercell, España, Spain, Deck, Mazo, Cards, Cartas, Clan, Elite España">
910
<meta name="viewport" content="width=device-width">
11+
<meta name="google-site-verification" content="Gg7DJttoAb0Tkr5Jec4a-6w4mYKpKYwkUU1rXB97KBE" />
1012
<!-- Place favicon.ico and apple-touch-icon.png in the root directory -->
1113
</head>
1214
<body>

server/api/pgo/getPokemonList.js

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import util from 'util'
2+
import PokemonGO from 'pokemon-go-node-api'
3+
4+
const nullToZero = (object) => {
5+
if (object === null) {
6+
return 0
7+
}
8+
return object
9+
}
10+
11+
const getPokemonList = (username, password, prov, localization) => {
12+
const pokeio = new PokemonGO.Pokeio()
13+
14+
return new Promise(
15+
(resolve, reject) => {
16+
17+
pokeio.init(username, password, localization, prov, (err) => {
18+
if (err) {
19+
return reject(err)
20+
}
21+
22+
pokeio.GetProfile((err) => {
23+
if (err) {
24+
return reject(err)
25+
}
26+
27+
pokeio.Heartbeat((err) => {
28+
if (err) {
29+
return reject(err)
30+
}
31+
})
32+
33+
pokeio.GetInventory((err, inv) => {
34+
if (err) {
35+
return reject(err)
36+
}
37+
const pokemonList = inv.inventory_delta.inventory_items.reduce((prev, element) => {
38+
const pokemon = element.inventory_item_data.pokemon
39+
if (pokemon !== null && pokemon.pokemon_id !== null) {
40+
const id = Buffer.from(pokemon.id.toString()).toString('base64')
41+
const info = pokeio.pokemonlist[pokemon.pokemon_id - 1]
42+
const indAttack = nullToZero(pokemon.individual_attack)
43+
const indDefense = nullToZero(pokemon.individual_defense)
44+
const indStamina = nullToZero(pokemon.individual_stamina)
45+
46+
const pokemonObject = {
47+
id,
48+
indAttack,
49+
indDefense,
50+
indStamina,
51+
info,
52+
cp: pokemon.cp,
53+
move1: pokemon.move_1,
54+
move2: pokemon.move_2,
55+
cpMultiplier: pokemon.cp_multiplier
56+
}
57+
prev[id] = pokemonObject
58+
}
59+
return prev
60+
}, {})
61+
62+
resolve(pokemonList)
63+
})
64+
65+
})
66+
67+
})
68+
}
69+
)
70+
}
71+
72+
export default getPokemonList

server/api/pgo/index.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
'use strict';
2+
3+
var express = require('express');
4+
var controller = require('./pgo.controller');
5+
6+
var router = express.Router();
7+
8+
router.get('/', controller.index);
9+
router.get('/:usr/:pass/:prov/:loc', controller.show);
10+
router.post('/', controller.create);
11+
router.put('/:id', controller.upsert);
12+
router.patch('/:id', controller.patch);
13+
router.delete('/:id', controller.destroy);
14+
15+
module.exports = router;

server/api/pgo/index.spec.js

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
'use strict';
2+
3+
var proxyquire = require('proxyquire').noPreserveCache();
4+
5+
var pgoCtrlStub = {
6+
index: 'pgoCtrl.index',
7+
show: 'pgoCtrl.show',
8+
create: 'pgoCtrl.create',
9+
upsert: 'pgoCtrl.upsert',
10+
patch: 'pgoCtrl.patch',
11+
destroy: 'pgoCtrl.destroy'
12+
};
13+
14+
var routerStub = {
15+
get: sinon.spy(),
16+
put: sinon.spy(),
17+
patch: sinon.spy(),
18+
post: sinon.spy(),
19+
delete: sinon.spy()
20+
};
21+
22+
// require the index with our stubbed out modules
23+
var pgoIndex = proxyquire('./index.js', {
24+
express: {
25+
Router() {
26+
return routerStub;
27+
}
28+
},
29+
'./pgo.controller': pgoCtrlStub
30+
});
31+
32+
describe('Pgo API Router:', function() {
33+
it('should return an express router instance', function() {
34+
expect(pgoIndex).to.equal(routerStub);
35+
});
36+
37+
describe('GET /api/pgo', function() {
38+
it('should route to pgo.controller.index', function() {
39+
expect(routerStub.get
40+
.withArgs('/', 'pgoCtrl.index')
41+
).to.have.been.calledOnce;
42+
});
43+
});
44+
45+
describe('GET /api/pgo/:id', function() {
46+
it('should route to pgo.controller.show', function() {
47+
expect(routerStub.get
48+
.withArgs('/:id', 'pgoCtrl.show')
49+
).to.have.been.calledOnce;
50+
});
51+
});
52+
53+
describe('POST /api/pgo', function() {
54+
it('should route to pgo.controller.create', function() {
55+
expect(routerStub.post
56+
.withArgs('/', 'pgoCtrl.create')
57+
).to.have.been.calledOnce;
58+
});
59+
});
60+
61+
describe('PUT /api/pgo/:id', function() {
62+
it('should route to pgo.controller.upsert', function() {
63+
expect(routerStub.put
64+
.withArgs('/:id', 'pgoCtrl.upsert')
65+
).to.have.been.calledOnce;
66+
});
67+
});
68+
69+
describe('PATCH /api/pgo/:id', function() {
70+
it('should route to pgo.controller.patch', function() {
71+
expect(routerStub.patch
72+
.withArgs('/:id', 'pgoCtrl.patch')
73+
).to.have.been.calledOnce;
74+
});
75+
});
76+
77+
describe('DELETE /api/pgo/:id', function() {
78+
it('should route to pgo.controller.destroy', function() {
79+
expect(routerStub.delete
80+
.withArgs('/:id', 'pgoCtrl.destroy')
81+
).to.have.been.calledOnce;
82+
});
83+
});
84+
});

0 commit comments

Comments
 (0)