function hit($keywords, $attempt = 0, $page_token = null) { $geocode_api_key = ''; //put your api key here $url = 'https://maps.googleapis.com/maps/api/place/textsearch/json'; $params = array("query" => $keywords, "key" => $geocode_api_key); if ($page_token) { $params['pagetoken'] = $page_token; } $url = $url . "?"; foreach ($params as $key => $value) { $url = $url . $key . '=' . urlencode($value) . '&'; } rtrim($url, '&'); if ($attempt > 0) { echo "\nattempt = {$attempt}\n"; } if ($attempt >= 5) { echo "\n\ngiving up on {$url}\n\n"; exit; } $ch = new CurlHttpClient(); $ch->fetch_url($url); $resp_raw = $ch->get_response(); echo "{$url} attempt = {$attempt}, resp_raw = {$resp_raw}\n"; $resp = json_decode($resp_raw, true); $status = $resp['status']; if ($status == 'OVER_QUERY_LIMIT') { //api query limit exceeded echo "over limit for {$keywords}"; exit; } if ($status == 'ZERO_RESULTS') { echo 'zero results'; exit; } if ($status != 'OK') { usleep(500000); return hit($keywords, $attempt + 1); } $page_token = isset($resp['next_page_token']) ? $resp['next_page_token'] : null; return array($resp['results'], $page_token); }
$uron = $uron / 2; $phrase .= "<span class=date>{$date}</span> <span class={$span2}>{$select_target}</span> понял что его спасение это прием <b>Активная защита</b>.<br>"; mysql_query("UPDATE person_on SET pr_active=1 WHERE id_person='" . $users_id . "' and battle_id=" . $b_id . " and pr_name='block'"); } if (in_Array("fullshield", $def_priem)) { $uron = 1; $phrase .= "<span class=date>{$date}</span> <span class={$span2}>{$select_target}</span> понял что его спасение это прием <b>Полная защита</b>.<br>"; mysql_query("UPDATE person_on SET pr_active=1 WHERE id_person='" . $users_id . "' and battle_id=" . $b_id . " and pr_name='fullshield'"); } if ($uron <= 0) { $uron = 3 * $db["level"]; } $uron = ceil($uron); $hp_new = $hp_now - $uron; if ($hp_new <= 0) { $hp_new = 0; $phrase .= "<span class=sysdate>{$date}</span> <B>" . $select_target . " убит</B><BR>"; } if ($target_bot != 1) { mysql_query("UPDATE users SET hp='" . $hp_new . "' WHERE login='******'"); } else { mysql_query("UPDATE bot_temp SET hp='" . $hp_new . "' WHERE battle_id='" . $b_id . "' AND bot_name='" . $select_target . "'"); } mysql_query("UPDATE teams SET hitted=hitted+{$uron} WHERE player='" . $login . "'"); mysql_query("UPDATE battle_units SET counter=counter+1 WHERE battle_id={$b_id} and player='" . $login . "'"); $phrase .= "<span class=date>{$date}</span> <span class={$span}>" . $login . "</span> произнес заклятье <span class=magic>" . $is_pr["name"] . "</span> на <span class={$span2}>{$select_target}</span> на <span class=hitted>-{$uron}</span> [{$hp_new}/{$hp_all}]<BR>"; battle_log($b_id, $phrase); hit($login, $target, 0, 0, 0, 0, $b_id, 0); } } }
$bat_id = (int) $_GET["bat_id"]; $bat_sql = mysql_query("SELECT creator_id FROM battles WHERE id=" . $bat_id); if (mysql_num_rows($bat_sql)) { $battle = mysql_fetch_Array($bat_sql); $bot = mysql_query("SELECT * FROM bot_temp WHERE battle_id='" . $bat_id . "' and hp>0"); while ($bots = mysql_fetch_array($bot)) { $enemy_teams = $bots["team"] == 1 ? 2 : 1; $sql = mysql_query("SELECT * FROM teams WHERE team={$enemy_teams} and battle_id=" . $battle["creator_id"]); while ($teams = mysql_fetch_array($sql)) { $hits = mysql_query("SELECT * FROM hit_temp WHERE attack='" . $teams["player"] . "' and defend='" . $bots["bot_name"] . "' and battle_id=" . $bat_id); if (!mysql_num_rows($hits)) { $hit1 = rand(1, 5); $hit2 = rand(1, 5); $block = rand(1, 5); hit($bots["bot_name"], $teams["player"], $hit1, $hit2, $hit3, $block, $bat_id, 1); } } $sql_bot = mysql_query("SELECT * FROM bot_temp WHERE team={$enemy_teams} and battle_id=" . $bat_id . " and hp>0"); while ($teams_bot = mysql_fetch_array($sql_bot)) { $hits_bot = mysql_query("SELECT * FROM hit_temp WHERE attack='" . $teams_bot["bot_name"] . "' and defend='" . $bots["bot_name"] . "' and battle_id=" . $bat_id); if (!mysql_num_rows($hits_bot)) { $hit1 = rand(1, 5); $hit2 = rand(1, 5); $block = rand(1, 5); hit($bots["bot_name"], $teams_bot["bot_name"], $hit1, $hit2, $hit3, $block, $bat_id, 1); } } } } } mysql_close($data);
$hit2 = 0; $hit3 = 0; $blok = 0; if (!$_SESSION["random_hit"]) { $hit1 = (int) $_POST['attack0']; $hit2 = (int) $_POST['attack1']; $hit3 = (int) $_POST['attack2']; $blok = (int) $_POST['defend']; } else { $hit1 = mt_rand(1, 5); $hit2 = mt_rand(1, 5); $hit3 = mt_rand(1, 5); $blok = mt_rand(1, 5); } if ($hit1 && ($zones == 2 && $hit2 || $zones == 3 && $hit2 && $hit3 || $zones == 1) && $blok) { hit($login, $opponent, $hit1, $hit2, $hit3, $blok, $bid, 0); Header("Location: battle.php?tmp={$random}"); die; } } ######################################################################################## ?> <TABLE border=0 width=100% cellpadding=0 cellspacing=0> <TR> <TD WIDTH=260 VALIGN=TOP ALIGN=LEFT nowrap> <?php include_once "inc/battle/left.php"; ?> </TD> <TD width=100% valign=top align=center nowrap> <FORM action="battle.php?act=hit&<?php
$hp_now = $victims[$i]["hp"]; $hp_all = $victims[$i]["hp_all"]; $opponenti = $victims[$i]["opponent"]; $hp_add = ceil(mt_rand($hp_min, $hp_max)); if ($hp_all - $hp_now < $hp_add) { $hp_add = $hp_all - $hp_now; } $hp_new = $hp_now + $hp_add; setHP($opponenti, $hp_new, $hp_all); $ret['action'] .= "<span class=date>{$date}</span> <span class={$span}>" . $login . "</span> понимая, что ситуация становится критической, применил прием <span class=magic>" . $is_pr["name"] . "</span> и восстановил здоровье <span class={$span}>" . $opponenti . "</span> на <span class=hitted>+{$hp_add}</span> [{$hp_new}/{$hp_all}]<BR>"; } if ($db["hp"] < $db["hp_all"]) { if ($db["hp_all"] - $db["hp"] < $hp_me) { $hp_me = $db["hp_all"] - $db["hp"]; } $hp_new_me = $db["hp"] + $hp_me; setHP($login, $hp_new_me, $db["hp_all"]); $ret['action'] .= "<span class=date>{$date}</span> <span class={$span}>" . $login . "</span> понимая, что ситуация становится критической, применил прием <span class=magic>" . $is_pr["name"] . "</span> и восстановил свое здоровье <span class=hitted>+{$hp_me}</span> [{$hp_new_me}/" . $db["hp_all"] . "]<BR>"; $yes_me = 1; } if (count($victims) > 0 || $yes_me == 1) { mysql_query("UPDATE battle_units SET hit=hit-" . (int) $is_pr["hit"] . ",krit=krit-" . (int) $is_pr["krit"] . ",uvarot=uvarot-" . (int) $is_pr["uvarot"] . ",block=block-" . (int) $is_pr["block"] . ",hp=hp-" . (int) $is_pr["hp"] . ",counter=counter-" . (int) $is_pr["all_hit"] . " WHERE player='" . $login . "' and battle_id='" . $b_id . "'"); mysql_query("UPDATE person_on SET pr_active=1,pr_wait_for=" . $is_pr["wait"] . " WHERE id_person='" . $db["id"] . "' and pr_name='earthhp6' and battle_id='" . $b_id . "'"); mysql_query("UPDATE person_on SET pr_active=1,pr_wait_for=" . $is_pr["wait"] . " WHERE id_person='" . $db["id"] . "' and pr_name='earthhp7' and battle_id='" . $b_id . "'"); mysql_query("UPDATE person_on SET pr_active=1,pr_wait_for=" . $is_pr["wait"] . " WHERE id_person='" . $db["id"] . "' and pr_name='earthhp8' and battle_id='" . $b_id . "'"); mysql_query("UPDATE person_on SET pr_active=1,pr_wait_for=" . $is_pr["wait"] . " WHERE id_person='" . $db["id"] . "' and pr_name='earthhp9' and battle_id='" . $b_id . "'"); mysql_query("UPDATE person_on SET pr_active=1,pr_wait_for=" . $is_pr["wait"] . " WHERE id_person='" . $db["id"] . "' and pr_name='earthhp10' and battle_id='" . $b_id . "'"); } battle_log($b_id, $ret['action']); hit($login, $db["battle_opponent"], 0, 0, 0, 0, $b_id, 0); }
<?php require_once "Character.php"; $bob = new Character(100, 5, 10); $lennon = new Character(50, 10, 20); function hit($attacker_name, $attacker, $defender_name, $defender) { printf("{$attacker_name} attacks {$defender_name}" . PHP_EOL); $attacker->attack($defender); printf("{$defender_name} has %d HP" . PHP_EOL, $defender->getHp()); if ($defender->isKo()) { printf("{$attacker_name} won by Ko, he has %d hp left" . PHP_EOL, $attacker->getHp()); exit; } } while (true) { hit("Bob", $bob, "Lennon", $lennon); hit("Lennon", $lennon, "Bob", $bob); }
$ret['action'] .= "<span class=date>{$date}</span> <B>" . $victims[$i]["opponent"] . " убит</B><BR>"; } if ($victims[$i]["types"] == "human") { mysql_query("UPDATE users SET hp='" . $hp_new . "' WHERE login='******'"); } else { if ($victims[$i]["types"] == "bot") { mysql_query("UPDATE bot_temp SET hp='" . $hp_new . "' WHERE battle_id='" . $b_id . "' AND bot_name='" . $victims[$i]["opponent"] . "'"); } } $ret['action'] .= "<span class=date>{$date}</span> <span class={$span}>" . $login . "</span> обрушил <span class=magic>Каменный Дождь[6]</span> на <span class={$span2}>" . $victims[$i]["opponent"] . "</span>, <span class=hitted>-{$uron}</span> [" . $hp_new . "/" . $victims[$i]["hp_all"] . "]<BR>"; $ret['uron'] += $uron; } mysql_query("UPDATE teams SET hitted=hitted+" . $ret['uron'] . " WHERE player='" . $login . "'"); mysql_query("UPDATE users SET battle_opponent='' WHERE login='******'"); mysql_query("UPDATE timeout SET lasthit='" . $t . "' WHERE battle_id='" . $b_id . "'"); $td = fopen("logs/" . $b_id . ".dis", "a"); fputs($td, $ret['action']); fclose($td); mysql_query("UPDATE inv SET iznos = iznos+1 WHERE id='" . $id . "'"); $S_INV = mysql_query("SELECT iznos,iznos_max FROM inv WHERE id = '" . $id . "' limit 1"); $DAT = mysql_fetch_array($S_INV); if ($DAT["iznos"] == $DAT["iznos_max"]) { mysql_query("UPDATE users SET slot" . $slot . "=0 WHERE login='******'"); mysql_query("DELETE FROM inv WHERE id = '" . $id . "'"); say($login, "Заклинание <b>«" . $name . "»</b> полностью использован!", $login); } $c = count($hited_targets); for ($i = 0; $i < $c; $i++) { hit($login, $hited_targets[$i], 0, 0, 0, $b_id); } }
<?php /** * Created by PhpStorm. * User: Øyvind * Date: 05.07.2015 * Time: 17.52 */ if (!isset($_SESSION['doubleClick'])) { if (isset($_SESSION['newRound']) && $_SESSION['newRound']) { init(); } elseif (isset($_POST['hit'])) { hit(); } elseif (isset($_POST['stand'])) { stand(); } elseif (isset($_POST['split'])) { splitHand(); } elseif (isset($_POST['double'])) { doubleHand(); } } else { if (isset($_SESSION['language_changed']) && $_SESSION['language_changed']) { printCards(); $_SESSION['language_changed'] = false; } } /** * Initializes a new round */ function init() {
session_start(); //$count = 0; if (isset($_POST['hit']) && $_SESSION['blackjack_state'] == "in_game") { hit("player"); //check if player busted if (countCards($_SESSION['blackjack_player_cards']) > 21) { echo "You busted, dealer won..."; $_SESSION['blackjack_state'] = 2; } } elseif (isset($_POST['stay']) && $_SESSION['blackjack_state'] == "in_game") { //calc player & dealer points $dealer = countCards($_SESSION['blackjack_dealer_cards']); $player = countCards($_SESSION['blackjack_player_cards']); //if dealer under 17 points, keep hitting. while ($dealer < 17) { hit("dealer"); $dealer = countCards($_SESSION['blackjack_dealer_cards']); } //dealer has blackjack if ($dealer == 21) { echo "Dealer Got BlackJack... You lost..."; } elseif ($dealer >= $player) { //if dealer under 21, they win if ($dealer < 21) { echo "Dealer Won..."; } else { echo "Congradulations, you won. The dealer busted..."; } } else { //player has blackjack if ($player == 21) {