MCPcopy Index your code
hub / github.com/battlecode/battlecode-2018 / research

Method research

battlecode-engine/src/unit.rs:1173–1226  ·  view source on GitHub ↗

Research the next level.

(&mut self)

Source from the content-addressed store, hash-verified

1171
1172 /// Research the next level.
1173 pub(crate) fn research(&mut self) -> Result<(), GameError> {
1174 match self.unit_type {
1175 Worker => match self.level {
1176 0 => { self.harvest_amount += 1; },
1177 1 => {
1178 self.build_health += 1;
1179 self.repair_health += 1;
1180 },
1181 2 => {
1182 self.build_health += 1;
1183 self.repair_health += 1;
1184 },
1185 3 => {
1186 self.build_health += 3;
1187 self.repair_health += 3;
1188 },
1189 _ => Err(GameError::ResearchNotUnlocked {unit_type: Worker})?,
1190 },
1191 Knight => match self.level {
1192 0 => { self.defense += 5; },
1193 1 => { self.defense += 5; },
1194 2 => { self.is_ability_unlocked = true; },
1195 _ => Err(GameError::ResearchNotUnlocked {unit_type: Knight})?,
1196 },
1197 Ranger => match self.level {
1198 0 => { self.movement_cooldown -= 5; },
1199 1 => { self.vision_range += 30; },
1200 2 => { self.is_ability_unlocked = true; },
1201 _ => Err(GameError::ResearchNotUnlocked {unit_type: Ranger})?,
1202 },
1203 Mage => match self.level {
1204 0 => { self.damage += 15; },
1205 1 => { self.damage += 15; },
1206 2 => { self.damage += 15; },
1207 3 => { self.is_ability_unlocked = true; },
1208 _ => Err(GameError::ResearchNotUnlocked {unit_type: Mage})?,
1209 },
1210 Healer => match self.level {
1211 0 => { self.damage -= 2; },
1212 1 => { self.damage -= 5; },
1213 2 => { self.is_ability_unlocked = true; },
1214 _ => Err(GameError::ResearchNotUnlocked {unit_type: Healer})?,
1215 },
1216 Rocket => match self.level {
1217 0 => { self.is_ability_unlocked = true; },
1218 1 => { self.travel_time_decrease += 20; },
1219 2 => { self.max_capacity += 4; },
1220 _ => Err(GameError::ResearchNotUnlocked {unit_type: Rocket})?,
1221 },
1222 Factory => Err(GameError::ResearchNotUnlocked {unit_type: Factory})?,
1223 }
1224 self.level += 1;
1225 Ok(())
1226 }
1227
1228 /// Process the end of the round.
1229 pub(crate) fn end_round(&mut self) {

Callers 3

process_researchMethod · 0.80
newMethod · 0.80
test_researchFunction · 0.80

Calls

no outgoing calls

Tested by 1

test_researchFunction · 0.64