* Get the number of time units a certain action takes. * @param actionType * @param item * @return TUs */
| 1101 | * @return TUs |
| 1102 | */ |
| 1103 | int BattleUnit::getActionTUs(BattleActionType actionType, BattleItem *item) |
| 1104 | { |
| 1105 | if (item == 0) |
| 1106 | { |
| 1107 | return 0; |
| 1108 | } |
| 1109 | |
| 1110 | int cost = 0; |
| 1111 | switch (actionType) |
| 1112 | { |
| 1113 | case BA_PRIME: |
| 1114 | cost = 50; // maybe this should go in the ruleset |
| 1115 | break; |
| 1116 | case BA_THROW: |
| 1117 | cost = 25; |
| 1118 | break; |
| 1119 | case BA_AUTOSHOT: |
| 1120 | cost = item->getRules()->getTUAuto(); |
| 1121 | break; |
| 1122 | case BA_SNAPSHOT: |
| 1123 | cost = item->getRules()->getTUSnap(); |
| 1124 | break; |
| 1125 | case BA_STUN: |
| 1126 | case BA_HIT: |
| 1127 | cost = item->getRules()->getTUMelee(); |
| 1128 | break; |
| 1129 | case BA_LAUNCH: |
| 1130 | case BA_AIMEDSHOT: |
| 1131 | cost = item->getRules()->getTUAimed(); |
| 1132 | break; |
| 1133 | case BA_USE: |
| 1134 | case BA_MINDCONTROL: |
| 1135 | case BA_PANIC: |
| 1136 | cost = item->getRules()->getTUUse(); |
| 1137 | break; |
| 1138 | default: |
| 1139 | cost = 0; |
| 1140 | } |
| 1141 | |
| 1142 | // if it's a percentage, apply it to unit TUs |
| 1143 | if (!item->getRules()->getFlatRate() || actionType == BA_THROW || actionType == BA_PRIME) |
| 1144 | { |
| 1145 | cost = (int)floor(getStats()->tu * cost / 100.0f); |
| 1146 | } |
| 1147 | |
| 1148 | return cost; |
| 1149 | } |
| 1150 | |
| 1151 | |
| 1152 | /** |
no test coverage detected