const int PP_TURN_TEAM2 = 0x0002;
const int PP_TURN_TEAM = 0x000f; // turn team mask
-const int PP_BLOCKED_TEAM = 5; // there won't ever be a 5th team, so we can abuse this
+const int PP_SPECTATOR_TEAM = 255; // must be above max teams and equal to or below 255
const int PP_LET_CNT = 7;
const int PP_NUM_CNT = 7;
int pl_num = minigame_count_players(minigame);
// Don't allow more than 2 players
- if(pl_num >= 2) { return false; }
+ if(pl_num >= 2) { return PP_SPECTATOR_TEAM; }
// Get the right team
if(minigame.minigame_players)
}
case "cmd":
{
+ entity player = ...(0,entity);
+ bool event_blocked = (player.team == PP_SPECTATOR_TEAM);
switch(argv(0))
{
case "move":
+ if(event_blocked)
+ return true;
pp_move(minigame, ...(0,entity), ...(1,int) == 2 ? argv(1) : string_null );
return true;
case "next":
+ if(event_blocked)
+ return true;
pp_next_match(minigame,...(0,entity));
return true;
}
sprintf(_("%s^7 won the game!"), pname),
winfs, 0, DRAWFLAG_NORMAL, 0.5);
- drawfill(win_pos-eY*hud_fontsize_y,win_sz+2*eY*hud_fontsize_y,'1 1 1',0.5,DRAWFLAG_ADDITIVE);
+ drawfill(win_pos-eY*hud_fontsize_y,win_sz+2*eY*hud_fontsize_y,'1 1 1',0.5*panel_fg_alpha,DRAWFLAG_ADDITIVE);
minigame_drawcolorcodedstring_wrapped(mySize_x,win_pos,
sprintf(_("%s^7 won the game!"), pname),
winfs, panel_fg_alpha, DRAWFLAG_NORMAL, 0.5);
}
+
+ minigame_show_allspecs(pp_boardpos, pp_boardsize);
}
vector mypos;
vector tile_size = '48 48 0';
- mypos = pos;
- if ( (active_minigame.minigame_flags&PP_TURN_TEAM) == 2 )
- mypos_y += player_fontsize_y + ts_y;
- drawfill(mypos,eX*mySize_x+eY*player_fontsize_y,'1 1 1',0.5,DRAWFLAG_ADDITIVE);
- mypos_y += player_fontsize_y;
- drawfill(mypos,eX*mySize_x+eY*tile_size_y,'1 1 1',0.25,DRAWFLAG_ADDITIVE);
+ if(minigame_self.team != PP_SPECTATOR_TEAM)
+ {
+ mypos = pos;
+ if ( (active_minigame.minigame_flags&PP_TURN_TEAM) == 2 )
+ mypos_y += player_fontsize_y + ts_y;
+ drawfill(mypos,eX*mySize_x+eY*player_fontsize_y,'1 1 1',0.5*panel_fg_alpha,DRAWFLAG_ADDITIVE);
+ mypos_y += player_fontsize_y;
+ drawfill(mypos,eX*mySize_x+eY*tile_size_y,'1 1 1',0.25*panel_fg_alpha,DRAWFLAG_ADDITIVE);
+ }
entity e;
FOREACH_MINIGAME_ENTITY(e)
{
- if ( e.classname == "minigame_player" )
+ if ( e.classname == "minigame_player" && e.team != PP_SPECTATOR_TEAM )
{
vector tile_color = '1 1 1';
switch(e.team)
// Turn a set of flags into a help message
string pp_turn_to_string(int turnflags)
{
+ if(minigame_self.team == PP_SPECTATOR_TEAM)
+ return _("You are spectating");
+
if ( turnflags & PP_TURN_DRAW )
return _("Draw");
if ( turnflags & PP_TURN_WIN )
{
// translator-friendly messages composed of 2 existing messages
- if ( (turnflags&PP_TURN_TEAM) != minigame_self.team )
+ if ( (turnflags & PP_TURN_TEAM) != minigame_self.team )
return strcat(_("You lost the game!"), "\n", _("Select \"^1Next Match^7\" on the menu for a rematch!"));
return strcat(_("You win!"), "\n", _("Select \"^1Next Match^7\" on the menu to start a new match!"));
}
return false;
}
case "key_pressed":
+ case "key_released":
{
- if((minigame.minigame_flags & PP_TURN_TEAM) == minigame_self.team)
+ bool event_blocked = ((event == "key_released")
+ || ((minigame.minigame_flags & PP_TURN_TEAM) != minigame_self.team));
+ if (!(minigame.minigame_flags & PP_TURN_WIN) && !(minigame.minigame_flags & PP_TURN_DRAW))
{
switch ( ...(0,int) )
{
case K_RIGHTARROW:
case K_KP_RIGHTARROW:
+ if (event_blocked)
+ return true;
if ( ! pp_curr_pos )
pp_set_curr_pos("a3");
else
return true;
case K_LEFTARROW:
case K_KP_LEFTARROW:
+ if (event_blocked)
+ return true;
if ( ! pp_curr_pos )
pp_set_curr_pos("c3");
else
return true;
case K_UPARROW:
case K_KP_UPARROW:
+ if (event_blocked)
+ return true;
if ( ! pp_curr_pos )
pp_set_curr_pos("a1");
else
return true;
case K_DOWNARROW:
case K_KP_DOWNARROW:
+ if (event_blocked)
+ return true;
if ( ! pp_curr_pos )
pp_set_curr_pos("a3");
else
case K_ENTER:
case K_KP_ENTER:
case K_SPACE:
+ if (event_blocked)
+ return true;
pp_make_move(minigame);
return true;
}
{
if(...(0,int) == K_MOUSE1)
{
+ pp_client_event(minigame, "mouse_moved");
pp_make_move(minigame);
return true;
}