Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Using the player symbol and color (not tested)

* Returning the session_user_id in the map_tic.php
* Using the session_user_id when checking planets
  • Loading branch information...
commit ca413c3bd8429351eadd78e61c2927828d6b4161 1 parent c6d86d0
@Sailias Sailias authored
View
4 clients/TrainingWheels/js/main.coffee
@@ -20,7 +20,9 @@ window.startVisualization = () ->
# Once the players have loaded, start going through the tics
schemaverse.getTic () ->
- schemaverse.active = true
+ schemaverse.active = true
+
+ # The starting tic to start mapping
schemaverse.mapTic(380)
)
View
15 clients/TrainingWheels/js/schemaverse.coffee
@@ -48,12 +48,23 @@ window.schemaverse = {
for pData in planetData
$planetText = $('#planet-' + pData.referencing_id)
- if pData.player_id_1 is "11247"
- $planetText.text('R').attr('fill', 'red')
+ if pData.player_id_1 is pData.session_user_id
+ # Set the planet visual symbol and colour
+ playerSymbol = getSymbol(players[pData.session_user_id])
+ playerColour = getColor(players[pData.session_user_id])
+
+ # Replace the planet symbol in the map
+ $planetText.text(playerSymbol).attr('fill', 'red')
+
+ # Find out how many total planets the player owns
planetCount = parseInt($('#total_planets').html())
$('#total_planets').html(planetCount + 1)
else
+ # We've lost the planet
+ # Change the colour back to black and the default symbol
$planetText.text("\u26aa").attr('fill', 'black')
+
+ # Remove the planets from the count
planetCount = parseInt($('#total_planets').html())
$('#total_planets').html(planetCount - 1)
else
View
8 clients/TrainingWheels/js/schemaverse.js
@@ -25,7 +25,7 @@
},
getTicData: function(ticNumber, callback) {
return d3.json('/visualizer/map_tic.json?tic=' + ticNumber, function(data) {
- var $planetText, pData, planetCount, planetData, shipData, _i, _len;
+ var $planetText, pData, planetCount, planetData, playerColour, playerSymbol, shipData, _i, _len;
$('#tic_value').html(ticNumber);
if (data) {
shipData = data.ships;
@@ -47,8 +47,10 @@
for (_i = 0, _len = planetData.length; _i < _len; _i++) {
pData = planetData[_i];
$planetText = $('#planet-' + pData.referencing_id);
- if (pData.player_id_1 === "11247") {
- $planetText.text('R').attr('fill', 'red');
+ if (pData.player_id_1 === pData.session_user_id) {
+ playerSymbol = getSymbol(players[pData.session_user_id]);
+ playerColour = getColor(players[pData.session_user_id]);
+ $planetText.text(playerSymbol).attr('fill', 'red');
planetCount = parseInt($('#total_planets').html());
$('#total_planets').html(planetCount + 1);
} else {
View
2  clients/TrainingWheels/visualizer/map_tic.php
@@ -16,7 +16,7 @@
}
$ship_arr = pg_fetch_all($ship_result);
- $planet_result = pg_query($conn, "SELECT * FROM my_events WHERE action='CONQUER' AND (player_id_1=GET_PLAYER_ID(SESSION_USER) OR player_id_2=GET_PLAYER_ID(SESSION_USER)) AND tic=" . $tic);
+ $planet_result = pg_query($conn, "SELECT *, GET_PLAYER_ID(SESSION_USER) as session_user_id FROM my_events WHERE action='CONQUER' AND (player_id_1=GET_PLAYER_ID(SESSION_USER) OR player_id_2=GET_PLAYER_ID(SESSION_USER)) AND tic=" . $tic);
if (!$planet_result) {
echo json_encode(array('ships' => array(), 'planets' => array()));
exit;
Please sign in to comment.
Something went wrong with that request. Please try again.