diff --git a/api/actions/placeact.php b/api/actions/placeact.php new file mode 100644 index 0000000..72db971 --- /dev/null +++ b/api/actions/placeact.php @@ -0,0 +1,44 @@ +isClaimed()) { + if ($place->getTeamID() == $player->getTeamID()) { + // Same teams, player is defending + if ($place->energy->getEnergy() == $place->energy->getMaxEnergy()) { + sendJsonResp($Strings->get("Nothing happened.", false)); + } + $place->changeEnergy(10); + $player->changeEnergy(-5); + $player->addExp(); + $player->stats->updateStat(PlayerStats::DEFENDS, 1); + $place->save(); + $player->save(); + sendJsonResp($Strings->get("Defending...", false)); + } else { + // Different teams, player is attacking + $place->changeEnergy(-10); + $player->changeEnergy(-5); + $player->addExp(); + $player->stats->updateStat(PlayerStats::ATTACKS, 1); + $place->save(); + $player->save(); + sendJsonResp($Strings->get("Attacking...", false)); + } +} else { + // Place unclaimed, player is claiming + $place->claim($player); + $player->addExp(); + $player->stats->updateStat(PlayerStats::CLAIMS, 1); + $place->save(); + $player->save(); + sendJsonResp($Strings->get("Control established.", false)); +} \ No newline at end of file