View file wapirate/xhtml/monster.php

File size: 32.19Kb
<?php



include("head.php");

    $player=getnick_sid($sid);

    $userstats="SELECT * from ibwf_users where name='$player'";

    $userstats2=mysql_query($userstats) or die("Could not get user stats");

    $userstats3=mysql_fetch_array($userstats2);

addonline(getuid_sid($sid),"Pirate Challange","");

    

////////////////////////////////////////MAIN PAGE

if($action=="main")

{

 echo "<div><br/>Pirate Challange<br/></div>";

    if($userstats3[dead]=='Yes')

    {

	    echo "<p>";

      echo "You Have Been Killed By $userstats3[killer]<br/>Costs 10 Gold To Revive</p>";

      echo "<form action='monster.php?action=revive' method='post'>";

      echo "<p><input type='hidden' name='ID' value='$userstats3[id]'/>";

      echo "<input type='submit' name='revives' value='revive'/></p></form>";

    }

    else

    {

     $update = "update ibwf_users set numturns=20 where id='$userstats3[id]'";

      $updaterefresh="update ibwf_users set justattacked=0 where id='$userstats3[id]'";

//mysql_query($update);

      mysql_query($updaterefresh) or die("Died");

    echo "<p align=\"center\">";

      echo "<b>Welcome Pirate, $player. </b><br/>So You Have Come To Sail The Seven Sea`s<br/>Buy Pirate Crew And Defeat Sea Monsters And Become The Almighty Pirate!<br/></p>";

      echo "<p><b><u>Your Stats</u></b><br/>";

      //echo "<i>You have $userstats3[numturns] Turns<br/>";

      echo "Your Skill pts: $userstats3[numturns]<br/>";

      echo "Your Honor: $userstats3[honor]<br/>";

      echo "Your Gold: $userstats3[plusses]<br/>";

      echo "Your Ships: $userstats3[land]<br/>";

      echo "Your Offensive Crew: $userstats3[offarmy]<br/>";

      echo "Your Defensive Crew: $userstats3[dffarmy]<br/>";

      echo "Crew Training Pts: $userstats3[science]</i></p>";



      echo "<p><b><u><a href=\"monster.php?action=ranks\">[*] Ranks and Rules</a></u></b></p>";

      echo "<p><b><u><a href=\"monster.php?action=ships\">[*] Buy Ships</a></u></b></p>";

      echo "<p><b><u><a href=\"monster.php?action=crew\">[*] Buy Crew</a></u></b></p>";

      echo "<p><b><u><a href=\"monster.php?action=bsci\">[*] Buy Crew Training Pts</a></u></b></p>";

       

      $monster1="SELECT * from km_monsters order by skill asc";

      $monster2=mysql_query($monster1) or die("Could not select Monster");

      $monsternum=mysql_num_rows($monster2);

      if($monsternum>0)

      {

      echo "<p>Sea Monsters Are Listed In Order Of Increasing Difficulty.<br/><b><u>Select Monster To Slay</u></b><br/>";

     

      echo "</p><form action='monster.php?action=slaymonster' method='post'>";

      echo "<p><select name='monstername'>";

      

      while ($monster3=mysql_fetch_array($monster2))

      {

        echo "<option>$monster3[name]</option>";

      }

      echo "</select><br/>";

      echo "<input type='submit' name='submit' value='Kill Monster'/></p></form>";

 	  }

      echo "<p><b><u>Select Player To Challenge</u></b><br/>";

      echo "Type The Name Of The Pirate You Wish To Challenge:</p>";

      echo "<form action='monster.php?action=challengeplayer' method='post'>";

      echo "<p><input type='text' name='playerID' size='20'/><br/>";

      echo "<input type='submit' name='submit2' value='Challenge'/></p></form>";

      

      echo "<p><b><u>Select Pirate's Ships to attack</u></b><br/>";

      echo "Type The Name Of The Pirate Whose Ships You Wish To Attack:</p>";

      echo "<form action='monster.php?action=attack' method='post'>";

      echo "<p><input type='text' name='victimid' size='20'/><br/>";

      echo "<input type='submit' name='submit' value='Attack'/></p></form>";

      

      if($userstats3[numberattck]>0)

      {

	    echo "<p><b><u>Attacked!!</u></b><br/>";

        echo "<font color='red'>You have Survived $userstats3[numberattck] Attacks Since Your Last Visit.</font><br><br>";

        $resets="update ibwf_users set numberattck='0' where name='$player'";

        mysql_query($resets) or die("could not query");

        echo "</p>";

      }

      $getbattlerecords="SELECT * from km_battlerecords where victimid='$userstats3[id]'";

      $getbattlerecords2=mysql_query($getbattlerecords) or die("Could not get battlerecords");

      $battles=mysql_num_rows($getbattlerecords2);

      if($battles>0)

      {

      echo "<p><b><u>Battle Records Since Last Visit</u></b><br/>";



      while($getbattlerecords3=mysql_fetch_array($getbattlerecords2))

      {

         echo "Attacker ID: $getbattlerecords3[attid]<br/>";

         echo "Attacker Name: $getbattlerecords3[attname]<br/>";

         echo "Result: $getbattlerecords3[result]<br/>";

         echo "Ships Lost: $getbattlerecords3[landlost]<br/><br/>";

      }

      echo "</p>";

      $delrecords="DELETE from km_battlerecords where victimid='$userstats3[id]'";

      mysql_query($delrecords) or die("Could not delete battle records");

		}

	} 

    echo "<p align=\"center\">";

echo getfoot($sid,$folder);

exit(); 

}



//////////////////////////////////////////////////////

/* Ranks Coding */

else if($action=="ranks")

{

 echo "<div><br/>Ranks And Rules!<br/></div>";

 echo "<p>";

 echo "<b><u>Ranks And Rules</u></b><br/><br/>";

 echo "<a href='monster.php?action=top&amp;top=top'>Pirates By Rank</a><br/>";

 echo "<a href='monster.php?action=playerclose'>Pirates Close To You</a><br/>";

 echo "<a href='monster.php?action=top&amp;top=honor'>Pirates By Honor</a><br/>";

 echo "<a href='monster.php?action=top&amp;top=ships'>Largest Pirate Colony</a><br/>";

 echo "<a href='monster.php?action=challengeinfo'>Rules For Challenging Other Pirates</a>";

 echo "</p>"; 

    echo "<p align=\"center\">";

     echo "<a href=\"monster.php?action=main\">Back To Menu</a><br/>";



echo getfoot($sid,$folder);

exit(); 

}

//////////////////////////////////////////////////////////////

else if($action=="top")

{

$top = $_GET["top"];

if($top=="top"){

 echo "<div><br/>Top Pirates!<br/></div>";

}else if($top=="honor"){

echo "<div><br/>Top Honor!<br/></div>";

}else{

echo "<div><br/>Most Ships!<br/></div>";

}

    //////ALL LISTS SCRIPT <<

       echo "<p align=\"center\">";

   echo getinbox($sid,"monster*main","Pirate Challange");

    //echo "</p>";



    if($page=="" || $page<=0)$page=1;

    $noi = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_users"));

    $num_items = $noi[0]; //changable

    $items_per_page= 10;

    $num_pages = ceil($num_items/$items_per_page);

    if(($page>$num_pages)&&$page!=1)$page= $num_pages;

    $limit_start = ($page-1)*$items_per_page;



if($top=="top"){

$sql = "SELECT id, name, numturns, dead FROM ibwf_users ORDER BY numturns DESC LIMIT $limit_start, $items_per_page";

$hmm = "Skill Points";

}else if($top=="honor"){

$sql = "SELECT id, name, honor, dead FROM ibwf_users ORDER BY honor DESC LIMIT $limit_start, $items_per_page";

$hmm = "Honor";

}else{

$sql = "SELECT id, name, land, dead FROM ibwf_users ORDER BY land DESC LIMIT $limit_start, $items_per_page";

$hmm = "Ships";

}

        



    //echo "<p>";

    $items = mysql_query($sql);

    echo mysql_error();

    if(mysql_num_rows($items)>0)

    {

    while ($item = mysql_fetch_array($items))

    {



    echo "Pirate Name: <a href=\"index.php?action=viewuser&amp;who=$item[0]\">$item[1]</a><br/>";

    echo "$hmm: $item[2]<br/>";

if($item[3]==""){

$item[3]= "no";

}

    echo "Dead? $item[3]<br/><br/>";



    }

    }

    echo "</p>";

    echo "<p align=\"center\">";

    if($page>1)

    {

      $ppage = $page-1;

      echo "<a href=\"monster.php?action=$action&amp;page=$ppage&amp;top=$top\">&#171;PREV</a> ";

    }

    if($page<$num_pages)

    {

      $npage = $page+1;

      echo "<a href=\"monster.php?action=$action&amp;page=$npage&amp;top=$top\">Next&#187;</a>";

    }

    echo "<br/>$page/$num_pages<br/>";

    echo "</p>";

    if($num_pages>2)

    {

      $rets = "<center><form action=\"monster.php\" method=\"get\">";

      $rets .= "<input name=\"page\" style=\"-wap-input-format: '*N'\" size=\"2\"/>";

      $rets .= "<input type=\"hidden\" name=\"action\" value=\"$action\">";

      $rets .= "<input type=\"hidden\" name=\"top\" value=\"$top\">";

      $rets .= "<input type=\"hidden\" name=\"sid\" value=\"$sid\">";

      $rets .= "<input type=\"hidden\" name=\"who\" value=\"$who\">";

      $rets .= "<input type=\"Submit\" name=\"Submit\" Value=\"Go To Page\"></form></center>";

      echo $rets;

    }



  ////// UNTILL HERE >>

    echo "<p align=\"center\">";

echo "<a href=\"monster.php?action=main\">Back To Menu</a><br/>";

echo getfoot($sid,$folder);

exit(); 

}



/////////////////////////////////////////////////////

else if($action=="playerclose")

{

 echo "<div><br/>Pirates Close To You<br/></div>";

 echo "<p align=\"center\">";

 $player=getnick_sid($sid);

  $getplayerpoints="SELECT * from ibwf_users where name='$player'";

  $getplayerpoints2=mysql_query($getplayerpoints) or die("Could not get player points");

  $getplayerpoints3=mysql_fetch_array($getplayerpoints2);

  $numrows="SELECT * from ibwf_users where numturns>='$getplayerpoints3[gplus]'";

  $numrows2=mysql_query($numrows) or die("Could not grab rows");

  $numrows3=mysql_num_rows($numrows2);

  $total="SELECT * from ibwf_users";

  $total2=mysql_query($total) or die("Could not get users");

  $total3=mysql_num_rows($total2);

  $numrows4=$numrows3+10;

  if($numrows4>=$total3)

  {

    $numrows4=$total3;

  }

  $numrows5=$numrows3-10;

  if($numrows5<0)

  {

    $numrows5=0;

  }

  echo "Pirates Close To You In Rank, Your Name Is In Red<br/>";

  $getrank="SELECT * from ibwf_users order by numturns desc limit $numrows5,$numrows4";

  $getrank2=mysql_query($getrank) or die("Could not fetch ranks");

  while($getrank3=mysql_fetch_array($getrank2))

  {

$dead = "$getrank3[dead]";

if($dead==""){

$dead = "no";

}

    if($getplayerpoints3[id]==$getrank3[id])

    {

      echo "<font color=\"red\">Pirate Name : <a href=\"index.php?action=viewuser&amp;who=$getrank3[id]\">".getnick_uid($getrank3['id'])."</a></font><br/>";

      echo "<font color='red'>Skill Points : $getrank3[numturns]</font><br/>";

      echo "<font color='red'>Dead? $dead</font><br/><br/>";

    }

    else

    {

      echo "Pirate Name : <a href=\"index.php?action=viewuser&amp;who=$getrank3[id]\">".getnick_uid($getrank3['id'])."</a><br/>";

      echo "Skill Points : $getrank3[numturns]<br/>";

      echo "Dead? $dead<br/><br/>";

    }

  }



 echo "</p>"; 

echo "<p align=\"center\">";

     echo "<a href=\"monster.php?action=main\">Back To Game Menu</a><br/>";

echo getfoot($sid,$folder);

exit(); 

}



////////////////////////////////////////////////////////

else if($action=="challengeinfo")

{

echo "<div><br/>Challenge Info<br/></div>";

 echo "<p align=\"center\">";

echo "This Is How Challenging Other Pirates works. If You Win, You Gain 1/10 Of The Other Pirate's Skillpoints<br/>";

echo "(So It Makes No Sense To Challenge Someone With Less Than 10 Skillpoints)<br/>";

echo "And The Other Pirate Dies And Loses 1/10 Of His Skill Pts And Has To Revive.<br/>";

echo "You Will Also Recieve 20 Gold Off Of The Other Pirate<br/>Reviving Costs 10 Gold<br/>You Can Win/Lose Differnt Ammounts While Fighting Monsters Depending On There Difficulty<br/>";

 echo "</p>"; 

echo "<p align=\"center\">";

     echo "<a href=\"monster.php?action=main\">Back To Menu</a><br/>";

echo getfoot($sid,$folder);

exit(); 

}

