35 if ( e.classname ==
"minigame_board_piece" && e.netname == tile )
47 return 0 <= number && number < PP_NUM_CNT && 0 <= letter && letter <
PP_LET_CNT;
77 entity current = minigame.pp_curr_piece;
100 if ( minigame.minigame_flags & PP_TURN_PLACE )
101 if ( pos && player.team == (minigame.minigame_flags & PP_TURN_TEAM) )
107 if(existing && existing.team != 5)
109 if(existing.team == 1)
110 minigame.pp_team1_score++;
111 if(existing.team == 2)
112 minigame.pp_team2_score++;
115 if(minigame.pp_curr_piece)
117 minigame.pp_curr_piece.cnt = 0;
118 minigame.pp_curr_piece.team = 5;
130 piece.team = player.team;
135 minigame.pp_curr_piece = piece;
138 if(minigame.pp_team1_score == minigame.pp_team2_score)
141 minigame.minigame_flags = PP_TURN_WIN | ((minigame.pp_team1_score > minigame.pp_team2_score) ? 1 : 2);
144 minigame.minigame_flags = PP_TURN_PLACE | minigame.pp_nexteam;
155 bool t2_true = ((i == 0 || i == 6) && t > 0 && t < 6);
156 bool t1_true = (i > 0 && i < 6 && (t == 0 || t == 6));
158 if(t1_true || t2_true)
161 piece.team = ((t1_true) ? 1 : 2);
168 minigame.pp_curr_piece =
NULL;
176 if ( minigame.minigame_flags & (PP_TURN_WIN|PP_TURN_DRAW) )
178 minigame.minigame_flags = PP_TURN_NEXT | player.team;
181 else if ( (minigame.minigame_flags & PP_TURN_NEXT) &&
182 !( minigame.minigame_flags & player.team ) )
185 minigame.minigame_flags = PP_TURN_PLACE | minigame.pp_nexteam;
189 if ( e.classname ==
"minigame_board_piece" )
191 minigame.pp_team1_score = 0;
192 minigame.pp_team2_score = 0;
202 int pp_server_event(
entity minigame,
string event, ...)
216 if(e.classname ==
"minigame_board_piece")
231 if(minigame.minigame_players)
263 WriteByte(MSG_ENTITY,sent.pp_team1_score);
264 WriteByte(MSG_ENTITY,sent.pp_team2_score);
266 else if(sent.classname ==
"minigame_board_piece")
287 pp_boardsize = mySize;
297 if(e.classname ==
"minigame_board_piece")
306 if ( e.classname ==
"minigame_board_piece" )
311 vector tile_color =
'1 1 1';
314 case 1: tile_color =
'1 0.3 0.3';
break;
315 case 2: tile_color =
'0.3 0.3 1';
break;
319 string tile_name =
strcat(
"pp/piece",
ftos(e.team));
320 if(e.team == 5) { tile_name =
"pp/piece_taken"; }
324 tile_name =
"pp/piece_current";
361 if ( e.classname ==
"minigame_player" &&
363 pname = entcs_GetName(e.minigame_playerslot-1);
365 vector win_pos = pos+
eY*(mySize_y-winfs_y)/2;
368 sprintf(_(
"%s^7 won the game!"), pname),
374 sprintf(_(
"%s^7 won the game!"), pname),
392 ts_y = ( mySize_y - 2*player_fontsize_y ) / 2;
395 vector tile_size =
'48 48 0';
401 mypos_y += player_fontsize_y + ts_y;
403 mypos_y += player_fontsize_y;
410 if ( e.classname ==
"minigame_player" && e.team != PP_SPECTATOR_TEAM )
412 vector tile_color =
'1 1 1';
415 case 1: tile_color =
'1 0.3 0.3';
break;
416 case 2: tile_color =
'0.3 0.3 1';
break;
422 mypos_y += player_fontsize_y + ts_y;
424 entcs_GetName(e.minigame_playerslot-1),
427 mypos_y += player_fontsize_y;
432 mypos_x += tile_size_x;
444 string pp_turn_to_string(
int turnflags)
447 return _(
"You are spectating");
449 if ( turnflags & PP_TURN_DRAW )
452 if ( turnflags & PP_TURN_WIN )
456 return strcat(_(
"You lost the game!"),
"\n", _(
"Select \"^1Next Match^7\" on the menu for a rematch!"));
457 return strcat(_(
"You win!"),
"\n", _(
"Select \"^1Next Match^7\" on the menu to start a new match!"));
460 if ( turnflags & PP_TURN_NEXT )
463 return _(
"Select \"^1Next Match^7\" on the menu to start a new match!");
464 return _(
"Wait for your opponent to confirm the rematch");
468 return _(
"Wait for your opponent to make their move");
470 if ( turnflags & PP_TURN_PLACE )
471 return _(
"Click on the game board to place your piece");
477 void pp_make_move(
entity minigame)
479 if ( minigame.minigame_flags == (PP_TURN_PLACE|
minigame_self.team) )
485 void pp_set_curr_pos(
string s)
494 int pp_client_event(
entity minigame,
string event, ...)
501 strcpy(minigame.message, pp_turn_to_string(minigame.minigame_flags));
512 bool event_blocked = ((
event ==
"key_released")
513 || ((minigame.minigame_flags & PP_TURN_TEAM) !=
minigame_self.team));
514 if (!(minigame.minigame_flags & PP_TURN_WIN) && !(minigame.minigame_flags &
PP_TURN_DRAW))
516 switch ( ...(0,
int) )
523 pp_set_curr_pos(
"a3");
532 pp_set_curr_pos(
"c3");
541 pp_set_curr_pos(
"a1");
550 pp_set_curr_pos(
"a3");
559 pp_make_move(minigame);
566 case "mouse_pressed":
570 pp_client_event(minigame,
"mouse_moved");
571 pp_make_move(minigame);
580 if ( minigame.minigame_flags == (PP_TURN_PLACE|
minigame_self.team) )
587 case "network_receive":
591 if ( sent.classname ==
"minigame" )
595 strcpy(sent.message, pp_turn_to_string(sent.minigame_flags));
598 sent.pp_team1_score = ReadByte();
599 sent.pp_team2_score = ReadByte();
602 else if(sent.classname ==
"minigame_board_piece")
604 sent.cnt = ReadByte();
606 minigame.pp_curr_piece = sent;
618 if(...(0,
string) ==
"next")
int minigame_tile_number(string id)
void minigame_server_sendflags(entity ent, int mgflags)
void HUD_MinigameMenu_CustomEntry(entity parent, string menumessage, string event_arg)
#define FOREACH_MINIGAME_ENTITY(entityvar)
vector minigame_hud_denormalize_size(vector v, vector pos, vector mySize)
REGISTER_MINIGAME(pp, _("Push-Pull"))
bool pp_winning_piece(entity piece)
#define minigame_hud_fitsqare(pos, mySize)
entity msle_spawn(entity minigame_session, entity e)
int minigame_next_team(int curr_team, int n_teams)
void pp_move(entity minigame, entity player, string pos)
vector minigame_hud_normalize(vector v, vector pos, vector mySize)
bool pp_valid_move(entity minigame, string pos)
const int MINIG_SF_UPDATE
string minigame_tile_name(vector pos, int rows, int columns)
const float DRAWFLAG_ADDITIVE
#define HUD_Panel_DrawBg()
void minigame_drawpic_centered(vector pos, string texture, vector sz, vector color, float thealpha, int drawflags)
string minigame_texture(string name)
vector minigame_tile_pos(string id, int rows, int columns)
vector minigame_drawcolorcodedstring_wrapped(float maxwidth, vector pos, string text, vector fontsize, float theAlpha, int drawflags, float align)
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1 s1 strcat(_("Level %s: "), "^BG%s\3\, _("^BGPress ^F2%s^BG to enter the game"))
const float DRAWFLAG_NORMAL
int minigame_tile_letter(string id)
void pp_setup_pieces(entity minigame)
#define minigame_cmd(...)
string minigame_tile_buildname(int letter, int number)
vector(float skel, float bonenum) _skel_get_boneabs_hidden
string minigame_relative_tile(string start_id, int dx, int dy, int rows, int columns)
int minigame_count_players(entity minigame)
vector minigame_hud_denormalize(vector v, vector pos, vector mySize)
entity pp_find_piece(entity minig, string tile)
void minigame_drawcolorcodedstring_trunc(float maxwidth, vector pos, string text, vector fontsize, float theAlpha, int drawflags)
void minigame_hud_simpleboard(vector pos, vector mySize, string board_texture)
const int PP_SPECTATOR_TEAM
bool pp_valid_tile(string tile)
void pp_next_match(entity minigame, entity player)
vector minigame_drawstring_wrapped(float maxwidth, vector pos, string text, vector fontsize, vector color, float theAlpha, int drawflags, float align)