예제 #1
0
        public static void Main()
        {
            ///Introduction
            Console.WriteLine("Welcome to Yahztee!");
            Console.WriteLine("");
            Console.WriteLine("The objective of Yahtzee is to get as many points as possible by rolling five dice and getting" +
                              " certain combinations of dice.");
            Console.WriteLine("");
            Console.WriteLine("Enter q or quit at any time to quit the game.");
            Console.WriteLine("");
            var player1 = new Human();
            var player2 = new AI2();

            Console.WriteLine("You will be playing against the computer, my name is {0}!", player2.GetName());
            Console.WriteLine("");
            Console.WriteLine("Press enter to begin!");
            Console.ReadKey();

            /// Main Game Loop

            while (player1.PlayerFinished() == false && player2.PlayerFinished() == false)
            {
                Console.Clear();
                PrintCard(player1, player2);
                player1.TakeTurn();
                player2.TakeTurn();
            }
            PrintCard(player1, player2);
            GameOver(player1, player2);
            Quit();
            /// Write function that goes here and calculates who had the higher score and prints who won the game.
        }
예제 #2
0
파일: World.cs 프로젝트: Zarokhan/Pong
        public void Update(float delta)
        {
            if (c1 != null)
            {
                c1.Update(p1);
            }
            if (c2 != null)
            {
                c2.Update(p2);
            }
            if (playerAI != null)
            {
                playerAI.Update(p2, ball);
            }
            if (AI2 != null)
            {
                AI2.Update(p1, ball);
            }
            p1.Update(delta);
            p2.Update(delta);

            ball.Update(delta);

            HorizontalCollision(delta);
            VerticalCollision();
        }
예제 #3
0
        /// <summary>
        /// 前一交易日
        /// </summary>
        /// <param name="ld_date_last">當前交易日期</param>
        /// <param name="sheet">第N個工作表</param>
        /// <returns></returns>
        public DateTime GetDateLast(DateTime ld_date_last, int sheet)
        {
            object[] parms =
            {
                ":ld_date_last", ld_date_last
            };

            DateTime dateTime = DateTime.MinValue;

            switch (sheet)
            {
            case 0:
                string    sql      = @"select nvl(max(mg1_date),to_date('1901/1/1','yyyy/mm/dd'))
                          from ci.mg1
                         where mg1_date < :ld_date_last";
                DataTable dtResult = db.GetDataTable(sql, parms);
                dateTime = dtResult.Rows[0][0].AsDateTime();
                break;

            case 1:
                string dateLast = new AI2().GetLastSumTypeDate("D", "2", "S", ld_date_last);
                dateTime = dateLast.AsDateTime();
                break;

            default:
                break;
            }

            return(dateTime);
        }
예제 #4
0
 /// <summary>
 /// 證期局七組月報
 /// </summary>
 /// <param name="FilePath">Excel_Template</param>
 /// <param name="datetime">em_month.Text</param>
 public B30310(string FilePath, string datetime)
 {
     daoAI2       = new AI2();
     daoAI3       = new AI3();
     dao30310     = new D30310();
     _lsFile      = FilePath;
     _emMonthText = datetime;
 }
예제 #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="FilePath">Excel_Template</param>
        /// <param name="datetime">em_month.Text</param>
        public B30393(Workbook workbook, string datetime)
        {
            _workbook    = workbook;
            _emMonthText = datetime;

            daoAI2 = new AI2();
            daoAI3 = new AI3();
            b30398 = new B30398(workbook, datetime);
        }
예제 #6
0
	public void stuff(AI2 other)
	{
		int x = 7;
		other.val = x;
		val = x;
		x = other.val;
		x = val;
		val = other.val;
	}
예제 #7
0
    public void stuff(AI2 other)
    {
        int x = 7;

        other.val = x;
        val       = x;
        x         = other.val;
        x         = val;
        val       = other.val;
    }
예제 #8
0
        public W30722(string programID, string programName) : base(programID, programName)
        {
            daoRPT   = new RPT();
            daoAM2   = new AM2();
            daoAI2   = new AI2();
            daoRamm1 = new RAMM1();

            InitializeComponent();
            this.Text             = _ProgramID + "─" + _ProgramName;
            txtDate.DateTimeValue = GlobalInfo.OCF_DATE;

            ExportShow.Hide();
        }
예제 #9
0
        public W30400(string programID, string programName) : base(programID, programName)
        {
            InitializeComponent();

            this.Text            = _ProgramID + "─" + _ProgramName;
            txtMon.DateTimeValue = GlobalInfo.OCF_DATE;
            txtMon.Text          = GlobalInfo.OCF_DATE.ToString("yyyy/MM");

            dao30400 = new D30400();
            daoAI2   = new AI2();

#if DEBUG
            txtMon.DateTimeValue = DateTime.ParseExact("2012/07", "yyyy/MM", null);
            this.Text           += "(開啟測試模式),Date=2012/07";
#endif
        }
예제 #10
0
    public static int[] ReRoll(int[] dice) //method to re-roll certain dice
    {
        Console.WriteLine("\nPlease enter any letter from A to E to reroll that die");
        Console.Write("Please enter letters to reroll: ");
        Console.WriteLine(AI2.HoldDice(dice));
        string letters          = AI2.HoldDice(dice);
        var    userInputLetters = letters.Replace(" ", "").ToUpper();
        var    userInputList    = userInputLetters.ToCharArray().ToList();

        userInputList = userInputList.Distinct().ToList();

        var diceValue = random.Next(1, 7);

        for (var i = 0; i < userInputList.Count; i++)
        {
            if (userInputList[i] == 'A')
            {
                dice[0] = diceValue;
            }
            else if (userInputList[i] == 'B')
            {
                dice[1] = diceValue;
            }
            else if (userInputList[i] == 'C')
            {
                dice[2] = diceValue;
            }
            else if (userInputList[i] == 'D')
            {
                dice[3] = diceValue;
            }
            else if (userInputList[i] == 'E')
            {
                dice[4] = diceValue;
            }
        }

        char[] chars = { 'A', 'B', 'C', 'D', 'E' };
        Array.Sort(dice);
        for (int j = 0; j < dice.Length; j++)
        {
            Console.Write("{0}: {1}  ", chars[j], dice[j]);
        }
        Console.WriteLine("");
        return(dice);
    }
예제 #11
0
        public W30055(string programID, string programName) : base(programID, programName)
        {
            InitializeComponent();
            this.Text = _ProgramID + "─" + _ProgramName;

            GridHelper.SetCommonGrid(gvMsg);
            gcMsg.Visible = false;
            gvMsg.OptionsBehavior.Editable            = false;
            gvMsg.OptionsBehavior.AutoPopulateColumns = true;
            gvMsg.OptionsView.ColumnAutoWidth         = true;

            dtMsg = new DataTable("ProcessMessage");
            dtMsg.Columns.Add(new DataColumn("SheetName"));
            dtMsg.Columns.Add(new DataColumn("SheetSubTitle"));
            dtMsg.Columns.Add(new DataColumn("SubMsg"));
            dtMsg.Columns.Add(new DataColumn("Msg"));

            dao30055 = new D30055();
            amif     = new AMIF();
            ai2      = new AI2();
        }
예제 #12
0
        /// <summary>
        /// 2.8 匯率期貨行情表
        /// 2.10商品期貨行情表
        /// </summary>
        /// <param name="ws"></param>
        /// <param name="tradeDate"></param>
        /// <param name="as_type">E=匯率期貨行情表,C=商品期貨行情表</param>
        protected bool wf_30055_prod_subtype(Worksheet ws, DateTime tradeDate, string as_type = "E")
        {
            string sheetName     = "Sheet1";
            string sheetSubTitle = (as_type == "E" ? "匯率期貨行情表" : "商品期貨行情表");

            labMsg.Text = string.Format("{0} 資料轉出中......", sheetName);
            this.Refresh();

            //2.8.1 get 匯率類/商品類 前一交易日
            DateTime tempDate = tradeDate.AddDays(-30);
            DateTime lastDate = new AI2().GetLastDate(tradeDate, "D", "%", as_type);

            if (lastDate == DateTime.MinValue)
            {
                lastDate = tradeDate;
            }

            //2.8.2 讀取資料
            DataTable dtFuture = dao30055.wf_30055_prod_subtype(tradeDate.ToString("yyyyMMdd"), lastDate.ToString("yyyyMMdd"), as_type);

            if (dtFuture.Rows.Count <= 0)
            {
                showMsg(sheetName, sheetSubTitle, "無資料");
                return(false);
            }

            //2.8.3 write data
            //順序都連續並且固定,所以可以用import
            int rowBegin = dtFuture.Rows[0]["seq_no"].AsInt() - 1;//rowIndex是參考RPT的rpt_level_1=seq_no

            dtFuture.Columns.Remove("apdk_name");
            dtFuture.Columns.Remove("amif_settle_date");
            dtFuture.Columns.Remove("kind_id2");
            dtFuture.Columns.Remove("seq_no");
            ws.Import(dtFuture, false, rowBegin, 2);

            showMsg(sheetName, sheetSubTitle, dtFuture.Rows.Count.ToString());
            flag++;
            return(true);
        }
예제 #13
0
        protected override ResultStatus Export()
        {
            try {
                #region 輸入&日期檢核

                //if (!txtStartDate.IsDate(txtStartDate.Text , CheckDate.Start)
                //      || !txtEndDate.IsDate(txtEndDate.Text , CheckDate.End)) {
                //   return ResultStatus.Fail;
                //}

                if (string.Compare(txtStartDate.Text, txtEndDate.Text) > 0)
                {
                    MessageDisplay.Error(CheckDate.Datedif, GlobalInfo.ErrorText);
                    return(ResultStatus.Fail);
                }
                #endregion

                //1. ready
                panFilter.Enabled = false;
                labMsg.Visible    = true;
                labMsg.Text       = "開始轉檔...";
                this.Cursor       = Cursors.WaitCursor;
                this.Refresh();
                Thread.Sleep(5);

                //2. copy template xls to target path
                string excelDestinationPath = PbFunc.wf_copy_file(_ProgramID, _ProgramID);

                //3. open xls
                Workbook workbook = new Workbook();
                workbook.LoadDocument(excelDestinationPath);

                //4. 年月表頭
                DataTable dtAi2Ymd = new AI2().ListWeek(txtStartDate.DateTimeValue, txtEndDate.DateTimeValue, "D", "F");
                if (dtAi2Ymd.Rows.Count <= 0)
                {
                    MessageDisplay.Info(string.Format("{0}~{1},{2}-年月,無任何資料!", StartDate, EndDate, _ProgramID), GlobalInfo.ResultText);
                    WriteLog(string.Format("{0}~{1},{2}-年月,無任何資料!", StartDate, EndDate, _ProgramID));
                }//if (dtAi2Ymd.Rows.Count <= 0)

                //4.1處理資料型態
                DataTable dtYmd = dtAi2Ymd.Clone();                   //轉型別用的datatable
                dtYmd.Columns["startDate"].DataType = typeof(string); //將原DataType(datetime)轉為string
                dtYmd.Columns["endDate"].DataType   = typeof(string);
                foreach (DataRow row in dtAi2Ymd.Rows)
                {
                    dtYmd.ImportRow(row);
                }

                for (int i = 0; i < dtYmd.Rows.Count; i++)
                {
                    dtYmd.Rows[i]["startDate"] = Convert.ToDateTime(dtAi2Ymd.Rows[i]["startDate"]).ToString("yyyy/MM/dd");
                    dtYmd.Rows[i]["endDate"]   = Convert.ToDateTime(dtAi2Ymd.Rows[i]["endDate"]).ToString("yyyy/MM/dd");
                }


                //5. 填資料
                bool res1 = false, res2 = false, res3 = false;
                int  rowNum = 2;
                res1 = wf_30417(workbook, SheetNo.tradeSum, rowNum, dtYmd);
                res2 = wf_30418(workbook, SheetNo.dailyAvg, rowNum, dtYmd);
                res3 = wf_30419(workbook, SheetNo.oint, rowNum, dtYmd);

                if (!res1 && !res2 && !res3)
                {
                    File.Delete(excelDestinationPath);
                    return(ResultStatus.Fail);
                }

                //6. save
                workbook.SaveDocument(excelDestinationPath);
                labMsg.Visible = false;

                if (FlagAdmin)
                {
                    System.Diagnostics.Process.Start(excelDestinationPath);
                }

                return(ResultStatus.Success);
            } catch (Exception ex) {
                WriteLog(ex);
            } finally {
                panFilter.Enabled = true;
                labMsg.Text       = "";
                labMsg.Visible    = false;
                this.Cursor       = Cursors.Arrow;
            }
            return(ResultStatus.Fail);
        }