Page 1 of 1

Retrieval of specific game

PostPosted: Wed Dec 22, 2010 1:39 pm
by theherkman
How can I make a request of the CC api to retrieve all games by a specific user? Also, how can I request a specific game? Does the xml output of this request show which turns have been taken in the current freestyle round? If not, how can I extrapolate this information using api requests?

Re: Retrieval of specific game

PostPosted: Wed Dec 22, 2010 1:53 pm
by sherkaner
Wow, 4 questions. http://www.conquerclub.com/api.php gives the basic information (xml, check the source if it doesn't display properly).
1st: set p1un (or p1) to the value you want. So http://www.conquerclub.com/api.php?mode ... theherkman would give you the first 200 of your games, increase page number to get the rest.
2nd: set the game number, http://www.conquerclub.com/api.php?mode=gamelist&gn=1
3: Not entirely possible, the players will have a status. But at first a player might be waiting because he went last.
4. No way through the api afaik.

Re: Retrieval of specific game

PostPosted: Wed Dec 22, 2010 2:21 pm
by theherkman
Shoot... Okay, moving on to my next script... http://www.conquerclub.com/api.php?mode ... theherkman

I am looking to TEST a script I am writing for feudal war esc. These are the settings I will be testing it on. If all goes well I will figure out a way to open this up and add variables for personal customization. Right now I am using AHK, but will probably end up compiling it in something more user friendly. I have programed the page request and source code open. I also have activated the window and sent focus to the source. This all takes less than a second or two. How can I retrieve the contents of the source file for use with AHK so I can add variables and set up arrays and arguments?

Re: Retrieval of specific game

PostPosted: Wed Dec 22, 2010 3:25 pm
by Dako
That is an interesting question. I just didn't understand - what kind of source do you want to extract?

Re: Retrieval of specific game

PostPosted: Wed Dec 22, 2010 3:42 pm
by theherkman
Dako wrote:That is an interesting question. I just didn't understand - what kind of source do you want to extract?



Well originally I wanted to extract the entire source of the API so I could extrapolate which games need turns to be taken. For instance, in 4 player Feudal ESC, I want all turns to be taken unless there are only 2 players, or another player has entered my castle. I have used the code below to extract that info.

Code: Select all
^!f::                                 ;Start script with Ctrl+Alt+F
IfWinExist Mozilla Firefox Start Page - Mozilla Firefox
{
   WinActivate                           ;Check for FF Process
}
else                                 ;If none is running
{
   Run firefox.exe                           ;Start FF
   WinWait Mozilla Firefox Start Page - Mozilla Firefox            ;Wait until FF is launched
   WinActivate                           ;Give FF focus
}

Click 267, 63                              ;Give address bar focus

SetKeyDelay, 0                              ;No key delay
Send http://tinyurl.com/256o8ga{Enter}                     ;Input CC API URL

Sleep 1000                              ;Allow page load

RightClick 719, 164                           ;Open FF context menu

Click 812, 394                              ;Select source code page

IfWinExist Source of                           ;Find source window
{
   WinActivate                           ;Give focus
}

Click 812, 394                              ;Click to give focus to text area

send Ctrl+A                              ;Select source

Sleep 100                              ;Sleep for safety

send Ctrl+C                              ;Copy source

Sleep 100                              ;Sleep for safety


Then I will take the information from the clipboard and paste all the game numbers into a temp file that will be deleted at the end of the script. Then the script would load those games individually, checking to see if conditions are met for taking a turn. I plan to use a combination of the Game Log and BOB to ensure a player hasn't entered the castle. Then I will check for trade-ins. If I have less than 5 cards, I will deploy on the castle, bombard the correct territory, and end turn. This last step will require a large amount of programming from myself...

Re: Retrieval of specific game

PostPosted: Wed Dec 22, 2010 3:50 pm
by chipv
Basically automating your turns, right.

Re: Retrieval of specific game

PostPosted: Wed Dec 22, 2010 3:55 pm
by Dako
Interesting, interesting, but I cannot say people will like it :).

Re: Retrieval of specific game

PostPosted: Wed Dec 22, 2010 3:56 pm
by theherkman
Only for 4 player Feudal ESC where there are more than 2 players remaining and no player has invaded your castle.

Re: Retrieval of specific game

PostPosted: Wed Dec 22, 2010 4:00 pm
by theherkman
This could take me a looooooooong time to finish. I still have to figure out how to feed the map info to the script. Is there an API request for a game that gives map info like who holds what and where that links to?

Re: Retrieval of specific game

PostPosted: Wed Dec 22, 2010 4:00 pm
by Dako
Nope. No army counts or anything. Just the log lines.

Re: Retrieval of specific game

PostPosted: Wed Dec 22, 2010 4:02 pm
by theherkman
Is there an API request for log? How does Bob know that yellow owns a territory right next to you and how is it able to highlight this in a foggy game? Wouldn't it show up as ? in the log?

Re: Retrieval of specific game

PostPosted: Wed Dec 22, 2010 4:04 pm
by chipv
Yes there is page you can request for this info (BOB gets it)... but I really wouldn't go down this road, people tend
to notice unusual speed of moves...

Re: Retrieval of specific game

PostPosted: Wed Dec 22, 2010 4:27 pm
by Dako
The game page has that info. Not the API.

Re: Retrieval of specific game

PostPosted: Wed Dec 22, 2010 4:32 pm
by chipv
Dako wrote:The game page has that info. Not the API.


I didn't say API, and the game page does not have this info either (aside from scraping), you need an additional parameter.

Re: Retrieval of specific game

PostPosted: Wed Dec 22, 2010 4:43 pm
by sherkaner
chipv wrote:
Dako wrote:The game page has that info. Not the API.


I didn't say API, and the game page does not have this info either (aside from scraping), you need an additional parameter.

Bob only gets the full log if needed, the rest is on the page now (especially the structure of the map and the placing of the armies).

Re: Retrieval of specific game

PostPosted: Wed Dec 22, 2010 4:44 pm
by chipv
Are we done now, boys? :-)

Re: Retrieval of specific game

PostPosted: Wed Dec 22, 2010 4:58 pm
by sherkaner
Sorry :P

Re: Retrieval of specific game

PostPosted: Wed Dec 22, 2010 11:04 pm
by theherkman
Okay, thanks for the help. I will gladly plod along until I have more questions with the confusing API...

Re: Retrieval of specific game

PostPosted: Thu Dec 23, 2010 12:51 am
by theherkman
Okay, I have a question. How does BOB know when yellow has a territory next to player red in a foggy game? I can't figure it out... It's driving me nuts here...

Re: Retrieval of specific game

PostPosted: Thu Dec 23, 2010 1:44 pm
by theherkman
Okay, doesn't matter anymore. New line of questioning... How can I bring focus to the in game action pane? I see an ID in the source code, but I only see one... Wouldn't that make the entire action pane one big form but with different variables to fill in?