Created
July 2, 2015 17:20
-
-
Save hasasn/5fc888edd420e1933f30 to your computer and use it in GitHub Desktop.
base.py_xena_help
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import json | |
import re | |
class rotaApi: | |
def __init__(self): | |
self.baseUrl='http://rota.praetorian.com/rota/service/play.php' | |
def newGame(self): | |
req = self.baseUrl+'?request=new' | |
res = requests.get(req) | |
return res | |
def place(self,location,cookie): | |
req=self.baseUrl+'?request=place&location=%s' % location.__str__() | |
return requests.get(req,cookies=cookie) | |
def move(self, startLocation, endLocation, cookie): | |
req=self.baseUrl+'?request=move&from=%s&to=%s' % (startLocation, endLocation) | |
res = requests.get(req,cookies=cookie) | |
data = json.loads(res.text) | |
return data | |
def status(self,cookie): | |
res = requests.get(self.baseUrl + '?request=status', cookies=cookie) | |
data = json.loads(res.text) | |
#list = data.get('data') | |
#output=re.sub( "(.{3})","\\1\n",(list['board']), 0, re.DOTALL) | |
#print(output) | |
return data | |
class gameController: | |
def __init__(self): | |
self.conn= rotaApi() | |
def newGame(self): | |
res = self.conn.newGame() | |
self.sess= res.cookies | |
return res | |
def place(self, location): | |
res = self.conn.place(location, self.sess) | |
return res | |
def move(self, startLocation, endLocation): | |
res = self.conn.move(startLocation, endLocation, self.sess) | |
return res | |
def status(self): | |
res = self.conn.status(self.sess) | |
return res | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment