Code Search for Developers
 
 
  

OK.py from Thousand Parsec at Krugle


Show OK.py syntax highlighted


from xstruct import pack

from Header import Processed

class OK(Processed):
	"""\
	The OK packet consists of:
		* A string 
		(the string can be safely ignored - however it may 
		contain useful information for debugging purposes)
	"""

	no = 0
	struct = "S"

	def __init__(self, sequence, s=""):
		if 1 > sequence:
			raise ValueError("OK is a reply packet so needs a valid sequence number (%i)" % sequence)
		Processed.__init__(self, sequence)

		# Length is:
		#  * 4 bytes (32 bit integer)
		#  * the string
		#  * null terminator
		#
		self.length = 4 + len(s) 
		self.s = s
	
	def __str__(self):
		output = Processed.__str__(self)
		output += pack(self.struct, self.s)

		return output




See more files for this project here

Thousand Parsec

Thousand Parsec is a framework for turn based 4 X\'s game (eXplore, eXpand, eXploit, eXterminate). Designed for long games, supporting massive universes and has an easily expanded tech tree.

Project homepage: http://sourceforge.net/projects/thousandparsec
Programming language(s): C++,Python
License: other

  ObjectExtra/
    Fleet.py
    Galaxy.py
    Planet.py
    README
    StarSystem.py
    Universe.py
    __init__.py
  OrderExtra/
    Move.py
    NOp.py
    README
    __init__.py
  Account.py
  Base.py
  Board.py
  Board_Get.py
  Board_GetID.py
  Board_IDSequence.py
  Category.py
  Category_Add.py
  Category_Get.py
  Category_GetID.py
  Category_IDSequence.py
  Category_Remove.py
  Component.py
  Component_Get.py
  Component_GetID.py
  Component_IDSequence.py
  Connect.py
  Description.py
  Design.py
  Design_Add.py
  Design_Get.py
  Design_GetID.py
  Design_IDSequence.py
  Design_Modify.py
  Design_Remove.py
  Fail.py
  Feature.py
  Feature_Get.py
  Game.py
  Header.py
  Login.py
  Message.py
  Message_Get.py
  Message_Insert.py
  Message_Remove.py
  OK.py
  Object.py
  ObjectDesc.py
  ObjectDesc_Get.py
  Object_GetById.py
  Object_GetID.py
  Object_GetID_ByContainer.py
  Object_GetID_ByPos.py
  Object_IDSequence.py
  Order.py
  OrderDesc.py
  OrderDesc_Get.py
  OrderDesc_GetID.py
  OrderDesc_IDSequence.py
  Order_Get.py
  Order_Insert.py
  Order_Probe.py
  Order_Remove.py
  Ping.py
  Player.py
  Player_Get.py
  Property.py
  Property_Get.py
  Property_GetID.py
  Property_IDSequence.py
  Redirect.py
  Resource.py
  Resource_Get.py
  Resource_GetID.py
  Resource_IDSequence.py
  Sequence.py
  TimeRemaining.py
  TimeRemaining_Get.py
  __init__.py
  constants.py
  showid.sh