Esempio n. 1
0
 public EndTurnInfo Move(TurnInfo info)
 {
     if (info.CharacterId >= _ships.Count)
         throw new ArgumentOutOfRangeException(string.Format("No Character with ID={0}", info.CharacterId));
     var ch = _ships[info.CharacterId].Crew[0];
     var characterPoint = ch.GetPoint();
     if (!characterPoint.MoveBySide(info.MovingSide))
         return new EndTurnInfo(_map.ChangedCells(true),
             _ships.Select(ship => ship.Crew[0].GetCharInfo()).ToArray());
     if (!CanMoveInThatCell(characterPoint))
     {
         characterPoint.OpositeMove(info.MovingSide);
     }
     else
     {
         RestoreCell(info.MovingSide, ch);
         CheckActionsOnThatCell(ch, characterPoint);
         SaveFutureCell(ch,characterPoint);
         SetCharacterOnMap(characterPoint.X, characterPoint.Y, info.CharacterId);
         ch.ApplyPoint(characterPoint);
     }
     return new EndTurnInfo(_map.ChangedCells(true), _ships.Select(ship => ship.Crew[0].GetCharInfo()).ToArray());
 }