* Gets the morale modifier for * - either XCom based on the highest ranked, living XCom unit, * - or the unit passed to this function. * @param unit Unit. * @return The morale modifier. */
| 1567 | * @return The morale modifier. |
| 1568 | */ |
| 1569 | int SavedBattleGame::getMoraleModifier(BattleUnit* unit) |
| 1570 | { |
| 1571 | int result = 100; |
| 1572 | |
| 1573 | if (unit == 0) |
| 1574 | { |
| 1575 | BattleUnit *leader = getHighestRankedXCom(); |
| 1576 | if (leader) |
| 1577 | { |
| 1578 | switch (leader->getRankInt()) |
| 1579 | { |
| 1580 | case 5: |
| 1581 | result += 25; |
| 1582 | case 4: |
| 1583 | result += 10; |
| 1584 | case 3: |
| 1585 | result += 5; |
| 1586 | case 2: |
| 1587 | result += 10; |
| 1588 | default: |
| 1589 | break; |
| 1590 | } |
| 1591 | } |
| 1592 | } |
| 1593 | else if (unit->getFaction() == FACTION_PLAYER) |
| 1594 | { |
| 1595 | switch (unit->getRankInt()) |
| 1596 | { |
| 1597 | case 5: |
| 1598 | result += 25; |
| 1599 | case 4: |
| 1600 | result += 20; |
| 1601 | case 3: |
| 1602 | result += 10; |
| 1603 | case 2: |
| 1604 | result += 20; |
| 1605 | default: |
| 1606 | break; |
| 1607 | } |
| 1608 | } |
| 1609 | return result; |
| 1610 | } |
| 1611 | |
| 1612 | /** |
| 1613 | * Places a unit on or near a position. |
no test coverage detected