Exemple #1
0
    /**
     * Make this planet a homeworld planet for a race
     */
    public void makeHomeworld(Player player, int year)
    {
        owner   = player;
        ownerID = owner.getID();
        Race race = player.getRace();

        System.Random random = new System.Random();
        int           min    = Consts.minHWMineralConc;
        int           max    = Consts.maxStartingConc;

        concMinerals = new Mineral(random.Next(max) + min, random.Next(max) + min, random.Next(max) + min);

        hab = new Hab();
        hab.setGrav(((race.getHabHigh().getGrav() - race.getHabLow().getGrav()) / 2) + race.getHabLow().getGrav());
        hab.setTemp(((race.getHabHigh().getTemp() - race.getHabLow().getTemp()) / 2) + race.getHabLow().getTemp());
        hab.setRad(((race.getHabHigh().getRad() - race.getHabLow().getRad()) / 2) + race.getHabLow().getRad());

        min = Consts.minStartingSurf;
        max = Consts.maxStartingSurf;
        setCargo(new Cargo(random.Next(max) + min, random.Next(max) + min, random.Next(max) + min, 0, 0));

        setPopulation(Consts.startingPopulation);
        if (race.hasLRT(LRT.LSP))
        {
            setPopulation((int)(getPopulation() * Consts.lowStartingPopFactor));
        }

        mines                 = Consts.startingMines;
        factories             = Consts.startingFactories;
        defenses              = Consts.startingDefenses;
        homeworld             = true;
        contributesToResearch = true;
        scanner               = true;
    }
Exemple #2
0
    public Race setHumanoid()
    {
        setName("Humanoid");
        setPluralName("Humanoids");

        prt                   = PRT.JoaT;
        habLow                = new Hab(15, 15, 15);
        habHigh               = new Hab(85, 85, 85);
        growthRate            = 15;
        colonistsPerResource  = 1000;
        factoryOutput         = 10;
        factoryCost           = 10;
        numFactories          = 10;
        factoriesCostLess     = false;
        mineOutput            = 10;
        mineCost              = 5;
        numMines              = 10;
        techsStartHigh        = false;
        immuneGrav            = false;
        immuneTemp            = false;
        immuneRad             = false;
        spendLeftoverPointsOn = SpendLeftoverPointsOn.SurfaceMinerals;
        researchCost          = new ResearchCost(ResearchCostLevel.Standard, ResearchCostLevel.Standard, ResearchCostLevel.Standard, ResearchCostLevel.Standard,
                                                 ResearchCostLevel.Standard, ResearchCostLevel.Standard);

        init();

        return(this);
    }
Exemple #3
0
    /**
     * Copy constructor for initializing the race for a player
     */
    public Race(Race race, Player player)
    {
        this.name                  = race.name;
        this.pluralName            = race.pluralName;
        this.prt                   = race.prt;
        this.habLow                = race.habLow;
        this.habHigh               = race.habHigh;
        this.growthRate            = race.growthRate;
        this.colonistsPerResource  = race.colonistsPerResource;
        this.factoryOutput         = race.factoryOutput;
        this.factoryCost           = race.factoryCost;
        this.numFactories          = race.numFactories;
        this.factoriesCostLess     = race.factoriesCostLess;
        this.mineOutput            = race.mineOutput;
        this.mineCost              = race.mineCost;
        this.numMines              = race.numMines;
        this.techsStartHigh        = race.techsStartHigh;
        this.immuneGrav            = race.immuneGrav;
        this.immuneTemp            = race.immuneTemp;
        this.immuneRad             = race.immuneRad;
        this.spendLeftoverPointsOn = race.spendLeftoverPointsOn;
        this.researchCost          = new ResearchCost(race.researchCost);
        //this.player = player;

        this.init();
    }
Exemple #4
0
        public IActionResult Index()
        {
            List <Hab> habs = new List <Hab>();

            conn.Open();
            NpgsqlCommand cmd = new NpgsqlCommand(" SELECT h.numhab,t.nomtiphab, h.estado, c.numerodoccli FROM  tipohabitacion t, habitacion ha ,reservahab h, reservahabitacion r , cliente c where ha.numhab=h.numhab and  ha.tiphabcod=t.codtiphab and h.codreserva=r.codreserva and r.clientecod=c.codcliente and current_date=r.checkin", conn);

            NpgsqlDataReader dr = cmd.ExecuteReader();

            while (dr.Read())
            {
                Hab hab = new Hab();
                hab.numhab = dr.GetInt32(0);
                hab.tipo   = dr.GetValue(1).ToString();
                hab.estado = dr.GetValue(2).ToString();
                hab.codcli = dr.GetValue(3).ToString();
                habs.Add(hab);
            }
            List <Hab> habb = new List <Hab>();

            foreach (var item in habs)
            {
                if (item.estado.Equals("Reservado"))
                {
                    habb.Add(item);
                }
            }
            ViewBag.Habb = habb;
            List <Hab> habs1 = new List <Hab>();
            List <Hab> habs2 = new List <Hab>();
            List <Hab> habs3 = new List <Hab>();
            List <Hab> habs4 = new List <Hab>();

            conn.Close();
            foreach (var item in habs)
            {
                if (item.numhab < 300)
                {
                    habs1.Add(item);
                }
                else if (item.numhab < 400 && item.numhab >= 300)
                {
                    habs2.Add(item);
                }
                else if (item.numhab < 500 && item.numhab >= 400)
                {
                    habs3.Add(item);
                }
                else
                {
                    habs4.Add(item);
                }
            }
            ViewBag.Hab2 = habs1;
            ViewBag.Hab3 = habs2;
            ViewBag.Hab4 = habs3;
            ViewBag.Hab5 = habs4;
            return(View());
        }
Exemple #5
0
 public void discover(int year, Planet planet)
 {
     this.reportYear   = year;
     this.population   = planet.getPopulation();
     this.hab          = new Hab(planet.getHab());
     this.owner        = planet.getOwner();
     this.ownerID      = planet.getOwnerID();
     this.concMinerals = new Mineral(planet.getConcMinerals());
 }
Exemple #6
0
        public Solution()
        {
            solRoom      = Hab.Dan;
            solCharacter = Car.Gree;
            solGun       = Arm.Wre;

            room      = Hab.Emp;
            character = Car.Emp;
            gun       = Arm.Emp;
        }
Exemple #7
0
        public IActionResult Index()
        {
            List <Hab> habs = new List <Hab>();

            conn.Open();
            NpgsqlCommand cmd = new NpgsqlCommand(" SELECT h.numhab,t.nomtiphab FROM  tipohabitacion t, habitacion h , reservahab rh where  h.tiphabcod=t.codtiphab and h.numhab=rh.numhab and rh.estado='Ocupado' order by numhab", conn);

            NpgsqlDataReader dr = cmd.ExecuteReader();

            while (dr.Read())
            {
                Hab hab = new Hab();
                hab.numhab = dr.GetInt32(0);
                hab.tipo   = dr.GetValue(1).ToString();
                habs.Add(hab);
            }
            dr.Close();
            conn.Close();
            List <Hab> habs1 = new List <Hab>();
            List <Hab> habs2 = new List <Hab>();
            List <Hab> habs3 = new List <Hab>();
            List <Hab> habs4 = new List <Hab>();

            foreach (var item in habs)
            {
                if (item.numhab < 300)
                {
                    habs1.Add(item);
                }
                else if (item.numhab < 400 && item.numhab >= 300)
                {
                    habs2.Add(item);
                }
                else if (item.numhab < 500 && item.numhab >= 400)
                {
                    habs3.Add(item);
                }
                else
                {
                    habs4.Add(item);
                }
            }
            ViewBag.Hab2 = habs1;
            ViewBag.Hab3 = habs2;
            ViewBag.Hab4 = habs3;
            ViewBag.Hab5 = habs4;

            return(View());
        }
Exemple #8
0
 public Room(string n, float positionx, float positionz, Hab h1, Hab h2, Hab h3, Hab h4, Hab h5, Hab h6)
 {
     HintTimePlayer1 = 0;
     HintTimePlayer2 = 0;
     name            = n;
     PositionX       = positionx;
     PositionZ       = positionz;
     Distances       = new Hab[6];
     Distances[0]    = h1;
     Distances[1]    = h2;
     Distances[2]    = h3;
     Distances[3]    = h4;
     Distances[4]    = h5;
     Distances[5]    = h6;
     Elementos       = 0;
 }
Exemple #9
0
        public IActionResult Habitaciones()
        {
            List <Hab>       habs = new List <Hab>();
            NpgsqlConnection conn = new NpgsqlConnection("Host = ec2-34-197-141-7.compute-1.amazonaws.com; Username=ndjaxklicmdweo;Password= 1ce8484d6fcc56b48073eca44510227bab6703584f2b994f37b8a0de42570940;Database = d6pb7d8nu1qd7t; Port= 5432; SSL Mode= Require; Trust Server certificate = true");

            conn.Open();
            NpgsqlCommand cmd = new NpgsqlCommand(" SELECT h.numhab, h.estadohab,t.nomtiphab FROM  tipohabitacion t, habitacion h  where  h.tiphabcod=t.codtiphab union select numhab,estadohab, th.nomtiphab from habitacion h, tipohabitacion th where estadohab='Disponible' and th.codtiphab=h.tiphabcod  order by numhab", conn);

            NpgsqlDataReader dr = cmd.ExecuteReader();

            while (dr.Read())
            {
                Hab hab = new Hab();
                hab.numhab = dr.GetInt32(0);
                hab.estado = dr.GetValue(1).ToString();
                hab.tipo   = dr.GetValue(2).ToString();
                habs.Add(hab);
            }

            ViewBag.Hab = habs;
            conn.Close();
            return(View());
        }
Exemple #10
0
 public void Restart()
 {
     room      = Hab.Emp;
     character = Car.Emp;
     gun       = Arm.Emp;
 }
Exemple #11
0
 public void setHabHigh(Hab habHigh)
 {
     this.habHigh = habHigh;
     init();
 }
Exemple #12
0
 public void setHabLow(Hab habLow)
 {
     this.habLow = habLow;
     init();
 }
Exemple #13
0
    /**
     * Get the habitability of this race for a given planet's hab value
     */
    public long getPlanetHabitability(Hab planetHabData)
    {
        long planetValuePoints = 0, redValue = 0, ideality = 10000;
        int  habValue, habCenter, habUpper, habLower, fromIdeal, habRadius, poorPlanetMod, habRed, tmp;

        for (int habType = 0; habType < 3; habType++)
        {
            habValue  = planetHabData.getAtIndex(habType);
            habCenter = this.habCenter[habType];
            habLower  = this.habLow.getAtIndex(habType);
            habUpper  = this.habHigh.getAtIndex(habType);

            if (isImmune(habType))
            {
                planetValuePoints += 10000;
            }
            else
            {
                if (habLower <= habValue && habUpper >= habValue)
                {
                    /* ideal planet */
                    fromIdeal = Mathf.Abs(habValue - habCenter) * 100;
                    if (habCenter > habValue)
                    {
                        habRadius  = habCenter - habLower;
                        fromIdeal /= habRadius;
                        tmp        = habCenter - habValue;
                    }
                    else
                    {
                        habRadius  = habUpper - habCenter;
                        fromIdeal /= habRadius;
                        tmp        = habValue - habCenter;
                    }
                    poorPlanetMod      = ((tmp) * 2) - habRadius;
                    fromIdeal          = 100 - fromIdeal;
                    planetValuePoints += fromIdeal * fromIdeal;
                    if (poorPlanetMod > 0)
                    {
                        ideality *= habRadius * 2 - poorPlanetMod;
                        ideality /= habRadius * 2;
                    }
                }
                else
                {
                    /* bad planet */
                    if (habLower <= habValue)
                    {
                        habRed = habValue - habUpper;
                    }
                    else
                    {
                        habRed = habLower - habValue;
                    }

                    if (habRed > 15)
                    {
                        habRed = 15;
                    }

                    redValue += habRed;
                }
            }
        }

        if (redValue != 0)
        {
            return(-redValue);
        }

        planetValuePoints = (long)(Mathf.Sqrt(planetValuePoints / 3) + 0.9f);
        planetValuePoints = planetValuePoints * ideality / 10000;

        return(planetValuePoints);
    }
Exemple #14
0
 public void SetRoom(Hab value)
 {
     room = value;
 }
Exemple #15
0
 public Hab(Hab hab)
 {
     this.grav = hab.grav;
     this.temp = hab.temp;
     this.rad  = hab.rad;
 }
Exemple #16
0
 public void setHab(Hab hab)
 {
     this.hab = hab;
 }
/**
 * Compute the hab range advantage points for this race by generating test planets for a variety
 * of ranges and using the habitability of those planets
 */
    private static long getHabRange()
    {
        bool   totalTerraforming;
        double temperatureSum, gravitySum;
        long   radiationSum, planetDesirability;
        int    terraformOffsetSum, tmpHab;

        int[] terraformOffset = new int[3];

        Hab testHabStart = new Hab();
        Hab testHabWidth = new Hab();

        double points = 0.0;

        totalTerraforming = race.getLrts().Contains(LRT.TT);

        terraformOffset[0] = terraformOffset[1] = terraformOffset[2] = 0;

        if (race.isImmuneGrav())
        {
            numIterationsGrav = 1;
        }
        else
        {
            numIterationsGrav = 11;
        }
        if (race.isImmuneTemp())
        {
            numIterationsTemp = 1;
        }
        else
        {
            numIterationsTemp = 11;
        }
        if (race.isImmuneRad())
        {
            numIterationsRad = 1;
        }
        else
        {
            numIterationsRad = 11;
        }
        for (int loopIndex = 0; loopIndex < 3; loopIndex++)
        {
            // each main loop gets a different TTCorrectionFactor
            if (loopIndex == 0)
            {
                TTCorrectionFactor = 0;
            }
            else if (loopIndex == 1)
            {
                TTCorrectionFactor = totalTerraforming ? 8 : 5;
            }
            else
            {
                TTCorrectionFactor = totalTerraforming ? 17 : 15;
            }


            for (int habType = 0; habType < 3; habType++)
            {
                if (race.isImmune(habType))
                {
                    testHabStart.setAtIndex(habType, 50);
                    testHabWidth.setAtIndex(habType, 11);
                }
                else
                {
                    testHabStart.setAtIndex(habType, race.getHabLow().getAtIndex(habType) - TTCorrectionFactor);

                    if (testHabStart.getAtIndex(habType) < 0)
                    {
                        testHabStart.setAtIndex(habType, 0);
                    }

                    tmpHab = race.getHabHigh().getAtIndex(habType) + TTCorrectionFactor;

                    if (tmpHab > 100)
                    {
                        tmpHab = 100;
                    }

                    testHabWidth.setAtIndex(habType, tmpHab - testHabStart.getAtIndex(habType));
                }
            }
            gravitySum = 0.0;
            for (int iterationGrav = 0; iterationGrav < numIterationsGrav; iterationGrav++)
            {
                tmpHab = getPlanetHabForHabIndex(iterationGrav, 0, loopIndex, numIterationsGrav, testHabStart.getGrav(), testHabWidth.getGrav(), terraformOffset);
                testPlanetHab.setGrav(tmpHab);

                temperatureSum = 0.0;
                for (int iterationTemp = 0; iterationTemp < numIterationsTemp; iterationTemp++)
                {
                    tmpHab = getPlanetHabForHabIndex(iterationTemp, 1, loopIndex, numIterationsTemp, testHabStart.getTemp(), testHabWidth.getTemp(), terraformOffset);
                    testPlanetHab.setTemp(tmpHab);

                    radiationSum = 0;
                    for (int iterationRad = 0; iterationRad < numIterationsRad; iterationRad++)
                    {
                        tmpHab = getPlanetHabForHabIndex(iterationRad, 2, loopIndex, numIterationsRad, testHabStart.getRad(), testHabWidth.getRad(), terraformOffset);
                        testPlanetHab.setRad(tmpHab);

                        planetDesirability = race.getPlanetHabitability(testPlanetHab);

                        terraformOffsetSum = terraformOffset[0] + terraformOffset[1] + terraformOffset[2];
                        if (terraformOffsetSum > TTCorrectionFactor)
                        {
                            planetDesirability -= terraformOffsetSum - TTCorrectionFactor;
                            if (planetDesirability < 0)
                            {
                                planetDesirability = 0;
                            }
                        }
                        planetDesirability *= planetDesirability;

                        switch (loopIndex)
                        {
                        case 0:
                            planetDesirability *= 7;
                            break;

                        case 1:
                            planetDesirability *= 5;
                            break;

                        default:
                            planetDesirability *= 6;
                            break;
                        }

                        radiationSum += planetDesirability;
                    }
                    if (!race.isImmuneRad())
                    {
                        radiationSum = (radiationSum * testHabWidth.getRad()) / 100;
                    }
                    else
                    {
                        radiationSum *= 11;
                    }

                    temperatureSum += radiationSum;
                }
                if (!race.isImmuneTemp())
                {
                    temperatureSum = (temperatureSum * testHabWidth.getTemp()) / 100;
                }
                else
                {
                    temperatureSum *= 11;
                }

                gravitySum += temperatureSum;
            }
            if (!race.isImmuneGrav())
            {
                gravitySum = (gravitySum * testHabWidth.getGrav()) / 100;
            }
            else
            {
                gravitySum *= 11;
            }

            points += gravitySum;
        }

        return((long)(points / 10.0 + 0.5));
    }