private void ASCIIWriteShip(IDNumber ctrlIdx, Ship ship, char character, ConsoleColor colorText, ConsoleColor colorBack) { foreach (Coordinates coord in ship.Locations) { ModifyASCII(ctrlIdx, coord.X, coord.Y, character, colorText, colorBack); } }
public IDNumber NextTurn() { if (turns.Count == 1) { CurrentTurnPlayer = turns[0]; return(CurrentTurnPlayer); } int currentTurnIdx; for (currentTurnIdx = 0; currentTurnIdx < turns.Count; currentTurnIdx++) { if (turns[currentTurnIdx] == CurrentTurnPlayer) { break; } } for (int i = 1; i < turns.Count; i++) { IDNumber plr = turns[(currentTurnIdx + i) % turns.Count]; if (Match.Teams[DeadTeam].Members.Contains(plr)) { continue; } return(plr); } return(CurrentTurnPlayer); }
public List <IDNumber> SelectIDNumber(IDNumber parameter) { List <IDNumber> list = new List <IDNumber>(); try { var query = from a in _dataContext.IDNumbers .WhereIf(parameter.SlNo != 0, q => q.SlNo == parameter.SlNo) .WhereIf(!String.IsNullOrEmpty(parameter.IDNo), q => q.IDNo == parameter.IDNo) .WhereIf(!String.IsNullOrEmpty(parameter.IDTypeId), q => q.IDTypeId == parameter.IDTypeId) .WhereIf(!String.IsNullOrEmpty(parameter.CompanyId), q => q.CompanyId == parameter.CompanyId) .WhereIf(!String.IsNullOrEmpty(parameter.LocationId), q => q.LocationId == parameter.LocationId) .WhereIf(!String.IsNullOrEmpty(parameter.EntryBy), q => q.EntryBy == parameter.EntryBy) .WhereIf(parameter.DateOfEntry.HasValue, q => q.DateOfEntry == parameter.DateOfEntry.Value) .WhereIf(parameter.IDYear.HasValue, q => q.IDYear == parameter.IDYear.Value) orderby a.IDNo ascending select a; list = query.ToList <IDNumber>(); } catch (SqlException ex) { _ErrorHandler.ONSERRORProcessing(ex); } return(list); }
/// <summary> /// Creates the entity based on the state of the parent that it will be added to. /// </summary> /// <param name="parent"></param> public Entity(Entity parent) { this.parent = parent; if (parent == null) { parentTimer = new Stopwatch(); evQueue = new Queue <EntityEventInvokeQueueItem>(); id = 0; } else { Type myType = GetType(); var parentChildren = parent.children; if (!parentChildren.ContainsKey(myType)) { parentChildren.Add(myType, new List <Entity>()); } List <Entity> children = parentChildren[myType]; id = FindID(children); children.Add(this); evQueue = parent.evQueue; parentTimer = parent.parentTimer; OnEvent += parent.NotifyEvent; } }
public bool ShotValid(IDNumber shooter, Shot shot) { return(shot != null && shot.Coordinates < Match.CompiledConfig.FieldSize && shot.Coordinates >= new Coordinates(0, 0) && shooter != shot.Receiver && !Match.Fields[shooter].Shots.Contains(shot) && !Match.Teams[DeadTeam].Members.Contains(shot.Receiver)); }
public ClassicGame(IDNumber roundID, ActiveMatch match) : base(roundID, match) { FormTeams(); turns = RandomizeTurns(); shipsPlaced = false; CurrentTurnPlayer = NextTurn(); AddEventAction(typeof(MatchAddPlayerEvent), PlayerInit); }
public PersonalInfoPage UseParametersID() { SelectElement id = new SelectElement(IDType); id.SelectByValue(idValue); IDNumber.SendKeys(idnumber); SelectElement idstate = new SelectElement(IDState); idstate.SelectByValue(idStateValue); return(this); }
public override string ToString() { if (Name != null) { return(Name); } else { return(IDNumber.ToString()); } }
protected override ValidationResult IsValid(object value, ValidationContext validationContext) { if (value != null) { PersonViewModel vm = (PersonViewModel)validationContext.ObjectInstance; if (!IDNumber.IsRecognised(vm.MilitaryIDNumber)) { return(new ValidationResult(this.ErrorMessage)); } } return(ValidationResult.Success); }
public virtual void UnsetControllerFromTeam(IDNumber ctrl, IDNumber team) { if (!controllers.ContainsKey(ctrl)) { throw new ArgumentException("Controller ID number " + ctrl + " does not exist in the current match."); } if (!Teams.ContainsKey(team)) { throw new ArgumentException("Team ID number " + team + " does not exist in the current match."); } ApplyEvent(new PlayerTeamUnassignEvent(ctrl, team)); }
/// <summary> /// <see cref="IController.OpponentDestroyed()"/> /// </summary> public void OpponentDestroyed(IDNumber destroyedID) { try { aborter.MonBegin(); controller.OpponentDestroyed(destroyedID); aborter.MonEnd(); } catch (ThreadAbortException ex) { Thread.ResetAbort(); throw new ControllerTimeoutException("OpponentDestroyed", this); } }
private bool CheckIDLength() { var id = IDNumber.ToString(); var idLength = id.Length; if (idLength == 5) { return(true); } else { return(false); } }
public bool ShipsValid(IDNumber player) { bool result = Match.Fields[player].Ships != null && Match.Fields[player].Ships.EqualLengthsAs(Match.CompiledConfig.StartingShips) && Match.Fields[player].Ships.ShipsPlaced && Match.Fields[player].Ships.GetConflictingShips().Count == 0; foreach (var ship in Match.Fields[player].Ships) { ship.IsValid(Match.CompiledConfig.FieldSize); } return(result); }
public IList <Person> GetPersonsWithUnmatchedMilitaryID() { IList <Person> persons = this.personRepo.GetAll().Where(x => !x.Archive && !string.IsNullOrEmpty(x.MilitaryIDNumber)).ToList(); IList <Person> unmatchedList = new List <Person>(); foreach (Person p in persons) { if (!IDNumber.IsRecognised(p.MilitaryIDNumber)) { unmatchedList.Add(p); } } return(unmatchedList); }
protected void btnSearch_Click(object sender, EventArgs e) { using (var _context = new ApplicationDbContext()) { try { string idNo = Request.Form["idno"]; var yearPart = Convert.ToInt32(idNo.Substring(0, 2)); var Year = yearPart <= 20 ? 2000 + yearPart : 1900 + yearPart; var Month = Convert.ToInt32(idNo.Substring(2, 2)); var Day = Convert.ToInt32(idNo.Substring(4, 2)); IDNumber idNumber = new IDNumber(); idNumber.IDNo = idNo; idNumber.DateOfBirth = new DateTime(Year, Month, Day); idNumber.Gender = Convert.ToInt32(idNo.Substring(6, 1)) < 5 ? "F" : "M"; idNumber.SACitizen = idNo.Substring(10, 1) == "0"; var prevIDNumber = _context.IDNumbers.Where(i => i.IDNo == idNumber.IDNo); if (prevIDNumber.Count() == 0) { idNumber.Counter = 1; _context.IDNumbers.Add(idNumber); _context.SaveChanges(); } else { var counter = _context.IDNumbers.Where(i => i.IDNo == idNumber.IDNo).FirstOrDefault().Counter; idNumber.Counter = counter + 1; SqlCommand cmd = new SqlCommand("UpdateCounter", conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@IDNumber", idNo); cmd.Parameters.AddWithValue("@Counter", counter + 1); conn.Open(); cmd.ExecuteNonQuery(); conn.Close(); } var holidayList = APICall(idNo, Year, Month, Day); DisplayInfo(holidayList, idNumber); } catch (Exception) { throw; } } }
private void PlayerLose(IDNumber plr) { Match.Teams[DeadTeam].Members.Add(plr); turns.Remove(plr); ApplyEvent(new PlayerLostEvent(plr)); try { Match.Controllers[plr].RoundLost(); } catch (ControllerTimeoutException ex) { ApplyEvent(new PlayerTimeoutEvent(plr, ex)); } CurrentTurnPlayer = NextTurn(); }
/// <summary> /// Inserts the ID number. /// </summary> /// <param name="_IDNumber">The _ ID number.</param> /// <returns></returns> public ONSResult InsertIDNumber(IDNumber _IDNumber) { ONSResult _ONSResultSave = new ONSResult(); try { using (TransactionScope transaction = new TransactionScope(TransactionScopeOption.Required, DBHelper.TransactionOptions)) { _ONSResultSave = ApplicationState.DAClient.InsertIDNumber(_IDNumber); transaction.Complete(); } } catch (Exception ex) { ErrorHandler _ErrorHandler = new ErrorHandler(); _ErrorHandler.ONSERRORProcessing(ex); } return(_ONSResultSave); }
public ONSResult InsertIDNumber(IDNumber parameter) { ONSResult _ONSResultInsert = new ONSResult(); try { _dataContext.IDNumbers.InsertOnSubmit(parameter); _dataContext.SubmitChanges(); _ONSResultInsert.ID = parameter.SlNo.ToString(); _ONSResultInsert.IsSuccess = true; _ONSResultInsert.Message = "IDNumber inserted successfully."; } catch (Exception ex) { _ONSResultInsert.IsSuccess = false; _ONSResultInsert.Message = ex.Message; _ErrorHandler.ONSERRORProcessing(ex); } return(_ONSResultInsert); }
protected void DisplayInfo(List <Holiday> lstHoliday, IDNumber idNumber) { try { dvResults.Visible = true; lblIDNumber.Text = idNumber.IDNo; lblDateOfBirth.Text = idNumber.DateOfBirth.HasValue ? idNumber.DateOfBirth.Value.ToShortDateString() : string.Empty; lblGender.Text = idNumber.Gender == "M" ? "Male" : "Female"; lblSACitizen.Text = idNumber.SACitizen ? "Yes" : "No"; lblCounter.Text = idNumber.Counter.ToString(); gvIDInfo.DataSource = lstHoliday; gvIDInfo.DataBind(); } catch (Exception ex) { dvResults.Visible = false; throw ex; } finally { } }
void FSerch(int id) { try { MContext mc = new MContext(); if (mc.SKUs.Any(x => x.ID == id)) { SKU s = mc.SKUs.First(x => x.ID == id); InfoSKU asku = new InfoSKU(s); asku.ShowDialog(); this.Close(); } else { MessageBox.Show("Товар с таким ID не найден"); } } catch { MessageBox.Show("Введен не корректный ID"); IDNumber.Clear(); } }
/// <summary> /// This method is called when an opponent controller has had all their ships destroyed, and is no longer /// active in the game. /// </summary> /// <param name="destroyedID"></param> public override void OpponentDestroyed(IDNumber destroyedID) { base.OpponentDestroyed(destroyedID); }
public void Type_IDNumber() { IDNumber.SendKeys(Parameters.GetData <string>("idnumber")); }
/// <summary> /// Passes the <paramref name="round"/> to the base constructor /// </summary> /// <param name="round"></param> public RoundEndEvent(Match match, IDNumber roundNumber) : base(match) { Round = roundNumber; }
public override int GetHashCode() { return(IDNumber.GetHashCode()); }
public bool Equals(IIntake other) { return(IDNumber.Equals(other.IDNumber) & well.Equals(other.well)); }
/// <summary> /// Stores the information provided by the <paramref name="exception"/> and bases the <see cref="Event.Message"/> /// from it. /// </summary> /// <param name="exception">The <see cref="ControllerTimeoutException"/> generated by a <see cref="Player"/>.</param> public PlayerTimeoutEvent(IDNumber playerID, ControllerTimeoutException exception) : base(playerID) { TimeTaken = 500; Method = exception.MethodName; }
private void PlayerTimedOut(IDNumber plr, ControllerTimeoutException ex) { ApplyEvent(new PlayerTimeoutEvent(plr, ex)); PlayerLose(plr); }
public ONSResult UpdateIDNumber(IDNumber parameter) { ONSResult _ONSResultInsert = new ONSResult(); try { List <IDNumber> list = new List <IDNumber>(); var query = from a in _dataContext.IDNumbers where a.SlNo == parameter.SlNo select a; list = query.ToList <IDNumber>(); if (list.Count == 1) { IDNumber obj = list[0]; if (parameter.SlNo != 0) { obj.SlNo = parameter.SlNo; } if (!String.IsNullOrEmpty(parameter.IDNo)) { obj.IDNo = parameter.IDNo; } if (!String.IsNullOrEmpty(parameter.IDTypeId)) { obj.IDTypeId = parameter.IDTypeId; } if (!String.IsNullOrEmpty(parameter.CompanyId)) { obj.CompanyId = parameter.CompanyId; } if (!String.IsNullOrEmpty(parameter.LocationId)) { obj.LocationId = parameter.LocationId; } if (!String.IsNullOrEmpty(parameter.EntryBy)) { obj.EntryBy = parameter.EntryBy; } if (parameter.DateOfEntry.HasValue) { obj.DateOfEntry = parameter.DateOfEntry.Value; } if (parameter.IDYear.HasValue) { obj.IDYear = parameter.IDYear.Value; } _dataContext.SubmitChanges(); } _ONSResultInsert.IsSuccess = true; _ONSResultInsert.Message = "IDNumber updated successfully."; } catch (Exception ex) { _ONSResultInsert.IsSuccess = false; _ONSResultInsert.Message = ex.Message; _ErrorHandler.ONSERRORProcessing(ex); } return(_ONSResultInsert); }
/// <summary> /// Compares using the ID-number /// </summary> /// <param name="other"></param> /// <returns></returns> public int CompareTo(IIntake other) { return(IDNumber.CompareTo(other.IDNumber)); }
private void PlayerDead(IDNumber plr) { //Match.Teams[DeadTeam].Members.Add(plr); PlayerLose(plr); }