Commit 7dcfd737 authored by Jonathan Michalon's avatar Jonathan Michalon

New module pawn.

Added new module pawn: the idea is that they not only belong to players
but to the board too when they are moved. Otherwise we had to scan the players'
pawns to calculate scores on the board.
So: a list of them in each player, when they are "at home", a hash table on
their position when they are on the board.
parent a8b19ac1
......@@ -3,6 +3,7 @@ noinst_PROGRAMS = test
libovcc_la_CPPFLAGS = -DG_LOG_DOMAIN=\"libovcc\"
libovcc_la_SOURCES = board.c \
pawn.c \
player.c \
stack.c \
tile.c \
......
......@@ -44,6 +44,7 @@
struct _OVCCBoard
{
GHashTable *board;
GHashTable *pawns;
gint leftedge;
gint topedge;
gint rightedge;
......
/*
*
* Copyright (C) 2009 Colomban Wendling <ban@herbesfolles.org>
* Jonathan Michalon <studios.chalmion@no-log.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "pawn.h"
#include <glib.h>
#include "player.h"
/**
* SECTION: pawn
* @short_description: Implementation of OVCC pawns
* @include: libovcc/pawn.h
*
* This is the API for managing pawns in OVCC.
*/
/**
* OVCCPawn:
*
* The opaque structure representing any pawn (like meeple, architect).
*/
struct _OVCCPawn
{
OVCCPawnKind kind;
OVCCPlayerID playerid;
};
/**
* ovcc_pawn_new:
* @kind: The #OVCCPawnKind representing which type of pawn this one is.
* @playerid: The #OVCCPlayerID identifying the player it belongs to.
*
* Creates a new #OVCCPawn.
*
* Returns: The newly created #OVCCPawn.
*/
OVCCPawn *
ovcc_pawn_new (OVCCPawnKind kind,
OVCCPlayerID playerid)
{
OVCCPawn *pawn;
pawn = g_malloc (sizeof *pawn);
if (pawn) {
pawn->kind = kind;
pawn->playerid = playerid;
}
return pawn;
}
/**
* ovcc_pawn_free:
* @pawn: The #OVCCPawn to free.
*
* Frees an #OVCCPawn.
*/
void
ovcc_pawn_free (OVCCPawn *pawn)
{
if (pawn) {
g_free (pawn);
}
}
/**
* ovcc_pawn_goto_board:
* @pawn: The #OVCCPawn to move.
* @player: An #OVCCPlayer, whom belongs the pawn.
* @board: An #OVCCBoard, on which to put the pawn.
* @pos: The #OVCCPosition where to put the pawn on the board.
*
* Puts a pawn from a player on the board.
*/
void
ovcc_pawn_goto_board (OVCCPawn *pawn,
OVCCPlayer *player,
OVCCBoard *board,
OVCCPosition *pos)
{
}
/**
* ovcc_pawn_release:
* @pawn: The #OVCCPawn to release.
* @player: An #OVCCPlayer, whom belongs the pawn.
* @board: An #OVCCBoard, from where it is to be released.
* @pos: The #OVCCPosition where the pawn is currently on the board.
*
* Releases a pawn from a given position of the board to his player.
*/
void
ovcc_pawn_release (OVCCPawn *pawn,
OVCCPlayer *player,
OVCCBoard *board,
OVCCPosition *pos)
{
}
/*
*
* Copyright (C) 2009 Colomban Wendling <ban@herbesfolles.org>
* Jonathan Michalon <studios.chalmion@no-log.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef H_OVCC_PAWN
#define H_OVCC_PAWN
#include <glib.h>
G_BEGIN_DECLS
typedef struct _OVCCPawn OVCCPawn;
/**
* OVCCObjectKind:
* @OVCC_PAWN_MEEPLE: The pawn is a meeple
* "A small person-shaped figure used as a player's
* token in a board game" (WP)
* @OVCC_PAWN_BIG_MEEPLE: The pawn is a big meeple
* @OVCC_PAWN_ARCHITECT: The pawn is an architect
*
* Different kind of pawns possible.
*/
typedef enum
{
OVCC_PAWN_MEEPLE,
OVCC_PAWN_BIG_MEEPLE,
OVCC_PAWN_ARCHITECT
} OVCCPawnKind;
G_END_DECLS
#endif /* guard */
......@@ -34,17 +34,6 @@
*/
/**
* OVCCObject:
*
* The opaque structure representing any object (like meeple, architect).
*/
struct _OVCCObject
{
OVCCObjectKind kind;
gboolean active;
OVCCPosition pos;
};
/**
* OVCCPlayer:
......@@ -53,8 +42,8 @@ struct _OVCCObject
*/
struct _OVCCPlayer
{
OVCCPlayerColor color;
GSList objects;
OVCCPlayerID id;
GSList pawns;
guint score;
};
......
......@@ -30,43 +30,17 @@
G_BEGIN_DECLS
typedef struct _OVCCObject OVCCObject;
typedef struct _OVCCPlayer OVCCPlayer;
/**
* OVCCObjectKind:
* @OVCC_OBJECT_MEEPLE: The object is a meeple
* "A small person-shaped figure used as a player's
* token in a board game" (WP)
* @OVCC_OBJECT_BIG_MEEPLE: The object is a big meeple
* @OVCC_OBJECT_ARCHITECT: The object is an architect
* OVCCPlayerID:
*
* Different kind of objects possible.
*/
typedef enum
{
OVCC_OBJECT_MEEPLE,
OVCC_OBJECT_BIG_MEEPLE,
OVCC_OBJECT_ARCHITECT
} OVCCObjectKind;
/**
* OVCCPlayerColor:
* @OVCC_PLAYER_GREEN: Indicates that the player's color is green.
* @OVCC_PLAYER_BLUE: Indicates that the player's color is blue.
* @OVCC_PLAYER_RED: Indicates that the player's color is red.
* @OVCC_PLAYER_YELLOW: Indicates that the player's color is yellow.
* Type representing a Player ID.
*
* The various colors a player may have.
* A player ID is unique, and is used to distinguish them.
*/
typedef enum
{
OVCC_PLAYER_GREEN,
OVCC_PLAYER_BLUE,
OVCC_PLAYER_RED,
OVCC_PLAYER_YELLOW,
} OVCCPlayerColor;
typedef guint OVCCPlayerID;
gboolean ovcc_player_add_tile (OVCCBoard *board,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment