<?php
require_once("Class/Donnees/interface.php");

class dSpatial implements Donnees
{
    public static function metal($id, $nombre, surface $planete)
    {
        switch ($id) {
            case 0:
                $metal = 1000;
                break;
            case 1:
                $metal = 4000;
                break;
            case 2:
                $metal = 4000;
                break;
            case 3:
                $metal = 9000;
                break;
            case 4:
                $metal = 9000;
                break;
            case 5:
                $metal = 1000;
                break;
            case 6:
                $metal = 15000;
                break;
            case 7:
                $metal = 1800;
                break;
            case 8:
                $metal = 2550;
                break;
            case 9:
                $metal = 12950;
                break;
            case 10:
                $metal = 26000;
                break;
            case 11:
                $metal = 60000;
                break;
            case 12:
                $metal = 500000;
                break;
            case 13:
                $metal = 500000;
                break;
            default:
                trigger_error("Vaisseau ".$id." introuvable dans les données", E_USER_ERROR);
        }

        //On tient compte des bonus
        if (isset($planete->politique) && $planete->politique == 1) {
            $metal *= 0.9;
        }

        return $metal * $nombre;
    }

    public static function cristal($id, $nombre, surface $planete)
    {
        switch ($id) {
            case 0:
                $cristal = 800;
                break;
            case 1:
                $cristal = 3000;
                break;
            case 2:
                $cristal = 3000;
                break;
            case 3:
                $cristal = 9000;
                break;
            case 4:
                $cristal = 9000;
                break;
            case 5:
                $cristal = 1200;
                break;
            case 6:
                $cristal = 9000;
                break;
            case 7:
                $cristal = 1000;
                break;
            case 8:
                $cristal = 1350;
                break;
            case 9:
                $cristal = 16400;
                break;
            case 10:
                $cristal = 6900;
                break;
            case 11:
                $cristal = 40000;
                break;
            case 12:
                $cristal = 400000;
                break;
            case 13:
                $cristal = 400000;
                break;
            default:
                trigger_error("Vaisseau ".$id." introuvable dans les données", E_USER_ERROR);
        }

        //On tient compte des bonus
        if (isset($planete->politique) && $planete->politique == 1) {
            $cristal *= 0.9;
        }

        return $cristal * $nombre;
    }

    public static function hydrogene($id, $nombre, surface $planete)
    {
        switch ($id) {
            case 0:
                $hydrogene = 0;
                break;
            case 1:
                $hydrogene = 0;
                break;
            case 2:
                $hydrogene = 0;
                break;
            case 3:
                $hydrogene = 1000;
                break;
            case 4:
                $hydrogene = 1000;
                break;
            case 5:
                $hydrogene = 100;
                break;
            case 6:
                $hydrogene = 1000;
                break;
            case 7:
                $hydrogene = 0;
                break;
            case 8:
                $hydrogene = 65;
                break;
            case 9:
                $hydrogene = 100;
                break;
            case 10:
                $hydrogene = 1600;
                break;
            case 11:
                $hydrogene = 3000;
                break;
            case 12:
                $hydrogene = 250000;
                break;
            case 13:
                $hydrogene = 250000;
                break;
            default:
                trigger_error("Vaisseau ".$id." introuvable dans les données", E_USER_ERROR);
        }

        //On tient compte des bonus
        if (isset($planete->politique) && $planete->politique == 1) {
            $hydrogene *= 0.9;
        }

        return $hydrogene * $nombre;
    }

    public static function credits($id, $nombre, surface $planete)
    {
        return 0;
    }

