Example #1
0
        private void SetupSoftwareColumnDefinition(GUIListView listView)
        {
            listView.AddColumn("Name", content =>
            {
                SoftwareProduct softwareProduct = content as SoftwareProduct;
                Debug.Assert(softwareProduct != null);
                return(softwareProduct.Name);
            }, (obj1, obj2) =>
            {
                SoftwareProduct softwareProduct1 = obj1 as SoftwareProduct;
                SoftwareProduct softwareProduct2 = obj2 as SoftwareProduct;
                Debug.Assert(softwareProduct1 != null && softwareProduct2 != null);
                return(string.CompareOrdinal(softwareProduct1.Name, softwareProduct2.Name));
            }, false);

            listView.AddColumn("Release", content =>
            {
                SoftwareProduct softwareProduct = content as SoftwareProduct;
                Debug.Assert(softwareProduct != null);
                return(softwareProduct.Release.ToCompactString());
            }, (obj1, obj2) =>
            {
                SoftwareProduct softwareProduct1 = obj1 as SoftwareProduct;
                SoftwareProduct softwareProduct2 = obj2 as SoftwareProduct;
                Debug.Assert(softwareProduct1 != null && softwareProduct2 != null);
                return(softwareProduct1.Release.CompareTo(softwareProduct2.Release));
            }, false);

            listView.AddActionColumn("Inspect", action =>
            {
                SoftwareProduct item = action as SoftwareProduct;

                _selectedProduct = item;
            }, false);
        }
Example #2
0
        public static void RemoveSoft()
        {
            SDateTime   time = new SDateTime(1, 70);
            CompanyType type = new CompanyType();
            Dictionary <string, string[]> dict = new Dictionary <string, string[]>();
            SimulatedCompany simComp           = new SimulatedCompany("Trainer Company", time, type, dict, 0f);

            simComp.CanMakeTransaction(1000000000f);

            SoftwareProduct[] Products = GameSettings.Instance.simulation.GetAllProducts().Where(product =>
                                                                                                 product.DevCompany == GameSettings.Instance.MyCompany &&
                                                                                                 product.Inventor != GameSettings.Instance.MyCompany.Name).ToArray();

            if (Products.Length == 0)
            {
                return;
            }

            for (int i = 0; i < Products.Length; i++)
            {
                SoftwareProduct Product = Products[i];

                Product.Userbase       = 0;
                Product.PhysicalCopies = 0;
                Product.Marketing      = 0;
                Product.Trade(simComp);
            }

            WindowManager.SpawnDialog("Products that you didn't invent are removed.", false, DialogWindow.DialogType.Information);
        }
Example #3
0
        public void PushDeal()
        {
            PropertyHelper.DealIsPushed = true;

            SoftwareProduct[] Products = Settings.simulation.GetAllProducts().Where(pr =>
                                                                                    (pr.Type.ToString() == "CMS" ||
                                                                                     pr.Type.ToString() == "Office Software" ||
                                                                                     pr.Type.ToString() == "Operating System" ||
                                                                                     pr.Type.ToString() == "Game") &&
                                                                                    pr.Userbase > 0 &&
                                                                                    pr.DevCompany.Name != Settings.MyCompany.Name &&
                                                                                    pr.ServerReq > 0 &&
                                                                                    !pr.ExternalHostingActive)
                                         .ToArray();

            int index = PropertyHelper.Random.Next(0, Products.Length);

            SoftwareProduct prod = Settings.simulation.GetProduct(Products.ElementAt(index).SoftwareID, false);

            ServerDeal deal = new ServerDeal(Products[index])
            {
                Request = true
            };

            deal.StillValid(true);
            HUD.Instance.dealWindow.InsertDeal(deal);
        }