/* End Ranks Section */



//////////////////////////////////////////////////////

/* Buy Land Code */

else if($action=="ships")

{

echo "<div><br/>Buy Ships<br/></div>";

 echo "Ship Costs $500 </p>";

 echo "<form action='monster.php?action=buyships&amp;id=$userstats3[id]' method='post'>";

 echo "<p>Ships To Buy:&nbsp;<input type='text' name='ships' size='6'/>&nbsp;";

 echo "<input type='submit' name='submit' value='buy'/></p></form>";

 echo "<p align=\"center\">";

     echo "<a href=\"monster.php?action=main\">Back To Menu</a><br/>";

echo getfoot($sid,$folder);

exit(); 

}



else if($action=="buyships")

{



echo "<div><br/>Buy Ships<br/></div>";

echo "<p align=\"center\">";

 $player=getnick_sid($sid);

    $userstats="SELECT * from ibwf_users where name='$player'";

    $userstats2=mysql_query($userstats) or die("Could not get user stats");

    $userstats3=mysql_fetch_array($userstats2);

    if(isset($_POST['submit']))

    {

       $ships=$_POST['ships'];

       $ships=strip_tags($ships);

       $total=$ships*500;

       if($ships<1)

       {

          echo "You Cannot Buy $ships Ships.<br/>";

       }

       else if($userstats3[gold]<$total)

       {

          echo "You Do Not Have Enough Gold To Buy That Many Ships.<br/>";

       }

       else if($userstats3[gold]>=$total)

       {



          $getland="update ibwf_users set gold=gold-'$total', land=land+'$ships' where id='$userstats3[id]'";

          mysql_query($getland) or die("Could not buy land");

          echo "You bought $ships Ships.<br/>";

       }

   }

     echo "</p>";       

echo "<p align=\"center\">";

     echo "<a href=\"monster.php?action=main\">Back To Menu</a><br/>";

echo getfoot($sid,$folder);

exit(); 

}

/* End Buy Land Code */

/////////////////////////////////////////////////////

/* Buy Army Code */

else if($action=="crew")

{

echo "<div><br/>Buy Crew<br/></div>";

echo "<p>";

echo "Each Crew Member Costs 75 Gold and each Ship Can Support a Max Of Ten Crew Members:</p>";

      echo "<form action='monster.php?action=buycrew&amp;id=$userstats3[id]' method='post'>";

      echo "<p>Offensive Crew:&nbsp;<input type='text' name='off' size='6'/><br/>";

      echo "Defensive Crew:&nbsp;<input type='text' name='dff' size='6'/><br/>";

      echo "<input type='submit' name='submit' value='Buy Army'/></p></form>";



 echo "<p align=\"center\">";

     echo "<a href=\"monster.php?action=main\"><img src=\"images/roll.gif\" alt=\"*\"/>";

echo "Back To Game Menu</a><br/>";

echo getfoot($sid,$folder);

exit(); 

}

///////////////////////////////////////////////////here

else if($action=="buycrew")

{

   



echo "<div><br/>Buy Crew<br/></div>";

echo "<p align=\"center\">";



    $player=getnick_sid($sid);

    $userstats="SELECT * from ibwf_users where name='$player'";

    $userstats2=mysql_query($userstats) or die("Could not get user stats");

    $userstats3=mysql_fetch_array($userstats2);

    if(isset($_POST['submit']))

    {

        $off=$_POST['off'];          

        $dff=$_POST['dff'];

        $off=strip_tags($off);

        $dff=strip_tags($dff);

        $totalcost=($off+$dff)*75;

        $totalunits=$off+$dff+$userstats3[offarmy]+$userstats3[dffarmy];

        $landhold=$userstats3[land]*10;

        $threshold=date("U")-3600*6;    

        $thetime=date("U");  

        if($off<1&&$dff<1)

        {

echo "<img src=\"images/notok.gif\" alt=\"x\"/><br/>";

           echo "You May Not Buy 0 Crew<br/>";

        }

        else if($totalcost>$userstats3[gold])

        {

echo "<img src=\"images/notok.gif\" alt=\"x\"/><br/>";

          echo "You Do Not Have $totalcost Gold<br/>";

        }

        else if($totalunits>$landhold)

        {

echo "<img src=\"images/notok.gif\" alt=\"x\"/><br/>";

          echo "You Do Not Have Enough Ships To Support That Many Crew<br/>";

        }

        else if($userstats3[lastaction]>$threshold)

        {

echo "<img src=\"images/notok.gif\" alt=\"x\"/><br/>";

          echo "You Have To Wait Six Hours After An Attack To Buy Crew<br/>";

        }

        else if($totalunits<=$landhold)

        {

           $getarmy="UPDATE ibwf_users SET gold=gold-'$totalcost', offarmy=offarmy+'$off', dffarmy=dffarmy+'$dff' WHERE id='$userstats3[id]'";

           mysql_query($getarmy) or die("Can't get Crew");

echo "<img src=\"images/ok.gif\" alt=\"O\"/><br/>";

           echo "Crew Aquired.";

        }



    }

echo "</p>";

 echo "<p align=\"center\">";

     echo "<a href=\"monster.php?action=main\">Back To Menu</a><br/>";

echo getfoot($sid,$folder);

exit(); 

}

/* End army Code */

/////////////////////////////////////////////////////////////

/* Buy Army Training Points Code start */

else if($action=="bsci")

{

echo "<div><br/>Buy Crew Training Points<br/></div>";

echo "<p align=\"center\">";

echo "Each Training point Cost 35 Gold.<br/>";

      $max=$userstats3[land]*10;

      if($userstats3[land]<=0)

      {

         echo "Training Points Not Applicable Due To Lack Of Ships.<br/>";

      }

      else

      {

        $percent=$userstats3[science]/$max*100;

        echo "You have: $userstats3[science] Pts($percent %)<br/>";

      }

      echo "</p><form action='monster.php?action=buyscience&amp;id=$user3stats[id]' method='post'>";

      echo "<p><input type='text' name='scipts' size='6'/><br/>";

      echo "<input type='submit' name='submit' value='submit'/></p></form>";



 echo "<p align=\"center\">";

     echo "<a href=\"monster.php?action=main\"><img src=\"images/roll.gif\" alt=\"*\"/>";

echo "Back To Game Menu</a><br/>";

echo getfoot($sid,$folder);

exit(); 

}

/////////////////////////////////////////////

else if($action=="buyscience")

{



echo "<div><br/>Buy Crew Training Points<br/></div>";

echo "<p align=\"center\">";

    $player=getnick_sid($sid);

    $userstats="SELECT * from ibwf_users where name='$player'";

    $userstats2=mysql_query($userstats) or die("Could not get user stats");

    $userstats3=mysql_fetch_array($userstats2);

    if(isset($_POST['submit']))

    {

         

        $scipts=$_POST['scipts'];

        $scipts=strip_tags($scipts);

        $totalcost=$scipts*35; 

        if($scipts<1)

        {

echo "<img src=\"images/notok.gif\" alt=\"x\"/><br/>";

           echo "You Cannot Buy $scipts Training Pts.<br/>";

        }

        else if($totalcost>$userstats3[gold])

        {

echo "<img src=\"images/notok.gif\" alt=\"x\"/><br/>";

           echo "You Do Not Have Enough Gold.<br/>";

        }

        else if($totalcost<=$userstats3[gold])

        {

            $updatestats="UPDATE ibwf_users SET science=science+'$scipts', gold=gold-'$totalcost'  WHERE id='$userstats3[id]'";

            mysql_query($updatestats) or die("Could not update stats");

echo "<img src=\"images/ok.gif\" alt=\"O\"/><br/>";

            echo "You Have Bought $scipts Traing Points.<br/>";





        }

    }

	echo "</p>";

 echo "<p align=\"center\">";

     echo "<a href=\"monster.php?action=main\">Back To Menu</a><br/>";

echo getfoot($sid,$folder);

exit(); 

}

/* End Buy Army Points Code */

/////////////////////////////////////////////////////////////

/* Slay Monster code */



else if($action=="slaymonster")

{

echo "<div><br/>Slay Monster<br/></div>";

echo "<p align=\"center\">";

 

    if(isset($_POST['submit']))

    {

     $player=getnick_sid($sid);

     $playerstats1="SELECT * from ibwf_users where name='$player'";

     $playerstats2=mysql_query($playerstats1) or die ("Could not find player");

     $playerstats3=mysql_fetch_array($playerstats2);

     //if($playerstats3[numturns]<1)

if($no_string=="nothing")

     {

        echo "You Need At Least 1 Skill To Kill A Monster<br/>";

     }

     else

     {

       if($playerstats3[justattacked]==0)

       {

         $monstername=$_POST['monstername'];

         $monstername=strip_tags($monstername);

         $selmonster="SELECT * from km_monsters where name='$monstername'";

         $selmonster2=mysql_query($selmonster) or die ("Cannot select Monster");

         $selmonster3=mysql_fetch_array($selmonster2);

         if (!$selmonster3)

         {

           echo "There Is Not A Monster Of That Name<br/>";

         }

         else

         {

           $totalskill=$playerstats3[numturns]+$selmonster3[skill];

           $randomnumber=rand(1,$totalskill);

           if($randomnumber<=$playerstats3[numturns])

           {

             $gained=$selmonster3[pointsifkilled];

             $gold=$selmonster3[goldworth];

             $updateplayerstats="Update ibwf_users set numturns=numturns+'$gained', gold=gold+'$gold' where name='$player'";

             mysql_query($updateplayerstats) or die("Could not update player stats");

             echo "<img src='/smilies/yay.gif'/><br/>";

             echo "You Slayed The $selmonster3[name] Monster In Glorius Combat And Gained $gained Skill Points And $gold Gold";

             echo "<br/><br/><A href='monster.php?action=main'>Kill More Monsters</a>";

           }

           else

           {

             $gained=$selmonster3[pointsifkilled];

             $gold=$selmonster3[goldworth];

             $updateplayerstats="Update ibwf_users set numturns=numturns-1, gold=gold-'$gold' where name='$player'";

             mysql_query($updateplayerstats) or die("Could not update player stats");



             echo "<img src='/smilies/evil.gif'/><br/>";

             echo "The $selmonster3[name] Monster Laughs As You Dive Into Your Dingy And Paddle Away As Fast As You Can Like A Chicken<br>You Lost 1 Skill Points And $gold Gold<br>";

             echo "<br/><br/><A href='monster.php?action=main'>Kill More Monsters</a>";

           }



          }

          $updaterefresh="update ibwf_users set justattacked=1, numturns=numturns+1 where id='$playerstats3[id]'";

          mysql_query($updaterefresh) or die("It just died");

       }

       else

       {

echo "<img src=\"images/notok.gif\" alt=\"x\"/><br/>";

         echo "No Refreshing Is Allowed<br/>";

       }

     }

   }

 

 

     echo "</p>";

 echo "<p align=\"center\">";

     echo "<a href=\"monster.php?action=main\">Back To Menu</a><br/>";

echo getfoot($sid,$folder);

exit(); 

}

/* Slay Monster Code End */

//////////////////////////////////////////////////////////////

/* Challenge Player Code Start */



else if($action=="challengeplayer")

{

echo "<div><br/>Challenge Pirate<br/></div>";

echo "<p align=\"center\">";



 

   if(isset($_POST['submit2']))

  {

	$player=getnick_sid($sid);

    $datenow=date("U");

    $datenow=$datenow%100000;

    srand($datenow);

    $yourstats="SELECT * from ibwf_users where name='$player'";

    $yourstats2=mysql_query($yourstats) or die("Could not get your stats");

    $yourstats3=mysql_fetch_array($yourstats2);

    $playername=$_POST['playerID'];

    $playerID=getuid_nick($playername);

    $playerID=strip_tags($playerID);

    $oppstats="SELECT * from ibwf_users where id='$playerID'";

    $oppstats2=mysql_query($oppstats) or die("Could not get opponent's stats");

    $oppstats3=mysql_fetch_array($oppstats2);

    $statst=2*$oppstats3[numturns];

    if($yourstats3[numturns]<2)

    {

echo "<img src=\"images/notok.gif\" alt=\"x\"/><br/>";

       echo "You Need At Least 2 Skill To Challenge Someone Else.<br/>";

    }

    else if($yourstats3[id]===$oppstats3[id])

    {

echo "<img src=\"images/notok.gif\" alt=\"x\"/><br/>";

       echo "You May Not Challenge Yourself<br/>";

    }

    else if($yourstats3[numturns]>=$statst)

    {

echo "<img src=\"images/notok.gif\" alt=\"x\"/><br/>";

       echo "You May Not Kill Pirates Who Have Less Than Half Your Skill Points.<br/>";

    }

    else if(!$oppstats3||$oppstats3[dead]=='Yes')

    {

echo "<img src=\"images/notok.gif\" alt=\"x\"/><br/>";

      echo "There Is No Such Pirate Or The Pirate Is Already Dead<br/>";

    }

    else

    {

      $totalstats=$oppstats3[numturns]+$yourstats3[numturns];

      $randomnumber=rand(1, $totalstats);

      if($randomnumber<=$yourstats3[numturns])

      {

        $ptsgained=$oppstats3[numturns]/10;

        $ptslost=$oppstats3[numturns]/10;

echo "<img src=\"images/ok.gif\" alt=\"O\"/><br/>";

        echo "<b>Congratulations, You have Defeated $oppstats3[name] And Have Gained $ptsgained Skill Points.<br>";

        $updateyourstats="UPDATE ibwf_users SET gold=gold+20, numturns=numturns+'$ptsgained',honor=honor+1 WHERE name='$player'";

        mysql_query($updateyourstats) or die("Could not update your stats");

        $updateopp="UPDATE ibwf_users SET gold=gold-20, numturns=numturns-'$ptslost',dead='Yes',killer='$player',numberattck='0', honor=honor-1 WHERE id='$playerID'";

        mysql_query($updateopp) or die(mysql_error());



      }

      else if($randomnumber>$yourstats3[numturns])

      {

        $ptsgained=$yourstats3[numturns]/10;

        $ptslost=$yourstats3[numturns]/3;

        echo "You Have Lost The Battle And Have Been Killed, You Will Need To Go To The <a href='monster.php?action=main'>Main Menu</a> And Revive Yourself.<br>";

        $killyou="update ibwf_users set gold=gold-20, numturns=numturns-'$ptslost',dead='Yes', killer='$oppstats3[name]', honor=honor-1 where name='$player'";

        mysql_query($killyou) or die("Could not kill you");

        $foestats="update ibwf_users set gold=gold+20, numturns=numturns+'$ptsgained', numberattck=numberattck+'1', honor=honor+1 where id='$playerID'";

        mysql_query($foestats) or die("Could not dishonor you by updating opponent's stats");

      }



   }

  }

 

	echo "</p>";

 echo "<p align=\"center\">";

     echo "<a href=\"monster.php?action=main\">Back To Game Menu</a><br/>";

echo getfoot($sid,$folder);

exit(); 

}



/* End Challenge Player Code */

////////////////////////////////////////////////////////////////////////////////////

/* Start Land Attack Code */



else if($action=="attack")

{

echo "<div><br/>Attack Ships<br/></div>";

echo "<p align=\"center\">";



     $player=getnick_sid($sid);

    $userstats="SELECT * from ibwf_users where name='$player'";

    $userstats2=mysql_query($userstats) or die("Could not get user stats");

    $userstats3=mysql_fetch_array($userstats2);

    $victimid=$_POST['victimid'];

    $victimid=getuid_nick($victimid);

    $victimid=strip_tags($victimid);

    $victimselect="SELECT * from ibwf_users where id='$victimid'";

    $victimselect2=mysql_query($victimselect) or die("Could not select Victim");

    $victimselect3=mysql_fetch_array($victimselect2);

    $minlim=2*$victimselect3[land];

    $thetime=date("U");

    $timelimit=$thetime-3600*6;

    $attacklimit="SELECT COUNT(*) as attname from km_battlerecords where ID='$vicitimselect3[id]'";

    $attacklimit2=mysql_query($attacklimit) or die("Could not get limit");

    $attacklimit3=mysql_result($attacklimit2,0);



    if(isset($_POST['submit']))

    {

      

        if($userstats3[numturns]<3)

        {

echo "<img src=\"images/notok.gif\" alt=\"x\"/><br/>";

           echo "It Takes 3 Skill To Do An Attack On Someone Else's Ship<br/>";

        }

        else if($userstats3[land]>$minlim)

        {

echo "<img src=\"images/notok.gif\" alt=\"x\"/><br/>";

            echo "You Cannot Attack Someone With Less Than Half Your Ships.<br/>";

        }

        else if($userstats3[lastaction]>$timelimit)

        {

echo "<img src=\"images/notok.gif\" alt=\"x\"/><br/>";

            echo "You have  Attacked  Within The Last 6 Hours, You Can Only Take One Of These Actions In Each 6-Hour Period.<br/>";

        }

        else if($userstats3[id]==$victimselect3[id])

        {

echo "<img src=\"images/notok.gif\" alt=\"x\"/><br/>";

            echo "Of Course, You Cannot Attack Yourself<br/>";

        }

        else if($attacklimit3>=5)

        {

echo "<img src=\"images/notok.gif\" alt=\"x\"/><br/>";

            echo "That Person Has Already Been Attacked 5 Times Since There Last Visit,  You May Not Attack Them.<br/>";

        }

        else if($victimselect3[land]<=0)

        {

echo "<img src=\"images/notok.gif\" alt=\"x\"/><br/>";

            echo "You Cannot Attack Someone That Has No Ships<br/>";

        }

        else if($userstats3[land]<1)

        {

echo "<img src=\"images/notok.gif\" alt=\"x\"/><br/>";

          echo "You Cannot Attack Someone If You Have No Ships To Attack From<br/>";

        }

        else

        {

           $updateactions="Update ibwf_users set lastaction='$thetime' where id='$userstats3[id]'";

           mysql_query($updateactions) or die("Could not update actions");

           $attscimod=$userstats3[science]/($userstats3[land]*10)+1;

           $dffscimod=$victimselect3[science]/($victimselect3[land]*10)+1;

           if($userstats3[honor]>50)

           {

               $ahonormod=1.5;

           }

           else if($userstats3[honor]>25)

           {

               $ahonormod=1.3;

           }

           else  if($userstats3[honor]>10)

           {

               $ahonormod=1.1;

           }

           else

           {

               $ahonormod=1;

           }

           if($victimselect3[honor]>50)

           {

               $dhonormod=1.5;

           }

           else if($victimselect3[honor]>25)

           {

               $dhonormod=1.3;

           }

           else if($victimselect3[honor]>10)

           {

               $dhonormod=1.1;

           }

           else

           {

               $dhonormod=1;

           }

           $attstrength=$userstats3[offarmy]*5*$attscimod*$ahonormod;

           $dffstrength=$victimselect3[dffarmy]*5*$dffscimod*$dhonormod;

           $attloss=round($dffstrength/30);

           $dffloss=round($attstrength/40);

           if($attloss>=$userstats3[offarmy])

           {

              $attloss=$userstats3[offarmy];

           }

           if($dffloss>=$victimselect3[dffarmy])

           {

              $dffloss=$victimselect3[dffarmy];

           }

           if($attstrength>$dffstrength)

           {

              $wonland=$victimselect3[land]/10;

              $wonland=round($wonland);

              $battlerecord="INSERT into km_battlerecords (victimid,attid,attname,result,landlost) values('$victimselect3[id]','$userstats3[id]','$userstats3[name]','lost','$wonland')";

              mysql_query($battlerecord) or die("Could not update records");

              $updatestats1="update ibwf_users set offarmy=offarmy-'$attloss', land=land+'$wonland' where id='$userstats3[id]'";

              mysql_query($updatestats1) or die("Could not gain land");

              $updatestats2="update ibwf_users set dffarmy=dffarmy-'$dffloss', land=land-'$wonland' where id='$victimselect3[id]'";

              mysql_query($updatestats2) or die("Could not lose land");

              echo "You have Won The Battle And Killed $dffloss Of The Enemy's Crew While Losing $attloss Crew And Gained $wonland Ships.<br>";

           }

           else

           {

              

              $updatestats1="update ibwf_users set offarmy=offarmy-'$attloss' where id='$userstats3[id]'";

              mysql_query($updatestats1) or die("Could not gain land");

              $updatestats2="update ibwf_users set dffarmy=dffarmy-'$dffloss' where id='$victimselect3[id]'";

              mysql_query($updatestats2) or die(mysql_error());

              $battlerecord="INSERT into km_battlerecords (victimid,attid,attname,result,landlost) values('$victimselect3[id]','$userstats3[id]','$userstats3[playername]','won','0')";

              mysql_query($battlerecord) or die(mysql_error());

              echo "Your Attack Was Unsuccessful And You Lost $attloss Crew While Killing $dffloss Of The Enemys Crew<br>";

           }

          

        }



    }

 

 echo "</p>";

  echo "<p align=\"center\">";

     echo "<a href=\"monster.php?action=main\">Back To Menu</a><br/>";

echo getfoot($sid,$folder);

exit(); 

}

/* End Attack Code */

//////////////////////////////////////////////////////

/* Revive Code Start */



else if($action=="revive")

{

echo "<div><br/>Revive<br/></div>";

echo "<p>";





  if(isset($_POST['revives']))

  { 

     $ID=$_POST['ID']; 

     $rejuv="update ibwf_users set gold=gold-10, dead='no' where id='$uid'";

     mysql_query($rejuv) or die("Could not revive");

  }

 echo "</p>"; 

 echo "<p align=\"center\">";

     echo "<a href=\"monster.php?action=main\">Back To Game Menu</a><br/>";

echo getfoot($sid,$folder);

exit(); 

}



/* End Revive Code */



?>