[Toss-devel-svn] SF.net SVN: toss:[1490] trunk/Toss
Status: Beta
Brought to you by:
lukaszkaiser
|
From: <luk...@us...> - 2011-06-19 18:04:37
|
Revision: 1490
http://toss.svn.sourceforge.net/toss/?rev=1490&view=rev
Author: lukaszkaiser
Date: 2011-06-19 18:04:31 +0000 (Sun, 19 Jun 2011)
Log Message:
-----------
First PacMan example, some JS cleanups and news section in index html.
Modified Paths:
--------------
trunk/Toss/Server/ReqHandler.ml
trunk/Toss/WebClient/Connect.js
trunk/Toss/WebClient/Login.js
trunk/Toss/WebClient/Main.js
trunk/Toss/WebClient/Play.js
trunk/Toss/WebClient/State.js
trunk/Toss/WebClient/index.html
trunk/Toss/WebClient/msw.js
Added Paths:
-----------
trunk/Toss/WebClient/pics/appstore.png
trunk/Toss/examples/PacMan.toss
Modified: trunk/Toss/Server/ReqHandler.ml
===================================================================
--- trunk/Toss/Server/ReqHandler.ml 2011-06-19 11:57:18 UTC (rev 1489)
+++ trunk/Toss/Server/ReqHandler.ml 2011-06-19 18:04:31 UTC (rev 1490)
@@ -455,10 +455,7 @@
| x when x > 1 -> failwith ("passwd from db: multiple entries for " ^ uid)
| _ -> let r = List.hd res in (* r = (uid,_,_,_,pwd) *) Some (r.(4)) in
let get_user_name_surname_mail uid =
- let res0 = dbtable ("id='" ^ uid ^ "'") "users" in
- let res = if res0 = [] then
- dbtable ("id='" ^ (str_replace "-" "_" uid) ^ "'") "users"
- else res0 in
+ let res = dbtable ("id='" ^ uid ^ "'") "users" in
match List.length res with
| 0 -> ("", "", "")
| x when x > 1 -> failwith ("get_user_name: multiple entries for " ^ uid)
@@ -473,11 +470,9 @@
let list_plays game pl_id =
let or_s = "(player1='" ^ pl_id ^ "' or player2='" ^ pl_id ^ "')" in
let plays = dbtable ("game='" ^ game ^ "' and " ^ or_s) "cur_states" in
- let rpl s = str_replace "_" "-" s in
let play_name p = (* p = (pid, g, p1, p2, move, _, _, _, _) *)
- "/" ^ (rpl p.(1)) ^ "_" ^ (rpl p.(2)) ^ "_" ^ (rpl p.(3)) ^ "_" ^
- (rpl p.(0)) ^ "_" ^ (rpl p.(4)) ^ "_" ^ (rpl p.(7)) in
- lstr ~sep:"#" (List.map play_name plays) in
+ p.(1) ^"#"^ p.(2) ^"#"^ p.(3) ^"#"^ p.(0) ^"#"^ p.(4) ^"#"^ p.(7) in
+ lstr ~sep:"##" (List.map play_name plays) in
let user_plays uid =
let (name, _, _) = get_user_name_surname_mail uid in
let app_plays plays g = plays ^ "@" ^ (list_plays g uid) in
Modified: trunk/Toss/WebClient/Connect.js
===================================================================
--- trunk/Toss/WebClient/Connect.js 2011-06-19 11:57:18 UTC (rev 1489)
+++ trunk/Toss/WebClient/Connect.js 2011-06-19 18:04:31 UTC (rev 1490)
@@ -20,7 +20,7 @@
// Convert a string [str] representing python list to array and return it.
// WARNING: we use [sep] as separator, it must not occur in list elements!
-function convert_python_list (sep, str_in) {
+function parse_list (sep, str_in) {
var res_arr = [];
var str = strip(' ', '\n', str_in);
res_arr = strip('[', ']', str).split(sep);
Modified: trunk/Toss/WebClient/Login.js
===================================================================
--- trunk/Toss/WebClient/Login.js 2011-06-19 11:57:18 UTC (rev 1489)
+++ trunk/Toss/WebClient/Login.js 2011-06-19 18:04:31 UTC (rev 1490)
@@ -68,6 +68,7 @@
document.getElementById("toss-link").style.display = "none";
document.getElementById("welcome-top").style.display = "none";
document.getElementById("welcome-list-main").style.display = "none";
+ document.getElementById("news").style.display = "none";
document.getElementById("topuser").innerHTML = "Choose Your Next Game";
document.getElementById("leftupperlogo-link").href =
"index.html?simple=true";
@@ -114,7 +115,7 @@
o.appendChild (li);
}
var lst = CONN.allopnts ();
- var users = convert_python_list (',', lst);
+ var users = parse_list (',', lst);
var u = document.getElementById("users-list");
for (var i = 0; i < users.length; i++) {
if (users[i] != un && FRIENDS.indexOf(users[i]) == -1) {
@@ -229,6 +230,11 @@
alert ("Your data must not contain #, i.e. the hash symbol." + CORRMSG);
return;
}
+ if (un.indexOf ("@") > 0 || name.indexOf ("@") > 0 ||
+ surname.indexOf ("@") > 0) {
+ alert ("Your username, name and surname must not contain @." + CORRMSG);
+ return;
+ }
if (un.indexOf (",") > 0 || name.indexOf (",") > 0 ||
surname.indexOf (",") > 0 || email.indexOf (",") > 0) {
alert ("Your data must not contain commas." + CORRMSG);
Modified: trunk/Toss/WebClient/Main.js
===================================================================
--- trunk/Toss/WebClient/Main.js 2011-06-19 11:57:18 UTC (rev 1489)
+++ trunk/Toss/WebClient/Main.js 2011-06-19 18:04:31 UTC (rev 1490)
@@ -46,9 +46,8 @@
}
function play_from_string (game, s) {
- var d = game.length + 2;
- var p = s.substring(s.lastIndexOf('/') + d);
- var lst = convert_python_list ('_', p);
+ var p = s.substring(game.length + 1);
+ var lst = parse_list ('#', p);
return (new Play (game, [0, 1], [lst[0], lst[1]],
lst[2], lst[3], lst[4], UNAME));
}
@@ -136,7 +135,7 @@
function list_plays_string (game, lst) {
- PLAYS = convert_python_list ('#', lst);
+ PLAYS = parse_list ('##', lst);
var a_plist = document.getElementById("a-plays-list-" + game);
var d_plist = document.getElementById("d-plays-list-" + game);
while (a_plist.childNodes.length > 0) { a_plist.removeChild(a_plist.firstChild); }
@@ -332,7 +331,7 @@
function get_opponents () {
var lst = CONN.friends ();
- FRIENDS = convert_python_list (',', lst);
+ FRIENDS = parse_list (',', lst);
}
function play_anew (me_starts) {
Modified: trunk/Toss/WebClient/Play.js
===================================================================
--- trunk/Toss/WebClient/Play.js 2011-06-19 11:57:18 UTC (rev 1489)
+++ trunk/Toss/WebClient/Play.js 2011-06-19 18:04:31 UTC (rev 1490)
@@ -132,8 +132,7 @@
if (this.CUR_MOVE == "") return;
var m = parseInt(this.CUR_MOVE.substring (0, 1)) - 1;
if (!isNaN(m) && this.players[m] != this.cur_player_uid &&
- this.players[m] != "computer" &&
- this.players[m] != this.cur_player_uid.replace("_", "-")) {
+ this.players[m] != "computer") {
alert ("It is your Opponent's move");
return;
}
Modified: trunk/Toss/WebClient/State.js
===================================================================
--- trunk/Toss/WebClient/State.js 2011-06-19 11:57:18 UTC (rev 1489)
+++ trunk/Toss/WebClient/State.js 2011-06-19 18:04:31 UTC (rev 1490)
@@ -106,10 +106,10 @@
this.height = Math.max (SVG_HEIGHT / 100, (this.maxy - this.miny));
// The second component is the list of elements of the structure.
- var l = convert_python_list(',', res_arr[1]);
+ var l = parse_list(',', res_arr[1]);
this.elems = [];
for (var i = 0; i < l.length; i++) {
- var e = convert_python_list (';', l[i]);
+ var e = parse_list (';', l[i]);
var pos = translate_pos ([parseFloat(e[1]), parseFloat(e[2])],
this.minx, this.miny,
this.width, this.height, this.mirror);
@@ -124,12 +124,12 @@
}
// The third component are the relations in the structure.
- var r = convert_python_list(';', res_arr[2]);
+ var r = parse_list(';', res_arr[2]);
var rels = [];
for (var i = 0; i < r.length; i++) {
var rel_name = strip(' ', '\'', r[i].substring(1,r[i].indexOf(',')));
var args_s = r[i].substring(r[i].indexOf('[')+1, r[i].indexOf(']'));
- var args = convert_python_list (',', args_s);
+ var args = parse_list (',', args_s);
var is_undefined = false;
for (var j = 0; j < args.length; j++) {
args[j] = find_elem (args[j], this.elems);
@@ -153,7 +153,7 @@
// If there are no moves possible, it is the payoff.
// The second option in "or" below is just for old format, will be removed.
if (res_arr[3].substring(2, 3) =="(" || res_arr[3].substring(0, 1) =="(") {
- var move_strs = convert_python_list (';', res_arr[3]);
+ var move_strs = parse_list (';', res_arr[3]);
var mvs = [];
var pls = [];
for (i = 0; i < move_strs.length; i++) {
Modified: trunk/Toss/WebClient/index.html
===================================================================
--- trunk/Toss/WebClient/index.html 2011-06-19 11:57:18 UTC (rev 1489)
+++ trunk/Toss/WebClient/index.html 2011-06-19 18:04:31 UTC (rev 1490)
@@ -94,7 +94,11 @@
<div id="welcome">
<p id="welcome-top">Enjoy the best games on <span class="logo-in">tPlay</span>
- for free</p>
+ for free
+ <a href="http://itunes.apple.com/us/app/tplay/id438620686">
+ <img style="height: 2em; float:right;" src="pics/appstore.png" />
+ </a>
+</p>
<p id="p-under-welcome" style="display: none;">
Strategic games are fun!
<a href="register.html">Register</a>, login and enjoy quality games
@@ -172,8 +176,22 @@
<li>Challenge your friends or play a fast game against the computer for fun</li>
</ul>
+<div id="news">
+<h3>News</h3>
+<ul id="welcome-list-news" class="welcome-list">
+<li><b>19/06/11</b> News section on the front page of tPlay</li>
+<li><b>15/06/11</b> Bug with underscores in user names corrected</li>
+<li><b>10/06/11</b> New register site handles forgotten passwords</li>
+<li><b>05/06/11</b> Pre-caching client states improves response times</li>
+<li><b>03/06/11</b> Corrected tPlay 1.1 app accepted on App Store</li>
+<li><b>30/05/11</b> Large restructuring of JavaScript code finished</li>
+<li><b>24/05/11</b> Breakthrough generation from examples in SVN</li>
+<li><b>23/05/11</b> First tPlay application accepted on App Store</li>
+</ul>
</div>
+</div>
+
<div id="nosvg">
<p style="padding-left: 1.2em; font-size: 1.2em;"><b>SVG Support Missing</b></p>
<p>Your browser does not seem to support SVG,
Modified: trunk/Toss/WebClient/msw.js
===================================================================
--- trunk/Toss/WebClient/msw.js 2011-06-19 11:57:18 UTC (rev 1489)
+++ trunk/Toss/WebClient/msw.js 2011-06-19 18:04:31 UTC (rev 1490)
@@ -1,11 +1,11 @@
function msw_list_plays_string (game, lst) {
- PLAYS = convert_python_list ('#', lst);
+ PLAYS = parse_list ('#', lst);
//var plist = document.getElementById("plays-list-" + game);
//while (plist.childNodes.length > 0) { plist.removeChild(plist.firstChild); }
var d = game.length + 2;
for (var i = 0; i < PLAYS.length; i++) {
var p = PLAYS[i].substring(PLAYS[i].lastIndexOf('/') + d);
- PLAYS[i] = convert_python_list ('_', p);
+ PLAYS[i] = parse_list ('_', p);
//plist.appendChild(new_play_item (game, i));
}
/*if (PLAYS.length == 0) {
Added: trunk/Toss/WebClient/pics/appstore.png
===================================================================
(Binary files differ)
Property changes on: trunk/Toss/WebClient/pics/appstore.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/Toss/examples/PacMan.toss
===================================================================
--- trunk/Toss/examples/PacMan.toss (rev 0)
+++ trunk/Toss/examples/PacMan.toss 2011-06-19 18:04:31 UTC (rev 1490)
@@ -0,0 +1,45 @@
+PLAYERS 1, 2, 3
+RULE Go1:
+ [ a1, a2 | C { (a1) }; E { (a1, a2) } | - ]
+ ->
+ [ a1, a2 | C { (a2) }; E { (a1, a2) } | - ]
+emb C, C2
+RULE Go2:
+ [ a1, a2 | C2 { (a1) }; E { (a1, a2) } | - ]
+ ->
+ [ a1, a2 | C2 { (a2) }; E { (a1, a2) } | - ]
+emb C, C2
+RULE Wait:
+ [ a1 | R { (a1) } | - ] -> [ a1 | R { (a1) } | - ]
+emb R, C, C2
+RULE Wait1:
+ [ a1 | C { (a1) } | - ] -> [ a1 | C { (a1) } | - ]
+emb R, C, C2
+RULE Wait2:
+ [ a1 | C2 { (a1) } | - ] -> [ a1 | C2 { (a1) } | - ]
+emb R, C, C2
+RULE Run:
+ [ a1, a2 | E { (a1, a2) }; R { (a1) } | - ]
+ ->
+ [ a1, a2 | E { (a1, a2) }; R { (a2) } | - ]
+emb R, C, C2
+LOC 0 {
+ PLAYER 1 { PAYOFF 0. }
+ PLAYER 2 {
+ PAYOFF 0.
+ MOVES [Go1 -> 1]; [Wait1 -> 1]
+ }
+ PLAYER 3 {
+ PAYOFF 0.
+ MOVES [Go2 -> 1]; [Wait2 -> 1]
+ }
+}
+LOC 1 {
+ PLAYER 1 {
+ PAYOFF -1.
+ MOVES [Run -> 0]; [Wait -> 0]
+ }
+ PLAYER 2 { PAYOFF 1. }
+ PLAYER 3 { PAYOFF 1. }
+}
+MODEL [ a1, a2, b1, b2, c1, c2, d1, d2, f1, f2, g1, g2, h1, h2, e1, e2, i1, i2 | C { (a1) }; C2 { (a2) }; E { (a2, a1); (a2, b2); (a1, a2); (a1, b1); (b1, a1); (b1, b2); (b1, c1); (b2, a2); (b2, b1); (b2, c2); (c2, b2); (c2, c1); (c2, d2); (c1, b1); (c1, c2); (c1, d1); (d2, c2); (d2, d1); (d2, e1); (d1, c1); (d1, d2); (d1, e2); (f1, f2); (f1, g1); (f1, e1); (f2, f1); (f2, g2); (f2, e2); (g1, f1); (g1, g2); (g1, h1); (g2, f2); (g2, g1); (g2, h2); (h1, g1); (h1, h2); (h1, i1); (h2, g2); (h2, h1); (h2, i2); (e1, d2); (e1, f1); (e1, e2); (e2, d1); (e2, f2); (e2, e1); (i1, h1); (i1, i2); (i2, h2); (i2, i1) }; R { (e1) }; _opt_C:1 { } | vx { d4->0., a2->0., a1->0., b1->0., b2->0., e4->0., c2->0., c1->0., f4->0., d2->0., d1->0., f1->0., f2->0., g1->0., g2->0., h1->0., h2->0., e1->0., e2->0., i1->0., i2->0. }; vy { d4->0., a2->0., a1->0., b1->0., b2->0., e4->0., c2->0., c1->0., f4->0., d2->0., d1->0., f1->0., f2->0., g1->0., g2->0., h1->0., h2->0., e1->0., e2->0., i1->0., i2->0. }; x { d4->100., a2->-50., a1->-50., b1->0., b2->0., e4->150., c2->50., c1->50., f4->200., d2->100., d1->100., f1->200., f2->200., g1->250., g2->250., h1->300., h2->300., e1->150., e2->150., i1->350., i2->350. }; y { d4->-150., a2->-100., a1->-50., b1->-50., b2->-100., e4->0., c2->-100., c1->-50., f4->-150., d2->-100., d1->-50., f1->-100., f2->-50., g1->-100., g2->-50., h1->-100., h2->-50., e1->-100., e2->-50., i1->-100., i2->-50. } ]
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|