ISWDRBPZCEGJSXNXHML7D7XDW4N3Z7MXOF4OS7UHC6U2GVXFHYZQC 5I4UCQOTFNIXNO3IEJBPOHAHI63WOS7ZCOGHWJ47IK6MDJ6CBW6AC OPI6W7BO4V3R5WGEVN4USOHVPUV5PVWGKYBMCRU4VQOI7F7RCF5QC CGTXUBZEQ3JIDHM7MY5JDL5LB43L2QECXRS6W3RLTRIVCZTHH4IAC ZXBDOUETFSXTFY6J5LIMXBCNMDW6NTUTZ7HZZ6ND7BNUKISR74FAC NRK37A4NNGLF53STW5RJDHUEP6OKKJORJZL3HYVOKD7OW4QBO5XAC 2KCPYEJPVD4GH2WZIVQY5MY6DSVHGQ2IOZ3V7WQ5Q267B4L6KBUQC M74RMZSTQLQHMG5PGM6DMM7JJFUHHNBS7QPNGJNXCSB4WHQVBTFAC EZYBNJFUNOS3LIU6ILXN7MFKLVW4SDXW6K5T4YFKFZ2R4UWSFUXAC ALTER TABLE `player` ADD `player_penalty` tinyint(1) NOT NULL DEFAULT 0;ALTER TABLE `player` ADD `player_solved_in_round` tinyint(1) UNSIGNED;
// "my_second_global_variable" => 11,
// The inner-minigame round. Required to determine how many points// players score when solving. All players that solve in the same// round score the same, then the score drops. Also a minigame ends// when a new round begins and only 1 player is left with an// unsolved case. That player then scores 0 for that minigame and a// new one starts (or game end)."minigame_round" => 11,// The current value of points a player would get if they would// score correctly now. Decreases after rounds in that a player (or// multiple) successfully scored."points_winnable" => 12,
$cards[] = array('type' => 'evidence','type_arg' => $this->getCardTypeArg('evidence', $card_id),'nbr' => 1);}// Create Case cardsforeach ($this->cardBasis as $card_id => $card) {$cards[] = array('type' => $card['casetype'],'type_arg' => $this->getCardTypeArg($card['casetype'], $card_id),'nbr' => 1);
$cards[] = array('type' => ($card_id <= 36) ? 'evidence' : $card['casetype'],'type_arg' => $card_id,'nbr' => 1);
// Next player$this->gamestate->nextState('selectEvidence');
function getMaterialNames($material, $ids, $sorted=false){$filtered_material = array_filter($material,function($id) use ($ids) { return in_array($id, $ids); },ARRAY_FILTER_USE_KEY);$names = array_pluck($filtered_material, 'name');if ($sorted) sort($names);return $names;
$case_cards = getPlayerCaseCards($player_id);
$case_cards = $this->getPlayerCaseCards($player_id);$card_mids = array_pluck($case_cards, 'type_arg'); // material ids$card_names = $this->getMaterialNames($this->cardBasis, $card_mids, true);$tile_mids = array_pluck($this->cards->getCards($tile_ids), 'type_arg');$tile_names = $this->getMaterialNames($this->tiles, $tile_mids, true);$player_correct = $card_names == $tile_names;
if ($playerCorrect) {// If it was the last player to solve this round, we are done and// can start a new minigame; or even end the game.
if ($player_correct) {// Score + mark as inactive for the rest of the minigame.self::DbQuery("UPDATE playerSET player_score = player_score + " . self::getGameStateValue('points_winnable') . ",player_solved_in_round = " . self::getGameStateValue('minigame_round') . "WHERE player_id = $player_id");// TODO: use this notification to grey out the player areaself::notifyPlayer(self::getActivePlayerId(),'playerSolved',// TODO: improve wordingclienttranslate('You were correct, congratulations! You can now relax until the end of the mini-game.'),array());
$this->increasePenalty($player_id);
// Give penalty pointsself::DbQuery("UPDATE playerSET player_score = player_score - 2,player_penalty = player_penalty - 2WHERE player_id = $player_id");self::notifyAllPlayers(self::getActivePlayerId(),'playerFailed',// TODO: improve wordingclienttranslate('You were not correct.'),array());
self::notifyPlayer(self::getActivePlayerId(),'playerTriedToSolve',clienttranslate('You tried to solve'),array());// self::notifyAllPlayers(// 'evidenceSelected',// clienttranslate('${player_name} had no luck following evidence ${card_name}'),// array (// 'i18n' => array ('card_name'),// 'useful' => false,// 'card_id' => $card_id,// 'card_name' => $this->cardBasis[$currentCard['type_arg']]['name'],// 'card_type' => $currentCard['type_arg'],// 'player_id' => $player_id,// 'player_name' => self::getActivePlayerName(),// )// );
$this->gamestate->nextState('nextTurn');
// TODO: First check if the round is over; then we start a new minigame,// or even end the game completely, if we are already in the last// minigame. Round is over once all players solved; or even if a new// round starts and only 1 player remains with an unsolved case.
$active_player_id = self::getActivePlayerId(); // not really 'active', as this is a 'game' turn.$unsolved_player_ids = self::getObjectListFromDB("SELECT player_id FROM player WHERE player_solved_in_round IS NULL", true);// First check if the round is over; then we start a new minigame, or// even end the game completely, if we are already in the last minigame.// Round is over once all players solved; or even if a new round starts// and only 1 player remains with an unsolved case.// A round (within this minigame) is over if the (potential) next player// has `player_no` == current minigame number.$player_after = self::getPlayerAfter($active_player_id);$round_over = $player_after['player_no'] == self::getGameStateValue('minigame');if ($round_over) {// Is only one player with unsolved case left? -> start new minigameif (count($unsolved_player_ids) == 1) {$this->gamestate->nextState('nextMinigame');return;}// Did any player solve in that round? Then decrease points_winnable$round = self::incGameStateInitialValue('minigame_round');$sql = "SELECT COUNT(player_id) FROM player WHERE player_solved_in_round = $round";if (self::getUniqueValueFromDB($sql)) {self::setGameStateValue('points_winnable',max(0, self::getGameStateValue('points_winnable') - 2));}self::incGameStateInitialValue('minigame_round', 1);}
// Case: Player solved// Notify: {Player} solved ...
// Look for the next 'unsolved' player to activate.do {$next_active_player_id = self::activeNextPlayer();} while (!in_array($next_active_player_id, $unsolved_player_ids));