21 if ( e.classname ==
"minigame_board_piece" && e.netname == tile )
30 if( e.classname ==
"minigame_board_piece" )
46 else if(number > PS_NUM_CNT - 3)
49 if(letter > PS_LET_CNT - 3)
53 else if(number > PS_NUM_CNT - 3)
69 return 0 <= number && number < PS_NUM_CNT && 0 <= letter && letter <
PS_LET_CNT;
80 if ( e.classname ==
"minigame_board_piece" )
126 if(i ==
floor(PS_NUM_CNT * 0.5) && t ==
floor(PS_LET_CNT * 0.5))
150 strcpy(piece.netname, pos);
160 if ( (minigame.minigame_flags & PS_TURN_MOVE) )
177 done =
ps_move_piece(minigame, piece, pos, letter - 1, number);
184 done =
ps_move_piece(minigame, piece, pos, letter + 1, number);
191 done =
ps_move_piece(minigame, piece, pos, letter, number - 1);
198 done =
ps_move_piece(minigame, piece, pos, letter, number + 1);
223 int ps_server_event(
entity minigame,
string event, ...)
237 if(e.classname ==
"minigame_board_piece")
287 ps_boardsize = mySize;
295 bool highlight =
false;
330 bool draw_pos =
false;
341 if(
try == ps_curr_pos)
348 if(
try == ps_curr_pos)
355 if(
try == ps_curr_pos)
362 if(
try == ps_curr_pos)
370 if ( e.classname ==
"minigame_board_piece" )
375 vector tile_color =
'1 1 1';
378 if(e.netname == ps_curr_pos)
379 if(ps_curr_piece.netname != ps_curr_pos)
385 if(e == ps_curr_piece)
412 if(e.classname ==
"minigame_board_piece")
416 string remaining_text;
418 remaining_text = _(
"All pieces cleared!");
420 remaining_text =
strcat(_(
"Remaining pieces:"),
" ",
ftos(remaining));
422 vector win_pos = pos+
eY*(mySize_y-winfs_y)/2;
425 strcat(_(
"Game over!"),
" ", remaining_text),
431 strcat(_(
"Game over!"),
" ", remaining_text),
449 ts_y = ( mySize_y - 2*player_fontsize_y ) / 2;
452 vector tile_size =
'48 48 0';
458 mypos_y += player_fontsize_y;
466 if(e.classname ==
"minigame_board_piece")
474 if ( e.classname ==
"minigame_player" && e.team != PS_SPECTATOR_TEAM )
478 entcs_GetName(e.minigame_playerslot-1),
481 mypos_y += player_fontsize_y;
488 drawstring(mypos,sprintf(_(
"Pieces left: %s"),
ftos(remaining)),
'28 28 0',
495 string ps_turn_to_string(
int turnflags)
498 return _(
"You are spectating");
500 if (turnflags & PS_TURN_DRAW )
501 return _(
"No more valid moves");
503 if ( turnflags & PS_TURN_WIN )
504 return _(
"Well done, you win!");
506 if ( turnflags & PS_TURN_MOVE )
507 return _(
"Jump a piece over another to capture it");
513 void ps_make_move(
entity minigame)
515 if ( minigame.minigame_flags == PS_TURN_MOVE )
518 if(!ps_curr_piece || piece)
522 minigame_cmd(
"move ", ps_curr_piece.netname,
" ", ps_curr_pos);
523 ps_curr_piece =
NULL;
528 void ps_set_curr_pos(
string s)
537 int ps_client_event(
entity minigame,
string event, ...)
544 ps_curr_piece =
NULL;
545 strcpy(minigame.message, ps_turn_to_string(minigame.minigame_flags));
557 if (!(minigame.minigame_flags & PS_TURN_WIN) && !(minigame.minigame_flags &
PS_TURN_DRAW))
559 switch ( ...(0,
int) )
566 ps_set_curr_pos(
"a3");
575 ps_set_curr_pos(
"c3");
584 ps_set_curr_pos(
"a1");
593 ps_set_curr_pos(
"a3");
602 ps_make_move(minigame);
609 case "mouse_pressed":
613 ps_client_event(minigame,
"mouse_moved");
614 ps_make_move(minigame);
623 if ( minigame.minigame_flags == PS_TURN_MOVE &&
minigame_self.team != PS_SPECTATOR_TEAM )
632 case "network_receive":
636 if ( sent.classname ==
"minigame" )
640 strcpy(sent.message, ps_turn_to_string(sent.minigame_flags));
int minigame_tile_number(string id)
void minigame_server_sendflags(entity ent, int mgflags)
#define FOREACH_MINIGAME_ENTITY(entityvar)
void ps_move(entity minigame, entity player, string thepiece, string pos)
vector minigame_hud_denormalize_size(vector v, vector pos, vector mySize)
#define minigame_hud_fitsqare(pos, mySize)
bool ps_tile_blacklisted(string tile)
entity msle_spawn(entity minigame_session, entity e)
bool ps_draw(entity minigame)
bool ps_valid_tile(string tile)
vector minigame_hud_normalize(vector v, vector pos, vector mySize)
entity ps_find_piece(entity minig, string tile)
const int MINIG_SF_UPDATE
void ps_setup_pieces(entity minigame)
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"))
bool ps_winning_piece(entity minigame)
bool ps_move_piece(entity minigame, entity piece, string pos, int leti, int numb)
const float DRAWFLAG_NORMAL
int minigame_tile_letter(string id)
#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)
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)
REGISTER_MINIGAME(ps, _("Peg Solitaire"))
const int PS_SPECTATOR_TEAM
vector minigame_drawstring_wrapped(float maxwidth, vector pos, string text, vector fontsize, vector color, float theAlpha, int drawflags, float align)