Skip to content
This repository has been archived by the owner on Jan 13, 2022. It is now read-only.

Commit

Permalink
initial sending progress
Browse files Browse the repository at this point in the history
  • Loading branch information
brucero committed May 26, 2011
1 parent d4c79d9 commit 0a604e1
Show file tree
Hide file tree
Showing 9 changed files with 332 additions and 44 deletions.
3 changes: 1 addition & 2 deletions bin/jsgamebench
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ LogProc = require('../lib/logproc');

Utils = require('../engine/core/utils');
Users = require('../lib/users');
Graph = require('../lib/graph');
Server = require('../lib/server');
Comm = require('../lib/comm');
Grid = require('../engine/shared/grid');
Expand Down Expand Up @@ -67,9 +68,7 @@ for(var i=0;i<process.argv.length;i++) {
}
}

if (sslPort) {
https = require('https');
}

sys.puts("reading log file");
LogProc.start('logs/stats.log',null);
Expand Down
17 changes: 17 additions & 0 deletions chess/cheevo/win.shtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:og="http://ogp.me/ns#"
xmlns:fb="https://www.facebook.com/2008/fbml">
<head>
<title>Win With Rook</title>
<meta property="og:type" content="og:games.achievement"/>
<meta property="og:url" content="http://pirateninjachess.com/chess/cheevo/win.shtml"/>
<meta property="og:title" content="Win A Game With Rook"/>
<meta property="og:description"
content="Win a game with rook"/>
<meta property="og:image" content="http://t0.gstatic.com/images?q=tbn:ANd9GcT4QORJxRO5bvS5MeAnmP18MUUynqAI2B_cN75zpsXSQB18jQZw" />
<meta property="og:points" content="10" />
</head>
<body>
<h1>This Is For Open Graph Only, not for looking at! go-way!!</h1>
</body>
</html>
8 changes: 5 additions & 3 deletions chess/chess.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ var Chess = (function() {
}
if (game_state == 'menu') {
var dt = parseInt(((new Date).getTime() - menu_time) / 1000);
if (dt > request_time) {
if (0 && dt > request_time) {
Publish.getRequests(game_state);
request_time += Math.sqrt(dt);
}
Expand Down Expand Up @@ -132,6 +132,7 @@ var Chess = (function() {

function postImageLoad() {
logtime('postImageLoad');
dumplog(1);
Board.init();
Pieces.init();
var hash = window.location.hash;
Expand Down Expand Up @@ -231,8 +232,9 @@ var Chess = (function() {
Input.hookEvents('gamebody');
newGameState('login');
Publish.fbInit(fb_app_id);
loadImageList('/chess/images/',['Pirate_King.png', 'Ninja_King.png', 'Pirate_Queen.png', 'Ninja_Queen.png', 'Pirate_Bishop.png', 'Ninja_Bishop.png', 'Pirate_Knight.png', 'Ninja_Knight.png', 'Pirate_Rook.png', 'Ninja_Rook.png', 'Pirate_Pawn.png', 'Ninja_Pawn.png']);
loadAnimList('/chess/images/',[['small_explo.png', 6]]);
loadImageList('/chess/images/',['Pirate_King.png']);
//loadImageList('/chess/images/',['Pirate_King.png', 'Ninja_King.png', 'Pirate_Queen.png', 'Ninja_Queen.png', 'Pirate_Bishop.png', 'Ninja_Bishop.png', 'Pirate_Knight.png', 'Ninja_Knight.png', 'Pirate_Rook.png', 'Ninja_Rook.png', 'Pirate_Pawn.png', 'Ninja_Pawn.png']);
//loadAnimList('/chess/images/',[['small_explo.png', 6]]);
}

function concede() {
Expand Down
2 changes: 1 addition & 1 deletion chess/chess.manifest
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
CACHE MANIFEST
# version 1.2
# version 1.3

images/Ninja_Bishop.png
images/Ninja_King.png
Expand Down
43 changes: 18 additions & 25 deletions chess/index.shtml
Original file line number Diff line number Diff line change
@@ -1,43 +1,36 @@
<!DOCTYPE html>
<html >
<html> <!-- manifest="chess/chess.manifest" -->
<head>

<script type="text/javascript">

function postwith (to,p) {
var myForm = document.createElement("form");
myForm.method="post" ;
myForm.action = to ;
for (var k in p) {
var myInput = document.createElement("input") ;
myInput.setAttribute("name", k) ;
myInput.setAttribute("value", p[k]);
myForm.appendChild(myInput) ;
}
document.body.appendChild(myForm) ;
myForm.submit() ;
document.body.removeChild(myForm) ;
var log_str = '';
var g_base_time = (new Date).getTime();
var dump_count = 3;
function logtime(str) {
log_str += ((new Date).getTime() - g_base_time) + ' ' + str + '\n';
}

function dumplog() {
function dumplog(mask) {
dump_count &= ~mask;
if (dump_count) {
return;
}
console.log(log_str);
//postwith('/results',{log_str: log_str});
mypostrequest = new XMLHttpRequest();
mypostrequest.open("POST", "/results", true);
mypostrequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
mypostrequest.send("log_str="+log_str);
}


var log_str = '';
var g_base_time = (new Date).getTime();
function logtime(str) {
log_str += ((new Date).getTime() - g_base_time) + ' ' + str + ', ';
}
logtime('index.html');
logtime('index.html');
</script>


<script type="text/javascript"> logtime('css load') </script>
<link rel="stylesheet" type="text/css" href="/chess/style.css" />
<script type="text/javascript"> logtime('jssdk lib load') </script>
#include '/engine/include/fb_jssdk.include'
<script type="text/javascript" src="/chess/mc_all.js"></script>
<script type="text/javascript"> logtime('jssdk lib load-done') </script>
#include '/engine/include/portrait.include'
#include 'app_id'
Expand Down
1 change: 1 addition & 0 deletions chess/pieces.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ var Pieces = (function() {
sprite = color == White ? "Pirate_King" : "Ninja_King";
break;
}
sprite = "Pirate_King";
square.piece = Gob.add(Utils.uuidv4(), sprite, 0, [square.left+square.delta*0.5,square.top+square.delta*0.5], [0,0], 10, default_scale*square.delta/piecescales[type]);
square.piece.type = type;
square.piece.color = color;
Expand Down
19 changes: 16 additions & 3 deletions chess/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,14 @@ var Publish = (function() {
logtime('FB.init');
FB.init({
appId : fb_app_id,
status : true, // check login status
status : false, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : false // parse XFBML
});
logtime('FB.init-done (sync)');
logtime('FB.getLoginStatus');
FB.getLoginStatus(function(response) {
logtime('FB.getLoginStatus-'+response.session);
dumplog();
logtime('FB.getLoginStatus-done');
fb_logged_in = response.session;
if (response.session) {
console.log('logged in');
Expand Down Expand Up @@ -91,11 +90,14 @@ var Publish = (function() {
}

function getInfo() {
logtime('getinfo');
FB.api('me', {
fields: 'name, picture'
}, function (result) {
player.name = result.name;
player.picture = result.picture;
logtime('getinfo-done');
dumplog(2);
});
getRequests();
}
Expand Down Expand Up @@ -129,8 +131,11 @@ var Publish = (function() {
}

function getRequests(valid_state) {
logtime('request');
FB.api('me/apprequests', function(result) {
var reqs = result.data;
logtime('request-done');
dumplog(4);
if (!reqs || valid_state != Chess.gameState()) {
return;
}
Expand Down Expand Up @@ -196,6 +201,7 @@ var Publish = (function() {
var time_str = (t.getHours() % 12) +':'+ t.getMinutes() + (t.getHours()<=12 ? 'AM' : 'PM') + ' ' + t.toString().split(' ')[0];
Publish.sendRequest('(game started '+time_str+')',payload);
}
sendMsg('addcheevo win');
}

function publishStory() {
Expand Down Expand Up @@ -233,6 +239,13 @@ var Publish = (function() {
});
}

function sendMsg(str) {
mypostrequest = new XMLHttpRequest();
mypostrequest.open("POST", "/msg", true);
mypostrequest.setRequestHeader("Content-type", "text/plain");
mypostrequest.send('cmd: ' + str);
}

return {
publishStory: publishStory,
sendRequest: sendRequest,
Expand Down
Loading

0 comments on commit 0a604e1

Please sign in to comment.