Project Documentation - Manfredtham/Battleship GitHub Wiki

Coding Standard

  • C# Coding Standard

List of Issues

Functional Errors:

1. ALL

 - Missing reference System.Data

2. DeploymentController.cs

 - Missing Class datatype
 - VK_ -> vk_
 - i = Conversion.Int(sn) -> i = ((int)sn) - 1;

3. DiscoveryController.cs

 - Missing Class datatype
 - VK_ -> vk_

4. EndingGameController.cs

 - Missing Class datatype
 - VK_ -> vk_

5. GameController.cs

 - public GameController() -> static GameController()
 - Missing Class datatype

6. GameLogic.cs

 - Missing using SwinGameSDK
 - Missing Class datatype

7. GameResources.cs

 - _Fonts(font) -> _Fonts[font]
 - foreach(obj in _Fonts.Values) -> foreach(Font obj in _Fonts.Values) (Remove Font obj = default(Font);)

8. HighScoreController.cs

 - Missing Class datatype
 - s = _Scores.Item(i) -> s = _Scores[i]
 - VK_ -> vk_
 - if (value > _Scores.Item(_Scores.Count - 1).Value) -> if (value > _Scores[_Scores.Count - 1].Value)

9. MenuController.cs

 - VK_ -> vk_
 - Missing Class datatype
 - _menuStructure(menu).Length  -> _menuStructure[menu].Length 
 - SwinGame.DrawTextLines(_menuStructure(menu)(i)...) -> SwinGame.DrawTextLines(_menuStructure[menu][i]...)

10. UtilityFunctions.cs

 - Missing using SwinGameSDK
 - switch (grid.Item(row, col)) -> switch (grid[row, col])

 - case TileView.Sea:     ->    case TileView.Sea:      (Delete .Ship)
   case TileView.Ship:

 - s.animationHasEnded -> s.AnimationHasEnded

Bug Fixes:

1) Map coordinate error, deployment of ships is offset by 3 cells in the y-axis.

In DeploymentController.cs:
 ROW 105: row = Convert.ToInt32 (Math.Floor ((mouse.Y) -> ((mouse.Y - UtilityFunctions.FIELD_TOP)

2) Play button / Ships menu covered by solid color.

In DeploymentController.cs:
 ROW 147, 149, 160: Remove SwinGame.FillRectangle

3. Horizontol deployment of the ships. unable to switch back to vertical setting

In DeploymentController.cs:
 ROW 79: _currentDirection = Direction.LeftRight; -> _currentDirection = Direction.UpDown

4. Shots still increase when the same position (cell) is clicked.

In Player.cs:
 ROW 187 = Add new case: ResultOfAttack.ShotAlready: _shots -= 1; break;

5. Explosion effect not working, still splash effect when we hit

In UtilityFunction.cs:
 ROW 256 = AddAnimation (row, col, "Splash"); -> AddAnimation (row, col, "Explosion");
 ROW 314 = Added a delay of 1ms between animation cells using SwinGame.Delay(10) to improve the effect.

New Feature:

1. Add Current Difficulty

In GameResources.cs:
 ROW 21: Add new font named "MenuLarge"
In MenuController.cs:
 ROW 44: Create new variable (CURRENT_DIFFICULTY)
 ROW 148: Draw current difficulty by adding new SwinGame.DrawTextLines(...)
 ROW 292-300: Add new codes to change current difficulty in PerformSetupMenuAction() function. (CURRENT_DIFFICULTY = ...)

2. Add Score Monitor

In GameResources.cs:
 ROW 65: Instantiate variable: const int SCORE_TOP = 306, for Score's position.
 ROW 79: Draw the score to the screen by adding SwinGame.DrawText (GameController.HumanPlayer.Score.ToString (), Color.White, GameResources.GameFont ("Menu"), SCORES_LEFT, SCORE_TOP);
In Images folder:
 Edit background image: add score's row

3. Add Result Summary in endgame

In EndingGameController.cs:
 ROW 27 - 39: Add more SwinGame.DrawTextLines()
In GameResources.cs:
 ROW 17: Add new font named "ArialSmall"

4. Add Pause button

In GameResources.cs:
 ROW 36 -> Add new image named PauseButton
In DiscoveryController.cs:
 ROW 49 -> Add pause area (if (row == -1 & col == 9)) 
 ROW 92 -> Draw pause button by adding SwinGame.DrawBitmap()
In Images folder:
 Add pause button image

5. Add Github button

In Images folder:
 Create Guthub button image
In MenuController.cs:
 ROW 135-144 ->

      //If wiki page button is clicked
      Point2D mouse = default (Point2D);

      mouse = SwinGame.MousePosition ();
      int mouseX = Convert.ToInt32 (mouse.X);
      int mouseY = Convert.ToInt32 (mouse.Y);

      if (mouseX > 700 && mouseX < 780 && mouseY > 200 && mouseY <246) {
       Process.Start ("https://github.com/Manfredtham/Battleship/wiki");
      }

 ROW 233-234 ->

      //Add navigator to Group Wiki page.
      SwinGame.DrawText ("About Us", Color.White, GameResources.GameFont ("Menu"), 695, 160);
      SwinGame.DrawBitmap (GameResources.GameImage ("GitHub"), 700, 200);

6. Add Discovery Timer

In DeploymentController.cs:
 ROW 77 -> const int TIMER_LEFT = 510;
 ROW 78 -> const int TIMER_TOP = 85;

 ROW 108 -> SwinGame.DrawText (GameController.timeCount (480000), Color.White, GameResources.GameFont ("MenuMedium"), 
            TIMER_LEFT, TIMER_TOP);
In GameController.cs:
 ROW 33-61 ->

    public static string timeCount (int _time)
    {

	SwinGame.StartTimer (_timer);
	int _timeLeft = 480000;
	_timeLeft -= (int)SwinGame.TimerTicks (_timer);
	_timeLeft /= 1000;

	if (_timeLeft < 0) {
		_timeLeft = 0;
	_time -= (int)SwinGame.TimerTicks (_timer);
	_time /= 1000;

	if (_time < 0) {
		_time = 0;
		SwitchState (GameState.EndingGame);
	}

	int _mins, _secs;

	_mins = _timeLeft / 60;
	_secs = _timeLeft - (_mins * 60);
	_mins = _time / 60;
	_secs = _time - (_mins * 60);

	string _time;
	string _timeLeft;

	if (_secs < 10) 
	{

		_time = _mins + ":0" + _secs;
		_timeLeft = _mins + ":0" + _secs;
	} 
	else 
	{

		_time = _mins + ":" + _secs;
		_timeLeft = _mins + ":" + _secs;
	}

	return _time;
	return _timeLeft;
        }

 ROW 370-372 ->

        case GameState.Discovering:
    if (SwinGame.TimerTicks (Timer) == 0) {
	  SwinGame.StartTimer (Timer);
    }

 ROW 375 ->

    case GameState.EndingGame:
	  SwinGame.StopTimer (Timer);
⚠️ **GitHub.com Fallback** ⚠️