<html>
<head>
<title>Attrition Calculator</title>
</head>
<body>
<center><form action="" method="post">
<?php $daynow = 1;
$attackerN = $_POST['attackerN'];
$defenderN = $_POST['defenderN'];
$attackerP = $_POST['attackerP'];
$defenderP = $_POST['defenderP'];
$attackerso = $_POST['attackerso'];
$defenderso = $_POST['defenderso'];
$K = $_POST['K'];
$rc = $_POST['rc'];
$hc = $_POST['hc'];
$uc = $_POST['uc'];
$Su = $_POST['Su'];
$KOR = $_POST['KOR'];
$rcOR = $_POST['rcOR'];
$hcOR = $_POST['hcOR'];
$ucOR = $_POST['ucOR'];
($days == "")? $days = 1 : $days = $_POST['days'];
$Suing = $_POST['Suing'];
$AInfArmor = $_POST['AInfArmor'];
$DInfArmor = $_POST['DInfArmor'];?>
<table>
<tr><td></td><td align=center>Personnel strength</td><td align=center>Combat power</td><td align=center><em>so</em></td><td align=center>b</td></tr>
<tr><td align=right>Attacker</td><td align=center><input type="text" name="attackerN" size="7" value="<? echo $attackerN?>" /></td><td align=center><input type="text" name="attackerP" size="7" value="<? echo $attackerP?>" /></td><td align=center><input type="checkbox" value="yes" name="attackerso" <? if($attackerso == "yes") echo checked; ?>><td align=center><input type="checkbox" value="yes" name="AInfArmor" <? if($AInfArmor == "yes") echo checked; ?>></td></td></tr>
<tr><td align=right>Defender</td><td align=center><input type="text" name="defenderN" size="7" value="<? echo $defenderN?>" /></td><td align=center><input type="text" name="defenderP" size="7" value="<? echo $defenderP?>" /></td><td align=center><input type="checkbox" value="yes" name="defenderso" <? if($defenderso == "yes") echo checked; ?></td></td><td align=center><input type="checkbox" value="yes" name="DInfArmor" <? if($DInfArmor == "yes") echo checked; ?>></td></tr>
</table>
<br />
<table><tr align=center><td></td><td>Attacker</td><td>Defender</td></tr>
<td colspan="3"></td>
<tr align=center><td></td></tr>
</table>
<table>
<tr><td /><td /><td align=center><strong>!</strong></td></tr>
<tr><td align=right>Era constant:</td><td><select name="K">
<option>Napoleonic Wars</option>
<option <? if($K == "World War I") echo selected; ?>>World War I</option>
<option <? if($K == "Modern Warfare") echo selected; ?>>Modern Warfare</option>
</select></td><td align=center><input type="text" size="2" name="KOR"></td></tr>
<tr><td align=right>Terrain factor:</td><td><select name="rc">
<option>Rugged, heavily wooded</option>
<option <? if($rc == "Rugged, mixed (extra-rugged, bare)") echo selected; ?>>Rugged, mixed (extra-rugged, bare)</option>
<option <? if($rc == "Rugged, bare") echo selected; ?>>Rugged, bare</option>
<option <? if($rc == "Rolling foothills, heavily wooded") echo selected; ?>>Rolling foothills, heavily wooded</option>
<option <? if($rc == "Rolling foothills, mixed") echo selected; ?>>Rolling foothills, mixed</option>
<option <? if($rc == "Rolling foothills, bare") echo selected; ?>>Rolling foothills, bare</option>
<option <? if($rc == "Rolling gentle, heavily wooded") echo selected; ?>>Rolling gentle, heavily wooded</option>
<option <? if($rc == "Rolling gentle, mixed") echo selected; ?>>Rolling gentle, mixed</option>
<option <? if($rc == "Rolling gentle, bare") echo selected; ?>>Rolling gentle, bare</option>
<option <? if($rc == "Flat, heavily wooded") echo selected; ?>>Flat, heavily wooded</option>
<option <? if($rc == "Flat, mixed") echo selected; ?>>Flat, mixed</option>
<option <? if($rc == "Flat, bare, hard") echo selected; ?>>Flat, bare, hard</option>
<option <? if($rc == "Flat, desert") echo selected; ?>>Flat, desert</option>
<option <? if($rc == "Rolling dunes") echo selected; ?>>Rolling dunes</option>
<option <? if($rc == "Swamp, jungle") echo selected; ?>>Swamp, jungle</option>
<option <? if($rc == "Swamp, mixed or open") echo selected; ?>>Swamp, mixed or open</option>
<option <? if($rc == "Urban") echo selected; ?>>Urban</option>
</select></td><td align=center><input type="text" size="2" name="rcOR"></td></tr>
<tr><td align=right>Weather factor:</td><td><select name="hc">
<option>Dry, sunshine, extreme heat</option>
<option <? if($hc == "Dry, sunshine, temperate") echo selected; ?>>Dry, sunshine, temperate</option>
<option <? if($hc == "Dry, sunshine, extreme cold") echo selected; ?>>Dry, sunshine, extreme cold</option>
<option <? if($hc == "Dry, overcast, extreme heat") echo selected; ?>>Dry, overcast, extreme heat</option>
<option <? if($hc == "Dry, overcast, temperate") echo selected; ?>>Dry, overcast, temperate</option>
<option <? if($hc == "Dry, overcast, extreme cold") echo selected; ?>>Dry, overcast, extreme cold</option>
<option <? if($hc == "Wet, light, extreme heat") echo selected; ?>>Wet, light, extreme heat</option>
<option <? if($hc == "Wet, light, temperate") echo selected; ?>>Wet, light, temperate</option>
<option <? if($hc == "Wet, light, extreme cold") echo selected; ?>>Wet, light, extreme cold</option>
<option <? if($hc == "Wet, heavy, extreme heat") echo selected; ?>>Wet, heavy, extreme heat</option>
<option <? if($hc == "Wet, heavy, temperate") echo selected; ?>>Wet, heavy, temperate</option>
<option <? if($hc == "Wet, heavy, extreme cold") echo selected; ?>>Wet, heavy, extreme cold</option>
</select></td><td align=center><input type="text" size="2" name="hcOR"></td></tr>
<tr><td align=right>Posture factor</td><td><select selected="Delay" name="uc">
<option>Fortified defense</option>
<option <? if($uc == "Prepared defense") echo selected; ?>>Prepared defense</option>
<option <? if($uc == "Hasty defense") echo selected; ?>>Hasty defense</option>
<option <? if($uc == "Delay") echo selected; ?>>Delay</option>
<option <? if($uc == "Withdrawal") echo selected; ?>>Withdrawal</option>
</select></td><!--<td align=center><input type="text" size="2" name="ucOR">--></td></tr>
<tr><td align=right>Surprise factor:</td><td colspan="2"><select name="Su">
<option>None</option>
<option <? if($Su == "Complete surprise") echo selected; ?>>Complete surprise</option>
<option <? if($Su == "Substantial surprise") echo selected; ?>>Substantial surprise</option>
<option <? if($Su == "Minor surprise") echo selected; ?>>Minor surprise</option>
</select>, achieved by <input type="radio" value="ASuer" name="Suing" <? if($Suing == "ASuer") echo checked; ?>>A<input type="radio" value="DSuer" name="Suing" <? if($Suing == "DSuer") echo checked; ?>>D</td></tr>
</table>
<br />
<table>
<tr><td>Length of battle: </td><td> <input type="text" size="3" name="days" value="<? echo $days?>"> day(s)</td></tr>
</table>
<br />
<!-- <table>
<tr><td></td><td align=center>K</td></td><td align=center>rc</td></td><td align=center>hc</td></td><td align=center>uc</td></td><td align=center>tz</td></td><td align=center>op</td></td><td align=center>Su</td></td><td align=center>so</td><td align=center>Casualties</td></tr>
<tr><td>Attackers</td><td><? echo K($K,$KOR) ?></td></td><td><? echo rc($rc,$rcOR) ?></td></td><td><? echo hc($hc,$hcOR) ?></td></td><td><? echo uca($uc) ?></td></td><td><? echo tz($attackerN)?></td></td><td><? echo op($attackerP,$defenderP) ?></td></td><td><? echo Su($Su,$daynow,$Suing,"A") ?></td></td><td><? echo so($attackerso) ?></td><td><? echo (integer) ($attackerN*K($K,$KOR)*rc($rc,$rcOR)*hc($hc,$hcOR)*uca($uc)*tz($attackerN)*op($attackerP,$defenderP)*Su($Su,$daynow,$Suing,"A")*so($attackerso)); ?></td></tr>
<tr><td>Defenders</td><td><? echo K($K,$KOR) ?></td></td><td><? echo rc($rc,$rcOR) ?></td></td><td><? echo hc($hc,$hcOR) ?></td></td><td><? echo ucd($uc) ?></td></td><td><? echo tz($defenderN)?></td></td><td><? echo op($defenderP,$attackerP) ?></td></td><td><? echo Su($Su,$daynow,$Suing,"D") ?></td></td><td><? echo so($defenderso) ?></td><td><? echo (integer) ($defenderN*K($K,$KOR)*rc($rc,$rcOR)*hc($hc,$hcOR)*ucd($uc)*tz($defenderN)*op($defenderP,$attackerP)*Su($Su,$daynow,$Suing,"D")*so($defenderso)); ?></td></tr>
</table> -->
<?$AN = $attackerN; $ATC = 0; $ATKIA = 0; $ATWIA = 0;
$DN = $defenderN; $DTC = 0; $DTKIA = 0; $DTWIA = 0;?>
<table>
<tr><td></td><td colspan="3" align=center>Attacker</td><td colspan="3" align=center>Defender</td></tr>
<tr align=right><td></td><td>KIA</td><td>WIA</td><td>Cas.</td><td>KIA</td><td>WIA</td><td>Cas.</td></tr>
<td></td><?
for($i = $daynow; $i <= $days; $i++){
$AC = (integer)($AN*K($K,$KOR)*rc($rc,$rcOR)*hc($hc,$hcOR)*uca($uc)*tz($attackerN)*op($attackerP,$defenderP)*Su($Su,$daynow,$Suing,"A")*so($attackerso));
$AN -= $AC; $AKIA = KIA($AC,$AInfArmor); $AWIA = WIA($AC,$AInfArmor); $ATC += $AC;
$DC = (integer)($DN*K($K,$KOR)*rc($rc,$rcOR)*hc($hc,$hcOR)*ucd($uc)*tz($defenderN)*op($defenderP,$attackerP)*Su($Su,$daynow,$Suing,"D")*so($defenderso));
$DN -= $DC; $DKIA = KIA($DC,$DInfArmor); $DWIA = WIA($DC,$DInfArmor); $DTC += $DC;
echo "<tr align=right><td></td><td>",$AKIA,"</td><td>",$AWIA,"</td><td><em>",$AKIA+$AWIA,"</em></td><td>",$DKIA,"</td><td>",$DWIA,"</td><td><em>",$DKIA+$DWIA,"</em></td></tr>";
$ATKIA += $AKIA; $ATWIA += $AWIA;
$DTKIA += $DKIA; $DTWIA += $DWIA;
}
echo "<tr align=right><td>Total: </td><td>",$ATKIA,"</td><td>",$ATWIA,"</td><td><strong>",$ATKIA+$ATWIA,"</strong></td><td>",$DTKIA,"</td><td>",$DTWIA,"</td><td><strong>",$DTKIA+$DTWIA,"</storng></td></tr>";?>
</table>
<p><input type="submit" value="Calculate" /></p>
<!--$DC = (integer)($DN*K($K,$KOR)*rc($rc,$rcOR)*hc($hc,$hcOR)*ucd($uc)*tz($defenderN)*op($defenderP,$attackerP)*Su($Su,$daynow,$Suing,"D")*so($defenderso));
$DN -= $DC;
$AC = (integer)($AN*K($K,$KOR)*rc($rc,$rcOR)*hc($hc,$hcOR)*uca($uc)*tz($attackerN)*op($attackerP,$defenderP)*Su($Su,$daynow,$Suing,"A")*so($attackerso));
$AN -= $AC;-->
<?
function WIA($C,$b){
if($b == "yes") return (integer)($C*0.85);
return (integer)($C*0.80);}
function KIA($C,$b){
if($b == "yes") return (integer)($C*0.15);
return (integer)($C*0.20);}
function K($K,$KOR){
if($KOR != "") return $KOR;
if($K == "Napoleonic Wars") return 0.45;
if($K == "World War I") return 0.12;
if($K == "Modern Warfare") return 0.04;}
function rc($rc,$rcOR){
if($rcOR != "") return $rcOR;
if($rc == "Rugged, heavily wooded") return 0.3;
if($rc == "Rugged, mixed (extra-rugged, bare)") return 0.4;
if($rc == "Rugged, bare") return 0.5;
if($rc == "Rolling foothills, heavily wooded") return 0.6;
if($rc == "Rolling foothills, mixed") return 0.7;
if($rc == "Rolling foothills, bare") return 0.8;
if($rc == "Rolling gentle, heavily wooded") return 0.65;
if($rc == "Rolling gentle, mixed") return 0.75;
if($rc == "Rolling gentle, bare") return 0.85;
if($rc == "Flat, heavily wooded") return 0.7;
if($rc == "Flat, mixed") return 0.8;
if($rc == "Flat, bare, hard") return 1;
if($rc == "Flat, desert") return 0.9;
if($rc == "Rolling dunes") return 0.5;
if($rc == "Swamp, jungle") return 0.3;
if($rc == "Swamp, mixed or open") return 0.4;
if($rc == "Urban") return 0.5;}
function hc($hc,$hcOR){
if($hcOR != "") return $rcOR;
if($hc == "Dry, sunshine, extreme heat") return 0.8;
if($hc == "Dry, sunshine, temperate") return 1;
if($hc == "Dry, sunshine, extreme cold") return 0.7;
if($hc == "Dry, overcast, extreme heat") return 0.9;
if($hc == "Dry, overcast, temperate") return 1;
if($hc == "Dry, overcast, extreme cold") return 0.6;
if($hc == "Wet, light, extreme heat") return 0.7;
if($hc == "Wet, light, temperate") return 0.7;
if($hc == "Wet, light, extreme cold") return 0.4;
if($hc == "Wet, heavy, extreme heat") return 0.5;
if($hc == "Wet, heavy, temperate") return 0.5;
if($hc == "Wet, heavy, extreme cold") return 0.3;}
function uca($uc){
if($ucOR != "") return $ucOR;
if($uc == "Fortified defense") return 1;
if($uc == "Prepared defense") return 1;
if($uc == "Hasty defense") return 1;
if($uc == "Delay") return 0.9;
if($uc == "Withdrawal") return 0.8;}
function ucd($uc){
if($ucOR != "") return $ucOR;
if($uc == "Fortified defense") return 0.8;
if($uc == "Prepared defense") return 0.85;
if($uc == "Hasty defense") return 0.9;
if($uc == "Delay") return 0.9;
if($uc == "Withdrawal") return 0.95;}
function Suer($Su,$daynow){
if(($Su == "Complete surprise") and ($daynow == 1)) return 2.2;
if(($Su == "Complete surprise") and ($daynow == 2)) return 1.8;
if(($Su == "Complete surprise") and ($daynow == 3)) return 1.4;
if(($Su == "Substantial surprise") and ($daynow == 1)) return 1.8;
if(($Su == "Substantial surprise") and ($daynow == 2)) return 1.55;
if(($Su == "Substantial surprise") and ($daynow == 3)) return 1.25;
if(($Su == "Minor surprise") and ($daynow == 1)) return 1.4;
if(($Su == "Minor surprise") and ($daynow == 2)) return 1.25;
if(($Su == "Minor surprise") and ($daynow == 3)) return 1.1;
return 1;}
function Sued($Su,$daynow){
if(($Su =="Complete surprise") and ($daynow == 1)) return 2.5;
if(($Su =="Complete surprise") and ($daynow == 2)) return 2;
if(($Su =="Complete surprise") and ($daynow == 3)) return 1.5;
if(($Su =="Substantial surprise") and ($daynow == 1)) return 2;
if(($Su =="Substantial surprise") and ($daynow == 2)) return 1.67;
if(($Su =="Substantial surprise") and ($daynow == 3)) return 1.33;
if(($Su =="Minor surprise") and ($daynow == 1)) return 1.5;
if(($Su =="Minor surprise") and ($daynow == 2)) return 1.33;
if(($Su =="Minor surprise") and ($daynow == 3)) return 1.2;
return 1;}
function Su($Su,$daynow,$Suing,$who){
if($who == "A"){
if($Suing == "ASuer") return Suer($Su,$daynow);
if($Suing == "DSuer") return Sued($Su,$daynow);}
if($who == "D"){
if($Suing == "ASuer") return Sued($Su,$daynow);
if($Suing == "DSuer") return Suer($Su,$daynow);}
return 1;}
function tz($N){
if($N < 500) return 21;
if($N < 2000) return 8;
if($N < 4000) return 2.5;
if($N < 6000) return 1.8;
if($N < 8000) return 1.4;
if($N < 10000) return 1.2;
if($N < 12500) return 1.15;
if($N < 15000) return 1.1;
if($N < 25000) return 1;
if($N < 35000) return 0.9;
if($N < 45000) return 0.8;
if($N < 60000) return 0.7;
if($N < 75000) return 0.6;
if($N < 80000) return 0.5;
if($N < 100000) return 0.4;
return 0.3;}
function op($usP,$themP){
$opr = $usP/$themP;
if($opr >= 6) return 0.4;
if($opr >= 5) return 0.45;
if($opr >= 4.5) return 0.5;
if($opr >= 4) return 0.55;
if($opr >= 3) return 0.6;
if($opr >= 2.5) return 0.65;
if($opr >= 2) return 0.7;
if($opr >= 1.75) return 0.75;
if($opr >= 1.5) return 0.8;
if($opr >= 1.25) return 0.85;
if($opr >= 1) return 0.9;
if($opr >= 0.9) return 0.95;
if($opr >= 0.8) return 1;
if($opr >= 0.75) return 1.05;
if($opr >= 0.70) return 1.1;
if($opr >= 0.65) return 1.15;
if($opr >= 0.6) return 1.2;
if($opr >= 0.55) return 1.25;
if($opr >= 0.5) return 1.3;
if($opr >= 0.45) return 1.35;
if($opr >= 0.4) return 1.4;
if($opr >= 0.35) return 1.45;
if($opr >= 0.3) return 1.5;
if($opr >= 0.25) return 1.6;
if($opr >= 0.2) return 1.7;
if($opr >= 0.18) return 1.8;
if($opr >= 0.16) return 1.9;
if($opr >= 0.14) return 2;
if($opr >= 0.12) return 2.1;
if($opr >- 0.1) return 2.3;
return 2.5;}
function so($so){
if($so == "yes") return 0.5;
return 1;}
function JK($K){
if($K == "Napoleonic Wars") return 1;
if($K == "World War I") return 20;
if($K == "Modern Warfare") return 12;}
?>
</form>
<table><col width=400><tr><td>Assume and manually enter for now that Combat Power is Personnel strength times quality (on a scale of 1-10).</td></tr></table>
</center>
</body>
</html>