Updated version to 0.0.7.
[troncode.git] / BasicGameBoard.py
blob22043fbc367c4c25fbb4d93957c06dec648300d2
1 from AbstractGameBoard import AbstractGameBoard
2 from troncode_values import *
4 class BasicGameBoard( AbstractGameBoard ):
5 """Inherit from this if you want to make a fake GameBoard
6 for testing. It provides all the generic services of a
7 GameBoard, but allows you to override the methods that
8 provide information about the pixels and the players."""
10 def GetAbsolutePixel( self, (x, y) ):
11 raise Exception( "Not implemented" )
13 def GetArenaSize( self ):
14 raise Exception( "Not implemented" )
16 def GetPlayerPositions( self, pos_to_exclude = None ):
17 raise Exception( "Not implemented" )
19 def GetRelativePixel( self, start_pos, facing_dir,
20 offset_fwd, offset_right ):
22 if facing_dir == DIR_UP:
23 found_pos = ( start_pos[0] + offset_right,
24 start_pos[1] - offset_fwd )
25 elif facing_dir == DIR_RIGHT:
26 found_pos = ( start_pos[0] + offset_fwd,
27 start_pos[1] + offset_right )
28 elif facing_dir == DIR_DOWN:
29 found_pos = ( start_pos[0] - offset_right,
30 start_pos[1] + offset_fwd )
31 elif facing_dir == DIR_LEFT:
32 found_pos = ( start_pos[0] - offset_fwd,
33 start_pos[1] - offset_right )
35 if ( found_pos[0] < 0 or
36 found_pos[0] >= self.GetArenaSize()[0] or
37 found_pos[1] < 0 or
38 found_pos[1] >= self.GetArenaSize()[1] ):
39 retval = 100
40 else:
41 retval = self.GetAbsolutePixel( found_pos )
43 return retval
45 def TurnRight( self, direction ):
46 direction += 1
47 if direction > DIR_LEFT:
48 direction = DIR_UP
49 return direction
51 def TurnLeft( self, direction ):
52 direction -= 1
53 if direction < DIR_UP:
54 direction = DIR_LEFT
55 return direction