Some Refactoring Notes



At some stage there was an IRC discussion about unifying the board
games.  I wrote out some notes about the sort of stuff that could be
shared or frameworked, there's a fair few possibilities.  I also wrote
bits of possible API out.  They're very rudimentary and incomplete but
other projects prevented me from working on them in a major way.

I'm attaching these two files in the hope they might be useful to
someone.

-- 
         Matthew Tuck: Software Developer & All-Round Nice Guy        
 My Short Autobiography: 1985 Grade Bin Monitor 1990 Class Clown Award
1992 Awarded Most Likely To Spontaneously Combust 1996 Crowned Galactic
         Emperor 1998 Released From Smith Psychiatric Hospital

share bits of ai (minimax outline)

Board Structure
	Any size possible.
	Different piece themes, collected from the different apps.
	Different background colours and themes (monochrome, monochrome w/ gridlines,
       		shading glines style).
	Different animations, moving (glines, gnect) (with waypoints for glines),
		flipping (iagno, gataxx).
	Hover effect (same-gnome).
	Switch off/on animations.

Move Lists
	Undoing moves.
	Saving games.
	Network games.

Shared UI
	Shared menus.
	Shared preferences (if one app) (some remain game-specific).
	Status bar scores (can set up any number on the status bar)
	Game time on status bar.
	Central help system (if one app) (with game-specific pages).
	Sound system.

Shared AI
	Minimax algorithm?  Is the GNect AI engine general?
	Hints

Other
	Quit confirmation.
	Consider also what would be needed for a checkers/draughts game, in particular "jumping".
void board_set_size( guint8 x, guint8 y, guint8 pieces )

void board_set_highlight( guint8 x, guint8 y, bool on );

MOVE LIST
---------

The move list maintains a record of the game.  Moves are stored as
encoded strings.

void move_list_add( char *move );

Add a new move.  The move handler will get called as a result of this,
in order to perform the specific move operations.

void move_list_undo();

Undoes the last move.  This will automatically ensure animations are
off, and replay the move handler for all the moves that are still
applicable.

void move_list_set_move_handler( ? );

This registers a handler that, for this game, does the appropriate
board operations for this move.

For example, in Iagno, the first operation would be to add a piece,
and the second would be to flip a line of pieces.

BOARD OPERATIONS
----------------

This allows a move handler to operate upon the board.  A move will
result in one or more board operations.

void board_change_piece( guint8 top, guint8 bottom, guint8 left, guint8 right,
			 bool animate );

This changes a square of pieces to another status, possibly using a flipping
animation.

You can use this to add and remove pieces too, since "empty" is
a piece type.

This is used for adding pieces in most games, and also for flipping
pieces in iagno and gataxx.

void board_move_piece( guint8 src_x, guint8 src_y,
                       guint8 dst_x, guint8 dst_y, bool animate );

This moves a piece to another position on the board, possibly using a
rolling animation.

void board_replace_board( ???, bool animate );

This replaces an entire board at once with another, possibly using a
flipping animation like iagno and gataxx.  Would probably be needed
by same-gnome, but without animations.

void board_set_animations( bool animation_mode );

Sets whether the board operations are animated.  Note that this is
different from the user animation preference.  Animations will only
occur if the game allows them and the user wants them.

HIGHLIGHT OPERATIONS
--------------------

Highlight operations are used as aids to users, to let them see certain
pieces are special.

void board_set_piece_mode( guint8 x, guiny8 y, guint8 piece_mode );

Sets the piece "mode".  This can be normal, activated, or highlighted.  This
will typically change the display of the piece somewhat.

Activate should just some sort of animation to illustrate the fact that the
piece is waiting to be used.  Currently, glines activates pieces when you
first-click them, whereas same-gnome activates a group when you hover over
one.

Highlight should simply highlight the piece without an intrusive animation.
It could be used by GNect to highlight the row at the end of the game.

void board_set_cell_mode( guint 8 x, guint8 y, guint8 cell_mode );

Sets the cell "mode".  This can be normal or highlighted.

Highlight should simply highlight the cells.  Typically this will illustrate
to the user the possible moves that can be clicked on.  Gataxx does this.

void board_clear_board_piece_mode();
void board_clear_board_cell_mode();

Clears the statuses of the entire board.


----

void board_set_click_handler( ? );
void board_set_hover_handler( ? );

void ui_set_scores( GridScore **scores );

Sets up an array of scores to be shown on the status bar.

PREFERENCES
-----------

struct Prefs {
	AnimationTheme animation_mode;
	BoardTheme board_theme;
	PieceTheme piece_theme;
	Colour board_background;
	Colour board_foreground;
	Colour piece_colour;
	bool show_game_time;
}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]