Exemple #1
0
    public void PassStage(StageMapRecord passStageMap)
    {
        List <AwardItem> awardList = new List <AwardItem>();

        _FightingStage = LogicManager.Instance.EnterStageInfo;
        var baseAward = AwardManager.AddAward(_FightingStage.StageRecord.AwardType[0], _FightingStage.StageRecord.AwardValue[0]);

        awardList.Add(baseAward);

        int starCnt = 0;

        for (int i = 0; i < 3; ++i)
        {
            if (_FightingStage.IsStarOn(i))
            {
                continue;
            }

            bool isGetStar = true;
            if (passStageMap._StarInfos.Count > i)
            {
                isGetStar = StarInfoBase.isCanGetStar(passStageMap._StarInfos[i]);
            }

            if (isGetStar)
            {
                StageDataPack.Instance.SetStageStar(_FightingStage.StageRecord.Id, i);

                var starAward = AwardManager.AddAward(_FightingStage.StageRecord.AwardType[i + 1], _FightingStage.StageRecord.AwardValue[i + 1]);
                awardList.Add(starAward);
            }
        }

        for (int i = 0; i < 3; ++i)
        {
            if (_FightingStage.IsStarOn(i))
            {
                ++starCnt;
            }
        }

        StageDataPack.Instance.SaveClass(true);
        UIFightBox.HideOptMask();
        UIStageSucess.ShowAsyn(_FightingStage.StageRecord, starCnt, awardList);

        WeaponDataPack.Instance.RefreshUnLock();
    }
Exemple #2
0
    public void TestPass(string stageID, int starCnt)
    {
        List <AwardItem> awardList = new List <AwardItem>();
        var stage     = Tables.TableReader.StageInfo.GetRecord(stageID);
        var baseAward = AwardManager.AddAward(stage.AwardType[0], stage.AwardValue[0]);

        awardList.Add(baseAward);

        for (int i = 0; i < starCnt; ++i)
        {
            StageDataPack.Instance.SetStageStar(stage.Id, i);

            var starAward = AwardManager.AddAward(stage.AwardType[i + 1], stage.AwardValue[i + 1]);
            awardList.Add(starAward);
        }

        StageDataPack.Instance.SaveClass(true);
        //UIStageSucess.ShowAsyn(stage, starCnt, awardList);

        WeaponDataPack.Instance.RefreshUnLock();
    }
Exemple #3
0
        private static void MainInterface()
        {
            Console.WriteLine("\nPlase select some action:");
            Console.WriteLine("1. Add new User");
            Console.WriteLine("2. Remove User!");
            Console.WriteLine("3. Show all Users");
            Console.WriteLine("4. Add new Award");
            Console.WriteLine("5. Remove Award!");
            Console.WriteLine("6. Show all Awards");
            Console.WriteLine("7. Add Award to User");
            Console.WriteLine("8. Show User Awards");
            Console.WriteLine("9. Delete all User Awards!");
            Console.WriteLine("10. Show all users and their rewards");
            Console.WriteLine("11. Change the way data is stored");
            Console.WriteLine("12. Exit and Serialize all data in file!");

            Console.Write("Enter: ");
            var menuSelection = Console.ReadLine();

            if (uint.TryParse(menuSelection, out uint selectedOption) &&
                selectedOption > 0 &&
                selectedOption < 13)
            {
                switch (selectedOption)
                {
                case 1:
                    Console.Write("\n1. Enter user Name: ");
                    string userName = Console.ReadLine();
                    if (string.IsNullOrWhiteSpace(userName))
                    {
                        Console.WriteLine("\n Name cannot be empty!\n");
                        Console.ReadKey();
                        goto case 1;
                    }
                    Console.Write("2. Enter user date of birth by pattern dd.mm.yyyy: ");
                    bool BDateChecked = DateTime.TryParse(Console.ReadLine(), out DateTime dateOfBith);
                    if (BDateChecked && dateOfBith < DateTime.Now)
                    {
                        UserManager.CreateUser(userName, dateOfBith);
                        Console.WriteLine($"\nUser '{userName}' created!\n");
                        MainInterface();
                    }
                    else
                    {
                        Console.WriteLine("\n User not created! You cannot have a date of birth later than the present time!");
                        Console.ReadKey();
                        goto case 1;
                    }
                    //To DO: BLL - add User
                    break;

                case 2:
                    Console.WriteLine("\nChoose which User to delete:");
                    ShowUsersAndAddNumbers();
                    Console.Write("\nEnter number of User y whant to remove: ");
                    string numberOfUserToRemove = Console.ReadLine();

                    if (string.IsNullOrWhiteSpace(numberOfUserToRemove))
                    {
                        Console.WriteLine("\nThis field cannot be empty!");
                        Console.ReadKey();
                        goto case 2;
                    }
                    if (!UserIDs.ContainsKey(int.Parse(numberOfUserToRemove)))
                    {
                        Console.WriteLine("\nWrong number of User!");
                        Console.ReadKey();
                        goto case 2;
                    }

                    Guid userGuid     = UserIDs[int.Parse(numberOfUserToRemove)];
                    User userToRemove = UserManager.GetUserByID(userGuid);

                    if (UserManager.RemoveUser(userToRemove))
                    {
                        Console.WriteLine($"\nUser {userToRemove} removed!\n");
                        Console.WriteLine("Users: ");
                        ShowAllItems(UserManager.GetAllUsers());
                        Console.ReadKey();
                        MainInterface();
                    }
                    else
                    {
                        Console.WriteLine("\nUser deletion failed!\n");
                        Console.WriteLine("\nPress any button to return to the main menu...\n");
                        Console.ReadKey();
                        MainInterface();
                    }
                    //To DO: BLL - remove User
                    break;

                case 3:
                    Console.WriteLine("--------------------------------------------------------------------------------");
                    Console.WriteLine("List all users: ");
                    if (!ShowUsersAndAddNumbers())
                    {
                        Console.WriteLine("No Users! Add some new User in main menu!");
                    }
                    Console.WriteLine("--------------------------------------------------------------------------------");
                    MainInterface();
                    //To DO: BLL - get all Users
                    //       PL - show all Users
                    break;

                case 4:
                    Console.Write("\nEnter award Name: ");
                    string awardName = Console.ReadLine();
                    if (string.IsNullOrWhiteSpace(awardName))
                    {
                        Console.WriteLine("\n Name cannot be empty!\n");
                        Console.ReadKey();
                        goto case 4;
                    }
                    if (!AwardManager.AddAward(awardName))
                    {
                        Console.WriteLine("\nYou cannot create another award with the same name!\n");
                        Console.ReadKey();
                    }
                    else
                    {
                        Console.WriteLine($"\nAward '{awardName}' created!\n");
                    }
                    MainInterface();
                    //TO DO:BLL - Add Award
                    break;

                case 5:
                    Console.WriteLine("\nChoose which Award to delete:");
                    ShowAwardsAndAddNumbers();
                    Console.Write("\nEnter number of Award y whant to remove: ");
                    string numberOfAwardToRemove = Console.ReadLine();

                    if (string.IsNullOrWhiteSpace(numberOfAwardToRemove))
                    {
                        Console.WriteLine("\nThis field cannot be empty!");
                        Console.ReadKey();
                        goto case 5;
                    }
                    if (!AwardIDs.ContainsKey(int.Parse(numberOfAwardToRemove)))
                    {
                        Console.WriteLine("Wrong number of User!");
                        Console.ReadKey();
                        goto case 5;
                    }

                    Guid  awardGuid     = AwardIDs[int.Parse(numberOfAwardToRemove)];
                    Award awardToRemove = AwardManager.GetAwardByID(awardGuid);

                    if (AwardManager.RemoveAward(awardToRemove))
                    {
                        Console.WriteLine($"\nAward {awardToRemove} removed!\n");
                        Console.WriteLine("Awards: ");
                        ShowAllItems(AwardManager.GetAllAwards());
                        Console.ReadKey();
                        MainInterface();
                    }
                    else
                    {
                        Console.WriteLine("\nAward deletion failed!\n");
                        Console.WriteLine("\nPress any button to return to the main menu...\n");
                        Console.ReadKey();
                        MainInterface();
                    }
                    //TO DO:BLL - Remove Award
                    break;

                case 6:
                    Console.WriteLine("---------------------------------------------------------------------------------");
                    Console.WriteLine("List all awards: ");
                    if (!ShowAwardsAndAddNumbers())
                    {
                        Console.WriteLine("No Awards! Add some new Award in main menu!");
                    }
                    Console.WriteLine("---------------------------------------------------------------------------------");
                    MainInterface();
                    //TO DO:BLL - Get All Awards
                    //      PL - Show All Awards
                    break;

                case 7:
                    ShowUsersAndAddNumbers();
                    Console.Write("\nEnter the USER number to whom you would like to give an award: ");
                    string numberOfUserForAward = Console.ReadLine();

                    if (string.IsNullOrWhiteSpace(numberOfUserForAward))
                    {
                        Console.WriteLine("\nThis field cannot be empty!");
                        Console.ReadKey();
                        goto case 7;
                    }
                    if (!UserIDs.ContainsKey(int.Parse(numberOfUserForAward)))
                    {
                        Console.WriteLine("Invalid User number!");
                        goto case 7;
                    }

                    Guid userID = UserIDs[int.Parse(numberOfUserForAward)];

                    ShowAwardsAndAddNumbers();
                    Console.Write("\nEnter the AWARD number: ");
                    string numberOfAwardForUser = Console.ReadLine();

                    if (string.IsNullOrWhiteSpace(numberOfAwardForUser))
                    {
                        Console.WriteLine("\nThis field cannot be empty!");
                        Console.ReadKey();
                        goto case 7;
                    }
                    if (!AwardIDs.ContainsKey(int.Parse(numberOfAwardForUser)))
                    {
                        Console.WriteLine("Invalid Award number!");
                        return;
                    }

                    Guid awardID = AwardIDs[int.Parse(numberOfAwardForUser)];

                    if (AwardManager.AddAwardToUser(userID, awardID))
                    {
                        Console.WriteLine($@"Award - ""{AwardManager.GetAwardByID(awardID).Name}"" successfully added to User {UserManager.GetUserByID(userID).Name}!");
                        Console.ReadKey();
                    }
                    else
                    {
                        Console.WriteLine("\nYou cannot revard USER the same AWARD multiple times!");
                        Console.ReadKey();
                        Console.Write("\nWant to return to the main menu? y/n ");
                        ConsoleKeyInfo btn = Console.ReadKey();
                        if (btn.Key == ConsoleKey.Y)
                        {
                            MainInterface();
                        }
                        goto case 7;
                    }
                    MainInterface();
                    //TO DO:Bll,PL - Add Award to User
                    break;

                case 8:
                    ShowUsersAndAddNumbers();
                    Console.WriteLine("Enter the number of the USER you would like to view awards: ");
                    string numberOfUserToShowAwards = Console.ReadLine();

                    if (string.IsNullOrWhiteSpace(numberOfUserToShowAwards))
                    {
                        Console.WriteLine("\nThis field cannot be empty!");
                        Console.ReadKey();
                        goto case 8;
                    }
                    if (!UserIDs.ContainsKey(int.Parse(numberOfUserToShowAwards)))
                    {
                        Console.WriteLine("Invalid User number!");
                        goto case 8;
                    }

                    Guid    userToFindByID  = UserIDs[int.Parse(numberOfUserToShowAwards)];
                    User    newUserForAward = UserManager.GetUserByID(userToFindByID);
                    Award[] userAwards      = AwardManager.GetUserAwards(newUserForAward);
                    Thread.Sleep(50);
                    if (userAwards.Length == 0)
                    {
                        Console.WriteLine(newUserForAward.ToString());
                        Console.WriteLine($"Sorry...This User {newUserForAward.Name} has no Awards yet, or this Award was deleted...");
                    }
                    else
                    {
                        Console.WriteLine($"\nUser number {numberOfUserToShowAwards}:\n{newUserForAward.ToString()}\n");
                        Console.WriteLine($"Has Awards :");
                        ShowAllItems(userAwards);
                    }
                    //ToDo: Get User Awards - BLL,PL
                    MainInterface();
                    break;

                case 9:
                    Console.WriteLine("\nChoose which User Awards to delete:");
                    ShowUsersAndAddNumbers();
                    Console.Write("\nEnter number of User: "******"\nThis field cannot be empty!");
                        Console.ReadKey();
                        goto case 9;
                    }
                    if (!UserIDs.ContainsKey(int.Parse(userNameToDeleteAllAwards)))
                    {
                        Console.WriteLine("Wrong number of User!");
                        Console.ReadKey();
                        goto case 9;
                    }

                    Guid IDToDeleteAwards     = UserIDs[int.Parse(userNameToDeleteAllAwards)];
                    User userIDToDeleteAwards = UserManager.GetUserByID(IDToDeleteAwards);

                    if (AwardManager.DeleteUserAwards(userIDToDeleteAwards))
                    {
                        Console.WriteLine($"\nAll Users {userIDToDeleteAwards.Name} Awards successfully removed!");
                        Award[] userAwardsToDelete = AwardManager.GetUserAwards(userIDToDeleteAwards);
                        if (userAwardsToDelete.Length == 0)
                        {
                            Console.WriteLine(userIDToDeleteAwards.ToString());
                            Console.WriteLine("\nAll Award of this User deleted!");
                            Console.ReadKey();
                            MainInterface();
                        }
                        else
                        {
                            Console.WriteLine("Cant delete this Awards...");
                            Console.ReadKey();
                            MainInterface();
                        }
                        Console.ReadKey();
                        MainInterface();
                    }
                    else
                    {
                        Console.WriteLine("User dont have Awards!");
                        Console.ReadKey();
                        MainInterface();
                    }
                    break;

                case 10:
                    //ToDO: Show All Users Awards-BLL
                    if (!ShowAllUsersAwards())
                    {
                        Console.WriteLine("No Users! Add some new User in main menu!");
                    }
                    Console.ReadKey();
                    MainInterface();
                    break;

                case 11:
                    ChangeDALType();
                    break;

                case 12:
                    return;
                }
            }
            else
            {
                Console.WriteLine("Wrong number!");
                MainInterface();
            }
        }