Bridges-Python 3.5.1
Bridges(Python API)
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Static Public Attributes | Properties | List of all members
bridges.gamebase.GameBase Class Reference

This is the base class for all games in BRIDGES. More...

Inheritance diagram for bridges.gamebase.GameBase:
bridges.blocking_game.BlockingGame bridges.non_blocking_game.NonBlockingGame

Public Member Functions

 __init__ (self, assid, login, apikey, rows, cols, debug=False)
 PROTECTED constructor prevents the object from being directly created.
 
 game_base_init (self, id, log, key, rows, cols, debug=False)
 Initializes the gamebase object.
 
 close (self)
 close the socket connection (and game)
 
 register_keypress (self, kl)
 
 start (self)
 
 initialize (self)
 
 game_loop (self)
 
 quit (self)
 calling this function causes the game to end.
 
 set_title (self, title)
 sets title of game
 
 set_description (self, desc)
 sets description of the game
 
 get_bg_color (self, row, col)
 gets background color of a cell
 
 set_bg_color (self, row, col, color)
 sets background color of a cell
 
 get_symbol (self, row, col)
 gets symbol of the cell at row, col
 
 get_symbol_color (self, row, col)
 gets symbol color of the cell at row, col
 
 draw_symbol (self, row, col, s, c)
 draw symbol s with color col at cell (row, col)
 
 render (self)
 renders the board
 

Public Attributes

 grid_state
 
 debug
 
 firsttime
 
 bridges
 
 grid
 
 sock
 
 game_started
 

Static Public Attributes

bool debug = True
 

Properties

 board_width = property
 setter/getter property for board width
 
 board_height = property
 setter/getter property for board height
 

Detailed Description

This is the base class for all games in BRIDGES.

Author
David Burlinson, Erik Saule
Date
2020, 2021

Constructor & Destructor Documentation

◆ __init__()

bridges.gamebase.GameBase.__init__ (   self,
  assid,
  login,
  apikey,
  rows,
  cols,
  debug = False 
)

PROTECTED constructor prevents the object from being directly created.

Since GameBase is meant to be a purely internal class, that seems appropriate.

Parameters
assidassignment number
loginuser name
apikeyauthentication id
rowsheight of game grid
colswidth of game grid
Returns
None

Reimplemented in bridges.blocking_game.BlockingGame, and bridges.non_blocking_game.NonBlockingGame.

Member Function Documentation

◆ close()

bridges.gamebase.GameBase.close (   self)

close the socket connection (and game)

◆ draw_symbol()

bridges.gamebase.GameBase.draw_symbol (   self,
  row,
  col,
  s,
  c 
)

draw symbol s with color col at cell (row, col)

Parameters
rowthe row of the cell
colthe column of the cell
ssymbol
ccolor
Returns
color of type NamedColor

◆ game_base_init()

bridges.gamebase.GameBase.game_base_init (   self,
  id,
  log,
  key,
  rows,
  cols,
  debug = False 
)

Initializes the gamebase object.

Parameters
idassignment number
loguser name
keyauthentication id
rowsheight of game grid
colswidth of game grid

◆ game_loop()

bridges.gamebase.GameBase.game_loop (   self)
"Method contains all of the game logica and can call other user defined methods"

◆ get_bg_color()

bridges.gamebase.GameBase.get_bg_color (   self,
  row,
  col 
)

gets background color of a cell

Parameters
rowthe row of the cell
colthe column of the cell
Returns
returns a NamedColor

◆ get_symbol()

bridges.gamebase.GameBase.get_symbol (   self,
  row,
  col 
)

gets symbol of the cell at row, col

Parameters
rowthe row of the cell
colthe column of the cell
Returns
Symbol of type NamedSymbol

◆ get_symbol_color()

bridges.gamebase.GameBase.get_symbol_color (   self,
  row,
  col 
)

gets symbol color of the cell at row, col

Parameters
rowthe row of the cell
colthe column of the cell
Returns
color of type NamedColor

◆ initialize()

bridges.gamebase.GameBase.initialize (   self)
"Game initialization. . Called once at the beginning"

◆ quit()

bridges.gamebase.GameBase.quit (   self)

calling this function causes the game to end.

Returns
None

◆ register_keypress()

bridges.gamebase.GameBase.register_keypress (   self,
  kl 
)

◆ render()

bridges.gamebase.GameBase.render (   self)

renders the board

◆ set_bg_color()

bridges.gamebase.GameBase.set_bg_color (   self,
  row,
  col,
  color 
)

sets background color of a cell

Parameters
rowthe row of the cell
colthe column of the cell
colorcolor to be set
Returns
None

◆ set_description()

bridges.gamebase.GameBase.set_description (   self,
  desc 
)

sets description of the game

Returns
None

◆ set_title()

bridges.gamebase.GameBase.set_title (   self,
  title 
)

sets title of game

Returns
None

◆ start()

bridges.gamebase.GameBase.start (   self)
"starts the game. Called once at the beginning"

Reimplemented in bridges.blocking_game.BlockingGame, and bridges.non_blocking_game.NonBlockingGame.

Member Data Documentation

◆ bridges

bridges.gamebase.GameBase.bridges

◆ debug [1/2]

bool bridges.gamebase.GameBase.debug = True
static

◆ debug [2/2]

bridges.gamebase.GameBase.debug

◆ firsttime

bridges.gamebase.GameBase.firsttime

◆ game_started

bridges.gamebase.GameBase.game_started

◆ grid

bridges.gamebase.GameBase.grid

◆ grid_state

bridges.gamebase.GameBase.grid_state

◆ sock

bridges.gamebase.GameBase.sock

Property Documentation

◆ board_height

bridges.gamebase.GameBase.board_height = property
static

setter/getter property for board height

◆ board_width

bridges.gamebase.GameBase.board_width = property
static

setter/getter property for board width


The documentation for this class was generated from the following file: