* this function checks if a tile is visible, using maths. * @param pos the position to check against * @return what the maths decide */
| 2534 | * @return what the maths decide |
| 2535 | */ |
| 2536 | bool BattleUnit::checkViewSector (Position pos) const |
| 2537 | { |
| 2538 | int deltaX = pos.x - _pos.x; |
| 2539 | int deltaY = _pos.y - pos.y; |
| 2540 | |
| 2541 | switch (_direction) |
| 2542 | { |
| 2543 | case 0: |
| 2544 | if ( (deltaX + deltaY >= 0) && (deltaY - deltaX >= 0) ) |
| 2545 | return true; |
| 2546 | break; |
| 2547 | case 1: |
| 2548 | if ( (deltaX >= 0) && (deltaY >= 0) ) |
| 2549 | return true; |
| 2550 | break; |
| 2551 | case 2: |
| 2552 | if ( (deltaX + deltaY >= 0) && (deltaY - deltaX <= 0) ) |
| 2553 | return true; |
| 2554 | break; |
| 2555 | case 3: |
| 2556 | if ( (deltaY <= 0) && (deltaX >= 0) ) |
| 2557 | return true; |
| 2558 | break; |
| 2559 | case 4: |
| 2560 | if ( (deltaX + deltaY <= 0) && (deltaY - deltaX <= 0) ) |
| 2561 | return true; |
| 2562 | break; |
| 2563 | case 5: |
| 2564 | if ( (deltaX <= 0) && (deltaY <= 0) ) |
| 2565 | return true; |
| 2566 | break; |
| 2567 | case 6: |
| 2568 | if ( (deltaX + deltaY <= 0) && (deltaY - deltaX >= 0) ) |
| 2569 | return true; |
| 2570 | break; |
| 2571 | case 7: |
| 2572 | if ( (deltaY >= 0) && (deltaX <= 0) ) |
| 2573 | return true; |
| 2574 | break; |
| 2575 | default: |
| 2576 | return false; |
| 2577 | } |
| 2578 | return false; |
| 2579 | } |
| 2580 | |
| 2581 | /** |
| 2582 | * common function to adjust a unit's stats according to difficulty setting. |
no outgoing calls
no test coverage detected