This repository has been archived by the owner on Oct 25, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from KenCir:KenCir/issue36
プレイヤー同士で送金機能 #36
- Loading branch information
Showing
8 changed files
with
94 additions
and
29 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OutiServerPlugin; | ||
|
||
use ArgumentCountError; | ||
use Error; | ||
use ErrorException; | ||
use Exception; | ||
use InvalidArgumentException; | ||
use jojoe77777\FormAPI\{CustomForm, SimpleForm}; | ||
use pocketmine\Player; | ||
use TypeError; | ||
|
||
class Money | ||
{ | ||
private Main $plugin; | ||
|
||
public function __construct(Main $plugin) | ||
{ | ||
$this->plugin = $plugin; | ||
} | ||
|
||
public function Form(Player $player) | ||
{ | ||
try { | ||
$form = new SimpleForm(function (Player $player, $data) { | ||
if ($data === null) return true; | ||
|
||
switch ($data) { | ||
case 0: | ||
$name = $player->getName(); | ||
$playerdata = $this->plugin->db->GetMoney($name); | ||
if (!$playerdata) break; | ||
$player->sendMessage("あなたの現在の所持金: " . $playerdata["money"] . "円"); | ||
break; | ||
case 1: | ||
$this->MoveMoney($player); | ||
break; | ||
} | ||
return true; | ||
}); | ||
|
||
$form->setTitle("iPhone-Money"); | ||
$form->addButton("所持金の確認"); | ||
$form->addButton("他playerにお金を転送"); | ||
$player->sendForm($form); | ||
} | ||
catch (Error | TypeError | Exception | ErrorException | InvalidArgumentException | ArgumentCountError $e) { | ||
$this->plugin->errorHandler->onErrorNotPlayer($e); | ||
} | ||
} | ||
|
||
private function MoveMoney(Player $player) | ||
{ | ||
try { | ||
$name = $player->getName(); | ||
$playermoney = $this->plugin->db->GetMoney($name); | ||
$form = new CustomForm(function (Player $player, $data) { | ||
if($data === null) return true; | ||
else if(!isset($data[0]) or !is_numeric($data[1])) return true; | ||
|
||
$name = $player->getName(); | ||
$this->plugin->db->AddMoney($data[0], (int)$data[1]); | ||
$this->plugin->db->RemoveMoney($name, (int)$data[1]); | ||
$player->sendMessage($data[0] . "に" . $data[1] . "円転送しました"); | ||
return true; | ||
}); | ||
|
||
$form->setTitle("Money-他プレイヤーに所持金を転送"); | ||
$form->addInput("転送先のプレイヤー名", "playername", ""); | ||
$form->addSlider("転送するお金", 1, $playermoney["money"]); | ||
$player->sendForm($form); | ||
} | ||
catch (Error | TypeError | Exception | ErrorException | InvalidArgumentException | ArgumentCountError $e) { | ||
$this->plugin->errorHandler->onError($e, $player); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters