<?php
ini_set("display_errors", "on");
error_reporting(E_ALL ^ E_NOTICE);
require('commonFunctions.php');

$id = $_GET['id'];
$type = $_GET['type'];
$weapon = $_GET['weapon'];

$wsList = array();
$wsList['Hand-to-Hand'] = array("Combo", "Shoulder Tackle", "One Inch Punch", "Backhand Blow", "Raging Fists", "Spinning Attack", "Howling Fist", "Dragon Kick", "Asuran Fists", "Final Heaven", "Ascetic's Fury", "Stringing Pummel", "Tornado Kick", "Victory Smite");
$wsList['Dagger'] = array("Wasp Sting", "Viper Bite", "Shadowstitch", "Gust Slash", "Cyclone", "Energy Steal", "Energy Drain", "Dancing Edge", "Shark Bite", "Evisceration", "Mercy Stroke", "Mandalic Stab", "Mordant Rime", "Pyrrhic Kleos", "Aeolian Edge", "Rudra's Storm");
$wsList['Sword'] = array("Fast Blade", "Burning Blade", "Red Lotus Blade", "Flat Blade", "Shining Blade", "Seraph Blade", "Circle Blade", "Spirits Within", "Vorpal Blade", "Swift Blade", "Savage Blade", "Knights of Round", "Death Blossom", "Atonement", "Expiacion", "Sanguine Blade", "Chant du Cygne", "Uriel Blade", "Glory Slash");
$wsList['Great Sword'] = array("Hard Slash", "Power Slash", "Frostbite", "Freezebite", "Shockwave", "Crescent Moon", "Sickle Moon", "Spinning Slash", "Ground Strike", "Scourge", "Herculean Slash", "Torcleaver");
$wsList['Axe'] = array("Raging Axe", "Smash Axe", "Gale Axe", "Avalanche Axe", "Spinning Axe", "Rampage", "Calamity", "Mistral Axe", "Decimation", "Onslaught", "Primal Rend", "Bora Axe", "Cloudsplitter");
$wsList['Great Axe'] = array("Shield Break", "Iron Tempest", "Sturmwind", "Armor Break", "Keen Edge", "Weapon Break", "Raging Rush", "Full Break", "Steel Cyclone", "Metatron Torment", "King's Justice", "Fell Cleave", "Ukko's Fury");
$wsList['Scythe'] = array("Slice", "Dark Harvest", "Shadow of Death", "Nightmare Scythe", "Spinning Scythe", "Vorpal Scythe", "Guillotine", "Cross Reaper", "Spiral Hell", "Catastrophe", "Insurgency", "Infernal Scythe", "Quietus");
$wsList['Polearm'] = array("Double Thrust", "Thunder Thrust", "Raiden Thrust", "Leg Sweep", "Penta Thrust", "Vorpal Thrust", "Skewer", "Wheeling Thrust", "Impulse Drive", "Geirskogul", "Drakesbane", "Sonic Thrust", "Camlann's Torment");
$wsList['Katana'] = array("Blade: Rin", "Blade: Retsu", "Blade: Teki", "Blade: To", "Blade: Chi", "Blade: Ei", "Blade: Jin", "Blade: Ten", "Blade: Ku", "Blade: Metsu", "Blade: Kamu", "Blade: Yu", "Blade: Hi");
$wsList['Great Katana'] = array("Tachi: Enpi", "Tachi: Hobaku", "Tachi: Goten", "Tachi: Kagero", "Tachi: Jinpu", "Tachi: Koki", "Tachi: Yukikaze", "Tachi: Gekko", "Tachi: Kasha", "Tachi: Kaiten", "Tachi: Rana", "Tachi: Ageha", "Tachi: Fudo");
$wsList['Club'] = array("Shining Strike", "Seraph Strike", "Brainshaker", "Starlight", "Moonlight", "Skullbreaker", "True Strike", "Judgment", "Hexa Strike", "Black Halo", "Randgrith", "Mystic Boon", "Flash Nova", "Dagan");
$wsList['Staff'] = array("Heavy Swing", "Rock Crusher", "Earth Crusher", "Starburst", "Sunburst", "Shell Crusher", "Full Swing", "Spirit Taker", "Retribution", "Gate of Tartarus", "Vidohunir", "Garland of Bliss", "Omniscience", "Cataclysm", "Myrkr", "Tartarus Torpor");
$wsList['Archery'] = array("Flaming Arrow", "Piercing Arrow", "Dulling Arrow", "Sidewinder", "Blast Arrow", "Arching Arrow", "Empyreal Arrow", "Namas Arrow", "Refulgent Arrow", "Jishnu's Radiance");
$wsList['Marksmanship'] = array("Hot Shot", "Split Shot", "Sniper Shot", "Slug Shot", "Blast Shot", "Heavy Shot", "Detonator", "Coronach", "Trueflight", "Leaden Salute", "Numbing Shot", "Wildfire");


$jobListIn = array('WAR', 'MNK', 'WHM', 'BLM', 'RDM', 'THF', 'PLD', 'DRK', 'BST', 'BRD', 'RNG', 'SAM', 'NIN', 'DRG', 'SMN', 'BLU', 'COR', 'PUP', 'DNC', 'SCH');
$jobListOut = array(',Warrior', ',Monk', ',White Mage', ',Black Mage', ',Red Mage', ',Thief', ',Paladin', ',Dark Knight', ',Beastmaster', ',Bard', ',Ranger', ',Samurai', ',Ninja', ',Dragoon', ',Summoner', ',Blue Mage', ',Corsair', ',Puppetmaster', ',Dancer', ',Scholar');

$array = @file('AbilitiesParse.txt');

if (strlen($id) == 0 && $type == null) {
    print "<b>Ability Listing</b>\r\n<br />";
    $typeType = array();
    foreach ($array as $key => $curAbil) {
        $currow = explode('|', $curAbil);
        if ($typeType[$currow[4]] == null) {
            $typeType[$currow[4]] = 1;
            print "* [[<a href=\"Ability-O-Matic.php?type=".$currow[4]."\">".$currow[4]."</a>]]<br />\r\n";
        }
    }

} elseif (strlen($id) == 0) {
    print "<b>Ability Listing for '$type'</b>\r\n<br />";
    foreach ($array as $key => $curAbil) {
        $currow = explode('|', $curAbil);
        if ($currow[2] != '.' && $currow[4] == $type) {
            if ($type == "General") {
                print "* [[".$currow[2]."]]<br />\r\n";
            } else {
                print "* [[<a href=\"Ability-O-Matic.php?id=".$currow[1]."&type=$type\">".$currow[2]."</a>]]<br />\r\n";
            }
        }
    }
} else {
    $ablList = array();
    foreach ($array as $key => $curAbil) {
        $currow = explode('|', $curAbil);
        $ablList[$currow[1]] = $currow;
    }
    $data = $ablList[$id];
    $name = $data[2];
    $desc = $data[3];
    if ($type == 'Weapon') {
        $wsNames = array();
        $skill = '';
        foreach ($wsList as $thisSkill => $curSkill) {
            foreach ($curSkill as $key => $curWS) {
                if ($curWS == $name) {
                    $skill = "\r\n<br />[[Category:$thisSkill]]";
                }
            }
        }
        print "{| border=\"1\" cellpadding=\"0\" cellspacing=\"0\" BGCOLOR=\"#cee0f2\" width=\"50%\"
<br />|BGCOLOR=\"#cee0f2\" colspan=\"2\" align=\"center\"|'''Weapon Skill Information'''
<br />|-
<br />|BGCOLOR=\"#cee0f2\" width=\"30%\" align=\"left\" colspan=\"1\" valign=\"top\"|&amp;nbsp;'''Skill Level Obtained:'''
<br />|BGCOLOR=\"#ffffff\"  width=\"70%\" align=\"left\"|&amp;nbsp;?
<br />|-
<br />|BGCOLOR=\"#cee0f2\" width=\"30%\" align=\"left\" colspan=\"1\" valign=\"top\"|&amp;nbsp;'''Description:'''
<br />|BGCOLOR=\"#ffffff\"  width=\"70%\" align=\"left\"|&amp;nbsp;$desc
<br />|-
<br />|BGCOLOR=\"#cee0f2\" width=\"30%\" align=\"left\" colspan=\"1\" valign=\"top\"|&amp;nbsp;'''Elemental Property:'''
<br />|BGCOLOR=\"#ffffff\"  width=\"70%\" align=\"left\"|&amp;nbsp;?
<br />|-
<br />|BGCOLOR=\"#cee0f2\" width=\"30%\" align=\"left\" colspan=\"1\" valign=\"top\"|&amp;nbsp;'''Skillchain Placement:'''
<br />|BGCOLOR=\"#ffffff\"  width=\"70%\" align=\"left\"|&amp;nbsp;?
<br />|-
<br />|BGCOLOR=\"#cee0f2\" width=\"30%\" align=\"left\" colspan=\"1\" valign=\"top\"|&amp;nbsp;'''Statistical Modifiers:'''
<br />|BGCOLOR=\"#ffffff\"  width=\"70%\" align=\"left\"|&amp;nbsp;?
<br />|-
<br />|BGCOLOR=\"#cee0f2\" width=\"30%\" align=\"left\" colspan=\"1\" valign=\"top\"|&amp;nbsp;'''TP Multipliers:'''
<br />|BGCOLOR=\"#ffffff\"  width=\"70%\" align=\"left\"|
<br />&amp;nbsp;? at 100%
<br />&lt;br /&gt;&amp;nbsp;? at 200%
<br />&lt;br /&gt;&amp;nbsp;? at 300%
<br />|-
<br />|}
<br />
<br />==Job Levels==
<br />{| border=\"1\" cellpadding=\"4\" cellspacing=\"0\" BGCOLOR=\"#cee0f2\" width=\"30%\"
<br />|- BGCOLOR=\"#cee0f2\" width=\"40%\"
<br />! Job !! Skill Rating
<br />! width=\"20%\" | Job Level
<br />|- align=\"center\"
<br />| align=\"left\" | [[]]
<br />|
<br />|
<br />|-
<br />|}
<br />
<br />==Notes==
<br />
<br />
<br />==Weapon Skill Images==
<br />
<br />[[Category:Weapon Skills]]$skill";
    } elseif ($type == 'General') {
        print "Nothing to see here, move along.";
    } elseif ($type == 'BloodPactWard' || $type == 'BloodPactRage') {
        $ty = ($type == 'BloodPactWard') ? 'Ward' : 'Rage';
        if ($data[7] == 'Self') {
            $targ = '&lt;me&gt;';
        } elseif ($data[7] == 'Enemy') {
            $targ = '&lt;stnpc&gt;';
        } else {
            $targ = '&lt;stpc&gt;';
            if (stripos($data[7], "Self") === false) {
                $targ .= "(Cannot target yourself)";
            }
        }
        $cost = $data[6];
        $cost = $cost +1 -1;
        if ($cost == 0) {
            $cost = "Caster's level x2 required to use, but consumes all MP.";
        }
        print "{{Blood Pact
<br />|name=$name
<br />|avatar=
<br />|level=
<br />|desc=$desc
<br />|type=$ty
<br />|cost=$cost
<br />|duration=
<br />|target=$targ
<br />}}";
    } elseif ($type == 'Trait') {
        print "Pending template design.";
    } elseif ($type == 'Monster') {
        print "Not built yet.";
    } else {
        $cost = '';
        $command = ($type == 'Pet') ? '/pet' : '/ja';
        if ($data[7] == 'Self') {
            $targ = '&lt;me&gt;';
        } elseif ($data[7] == 'Enemy') {
            $targ = '&lt;stnpc&gt;';
        } elseif (stripos($data[7], 'Enemy') !== false) {
            $targ = '&lt;st&gt;';
        } else {
            $targ = '&lt;stpc&gt;';
            if (stripos($data[7], "Self") === false) {
                $targ .= "(Cannot target yourself)";
            }
        }
        $com = "$command \"$name\" $targ";
        $job = '';
        $pr = '';
        if ($type == 'Corsair' || $type == 'CorsairShot') {
            $job = 'Corsair';
            if ($type == 'Corsair') {
                $romanIn = array('1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11');
                $romanOut = array('I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX', 'X', 'XI');
                $splode = explode('Lucky Number:', $desc);
                $splode[1] = str_replace('.', '', $splode[1]);
                $splode[1] = str_replace($romanIn, $romanOut, $splode[1]);
                $rebasplosion = explode('Unlucky Number:', $splode[1]);
                $lucky = trim($rebasplosion[0]);
                $unlucky = trim($rebasplosion[1]);
                $pr = "\r\n<br />{{Phantom Roll
<br />|effect=
<br />|unlucky=$unlucky
<br />|lucky=$lucky
<br />|mod1=
<br />|mod2=
<br />|mod3=
<br />|mod4=
<br />|mod5=
<br />|mod6=
<br />|mod7=
<br />|mod8=
<br />|mod9=
<br />|mod10=
<br />|mod11=
<br />|modbust=
<br />}}";
            } else {
                //Shoot a bullet charged with the magical energy of a fire card. Special items required.
                $cost = str_replace("Shoot a bullet charged with the magical energy of a ", '', $desc);
                $cost = str_replace('. Special items required.', '', $cost);
                $cost = "[[".ucwords($cost)."]]";
            }
        } elseif ($type == 'Scholar') {
            $job = 'Scholar';
            $num  = $data[6] + 1 - 1;
            $cost = ($num == 1) ? "1 Strategem Charge" : $num." Strategem Charges";
        } elseif ($type == 'Samba' || $type == 'Waltz]' || $type == 'Jig'  || $type == 'Step' || stripos($type, "Flourish") !== false) {
            $job = 'Dancer';
            $cost = (strlen($data[9]) > 0) ? $data[9].' TP' : '';
        }
        print "{{Job Ability
<br />|job=$job
<br />|type=
<br />|level=
<br />|desc=$desc
<br />|range=
<br />|duration=
<br />|recast=
<br />|cost=$cost
<br />|command=$com
<br />|tier=
<br />|ranks=
<br />|effect=
<br />|notes=$pr
<br />|Insert Equipment Ability Modified Template=
<br />}}";
    }
}

?>
