- else if ($argz[0] == 'play') {
- $a_play = $argz[1];
- $a_x = $argz[2];
- $a_y = $argz[3];
-
- if (strpos($a_x, "px") != FALSE)
- $a_x = substr($a_x,0,-2);
- if (strpos($a_y, "px") != FALSE)
- $a_y = substr($a_y,0,-2);
-
- $loggo = sprintf("A_play %s, table_pos %d == %d, mazzo %d, gstart %d, card_stat %d, card_own %d",
- $a_play, $user->table_pos, ($table->gstart % PLAYERS_N),
- $table->mazzo, $table->gstart,
- $table->card[$a_play]->stat, $table->card[$a_play]->owner);
- log_wr($sess, "CIC".$loggo);
-
- /* se era il suo turno e la carta era sua ed era in mano */
- if ($a_play >=0 && $a_play < 40 &&
- ($user->table_pos == (($table->gstart + $table->turn) % PLAYERS_N)) &&
- $table->card[$a_play]->stat == 'hand' &&
- $table->card[$a_play]->owner == $user->table_pos) {
- log_wr($sess, sprintf("User: %s Play: %d",$user->name, $a_play));
-
- /* Change the card status. */
- $table->card[$a_play]->play($a_x, $a_y);
-
- /*
- * !!!! TURN INCREMENTED BEFORE !!!!
- */
- $turn_cur = ($table->gstart + $table->turn) % PLAYERS_N;
- $table->turn++;
-
- $card_play = sprintf("card_play(%d,%d,%d,%d);|",
- $user->table_pos, $a_play, $a_x, $a_y);
- if (($table->turn % PLAYERS_N) != 0) { /* manche not finished */
- $turn_nex = ($table->gstart + $table->turn) % PLAYERS_N;
-
- $player_cur = "remark_off();";
- $player_nex = $card_play . "is_my_time = true; remark_on();";
- $player_oth = $card_play;
- }
- else if ($table->turn <= (PLAYERS_N * 8)) { /* manche finished */
- $winner = calculate_winner($table);
- log_wr($sess,"GSTART 3");
- $table->gstart = $winner;
- $turn_nex = ($table->gstart + $table->turn) % PLAYERS_N;
-
- log_wr($sess, sprintf("The winner is: [%d] [%s]", $winner, $bri->user[$table->player[$winner]]->name));
- $card_take = sprintf("sleep(gst,2000);|cards_take(%d);|cards_hidetake($d);",
- $winner, $winner);
- $player_cur = "remark_off();" . $card_take . "|";
- if ($turn_cur != $turn_nex)
- $player_nex = $card_play . $card_take . "|";
- else
- $player_nex = "";
- if ($table->turn < (PLAYERS_N * 8)) /* game NOT finished */
- $player_nex .= "is_my_time = true; remark_on();";
- $player_oth = $card_play . $card_take;