[os-devel] SF.net SVN: ospace:[323] branches/ospace_0.5
Brought to you by:
qark
|
From: <qa...@us...> - 2011-12-05 21:53:48
|
Revision: 323
http://ospace.svn.sourceforge.net/ospace/?rev=323&view=rev
Author: qark
Date: 2011-12-05 21:53:41 +0000 (Mon, 05 Dec 2011)
Log Message:
-----------
- Game information now exported to json. [Qark]
- Server welcome page added. [Qark]
Modified Paths:
--------------
branches/ospace_0.5/ChangeLog.txt
branches/ospace_0.5/server/lib/ige/ospace/GameMngr.py
branches/ospace_0.5/server/lib/medusa/status_handler.py
Added Paths:
-----------
branches/ospace_0.5/server/website/
branches/ospace_0.5/server/website/background.jpg
branches/ospace_0.5/server/website/block_bg.png
branches/ospace_0.5/server/website/index.html
branches/ospace_0.5/server/website/styles.css
branches/ospace_0.5/server/website/top_bar_bg.png
Property Changed:
----------------
branches/ospace_0.5/server/
Modified: branches/ospace_0.5/ChangeLog.txt
===================================================================
--- branches/ospace_0.5/ChangeLog.txt 2011-12-05 17:28:39 UTC (rev 322)
+++ branches/ospace_0.5/ChangeLog.txt 2011-12-05 21:53:41 UTC (rev 323)
@@ -8,6 +8,8 @@
[2011-12-05]
- Fixed galaxy restart issue. [Qark]
+- Game information now exported to json. [Qark]
+- Server welcome page added. [Qark]
[2011-11-14]
- Fixed AI scripts deployment issues. [Qark]
Property changes on: branches/ospace_0.5/server
___________________________________________________________________
Modified: svn:ignore
- website
build
var
ticker.py
*.sh
*.bat
exportnews
crontab
MANIFEST
+ build
var
ticker.py
*.sh
*.bat
exportnews
crontab
MANIFEST
Modified: branches/ospace_0.5/server/lib/ige/ospace/GameMngr.py
===================================================================
--- branches/ospace_0.5/server/lib/ige/ospace/GameMngr.py 2011-12-05 17:28:39 UTC (rev 322)
+++ branches/ospace_0.5/server/lib/ige/ospace/GameMngr.py 2011-12-05 21:53:41 UTC (rev 323)
@@ -18,6 +18,7 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
+import json
import random, os, time, copy
import ige
@@ -402,60 +403,34 @@
os.makedirs('website/%s' % self.gameID)
except OSError:
pass
- # save info
- fh = open('website/%s/info_cz.html' % self.gameID, 'w')
+ # create structure to save
+ stats = dict()
universe = self.db[OID_UNIVERSE]
- print >> fh, '<strong><big>·</big></strong> Hracu: <strong>%d</strong><br>' % len(universe.players)
- turn = universe.turn
- print >> fh, '<strong><big>·</big></strong> Tah: <strong>%d:%02d</strong><br>' % (turn / 24, turn % 24)
+ stats["players"] = len(universe.players)
+ stats["turn"] = "%d:%02d" % (universe.turn / 24, universe.turn % 24)
+ galaxies = list()
+ stats["galaxies"] = galaxies
for galaxyID in universe.galaxies:
galaxy = self.db[galaxyID]
- print >> fh, '<strong><big>·</big></strong> Galaxie <strong>%s</strong> [<a href="http://ospace.net:9080/%s/galaxy%d.html">stats</a>]<br>' % (
- galaxy.name, self.gameID, galaxyID
+ galaxyStats = dict(
+ name = galaxy.name,
+ url = "http://www.ospace.net:9080/%s/galaxy%d.html" % (self.gameID, galaxyID),
+ freePositions = len(galaxy.startingPos),
+ players = 0,
+ rebels = 0,
+ age = int(((time.time() - galaxy.creationTime) / (24 * 3600))),
+ running = galaxy.timeEnabled and not galaxy.timeStopped,
)
- aiPlayers = 0
for playerID in universe.players:
player = self.db[playerID]
- if player.type == T_AIPLAYER and galaxy.oid in player.galaxies \
- and player.planets:
- aiPlayers += 1
- if len(galaxy.startingPos) or aiPlayers:
- print >> fh, ' Volnych pozic: <strong>%d + %d</strong><br>' % (
- len(galaxy.startingPos),
- aiPlayers,
- )
- print >> fh, ' Stari: <strong>%d</strong> dni<br>' % \
- ((time.time() - galaxy.creationTime) / (24 * 3600))
- if not galaxy.timeEnabled or galaxy.timeStopped:
- print >> fh, ' <strong>Cas zastaven</strong><br>'
- fh.close()
- # save info
- fh = open('website/%s/info_en.html' % self.gameID, 'w')
- universe = self.db[OID_UNIVERSE]
- print >> fh, '<strong><big>·</big></strong> Players: <strong>%d</strong><br>' % len(universe.players)
- turn = universe.turn
- print >> fh, '<strong><big>·</big></strong> Turn: <strong>%d:%02d</strong><br>' % (turn / 24, turn % 24)
- for galaxyID in universe.galaxies:
- galaxy = self.db[galaxyID]
- print >> fh, '<strong><big>·</big></strong> Galaxy <strong>%s</strong> [<a href="http://ospace.net:9080/%s/galaxy%d.html">stats</a>]<br>' % (
- galaxy.name, self.gameID, galaxyID
- )
- aiPlayers = 0
- for playerID in universe.players:
- player = self.db[playerID]
- if player.type == T_AIPLAYER and galaxy.oid in player.galaxies \
- and player.planets:
- aiPlayers += 1
- if len(galaxy.startingPos) or aiPlayers:
- print >> fh, ' Free positions: <strong>%d + %d</strong><br>' % (
- len(galaxy.startingPos),
- aiPlayers,
- )
- print >> fh, ' Age: <strong>%d</strong> days<br>' % \
- ((time.time() - galaxy.creationTime) / (24 * 3600))
- if not galaxy.timeEnabled or galaxy.timeStopped:
- print >> fh, ' <strong>Time is stopped.</strong><br>'
- fh.close()
+ if galaxy.oid not in player.galaxies:
+ continue
+ if player.type == T_PLAYER:
+ galaxyStats["players"] += 1
+ elif player.type == T_AIPLAYER:
+ galaxyStats["rebels"] += 1
+ galaxies.append(galaxyStats)
+ json.dump(stats, open("website/%s/info.json" % self.gameID, "w"))
def generateStats(self):
""" Generate games statistics """
@@ -668,18 +643,17 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
- <title>IGE - Outer Space Statistics [Game %s]</title>
- <link rel="STYLESHEET" href="../old/style.css" type="text/css">
+ <title>Outer Space Statistics for Game %s</title>
+ <link rel="STYLESHEET" href="../styles.css" type="text/css">
</head>
<body>
<center>
+<h1>Statistics for galaxy %s%s</h1>
+
<table cellspacing=2 border=0 cellpadding=5 width="80%%" class="main">
<tr>
- <td class="header">Statistics for galaxy %s%s</td>
-</tr>
-<tr>
<td valign="top">
<!-- body start -->
'''
Modified: branches/ospace_0.5/server/lib/medusa/status_handler.py
===================================================================
--- branches/ospace_0.5/server/lib/medusa/status_handler.py 2011-12-05 17:28:39 UTC (rev 322)
+++ branches/ospace_0.5/server/lib/medusa/status_handler.py 2011-12-05 21:53:41 UTC (rev 323)
@@ -68,21 +68,29 @@
request.push (
'<html>'
'<head>'
- '<title>Medusa Status Reports</title>'
- '<link rel="STYLESHEET" href="../style.css" type="text/css">'
+ '<title>Outer Space Status Reports</title>'
+ '<link rel="STYLESHEET" href="styles.css" type="text/css">'
'</head>'
- '<body bgcolor="#ffffff">'
- '<h1>Medusa Status Reports</h1>'
+ '<body>'
+ '<div class="main">'
+ '<div class="panel">'
+ '<div class="block">'
+ '<h1>Outer Space Status Reports</h1>'
+ '<div class="block-txt">'
'<b>Up:</b> %s' % up_time
)
for i in range(len(self.objects)):
request.push (self.objects[i].status())
- request.push ('<hr noshade>\r\n')
request.push (
# This is dangerous
# '<p><a href="%s/channel_list">Channel List</a>'
# '<hr noshade>'
# '<img src="%s/medusa.gif" align=right width=%d height=%d>'
+ '</div>'
+ '</div>'
+ '<div class="footer">© 2001 - 2011 Ludek Smid, <a href="http://www.ospace.net/">www.ospace.net</a></div>'
+ '</div>'
+ '</div>'
'</body></html>' % (
# self.statusdir,
# self.statusdir,
Property changes on: branches/ospace_0.5/server/website
___________________________________________________________________
Added: svn:ignore
+ Alpha
res.txt
Added: branches/ospace_0.5/server/website/background.jpg
===================================================================
(Binary files differ)
Property changes on: branches/ospace_0.5/server/website/background.jpg
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: branches/ospace_0.5/server/website/block_bg.png
===================================================================
(Binary files differ)
Property changes on: branches/ospace_0.5/server/website/block_bg.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: branches/ospace_0.5/server/website/index.html
===================================================================
--- branches/ospace_0.5/server/website/index.html (rev 0)
+++ branches/ospace_0.5/server/website/index.html 2011-12-05 21:53:41 UTC (rev 323)
@@ -0,0 +1,31 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+<head>
+ <title>Outer Space Server</title>
+ <link rel="STYLESHEET" href="/styles.css" type="text/css">
+</head>
+<body>
+
+<div class="main">
+<div class="panel">
+<div class="block">
+
+<h1>Outer Space Server</h1>
+
+<div class="block-txt">
+<a href="status"><h2>Run-time status</h2></a>
+
+</div>
+
+</div>
+
+<div class="footer">© 2001 - 2011 Ludek Smid, <a href="http://www.ospace.net/">www.ospace.net</a></div>
+
+</div>
+
+
+</div>
+
+
+</body>
+</html>
Property changes on: branches/ospace_0.5/server/website/index.html
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/ospace_0.5/server/website/styles.css
===================================================================
--- branches/ospace_0.5/server/website/styles.css (rev 0)
+++ branches/ospace_0.5/server/website/styles.css 2011-12-05 21:53:41 UTC (rev 323)
@@ -0,0 +1,261 @@
+@charset "utf-8";
+
+html {
+ height: 100%;
+}
+
+html,body,ul,ol,li,p,h1,h2,h3,h4,h5,h6,form,a,img {
+ margin: 0px;
+ padding: 0px;
+ border: 0px;
+}
+
+ol,ul {
+ padding-left: 2em;
+
+}
+
+body {
+ height: 100%;
+ font-weight: normal;
+ font: 12px Arial, Helvetica, sans-serif;
+ text-align: justify;
+ width: 100%;
+ background: url(background.jpg) no-repeat center top;
+ background-color: #181829;
+ color: #ffffff;
+}
+
+a {
+color:#8fb6e5;
+text-decoration:underline;
+}
+
+
+a:hover {
+text-decoration:none;
+}
+
+.main {
+ width: 1000px;
+ margin: 0 auto;
+ height: auto;
+ /* border: 1px solid red; */
+}
+
+/* web2py specific */
+div.flash {
+ padding: 5px 15px 5px 15px;
+ margin: 0px 0px 7px 7px;
+ width: 956px;
+ background: url(block_bg.png) repeat;
+ font-weight: bold;
+ text-align: right;
+ color: #e09c43;
+ -moz-border-radius:0px 0px 7px 7px;
+ border-radius:0px 0px 7px 7px;
+ border:1px solid #3d444e;
+}
+
+/* Menu section */
+.topbar {
+ margin-top: 0px;
+ padding-left: 0px;
+ padding-right: 0px;
+ width: 1000px;
+ height: 45px;
+ background: url(top_bar_bg.png) left top repeat-x;
+ -moz-border-radius:0px 0px 7px 7px;
+ border-radius:0px 0px 7px 7px;
+ text-shadow: 0px 1px 1px #fff;
+ color: #737373;
+}
+
+.topbar a {
+ color: #737373;
+ text-decoration:none;
+}
+
+.topbar a:hover {
+ color: #5C5C5C;
+ text-decoration:none;
+}
+
+.logo {
+ float: left;
+ margin-top: -2px;
+ padding: 0px;
+ border: 0px;
+ height: 45px;
+ /* border: 1px solid red; */
+}
+
+.logo img {
+ padding-top: 2px;
+ /* border: 1px solid red; */
+}
+
+.menu {
+ padding-top: 18px;
+ padding-bottom: 0px;
+ padding-right: 1em;
+ margin: 0px;
+ float: right;
+ height: 20px;
+ font-weight: bold;
+ /* border: 1px solid red; */
+}
+
+.clear {
+ clear: both;
+}
+
+/* About section */
+.about {
+ clear: both;
+ margin-top: 15px;
+ /* border: 1px solid red; */
+}
+
+.about_main {
+ margin-right: 315px;
+ background: url(block_bg.png) repeat;
+ font-size: large;
+ padding: 20px;
+ height: 150px;
+ -moz-border-radius:7px 7px 7px 7px;
+ border-radius:7px 7px 7px 7px;
+ border:1px solid #3d444e;
+}
+
+.about_main img {
+ float: left;
+ padding-right: 20px;
+}
+
+.about_sidebar {
+ float: right;
+ width: 300px;
+ font-size: 40px;
+}
+
+.about_sidebar #button {
+ text-align: left;
+ font-weight: bold;
+ padding: 6px;
+ padding-left: 0.5em;
+ margin-bottom: 5px;
+ background: url(block_bg.png) repeat;
+ border:1px solid #3d444e;
+ border-left:15px solid #a3abb6;
+ -moz-border-radius:0px 7px 7px 0px;
+ border-radius:0px 7px 7px 0px;
+}
+
+.about_sidebar a {
+ color:#d9dbe0;
+ text-decoration:none;
+}
+
+.about_sidebar a:hover {
+ color:#8fb6e5;
+ text-decoration:none;
+}
+
+/* Main part of the page */
+
+.panel {
+ min-height: 900px;
+}
+
+.block {
+ margin-top: 25px;
+ width: 685px;
+ background: url(block_bg.png) repeat;
+ -moz-border-radius:7px 7px 7px 7px;
+ border-radius:7px 7px 7px 7px;
+ border:1px solid #3d444e;
+}
+
+.block-txt {
+ padding-left: 15px;
+ padding-right: 15px;
+ padding-top: 5px;
+ padding-bottom: 15px;
+ line-height: 20px;
+}
+
+.block h1 {
+ padding-left: 15px;
+ padding-top: 5px;
+ width: 670px;
+ height:40px;
+ margin-bottom: 0.5em;
+ line-height: 35px;
+ background: url(top_bar_bg.png) repeat;
+ -moz-border-radius:7px 7px 0px 0px;
+ border-radius:7px 7px 0px 0px;
+ text-shadow: 0px 1px 1px #fff;
+ color: #737373;
+}
+
+.footer {
+ width: 655px;
+ padding: 15px;
+ background: url(block_bg.png) repeat;
+ -moz-border-radius:7px 7px 7px 7px;
+ border-radius:7px 7px 7px 7px;
+ border:1px solid #3d444e;
+ margin-bottom: 45px;
+}
+
+/* Messages and forums */
+.message_footer {
+ margin-top: 0.5em;
+ text-align: right;
+ font-size: smaller;
+}
+
+
+table.forums {
+ width: 100%;
+ border-bottom: 1px solid #888888;
+ border-top: 1px solid #888888;
+}
+
+table.forums th {
+ text-align: left;
+}
+
+table.forums td.name {
+ width: 60%;
+}
+
+table.forums td.posts {
+ width: 20%;
+}
+
+
+table.forums td.lastpost {
+ width: 20%;
+}
+
+table.forums a {
+ display: block;
+ border: 0;
+}
+
+table.forums a:hover {
+}
+
+ul.forums{
+ list-style-type: none;
+ padding: 0;
+ margin: 0;
+}
+
+ul.forums li {
+ border-bottom: 1px dotted #888888;
+ padding-bottom: 0.25em;
+ margin-bottom: 0.25em;
+}
Property changes on: branches/ospace_0.5/server/website/styles.css
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/ospace_0.5/server/website/top_bar_bg.png
===================================================================
(Binary files differ)
Property changes on: branches/ospace_0.5/server/website/top_bar_bg.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|