S
S
Sergey Kotov2020-02-20 23:04:17
OOP
Sergey Kotov, 2020-02-20 23:04:17

Have I drawn the plan for the OOP game of checkers correctly?

I am learning OOP. I wanted to try to write a game of checkers for two in javascript. And I threw on the xmind program, so to speak, the architecture of the game. I would like to know your opinion5e4ee639159e9770570557.png

Answer the question

In order to leave comments, you need to log in

6 answer(s)
S
Sergey Sokolov, 2020-02-20
@sergiks

Since you are studying OOP, maybe make the lady a child class that inherits something from a simple checker, but overrides some properties and methods?
The above scheme does not take into account the possibility of chains of “attacking” moves. Incl. with transformation into a lady in the process of gluttony)
You can enter the essence of the "move". Then you can add the moves to the array of the game. Save the game, play it. Walk over! )
Length in time: if done beautifully, there will be animations of checkers transition between cells. At this time, you can not interfere, for example. This is probably an over-complication, though.
The board will need initialization methods, maybe loading a position, evaluating a position.

D
Dmtm, 2020-02-21
@Dmtm

oops need abstractions!
on the figure! (today they are checkers, but tomorrow they will need go)
on the move! on the desk! (checkers are also hundred-celled)
to coordinates - so that you can go to spherical ones!
and cover everything with interfaces, for the glory of sotho ... oops!

M
Maxim, 2020-02-20
@myks92

Overall, not bad. But I would do it differently.
1. Do not display properties separately in the schema . It is not entirely clear what you are changing in the methods. What are the conditions for change. What settings. And so on. Properties are needed more for database design.
For example, it's better like this:
Hang a cage
- color (string(6))
2. Checker is an integral part of the board . Therefore, the modification of checkers will be from the essence of the board.
For example, you can see how any API is built. Everywhere there are methods and a description of what they do. What parameters are accepted. What result is returned. What type and so on. Go to the VK API and you will immediately understand. You need to make some kind of API.
otherwise ok)

N
Northern Lights, 2020-02-21
@php666

I am learning OOP. I wanted to try to write a game of checkers

1. Learning OOP on Zhs is not the best idea, take the same php.
2. Writing such a complex game as checkers, and even in OOP, is not the most trivial task for learning

E
Evgeny Glebov, 2020-02-27
@GLeBaTi

Cell State{
White Checker,
Black Checker,
White Checker King, Black Checker
King,
No Checkers
} Game
State {
Start,
Draw,
White Move,
Black Move,
Game Over,
}
Variables:
"Board" type: Checker State
"Stage" type:
GameState "Player1"
"Player2"
Methods:
SetStage(GameState) //Here you can use the "State" pattern
OnStart()
-InitializePlayers();
OnPairing()
-SetPlayersColors()
-FillBoard()
OnMove(Player, X, Y)
-HereMoveLogic (deleting chips, moving, etc.)
OnGameOver() -Calculate and
outputResults()

R
robomaker, 2020-03-21
@robomaker

It seems to me that OOP is not needed for such a simple architecture.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question