function add_card_owner_status($card, $player, $status) { if (get_status($card, $player) != $status) { $values["player"] = $player; $values["card"] = $card; $values["game"] = game; $values["turn"] = turn; $values["status"] = $status; create_entry("owned", array("card", "game", "player", "status", "turn"), array(), $values); $card_type = select_card($card, array("type"))["type"]; $all_typed_cards = array_of_ids(select_cards(array("type" => $card_type))); if ($status == owned) { foreach (select_suspects() as $other_player) { if ($other_player["id"] != $player) { add_card_owner_status($card, $other_player["id"], not_owned); } } $known_cards = known_cards_player($player); if (count($known_cards) == select_cards_player($player)) { foreach (select_cards(array("id" => array("NOT IN", $known_cards))) as $other_card) { add_card_owner_status($other_card["id"], $player, not_owned); } } $known_cards = known_cards_type($card_type); if (count($known_cards) + 1 == count($all_typed_cards)) { foreach (array_diff($all_typed_cards, $known_cards) as $left_out_card) { foreach (select_suspects() as $other_player) { add_card_owner_status($left_out_card, $other_player["id"], not_owned); } } } } elseif ($status == not_owned) { foreach (select_turns() as $turn) { $turn = select_turn($turn["id"], array("weapon", "room", "suspect", "witness")); if ($turn["witness"] == $player) { if ($turn["weapon"] == $card && get_status($turn["room"], $player) == not_owned || $turn["room"] == $card && get_status($turn["weapon"], $player) == not_owned) { add_card_owner_status($turn["suspect"], $player, owned); } elseif ($turn["weapon"] == $card && get_status($turn["suspect"], $player) == not_owned || $turn["suspect"] == $card && get_status($turn["weapon"], $player) == not_owned) { add_card_owner_status($turn["room"], $player, owned); } elseif ($turn["suspect"] == $card && get_status($turn["room"], $player) == not_owned || $turn["room"] == $card && get_status($turn["suspect"], $player) == not_owned) { add_card_owner_status($turn["weapon"], $player, owned); } } } if (exists_murder_card($card_type)) { foreach (select_cards(array("type" => $card_type)) as $other_card) { $unknown_owners = select_unknown_owners($other_card["id"]); if (count($unknown_owners) == 1) { foreach ($unknown_owners as $owner) { add_card_owner_status($other_card["id"], $owner, owned); } } } } } } }
"></td> <?php } ?> </tr> <?php } ?> </tbody> </table> <h1>Non résolus</h1> <?php foreach (select_players() as $player) { $remaining_cards = select_cards_player($player["id"]) - count(known_cards_player($player["id"])); if ($remaining_cards > 0) { ?> <h2><?php echo pretty_card($player) . " (" . $remaining_cards . ")"; ?> </h2> <table class="table table-bordered table-hover table-small-char"> <tbody> <?php foreach (select_turns() as $turn) { $turn = select_turn($turn["id"], array("id", "weapon", "room", "suspect", "witness")); if (!is_empty($turn["witness"]) && $player["id"] == $turn["witness"]) { $status_weapon = get_status($turn["weapon"], $turn["witness"]); $status_room = get_status($turn["room"], $turn["witness"]); $status_suspect = get_status($turn["suspect"], $turn["witness"]);