Пример #1
0
        override public int RestoreHealth(float amnt)
        {
            int restoredamnt = base.RestoreHealth(amnt);

            CIO.Print("restored " + restoredamnt + "health");
            return(restoredamnt);
        }
Пример #2
0
        /// <summary>
        /// Open a user dialog which allows th user navigate through the NPCs Inventory and take Items
        /// </summary>
        public void loot()
        {
            if (!this.inventory.ContainsAnyItems())
            {
                CIO.Print(this.name + "'s inventory is empty");
                return;
            }
            GenericOption takeAllOption  = new GenericOption("take all");
            Optionhandler oh             = new Optionhandler(this.name + "'s inventory ", true);
            Option        selectedOption = null;

            //the user stays inside the inventory until all items are gon or he picks exit
            while (selectedOption != Optionhandler.Exit && this.inventory.ContainsAnyItems())
            {
                List <Item> allitems = this.inventory.GetAllItems();
                oh.ClearOptions();
                oh.AddOptions(Optionhandler.ItemToOption(allitems));
                oh.AddOption(takeAllOption);
                selectedOption = oh.selectOption();
                if (selectedOption == takeAllOption)
                {
                    foreach (Item i in allitems)
                    {
                        Inventory.transferItem(this.inventory, Player.getInstance().inventory, i);
                    }
                }
                else
                {
                    Inventory.transferItem(this.inventory, Player.getInstance().inventory, (Item)selectedOption);
                }
            }
        }
Пример #3
0
        public static Player CharacterSelection()
        {
            Game game = new Game();

            Console.WriteLine("Choose Character");
            Console.WriteLine("");
            String[] CharacterSelect = { "Assassin", "Mage", "Tank" };

            int MenuSelection = CIO.PromptForMenuSelection(CharacterSelect, true);

            if (MenuSelection == 1)
            {
                Player player = new Assassin();
                return(player);
            }
            else if (MenuSelection == 2)
            {
                Player player = new Mage();
                return(player);
            }
            else if (MenuSelection == 3)
            {
                Player player = new Tank();
                return(player);
            }
            else
            {
                game.BeginGame();
                return(null);
            }
        }
Пример #4
0
        static void Main(string[] args)
        {
            Console.WriteLine("files must be in the format \"filenameXX\"");
            bool keepGoing = true;

            while (keepGoing)
            {
                Console.WriteLine();
                switch (CIO.PromptForMenuSelection(new string[] { "Increment files with 2 trailing numbers", "Increment folders with 2 trailing numbers", "Convert trailing XX into numbers" }, true))
                {
                case 1:
                    Increment();
                    break;

                case 2:
                    IncrementFolders();
                    break;

                case 3:
                    Change();
                    break;

                case 0:
                    keepGoing = false;
                    break;
                }
            }
        }
Пример #5
0
        public bool Defend(DurakPlayer def, Card beat)
        {
            Console.Clear();
            DisplayTrump();
            Console.WriteLine("Attacker playerd:\t" + beat.ToString());
            Card defense;

            Console.WriteLine();
            List <string> options = def.DisplayHand();
            bool          valid   = false;

            do
            {
                int choice = CIO.PromptForMenuSelection(options, true);
                if (choice == 0)
                {
                    def.playerHand.AddRange(playfield);
                    playfield.Clear();
                    return(false);
                }
                else
                {
                    defense = def.playerHand[choice - 1];
                    valid   = CheckDefense(beat, defense);
                }
            } while (!valid);
            playfield.Add(defense);
            def.playerHand.Remove(defense);
            return(true);
        }
Пример #6
0
        public static void Run()
        {
            int choice = CIO.PromptForMenuSelection(menu, true);

            switch (choice)
            {
            case 1:
                GenerateLoots(1);
                break;

            case 2:
                GenerateLoots(rand.Next(1, 11));
                break;

            case 3:
                int n = GenerateN();
                GenerateLoots(n);
                break;

            case 4:
                DemonstrateConsumables();
                break;

            default:
                break;
            }
        }
Пример #7
0
        public string PromptForInput()
        {
            Console.BackgroundColor = ConsoleColor.Blue;
            string input = CIO.PromptForInput("Please entre a beautiful message: ", false);

            return(input);
        }
Пример #8
0
        private static void MainMenu()
        {
            List <string> mainMenu = new List <string>()
            {
                "Manage Flash Cards", "Review"
            };
            int choice = CIO.PromptForMenuSelection(mainMenu, true);

            Console.WriteLine();
            switch (choice)
            {
            case 1:
                ManageFlashCards();
                break;

            case 2:
                Review();
                break;

            case 0:
                Console.WriteLine("Thank you for using Flash Cards.");
                break;

            default:
                break;
            }
        }
Пример #9
0
 public static void TaoTableXacNhanCa(List <cUserInfo> dsnv, DataRow[] arrRecs, DataTable table)
 {
     table.Rows.Clear();
     foreach (var dataRow in arrRecs)
     {
         var nv       = (cUserInfo)dataRow["cUserInfo"];
         var ngay     = (DateTime)dataRow["TimeStrNgay"];
         var ngayCong = nv.DSNgayCong.Find(item => item.Ngay == ngay);
         foreach (var CIO in ngayCong.DSVaoRa)
         {
             if (CIO.HaveINOUT < 0)
             {
                 continue;
             }
             var row = table.NewRow();
             row["UserEnrollNumber"] = nv.MaCC;            //0
             row["UserFullCode"]     = nv.MaNV;            //1
             row["UserFullName"]     = nv.TenNV;           //1
             row["TimeStrNgay"]      = ngay;               //2
             row["TimeStrVao"]       = CIO.Vao.Time;       //4
             row["TimeStrRaa"]       = CIO.Raa.Time;       //5
             row["ShiftCode"]        = CIO.CIOCodeFull();
             row["ShiftID"]          = CIO.ThuocCa.ID;     //9
             row["Cong"]             = CIO.Cong;           //20
             row["TongGioLam"]       = CIO.TG.GioLamViec5; //Danglam giophut
             row["TongGioThuc"]      = CIO.TG.GioThucTe5;  //Danglam giophut
             row["cUserInfo"]        = nv;
             row["cNgayCong"]        = ngayCong;
             row["cCheckInOut"]      = CIO;
             row["IsEdited"]         = false;            //CIO.IsEdited;
             table.Rows.Add(row);
         }
     }
 }
Пример #10
0
        static void Main(string[] args)
        {
            List <string> menuList = new List <string>();

            menuList.Add("ducks");
            menuList.Add("cabbage");
            menuList.Add("monster trucks");
            menuList.Add("pizza");
            menuList.Add("Resident Evil 7");

            Console.WriteLine(CIO.PromptForMenuSelection(menuList, true));
            Console.WriteLine(CIO.PromptForBool("You like trains. True or false?", "true", "false"));
            Console.WriteLine(CIO.PromptForByte("Please enter a byte between 0 and 3", 0, 3));
            Console.WriteLine(CIO.PromptForShort("Enter a Short between 0 and 15", 0, 15));
            Console.WriteLine(CIO.PromptForChar("Please enter a valid char between 2 and 9", (char)2, (char)9));
            Console.WriteLine(CIO.PromptForDecimal("Please enter a decimal between 1 and 2", 1, 2));
            Console.WriteLine(CIO.PromptForDouble("Please enter a Double between 16 and 24", 16, 24));
            Console.WriteLine(CIO.PromptForFloat("Please enter a valid float between 78 and 98", 78, 98));
            Console.WriteLine(CIO.PromptForInput("Please Enter your Name", true));
            Console.WriteLine(CIO.PromptForLong("Please Enter a valid long between 987 and 1029234", 987, 1029234));
            Console.WriteLine(CIO.PromptForInt("Please enter an int between 1 and 10", 1, 10));

            Console.WriteLine("Press any key to continue...");
            string input = Console.ReadLine();
        }
Пример #11
0
        public long Write(byte[] data)
        {
            ThrowIfStreamClosed();

            var remainingCapacity = CIO.StreamGetRemainingWriteCapacityBytes(Stream);

            if (remainingCapacity < data.Length)
            {
                throw new NotSupportedException("Not enough stream capacity to write data.");
            }

            var bytesWritten = 0L;

            fixed(byte *dataToWrite = data)
            {
                bytesWritten = CIO.StreamWrite(Stream, dataToWrite, 1);
            }

            if (bytesWritten != -1)
            {
                return(bytesWritten);
            }

            var rawError = CIO.StreamGetLastError(Stream);

            throw new IOException(ApiInterop.FromUtf8Cstr(rawError));
        }
Пример #12
0
        public int PromptGameVersion()
        {
            string[] options       = { "Player v Player", "Player v Computer", "Back To Main Menu" };
            int      menuSelection = CIO.PromptForMenuSelection(options, false);

            return(menuSelection);
        }
Пример #13
0
        private void loadRow(cUserInfo nhanvien_goc, DateTime ngayCong)
        {
            var cNgayCong = nhanvien_goc.DSNgayCong.FirstOrDefault(item => item.Ngay == ngayCong);

            if (cNgayCong == null || cNgayCong.HasCheck == false)
            {
                return;
            }
            foreach (var CIO in cNgayCong.DSVaoRa)
            {
                var row = m_Bang_ChiTiet.NewRow();
                row["UserEnrollNumber"] = nhanvien_goc.MaCC;
                row["UserFullName"]     = nhanvien_goc.TenNV;
                row["UserFullCode"]     = nhanvien_goc.MaNV;
                row["TimeStrNgay"]      = cNgayCong.Ngay;
                row["TimeStrVao"]       = (CIO.Vao != null) ? CIO.Vao.Time : (object)DBNull.Value;
                row["TimeStrRaa"]       = (CIO.Raa != null) ? CIO.Raa.Time : (object)DBNull.Value;
                row["ShiftCode"]        = CIO.CIOCodeFull();
                row["cUserInfo"]        = nhanvien_goc;
                row["cChkInOut"]        = CIO;
                row["cNgayCong"]        = cNgayCong;
                row["IsEdited"]         = CIO.IsEdited;
                m_Bang_ChiTiet.Rows.Add(row);
            }
        }
Пример #14
0
 /// <summary>
 /// Creates players and populates the class level Player[]. Based on the count passed in, if 1 then there's a human and AI, if 2 then there's 2 human players
 /// </summary>
 /// <param name="count">The count of human players there will be in the program</param>
 public static void CreatePlayers(int count)
 {
     //AI vs Human
     if (count == 1)
     {
         string playerName = CIO.PromptForInput("\nEnter your player's name: ", true).Trim();
         if (string.IsNullOrEmpty(playerName))
         {
             playerName = "Player";
         }
         players[0] = new HumanPlayer(playerName);
         players[1] = new AIPlayer();
     }
     //Human vs Human
     else
     {
         string playerName1 = CIO.PromptForInput("\nEnter in player 1's name: ", true).Trim();
         if (string.IsNullOrEmpty(playerName1))
         {
             playerName1 = "Player 1";
         }
         players[0] = new HumanPlayer(playerName1);
         string playerName2 = CIO.PromptForInput("\nEnter in player 2's name: ", true).Trim();
         if (string.IsNullOrEmpty(playerName2))
         {
             playerName2 = "Player 2";
         }
         players[1] = new HumanPlayer(playerName2);
     }
 }
Пример #15
0
 public static IOStream CreateFileStream(string fileName,
                                         OpenModes openModes = OpenModes.OpenModeRead | OpenModes.OpenModeWrite | OpenModes.OpenModeTruncate)
 {
     fixed(byte *fileNameBytes = ApiInterop.ToUtf8Cstr(fileName))
     {
         return(new IOStream(CIO.CreateFileStream(fileNameBytes, (CIO.OpenModes)openModes)));
     }
 }
Пример #16
0
        //static string fileLocation = "C:\\Users\\drago\\Downloads\\People Records\\people\\long";
        //static string fileLocationSerial = "C:\\Users\\drago\\Downloads\\People Records\\people\\longserialized";


        public static void Main(string[] args)
        {
            int choice;

            do
            {
                String[] menu = { "Add Employee", "Delete Employee", "Update Employee", "Serialize All Employees", "Find serialized employee", "Find Employee By ID", "Find Employee by Last Name", "Find All Employees with Same Last Name", "Print Serialized details", "Print all employees" };
                choice = CIO.PromptForMenuSelection(menu, true);

                switch (choice)
                {
                case 1:
                    AddEmployee(CIO.PromptForInt("Enter ID: ", 1, Int32.MaxValue), CIO.PromptForInput("Enter First Name: ", false), CIO.PromptForInput("Enter Last Name: ", false), CIO.PromptForInt("Enter Hire Date: ", 1, Int32.MaxValue));
                    break;

                case 2:
                    DeleteEmployee(CIO.PromptForInt("Enter Employee ID: ", 1, Int32.MaxValue));
                    break;

                case 3:
                    UpdateEmployee(CIO.PromptForInt("Enter ID: ", 1, Int32.MaxValue), CIO.PromptForInput("Enter First Name: ", false), CIO.PromptForInput("Enter Last Name: ", false), CIO.PromptForInt("Enter Hire Date: ", 1, Int32.MaxValue));
                    break;

                case 4:
                    SerializeAllEmployees();
                    break;

                case 5:
                    Console.WriteLine(GetSerializedEmployee(CIO.PromptForInt("Enter Employee ID: ", 1, Int32.MaxValue)).ToString());
                    break;

                case 6:
                    Console.WriteLine(FindEmployeeById(CIO.PromptForInt("Enter Employee ID: ", 1, Int32.MaxValue)).ToString());
                    break;

                case 7:
                    Console.WriteLine(FindEmployeeByLastName(CIO.PromptForInput("Enter Last Name: ", false)).ToString());
                    break;

                case 8:
                    string lastName = CIO.PromptForInput("Enter Last Name: ", false);
                    foreach (var f in FindAllEmployeesByLastName(lastName))
                    {
                        Console.WriteLine(f.ToString());
                    }
                    break;


                case 9:
                    PrintSerializedDetails(fileLocationSerial);
                    break;

                case 10:
                    printAllEmployees();
                    break;
                }
            } while (choice != 0);
        }
Пример #17
0
        private long ExtractFromZip(string fName, string entryName, string destPath)
        {
            ZipFile zf = null;

            System.IO.Stream zp  = null;
            FileStream       fs  = null;
            ZipEntry         ze  = null;
            long             ret = -1;

            try
            {
                zf = new ZipFile(fName);
                ze = zf.GetEntry(entryName);
                zp = zf.GetInputStream(ze);

                string pt = destPath;
                pt += "\\" + entryName;
                if (CIO.FileExists(pt))
                {
                    CIO.blRemoveFile(pt);
                }
                fs = new FileStream(pt, FileMode.CreateNew);
                int bt;
                while (true)
                {
                    bt = zp.ReadByte();
                    if (bt < 0)
                    {
                        break;
                    }
                    fs.WriteByte(CConvert.ToByte(bt));
                }
                ret = ze.Size;
            }
            catch (Exception ex)
            {
                CLog.stLogException(new Exception("ExtractFromZip:", ex));
                ret = -1;
            }
            finally
            {
                if (zf != null)
                {
                    zf.Close();
                }
                if (zp != null)
                {
                    zp.Close();
                }
                if (fs != null)
                {
                    fs.Close();
                }
                CIO.blRemoveFile(fName);
            }
            return(ret);
        }
Пример #18
0
 public void GiveXP(int amount)
 {
     CIO.Print("received " + amount + "XP");
     XP += amount;
     if (Level.XPToLevel(this.level + 1, this) <= 0)
     {
         levelUp();
     }
 }
Пример #19
0
        /// <summary>
        /// Prompts user to make decisions necessary for a turn in Nim
        /// 1) Choose one of several heaps to remove from
        /// 2) Choose an amount to take from the chosen heap
        /// That amount is then taken
        /// </summary>
        /// <param name="heaps"> The heaps provided as choices </param>
        public override void TakeTurn(Dictionary <string, Heap> heaps)
        {
            //Playern's Turn
            //| A - 3 | B - 3 |
            //1) Choose pile
            //2) Quit
            Console.WriteLine(name + "'s Turn");

            Console.Write("| ");
            foreach (Heap h in heaps.Values)
            {
                Console.Write(h + " | ");
            }
            Console.WriteLine();

            if (CIO.PromptForMenuSelection(new string[] { "Choose pile" }, true) == 0)
            {
                Environment.Exit(0);
            }

            //Choose a pile
            //1) Heap1
            //2) Heap2
            //etc
            int  heapIndex;
            Heap chosenHeap;

            do
            {
                Console.WriteLine("Choose a pile");
                heapIndex  = CIO.PromptForMenuSelection(heaps.Keys, false);
                chosenHeap = heaps.ElementAt(heapIndex - 1).Value;

                if (chosenHeap.IsEmpty)
                {
                    Console.WriteLine("That heap is empty");
                }
            } while (chosenHeap == null || chosenHeap.IsEmpty);



            int  amountToTake = 0;
            bool validAmount  = true;

            //Pick amount to take from Heap
            do
            {
                amountToTake = CIO.PromptForInt("Pick amount to take from " + chosenHeap.name + " (Between 1 and " + chosenHeap.Amount + ")", Int32.MinValue, Int32.MaxValue);

                validAmount = chosenHeap.TakeAmount(amountToTake);
                if (!validAmount)
                {
                    Console.WriteLine(amountToTake < 1 ? "That's too little" : "That's too much");
                }
            } while (!validAmount);
        }
Пример #20
0
    public static void BuildABiOS()
    {
        string outputPath = CABPath.ABBuildOutPutDir(RuntimePlatform.IPhonePlayer);

        CIO.CreatDir(outputPath);

        CABBuilder.BuildAssetBundles(BuildTarget.iOS);

        AssetDatabase.Refresh();
    }
Пример #21
0
        public static void TaoTableXacNhanLamThem(List <cUserInfo> dsnv, DataTable table)
        {        /*( ngaycong.TG.GioLamViec > XL2._08gio
                 || ngaycong.DSVaoRa.Exists(item => item.HaveINOUT==0
                 ||                                                                                                     && item.DaXN == false
                 ||                                                                                                     && item.TG.OLai > TimeSpan.Zero))*/
            table.Rows.Clear();
            foreach (var nv in dsnv)
            {
                var min = 2;
                var max = nv.DSNgayCong.Count - 3;
                List <cNgayCong> list3 = nv.DSNgayCong
                                         .Where(item => item.TG.GioLamViec > XL2._08gio ||
                                                item.DSVaoRa.Exists(subitem => subitem.HaveINOUT == 0 && subitem.DaXN == false &&
                                                                    subitem.TG.OLai > TimeSpan.Zero))
                                         .TakeWhile((item1, i) => (i >= min || i <= max)).ToList();


                foreach (var ngayCong in list3)
                {
                    foreach (var CIO in ngayCong.DSVaoRa)
                    {
                        if (CIO.HaveINOUT < 0)
                        {
                            continue;
                        }
                        var row = table.NewRow();
                        row["UserEnrollNumber"] = nv.MaCC;                                   //0
                        row["UserFullCode"]     = nv.MaNV;                                   //1
                        row["UserFullName"]     = nv.TenNV;                                  //1
                        row["TimeStrNgay"]      = ngayCong.Ngay;                             //2
                        row["TimeStrVao"]       = CIO.Vao.Time;                              //4
                        row["TimeStrRaa"]       = CIO.Raa.Time;                              //5
                        row["ShiftCode"]        = CIO.CIOCodeFull();
                        row["ShiftID"]          = CIO.ThuocCa.ID;                            //9
                        row["Cong"]             = CIO.Cong;                                  //20
                        row["TongGioLam"]       = CIO.TG.GioLamViec;                         //Danglam giophut
                        row["TongGioThuc"]      = CIO.TG.GioThuc;                            //Danglam giophut
                        row["DuyetCPVaoTre"]    = CIO.DuyetChoPhepVaoTre;                    //ver 4.0.0.8
                        row["DuyetCPRaSom"]     = CIO.DuyetChoPhepRaSom;                     //ver 4.0.0.8
                        row["VaoTreTuDo"]       = CIO.VaoTreTinhCV;                          //ver 4.0.0.8
                        row["RaSomTuDo"]        = CIO.RaaSomTinhCV;                          //ver 4.0.0.8
                        row["ChoBuGioTre"]      = CIO.ChoBuGioTre;                           //ver 4.0.0.8
                        row["ChoBuGioSom"]      = CIO.ChoBuGioSom;                           //ver 4.0.0.8
                        row["ChoBuPhepTre"]     = CIO.ChoBuPhepTre;                          //ver 4.0.0.8
                        row["TGBuPhepTre"]      = XacDinhTGBuPhep(CIO.BuCongPhepTreCongDon); //ver 4.0.0.8
                        row["ChoBuPhepSom"]     = CIO.ChoBuPhepSom;                          //ver 4.0.0.8
                        row["TGBuPhepSom"]      = XacDinhTGBuPhep(CIO.BuCongPhepSomCongDon); //ver 4.0.0.8
                        row["cUserInfo"]        = nv;
                        row["cNgayCong"]        = ngayCong;
                        row["cCheckInOut"]      = CIO;
                        table.Rows.Add(row);
                    }
                }
            }
        }
Пример #22
0
        /// <summary>
        /// The main menu, which recieves user input about game options like difficulty and game mode.
        /// </summary>
        public static void MainMenu()
        {
            //Prompt the user for their game mode (Choices are PvP and PvE).
            bool PvP = CIO.PromptForBool("Please choose your game mode: ", "PvP", "PvE", true);

            //Clear console for readability
            Console.Clear();

            //Prompt the user for their prefered difficulty
            Difficulty difficulty;

            switch (CIO.PromptForMenuSelection(new string[] { "Easy", "Medium", "Hard" }, false))
            {
            case 1:
                difficulty = Difficulty.Easy;
                break;

            case 2:
                difficulty = Difficulty.Medium;
                break;

            default:
                difficulty = Difficulty.Hard;
                break;
            }

            //Clear console for readability
            Console.Clear();

            //Prompt player 1 for their name.
            string p1name = CIO.PromptForInput("Player 1, please enter your name: ", false, true);

            //Clear console for readability
            Console.Clear();

            //If the game mode is PvP, also prompt player 2 for their name.
            string p2Name = "CPU";

            if (PvP)
            {
                p2Name = CIO.PromptForInput("Player 2, please enter your name: ", false, true);
            }

            //Clear console for readability
            Console.Clear();

            //Store all values and end the main menu.
            board           = new Gameboard(difficulty);
            board.P1Name    = p1name;
            board.P2IsHuman = PvP;
            if (PvP)
            {
                board.P2Name = p2Name;
            }
        }
Пример #23
0
        /// <summary>
        /// Prompts the player through the console to choose the how many players,
        /// set their names, and choose what game mode they want
        /// </summary>
        void SetupGame()
        {
            if (!CIO.PromptForBool("Welcome to the Game of Nim!\n1 Player or 2 Players in this match?", "1 Player", "2 Players"))
            {
                Players = new BasePlayer[] { new Player(), new Player() }
            }
            ;
            else
            {
                Players = new BasePlayer[] { new Player(), new CPU() }
            };

            int index = 1;

            foreach (Player p in Players.OfType <Player>())
            {
                string input = CIO.PromptForInput("Please enter your name: ", true);
                p.name = (input != string.Empty) ? input : $"Player {index}";
                if (input == string.Empty)
                {
                    Console.WriteLine("Name defaulted to 'Player " + index + "'");
                }
                index++;
            }

            foreach (CPU c in Players.OfType <CPU>())
            {
                c.name = "Computer";
            }

            switch (CIO.PromptForMenuSelection(new string[] { "Easy - heaps with 3 and 3", "Medium - heaps with 2, 5, 7", "Hard = heaps of 2, 3, 8, 9" }, false))
            {
            case 1:
                heaps = new Dictionary <string, Heap> {
                    { "A", new Heap("A", 3) }, { "B", new Heap("B", 3) }
                };
                break;

            case 2:
                heaps = new Dictionary <string, Heap> {
                    { "A", new Heap("A", 2) }, { "B", new Heap("B", 5) }, { "C", new Heap("C", 7) }
                };
                break;

            case 3:
                heaps = new Dictionary <string, Heap> {
                    { "A", new Heap("A", 2) }, { "B", new Heap("B", 3) }, { "C", new Heap("C", 8) }, { "D", new Heap("D", 9) }
                };
                break;

            default:
                Environment.Exit(0);
                break;
            }
        }
Пример #24
0
        /// <summary>
        /// Attack the NPC with damage amoutn + type. Removes the health after substraction blocked damage
        /// </summary>
        override public int receiveDamage(int amount, DamageType type)
        {
            int dmg = base.receiveDamage(amount, type);

            CIO.Print(this.name + " lost " + dmg + " HP. " + health + "HP remaining");
            if (health <= 0)
            {
                this.alive = false;
            }
            return(dmg);
        }
Пример #25
0
 /// <summary>
 /// reprint the text and Optionhandler (the optionhandler  gets re-evaluated)
 /// </summary>
 public void Enter()
 {
     if (text != null)
     {
         CIO.Print(text);
     }
     if (myOptionhandler != null)
     {
         myOptionhandler.printOptions();
     }
 }
Пример #26
0
        void tryflee()
        {
            Random r = new Random();
            double d = r.NextDouble();

            if (d > 0.1)//
            {
                CIO.Print("you have been brutally slaughtered.");
                Program.gameOver();
            }
        }
Пример #27
0
        override public int receiveDamage(int amount, DamageType type)
        {
            int dmg = base.receiveDamage(amount, type);

            CIO.Print(" You lost " + dmg + " HP. " + health + "HP remain");
            if (health <= 0)
            {
                Program.gameOver();
            }
            return(dmg);
        }
        /// <summary>
        /// It updates install shields for affiliates.
        /// </summary>
        public bool UpdateSkin()
        {
            bool ret = true;

            try
            {
                ArrayList ar = new ArrayList();

                //1. Create file list xml
                string xmlString = "";
                string filePath  = "";
                ar.Clear();
                ar.Add("@SkinsID");
                ar.Add(m_SkinsID);
                DataTable oDTXML = oDB.GetDataTable(DbGetClientApplicationFileListForXML, CommandType.StoredProcedure, ar);
                foreach (DataRow bRow in oDTXML.Rows)
                {
                    xmlString += bRow[0].ToString();
                }
                xmlString = String.Format("<{0}>{1}</{0}>", xmlTopRoot, xmlString);
                filePath  = WSCommon.GetAffiliatePath(m_SkinsID, false);
                if (!filePath.Trim().EndsWith("\\"))
                {
                    filePath += "\\";
                }
                filePath += xmlFileName;
                CIO.WriteToFile(filePath, xmlString);

                //2. Parse installation code file
                ParseInstallFile(m_SkinsID);

                DataTable tbAff = oDB.GetDataTable(DbGetAffiliateList, CommandType.StoredProcedure, new object[] { "@SkinID", m_SkinsID });
                foreach (DataRow dr in tbAff.Rows)
                {
                    //3. Rebuild installation for affiliate
                    if (Convert.ToInt32(dr["StatusID"]) == 4)
                    {
                        int  AffID = Convert.ToInt32(dr["id"]);
                        bool bRet  = CreateSkin(m_SkinsID, AffID);
                        if (!bRet)
                        {
                            CLog.stWriteLog(CLog.LogSeverityLevels.lslError, this, String.Format("Error occured for Skin {0}, AffID {1}<br>", m_SkinsID, AffID));
                            ret = false;
                        }
                    }
                }
            }
            catch (Exception oEx)
            {
                CLog.stLogException(new Exception("UpdateSkin:", oEx));
                ret = false;
            }
            return(ret);
        }
Пример #29
0
        private static void IncrementFolders()
        {
            string folderPath     = "";
            FolderBrowserDialog f = new FolderBrowserDialog();
            DialogResult        d = f.ShowDialog();

            if (d == DialogResult.OK)
            {
                folderPath = f.SelectedPath;
                string[] folders = Directory.GetDirectories(folderPath);
                if (folders.Count() != 0)
                {
                    if (CIO.PromptForBool($"{folders.Count()} folders found. Continue? (y/n)", "y", "n"))
                    {
                        int           inc   = CIO.PromptForInt("How much do you want to increment each folder by?", 0, int.MaxValue);
                        List <string> names = new List <string>();
                        foreach (string folder in folders)
                        {
                            try
                            {
                                int num = int.Parse(folder.Substring(folder.Length - 2, 2));
                                num += inc;
                                string   folderBeginning = folder.Substring(0, folder.Length - 2);
                                string[] path            = folder.Split('\\');
                                string   name            = path[path.Count() - 1];
                                name = name.Substring(0, name.Length - 2);
                                Directory.CreateDirectory(folderPath + "\\TEMPFOLDERDONOTTOUCHWHILEPROGRAMISRUNNINGYEEEEEEET");
                                Directory.Move(folder, folderPath + $"\\TEMPFOLDERDONOTTOUCHWHILEPROGRAMISRUNNINGYEEEEEEET\\{name}{(num <= 9 ? "0" + num : num.ToString())}");
                                names.Add(folderPath + $"\\TEMPFOLDERDONOTTOUCHWHILEPROGRAMISRUNNINGYEEEEEEET\\{name}{(num <= 9 ? "0" + num : num.ToString())}");
                            }
                            catch (Exception e)
                            {
                                Console.WriteLine($"{folder} will be skipped: " + e.Message);
                            }
                        }
                        foreach (string path in names)
                        {
                            //no catches
                            Directory.Move(path, folderPath + $"\\{(path.Split('\\')[path.Split('\\').Count() - 1])}");
                        }
                        if (names.Count > 0)
                        {
                            Directory.Delete(Directory.GetParent(names[0].Split('.')[0]).FullName);
                        }
                        //
                    }
                }
                else
                {
                    Console.WriteLine("No Folders found");
                }
            }
        }
Пример #30
0
        public bool EndPostFileArch(string subFolder, string fileName, string entryName, long fileSize, long origFileSize, bool IsFileArchive)
        {
            try
            {
                if (!CIO.FileExists(fileName))
                {
                    CLog.stWriteLog(CLog.LogSeverityLevels.lslError, this, fileName + " : does'nt exist");
                    return(false);
                }

                FileInfo fi = new FileInfo(fileName);
                if (fileSize != fi.Length)
                {
                    CLog.stWriteLog(CLog.LogSeverityLevels.lslError, this, String.Format(Path.GetFileName(fileName) + " : wrong archive file size {0} , {1} ", fileSize, fi.Length));
                    return(false);
                }

                string destPath = GetDestinationPath(subFolder);
                if (IsFileArchive)
                {
                    long fSize = ExtractFromZip(fileName, entryName, destPath);
                    if (fSize < 0)
                    {
                        CLog.stWriteLog(CLog.LogSeverityLevels.lslError, this, fileName + " : error decoding file");
                        return(false);
                    }
                }
                else
                {
                    if (File.Exists(destPath + "\\" + entryName))
                    {
                        File.Delete(destPath + "\\" + entryName);
                    }
                    File.Move(fileName, destPath + "\\" + entryName);
                }

                fi = new FileInfo(destPath + "\\" + entryName);
                if (fi.Length != origFileSize)
                {
                    CLog.stWriteLog(CLog.LogSeverityLevels.lslError, this,
                                    String.Format(entryName + " : wrong destination file size {0} , {1}", origFileSize, fi.Length));
                    CIO.blRemoveFile(destPath + "\\" + entryName);
                    return(false);
                }
            }
            catch (Exception ex)
            {
                CLog.stLogException(new Exception("EndPostFile:", ex));
                return(false);
            }

            return(true);
        }