diff --git a/src/Main.php b/src/Main.php index 977d4c7..36b3354 100644 --- a/src/Main.php +++ b/src/Main.php @@ -17,6 +17,7 @@ use NeiroNetwork\AlternativeCoreWars\core\PlayerBlockTracker; use NeiroNetwork\AlternativeCoreWars\core\GameArenaProtector; use NeiroNetwork\AlternativeCoreWars\core\PlayerKillAssistsEventMaker; +use NeiroNetwork\AlternativeCoreWars\core\CommandFactory; use NeiroNetwork\AlternativeCoreWars\core\PrivateCraftingForBrewingAndSmelting; use NeiroNetwork\AlternativeCoreWars\core\RewardGiver; use NeiroNetwork\AlternativeCoreWars\core\ServerSpecificationNormalizer; @@ -70,6 +71,7 @@ protected function onLoad() : void{ ShopCreator::class, DropItemReplacer::class, KitEventBroker::class, + CommandFactory::class, ]); } diff --git a/src/command/PlayerStatsCommand.php b/src/command/PlayerStatsCommand.php new file mode 100644 index 0000000..4e81d18 --- /dev/null +++ b/src/command/PlayerStatsCommand.php @@ -0,0 +1,34 @@ +hasPermission(DefaultPermissions::ROOT_OPERATOR) ? implode(" ", $args) : ""; + $target = $sender->getServer()->getPlayerByPrefix($target) ?? $sender; + if($target instanceof Player){ + $sender->sendMessage(InfoAPI::resolve( + TextFormat::GOLD . "========== " . TextFormat::WHITE . "{$sender->getName()} さんのステータス " . TextFormat::GOLD . "==========" . TextFormat::RESET . PHP_EOL . + "所持金: {money} Money" . PHP_EOL . + "経験値: {exp} EXP" . PHP_EOL . + "音色ポイント: {np} NP", + new PlayerInfo($target) + )); + } + } +} diff --git a/src/core/CommandFactory.php b/src/core/CommandFactory.php new file mode 100644 index 0000000..762ce5d --- /dev/null +++ b/src/core/CommandFactory.php @@ -0,0 +1,17 @@ +getServer()->getCommandMap()->registerAll($this->getName(), [ + new PlayerStatsCommand(), + ]); + } +} diff --git a/src/core/PlayerActivityTracker.php b/src/core/PlayerActivityTracker.php new file mode 100644 index 0000000..80e520b --- /dev/null +++ b/src/core/PlayerActivityTracker.php @@ -0,0 +1,46 @@ +kills = $api->completeConfig(["currency" => "kills"]); + $this->assists = $api->completeConfig(["currency" => "assists"]); + $this->deaths = $api->completeConfig(["currency" => "deaths"]); + $this->breaks = $api->completeConfig(["currency" => "breaks"]); + $this->victories = $api->completeConfig(["currency" => "victories"]); + $this->defeats = $api->completeConfig(["currency" => "defeats"]); + $this->playtime = $api->completeConfig(["currency" => "playtime"]); + }); + } + + private function increase(Player $player, Complete $schema, LabelSet $label = null) : void{ + Capital::api("0.1.0", function(Capital $api) use ($player, $schema, $label){ + yield from $api->addMoney($this->getName(), $player, $schema, 1, $label ?? new LabelSet([])); + }); + } + + public function onDeath(PlayerDeathWithoutDeathScreenEvent $event) : void{ + $player = $event->getPlayer(); + $last = $player->getLastDamageCause(); + + $this->increase($player, $this->deaths, new LabelSet(["cause" => $last->getCause()])); + if($last instanceof EntityDamageByEntityEvent && ($damager = $last->getEntity()) instanceof Player){ + $this->increase($damager, $this->kills, new LabelSet(["cause" => $last->getCause()])); + } + } +}