Skip to content

Commit

Permalink
Map expieration timestamps / names (#4633) (#4636)
Browse files Browse the repository at this point in the history
* Map expieration timestamps / names (#4633)

* name from ID

* p name

* name from id

* Pokemon name & expiration information

* Update map.js

* Update map.js

* Add files via upload

* Update main.js

* Update map.js

* Add files via upload (#4637)
  • Loading branch information
BreezeRo authored Aug 24, 2016
1 parent 081c5e3 commit 73c359f
Show file tree
Hide file tree
Showing 17 changed files with 34 additions and 13 deletions.
Binary file modified map-chat/images/blue_marker.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified map-chat/images/grey_marker.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added map-chat/images/p/01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added map-chat/images/p/02.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added map-chat/images/p/03.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added map-chat/images/p/04.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added map-chat/images/p/05.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added map-chat/images/p/06.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added map-chat/images/p/07.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added map-chat/images/p/08.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added map-chat/images/p/09.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 5 additions & 3 deletions map-chat/javascript/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@ function initialiseEventBus(){
var olong = pLoadR2[1]
var sessid = pLoadR2[2]
var ico = pLoadR2[3]
var expir = pLoadR2[4]
var pokenick = pLoadR2[5]
var path = "./images/p/"
var icon = path+"0"+ico+".png"
var icostr = icon.toString();
//console.log(icostr)
var icostr = icon.toString();
//console.log(icostr)

displayMessageOnMap(payload, olat, olong, sessid, icostr);
displayMessageOnMap(payload, olat, olong, sessid, icostr, expir, pokenick);
}
});

Expand Down
26 changes: 21 additions & 5 deletions map-chat/javascript/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,12 +207,27 @@ function displayChatMessageOnMap(raw){
}
}

function displayMessageOnMap(msg, olat, olong, sessid, icostr){
// @ro: to calculate time until expiration
function timeUntil(now, then) {
var timestampNow = Date.parse(now);
var timestampThen = Date.parse(then);
var diff = new Date(timestampThen - timestampNow);

diff.setSeconds(Math.round(diff.getSeconds() / 30) * 30);

return diff;
}


function displayMessageOnMap(msg, olat, olong, sessid, icostr, expir, pokenick){

// @ro: passing values split from incoming payload into two variables for now (lat and long)
var newPosition = new google.maps.LatLng(olat, olong);
var msgSessionId = sessid;

var expiration = expir;
var thetime = "155564565475"
var pName = pokenick/* + " disappears in " + timeUntil(thetime,expiration)*/;
console.log(pName)
// @ro: just checking the output
//console.log(olat);
//console.log(olong);
Expand All @@ -233,7 +248,7 @@ function displayMessageOnMap(msg, olat, olong, sessid, icostr){

if(markersMap[msgSessionId]){ // update existing marker
var infoWindow = new google.maps.InfoWindow({
content: msg.text,
content: pName,
maxWidth: 400,
disableAutoPan: true,
zIndex: infoWindowZIndex
Expand All @@ -245,6 +260,7 @@ function displayMessageOnMap(msg, olat, olong, sessid, icostr){
map: map,
draggable: false,
icon: icostr,
icon: { url: icostr, scaledSize: new google.maps.Size(60,60) },
title: "Click to mute/un-mute User "+msgSessionId
});

Expand All @@ -260,7 +276,7 @@ function displayMessageOnMap(msg, olat, olong, sessid, icostr){
});
} else { // new marker
var infoWindow = new google.maps.InfoWindow({
content: msg.text,
content: pName,
maxWidth: 400,
disableAutoPan: true,
zIndex: infoWindowZIndex
Expand All @@ -271,7 +287,7 @@ function displayMessageOnMap(msg, olat, olong, sessid, icostr){
position: newPosition,
map: map,
draggable: false,
icon: markerImage,
icon: { url: icostr, scaledSize: new google.maps.Size(60,60) },
title: "Click to mute/un-mute User "+msgSessionId
});

Expand Down
3 changes: 2 additions & 1 deletion pokemongo_bot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,8 @@ def _register_events(self):
'encounter_id',
'latitude',
'longitude',
'expiration_timestamp_ms'
'expiration_timestamp_ms',
'pokemon_name'
)
)
self.event_manager.register_event(
Expand Down
3 changes: 2 additions & 1 deletion pokemongo_bot/cell_workers/catch_pokemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from utils import fort_details, distance
from pokemongo_bot.base_dir import _base_dir
from pokemongo_bot.constants import Constants

from pokemongo_bot.inventory import Pokemons, Pokemon, Attack

class CatchPokemon(BaseTask):
SUPPORTED_TASK_API_VERSION = 1
Expand Down Expand Up @@ -60,6 +60,7 @@ def get_visible_pokemon(self):
'latitude': pokemon['latitude'],
'longitude': pokemon['longitude'],
'expiration_timestamp_ms': pokemon['expiration_timestamp_ms'],
'pokemon_name': Pokemons.name_for(pokemon['pokemon_id']),
}
)

Expand Down
3 changes: 2 additions & 1 deletion pokemongo_bot/cell_workers/catch_visible_pokemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from utils import distance
from pokemongo_bot.worker_result import WorkerResult
from pokemongo_bot.base_dir import _base_dir

from pokemongo_bot.inventory import Pokemons, Pokemon, Attack

class CatchVisiblePokemon(BaseTask):
SUPPORTED_TASK_API_VERSION = 1
Expand Down Expand Up @@ -54,6 +54,7 @@ def work(self):
'latitude': pokemon['latitude'],
'longitude': pokemon['longitude'],
'expiration_timestamp_ms': pokemon['expiration_timestamp_ms'],
'pokemon_name': Pokemons.name_for(pokemon['pokemon_id']),
}
)
if not self.was_encountered(pokemon):
Expand Down
4 changes: 2 additions & 2 deletions pokemongo_bot/event_handlers/social_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ def handle_event(self, event, sender, level, formatted_msg, data):
#self.mqttc.publish("pgomapcatch/all/catchable/"+str(data['pokemon_id']), str(data))
# precision=4 mean 19545 meters, http://stackoverflow.com/questions/13836416/geohash-and-max-distance
geo_hash = Geohash.encode(data['latitude'], data['longitude'], precision=4)
self.mqttc.publish("pgomapgeo/"+geo_hash+"/"+str(data['pokemon_id']), str(data['latitude'])+","+str(data['longitude'])+","+str(data['encounter_id'])+","+str(data['pokemon_id']))
self.mqttc.publish("pgomapcatch/all/catchable/"+str(data['pokemon_id']), str(data['latitude'])+","+str(data['longitude'])+","+str(data['encounter_id'])+","+str(data['pokemon_id']))
self.mqttc.publish("pgomapgeo/"+geo_hash+"/"+str(data['pokemon_id']), str(data['latitude'])+","+str(data['longitude'])+","+str(data['encounter_id'])+","+str(data['pokemon_id'])+","+str(data['expiration_timestamp_ms'])+","+str(data['pokemon_name']))
self.mqttc.publish("pgomapcatch/all/catchable/"+str(data['pokemon_id']), str(data['latitude'])+","+str(data['longitude'])+","+str(data['encounter_id'])+","+str(data['pokemon_id'])+","+str(data['expiration_timestamp_ms'])+","+str(data['pokemon_name']))

#print 'have catchable_pokemon'
#print message

0 comments on commit 73c359f

Please sign in to comment.