Exemplo n.º 1
0
     $cmdnum++;
 } else {
     if ($command == 'itemget') {
         include_once GAME_ROOT . './include/game/itemmain.func.php';
         itemget();
     } else {
         if ($command == 'getcorpse') {
             include_once GAME_ROOT . './include/game/itemmain.func.php';
             getcorpse($var1);
         } else {
             if ($command == 'attack') {
                 include_once GAME_ROOT . './include/game/combat.func.php';
                 if ($var1 == 'back') {
                     combat(1, $var1);
                 } else {
                     combat(1);
                 }
             } else {
                 if (strpos($command, 'drop') === 0) {
                     include_once GAME_ROOT . './include/game/itemmain.func.php';
                     $drop_item = substr($command, 4);
                     itemdrop($drop_item);
                 } else {
                     if (strpos($command, 'off') === 0) {
                         include_once GAME_ROOT . './include/game/itemmain.func.php';
                         $off_item = substr($command, 3);
                         itemoff($off_item);
                     } else {
                         if (strpos($command, 'swap') === 0) {
                             include_once GAME_ROOT . './include/game/itemmain.func.php';
                             $swap_item = substr($command, 4);
Exemplo n.º 2
0
function discover($schmode = 0)
{
    global $art, $pls, $now, $log, $mode, $command, $cmd, $event_obbs, $weather, $pls, $club, $pose, $tactic, $inf, $item_obbs, $enemy_obbs, $trap_min_obbs, $trap_max_obbs, $bid, $db, $tablepre, $gamestate, $corpseprotect, $action, $skills, $rp, $aidata;
    $event_dice = rand(0, 99);
    if ($event_dice < $event_obbs || $art != "Untainted Glory" && $pls == 34 && $gamestate != 50) {
        include_once GAME_ROOT . './include/game/event.func.php';
        event();
        $mode = 'command';
        return;
    }
    include_once GAME_ROOT . './include/game/aievent.func.php';
    //AI事件
    $aidata = false;
    //用于判断天然呆AI(冴冴这样的)是否已经来到你身后并且很生气
    aievent(20);
    //触发AI事件的概率
    if (is_array($aidata)) {
        include_once GAME_ROOT . './include/game/attr.func.php';
        $active_r = get_active_r($weather, $pls, $pose, $tactic, $club, $inf, $aidata['pose']);
        include_once GAME_ROOT . './include/game/clubskills.func.php';
        $active_r *= get_clubskill_bonus_active($club, $skills, $aidata['club'], $aidata['skills']);
        if ($active_r > 96) {
            $active_r = 96;
        }
        $bid = $aidata['pid'];
        $active_dice = rand(0, 99);
        if ($active_dice < $active_r) {
            $action = 'enemy' . $aidata['pid'];
            include_once GAME_ROOT . './include/game/battle.func.php';
            findenemy($aidata);
            return;
        } else {
            include_once GAME_ROOT . './include/game/combat.func.php';
            combat(0);
            return;
        }
    }
    $trap_dice = rand(0, 99);
    //随机数,开始判断是否踩陷阱
    if ($trap_dice < $trap_max_obbs) {
        //踩陷阱概率最大值
        $trapresult = $db->query("SELECT * FROM {$tablepre}maptrap WHERE pls = '{$pls}' ORDER BY itmk DESC");
        //		$traplist = Array();
        //		while($trap0 = $db->fetch_array($result)){
        //			$traplist[$trap0['tid']] = $trap0;
        //			if($trap0['itmk'] == 'TOc'){
        //				$xtrap = true;
        //				$xtrapid = $
        //			}
        //		}
        $xtrp = $db->fetch_array($trapresult);
        $xtrpflag = false;
        //echo $xtrp['itm'];
        if ($xtrp['itmk'] == 'TOc') {
            $xtrpflag = true;
        }
        $trpnum = $db->num_rows($trapresult);
        if ($trpnum) {
            //看地图上有没有陷阱
            //echo "踩陷阱概率:{$real_trap_obbs}%";
            if ($xtrpflag) {
                global $itm0, $itmk0, $itme0, $itms0, $itmsk0;
                $itm0 = $xtrp['itm'];
                $itmk0 = $xtrp['itmk'];
                $itme0 = $xtrp['itme'];
                $itms0 = $xtrp['itms'];
                $itmsk0 = $xtrp['itmsk'];
                $tid = $xtrp['tid'];
                $db->query("DELETE FROM {$tablepre}maptrap WHERE tid='{$tid}'");
                include_once GAME_ROOT . './include/game/itemmain.func.php';
                itemfind();
                return;
            } else {
                $real_trap_obbs = $trap_min_obbs + $trpnum / 4;
                //Anti-Meta RP System Version 2.00 ~ Nemo
                //冴冴我喜欢你!
                //17rp/177rp+1%
                if ($gamestate >= 50) {
                    $real_trap_obbs = $real_trap_obbs + $rp / 177;
                } else {
                    $real_trap_obbs = $real_trap_obbs + $rp / 30;
                }
                if ($pose == 1) {
                    $real_trap_obbs += 1;
                } elseif ($pose == 3) {
                    $real_trap_obbs += 3;
                }
                //攻击和探索姿势略容易踩陷阱
                if ($gamestate >= 40) {
                    $real_trap_obbs += 3;
                }
                //连斗以后略容易踩陷阱
                if ($pls == 0) {
                    $real_trap_obbs += 15;
                }
                //在后台非常容易踩陷阱
                if ($club == 6) {
                    $real_trap_obbs -= 5;
                }
                //人肉搜索称号遭遇陷阱概率减少
                if ($trap_dice < $real_trap_obbs) {
                    //踩陷阱判断
                    $itemno = rand(0, $trpnum - 1);
                    $db->data_seek($trapresult, $itemno);
                    $mi = $db->fetch_array($trapresult);
                    global $itm0, $itmk0, $itme0, $itms0, $itmsk0;
                    $itm0 = $mi['itm'];
                    $itmk0 = $mi['itmk'];
                    $itme0 = $mi['itme'];
                    $itms0 = $mi['itms'];
                    $itmsk0 = $mi['itmsk'];
                    $tid = $mi['tid'];
                    $db->query("DELETE FROM {$tablepre}maptrap WHERE tid='{$tid}'");
                    if ($itms0) {
                        include_once GAME_ROOT . './include/game/itemmain.func.php';
                        itemfind();
                        return;
                    }
                }
            }
        }
    }
    //	$trap_dice =  rand(0,99);
    //	if($pose==1){$trap_dice-=5;}
    //	elseif($pose==3){$trap_dice-=8;}//攻击和探索姿势略容易踩陷阱
    //	if($gamestate >= 40){$trap_dice-=5;}//连斗以后略容易踩陷阱
    //	if($trap_dice < $trap_obbs){
    //		$result = $db->query("SELECT * FROM {$tablepre}{$pls}mapitem WHERE itmk = 'TO'");
    //		$trpnum = $db->num_rows($result);
    //		if($trpnum){
    //			$itemno = rand(0,$trpnum-1);
    //			$db->data_seek($result,$itemno);
    //			$mi=$db->fetch_array($result);
    //			global $itm0,$itmk0,$itme0,$itms0,$itmsk0;
    //			$itm0=$mi['itm'];
    //			$itmk0=$mi['itmk'];
    //			$itme0=$mi['itme'];
    //			$itms0=$mi['itms'];
    //			$itmsk0=$mi['itmsk'];
    //			$iid=$mi['iid'];
    //			$db->query("DELETE FROM {$tablepre}{$pls}mapitem WHERE iid='$iid'");
    //			if($itms0){
    //				include_once GAME_ROOT.'./include/game/itemmain.func.php';
    //				itemfind();
    //				return;
    //			}
    //		}
    //	}
    include_once GAME_ROOT . './include/game/attr.func.php';
    $mode_dice = rand(0, 99);
    if ($mode_dice < $schmode) {
        global $pid, $corpse_obbs, $teamID, $fog, $bid, $gamestate;
        //		if($gamestate < 40) {
        //			$result = $db->query("SELECT * FROM {$tablepre}players WHERE pls='$pls' AND pid!='$pid' AND pid!='$bid'");
        //		} else {
        //			$result = $db->query("SELECT * FROM {$tablepre}players WHERE pls='$pls' AND pid!='$pid'");
        //		}
        $result = $db->query("SELECT * FROM {$tablepre}players WHERE pls='{$pls}' AND pid!='{$pid}'");
        if (!$db->num_rows($result)) {
            $log .= '<span class="yellow">周围一个人都没有。</span><br>';
            if (CURSCRIPT == 'botservice') {
                echo "noenemy=1\n";
            }
            $mode = 'command';
            return;
        }
        $enemynum = $db->num_rows($result);
        $enemyarray = range(0, $enemynum - 1);
        shuffle($enemyarray);
        $find_r = get_find_r($weather, $pls, $pose, $tactic, $club, $inf);
        $find_obbs = $enemy_obbs + $find_r;
        foreach ($enemyarray as $enum) {
            $db->data_seek($result, $enum);
            $edata = $db->fetch_array($result);
            if (!$edata['type'] || $gamestate < 50) {
                if ($edata['hp'] > 0) {
                    global $art, $artk, $name;
                    if (!$edata['type'] && $artk == 'XX' && ($edata['artk'] != 'XX' || $edata['art'] != $name) && $gamestate < 50) {
                        continue;
                    }
                    if ($artk != 'XX' && $edata['artk'] == 'XX' && $gamestate < 50) {
                        continue;
                    }
                    $hide_r = get_hide_r($weather, $pls, $edata['pose'], $edata['tactic'], $edata['club'], $edata['inf']);
                    include_once GAME_ROOT . './include/game/clubskills.func.php';
                    $hide_r *= get_clubskill_bonus_hide($edata['club'], $edata['skills']);
                    $enemy_dice = rand(0, 99);
                    if ($enemy_dice < $find_obbs - $hide_r) {
                        if ($teamID && !$fog && $gamestate < 40 && $teamID == $edata['teamID']) {
                            $bid = $edata['pid'];
                            $action = 'team' . $edata['pid'];
                            include_once GAME_ROOT . './include/game/battle.func.php';
                            findteam($edata);
                            return;
                        } else {
                            $active_r = get_active_r($weather, $pls, $pose, $tactic, $club, $inf, $edata['pose']);
                            include_once GAME_ROOT . './include/game/clubskills.func.php';
                            $active_r *= get_clubskill_bonus_active($club, $skills, $edata['club'], $edata['skills']);
                            if ($active_r > 96) {
                                $active_r = 96;
                            }
                            $bid = $edata['pid'];
                            $active_dice = rand(0, 99);
                            if ($active_dice < $active_r) {
                                $action = 'enemy' . $edata['pid'];
                                include_once GAME_ROOT . './include/game/battle.func.php';
                                findenemy($edata);
                                return;
                            } else {
                                if (CURSCRIPT == 'botservice') {
                                    echo "passive_battle=1\n";
                                    echo "passive_w_name={$edata['name']}\n";
                                    echo "passive_w_type={$edata['type']}\n";
                                    echo "passive_w_sNo={$edata['sNo']}\n";
                                }
                                include_once GAME_ROOT . './include/game/combat.func.php';
                                combat(0);
                                return;
                            }
                        }
                    } else {
                        $hideflag = true;
                    }
                } else {
                    $corpse_dice = rand(0, 99);
                    if ($corpse_dice < $corpse_obbs) {
                        if ($gamestate < 40 && $edata['endtime'] < $now - $corpseprotect && ($edata['weps'] && $edata['wepe'] || $edata['arbs'] && $edata['arbe'] || $edata['arhs'] || $edata['aras'] || $edata['arfs'] || $edata['arts'] || $edata['itms0'] || $edata['itms1'] || $edata['itms2'] || $edata['itms3'] || $edata['itms4'] || $edata['itms5'] || $edata['money'])) {
                            $bid = $edata['pid'];
                            $action = 'corpse' . $edata['pid'];
                            include_once GAME_ROOT . './include/game/battle.func.php';
                            findcorpse($edata);
                            return;
                        } else {
                            //这看上去是个bug…… 会导致地图上最后一个兵很难摸到……
                            //改成discover(100)应该就能解决问题…… 但修复了可能导致平衡性问题…… 所以暂时留在这……
                            discover(50);
                            return;
                        }
                    }
                }
            }
        }
        if ($hideflag == true) {
            $log .= '似乎有人隐藏着……<br>';
        } else {
            $log .= '<span class="yellow">周围一个人都没有。</span><br>';
        }
        $mode = 'command';
        return;
    } else {
        $find_r = get_find_r($weather, $pls, $pose, $tactic, $club, $inf);
        $find_obbs = $item_obbs + $find_r;
        $item_dice = rand(0, 99);
        if ($item_dice < $find_obbs) {
            //$mapfile = GAME_ROOT."./gamedata/mapitem/{$pls}mapitem.php";
            //$mapitem = openfile($mapfile);
            //$itemnum = sizeof($mapitem) - 1;
            //			$result = $db->query("SELECT * FROM {$tablepre}mapitem WHERE map='$pls'");
            //			$itemnum = $db->num_rows($result);
            $result = $db->query("SELECT * FROM {$tablepre}mapitem WHERE pls = '{$pls}'");
            $itemnum = $db->num_rows($result);
            if ($itemnum <= 0) {
                $log .= '<span class="yellow">周围找不到任何物品。</span><br>';
                $mode = 'command';
                return;
            }
            $itemno = rand(0, $itemnum - 1);
            $db->data_seek($result, $itemno);
            $mi = $db->fetch_array($result);
            global $itm0, $itmk0, $itme0, $itms0, $itmsk0;
            $itm0 = $mi['itm'];
            $itmk0 = $mi['itmk'];
            $itme0 = $mi['itme'];
            $itms0 = $mi['itms'];
            $itmsk0 = $mi['itmsk'];
            $iid = $mi['iid'];
            $db->query("DELETE FROM {$tablepre}mapitem WHERE iid='{$iid}'");
            //list($itm0,$itmk0,$itme0,$itms0,$itmsk0) = explode(',', $mapitem[$itemno]);
            //array_splice($mapitem,$itemno,1);
            //writeover($mapfile,implode('', $mapitem),'wb');
            //unset($mapitem);
            if ($itms0) {
                include_once GAME_ROOT . './include/game/itemmain.func.php';
                itemfind();
                return;
            } else {
                $log .= "但是什么都没有发现。可能是因为道具有天然呆属性。<br>";
            }
        } else {
            $log .= "但是什么都没有发现。<br>";
        }
    }
    $mode = 'command';
    return;
}
Exemplo n.º 3
0
             } else {
                 if ($retval == 2) {
                     $log .= "未选择称号。<br>";
                 } else {
                     $log .= "称号选择非法!<br>";
                 }
             }
         }
         $mode = 'command';
     }
 } elseif ($mode == 'senditem') {
     include_once GAME_ROOT . './include/game/battle.func.php';
     senditem();
 } elseif ($mode == 'combat') {
     include_once GAME_ROOT . './include/game/combat.func.php';
     combat(1, $command);
 } elseif ($mode == 'rest') {
     include_once GAME_ROOT . './include/state.func.php';
     rest($command);
     //		} elseif($mode == 'chgpassword') {
     //			include_once GAME_ROOT.'./include/game/special.func.php';
     //			chgpassword($oldpswd,$newpswd,$newpswd2);
     //		} elseif($mode == 'chgword') {
     //			include_once GAME_ROOT.'./include/game/special.func.php';
     //			chgword($newmotto,$newlastword,$newkillmsg);
 } elseif ($mode == 'corpse') {
     include_once GAME_ROOT . './include/game/itemmain.func.php';
     getcorpse($command);
 } elseif ($mode == 'team') {
     include_once GAME_ROOT . './include/game/team.func.php';
     if ($command == "teammake") {
Exemplo n.º 4
0
function unloadUnit($getPage_connection2)
{
    $validMove = false;
    if ($_SESSION["action_id"] >= 1) {
        $unitInfoW = getUnitInfoByID($getPage_connection2, $_SESSION["action_id"]);
        // is it a valid entity?
        if ($unitInfoW["continent"] == $_SESSION["continent_id"] && $unitInfoW["xpos"] == $_SESSION["xpos"] && $unitInfoW["ypos"] == $_SESSION["ypos"]) {
            // is it owned by current player?
            if ($unitInfoW["owner"] == $_SESSION["nation_id"]) {
                $unitTypeInfoW = getUnitTypeInfo($getPage_connection2, $unitInfoW["type"]);
                if ($unitInfoW["transport"] >= 1) {
                    $transportInfoW = getTransportInfo($getPage_connection2, $unitInfoW["transport"]);
                    if ($transportInfoW["id"] >= 1) {
                        if (count($transportInfoW["list"]) >= 1) {
                            $unitID = $transportInfoW["list"][1];
                            $unitInfoWA = getUnitInfoByID($getPage_connection2, $unitID);
                            $unitTypeInfoWA = getUnitTypeInfo($getPage_connection2, $unitInfoWA["type"]);
                            // does unit have movement left?
                            if ($unitInfoWA["used"] < $unitTypeInfoWA["movement"]) {
                                $tileInfoW = getTileInfo($getPage_connection2, $_SESSION["new_continent"], $_SESSION["new_xpos"], $_SESSION["new_ypos"]);
                                $terrainInfoW = getTerrainInfo($getPage_connection2, $tileInfoW["terrain"]);
                                if ($terrainInfoW["movementRestriction"] >= 1 && $unitInfoWA["used"] < $terrainInfoW["movementRestriction"] || $terrainInfoW["movementRestriction"] == 0) {
                                    // land
                                    if ($unitTypeInfoWA["water"] == 0) {
                                        if ($tileInfoW["terrain"] != 2 && $tileInfoW["terrain"] >= 1) {
                                            if ($_SESSION["new_continent"] == $_SESSION["continent_id"] && ($_SESSION["new_xpos"] >= $_SESSION["xpos"] - 1 && $_SESSION["new_xpos"] <= $_SESSION["xpos"] + 1) && ($_SESSION["new_ypos"] >= $_SESSION["ypos"] - 1 && $_SESSION["new_ypos"] <= $_SESSION["ypos"] + 1)) {
                                                $validMove = true;
                                            }
                                            // if
                                        }
                                        // if
                                        // water
                                    } else {
                                        if ($tileInfoW["terrain"] == 2 && $tileInfoW["terrain"] >= 1) {
                                            if ($_SESSION["new_continent"] >= $_SESSION["continent_id"] - 1 && $_SESSION["new_continent"] <= $_SESSION["continent_id"] + 1 && ($_SESSION["new_xpos"] >= $_SESSION["xpos"] - 1 && $_SESSION["new_xpos"] <= $_SESSION["xpos"] + 1) && ($_SESSION["new_ypos"] >= $_SESSION["ypos"] - 1 && $_SESSION["new_ypos"] <= $_SESSION["ypos"] + 1)) {
                                                $validMove = true;
                                            }
                                            // if
                                        }
                                        // if
                                    }
                                    // else
                                    // move is valid, move on to processing
                                    if ($validMove === true) {
                                        $unitInfoC = getUnitInfo($getPage_connection2, $_SESSION["new_continent"], $_SESSION["new_xpos"], $_SESSION["new_ypos"]);
                                        $unitTypeInfoC = getUnitTypeInfo($getPage_connection2, $unitInfoC["type"]);
                                        // if enemy unit is found on destination tile, there is conflict!
                                        if ($unitInfoC["id"] >= 1 && $unitInfoC["owner"] != $_SESSION["nation_id"]) {
                                            // land units can only attack other land units, water units can attack both, with the exception of artillery which can attack water units as well
                                            if ($unitTypeInfoWA["water"] == 0 && $unitTypeInfoC["water"] != 1 || $unitTypeInfoWA["water"] == 0 && $unitTypeInfoC["water"] == 1 && $unitInfoWA["type"] == 4 || $unitTypeInfoWA["water"] == 1) {
                                                combat($getPage_connection2, $_SESSION["new_continent"], $_SESSION["new_xpos"], $_SESSION["new_ypos"], $unitInfoWA, $unitInfoC, 1);
                                            } else {
                                                $_SESSION["warning_message"] = "Cannot complete action: unit cannot attack specified unit.";
                                            }
                                            // else
                                            // if friendly unit is found on destination tile, current unit does not move
                                        } else {
                                            if ($unitInfoC["id"] >= 1 && $unitInfoC["owner"] == $_SESSION["nation_id"]) {
                                                $_SESSION["warning_message"] = "Cannot complete action: unit cannot move into another friendly unit's territory.";
                                                // else move as normal
                                            } else {
                                                $new_used = $unitInfoWA["used"] + 1;
                                                $_SESSION["success_message"] = "Player's unit " . $unitInfoWA["name"] . " has been moved successfully!";
                                                // set new transport list
                                                $new_transport_list = array(0 => 0);
                                                $counterB = 0;
                                                for ($b = 0; $b < count($transportInfoW); $b++) {
                                                    if ($b != 1) {
                                                        $new_transport_list[$counterB] = $transportInfoW["list"][$b];
                                                        $counterB++;
                                                    }
                                                    // if
                                                }
                                                // for
                                                setTransportInfo($getPage_connection2, $unitInfoW["transport"], $new_transport_list);
                                                setUnitInfo($getPage_connection2, $unitInfoWA["id"], $_SESSION["new_continent"], $_SESSION["new_xpos"], $_SESSION["new_ypos"], $unitInfoWA["health"], $new_used, $unitInfoWA["name"], $unitInfoWA["type"], $unitInfoWA["owner"], $unitInfoWA["level"], $unitInfoWA["transport"], $unitInfoW["created"], $unitInfoW["exp"]);
                                            }
                                        }
                                        // else
                                    } else {
                                        $_SESSION["warning_message"] = "Cannot complete action: unit cannot move to specified tile.";
                                    }
                                    // else
                                } else {
                                    $_SESSION["warning_message"] = "Cannot complete action: unit does not have the required movement available for terrain type.";
                                }
                                // else
                            } else {
                                $_SESSION["warning_message"] = "Cannot complete action: unit does not have enough movement.";
                            }
                            // else
                        } else {
                            $_SESSION["warning_message"] = "Cannot complete action: transport is not available.";
                        }
                        // else
                    } else {
                        $_SESSION["warning_message"] = "Cannot complete action: transport is not available.";
                    }
                    // else
                } else {
                    $_SESSION["warning_message"] = "Cannot complete action: transport is not available.";
                }
                // else
            } else {
                $_SESSION["warning_message"] = "Cannot complete action: unit is not owned by current player.";
            }
            // else
        } else {
            $_SESSION["warning_message"] = "Cannot complete action: unit is not valid.";
        }
        // else
    } else {
        $_SESSION["warning_message"] = "Cannot complete action: unit is not valid.";
    }
    // else
}
Exemplo n.º 5
0
function main()
{
    $nick = getNickFromArgs();
    $mapData = null;
    $charData = null;
    // This will force everyone into creating a Dynasty save.
    // We patching shit, yo.
    $dynPatch = false;
    $dynPath = getSaveFilePath($nick, SaveFileType::Dynasty);
    if (!file_exists($dynPath)) {
        saveGame($nick, SaveFileType::Dynasty);
        $dynPatch = true;
    }
    if (!checkIfNewGame($nick)) {
        // Load character save data.
        $charFilePath = getSaveFilePath($nick, SaveFileType::Character);
        $charData = FileIO::UnserializeFile($charFilePath);
        $charDataDirty = false;
        // Load map save data.
        $mapFilePath = getSaveFilePath($nick, SaveFileType::Map);
        $mapData = FileIO::UnserializeFile($mapFilePath);
        $mapDataDirty = false;
        // Load dynasty save data.
        $dynFilePath = getSaveFilePath($nick, SaveFileType::Dynasty);
        $dynData = FileIO::UnserializeFile($dynFilePath);
        $dynDataDirty = false;
        // Put everyone into the dynasty initialisation state, just this once.
        //$notYetPatched	= !isset($charData->patched);
        $notYetPatched = !isset($dynData->initialised);
        $notPatching = $charData->state != GameStates::DynastyInit;
        if (empty($dynData) || $notYetPatched && $notPatching) {
            $charData->patchState = $charData->state;
            $charData->patchPrevState = $charData->previousState;
            DEBUG_echo("Patching in Dynasty...");
            StateManager::ChangeState($charData, GameStates::DynastySplash);
        }
        // Patch the stat changes in.
        doStatPatchIfNeeded($charData);
        // Ensure it's sane.
        if (empty($charData) || empty($mapData)) {
            echo "ERROR: Save data's f****d.\n";
            exit(3);
        }
        // Read STDIN for input.
        $input = readStdin();
        switch ($charData->state) {
            case GameStates::DynastySplash:
                DEBUG_echo("DynastySplash");
                echo "Your Dynasty begins, and needs a name. Choose your name wisely - you cannot alter history.\n";
                StateManager::ChangeState($charData, GameStates::DynastyInit);
                $dynData->initialised = true;
                $charDataDirty = true;
                $dynDataDirty = true;
                break;
            case GameStates::DynastyInit:
                DEBUG_echo("DynastyInit");
                // Validate input.
                $validName = preg_match("/^[a-zA-Z]{1,16}\$/", $input, $output);
                if (!$validName) {
                    echo "Please enter a valid name. Letters only, between 1 and 16 characters.\n";
                    return;
                }
                $dynData->name = $input;
                $output = "The Dynasty of {$input} begins! Onwards, to adventure!";
                echo "{$output}\n";
                // Hook back up to where we were.
                $charData->state = $charData->patchState;
                $charData->previousState = $charData->patchPrevState;
                $charDataDirty = true;
                $dynDataDirty = true;
                break;
            case GameStates::NameSelect:
                DEBUG_echo("NameSelect");
                $validName = preg_match("/^[a-zA-Z]{1,16}\$/", $input, $output);
                if (!$validName) {
                    echo "Please enter a valid name. Letters only, between 1 and 16 characters.\n";
                    exit(13);
                }
                $output = "Please choose a class for {$input} {$dynData->name}: ";
                global $classSelect;
                foreach ($classSelect->commands as $fragment) {
                    $output .= "{$fragment->displayString}, ";
                }
                $output = rtrim($output, ", ") . "\n";
                echo $output;
                $charData->name = $input;
                StateManager::ChangeState($charData, GameStates::ClassSelect);
                $charDataDirty = true;
                break;
            case GameStates::ClassSelect:
                DEBUG_echo("ClassSelect");
                $input = strtolower($input);
                $setClass = classSelect($input, $charData, $dynData, $charData->name);
                if ($setClass) {
                    StateManager::ChangeState($charData, GameStates::FirstPlay);
                    $charDataDirty = true;
                }
                break;
                // Initialise the characters
            // Initialise the characters
            case GameStates::FirstPlay:
                DEBUG_echo("FirstPlay");
                firstPlay($charData, $dynData);
                StateManager::ChangeState($charData, GameStates::Adventuring);
                // purposeful fall-through!
                // The main loop for when we're romping around.
            // purposeful fall-through!
            // The main loop for when we're romping around.
            case GameStates::Adventuring:
                DEBUG_echo("Adventuring");
                adventuring($input, $charData, $mapData, $dynData);
                $charDataDirty = true;
                $mapDataDirty = true;
                break;
                // Sleepy nap time.
            // Sleepy nap time.
            case GameStates::Resting:
                DEBUG_echo("Resting");
                resting($input, $charData, $mapData);
                $charDataDirty = true;
                break;
                // IT'S CLOBBERING TIME
            // IT'S CLOBBERING TIME
            case GameStates::Combat:
                DEBUG_echo("Combat");
                combat($input, $charData, $mapData, $dynData);
                $charDataDirty = true;
                $mapDataDirty = true;
                break;
            case GameStates::Spellcasting:
                DEBUG_echo("Spellcasting");
                $nonCombat = isset($charData->previousState) && $charData->previousState != GameStates::Combat;
                spellcasting($input, $charData, $mapData, $nonCombat);
                $charDataDirty = true;
                $mapDataDirty = true;
                break;
            case GameStates::Looting:
                DEBUG_echo("Looting");
                looting($input, $charData, $mapData);
                $charDataDirty = true;
                $mapDataDirty = true;
                break;
            case GameStates::LevelUp:
                DEBUG_echo("LevelUp");
                levelUp($input, $charData, $mapData);
                $charDataDirty = true;
                break;
            case GameStates::UsingItem:
                DEBUG_echo("UsingItem");
                $nonCombat = isset($charData->previousState) && $charData->previousState != GameStates::Combat;
                usingItem($input, $charData, $mapData, $nonCombat);
                $charDataDirty = true;
                break;
            case GameStates::Shopping:
                DEBUG_echo("Shopping");
                shopping($input, $charData, $mapData);
                $charDataDirty = true;
                $mapDataDirty = true;
                break;
            case GameStates::Dynasty:
                DEBUG_echo("Dynasty");
                dynasty($input, $charData, $mapData, $dynData);
                $charDataDirty = true;
                $dynDataDirty = true;
                break;
            default:
                break;
        }
    } else {
        // Initialise the character save.
        saveGame($nick, SaveFileType::Character);
        // Initialise the map save.
        saveGame($nick, SaveFileType::Map);
        // Prompt for name/dynasty select.
        if (!$dynPatch) {
            echo "How do you want to alter your Dynasty?\n";
        } else {
            echo "Welcome to blaventure!\n";
        }
    }
    if (isset($charData) && $charDataDirty) {
        saveGame($nick, SaveFileType::Character, $charData);
    }
    if (isset($mapData) && $mapDataDirty) {
        saveGame($nick, SaveFileType::Map, $mapData);
    }
    if (isset($dynData) && $dynDataDirty) {
        saveGame($nick, SaveFileType::Dynasty, $dynData);
    }
}
Exemplo n.º 6
0
function discover($schmode = 0)
{
    global $log, $mode, $command, $cmd, $event_obbs, $weather, $pls, $club, $pose, $tactic, $inf, $item_obbs, $enemy_obbs, $active_obbs;
    $event_dice = rand(0, 99);
    if ($event_dice < $event_obbs) {
        include_once GAME_ROOT . './include/game/event.func.php';
        event();
        $mode = 'command';
        return;
    }
    include_once GAME_ROOT . './include/game/attr.func.php';
    $mode_dice = rand(0, 99);
    if ($mode_dice < $schmode) {
        global $db, $tablepre, $pid, $corpse_obbs, $teamID, $fog, $gamestate, $bid;
        if ($gamestate < 40) {
            $result = $db->query("SELECT * FROM {$tablepre}players WHERE pls='{$pls}' AND pid!='{$pid}' AND pid!='{$bid}'");
        } else {
            $result = $db->query("SELECT * FROM {$tablepre}players WHERE pls='{$pls}' AND pid!='{$pid}'");
        }
        if (!$db->num_rows($result)) {
            $log .= '这里似乎已经没有人在了。<br>';
            $mode = 'command';
            return;
        }
        $enemynum = $db->num_rows($result);
        $enemyarray = range(0, $enemynum - 1);
        shuffle($enemyarray);
        $find_r = get_find_r($weather, $pls, $pose, $tactic, $club, $inf);
        $find_obbs = $enemy_obbs + $find_r;
        foreach ($enemyarray as $enum) {
            $db->data_seek($result, $enum);
            $edata = $db->fetch_array($result);
            if ($edata['hp'] > 0) {
                $hide_r = get_hide_r($weather, $pls, $edata['pose'], $edata['tactic'], $edata['club'], $edata['inf']);
                $enemy_dice = rand(0, 99);
                if ($enemy_dice < $find_obbs - $hide_r) {
                    if ($teamID && !$fog && $teamID == $edata['teamID']) {
                        include_once GAME_ROOT . './include/game/battle.func.php';
                        findteam($edata);
                        return;
                    } else {
                        $active_r = get_active_r($weather, $pls, $pose, $tactic, $club, $inf);
                        $active_dice = rand(0, 99);
                        if ($active_dice < $active_obbs + $active_r) {
                            include_once GAME_ROOT . './include/game/battle.func.php';
                            findenemy($edata);
                            return;
                        } else {
                            include_once GAME_ROOT . './include/game/combat.func.php';
                            combat($edata, 0);
                            return;
                        }
                    }
                }
            } else {
                $corpse_dice = rand(0, 99);
                if ($corpse_dice < $corpse_obbs) {
                    if ($gamestate < 40 && ($edata['weps'] && $edata['wepe'] || $edata['arbs'] && $edata['arbe'] || $edata['arhs'] || $edata['aras'] || $edata['arfs'] || $edata['arts'] || $edata['itms0'] || $edata['itms1'] || $edata['itms2'] || $edata['itms3'] || $edata['itms4'] || $edata['itms5'] || $edata['money'])) {
                        include_once GAME_ROOT . './include/game/battle.func.php';
                        findcorpse($edata);
                        return;
                    } else {
                        discover(50);
                        return;
                    }
                }
            }
        }
        $log .= '似乎有什么人潜藏着┅┅士兵吗?<br>';
        $mode = 'command';
        return;
    } else {
        $find_r = get_find_r($weather, $pls, $pose, $tactic, $club, $inf);
        $find_obbs = $item_obbs + $find_r;
        $item_dice = rand(0, 99);
        if ($item_dice < $find_obbs) {
            $mapfile = GAME_ROOT . "./gamedata/mapitem/{$pls}mapitem.php";
            $mapitem = openfile($mapfile);
            $itemnum = sizeof($mapitem) - 1;
            if ($itemnum <= 0) {
                $log .= "这里似乎什么都没有了。<br>";
                $mode = 'command';
                return;
            }
            $itemno = rand(1, $itemnum);
            global $itm0, $itmk0, $itme0, $itms0, $itmsk0;
            list($itm0, $itmk0, $itme0, $itms0, $itmsk0) = explode(',', $mapitem[$itemno]);
            array_splice($mapitem, $itemno, 1);
            writeover($mapfile, implode('', $mapitem), 'wb');
            unset($mapitem);
            if ($itms0) {
                include_once GAME_ROOT . './include/game/itemmain.func.php';
                itemfind();
                return;
            } else {
                $log .= "但是什么都没有发现。<br>";
            }
        } else {
            $log .= "但是什么都没有发现。<br>";
        }
    }
    $mode = 'command';
    return;
}