Пример #1
0
        public bool Invent(Player pPlayer, Invention pInvention)
        {
            var result = Game.Invent(pPlayer, pInvention);

            BroadcastGame();
            return(result);
        }
    static void Init()
    {
        BlueprintCombinationEditor window = (BlueprintCombinationEditor)EditorWindow.GetWindow(typeof(BlueprintCombinationEditor));

        blueprintCollection = (BlueprintsCollection)AssetDatabase.LoadAssetAtPath("Assets/ScriptableObjects/BlueprintCollection.asset", typeof(BlueprintsCollection));

        foreach (string s in AssetDatabase.FindAssets("t:Blueprint"))
        {
            Blueprint b = AssetDatabase.LoadAssetAtPath <Blueprint> (s);

            if (!blueprintCollection.blueprints.Contains(b))
            {
                blueprintCollection.blueprints.Add(b);
            }
        }

        inventionCollection = (InventionCollection)AssetDatabase.LoadAssetAtPath("Assets/ScriptableObjects/BlueprintCombinations.asset", typeof(InventionCollection));

        foreach (string s in AssetDatabase.FindAssets("t:Invention"))
        {
            Invention b = AssetDatabase.LoadAssetAtPath <Invention> (s);

            if (!inventionCollection.inventions.Contains(b))
            {
                inventionCollection.inventions.Add(b);
            }
        }

        window.currentlySelected          = null;
        window.currentlySelectedBlueprint = null;



        window.Show();
    }
Пример #3
0
 public void EditInvention(Invention prev, Invention neo)
 {
     if (IsValidInvention(neo))
     {
         inventions[inventions.IndexOf(prev)] = neo;
     }
 }
Пример #4
0
 public HangingGardens() : base(30)
 {
     Name         = "Hanging Gardens";
     RequiredTech = new Pottery();
     ObsoleteTech = new Invention();
     SetSmallIcon(4, 2);
     Type = Wonder.HangingGardens;
 }
Пример #5
0
 public bool AddNewInvention(Invention i)
 {
     if (IsValidInvention(i))
     {
         inventions.Add(i);
         return(true);
     }
     return(false);
 }
Пример #6
0
 public void Update(Invention inventionCategory, InventionDto dto)
 {
     inventionCategory.SetCode(dto.Code);
     inventionCategory.SetName(dto.Name);
     inventionCategory.Description = dto.Description;
     inventionCategory.CategoryId  = dto.CategoryId;
     inventionCategory.SetPrice(dto.Price);
     inventionCategory.Enable = dto.Enable;
 }
    private void SelectInvention(Invention i)
    {
        ingredient1 = i.Material1;
        ingredient2 = i.Material2;
        ingredient3 = i.Material3;

        result = i.result;

        currentlySelected = i;
    }
Пример #8
0
        public void SetPrice_UsingInvalidPrice_ThrowsBusinessRuleException(int price)
        {
            //Arrange
            var invention = new Invention();

            //Act
            TestDelegate testDelegate = () => invention.SetPrice(price);

            //Assert
            Assert.Throws <BusinessRuleException>(testDelegate);
        }
Пример #9
0
        public void SetPrice_UsingValidPrice_SetsPriceToInvention()
        {
            //Arrange
            var invention = new Invention();

            //Act
            invention.SetPrice(100);

            //Assert
            Assert.IsTrue(invention.Price == 100);
        }
Пример #10
0
        public void SetCode_UsingValidCode_SetsCodeToInvention()
        {
            //Arrange
            var invention = new Invention();

            //Act
            invention.SetCode("test0000");

            //Assert
            Assert.IsTrue(invention.Code == "test0000");
        }
Пример #11
0
        public void SetName_UsingValidName_SetsNameToInvention()
        {
            //Arrange
            var invention = new Invention();

            //Act
            invention.SetName("test");

            //Assert
            Assert.IsTrue(invention.Name == "test");
        }
Пример #12
0
        public void SetCode_UsingInvalidCode_ThrowsBusinessRuleException(string code)
        {
            //Arrange
            var invention = new Invention();

            //Act
            TestDelegate testDelegate = () => invention.SetCode(code);

            //Assert
            Assert.Throws <BusinessRuleException>(testDelegate);
        }
Пример #13
0
        public async Task <IActionResult> Create([Bind("ID,DateCreated,IsForSale,Title,IsOpenForFunding,LongDescription")] Invention invention)
        {
            if (ModelState.IsValid)
            {
                var user = User.FindFirst(ClaimTypes.NameIdentifier).Value;
                invention.ApplicationUserId = user;
                _context.Add(invention);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Details", new { ID = invention.ID }));
            }
            return(View(invention));
        }
Пример #14
0
        public async Task <IActionResult> Edit(int id, string published, [Bind("ID,DateCreated,IsForSale,Title,IsOpenForFunding,LongDescription,IsPublished,Valuation,InvestmentRounds")] Invention invention)
        {
            if (id != invention.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    var user = User.FindFirst(ClaimTypes.NameIdentifier).Value;
                    if (published == "Save and Publish")
                    {
                        invention.IsPublished = true;
                    }
                    else
                    {
                        invention.IsPublished = false;
                    }
                    invention.ApplicationUserId = user;
                    //should be delted jan 30 - being handled in the details stage.
                    //if (invention.InvestmentRounds != null && invention.InvestmentRounds.Where(ir => ir.IsOpenForFunding).Count() > 0)
                    //{
                    //    invention.IsOpenForFunding = true;
                    //}
                    //else
                    //{
                    //    invention.IsOpenForFunding = false;
                    //}

                    _context.Update(invention);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!InventionExists(invention.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Details", new { ID = id }));
            }
            return(View(invention));
        }
Пример #15
0
        public static SimDescription ReturnCreaotrSimDescription(GameObject craftedObject)
        {
            Type t = craftedObject.GetType();

            // StyledNotification.Show(new StyledNotification.Format("Type: " + t.BaseType.ToString(), StyledNotification.NotificationStyle.kGameMessagePositive));


            if (t == typeof(PreparedFood))
            {
                return(SimDescription.Find(((PreparedFood)craftedObject).CookingProcess.Preparer.SimDescriptionId));
            }

            if (t == typeof(Fish))
            {
                return(((Fish)craftedObject).FishingSim);
            }
            if (t == typeof(NectarBottle))
            {
                return(((NectarBottle)craftedObject).Creator);
            }

            if (t == typeof(Photograph))
            {
                return(((Photograph)craftedObject).Artist);
            }

            if (t == typeof(Sculpture))
            {
                return(((Sculpture)craftedObject).SculptureComponent.Artist);
            }

            //If an invention
            Widget wid = craftedObject as Widget;

            if (wid != null)
            {
                return(wid.Inventor);
            }

            Invention inv = craftedObject as Invention;

            if (inv != null)
            {
                return(inv.Inventor);
            }

            return(null);
        }
Пример #16
0
        public async Task <IActionResult> CreateDIY([Bind("Invention.Title,Invention.LongDescription,Invention.Valuation,ExpertService.Title,ExpertService.Cost,ExpertService.MaxDaysToComplete")] InventionViewModel inventionCollection)
        {
            //two ways to chain: 1) add a couple or triple of models to a view controller, or 2) just chain them together with adds. Think #2 is better.

            if (ModelState.IsValid)
            {
                var       user      = User.FindFirst(ClaimTypes.NameIdentifier).Value;
                Invention invention = new Invention();
                invention.Title               = Request.Form["Invention.Title"];
                invention.LongDescription     = Request.Form["Invention.LongDescription"];
                invention.Valuation           = Convert.ToInt16(Request.Form["Invention.Valuation"]);
                invention.IsForSale           = false;
                invention.IsOpenForFunding    = true;
                invention.IsPublished         = true;
                invention.ApplicationUserId   = user;
                inventionCollection.Invention = invention;
                inventionCollection.Invention.ApplicationUserId = user;
                ExpertService expertService = new ExpertService();
                expertService.Title             = Request.Form["ExpertService.Title"];
                expertService.IsPublished       = false;
                expertService.LongDescription   = "I will use the funding to work on my invention and to pay for expenses.";
                expertService.MaxDaysToComplete = Convert.ToInt16(Request.Form["ExpertService.MaxDaysToComplete"]);
                expertService.Cost                = Convert.ToInt16(Request.Form["ExpertService.Cost"]);
                expertService.ServiceTypeID       = 2;
                expertService.ApplicationUserId   = user;
                inventionCollection.ExpertService = expertService;
                _context.Add(invention);
                _context.Add(expertService);
                _context.SaveChanges();
                InvestmentRound investmentRound = new InvestmentRound();
                investmentRound.InventionID      = invention.ID;
                investmentRound.RaiseAmount      = expertService.Cost;
                investmentRound.Title            = "DIY Round";
                investmentRound.IsOpenForFunding = true;
                investmentRound.ExpertServiceID  = expertService.ID;
                investmentRound.RoundStatusID    = 1;
                _context.Add(investmentRound);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Details", new { ID = inventionCollection.Invention.ID }));
            }
            return(View(inventionCollection));
        }
Пример #17
0
 public ActionResult Contact(Invention _invention)
 {
     #region Insert
     using (var session = DatabaseModule.OpenSession())
     {
         using (var tran = session.BeginTransaction())
         {
             if (_invention.Description != null || _invention.ScientistID != null)
             {
                 Inventions inventions = new Inventions {
                     ScientistID = _invention.ScientistID, Description = _invention.Description.ToString()
                 };
                 session.Save(inventions);
                 tran.Commit();
             }
             return(View());
         }
     }
     #endregion
 }
Пример #18
0
    private bool IsValidInvention(Invention i)
    {
        if (inventions.Contains(i))
        {
            return(false);
        }

        foreach (Invention invention in inventions)
        {
            if (invention.Material1 == i.Material1 || invention.Material1 == i.Material2 || invention.Material1 == i.Material3)
            {
                if (invention.Material2 == i.Material1 || invention.Material2 == i.Material2 || invention.Material2 == i.Material3)
                {
                    if (invention.Material3 == i.Material1 || invention.Material3 == i.Material2 || invention.Material3 == i.Material3)
                    {
                        return(false);
                    }
                }
            }
        }

        return(true);
    }
Пример #19
0
        public async Task <IActionResult> Invest(int?id)
        {
            //if user is not logged in, direct them to login or create account (with a redirect back to here) - should be automatic



            //if the user does not have an invention, direct them to create one (with a redirect back to here)
            //first we need to associate inventions with the active user.
            //to start, lets just create an invention

            if (id == null)
            {
                return(NotFound());
            }

            var expertService = await _context.ExpertService.Include(m => m.ServiceType).SingleOrDefaultAsync(m => m.ID == id);

            if (expertService == null)
            {
                return(NotFound());
            }

            var user = User.FindFirst(ClaimTypes.NameIdentifier).Value;

            Invention invention = new Invention();

            invention.ApplicationUserId = user;
            invention.Title             = User.Identity.Name + "'s Invention";
            invention.IsOpenForFunding  = true;
            //this will result in 20% of the invention being allocated to the round
            invention.Valuation   = expertService.Cost * 4;
            invention.IsPublished = true;

            _context.Add(invention);
            _context.SaveChanges();

            //await _context.SaveChangesAsync();


            //if the user has multiple inventions, ask them to select which one, assume the last updated and give them an option to change

            //now add an investment round, with the expert service and the invention specified - create investment round and associate with invention and expert service

            InvestmentRound investmentRound = new InvestmentRound();

            investmentRound.ExpertServiceID  = expertService.ID;
            investmentRound.InventionID      = invention.ID;
            investmentRound.RaiseAmount      = expertService.Cost;
            investmentRound.Title            = string.Format("Round for {0}", expertService.Title);
            investmentRound.IsOpenForFunding = true;
            investmentRound.RoundStatusID    = 1;


            _context.Add(investmentRound);
            await _context.SaveChangesAsync();

            //TempData["message"] = "Update Invention Title and add Long Description to.  that tells people just enough to get them to invest but without disclosing patentable subject matter, then click on Save and Publish to get it listed under the Invest tab!";
            TempData["isNew"] = "true";
            return(RedirectToAction("Edit", "Inventions", new { ID = invention.ID }));

            //We will have the amount to raise, we need to ask what the Current Value of the invention is and minimum investment - now this action should be done, and we should transition to investment round

            //Then we can calculate the equity that all investors are getting and the amount of equity for the minimum investment

            //Then this one should be marked open for funding
        }
    void OnGUI()
    {
        currentlyInCombinationTab = GUILayout.Toolbar(currentlyInCombinationTab? 1 : 0, new string[] { "Blueprint", "Blueprint Combinations" }) > 0;

        if (currentlyInCombinationTab)
        {
            if (inventionCollection == null)
            {
                GUILayout.Label("Your invention collection is missing, contact a programmer!");
                return;
            }

            GUILayout.BeginHorizontal();

            GUILayout.BeginVertical(GUILayout.Width((this.position.size.x / 3) - 20));

            foreach (Invention i in inventionCollection.inventions)
            {
                if (i.result != null)
                {
                    if (i.result.itemName != "" && i.result.itemName.Trim() != "")
                    {
                        if (i == currentlySelected)
                        {
                            GUILayout.Label(i.result.itemName);
                        }
                        else
                        {
                            if (GUILayout.Button(i.result.itemName))
                            {
                                SelectInvention(i);
                            }
                        }
                    }
                    else
                    {
                        if (i == currentlySelected)
                        {
                            GUILayout.Label("UNNAMED: " + i.result.name);
                        }
                        else
                        {
                            if (GUILayout.Button("UNNAMED: " + i.result.name))
                            {
                                SelectInvention(i);
                            }
                        }
                    }
                }
                else
                {
                    inventionCollection.inventions.Remove(i);
                }
            }

            GUILayout.EndVertical();

            GUILayout.BeginVertical(GUILayout.Width((this.position.size.x / 3) * 2));

            GUILayout.Label("Blueprint Combination", EditorStyles.boldLabel);

            ingredient1 = (Blueprint)EditorGUILayout.ObjectField("Blueprint 1", ingredient1, typeof(Blueprint), false);
            ingredient2 = (Blueprint)EditorGUILayout.ObjectField("Blueprint 2", ingredient2, typeof(Blueprint), false);
            ingredient3 = (Blueprint)EditorGUILayout.ObjectField("Blueprint 3", ingredient3, typeof(Blueprint), false);

            GUILayout.Space(10);

            result = (BaseItem)EditorGUILayout.ObjectField("Result", result, typeof(BaseItem), false);

            if (result != null && ingredient1 != null && ingredient2 != null && ingredient3 != null)
            {
                if (result != ingredient1 && result != ingredient2 && result != ingredient3)
                {
                    if (ingredient1 != ingredient2 && ingredient1 != ingredient3 && ingredient2 != ingredient3)
                    {
                        if (currentlySelected != null)
                        {
                            if (GUILayout.Button("Edit Invention"))
                            {
                                inventionCollection.EditInvention(currentlySelected, new Invention(ingredient1, ingredient2, ingredient3, result));

                                currentlySelected = null;

                                ingredient1 = null;
                                ingredient2 = null;
                                ingredient3 = null;

                                result = null;
                            }
                            if (GUILayout.Button("Delete Invention"))
                            {
                                inventionCollection.inventions.Remove(currentlySelected);
                                currentlySelected = null;

                                ingredient1 = null;
                                ingredient2 = null;
                                ingredient3 = null;

                                result = null;
                            }
                        }
                        else
                        {
                            if (GUILayout.Button("Add Invention"))
                            {
                                if (inventionCollection.AddNewInvention(new Invention(ingredient1, ingredient2, ingredient3, result)))
                                {
                                    currentlySelected = null;

                                    ingredient1 = null;
                                    ingredient2 = null;
                                    ingredient3 = null;

                                    result = null;
                                }
                            }
                        }
                    }
                }
            }

            GUILayout.EndVertical();

            GUILayout.EndHorizontal();
        }
        else
        {
            if (blueprintCollection == null)
            {
                GUILayout.Label("Your blueprint collection is missing, contact a programmer!");
                return;
            }

            GUILayout.BeginHorizontal();

            GUILayout.BeginVertical(GUILayout.Width((this.position.size.x / 3) - 20));

            foreach (Blueprint b in blueprintCollection.blueprints)
            {
                if (b != null)
                {
                    if (b.blueprintName != "" && b.blueprintName.Trim() != "")
                    {
                        if (b == currentlySelectedBlueprint)
                        {
                            GUILayout.Label(b.blueprintName);
                        }
                        else
                        {
                            if (GUILayout.Button(b.blueprintName))
                            {
                                SelectBlueprint(b);
                            }
                        }
                    }
                    else
                    {
                        if (b == currentlySelectedBlueprint)
                        {
                            GUILayout.Label("UNNAMED: " + b.name);
                        }
                        else
                        {
                            if (GUILayout.Button("UNNAMED: " + b.name))
                            {
                                SelectBlueprint(b);
                            }
                        }
                    }
                }
                else
                {
                    blueprintCollection.blueprints.Remove(b);
                }
            }

            GUILayout.EndVertical();

            GUILayout.BeginVertical(GUILayout.Width((this.position.size.x / 3) * 2));

            GUILayout.Label("Blueprint Combination", EditorStyles.boldLabel);

            blueprintName = EditorGUILayout.TextField("Blueprint name", blueprintName);
            icon          = (Sprite)EditorGUILayout.ObjectField("Blueprint Icon", icon, typeof(Sprite), false);
            category      = (BlueprintCategories)EditorGUILayout.EnumPopup("Blueprint category", category);

            if (currentlySelectedBlueprint != null)
            {
                if (GUILayout.Button("Edit Blueprint"))
                {
                    blueprintCollection.EditBlueprint(currentlySelectedBlueprint, new Blueprint(blueprintName, icon, category));

                    currentlySelectedBlueprint = null;

                    blueprintName = "";
                    icon          = null;
                    category      = BlueprintCategories.MACHINEPARTS;
                }
                if (GUILayout.Button("Delete Blueprint"))
                {
                    blueprintCollection.blueprints.Remove(currentlySelectedBlueprint);
                    currentlySelectedBlueprint = null;

                    blueprintName = "";
                    icon          = null;
                    category      = BlueprintCategories.MACHINEPARTS;
                }
            }
            else
            {
                if (GUILayout.Button("Add Blueprint"))
                {
                    if (blueprintCollection.AddNewBlueprint(new Blueprint(blueprintName, icon, category)))
                    {
                        currentlySelectedBlueprint = null;

                        blueprintName = "";
                        icon          = null;
                        category      = BlueprintCategories.MACHINEPARTS;
                    }
                }
            }

            GUILayout.EndVertical();

            GUILayout.EndHorizontal();
        }
    }
Пример #21
0
 public static void UnlockInvention(Invention invention)
 {
     AvailableInventions[invention] = true;
 }
Пример #22
0
 public static bool IsAvailable(Invention invention)
 {
     return(AvailableInventions[invention]);
 }
Пример #23
0
 public static void LockInvention(Invention invention)
 {
     AvailableInventions[invention] = false;
 }