コード例 #1
0
        public int[] DoSpy()
        {
            Random       rnd        = new Random();
            SystemTalent Sftp       = context.GetSystemTalents()[Talent.SFTP];
            int          sftpAction = int.Parse(Sftp.Action1.Split(',')[computerTo.Talent.SftpLevel]);

            int destroyedBreakpoints = 0;

            int[] report = null;

            //calculamos el porcentaje para cada nave espia
            for (int i = 0; i < hackOrder.BreakPoint; i++)
            {
                int randomNumber = rnd.Next(0, 100);

                //si el breakpoint supera el checkeo
                if (randomNumber > sftpAction)
                {
                    //generamos el reporte
                    report = new int[]
                    {
                        (int)computerTo.Resource.Knowledge,
                        (int)computerTo.Resource.Ingenyous,
                        (int)computerTo.Resource.Coffee,
                        computerTo.Script.Variable,
                        computerTo.Script.Conditional,
                        computerTo.Script.Iterator,
                        computerTo.Script.Json,
                        computerTo.Script.Class,
                        computerTo.Script.BreakPoint,
                        computerTo.Script.Throws,
                        computerTo.Script.TryCatch
                    };
                    break;
                }
                else
                {
                    //el breakpoint se destruye
                    destroyedBreakpoints++;
                }
            }

            //el hackorder regresa
            hackOrder.BreakPoint -= destroyedBreakpoints;
            hackOrder.IsReturn    = true;

            return(report);
        }
コード例 #2
0
        public BuildOrder CreateBuildOrder(int instituteId, int computerId, int buildId)
        {
            Computer  computer  = repository.GetComputer(computerId).Result;
            Institute institute = repository.GetInstitute(instituteId).Result;

            int milliToFinish = 60000 / (int)institute.RateTime;
            int building      = buildId % 20;

            int buildLevel = calculateBuildLevel(computer, buildId);

            int needKnowledge = 0;
            int needIngenyous = 0;
            int needCoffee    = 0;
            int needBuild     = 0;

            switch (buildId / 20)
            {
            case 0:
                SystemResource sysResource = repository.GetSystemResources().Result[building - 1];

                needKnowledge = int.Parse(sysResource.NeedKnowledge.Split(',')[buildLevel]);
                needIngenyous = int.Parse(sysResource.NeedIngenyous.Split(',')[buildLevel]);

                //se comprueba si hay suficientes recursos
                if (computer.Resource.Knowledge < needKnowledge || computer.Resource.Ingenyous < needIngenyous)
                {
                    return(null);
                }

                //se comprueba que no hay otra orden
                foreach (BuildOrder b in repository.GetBuildOrders(computerId).Result)
                {
                    if (b.BuildId < 40)
                    {
                        return(null);
                    }
                }

                //se comprueba que no hayas llegado al límite
                if (building == 1 && computer.Resource.KnowledgeLevel >= sysResource.LastVersion)
                {
                    return(null);
                }
                else if (building == 2 && computer.Resource.IngenyousLevel >= sysResource.LastVersion)
                {
                    return(null);
                }
                else if (building == 3 && computer.Resource.CoffeeLevel >= sysResource.LastVersion)
                {
                    return(null);
                }
                else if (building == 4 && computer.Resource.StressLevel >= sysResource.LastVersion)
                {
                    return(null);
                }

                milliToFinish *= int.Parse(sysResource.Time.Split(',')[buildLevel]);

                repository.NotAsyncUpdateResource(computer.Resource);
                break;

            case 1:
                SystemSoftware sysSoftware = repository.GetSystemSoftwares().Result[building - 1];

                needKnowledge = int.Parse(sysSoftware.NeedKnowledge.Split(',')[buildLevel]);
                needIngenyous = int.Parse(sysSoftware.NeedIngenyous.Split(',')[buildLevel]);
                needCoffee    = int.Parse(sysSoftware.NeedCoffee.Split(',')[buildLevel]);

                //se comprueba si hay suficientes recursos
                if (computer.Resource.Knowledge < needKnowledge || computer.Resource.Ingenyous < needIngenyous || computer.Resource.Coffee < needCoffee)
                {
                    return(null);
                }

                //se comprueba que no hay otra orden
                foreach (BuildOrder b in repository.GetBuildOrders(computerId).Result)
                {
                    if (b.BuildId < 40)
                    {
                        return(null);
                    }
                }

                //se comprueba que no hayas llegado al límite
                if (building == 1 && computer.Software.GeditVersion >= sysSoftware.LastVersion)
                {
                    return(null);
                }
                else if (building == 2 && computer.Software.MySqlVersion >= sysSoftware.LastVersion)
                {
                    return(null);
                }
                else if (building == 3 && computer.Software.GitHubVersion >= sysSoftware.LastVersion)
                {
                    return(null);
                }
                else if (building == 4 && computer.Software.StackOverFlowVersion >= sysSoftware.LastVersion)
                {
                    return(null);
                }
                else if (building == 5 && computer.Software.PostManVersion >= sysSoftware.LastVersion)
                {
                    return(null);
                }
                else if (building == 6 && computer.Software.VirtualMachineVersion >= sysSoftware.LastVersion)
                {
                    return(null);
                }

                milliToFinish *= int.Parse(sysSoftware.Time.Split(',')[buildLevel]);

                break;

            case 2:
                SystemTalent sysTalent = repository.GetSystemTalents().Result[building - 1];

                needKnowledge = int.Parse(sysTalent.NeedKnowledge.Split(',')[buildLevel]);
                needIngenyous = int.Parse(sysTalent.NeedIngenyous.Split(',')[buildLevel]);
                needCoffee    = int.Parse(sysTalent.NeedCoffee.Split(',')[buildLevel]);
                needBuild     = int.Parse(sysTalent.NeedBuild.Split(',')[buildLevel]);

                //se comprueba si hay suficientes recursos
                if (computer.Resource.Knowledge < needKnowledge || computer.Resource.Ingenyous < needIngenyous || computer.Resource.Coffee < needCoffee || computer.Software.StackOverFlowVersion < needBuild)
                {
                    return(null);
                }

                //se comprueba que no haya otra orden
                foreach (BuildOrder b in repository.GetBuildOrders(computerId).Result)
                {
                    if (b.BuildId >= 40 && b.BuildId < 60)
                    {
                        return(null);
                    }
                }

                //se comprueba que no hayas llegado al límite
                if (building == 1 && computer.Talent.RefactorLevel >= sysTalent.LastVersion)
                {
                    return(null);
                }
                else if (building == 2 && computer.Talent.InheritanceLevel >= sysTalent.LastVersion)
                {
                    return(null);
                }
                else if (building == 3 && computer.Talent.InjectionLevel >= sysTalent.LastVersion)
                {
                    return(null);
                }
                else if (building == 4 && computer.Talent.UdpLevel >= sysTalent.LastVersion)
                {
                    return(null);
                }
                else if (building == 5 && computer.Talent.TcpIpLevel >= sysTalent.LastVersion)
                {
                    return(null);
                }
                else if (building == 6 && computer.Talent.SftpLevel >= sysTalent.LastVersion)
                {
                    return(null);
                }
                else if (building == 7 && computer.Talent.EcbLevel >= sysTalent.LastVersion)
                {
                    return(null);
                }
                else if (building == 8 && computer.Talent.RsaLevel >= sysTalent.LastVersion)
                {
                    return(null);
                }
                else if (building == 9 && computer.Talent.SslLevel >= sysTalent.LastVersion)
                {
                    return(null);
                }

                milliToFinish *= int.Parse(sysTalent.Time.Split(',')[buildLevel]);

                break;

            case 3:
                SystemScript sysScript = repository.GetSystemScripts().Result[building - 1];

                needKnowledge = sysScript.NeedKnowledge;
                needIngenyous = sysScript.NeedIngenyous;
                needCoffee    = sysScript.NeedCoffee;

                //se comprueba si hay suficientes recursos
                if (computer.Resource.Knowledge < needKnowledge || computer.Resource.Ingenyous < needIngenyous || computer.Resource.Coffee < needCoffee)
                {
                    return(null);
                }

                //se comprueba que no haya otra orden
                foreach (BuildOrder b in repository.GetBuildOrders(computerId).Result)
                {
                    if (b.BuildId >= 60)
                    {
                        return(null);
                    }
                }

                //TODO: se comprueba que no hayas llegado al límite

                milliToFinish *= sysScript.Time;

                break;
            }

            //consumo de recursos
            computer.Resource.Knowledge -= needKnowledge;
            computer.Resource.Ingenyous -= needIngenyous;
            computer.Resource.Coffee    -= needCoffee;

            repository.NotAsyncUpdateResource(computer.Resource);

            BuildOrder buildOrder = new BuildOrder(computerId, milliToFinish, buildId);

            return(repository.SaveBuildOrder(buildOrder).Result);
        }