Example #4
0
        public ActionResult DeleteConfirmed(long id)
        {
            SoftwareProduct softwareProduct = db.SoftwareProducts.Find(id);

            db.SoftwareProducts.Remove(softwareProduct);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #5
0
 public ActionResult Edit([Bind(Include = "Id,Name,Version,Description,Logo,Picture,Price,IsDeleted,CreatedBy")] SoftwareProduct softwareProduct)
 {
     if (ModelState.IsValid)
     {
         db.Entry(softwareProduct).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(softwareProduct));
 }
Example #6
0
        public static void SetProductPriceAction(string input)
        {
            SoftwareProduct Product =
                GameSettings.Instance.MyCompany.Products.FirstOrDefault(product => product.Name == price_ProductName);

            if (Product == null)
            {
                return;
            }

            Product.Price = input.ConvertToFloatDef(50f);
            HUD.Instance.AddPopupMessage($"Trainer: Price for {Product.Name} has been setted up!", "Cogs", "", 0, 0, 0, 0);
        }
Example #7
0
        public static void AddActiveUsersAction(string input)
        {
            SoftwareProduct Product =
                GameSettings.Instance.MyCompany.Products.FirstOrDefault(product => product.Name == PropertyHelper.Product_PriceName);

            if (Product == null)
            {
                return;
            }

            Product.Userbase = input.ConvertToIntDef(100000);
            HUD.Instance.AddPopupMessage("Trainer: Active users for " + Product.Name + " has been setted up!", "Cogs", PopupManager.PopUpAction.None, 0, 0, 0, 0);
        }
Example #8
0
        public static void SetProductStockAction(string input)
        {
            SoftwareProduct Product =
                GameSettings.Instance.MyCompany.Products.FirstOrDefault(product => product.Name == price_ProductName);

            if (Product == null)
            {
                return;
            }

            Product.PhysicalCopies = (uint)input.ConvertToIntDef(100000);
            HUD.Instance.AddPopupMessage($"Trainer: Stock for {Product.Name} has been setted up!", "Cogs", "", 0, 0, 0, 0);
        }
Example #9
0
        public static void SetProductStockAction(string input)
        {
            SoftwareProduct Product =
                GameSettings.Instance.MyCompany.Products.FirstOrDefault(product => product.Name == PropertyHelper.Product_PriceName);

            if (Product == null)
            {
                return;
            }

            Product.PhysicalCopies = (uint)input.ConvertToIntDef(100000);
            HUD.Instance.AddPopupMessage("Trainer: Stock for " + Product.Name + " has been setted up!", "Cogs", PopupManager.PopUpAction.None, 0, 0, 0, 0);
        }
Example #10
0
        public static void SetProductPriceAction(string input)
        {
            SoftwareProduct Product =
                Settings.MyCompany.Products.FirstOrDefault(product => product.Name == PropertyHelper.ProductPriceName);

            if (Product == null)
            {
                return;
            }

            Product.Price = input.ConvertToFloatDef(50f);
            HUD.Instance.AddPopupMessage("Trainer: Price for " + Product.Name + " has been setted up!", "Cogs", PopupManager.PopUpAction.None, 0, 0, 0, 0);
        }
Example #11
0
        // GET: SoftwareProducts/Delete/5
        public ActionResult Delete(long?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            SoftwareProduct softwareProduct = db.SoftwareProducts.Find(id);

            if (softwareProduct == null)
            {
                return(HttpNotFound());
            }
            return(View(softwareProduct));
        }
Example #12
0
        public static void AddActiveUsersAction(string input)
        {
            SoftwareProduct Product =
                GameSettings.Instance.MyCompany.Products.FirstOrDefault(product => product.Name == price_ProductName);

            if (Product == null)
            {
                return;
            }

            Product.Userbase = input.ConvertToIntDef(100000);
            HUD.Instance.AddPopupMessage(
                $"Trainer: Active users for {Product.Name} has been setted up!", "Cogs", "", 0, 0, 0, 0);
        }
Example #13
0
            /// <summary>
            /// Changes the refunds
            /// </summary>
            /// <param name="product">The product which refunds should be changed</param>
            /// <param name="amount">The amount of sales</param>
            public static void Refunds(SoftwareProduct product, int amount)
            {
                int effectVal  = amount;
                int totalsales = 0;

                for (int i = 0; i < product.GetUnitSales(false).Count; i++)
                {
                    totalsales += product.GetUnitSales(false)[i];
                }
                if (totalsales < effectVal)
                {
                    effectVal = totalsales;
                }
                float refundcost = product.Price * effectVal;

                product.AddToCashflow(0, 0, effectVal, -refundcost, 0, TimeOfDay.Instance.GetDate());
            }
Example #14
0
        public static void SellProductStock()
        {
            WindowManager.SpawnDialog("Products stock with no active users have been sold in half a price.",
                                      false, DialogWindow.DialogType.Information);

            SoftwareProduct[] Products =
                GameSettings.Instance.MyCompany.Products.Where(product => product.Userbase == 0).ToArray();

            if (Products.Length == 0)
            {
                return;
            }

            for (int i = 0; i < Products.Length; i++)
            {
                SoftwareProduct product = Products[i];
                int             st      = (int)product.PhysicalCopies * (int)(product.Price / 2);

                product.PhysicalCopies = 0;
                GameSettings.Instance.MyCompany.MakeTransaction(st, Company.TransactionCategory.Sales);
            }
        }
Example #15
0
        public void PushDeal()
        {
            PropertyHelper.DealIsPushed = true;

            SoftwareProduct[] Products = GameSettings.Instance.simulation.GetAllProducts().Where(pr =>
                                                                                                 (pr.Type.ToString() == "CMS" ||
                                                                                                  pr.Type.ToString() == "Office Software" ||
                                                                                                  pr.Type.ToString() == "Operating System" ||
                                                                                                  pr.Type.ToString() == "Game") &&
                                                                                                 pr.Userbase > 0 &&
                                                                                                 pr.DevCompany.Name != GameSettings.Instance.MyCompany.Name &&
                                                                                                 pr.ServerReq > 0 &&
                                                                                                 !pr.ExternalHostingActive)
                                         .ToArray();

            int index = PropertyHelper.rnd.Next(0, Products.Length);

            SoftwareProduct prod =
                GameSettings.Instance.simulation.GetProduct(Products.ElementAt(index).SoftwareID, false);

            //var servers = GameSettings.Instance.GetAllServers();
            //foreach(var srv in servers)
            //{
            //    foreach(var item in srv.Items)
            //    {
            //        item.HandleLoad(100f);
            //    }
            //}
            ServerDeal deal = new ServerDeal(Products[index])
            {
                Request = true
            };

            deal.StillValid(true);
            HUD.Instance.dealWindow.InsertDeal(deal);
        }
 public Team()
 {
     product = new SoftwareProduct();
 }
Example #17
0
            /// <summary>
            /// Changes the online sales
            /// </summary>
            /// <param name="product">The product which sales should be changed</param>
            /// <param name="amount">The amount of sales</param>
            public static void Online(SoftwareProduct product, int amount)
            {
                float price = product.Price;

                product.AddToCashflow(amount, 0, 0, amount * price, 0, TimeOfDay.Instance.GetDate());
            }
Example #18
0
 /// <summary>
 /// Changes the amount of fans from the category of a SoftwareProduct
 /// </summary>
 /// <param name="product">The softwareproduct</param>
 /// <param name="amount">The amount of fans</param>
 public static void Product(SoftwareProduct product, int amount)
 {
     GameSettings.Instance.MyCompany.AddFans(amount, product.Category);
 }
Example #19
0
 /// <summary>
 /// Changes the popularity of a SoftwareProducts SoftwareCategory
 /// </summary>
 /// <param name="product">The SoftwareProduct</param>
 /// <param name="amount">The amount of popularity that should be changed</param>
 public static void Product(SoftwareProduct product, int amount)
 {
     product.Category.Popularity += amount;
 }
Example #20
0
        public bool TransferBestAvailableStaff(Team team, Team[] sourceTeams, out string error)
        {
            IEnumerable <SoftwareWorkItem> software =
                team.WorkItems.Where(wi => wi is SoftwareWorkItem).Cast <SoftwareWorkItem>();

            if (!software.Any())
            {
                error = "Team has no projects";
                return(false);
            }

            // Setup HR so that the correct number of employees are hired, should anyone leave
            if (AdjustDepartment != 0)
            {
                int MaxArt    = 0;
                int MaxCode   = 0;
                int MaxDesign = 0;
                foreach (SoftwareWorkItem workItem in software)
                {
                    Console.Log("Category 2: " + workItem.SWCategory);
                    SoftwareProduct softwareProduct = workItem.SequelTo;
                    SoftwareProduct sequelTo        = softwareProduct == null || !softwareProduct.Traded
                        ? softwareProduct
                        : (SoftwareProduct)null;

                    float devTime = workItem.Type.DevTime(workItem.GetFeatures(), workItem.SWCategory, null, null, null, null,
                                                          false, sequelTo);
                    if (workItem.Type.OSSpecific)
                    {
                        devTime += Mathf.Max(workItem.OSs.Length - 1, 0);
                    }

                    int[] employeeRatio = SoftwareType.GetOptimalEmployeeCount(devTime);

                    if ((AdjustDepartment & AdjustHRFlags.Art) != 0)
                    {
                        MaxArt = Mathf.Max(MaxArt, Mathf.CeilToInt(employeeRatio[1] * (1f - workItem.CodeArtRatio)));
                    }
                    if ((AdjustDepartment & AdjustHRFlags.Code) != 0)
                    {
                        MaxCode = Mathf.Max(MaxCode, Mathf.CeilToInt(employeeRatio[1] * workItem.CodeArtRatio));
                    }
                    if ((AdjustDepartment & AdjustHRFlags.Design) != 0)
                    {
                        MaxDesign = Mathf.Max(MaxDesign, employeeRatio[0]);
                    }
                }

                if (AdjustHR)
                {
                    if ((AdjustDepartment & AdjustHRFlags.Art) != 0)
                    {
                        team.HR.MaxEmployees[EmployeeIndex(Employee.EmployeeRole.Artist)] = MaxArt;
                    }
                    if ((AdjustDepartment & AdjustHRFlags.Code) != 0)
                    {
                        team.HR.MaxEmployees[EmployeeIndex(Employee.EmployeeRole.Programmer)] = MaxCode;
                    }
                    if ((AdjustDepartment & AdjustHRFlags.Design) != 0)
                    {
                        team.HR.MaxEmployees[EmployeeIndex(Employee.EmployeeRole.Designer)] = MaxDesign;
                    }
                }

                Console.Log(string.Format("Total staff required: C: {0} D: {1} A: {2}",
                                          team.HR.MaxEmployees[EmployeeIndex(Employee.EmployeeRole.Programmer)],
                                          team.HR.MaxEmployees[EmployeeIndex(Employee.EmployeeRole.Designer)],
                                          team.HR.MaxEmployees[EmployeeIndex(Employee.EmployeeRole.Artist)]));
            }

            // Switch team members around so that the team has the correct number of staff with the correct skills
            Dictionary <string, float> specializationMonths = null;

            foreach (SoftwareWorkItem workItem in software)
            {
                SoftwareProduct softwareProduct = workItem.SequelTo;
                SoftwareProduct sequelTo        = softwareProduct == null || !softwareProduct.Traded
                    ? softwareProduct
                    : (SoftwareProduct)null;


                var months = workItem.Type.GetSpecializationMonths(workItem.GetFeatures(), workItem.SWCategory,
                                                                   workItem.OSs, sequelTo);
                if (specializationMonths == null)
                {
                    specializationMonths = months;
                }
                else
                {
                    // Merge dictionaries
                    foreach (KeyValuePair <string, float> valuePair in months)
                    {
                        if (specializationMonths.ContainsKey(valuePair.Key))
                        {
                            specializationMonths[valuePair.Key] =
                                Mathf.Max(specializationMonths[valuePair.Key], valuePair.Value);
                        }
                        else
                        {
                            specializationMonths.Add(valuePair.Key, valuePair.Value);
                        }
                    }
                }
            }

            float totalMonths = specializationMonths.Sum(s => s.Value);

            List <Actor>        chosenEmployees = new List <Actor>();
            IEnumerable <Actor> actors          =
                GameSettings.Instance.sActorManager.Actors.Where(a => (!IdleOnly || a.IsIdle) &&
                                                                 (sourceTeams.Any(t => t == a.GetTeam()) ||
                                                                  a.GetTeam() == team || a.GetTeam() == null));

            Console.Log("Available employees : " + actors.Count());
            foreach (KeyValuePair <string, float> specialization in specializationMonths)
            {
                int numCodersRequired =
                    Mathf.CeilToInt((specialization.Value / totalMonths) *
                                    team.HR.MaxEmployees[EmployeeIndex(Employee.EmployeeRole.Programmer)]);
                int numDesignersRequired =
                    Mathf.CeilToInt((specialization.Value / totalMonths) *
                                    team.HR.MaxEmployees[EmployeeIndex(Employee.EmployeeRole.Designer)]);
                int numArtistsRequired =
                    Mathf.CeilToInt((specialization.Value / totalMonths) *
                                    team.HR.MaxEmployees[EmployeeIndex(Employee.EmployeeRole.Artist)]);

                Console.Log(
                    string.Format("Num {0} staff required: C: {1} D: {2} A: {3}", specialization.Key,
                                  numCodersRequired, numDesignersRequired, numArtistsRequired));

                // Coders
                if ((AdjustDepartment & AdjustHRFlags.Code) != 0)
                {
                    chosenEmployees.AddRange(actors
                                             .OrderByDescending(a =>
                                                                a.employee != null
                                ? a.employee
                                                                .GetSpecialization(Employee.EmployeeRole.Programmer,
                                                                                   specialization.Key, a)
                                : (float?)null)
                                             .Take(numCodersRequired));
                }

                // Designers
                if ((AdjustDepartment & AdjustHRFlags.Design) != 0)
                {
                    chosenEmployees.AddRange(actors
                                             .OrderByDescending(a =>
                                                                a.employee != null
                                ? a.employee
                                                                .GetSpecialization(Employee.EmployeeRole.Designer,
                                                                                   specialization.Key, a)
                                : (float?)null)
                                             .Take(numDesignersRequired));
                }

                // Artists
                if ((AdjustDepartment & AdjustHRFlags.Art) != 0)
                {
                    chosenEmployees.AddRange(actors
                                             .OrderByDescending(a =>
                                                                a.employee != null
                                ? a.employee
                                                                .GetSpecialization(Employee.EmployeeRole.Artist,
                                                                                   specialization.Key, a)
                                : (float?)null)
                                             .Take(numArtistsRequired));
                }
            }

            chosenEmployees = chosenEmployees.Distinct().ToList();

            // Remove old team members
            foreach (Actor actor in GameSettings.Instance.sActorManager.Actors.Where(a => a.GetTeam() == team))
            {
                // Don't kick out the lead
                if (actor.employee.IsRole(Employee.RoleBit.Lead))
                {
                    continue;
                }

                if ((AdjustDepartment & AdjustHRFlags.Art) == 0 && actor.employee.IsRole(Employee.RoleBit.Artist))
                {
                    continue;
                }

                if ((AdjustDepartment & AdjustHRFlags.Code) == 0 && actor.employee.IsRole(Employee.RoleBit.Programmer))
                {
                    continue;
                }

                if ((AdjustDepartment & AdjustHRFlags.Design) == 0 && actor.employee.IsRole(Employee.RoleBit.Designer))
                {
                    continue;
                }

                actor.Team = null;
            }

            // Make sure team has enough staff
            var unattachedStaff = GameSettings
                                  .Instance.sActorManager.Actors.Where(a => a.GetTeam() == null);

            if (chosenEmployees.Count(a => a.employee.IsRole(Employee.EmployeeRole.Programmer)) <
                team.HR.MaxEmployees[EmployeeIndex(Employee.EmployeeRole.Programmer)])
            {
                chosenEmployees.AddRange(unattachedStaff.OrderByDescending(a => a.employee != null
                        ? a.employee.GetSkill(Employee
                                              .EmployeeRole
                                              .Programmer)
                        : (float?)null)
                                         .Take(team.HR.MaxEmployees
                                               [EmployeeIndex(Employee.EmployeeRole.Programmer)]));
            }

            if (chosenEmployees.Count(a => a.employee.IsRole(Employee.EmployeeRole.Designer)) <
                team.HR.MaxEmployees[EmployeeIndex(Employee.EmployeeRole.Designer)])
            {
                chosenEmployees.AddRange(unattachedStaff.OrderByDescending(a =>
                                                                           a.employee != null
                            ? a.employee.GetSkill(Employee
                                                  .EmployeeRole
                                                  .Designer)
                            : (float?)null)
                                         .Take(team.HR.MaxEmployees
                                               [EmployeeIndex(Employee.EmployeeRole.Designer)]));
            }

            if (chosenEmployees.Count(a => a.employee.IsRole(Employee.EmployeeRole.Artist)) <
                team.HR.MaxEmployees[EmployeeIndex(Employee.EmployeeRole.Artist)])
            {
                chosenEmployees.AddRange(unattachedStaff.OrderByDescending(a => a.employee != null
                        ? a.employee.GetSkill(Employee
                                              .EmployeeRole
                                              .Artist)
                        : (float?)null)
                                         .Take(team.HR.MaxEmployees
                                               [EmployeeIndex(Employee.EmployeeRole.Artist)]));
            }

            chosenEmployees = chosenEmployees.Distinct().ToList();

            // Find how many staff we have stolen from each team
            IEnumerable <Actor> newActors = chosenEmployees.Where(e => e.GetTeam() != team && e.GetTeam() != null);

            Console.Log("newActors = " + newActors.Count());


            try
            {
                List <GroupCounts> teamCounts = newActors.GroupBy(e => e.Team)
                                                .Select(group => new GroupCounts()
                {
                    Key   = group.Key,
                    Count = group.Count()
                }).ToList();

                Console.Log("teamCounts = " + teamCounts.Count);
                // Add new team members
                foreach (Actor employee in chosenEmployees)
                {
                    employee.Team = team.Name;
                }

                // Which staff are still unattached
                foreach (var teamCount in teamCounts)
                {
                    unattachedStaff = unattachedStaff.Where(e => e.GetTeam() == null);
                    Console.Log(string.Format("After reassignment, {0} staff are unassigned.",
                                              unattachedStaff.Count()));

                    Console.Log(string.Format("Team {0} missing {1} staff.", teamCount.Key, teamCount.Count));
                    IEnumerable <Actor> takenStaff =
                        unattachedStaff.Take(Mathf.Min(unattachedStaff.Count(), teamCount.Count));
                    foreach (Actor employee in takenStaff)
                    {
                        employee.Team = teamCount.Key;
                    }
                }
            }
            catch (Exception e)
            {
                Debug.LogException(e);
                throw;
            }

            unattachedStaff = unattachedStaff.Where(e => e.GetTeam() == null);
            Console.Log(string.Format("After final reassignment, {0} staff are unassigned.", unattachedStaff.Count()));
            if (unattachedStaff.Any())
            {
                HUD.Instance.AddPopupMessage(
                    unattachedStaff.Count() + " staff are without a team following reassignemnt", "Cogs",
                    PopupManager.PopUpAction.None,
                    0, PopupManager.NotificationSound.Issue, 0f, PopupManager.PopupIDs.None, 0);
            }

            error = null;
            return(true);
        }
Example #21
0
 /// <summary>
 /// Changes the amount of bugs from a SoftwareProduct
 /// </summary>
 /// <param name="product">The SoftwareProduct</param>
 /// <param name="amount">The amount of change</param>
 public static void Bugs(SoftwareProduct product, int amount)
 {
     product.Bugs += amount;
 }