Revision: 16
http://pykol.svn.sourceforge.net/pykol/?rev=16&view=rev
Author: misza13
Date: 2007-05-04 13:52:23 -0700 (Fri, 04 May 2007)
Log Message:
-----------
Created the Campground class with a rest() function.
Added Paths:
-----------
campground.py
Added: campground.py
===================================================================
--- campground.py (rev 0)
+++ campground.py 2007-05-04 20:52:23 UTC (rev 16)
@@ -0,0 +1,30 @@
+# -*- coding: utf-8 -*-
+#
+# (C) Misza <mi...@mi...>, 2007
+#
+# Distributed under the terms of the MIT license.
+#
+
+class Campground:
+ def __init__(self, site):
+ self.site = site
+
+
+ def rest(self, count=1):
+ #Function will return cumulative gains:
+ cHPgain = 0
+ cMPgain = 0
+ for i in range(count):
+ print 'Now resting...'
+ response, data = self.site.getPage('campground.php?action=rest')
+
+ if "You don't need to rest." in data:
+ print "You don't need to rest."
+ break
+ else:
+ rx = re.search(r'You sleep.*?You gain (?P<hp>\d+).*?You gain (?P<mp>\d+)')
+ if rx:
+ HPgain = int(rx.group('hp'))
+ MPgain = int(rx.group('mp'))
+ print 'You gained %d HP, %d MP' % (HPgain,MPgain)
+ return (cHPgain,cMPgain)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|