Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Item rarity sets #26

Merged
merged 7 commits into from
Dec 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
name: RPGLike
version: 0.0.1
main: TheClimbing\RPGLike\RPGLike
api: 3.11.6
api: 4.0.0
...
35 changes: 34 additions & 1 deletion resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ Traits:
requirement: 50
drop_chance: 30
MonsterHunter:
blocks: ["Zombie", "Skeleton"]
blocks: [ "Zombie", "Skeleton" ]
action: 'kill'
levels:
1:
Expand All @@ -180,4 +180,37 @@ Traits:
2:
requirement: 100
drop_chance: 40
ItemTiers:
Uncommon:
colour: green
level_cap: 10
items:
272:
name: 'Training Sword'
bonuses:
damage: 1
Rare:
colour: blue
level_cap: 20
items:
267:
name: 'Silver Sword'
bonuses:
damage: 1
Epic:
colour: purple
level_cap: 30
items:
276:
name: 'Greatsword'
bonuses:
damage: 1
Mythic:
colour: red
level_cap: 40
items:
283:
name: 'Special Sword'
bonuses:
damage: 1
...
8 changes: 5 additions & 3 deletions src/TheClimbing/RPGLike/Commands/LevelUpCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use pocketmine\command\Command;
use pocketmine\command\CommandSender;
use pocketmine\Player;
use TheClimbing\RPGLike\Players\RPGPlayer;

class LevelUpCommand extends Command
{
Expand All @@ -17,11 +18,12 @@ public function __construct()

public function execute(CommandSender $sender, string $commandLabel, array $args)
{
if ($sender instanceof Player) {
if ($sender instanceof RPGPlayer) {
$xpmanager = $sender->getXpManager();
if (empty($args)) {
$sender->setXpLevel($sender->getXpLevel() + 1);
$xpmanager->setXpLevel($xpmanager->getXpLevel() + 1);
} else {
$sender->setXpLevel($args[0]);
$xpmanager->setXpLevel($args[0]);
}
}
}
Expand Down
60 changes: 32 additions & 28 deletions src/TheClimbing/RPGLike/Commands/PartyCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use pocketmine\command\Command;
use pocketmine\command\CommandSender;
use TheClimbing\RPGLike\Players\RPGPlayer;
use TheClimbing\RPGLike\RPGLike;
use TheClimbing\RPGLike\Systems\PartySystem;

Expand All @@ -21,39 +22,42 @@ public function execute(CommandSender $sender, string $commandLabel, array $args
if (empty($args) || $args[0] == '' || $args[0] == ' ') {
$sender->sendMessage($this->getUsage());
} else {
$args = array_map('strtolower', $args);
switch ($args[0]) {
case 'accept':
if ($sender->hasPartyInvite()){
PartySystem::getPlayerParty($sender->getPartyInvite())->addPlayerInParty($sender);
}
break;
case 'deny':
$sender->removePartyInvite();
break;
case 'create':
if (!empty($args[1])){
PartySystem::createParty($args[1], $sender, 4);
}else{
PartySystem::createParty($sender->getName(), $sender, 4); //TODO add configuration for party size
}
break;
default:
$targetPlayer = $this->source->getServer()->getPlayer($args[0]);
if ($targetPlayer != null){
if ($targetPlayer->getParty() == false){
if ($sender->getParty() != false){
$targetPlayer->sendPartyInvite($sender->getParty());
if ($sender instanceof RPGPlayer){
$args = array_map('strtolower', $args);
switch ($args[0]) {
case 'accept':
if ($sender->hasPartyInvite()){
PartySystem::getPlayerParty($sender->getPartyInvite())->addPlayerInParty($sender);
}
break;
case 'deny':
$sender->removePartyInvite();
break;
case 'create':
if (!empty($args[1])){
PartySystem::createParty($args[1], $sender, 4);
}else{
PartySystem::createParty($sender->getName(), $sender, 4); //TODO add configuration for party size
}
break;
default:
$targetPlayer = $this->source->getServer()->getPlayerExact($args[0]);
if ($targetPlayer instanceof RPGPlayer){
if ($targetPlayer->getParty() == false){
if ($sender->getParty() != false){
$targetPlayer->sendPartyInvite($sender->getParty());
}else{
$sender->sendMessage('You need to be in a party to send invites.');
}
}else{
$sender->sendMessage('You need to be in a party to send invites.');
$sender->sendMessage('Player already in a party');
}
}else{
$sender->sendMessage('Player already in a party');
$sender->sendMessage('The player is offline or is already in party');
}
}else{
$sender->sendMessage('The player is offline or is already in party');
}
}
}

}
}
}
11 changes: 1 addition & 10 deletions src/TheClimbing/RPGLike/Commands/RPGCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,18 @@

use pocketmine\command\Command;
use pocketmine\command\CommandSender;
use pocketmine\command\PluginIdentifiableCommand;
use pocketmine\plugin\Plugin;
use TheClimbing\RPGLike\Forms\RPGForms;
use TheClimbing\RPGLike\Players\RPGPlayer;
use TheClimbing\RPGLike\RPGLike;

class RPGCommand extends Command implements PluginIdentifiableCommand
class RPGCommand extends Command
{
private $loader;

public function __construct(RPGLike $rpg)
{
parent::__construct('rpg');
$this->loader = $rpg;
$this->setDescription('Opens RPG Menu');
$this->setPermission('rpgcommand');
$this->setUsage('rpg stats|skills|upgrade or rpg help <skillName>');
$this->setPermissionMessage('You dont have permission to use this command');
}
Expand Down Expand Up @@ -51,9 +47,4 @@ public function execute(CommandSender $sender, string $commandLabel, array $args
}
}
}

public function getPlugin(): Plugin
{
return $this->loader;
}
}
10 changes: 7 additions & 3 deletions src/TheClimbing/RPGLike/EventListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

use pocketmine\event\block\BlockBreakEvent;
use pocketmine\event\entity\EntityDamageByEntityEvent;
use pocketmine\event\entity\EntityRegainHealthEvent;
use pocketmine\event\entity\ProjectileHitEntityEvent;
use pocketmine\event\Listener;
use pocketmine\event\player\PlayerBlockPickEvent;
Expand All @@ -19,7 +18,11 @@
use pocketmine\event\player\PlayerQuitEvent;
use pocketmine\event\player\PlayerRespawnEvent;

use pocketmine\item\Item;
use pocketmine\item\ItemIds;
use pocketmine\item\TieredTool;
use TheClimbing\RPGLike\Forms\RPGForms;
use TheClimbing\RPGLike\Items\UncommonTierItem;
use TheClimbing\RPGLike\Players\RPGPlayer;

class EventListener implements Listener
Expand All @@ -45,6 +48,7 @@ public function playerJoin(PlayerJoinEvent $event)
RPGForms::welcomeForm($player);
}
$player->restorePlayerVariables();
$player->getInventory()->addItem(new UncommonTierItem(ItemIds::STONE_SWORD, 0, 'Uncommon Sword', ['damage' => 1]));
}
}

Expand Down Expand Up @@ -109,7 +113,7 @@ public function dealDamageEvent(EntityDamageByEntityEvent $event)
if ($damager instanceof RPGPlayer && $receiver instanceof RPGPlayer) {
if (($damager->getParty() != false)){
if($damager->getParty()->playerInThisParty($receiver->getName())){
$event->setCancelled(true);
$event->cancel();
}
}
$coinflip = $damager->getSkill('Coinflip');
Expand Down Expand Up @@ -142,7 +146,7 @@ public function onLevelUp(PlayerExperienceChangeEvent $event)
$spleft = $new_lvl - $old_level;
$player->setSPleft($player->getSPleft() + $spleft);
$player->setHealth($player->getMaxHealth());
$player->setFood($player->getMaxFood());
$player->getHungerManager()->setFood($player->getHungerManager()->getMaxFood());
$player->setAirSupplyTicks($player->getMaxAirSupplyTicks());
if ($player->xplevel == 1){
$player->sendMessage(Utils::parseKeywords(RPGLike::getInstance()->consts, RPGLike::getInstance()->getMessages()->get('level_up_message')));
Expand Down
18 changes: 8 additions & 10 deletions src/TheClimbing/RPGLike/Forms/RPGForms.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

namespace TheClimbing\RPGLike\Forms;

use pocketmine\Player;

use jojoe77777\FormAPI\SimpleForm;

use TheClimbing\RPGLike\Players\RPGPlayer;
Expand Down Expand Up @@ -41,7 +39,7 @@ public static function upgradeStatsForm(RPGPlayer $player)
}
$messages = self::parseMessages($player, 'UpgradeForm', $player->spleft);

$form = new SimpleForm(function (Player $pl, $data) use ($player) {
$form = new SimpleForm(function (RPGPlayer $pl, $data) use ($player) {
switch ($data) {
case "strength":
$player->setSTR($player->getSTR() + 1);
Expand Down Expand Up @@ -79,7 +77,7 @@ public static function upgradeStatsForm(RPGPlayer $player)
public static function skillHelpForm(RPGPlayer $player, ?BaseSkill $skill)
{
$messages = $skill->getMessages()['SkillHelpForm'];
$form = new SimpleForm(function (Player $pl, $data) use ($player) {
$form = new SimpleForm(function (RPGPlayer $pl, $data) use ($player) {
switch ($data) {
case 'Back':
self::skillsHelpForm($player);
Expand All @@ -96,7 +94,7 @@ public static function statsForm(RPGPlayer $player, bool $back = false)
{
$messages = self::parseMessages(($player), 'StatsForm');

$form = new SimpleForm(function (Player $p, $data) use ($player) {
$form = new SimpleForm(function (RPGPlayer $p, $data) use ($player) {
if ($data == 'back') {
self::menuForm($player);
}
Expand All @@ -116,7 +114,7 @@ public static function statsForm(RPGPlayer $player, bool $back = false)
public static function menuForm(RPGPlayer $player)
{
$menuStrings = self::parseMessages($player, 'MenuForm');
$form = new SimpleForm(function (Player $pl, $data) use ($player) {
$form = new SimpleForm(function (RPGPlayer $pl, $data) use ($player) {
switch ($data) {
case "skills":
self::skillsHelpForm($player);
Expand Down Expand Up @@ -145,7 +143,7 @@ public static function skillsHelpForm(RPGPlayer $player)
{
$skills = $player->getSkills();
$messages = self::parseMessages($player, 'SkillsHelpForm');
$form = new SimpleForm(function (Player $pl, $data) use ($skills, $player) {
$form = new SimpleForm(function (RPGPlayer $pl, $data) use ($skills, $player) {
foreach ($skills as $key => $skill) {
if ($key == $data) {
self::skillHelpForm($player, $skill);
Expand All @@ -167,15 +165,15 @@ public static function skillsHelpForm(RPGPlayer $player)
}
public static function welcomeForm(RPGPLayer $player){
$messages = self::parseMessages($player, 'WelcomeForm');
$form = new SimpleForm(function (Player $pl, $data) use ($player){});
$form = new SimpleForm(function (RPGPlayer $pl, $data) use ($player){});
$form->setTitle($messages['title']);
$form->setContent($messages['content']);
$player->sendForm($form);
}
public static function traitsForm(RPGPlayer $player){
$traits = $player->getTraits();
$messages = self::parseMessages($player, 'TraitsForm');
$form = new SimpleForm(function (Player $pl, $data) use ($traits, $player){
$form = new SimpleForm(function (RPGPlayer $pl, $data) use ($traits, $player){
foreach ($traits as $key => $trait) {
if ($key == $data){
self::traitHelpForm($player, $trait);
Expand All @@ -196,7 +194,7 @@ public static function traitsForm(RPGPlayer $player){
}
public static function traitHelpForm(RPGPlayer $player, BaseTrait $trait){
$messages = self::parseMessages($player,'TraitHelpForm');
$form = new SimpleForm(function (Player $pl, $data) use ($player) {
$form = new SimpleForm(function (RPGPlayer $pl, $data) use ($player) {
switch ($data) {
case 'Back':
self::traitsForm($player);
Expand Down
8 changes: 8 additions & 0 deletions src/TheClimbing/RPGLike/ItemSets/BaseSet.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

namespace TheClimbing\RPGLike\ItemSets;

class BaseSet
{

}
45 changes: 45 additions & 0 deletions src/TheClimbing/RPGLike/Items/Armor/BaseCustomArmor.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

namespace TheClimbing\RPGLike\Items\Armor;

use pocketmine\item\Item;
use TheClimbing\RPGLike\RPGLike;

trait BaseCustomArmor
{
public string $item_tier;
public array $lore;
public string $glow_colour;
public array $bonus;
public array $available_bonuses = [
'damage',
'health',
'defense',
'movement_speed',
'mining_speed',
'jump_power',
'mana' //add mana for active skills??
];
public function init(string $item_tier, array $bonus){
$this->item_tier = $item_tier;
if (array_search($bonus[array_key_first($bonus)],$this->available_bonuses) != false){
$this->bonus = $bonus;
}else{
RPGLike::getInstance()->getLogger()->alert('All available bonuses are: damage, health, defense, movement_speed, mining_speed, jump_power, mana');
$this->bonus = ['damage' => 1];
}
}
public function setEnchantGlow(){
$ench = new ListTag(Item::TAG_ENCH, [], NBT::TAG_Compound);
$this->setNamedTagEntry($ench);
}
public function getItemBonus(): array
{
return $this->bonus;
}
public function setCustomLore(string $tier)
{
$lore = RPGLike::getInstance()->getTieredItems()[$tier][$this->getCustomName()];

}
}
Loading