    public static function temps($id, $nombre, surface $planete)
    {
        switch ($id) {
            case 0:
                $temps = 1080;
                $moins = 1;
                break;
            case 1:
                $temps = 6300;
                $moins = 5;
                break;
            case 2:
                $temps = 6300;
                $moins = 5;
                break;
            case 3:
                $temps = 8280;
                $moins = 5;
                break;
            case 4:
                $temps = 8280;
                $moins = 5;
                break;
            case 5:
                $temps = 1440;
                $moins = 3;
                break;
            case 6:
                $temps = 7380;
                $moins = 5;
                break;
            case 7:
                $temps = 1200;
                $moins = 1;
                break;
            case 8:
                $temps = 4680;
                $moins = 3;
                break;
            case 9:
                $temps = 16800;
                $moins = 6;
                break;
            case 10:
                $temps = 16800;
                $moins = 6;
                break;
            case 11:
                $temps = 32400;
                $moins = 8;
                break;
            case 12:
                $temps = 117000;
                $moins = 12;
                break;
            case 13:
                $temps = 117000;
                $moins = 12;
                break;
            default:
                trigger_error("Vaisseau ".$id." introuvable dans les données", E_USER_ERROR);
        }

        //On tient compte de la vitesse
        $temps /= VITESSE;

        //On tient compte des bonus
        if (SURFACE == "planete") {
            return ceil($temps/pow(1.25, ($planete->batiments[8] - $moins))) * $nombre;
        } else {
            return ($temps * $nombre);
        }
    }


    public static function image($id, surface $planete)
    {
        if ($planete->race == "covenant") {
            switch ($id) {
                case 0:
                    return "cargo2pb6.jpg";
                    break;
                case 1:
                    return "sanstitre2copiegw9.jpg";
                    break;
                case 2:
                    return "colocopiers4.jpg";
                    break;
                case 3:
                    return "sonde_despionnage1.jpg";
                    break;
                case 4:
                    return "chasseurlourd7id.jpg";
                    break;
                case 5:
                    return "contactharvestbynameleszk3.jpg";
                    break;
                case 6:
                    return "vaisseauuu0.jpg";
                    break;
                case 7:
                    return "vaisseaudebataille9na.jpg";
                    break;
                case 8:
                    return "pv.jpg";
                    break;
                case 9:
                    return "stationorbitalezt7.jpg";
                    break;
                case 10:
                    return "citecovenant.jpg";
                    break;
            }
            return Donnees::image_covenant_default;
        } elseif ($planete->race == "humain") {
            switch ($id) {
                case 0:
                    return "csnucargoparabola2mc9.jpg";
                    break;
                case 1:
                    return "csnucargoladen2al8.jpg";
                    break;
                case 2:
                    return "colonisation.jpg";
                    break;
                case 3:
                    //return "";
                    break;
                case 4:
                    return "longsworduf9.jpg";
                    break;
                case 5:
                    //return "";
                    break;
                case 6:
                    //return "";
                    break;
                case 7:
                    return "frgatecopiegw1.jpg";
                    break;
                case 8:
                    //return "";
                    break;
                case 9:
                    return "halcyo15.jpg";
                    break;
                case 10:
                    return "qsu169.jpg";
                    break;
            }
            return Donnees::image_humain_default;
        } else {
            trigger_error("Impossible de trouver la race pour ".$planete->race, E_USER_ERROR);
        }
    }



    public static function needed($id, surface $planete, $print = false)
    {
        $neededSpatial =
            array(
                array(
                    array('batiments', 8, 1),
                    array('technologies', 0,3)
                ),
                array(
                    array('batiments', 8, 5),
                    array('technologies', 0,3),
                    array('technologies', 1,6)
                ),
                array(
                    array('batiments', 8, 5),
                    array('technologies', 8,0)
                ),
                array(
                    array('batiments', 8, 5),
                    array('technologies', 7,4)
                ),
                array(
                    array('batiments', 8, 5),
                    array('technologies', 7,0)
                ),
                array(
                    array('batiments', 8, 3),
                    array('technologies', 7,1)
                ),
                array(
                    array('batiments', 8, 5),
                    array('technologies', 7,2)
                ),
                array(
                    array('batiments', 8, 1),
                    array('technologies', 7,3)
                ),
                array(
                    array('batiments', 8, 3),
                    array('technologies', 7,5)
                ),
                array(
                    array('batiments', 8, 6),
                    array('technologies', 7,6)
                ),
                array(
                    array('batiments', 8, 6),
                    array('technologies', 7,1)
                ),
                array(
                    array('batiments', 8, 8),
                    array('technologies', 7,8)
                ),
                array(
                    array('batiments', 8, 10),
                    array('technologies', 7,9)
                ),
                array(
                    array('batiments', 8, 10),
                    array('technologies', 7,10)
                )
            );

        if ($print) {
            return dDonnees::print_neededCheck($neededSpatial[$id], $planete);
        } else {
            return dDonnees::neededCheck($neededSpatial[$id], $planete);
        }
    }


    public static function tailleCales($id)
    {
        switch ($id) {
            case 0:
                $vitesse = 10000;
                break;
            case 1:
                $vitesse = 50000;
                break;
            case 2:
                $vitesse = 25000;
                break;
            case 3:
                $vitesse = 25000;
                break;
            case 4:
                $vitesse = 100;
                break;
            case 5:
                $vitesse = 50;
                break;
            case 6:
                $vitesse = 200;
                break;
            case 7:
                $vitesse = 400;
                break;
            case 8:
                $vitesse = 800;
                break;
            case 9:
                $vitesse = 1000;
                break;
            case 10:
                $vitesse = 1500;
                break;
            case 11:
                $vitesse = 50000;
                break;
            case 12:
                $vitesse = 100000;
                break;
            case 13:
                $vitesse = 500;
                break;
            default:
                trigger_error("Vaisseau ".$id." introuvable dans les données", E_USER_ERROR);
        }

        //On tient compte des bonus
        return $vitesse;
    }


    public static function vitesseP($id)
    {
        switch ($id) {
            case 0:
                $vitesse = 1080;
                break;
            case 1:
                $vitesse = 6300;
                break;
            case 2:
                $vitesse = 6300;
                break;
            case 3:
                $vitesse = 8280;
                break;
            case 4:
                $vitesse = 8280;
                break;
            case 5:
                $vitesse = 1440;
                break;
            case 6:
                $vitesse = 7380;
                break;
            case 7:
                $vitesse = 1200;
                break;
            case 8:
                $vitesse = 4680;
                break;
            case 9:
                $vitesse = 16800;
                break;
            case 10:
                $vitesse = 16800;
                break;
            case 11:
                $vitesse = 32400;
                break;
            case 12:
                $vitesse = 117000;
                break;
            case 13:
                $vitesse = 117000;
                break;
            default:
                trigger_error("Vaisseau ".$id." introuvable dans les données", E_USER_ERROR);
        }

        //On tient compte des bonus
        return $vitesse;
    }

    public static function vitesseS($id)
    {
        switch ($id) {
            case 0:
                $vitesse = 1080;
                break;
            case 1:
                $vitesse = 6300;
                break;
            case 2:
                $vitesse = 6300;
                break;
            case 3:
                $vitesse = 8280;
                break;
            case 4:
                $vitesse = 8280;
                break;
            case 5:
                $vitesse = 1440;
                break;
            case 6:
                $vitesse = 7380;
                break;
            case 7:
                $vitesse = 1200;
                break;
            case 8:
                $vitesse = 4680;
                break;
            case 9:
                $vitesse = 16800;
                break;
            case 10:
                $vitesse = 16800;
                break;
            case 11:
                $vitesse = 32400;
                break;
            case 12:
                $vitesse = 117000;
                break;
            case 13:
                $vitesse = 117000;
                break;
            default:
                trigger_error("Vaisseau ".$id." introuvable dans les données", E_USER_ERROR);
        }

        //On tient compte des bonus
        return $vitesse;
    }

    public static function vitesseG($id)
    {
        switch ($id) {
            case 0:
                $vitesse = 1080;
                break;
            case 1:
                $vitesse = 6300;
                break;
            case 2:
                $vitesse = 6300;
                break;
            case 3:
                $vitesse = 8280;
                break;
            case 4:
                $vitesse = 8280;
                break;
            case 5:
                $vitesse = 1440;
                break;
            case 6:
                $vitesse = 7380;
                break;
            case 7:
                $vitesse = 1200;
                break;
            case 8:
                $vitesse = 4680;
                break;
            case 9:
                $vitesse = 16800;
                break;
            case 10:
                $vitesse = 16800;
                break;
            case 11:
                $vitesse = 32400;
                break;
            case 12:
                $vitesse = 117000;
                break;
            case 13:
                $vitesse = 117000;
                break;
            default:
                trigger_error("Vaisseau ".$id." introuvable dans les données", E_USER_ERROR);
        }

        //On tient compte des bonus
        return $vitesse;
    }
}
