Return to Home Page    Login    Forum    Register    Search    FAQ

Board index » Risk Forums » Game Suggestions




Post new topic Reply to topic  [ 4 posts ] 
 
Author Message
 Post subject: 2 or 3 defensive rolls
 Post Posted: Sat Oct 31, 2009 8:11 pm 
Offline

Joined: Thu Oct 22, 2009 3:15 pm
Posts: 5
I've modified "func_attack.php" (netrisk 1.9.7) to defend with 2 or 3 rolls a territory, it's based on $_SESSION['game_rolls'] tath have to set in the login page.

this is the code:
Code:
// NOW DO BATTLE
$attackrolls = array(0,0,0);
if($_SESSION['game_rolls'] == 3){
$defendrolls = array(0,0,0);
}else{
$defendrolls = array(0,0);}

// reset Session data
$_SESSION['defend_rolls'] = $defendrolls;
$_SESSION['attack_rolls'] = $attackrolls;

// generate first roll
$defendrolls[0] = mt_rand(1,6);
$attackrolls[0] = mt_rand(1,6);

// generate additional rolls if necessary
if($opposing_armies > 1){
   $defendrolls[1] = mt_rand(1,6); // default defend with 2 which is max if there are 2
    if($opposing_armies > 2 && $_SESSION['game_rolls'] == 3) {
    $defendrolls[2] = mt_rand(1,6); // generate 3rd defensive roll
   }
   }
if($attacking_armies > 1){
   $attackrolls[1] = mt_rand(1,6); // generate 2nd attack roll
   if($attacking_armies > 2)
      $attackrolls[2] = mt_rand(1,6); // generate 3rd attack roll
}

rsort($attackrolls); // sort highest to lowest
rsort($defendrolls);

// Save the die rolls as Session data
$_SESSION['defend_rolls'] = $defendrolls;
$_SESSION['attack_rolls'] = $attackrolls;

$attackcasualties = 0;
$defendcasualties = 0;
if($_SESSION['game_rolls'] == 3){
$fighters = 1; // keeps track of what rolls are fighting, subtract 1 to get at correct array index
while($fighters <= 3 && $fighters <= $opposing_armies && $fighters <= $attacking_armies){ // to keep 0's from engaging // 2 instead of attack armies cause
   if($attackrolls[$fighters-1] > $defendrolls[$fighters-1])   // you cant have 3 fighting ever in Risk
      $defendcasualties -= 1;
   else
      $attackcasualties -= 1;
   $fighters++;
  }
}else{
$fighters = 1; // keeps track of what rolls are fighting, subtract 1 to get at correct array index
while($fighters <= 2 && $fighters <= $opposing_armies && $fighters <= $attacking_armies){ // to keep 0's from engaging // 2 instead of attack armies cause
   if($attackrolls[$fighters-1] > $defendrolls[$fighters-1])   // you cant have 3 fighting ever in Risk
      $defendcasualties -= 1;
   else
      $attackcasualties -= 1;
   $fighters++;
  }
}


Maybe you can insert this option in netrisk 2.0

See You!

_________________
SMF + Multilanguage NetRisk


Top 
 Profile E-mail  
 
 Post subject: Re: 2 or 3 defensive rolls
 Post Posted: Sun Nov 01, 2009 8:19 pm 
Offline

Joined: Tue Jan 09, 2007 5:01 pm
Posts: 1140
Why would want to modify it to 3 rolls though? The game is designed for the Attacker to get 3 rolls and the defender gets 2.

_________________
Power Man Sports
Bored? Play Riskwars


Top 
 Profile  
 
 Post subject: Re: 2 or 3 defensive rolls
 Post Posted: Mon Nov 02, 2009 9:28 pm 
Offline

Joined: Thu Oct 22, 2009 3:15 pm
Posts: 5
Because italian's rules has 3 defensive rolls 8)

_________________
SMF + Multilanguage NetRisk


Last edited by kakkolone on Mon Nov 02, 2009 9:38 pm, edited 1 time in total.

Top 
 Profile E-mail  
 
 Post subject: Re: 2 or 3 defensive rolls
 Post Posted: Mon Nov 02, 2009 9:31 pm 
Offline

Joined: Thu Oct 22, 2009 3:15 pm
Posts: 5
Because italian's rules has 3 defensive rolls 8)

_________________
SMF + Multilanguage NetRisk


Top 
 Profile E-mail  
 
Display posts from previous:  Sort by  
 
Post new topic Reply to topic  [ 4 posts ] 

Board index » Risk Forums » Game Suggestions


Who is online

Users browsing this forum: No registered users and 0 guests

 
 

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron