Example #1
0
        private void GetMechs(int mechGroupRow)
        {
            LanceName = new LinqDataAccess().getMechGroupName(mechGroupRow);

            foreach (Mech mech in entities.Mechs)
            {
                if (mech.MechGroupId == mechGroupRow)
                {
                    Mechs.Add(new BaseMech(mech));
                    LanceAttack += (int)mech.Attack;
                    LanceDefense += (int)mech.Defense;
                }
            }
        }
Example #2
0
        protected void OnClickBattle(object sender, EventArgs e)
        {
            Random rnd = new Random();
            int counter = 1;
            int compLanceGroupRow = 0;
            int userLanceGroupRow = Convert.ToInt32(ddlLanceList.SelectedValue);

            int numberOfRows = new LinqDataAccess().countMechGroupRows();        //Determine the number of rows in the MechGroup table.
            int randomizeCompLanceGroupRow = rnd.Next(1, numberOfRows);          //Choose a random row from the MechGroup table.
            foreach (MechGroup mechgroup in entities.MechGroups)                 //Find the Id of the random row in the MechGroup table.
            {
                if (counter == randomizeCompLanceGroupRow)
                {
                    compLanceGroupRow = mechgroup.Id;
                    break;
                }
                counter++;
            }

            Lance userLance = new Lance(userLanceGroupRow);                //Retrieve the user's chosen lance and apply its attack/defense modifier.
            Lance compLance = new Lance(compLanceGroupRow);                //Retrieve the computer's random lance and apply its attack/defense modifier.

            BattleResult(userLance, compLance, rnd);
        }