ChatdServerClientExample: Difference between revisions

Content deleted Content added
No edit summary
No edit summary
Line 1:
A very simple example for you, the lazy reader, who can't be bothered to read the manual!<br>
But note, this example is by no way a substitute of HowToWriteGamesUsingArianne and it is only intended for readers that want a light introduction to Arianne.
 
!=Server=
First we create the server class using python.
<pre>
<verbatim>
import marauroa.game.python.PythonRP
 
Line 41:
def onTimeout(self, objectid):
return onExit(self,objectid)
</verbatimpre>
 
Ok, most of it is just trivial stuff. The core code is at execute and nextTurn.<br>
The execute method is the one called to execute the actions the client sends and it is really simple, it adds the messages content as a player attribute, and the trick thing is that is add the player a list so that it can be deleted the attribute in the next turn.
 
The nextTurn just delete the attributes that now are useless.
 
!=Client=
The client is a bit more complex. We need to make it login and choose a character. We will use a curses wrapper for python.
_TODO'''TODO:_''' Improve it
<pre>
<verbatim>
import pyarianne
import curses
Line 213:
uninitCurses(1,2)
 
</verbatimpre>
 
And here you can see how it looks:
 
[http://tribus.dyndns.org/~keiner/cursed-chat-client.png]