const int PP_BLOCKED_TEAM = 5; // there won't ever be a 5th team, so we can abuse this
+const int PP_LET_CNT = 7;
+const int PP_NUM_CNT = 7;
+
+const int PP_TILE_SIZE = 7;
+
.int pp_team1_score;
.int pp_team2_score;
return 0;
int number = minigame_tile_number(tile);
int letter = minigame_tile_letter(tile);
- return 0 <= number && number < 7 && 0 <= letter && letter < 7;
+ return 0 <= number && number < PP_NUM_CNT && 0 <= letter && letter < PP_LET_CNT;
}
// Checks if the given piece completes a row
void pp_setup_pieces(entity minigame)
{
int i, t; // letter, number
- for(i = 0; i < 7; ++i)
- for(t = 0; t < 7; ++t)
+ for(i = 0; i < PP_LET_CNT; ++i)
+ for(t = 0; t < PP_NUM_CNT; ++t)
{
bool t2_true = ((i == 0 || i == 6) && t > 0 && t < 6);
bool t1_true = (i > 0 && i < 6 && (t == 0 || t == 6));
minigame_hud_simpleboard(pos,mySize,minigame_texture("pp/board"));
- vector tile_size = minigame_hud_denormalize_size('1 1 0'/7,pos,mySize);
+ vector tile_size = minigame_hud_denormalize_size('1 1 0'/PP_TILE_SIZE,pos,mySize);
vector tile_pos;
active_minigame.pp_curr_piece = world;
{
if ( e.classname == "minigame_board_piece" )
{
- tile_pos = minigame_tile_pos(e.netname,7,7);
+ tile_pos = minigame_tile_pos(e.netname,PP_LET_CNT,PP_NUM_CNT);
tile_pos = minigame_hud_denormalize(tile_pos,pos,mySize);
vector tile_color = '1 1 1';
if ( (active_minigame.minigame_flags & PP_TURN_TEAM) == minigame_self.team )
if ( pp_valid_move(active_minigame, pp_curr_pos) )
{
- tile_pos = minigame_tile_pos(pp_curr_pos,7,7);
+ tile_pos = minigame_tile_pos(pp_curr_pos,PP_LET_CNT,PP_NUM_CNT);
tile_pos = minigame_hud_denormalize(tile_pos,pos,mySize);
minigame_drawpic_centered( tile_pos,
minigame_texture("pp/piece_current"),
}
else if(pp_valid_tile(pp_curr_pos))
{
- tile_pos = minigame_tile_pos(pp_curr_pos,7,7);
+ tile_pos = minigame_tile_pos(pp_curr_pos,PP_LET_CNT,PP_NUM_CNT);
tile_pos = minigame_hud_denormalize(tile_pos,pos,mySize);
minigame_drawpic_centered( tile_pos,
minigame_texture("pp/piece_selected"),
if ( ! pp_curr_pos )
pp_set_curr_pos("a3");
else
- pp_set_curr_pos(minigame_relative_tile(pp_curr_pos,1,0,7,7));
+ pp_set_curr_pos(minigame_relative_tile(pp_curr_pos,1,0,PP_LET_CNT,PP_NUM_CNT));
return true;
case K_LEFTARROW:
case K_KP_LEFTARROW:
if ( ! pp_curr_pos )
pp_set_curr_pos("c3");
else
- pp_set_curr_pos(minigame_relative_tile(pp_curr_pos,-1,0,7,7));
+ pp_set_curr_pos(minigame_relative_tile(pp_curr_pos,-1,0,PP_LET_CNT,PP_NUM_CNT));
return true;
case K_UPARROW:
case K_KP_UPARROW:
if ( ! pp_curr_pos )
pp_set_curr_pos("a1");
else
- pp_set_curr_pos(minigame_relative_tile(pp_curr_pos,0,1,7,7));
+ pp_set_curr_pos(minigame_relative_tile(pp_curr_pos,0,1,PP_LET_CNT,PP_NUM_CNT));
return true;
case K_DOWNARROW:
case K_KP_DOWNARROW:
if ( ! pp_curr_pos )
pp_set_curr_pos("a3");
else
- pp_set_curr_pos(minigame_relative_tile(pp_curr_pos,0,-1,7,7));
+ pp_set_curr_pos(minigame_relative_tile(pp_curr_pos,0,-1,PP_LET_CNT,PP_NUM_CNT));
return true;
case K_ENTER:
case K_KP_ENTER:
{
vector mouse_pos = minigame_hud_normalize(mousepos,pp_boardpos,pp_boardsize);
if ( minigame.minigame_flags == (PP_TURN_PLACE|minigame_self.team) )
- pp_set_curr_pos(minigame_tile_name(mouse_pos,7,7));
+ pp_set_curr_pos(minigame_tile_name(mouse_pos,PP_LET_CNT,PP_NUM_CNT));
if ( ! pp_valid_tile(pp_curr_pos) )
pp_set_curr_pos("");
const int TTT_SF_PLAYERSCORE = MINIG_SF_CUSTOM; // send minigame_player scores (won matches)
const int TTT_SF_SINGLEPLAYER = MINIG_SF_CUSTOM<<1;// send minigame.ttt_ai
+const int TTT_LET_CNT = 3;
+const int TTT_NUM_CNT = 3;
+const int TTT_TILE_SIZE = 3;
+
.int ttt_npieces; // (minigame) number of pieces on the board (simplifies checking a draw)
.int ttt_nexteam; // (minigame) next team (used to change the starting team on following matches)
.int ttt_ai; // (minigame) when non-zero, singleplayer vs AI
return 0;
int number = minigame_tile_number(tile);
int letter = minigame_tile_letter(tile);
- return 0 <= number && number < 3 && 0 <= letter && letter < 3;
+ return 0 <= number && number < TTT_NUM_CNT && 0 <= letter && letter < TTT_LET_CNT;
}
// make a move
minigame_server_sendflags(player, TTT_SF_PLAYERSCORE);
minigame.minigame_flags = TTT_TURN_WIN | player.team;
}
- else if ( minigame.ttt_npieces >= 9 )
+ else if ( minigame.ttt_npieces >= (TTT_LET_CNT * TTT_NUM_CNT) )
minigame.minigame_flags = TTT_TURN_DRAW;
else
minigame.minigame_flags = TTT_TURN_PLACE | minigame.ttt_nexteam;
minigame_hud_simpleboard(pos,mySize,minigame_texture("ttt/board"));
- vector tile_size = minigame_hud_denormalize_size('1 1 0'/3,pos,mySize);
+ vector tile_size = minigame_hud_denormalize_size('1 1 0'/TTT_TILE_SIZE,pos,mySize);
vector tile_pos;
if ( (active_minigame.minigame_flags & TTT_TURN_TEAM) == minigame_self.team )
if ( ttt_valid_tile(ttt_curr_pos) )
{
- tile_pos = minigame_tile_pos(ttt_curr_pos,3,3);
+ tile_pos = minigame_tile_pos(ttt_curr_pos,TTT_LET_CNT,TTT_NUM_CNT);
tile_pos = minigame_hud_denormalize(tile_pos,pos,mySize);
minigame_drawpic_centered( tile_pos,
minigame_texture(strcat("ttt/piece",ftos(minigame_self.team))),
{
if ( e.classname == "minigame_board_piece" )
{
- tile_pos = minigame_tile_pos(e.netname,3,3);
+ tile_pos = minigame_tile_pos(e.netname,TTT_LET_CNT,TTT_NUM_CNT);
tile_pos = minigame_hud_denormalize(tile_pos,pos,mySize);
if ( active_minigame.minigame_flags & TTT_TURN_WIN )
if ( ! ttt_curr_pos )
ttt_set_curr_pos("a3");
else
- ttt_set_curr_pos(minigame_relative_tile(ttt_curr_pos,1,0,3,3));
+ ttt_set_curr_pos(minigame_relative_tile(ttt_curr_pos,1,0,TTT_LET_CNT,TTT_NUM_CNT));
return true;
case K_LEFTARROW:
case K_KP_LEFTARROW:
if ( ! ttt_curr_pos )
ttt_set_curr_pos("c3");
else
- ttt_set_curr_pos(minigame_relative_tile(ttt_curr_pos,-1,0,3,3));
+ ttt_set_curr_pos(minigame_relative_tile(ttt_curr_pos,-1,0,TTT_LET_CNT,TTT_NUM_CNT));
return true;
case K_UPARROW:
case K_KP_UPARROW:
if ( ! ttt_curr_pos )
ttt_set_curr_pos("a1");
else
- ttt_set_curr_pos(minigame_relative_tile(ttt_curr_pos,0,1,3,3));
+ ttt_set_curr_pos(minigame_relative_tile(ttt_curr_pos,0,1,TTT_LET_CNT,TTT_NUM_CNT));
return true;
case K_DOWNARROW:
case K_KP_DOWNARROW:
if ( ! ttt_curr_pos )
ttt_set_curr_pos("a3");
else
- ttt_set_curr_pos(minigame_relative_tile(ttt_curr_pos,0,-1,3,3));
+ ttt_set_curr_pos(minigame_relative_tile(ttt_curr_pos,0,-1,TTT_LET_CNT,TTT_NUM_CNT));
return true;
case K_ENTER:
case K_KP_ENTER:
{
vector mouse_pos = minigame_hud_normalize(mousepos,ttt_boardpos,ttt_boardsize);
if ( minigame.minigame_flags == (TTT_TURN_PLACE|minigame_self.team) )
- ttt_set_curr_pos(minigame_tile_name(mouse_pos,3,3));
+ ttt_set_curr_pos(minigame_tile_name(mouse_pos,TTT_LET_CNT,TTT_NUM_CNT));
if ( ! ttt_valid_tile(ttt_curr_pos) )
ttt_set_curr_pos("");