public BotForFoundedShip(string coordinates, Playground enemyPlayGroundFromBot) { this.lastAttackPosstion = coordinates; string[] coordinatesArr = coordinates.Split(' '); this.firstXCoordinate = int.Parse(coordinatesArr[0]); this.secondXCoordinate = int.Parse(coordinatesArr[1]); this.FullTheQueues(this.firstXCoordinate, this.secondXCoordinate); this.sideForAttack = SideForAttack.Left; this.playground = enemyPlayGroundFromBot; }
public string Attack() { string posstion = string.Empty; if (this.sideForAttack == SideForAttack.Left) { if (this.AttackIsAvailable(this.toLeft)) { posstion = this.toLeft.Dequeue(); } else { this.sideForAttack = SideForAttack.Right; } } if (this.sideForAttack == SideForAttack.Right) { if (this.AttackIsAvailable(this.toRight)) { posstion = this.toRight.Dequeue(); } else { this.sideForAttack = SideForAttack.Up; } } if (this.sideForAttack == SideForAttack.Up) { if (this.AttackIsAvailable(this.toUp)) { posstion = this.toUp.Dequeue(); } else { this.sideForAttack = SideForAttack.Down; } } if (this.sideForAttack == SideForAttack.Down) { if (this.AttackIsAvailable(this.toDown)) { posstion = this.toDown.Dequeue(); } else { throw new ArgumentException("Problem in Method for Attack"); } } this.lastAttackPosstion = posstion; return posstion; }