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
38 found_pos
[1] >= self
.GetArenaSize()[1] ):
41 retval
= self
.GetAbsolutePixel( found_pos
)
45 def TurnRight( self
, direction
):
47 if direction
> DIR_LEFT
:
51 def TurnLeft( self
, direction
):
53 if direction
< DIR_UP
: