public static void TransportHackOrder(Service service, Computer computerTo, HackOrder hackOrder) { SystemSoftware systemSoftware = service.GetSystemSoftware()[Software.MYSQL]; int warehouse = int.Parse(systemSoftware.Action1.Split(',')[computerTo.Software.MySqlVersion]); //se traspasan los recursos de las naves al ordenador computerTo.Resource.Knowledge += hackOrder.Knowledge; if (computerTo.Resource.Knowledge > warehouse) { computerTo.Resource.Knowledge = warehouse; } computerTo.Resource.Ingenyous += hackOrder.Ingenyous; if (computerTo.Resource.Ingenyous > warehouse) { computerTo.Resource.Ingenyous = warehouse; } computerTo.Resource.Coffee += hackOrder.Coffee; if (computerTo.Resource.Coffee > warehouse) { computerTo.Resource.Coffee = warehouse; } service.UpdateComputer(computerTo); //se vacía el hackOrder entero }
public static void UpdateResources(Institute institute, Computer computer, List <SystemResource> systemResources, List <SystemSoftware> systemSoftwares) { SystemResource knowledge = systemResources[Resource.KNOWLEDGE]; SystemResource ingenyous = systemResources[Resource.INGENYOUS]; SystemResource coffee = systemResources[Resource.COFFEE]; SystemResource stress = systemResources[Resource.STRESS]; //cálculo estrés int knowledgeStress = int.Parse(knowledge.Sleep.Split(',')[computer.Resource.KnowledgeLevel]); int ingenyousStress = int.Parse(ingenyous.Sleep.Split(',')[computer.Resource.IngenyousLevel]); int coffeStress = int.Parse(coffee.Sleep.Split(',')[computer.Resource.CoffeeLevel]); int currentStress = int.Parse(stress.Increment.Split(',')[computer.Resource.StressLevel]); int finalStress = currentStress - knowledgeStress - ingenyousStress - coffeStress; //almacenamiento SystemSoftware mySql = systemSoftwares[Software.MYSQL]; int maxResource = int.Parse(mySql.Action1.Split(',')[computer.Software.MySqlVersion]); //modificador por estrés double modStress = 1 * institute.RateCost; if (finalStress < 0) { modStress = 0.5 * institute.RateCost; } //conocimiento if (computer.Resource.Knowledge < maxResource) { computer.Resource.Knowledge += double.Parse(knowledge.Increment.Split(',')[computer.Resource.KnowledgeLevel]) * modStress / MINUT; } //ingenio if (computer.Resource.Ingenyous < maxResource) { computer.Resource.Ingenyous += double.Parse(ingenyous.Increment.Split(',')[computer.Resource.IngenyousLevel]) * modStress / MINUT; } //café if (computer.Resource.Coffee < maxResource) { computer.Resource.Coffee += double.Parse(coffee.Increment.Split(',')[computer.Resource.CoffeeLevel]) * modStress / MINUT; } //sleep computer.Resource.Stress = finalStress; }
public int[] DoTransport() { SystemSoftware systemSoftware = context.GetSystemSoftware()[Software.MYSQL]; int warehouse = int.Parse(systemSoftware.Action1.Split(',')[computerTo.Software.MySqlVersion]); //se traspasan los recursos de las naves al ordenador computerTo.Resource.Knowledge += hackOrder.Knowledge; if (computerTo.Resource.Knowledge > warehouse) { computerTo.Resource.Knowledge = warehouse; } computerTo.Resource.Ingenyous += hackOrder.Ingenyous; if (computerTo.Resource.Ingenyous > warehouse) { computerTo.Resource.Ingenyous = warehouse; } computerTo.Resource.Coffee += hackOrder.Coffee; if (computerTo.Resource.Coffee > warehouse) { computerTo.Resource.Coffee = warehouse; } //se actualiza el ordenador context.UpdateComputer(computerTo); //se genera el report int[] report = new int[] { hackOrder.Knowledge, hackOrder.Ingenyous, hackOrder.Coffee }; //se vacían los recursos del hackOrder hackOrder.Knowledge = 0; hackOrder.Ingenyous = 0; hackOrder.Coffee = 0; //se vuelve hacia la base hackOrder.IsReturn = true; //se actualiza el hackOrder context.UpdateHackOrder(hackOrder); return(report); }
public void DoReturn() { SystemSoftware systemSoftware = context.GetSystemSoftware()[Software.MYSQL]; int warehouse = int.Parse(systemSoftware.Action1.Split(',')[computerTo.Software.MySqlVersion]); //se retornan los recursos computerFrom.Resource.Knowledge += hackOrder.Knowledge; if (computerFrom.Resource.Knowledge > warehouse) { computerFrom.Resource.Knowledge = warehouse; } computerFrom.Resource.Ingenyous += hackOrder.Ingenyous; if (computerFrom.Resource.Ingenyous > warehouse) { computerFrom.Resource.Ingenyous = warehouse; } computerFrom.Resource.Coffee += hackOrder.Coffee; if (computerFrom.Resource.Coffee > warehouse) { computerFrom.Resource.Coffee = warehouse; } //se retornan las naves computerFrom.Script.Variable += hackOrder.Variable; computerFrom.Script.Conditional += hackOrder.Conditional; computerFrom.Script.Iterator += hackOrder.Iterator; computerFrom.Script.Json += hackOrder.Json; computerFrom.Script.Class += hackOrder.Class; computerFrom.Script.BreakPoint += hackOrder.BreakPoint; //se borra el hackorder context.DeleteHackOrder(hackOrder); //se actualiza el computer context.UpdateComputer(computerFrom); }
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); }