Repository navigation
Conversation
|
@ihhub, could you help me with CI, please? I can see only code style checking error, but there is no context: file, line, etc. |
Click on ... next to failed CI stage to View Details. |
Ah, thank you! I had some of JS disabled, so that page rendered as almost empty for me (so code snippets), now it's fine |
| size_t i = 0; | ||
| const size_t count = units->size(); | ||
| for ( ; i < count; i++ ) { | ||
| const Battle::Unit * unit = units->at( i ); | ||
| if ( *unit == currentUnit ) { | ||
| break; | ||
| } | ||
| } | ||
| i++; | ||
| if ( i == count ) { | ||
| i = 0; | ||
| } | ||
|
|
||
| const Battle::Unit * next_unit = units->at( i ); | ||
| assert( next_unit != nullptr ); | ||
| return { next_unit }; |
There was a problem hiding this comment.
Does this code check units for the next turn?
There was a problem hiding this comment.
As I could understand, _orderOfUnits is like a circular buffer, hence I tried to find current unit in it and get the next unit by index.
| const Army * currentArmy = currentUnit.GetArmy(); | ||
| const Army * nextArmy = nextUnit->GetArmy(); | ||
|
|
||
| const bool isSameArmy = ( currentArmy != nullptr ) && ( currentArmy == nextArmy ); |
There was a problem hiding this comment.
Why do we need to compare armies instead of units?
There was a problem hiding this comment.
I thought of that as the simplest way to check if two units belong to the same army. Otherwise I can make a function like bool Unit#isSameArmyAs(const Unit& unit) const to make it look more OOP (it would do the same logic inside though).
| std::shared_ptr<const Units> getOrderOfUnits() const | ||
| { | ||
| return _orderOfUnits; | ||
| } |
There was a problem hiding this comment.
We should revert this change: see my comments above.
There was a problem hiding this comment.
I have no objections here, but how to receive order of units otherwise? It's required to find the next unit.
Hello!
This is an attempt to implement #10480
If some other checks besides army and morale of the next unit are required, I'll add them