Esempio n. 1
0
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);
                        }
                    }
                }
            }
        }
    }
}
Esempio n. 2
0
                    break;
            }
        }
        if (get_status($_POST["room"], $_POST["witness"]) == not_owned && get_status($_POST["weapon"], $_POST["witness"]) == not_owned) {
            add_card_owner_status($_POST["suspect"], $_POST["witness"], owned);
        } elseif (get_status($_POST["weapon"], $_POST["witness"]) == not_owned && get_status($_POST["suspect"], $_POST["witness"]) == not_owned) {
            add_card_owner_status($_POST["room"], $_POST["witness"], owned);
        } elseif (get_status($_POST["room"], $_POST["witness"]) == not_owned && get_status($_POST["suspect"], $_POST["witness"]) == not_owned) {
            add_card_owner_status($_POST["weapon"], $_POST["witness"], owned);
        }
        increment_turn();
        redirect_to_action("show");
        break;
    case "skip":
        increment_turn();
        redirect_to_action("show");
        break;
    case "show":
        break;
    case "daybook":
        break;
    case "revert":
        $turn = max(array_of_ids(select_turns()));
        delete_turn($turn);
        delete_owned_of_turn($turn);
        redirect_to_action("show");
        break;
    default:
        header_if(true, 403);
        exit;
}
Esempio n. 3
0
<?php

echo form_input(pretty_card(array("id" => get_current_player())) . " suspecte", "suspect", $form, array("options" => option_array(select_suspects(), "id", "name", "card")));
echo form_input("avec l'arme", "weapon", $form, array("options" => option_array(select_weapons(), "id", "name", "card")));
echo form_input("dans la pièce", "room", $form, array("options" => option_array(select_rooms(), "id", "name", "card")));
echo form_input("mais le témoin", "witness", $form, array("options" => array_true_merge(option_array(select_players(), "id", "name", "card"), array(0 => ""))));
if (get_current_player() == my_player()) {
    echo form_input("réfute avec", "evidence", $form, array("options" => option_array(select_types(), "id", "name", "type")));
} else {
    echo "réfute";
}
?>
.
<br>
<?php 
$turns = select_turns();
echo form_submit_button("Ok") . " " . link_to(path("skip", "game", game), "Suivant", array("class" => "btn btn-primary")) . " " . (!is_empty($turns) ? link_to(path("revert", "game", game), "Annuler le dernier coup", array("class" => "btn btn-primary")) : "");
Esempio n. 4
0
<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"]);
                if ($status_weapon != owned && $status_room != owned && $status_suspect != owned) {
                    ?>
              <tr>
                <td>
                  <?php 
                    if ($status_weapon != not_owned) {
                        echo pretty_card(array("id" => $turn["weapon"]));
                    }
                    ?>
                </td>